35 return !in_array( strtolower( $str ), array(
'',
'false',
'0',
'no',
'n',
'off', null ) );
53 if ( !empty( $url ) && is_string( $url ) ) {
54 return (
'#' === substr( $url, 0, 1 ) ||
'/' === substr( $url, 0, 1 ) ||
'http' === substr( $url, 0, 4 ) ||
55 false !== strpos( $url,
'?' ) ||
false !== strpos( $url,
'&' ) );
75 _deprecated_function( __FUNCTION__,
'1.2.0',
'WPDKMath::isInfinity()' );
89 if ( defined(
'DOING_AJAX' ) ) {
92 if ( isset( $_SERVER[
'HTTP_X_REQUESTED_WITH'] ) && strtolower( $_SERVER[
'HTTP_X_REQUESTED_WITH'] ) ==
'xmlhttprequest'
113 $parent_obj = get_post( $post->post_parent, ARRAY_A );
114 $parent = (string)$parent;
115 $parent_array = (array)$parent;
117 if ( $parent_obj && isset( $parent_obj[
'ID'] ) ) {
118 if ( in_array( (
string)$parent_obj[
'ID'], $parent_array ) ) {
121 elseif ( in_array( (
string)$parent_obj[
'post_title'], $parent_array ) ) {
124 elseif ( in_array( (
string)$parent_obj[
'post_name'], $parent_array ) ) {
150 return str_replace(
'-',
'_', sanitize_key( $key ) );
162 global $_wp_additional_image_sizes;
163 if ( isset( $_wp_additional_image_sizes[$name] ) ) {
164 return $_wp_additional_image_sizes[$name];
180 if ( is_array( $haystack ) && in_array( $current, $haystack ) ) {
181 $current = $haystack = 1;
183 return checked( $haystack, $current, $echo );
198 _deprecated_function( __FUNCTION__,
'1.2.0',
'WPDKHTMLTagSelect::selected()' );
200 if ( is_array( $haystack ) && in_array( $current, $haystack ) ) {
201 $current = $haystack = 1;
203 return selected( $haystack, $current, $echo );
230 $page = get_page_by_path( $slug, OBJECT, $post_type );
232 if ( is_null( $page ) ) {
233 $page = get_page_by_path( $alternative_slug, OBJECT, $post_type );
235 if ( is_null( $page ) ) {
237 if ( function_exists(
'icl_object_id' ) ) {
239 SELECT ID FROM {$wpdb->posts}
240 WHERE post_name =
'{$slug}'
241 AND post_type =
'{$post_type}'
242 AND post_status =
'publish'
244 $id = $wpdb->get_var( $sql );
245 $id = icl_object_id( $id, $post_type,
true );
255 $page = get_post( $id );
258 return apply_filters(
"the_content", $page->post_content );
277 $page = get_page_by_path( $slug, OBJECT, $post_type );
280 if ( is_null( $page ) ) {
283 if ( function_exists(
'icl_object_id' ) ) {
285 SELECT ID FROM {$wpdb->posts}
286 WHERE post_name =
'{$slug}'
287 AND post_type =
'{$post_type}'
288 AND post_status =
'publish'
290 $id = $wpdb->get_var( $sql );
291 $id = icl_object_id( $id, $post_type,
true );
301 $permalink = get_permalink( $id );
303 return trailingslashit( $permalink );
322 _deprecated_function( __FUNCTION__,
'1.2.0',
'WPDKObject::__delta()' );
337 _deprecated_function( __FUNCTION__,
'1.3.1',
'_WPDKPost::imageContent() or _WPDKPost::imageContentWithID()' );
341 $output = preg_match_all(
'/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', get_post_field(
'post_content', $id_post ), $matches );
342 if ( !empty( $matches ) && is_array( $matches ) && isset( $matches[1][0] ) ) {
343 $display_img = $matches[1][0];
361 _deprecated_function( __FUNCTION__,
'1.3.1',
'_WPDKPost::thumbnail() or _WPDKPost::thumbnailWithID()' );
362 if ( function_exists(
'has_post_thumbnail' ) ) {
363 if ( has_post_thumbnail( $id_post ) ) {
364 $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id_post ),
'full' );
382 _deprecated_function( __FUNCTION__,
'1.3.1',
'_WPDKPost::imageAttachmentsWithID() or _WPDKPost::imageAttachments()' );
383 if ( function_exists(
'wp_get_attachment_image' ) ) {
384 $children = get_children( array(
385 'post_parent' => $id_post,
386 'post_type' =>
'attachment',
388 'post_status' =>
'inherit',
389 'post_mime_type' =>
'image',
391 'orderby' =>
'menu_order ASC'
394 if ( empty( $children ) || !is_array( $children ) ) {
398 $item = current( $children );
400 if ( is_object( $item ) && isset( $item->ID ) ) {
401 $image = wp_get_attachment_image_src( $item->ID,
'full' );
427 _deprecated_function( __FUNCTION__,
'1.2.0',
'WPDKResult::isError()' );
445 _deprecated_function( __FUNCTION__,
'1.2.0',
'WPDKResult::isWarning()' );
463 _deprecated_function( __FUNCTION__,
'1.2.0',
'WPDKResult::isStatus()' );
485 function wpdk_add_page( $page_slug, $page_title, $capability, $function =
'', $hook_head =
'', $hook_load =
'' )
487 global $admin_page_hooks, $_registered_pages, $_parent_pages;
491 if ( !empty( $function ) && current_user_can( $capability ) ) {
492 $page_slug = plugin_basename( $page_slug );
493 $admin_page_hooks[$page_slug] = $page_title;
494 $hookname = get_plugin_page_hookname( $page_slug,
'' );
495 if ( !empty( $hookname ) ) {
496 add_action( $hookname, $function );
497 $_registered_pages[$hookname] =
true;
498 $_parent_pages[$page_slug] =
false;
500 if ( !empty( $hook_head ) ) {
501 add_action(
'admin_head-' . $hookname, $hook_head );
504 if ( !empty( $hook_load ) ) {
505 add_action(
'load-' . $hookname, $hook_load );
527 foreach ( $pages as $slug ) {
528 if ( is_page_template( $slug ) ) {
529 wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
552 if ( empty( $page_templates ) ) {
555 if ( is_string( $page_templates ) ) {
556 $page_templates = array( $page_templates );
558 foreach ( $page_templates as $slug ) {
559 if ( is_page_template( $slug ) ) {
560 wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
589 _deprecated_function( __CLASS__ .
'::' . __FUNCTION__,
'1.3.0',
'WPDKUser::setTransientWithUser()' );
612 _deprecated_function( __CLASS__ .
'::' . __FUNCTION__,
'1.4.8',
'WPDKUser::getTransientWithUser()' );
633 $user_id = is_null( $user_id ) ? get_current_user_id() : $user_id;
635 do_action(
'delete_user_transient_' . $transient, $transient, $user_id );
637 $transient_timeout =
'_transient_timeout_' . $transient;
638 $transient =
'_transient_' . $transient;
639 $result = delete_user_meta( $user_id, $transient );
641 delete_user_meta( $user_id, $transient_timeout );
642 do_action(
'deleted_user_transient', $transient, $user_id );
660 $verb = strtolower( $verb );
661 return ( $verb == strtolower( $_SERVER[
'REQUEST_METHOD'] ) );