Coding Standards: Fix the `Squiz.PHP.DisallowMultipleAssignments` violations in `wp-includes`.
See #47632. Built from https://develop.svn.wordpress.org/trunk@45590 git-svn-id: http://core.svn.wordpress.org/trunk@45401 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
55b2d94cca
commit
4803fc405e
|
@ -688,10 +688,15 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
|
|||
if ( is_admin() ) {
|
||||
$current_screen = get_current_screen();
|
||||
$post = get_post();
|
||||
if ( 'post' == $current_screen->base ) {
|
||||
$post_type_object = get_post_type_object( $post->post_type );
|
||||
} elseif ( 'edit' == $current_screen->base ) {
|
||||
$post_type_object = get_post_type_object( $current_screen->post_type );
|
||||
}
|
||||
|
||||
if ( 'post' == $current_screen->base
|
||||
&& 'add' != $current_screen->action
|
||||
&& ( $post_type_object = get_post_type_object( $post->post_type ) )
|
||||
&& ( $post_type_object )
|
||||
&& current_user_can( 'read_post', $post->ID )
|
||||
&& ( $post_type_object->public )
|
||||
&& ( $post_type_object->show_in_admin_bar ) ) {
|
||||
|
@ -715,7 +720,7 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
|
|||
);
|
||||
}
|
||||
} elseif ( 'edit' == $current_screen->base
|
||||
&& ( $post_type_object = get_post_type_object( $current_screen->post_type ) )
|
||||
&& ( $post_type_object )
|
||||
&& ( $post_type_object->public )
|
||||
&& ( $post_type_object->show_in_admin_bar )
|
||||
&& ( get_post_type_archive_link( $post_type_object->name ) )
|
||||
|
@ -727,29 +732,29 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
|
|||
'href' => get_post_type_archive_link( $current_screen->post_type ),
|
||||
)
|
||||
);
|
||||
} elseif ( 'term' == $current_screen->base
|
||||
&& isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag )
|
||||
&& ( $tax = get_taxonomy( $tag->taxonomy ) )
|
||||
&& is_taxonomy_viewable( $tax ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
array(
|
||||
'id' => 'view',
|
||||
'title' => $tax->labels->view_item,
|
||||
'href' => get_term_link( $tag ),
|
||||
)
|
||||
);
|
||||
} elseif ( 'user-edit' == $current_screen->base
|
||||
&& isset( $user_id )
|
||||
&& ( $user_object = get_userdata( $user_id ) )
|
||||
&& $user_object->exists()
|
||||
&& $view_link = get_author_posts_url( $user_object->ID ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
array(
|
||||
'id' => 'view',
|
||||
'title' => __( 'View User' ),
|
||||
'href' => $view_link,
|
||||
)
|
||||
);
|
||||
} elseif ( 'term' == $current_screen->base && isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag ) ) {
|
||||
$tax = get_taxonomy( $tag->taxonomy );
|
||||
if ( is_taxonomy_viewable( $tax ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
array(
|
||||
'id' => 'view',
|
||||
'title' => $tax->labels->view_item,
|
||||
'href' => get_term_link( $tag ),
|
||||
)
|
||||
);
|
||||
}
|
||||
} elseif ( 'user-edit' == $current_screen->base && isset( $user_id ) ) {
|
||||
$user_object = get_userdata( $user_id );
|
||||
$view_link = get_author_posts_url( $user_object->ID );
|
||||
if ( $user_object->exists() && $view_link ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
array(
|
||||
'id' => 'view',
|
||||
'title' => __( 'View User' ),
|
||||
'href' => $view_link,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$current_object = $wp_the_query->get_queried_object();
|
||||
|
@ -758,39 +763,44 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ( ! empty( $current_object->post_type )
|
||||
&& ( $post_type_object = get_post_type_object( $current_object->post_type ) )
|
||||
&& current_user_can( 'edit_post', $current_object->ID )
|
||||
&& $post_type_object->show_in_admin_bar
|
||||
&& $edit_post_link = get_edit_post_link( $current_object->ID ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
array(
|
||||
'id' => 'edit',
|
||||
'title' => $post_type_object->labels->edit_item,
|
||||
'href' => $edit_post_link,
|
||||
)
|
||||
);
|
||||
} elseif ( ! empty( $current_object->taxonomy )
|
||||
&& ( $tax = get_taxonomy( $current_object->taxonomy ) )
|
||||
&& current_user_can( 'edit_term', $current_object->term_id )
|
||||
&& $edit_term_link = get_edit_term_link( $current_object->term_id, $current_object->taxonomy ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
array(
|
||||
'id' => 'edit',
|
||||
'title' => $tax->labels->edit_item,
|
||||
'href' => $edit_term_link,
|
||||
)
|
||||
);
|
||||
} elseif ( is_a( $current_object, 'WP_User' )
|
||||
&& current_user_can( 'edit_user', $current_object->ID )
|
||||
&& $edit_user_link = get_edit_user_link( $current_object->ID ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
array(
|
||||
'id' => 'edit',
|
||||
'title' => __( 'Edit User' ),
|
||||
'href' => $edit_user_link,
|
||||
)
|
||||
);
|
||||
if ( ! empty( $current_object->post_type ) ) {
|
||||
$post_type_object = get_post_type_object( $current_object->post_type );
|
||||
$edit_post_link = get_edit_post_link( $current_object->ID );
|
||||
if ( $post_type_object
|
||||
&& $edit_post_link
|
||||
&& current_user_can( 'edit_post', $current_object->ID )
|
||||
&& $post_type_object->show_in_admin_bar ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
array(
|
||||
'id' => 'edit',
|
||||
'title' => $post_type_object->labels->edit_item,
|
||||
'href' => $edit_post_link,
|
||||
)
|
||||
);
|
||||
}
|
||||
} elseif ( ! empty( $current_object->taxonomy ) ) {
|
||||
$tax = get_taxonomy( $current_object->taxonomy );
|
||||
$edit_term_link = get_edit_term_link( $current_object->term_id, $current_object->taxonomy );
|
||||
if ( $tax && $edit_term_link && current_user_can( 'edit_term', $current_object->term_id ) ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
array(
|
||||
'id' => 'edit',
|
||||
'title' => $tax->labels->edit_item,
|
||||
'href' => $edit_term_link,
|
||||
)
|
||||
);
|
||||
}
|
||||
} elseif ( is_a( $current_object, 'WP_User' ) && current_user_can( 'edit_user', $current_object->ID ) ) {
|
||||
$edit_user_link = get_edit_user_link( $current_object->ID );
|
||||
if ( $edit_user_link ) {
|
||||
$wp_admin_bar->add_menu(
|
||||
array(
|
||||
'id' => 'edit',
|
||||
'title' => __( 'Edit User' ),
|
||||
'href' => $edit_user_link,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -541,7 +541,8 @@ function wp_list_authors( $args = '' ) {
|
|||
function is_multi_author() {
|
||||
global $wpdb;
|
||||
|
||||
if ( false === ( $is_multi_author = get_transient( 'is_multi_author' ) ) ) {
|
||||
$is_multi_author = get_transient( 'is_multi_author' );
|
||||
if ( false === $is_multi_author ) {
|
||||
$rows = (array) $wpdb->get_col( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 2" );
|
||||
$is_multi_author = 1 < count( $rows ) ? 1 : 0;
|
||||
set_transient( 'is_multi_author', $is_multi_author );
|
||||
|
|
|
@ -34,11 +34,14 @@ function get_bookmark( $bookmark, $output = OBJECT, $filter = 'raw' ) {
|
|||
} else {
|
||||
if ( isset( $GLOBALS['link'] ) && ( $GLOBALS['link']->link_id == $bookmark ) ) {
|
||||
$_bookmark = & $GLOBALS['link'];
|
||||
} elseif ( ! $_bookmark = wp_cache_get( $bookmark, 'bookmark' ) ) {
|
||||
$_bookmark = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->links WHERE link_id = %d LIMIT 1", $bookmark ) );
|
||||
if ( $_bookmark ) {
|
||||
$_bookmark->link_category = array_unique( wp_get_object_terms( $_bookmark->link_id, 'link_category', array( 'fields' => 'ids' ) ) );
|
||||
wp_cache_add( $_bookmark->link_id, $_bookmark, 'bookmark' );
|
||||
} else {
|
||||
$_bookmark = wp_cache_get( $bookmark, 'bookmark' );
|
||||
if ( ! $_bookmark ) {
|
||||
$_bookmark = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->links WHERE link_id = %d LIMIT 1", $bookmark ) );
|
||||
if ( $_bookmark ) {
|
||||
$_bookmark->link_category = array_unique( wp_get_object_terms( $_bookmark->link_id, 'link_category', array( 'fields' => 'ids' ) ) );
|
||||
wp_cache_add( $_bookmark->link_id, $_bookmark, 'bookmark' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,8 +142,8 @@ function get_bookmarks( $args = '' ) {
|
|||
$r = wp_parse_args( $args, $defaults );
|
||||
|
||||
$key = md5( serialize( $r ) );
|
||||
$cache = false;
|
||||
if ( 'rand' !== $r['orderby'] && $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) ) {
|
||||
$cache = wp_cache_get( 'get_bookmarks', 'bookmark' );
|
||||
if ( 'rand' !== $r['orderby'] && $cache ) {
|
||||
if ( is_array( $cache ) && isset( $cache[ $key ] ) ) {
|
||||
$bookmarks = $cache[ $key ];
|
||||
/**
|
||||
|
@ -204,7 +207,8 @@ function get_bookmarks( $args = '' ) {
|
|||
}
|
||||
|
||||
if ( ! empty( $r['category_name'] ) ) {
|
||||
if ( $r['category'] = get_term_by( 'name', $r['category_name'], 'link_category' ) ) {
|
||||
$r['category'] = get_term_by( 'name', $r['category_name'], 'link_category' );
|
||||
if ( $r['category'] ) {
|
||||
$r['category'] = $r['category']->term_id;
|
||||
} else {
|
||||
$cache[ $key ] = array();
|
||||
|
|
|
@ -93,23 +93,28 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
|
|||
$redirect['query'] = remove_query_arg( 'preview', $redirect['query'] );
|
||||
}
|
||||
|
||||
if ( is_feed() && ( $id = get_query_var( 'p' ) ) ) {
|
||||
if ( $redirect_url = get_post_comments_feed_link( $id, get_query_var( 'feed' ) ) ) {
|
||||
$id = get_query_var( 'p' );
|
||||
|
||||
if ( is_feed() && $id ) {
|
||||
$redirect_url = get_post_comments_feed_link( $id, get_query_var( 'feed' ) );
|
||||
if ( $redirect_url ) {
|
||||
$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type', 'feed' ), $redirect_url );
|
||||
$redirect['path'] = parse_url( $redirect_url, PHP_URL_PATH );
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_singular() && 1 > $wp_query->post_count && ( $id = get_query_var( 'p' ) ) ) {
|
||||
if ( is_singular() && 1 > $wp_query->post_count && $id ) {
|
||||
|
||||
$vars = $wpdb->get_results( $wpdb->prepare( "SELECT post_type, post_parent FROM $wpdb->posts WHERE ID = %d", $id ) );
|
||||
|
||||
if ( isset( $vars[0] ) && $vars = $vars[0] ) {
|
||||
if ( ! empty( $vars[0] ) ) {
|
||||
$vars = $vars[0];
|
||||
if ( 'revision' == $vars->post_type && $vars->post_parent > 0 ) {
|
||||
$id = $vars->post_parent;
|
||||
}
|
||||
|
||||
if ( $redirect_url = get_permalink( $id ) ) {
|
||||
$redirect_url = get_permalink( $id );
|
||||
if ( $redirect_url ) {
|
||||
$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url );
|
||||
}
|
||||
}
|
||||
|
@ -119,8 +124,9 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
|
|||
if ( is_404() ) {
|
||||
|
||||
// Redirect ?page_id, ?p=, ?attachment_id= to their respective url's
|
||||
$id = max( get_query_var( 'p' ), get_query_var( 'page_id' ), get_query_var( 'attachment_id' ) );
|
||||
if ( $id && $redirect_post = get_post( $id ) ) {
|
||||
$id = max( get_query_var( 'p' ), get_query_var( 'page_id' ), get_query_var( 'attachment_id' ) );
|
||||
$redirect_post = $id ? get_post( $id ) : false;
|
||||
if ( $redirect_post ) {
|
||||
$post_type_obj = get_post_type_object( $redirect_post->post_type );
|
||||
if ( $post_type_obj->public && 'auto-draft' != $redirect_post->post_status ) {
|
||||
$redirect_url = get_permalink( $redirect_post );
|
||||
|
@ -143,7 +149,8 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
|
|||
}
|
||||
|
||||
if ( ! $redirect_url ) {
|
||||
if ( $redirect_url = redirect_guess_404_permalink() ) {
|
||||
$redirect_url = redirect_guess_404_permalink();
|
||||
if ( $redirect_url ) {
|
||||
$redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'page', 'feed', 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url );
|
||||
}
|
||||
}
|
||||
|
@ -168,21 +175,25 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
|
|||
$redirect_url = get_attachment_link();
|
||||
}
|
||||
} elseif ( is_single() && ! empty( $_GET['p'] ) && ! $redirect_url ) {
|
||||
if ( $redirect_url = get_permalink( get_query_var( 'p' ) ) ) {
|
||||
$redirect_url = get_permalink( get_query_var( 'p' ) );
|
||||
if ( $redirect_url ) {
|
||||
$redirect['query'] = remove_query_arg( array( 'p', 'post_type' ), $redirect['query'] );
|
||||
}
|
||||
} elseif ( is_single() && ! empty( $_GET['name'] ) && ! $redirect_url ) {
|
||||
if ( $redirect_url = get_permalink( $wp_query->get_queried_object_id() ) ) {
|
||||
$redirect_url = get_permalink( $wp_query->get_queried_object_id() );
|
||||
if ( $redirect_url ) {
|
||||
$redirect['query'] = remove_query_arg( 'name', $redirect['query'] );
|
||||
}
|
||||
} elseif ( is_page() && ! empty( $_GET['page_id'] ) && ! $redirect_url ) {
|
||||
if ( $redirect_url = get_permalink( get_query_var( 'page_id' ) ) ) {
|
||||
$redirect_url = get_permalink( get_query_var( 'page_id' ) );
|
||||
if ( $redirect_url ) {
|
||||
$redirect['query'] = remove_query_arg( 'page_id', $redirect['query'] );
|
||||
}
|
||||
} elseif ( is_page() && ! is_feed() && 'page' == get_option( 'show_on_front' ) && get_queried_object_id() == get_option( 'page_on_front' ) && ! $redirect_url ) {
|
||||
$redirect_url = home_url( '/' );
|
||||
} elseif ( is_home() && ! empty( $_GET['page_id'] ) && 'page' == get_option( 'show_on_front' ) && get_query_var( 'page_id' ) == get_option( 'page_for_posts' ) && ! $redirect_url ) {
|
||||
if ( $redirect_url = get_permalink( get_option( 'page_for_posts' ) ) ) {
|
||||
$redirect_url = get_permalink( get_option( 'page_for_posts' ) );
|
||||
if ( $redirect_url ) {
|
||||
$redirect['query'] = remove_query_arg( 'page_id', $redirect['query'] );
|
||||
}
|
||||
} elseif ( ! empty( $_GET['m'] ) && ( is_year() || is_month() || is_day() ) ) {
|
||||
|
@ -203,21 +214,25 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
|
|||
}
|
||||
// now moving on to non ?m=X year/month/day links
|
||||
} elseif ( is_day() && get_query_var( 'year' ) && get_query_var( 'monthnum' ) && ! empty( $_GET['day'] ) ) {
|
||||
if ( $redirect_url = get_day_link( get_query_var( 'year' ), get_query_var( 'monthnum' ), get_query_var( 'day' ) ) ) {
|
||||
$redirect_url = get_day_link( get_query_var( 'year' ), get_query_var( 'monthnum' ), get_query_var( 'day' ) );
|
||||
if ( $redirect_url ) {
|
||||
$redirect['query'] = remove_query_arg( array( 'year', 'monthnum', 'day' ), $redirect['query'] );
|
||||
}
|
||||
} elseif ( is_month() && get_query_var( 'year' ) && ! empty( $_GET['monthnum'] ) ) {
|
||||
if ( $redirect_url = get_month_link( get_query_var( 'year' ), get_query_var( 'monthnum' ) ) ) {
|
||||
$redirect_url = get_month_link( get_query_var( 'year' ), get_query_var( 'monthnum' ) );
|
||||
if ( $redirect_url ) {
|
||||
$redirect['query'] = remove_query_arg( array( 'year', 'monthnum' ), $redirect['query'] );
|
||||
}
|
||||
} elseif ( is_year() && ! empty( $_GET['year'] ) ) {
|
||||
if ( $redirect_url = get_year_link( get_query_var( 'year' ) ) ) {
|
||||
$redirect_url = get_year_link( get_query_var( 'year' ) );
|
||||
if ( $redirect_url ) {
|
||||
$redirect['query'] = remove_query_arg( 'year', $redirect['query'] );
|
||||
}
|
||||
} elseif ( is_author() && ! empty( $_GET['author'] ) && preg_match( '|^[0-9]+$|', $_GET['author'] ) ) {
|
||||
$author = get_userdata( get_query_var( 'author' ) );
|
||||
if ( ( false !== $author ) && $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_author = %d AND $wpdb->posts.post_status = 'publish' LIMIT 1", $author->ID ) ) ) {
|
||||
if ( $redirect_url = get_author_posts_url( $author->ID, $author->user_nicename ) ) {
|
||||
$redirect_url = get_author_posts_url( $author->ID, $author->user_nicename );
|
||||
if ( $redirect_url ) {
|
||||
$redirect['query'] = remove_query_arg( 'author', $redirect['query'] );
|
||||
}
|
||||
}
|
||||
|
@ -229,49 +244,55 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
|
|||
}
|
||||
|
||||
$obj = $wp_query->get_queried_object();
|
||||
if ( $term_count <= 1 && ! empty( $obj->term_id ) && ( $tax_url = get_term_link( (int) $obj->term_id, $obj->taxonomy ) ) && ! is_wp_error( $tax_url ) ) {
|
||||
if ( ! empty( $redirect['query'] ) ) {
|
||||
// Strip taxonomy query vars off the url.
|
||||
$qv_remove = array( 'term', 'taxonomy' );
|
||||
if ( is_category() ) {
|
||||
$qv_remove[] = 'category_name';
|
||||
$qv_remove[] = 'cat';
|
||||
} elseif ( is_tag() ) {
|
||||
$qv_remove[] = 'tag';
|
||||
$qv_remove[] = 'tag_id';
|
||||
} else { // Custom taxonomies will have a custom query var, remove those too:
|
||||
$tax_obj = get_taxonomy( $obj->taxonomy );
|
||||
if ( false !== $tax_obj->query_var ) {
|
||||
$qv_remove[] = $tax_obj->query_var;
|
||||
if ( $term_count <= 1 && ! empty( $obj->term_id ) ) {
|
||||
$tax_url = get_term_link( (int) $obj->term_id, $obj->taxonomy );
|
||||
if ( $tax_url && ! is_wp_error( $tax_url ) ) {
|
||||
if ( ! empty( $redirect['query'] ) ) {
|
||||
// Strip taxonomy query vars off the url.
|
||||
$qv_remove = array( 'term', 'taxonomy' );
|
||||
if ( is_category() ) {
|
||||
$qv_remove[] = 'category_name';
|
||||
$qv_remove[] = 'cat';
|
||||
} elseif ( is_tag() ) {
|
||||
$qv_remove[] = 'tag';
|
||||
$qv_remove[] = 'tag_id';
|
||||
} else { // Custom taxonomies will have a custom query var, remove those too:
|
||||
$tax_obj = get_taxonomy( $obj->taxonomy );
|
||||
if ( false !== $tax_obj->query_var ) {
|
||||
$qv_remove[] = $tax_obj->query_var;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rewrite_vars = array_diff( array_keys( $wp_query->query ), array_keys( $_GET ) );
|
||||
$rewrite_vars = array_diff( array_keys( $wp_query->query ), array_keys( $_GET ) );
|
||||
|
||||
if ( ! array_diff( $rewrite_vars, array_keys( $_GET ) ) ) { // Check to see if all the Query vars are coming from the rewrite, none are set via $_GET
|
||||
$redirect['query'] = remove_query_arg( $qv_remove, $redirect['query'] ); //Remove all of the per-tax qv's
|
||||
if ( ! array_diff( $rewrite_vars, array_keys( $_GET ) ) ) { // Check to see if all the Query vars are coming from the rewrite, none are set via $_GET
|
||||
$redirect['query'] = remove_query_arg( $qv_remove, $redirect['query'] ); //Remove all of the per-tax qv's
|
||||
|
||||
// Create the destination url for this taxonomy
|
||||
$tax_url = parse_url( $tax_url );
|
||||
if ( ! empty( $tax_url['query'] ) ) { // Taxonomy accessible via ?taxonomy=..&term=.. or any custom qv..
|
||||
parse_str( $tax_url['query'], $query_vars );
|
||||
$redirect['query'] = add_query_arg( $query_vars, $redirect['query'] );
|
||||
} else { // Taxonomy is accessible via a "pretty-URL"
|
||||
$redirect['path'] = $tax_url['path'];
|
||||
}
|
||||
} else { // Some query vars are set via $_GET. Unset those from $_GET that exist via the rewrite
|
||||
foreach ( $qv_remove as $_qv ) {
|
||||
if ( isset( $rewrite_vars[ $_qv ] ) ) {
|
||||
$redirect['query'] = remove_query_arg( $_qv, $redirect['query'] );
|
||||
// Create the destination url for this taxonomy
|
||||
$tax_url = parse_url( $tax_url );
|
||||
if ( ! empty( $tax_url['query'] ) ) { // Taxonomy accessible via ?taxonomy=..&term=.. or any custom qv..
|
||||
parse_str( $tax_url['query'], $query_vars );
|
||||
$redirect['query'] = add_query_arg( $query_vars, $redirect['query'] );
|
||||
} else { // Taxonomy is accessible via a "pretty-URL"
|
||||
$redirect['path'] = $tax_url['path'];
|
||||
}
|
||||
} else { // Some query vars are set via $_GET. Unset those from $_GET that exist via the rewrite
|
||||
foreach ( $qv_remove as $_qv ) {
|
||||
if ( isset( $rewrite_vars[ $_qv ] ) ) {
|
||||
$redirect['query'] = remove_query_arg( $_qv, $redirect['query'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ( is_single() && strpos( $wp_rewrite->permalink_structure, '%category%' ) !== false && $cat = get_query_var( 'category_name' ) ) {
|
||||
$category = get_category_by_path( $cat );
|
||||
if ( ( ! $category || is_wp_error( $category ) ) || ! has_term( $category->term_id, 'category', $wp_query->get_queried_object_id() ) ) {
|
||||
$redirect_url = get_permalink( $wp_query->get_queried_object_id() );
|
||||
} elseif ( is_single() && strpos( $wp_rewrite->permalink_structure, '%category%' ) !== false ) {
|
||||
$cat = get_query_var( 'category_name' );
|
||||
if ( $cat ) {
|
||||
$category = get_category_by_path( $cat );
|
||||
if ( ( ! $category || is_wp_error( $category ) ) || ! has_term( $category->term_id, 'category', $wp_query->get_queried_object_id() ) ) {
|
||||
$redirect_url = get_permalink( $wp_query->get_queried_object_id() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -727,7 +727,8 @@ function current_user_can_for_blog( $blog_id, $capability ) {
|
|||
* @return bool Whether the post author has the given capability.
|
||||
*/
|
||||
function author_can( $post, $capability ) {
|
||||
if ( ! $post = get_post( $post ) ) {
|
||||
$post = get_post( $post );
|
||||
if ( ! $post ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -966,7 +967,8 @@ function revoke_super_admin( $user_id ) {
|
|||
|
||||
$user = get_userdata( $user_id );
|
||||
if ( $user && 0 !== strcasecmp( $user->user_email, get_site_option( 'admin_email' ) ) ) {
|
||||
if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) {
|
||||
$key = array_search( $user->user_login, $super_admins );
|
||||
if ( false !== $key ) {
|
||||
unset( $super_admins[ $key ] );
|
||||
update_site_option( 'site_admins', $super_admins );
|
||||
|
||||
|
|
|
@ -1223,7 +1223,8 @@ function term_description( $term = 0, $deprecated = null ) {
|
|||
* or the post does not exist, WP_Error on failure.
|
||||
*/
|
||||
function get_the_terms( $post, $taxonomy ) {
|
||||
if ( ! $post = get_post( $post ) ) {
|
||||
$post = get_post( $post );
|
||||
if ( ! $post ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,8 @@ function get_categories( $args = '' ) {
|
|||
'<code>taxonomy => link_category</code>'
|
||||
)
|
||||
);
|
||||
$taxonomy = $args['taxonomy'] = 'link_category';
|
||||
$taxonomy = 'link_category';
|
||||
$args['taxonomy'] = $taxonomy;
|
||||
}
|
||||
|
||||
$categories = get_terms( $taxonomy, $args );
|
||||
|
|
|
@ -926,11 +926,13 @@ class WP_Http {
|
|||
return $maybe_relative_path;
|
||||
}
|
||||
|
||||
if ( ! $url_parts = wp_parse_url( $url ) ) {
|
||||
$url_parts = wp_parse_url( $url );
|
||||
if ( ! $url_parts ) {
|
||||
return $maybe_relative_path;
|
||||
}
|
||||
|
||||
if ( ! $relative_url_parts = wp_parse_url( $maybe_relative_path ) ) {
|
||||
$relative_url_parts = wp_parse_url( $maybe_relative_path );
|
||||
if ( ! $relative_url_parts ) {
|
||||
return $maybe_relative_path;
|
||||
}
|
||||
|
||||
|
|
|
@ -440,7 +440,8 @@ class WP_oEmbed {
|
|||
|
||||
// Fetch URL content
|
||||
$request = wp_safe_remote_get( $url, $args );
|
||||
if ( $html = wp_remote_retrieve_body( $request ) ) {
|
||||
$html = wp_remote_retrieve_body( $request );
|
||||
if ( $html ) {
|
||||
|
||||
/**
|
||||
* Filters the link types that contain oEmbed provider URLs.
|
||||
|
@ -461,7 +462,8 @@ class WP_oEmbed {
|
|||
);
|
||||
|
||||
// Strip <body>
|
||||
if ( $html_head_end = stripos( $html, '</head>' ) ) {
|
||||
$html_head_end = stripos( $html, '</head>' );
|
||||
if ( $html_head_end ) {
|
||||
$html = substr( $html, 0, $html_head_end );
|
||||
}
|
||||
|
||||
|
@ -559,7 +561,8 @@ class WP_oEmbed {
|
|||
if ( 501 == wp_remote_retrieve_response_code( $response ) ) {
|
||||
return new WP_Error( 'not-implemented' );
|
||||
}
|
||||
if ( ! $body = wp_remote_retrieve_body( $response ) ) {
|
||||
$body = wp_remote_retrieve_body( $response );
|
||||
if ( ! $body ) {
|
||||
return false;
|
||||
}
|
||||
$parse_method = "_parse_$format";
|
||||
|
|
|
@ -144,7 +144,8 @@ class WP_Admin_Bar {
|
|||
);
|
||||
|
||||
// If the node already exists, keep any data that isn't provided.
|
||||
if ( $maybe_defaults = $this->get_node( $args['id'] ) ) {
|
||||
$maybe_defaults = $this->get_node( $args['id'] );
|
||||
if ( $maybe_defaults ) {
|
||||
$defaults = get_object_vars( $maybe_defaults );
|
||||
}
|
||||
|
||||
|
@ -183,7 +184,8 @@ class WP_Admin_Bar {
|
|||
* @return object Node.
|
||||
*/
|
||||
final public function get_node( $id ) {
|
||||
if ( $node = $this->_get_node( $id ) ) {
|
||||
$node = $this->_get_node( $id );
|
||||
if ( $node ) {
|
||||
return clone $node;
|
||||
}
|
||||
}
|
||||
|
@ -210,7 +212,8 @@ class WP_Admin_Bar {
|
|||
* @return array|void
|
||||
*/
|
||||
final public function get_nodes() {
|
||||
if ( ! $nodes = $this->_get_nodes() ) {
|
||||
$nodes = $this->_get_nodes();
|
||||
if ( ! $nodes ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -312,7 +315,8 @@ class WP_Admin_Bar {
|
|||
}
|
||||
|
||||
// Fetch the parent node. If it isn't registered, ignore the node.
|
||||
if ( ! $parent = $this->_get_node( $node->parent ) ) {
|
||||
$parent = $this->_get_node( $node->parent );
|
||||
if ( ! $parent ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,8 +90,9 @@ class WP_Ajax_Response {
|
|||
$response = '';
|
||||
if ( is_wp_error( $data ) ) {
|
||||
foreach ( (array) $data->get_error_codes() as $code ) {
|
||||
$response .= "<wp_error code='$code'><![CDATA[" . $data->get_error_message( $code ) . ']]></wp_error>';
|
||||
if ( ! $error_data = $data->get_error_data( $code ) ) {
|
||||
$response .= "<wp_error code='$code'><![CDATA[" . $data->get_error_message( $code ) . ']]></wp_error>';
|
||||
$error_data = $data->get_error_data( $code );
|
||||
if ( ! $error_data ) {
|
||||
continue;
|
||||
}
|
||||
$class = '';
|
||||
|
|
|
@ -429,7 +429,8 @@ class WP_Comment_Query {
|
|||
// Fetch full comment objects from the primed cache.
|
||||
$_comments = array();
|
||||
foreach ( $comment_ids as $comment_id ) {
|
||||
if ( $_comment = get_comment( $comment_id ) ) {
|
||||
$_comment = get_comment( $comment_id );
|
||||
if ( $_comment ) {
|
||||
$_comments[] = $_comment;
|
||||
}
|
||||
}
|
||||
|
@ -950,8 +951,9 @@ class WP_Comment_Query {
|
|||
$exclude_keys = array( 'parent', 'parent__in', 'parent__not_in' );
|
||||
do {
|
||||
// Parent-child relationships may be cached. Only query for those that are not.
|
||||
$child_ids = $uncached_parent_ids = array();
|
||||
$_parent_ids = $levels[ $level ];
|
||||
$child_ids = array();
|
||||
$uncached_parent_ids = array();
|
||||
$_parent_ids = $levels[ $level ];
|
||||
foreach ( $_parent_ids as $parent_id ) {
|
||||
$cache_key = "get_comment_child_ids:$parent_id:$key:$last_changed";
|
||||
$parent_child_ids = wp_cache_get( $cache_key, 'comment' );
|
||||
|
@ -1009,7 +1011,8 @@ class WP_Comment_Query {
|
|||
|
||||
// If a threaded representation was requested, build the tree.
|
||||
if ( 'threaded' === $this->query_vars['hierarchical'] ) {
|
||||
$threaded_comments = $ref = array();
|
||||
$threaded_comments = array();
|
||||
$ref = array();
|
||||
foreach ( $all_comments as $k => $c ) {
|
||||
$_c = get_comment( $c->comment_ID );
|
||||
|
||||
|
|
|
@ -1438,11 +1438,13 @@ final class WP_Customize_Widgets {
|
|||
$value = array();
|
||||
$value[ $parsed_id['number'] ] = $instance;
|
||||
$key = 'widget-' . $parsed_id['id_base'];
|
||||
$_REQUEST[ $key ] = $_POST[ $key ] = wp_slash( $value );
|
||||
$_REQUEST[ $key ] = wp_slash( $value );
|
||||
$_POST[ $key ] = $_REQUEST[ $key ];
|
||||
$added_input_vars[] = $key;
|
||||
} else {
|
||||
foreach ( $instance as $key => $value ) {
|
||||
$_REQUEST[ $key ] = $_POST[ $key ] = wp_slash( $value );
|
||||
$_REQUEST[ $key ] = wp_slash( $value );
|
||||
$_POST[ $key ] = $_REQUEST[ $key ];
|
||||
$added_input_vars[] = $key;
|
||||
}
|
||||
}
|
||||
|
@ -1856,8 +1858,9 @@ final class WP_Customize_Widgets {
|
|||
|
||||
// Render the widget.
|
||||
ob_start();
|
||||
dynamic_sidebar( $this->rendering_sidebar_id = $context['sidebar_id'] );
|
||||
$container = ob_get_clean();
|
||||
$this->rendering_sidebar_id = $context['sidebar_id'];
|
||||
dynamic_sidebar( $this->rendering_sidebar_id );
|
||||
$container = ob_get_clean();
|
||||
|
||||
// Reset variables for next partial render.
|
||||
remove_filter( 'sidebars_widgets', $filter_callback, 1000 );
|
||||
|
|
|
@ -158,7 +158,8 @@ final class _WP_Editors {
|
|||
$editor_class = ' class="' . trim( esc_attr( $set['editor_class'] ) . ' wp-editor-area' ) . '"';
|
||||
$tabindex = $set['tabindex'] ? ' tabindex="' . (int) $set['tabindex'] . '"' : '';
|
||||
$default_editor = 'html';
|
||||
$buttons = $autocomplete = '';
|
||||
$buttons = '';
|
||||
$autocomplete = '';
|
||||
$editor_id_attr = esc_attr( $editor_id );
|
||||
|
||||
if ( $set['drag_drop_upload'] ) {
|
||||
|
@ -437,7 +438,8 @@ final class _WP_Editors {
|
|||
*/
|
||||
$plugins = array_unique( apply_filters( 'tiny_mce_plugins', $plugins ) );
|
||||
|
||||
if ( ( $key = array_search( 'spellchecker', $plugins ) ) !== false ) {
|
||||
$key = array_search( 'spellchecker', $plugins );
|
||||
if ( false !== $key ) {
|
||||
// Remove 'spellchecker' from the internal plugins if added with 'tiny_mce_plugins' filter to prevent errors.
|
||||
// It can be added with 'mce_external_plugins'.
|
||||
unset( $plugins[ $key ] );
|
||||
|
@ -581,7 +583,9 @@ final class _WP_Editors {
|
|||
* @param string $editor_id Unique editor identifier, e.g. 'content'.
|
||||
*/
|
||||
$mce_buttons = apply_filters( 'teeny_mce_buttons', array( 'bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist', 'numlist', 'alignleft', 'aligncenter', 'alignright', 'undo', 'redo', 'link', 'fullscreen' ), $editor_id );
|
||||
$mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = array();
|
||||
$mce_buttons_2 = array();
|
||||
$mce_buttons_3 = array();
|
||||
$mce_buttons_4 = array();
|
||||
} else {
|
||||
$mce_buttons = array( 'formatselect', 'bold', 'italic', 'bullist', 'numlist', 'blockquote', 'alignleft', 'aligncenter', 'alignright', 'link', 'wp_more', 'spellchecker' );
|
||||
|
||||
|
@ -646,7 +650,8 @@ final class _WP_Editors {
|
|||
|
||||
$body_class = $editor_id;
|
||||
|
||||
if ( $post = get_post() ) {
|
||||
$post = get_post();
|
||||
if ( $post ) {
|
||||
$body_class .= ' post-type-' . sanitize_html_class( $post->post_type ) . ' post-status-' . sanitize_html_class( $post->post_status );
|
||||
|
||||
if ( post_type_supports( $post->post_type, 'post-formats' ) ) {
|
||||
|
@ -1460,7 +1465,8 @@ final class _WP_Editors {
|
|||
global $tinymce_version;
|
||||
|
||||
$tmce_on = ! empty( self::$mce_settings );
|
||||
$mceInit = $qtInit = '';
|
||||
$mceInit = '';
|
||||
$qtInit = '';
|
||||
|
||||
if ( $tmce_on ) {
|
||||
foreach ( self::$mce_settings as $editor_id => $init ) {
|
||||
|
|
|
@ -170,7 +170,8 @@ class WP_Embed {
|
|||
foreach ( $this->handlers as $priority => $handlers ) {
|
||||
foreach ( $handlers as $id => $handler ) {
|
||||
if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) {
|
||||
if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) ) {
|
||||
$return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr );
|
||||
if ( false !== $return ) {
|
||||
/**
|
||||
* Filters the returned embed handler.
|
||||
*
|
||||
|
|
|
@ -272,7 +272,8 @@ final class WP_Hook implements Iterator, ArrayAccess {
|
|||
$num_args = count( $args );
|
||||
|
||||
do {
|
||||
$this->current_priority[ $nesting_level ] = $priority = current( $this->iterations[ $nesting_level ] );
|
||||
$this->current_priority[ $nesting_level ] = current( $this->iterations[ $nesting_level ] );
|
||||
$priority = $this->current_priority[ $nesting_level ];
|
||||
|
||||
foreach ( $this->callbacks[ $priority ] as $the_ ) {
|
||||
if ( ! $this->doing_action ) {
|
||||
|
|
|
@ -235,7 +235,8 @@ class WP_Http_Curl {
|
|||
if ( ! $r['blocking'] ) {
|
||||
curl_exec( $handle );
|
||||
|
||||
if ( $curl_error = curl_error( $handle ) ) {
|
||||
$curl_error = curl_error( $handle );
|
||||
if ( $curl_error ) {
|
||||
curl_close( $handle );
|
||||
return new WP_Error( 'http_request_failed', $curl_error );
|
||||
}
|
||||
|
@ -281,7 +282,8 @@ class WP_Http_Curl {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if ( $curl_error = curl_error( $handle ) ) {
|
||||
$curl_error = curl_error( $handle );
|
||||
if ( $curl_error ) {
|
||||
curl_close( $handle );
|
||||
return new WP_Error( 'http_request_failed', $curl_error );
|
||||
}
|
||||
|
@ -307,7 +309,8 @@ class WP_Http_Curl {
|
|||
);
|
||||
|
||||
// Handle redirects.
|
||||
if ( false !== ( $redirect_response = WP_HTTP::handle_redirects( $url, $r, $response ) ) ) {
|
||||
$redirect_response = WP_HTTP::handle_redirects( $url, $r, $response );
|
||||
if ( false !== $redirect_response ) {
|
||||
return $redirect_response;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,15 +52,18 @@ class WP_Http_Encoding {
|
|||
return $compressed;
|
||||
}
|
||||
|
||||
if ( false !== ( $decompressed = @gzinflate( $compressed ) ) ) {
|
||||
$decompressed = @gzinflate( $compressed );
|
||||
if ( false !== $decompressed ) {
|
||||
return $decompressed;
|
||||
}
|
||||
|
||||
if ( false !== ( $decompressed = self::compatible_gzinflate( $compressed ) ) ) {
|
||||
$decompressed = self::compatible_gzinflate( $compressed );
|
||||
if ( false !== $decompressed ) {
|
||||
return $decompressed;
|
||||
}
|
||||
|
||||
if ( false !== ( $decompressed = @gzuncompress( $compressed ) ) ) {
|
||||
$decompressed = @gzuncompress( $compressed );
|
||||
if ( false !== $decompressed ) {
|
||||
return $decompressed;
|
||||
}
|
||||
|
||||
|
|
|
@ -326,7 +326,8 @@ class WP_Http_Streams {
|
|||
);
|
||||
|
||||
// Handle redirects.
|
||||
if ( false !== ( $redirect_response = WP_Http::handle_redirects( $url, $r, $response ) ) ) {
|
||||
$redirect_response = WP_Http::handle_redirects( $url, $r, $response );
|
||||
if ( false !== $redirect_response ) {
|
||||
return $redirect_response;
|
||||
}
|
||||
|
||||
|
|
|
@ -359,8 +359,11 @@ abstract class WP_Image_Editor {
|
|||
$name = wp_basename( $this->file, ".$ext" );
|
||||
$new_ext = strtolower( $extension ? $extension : $ext );
|
||||
|
||||
if ( ! is_null( $dest_path ) && $_dest_path = realpath( $dest_path ) ) {
|
||||
$dir = $_dest_path;
|
||||
if ( ! is_null( $dest_path ) ) {
|
||||
$_dest_path = realpath( $dest_path );
|
||||
if ( $_dest_path ) {
|
||||
$dir = $_dest_path;
|
||||
}
|
||||
}
|
||||
|
||||
return trailingslashit( $dir ) . "{$name}-{$suffix}.{$new_ext}";
|
||||
|
@ -392,7 +395,8 @@ abstract class WP_Image_Editor {
|
|||
* @return bool
|
||||
*/
|
||||
protected function make_image( $filename, $function, $arguments ) {
|
||||
if ( $stream = wp_is_stream( $filename ) ) {
|
||||
$stream = wp_is_stream( $filename );
|
||||
if ( $stream ) {
|
||||
ob_start();
|
||||
} else {
|
||||
// The directory containing the original file may no longer exist when using a replication plugin.
|
||||
|
|
|
@ -48,7 +48,8 @@ class WP_List_Util {
|
|||
* @param array $input Array to perform operations on.
|
||||
*/
|
||||
public function __construct( $input ) {
|
||||
$this->output = $this->input = $input;
|
||||
$this->output = $input;
|
||||
$this->input = $input;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -312,7 +312,8 @@ class WP_Meta_Query {
|
|||
* }
|
||||
*/
|
||||
public function get_sql( $type, $primary_table, $primary_id_column, $context = null ) {
|
||||
if ( ! $meta_table = _get_meta_table( $type ) ) {
|
||||
$meta_table = _get_meta_table( $type );
|
||||
if ( ! $meta_table ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -268,7 +268,8 @@ class WP_Network_Query {
|
|||
// Fetch full network objects from the primed cache.
|
||||
$_networks = array();
|
||||
foreach ( $network_ids as $network_id ) {
|
||||
if ( $_network = get_network( $network_id ) ) {
|
||||
$_network = get_network( $network_id );
|
||||
if ( $_network ) {
|
||||
$_networks[] = $_network;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -731,7 +731,8 @@ class WP_Query {
|
|||
public function parse_query( $query = '' ) {
|
||||
if ( ! empty( $query ) ) {
|
||||
$this->init();
|
||||
$this->query = $this->query_vars = wp_parse_args( $query );
|
||||
$this->query = wp_parse_args( $query );
|
||||
$this->query_vars = $this->query;
|
||||
} elseif ( ! isset( $this->query ) ) {
|
||||
$this->query = $this->query_vars;
|
||||
}
|
||||
|
@ -1140,7 +1141,8 @@ class WP_Query {
|
|||
|
||||
// Category stuff
|
||||
if ( ! empty( $q['cat'] ) && ! $this->is_singular ) {
|
||||
$cat_in = $cat_not_in = array();
|
||||
$cat_in = array();
|
||||
$cat_not_in = array();
|
||||
|
||||
$cat_array = preg_split( '/[,\s]+/', urldecode( $q['cat'] ) );
|
||||
$cat_array = array_map( 'intval', $cat_array );
|
||||
|
@ -2034,7 +2036,8 @@ class WP_Query {
|
|||
$reqpage_obj = get_post( $reqpage );
|
||||
if ( is_object( $reqpage_obj ) && 'attachment' == $reqpage_obj->post_type ) {
|
||||
$this->is_attachment = true;
|
||||
$post_type = $q['post_type'] = 'attachment';
|
||||
$post_type = 'attachment';
|
||||
$q['post_type'] = 'attachment';
|
||||
$this->is_page = true;
|
||||
$q['attachment_id'] = $reqpage;
|
||||
}
|
||||
|
@ -2888,7 +2891,8 @@ class WP_Query {
|
|||
$found_rows = 'SQL_CALC_FOUND_ROWS';
|
||||
}
|
||||
|
||||
$this->request = $old_request = "SELECT $found_rows $distinct $fields FROM {$wpdb->posts} $join WHERE 1=1 $where $groupby $orderby $limits";
|
||||
$old_request = "SELECT $found_rows $distinct $fields FROM {$wpdb->posts} $join WHERE 1=1 $where $groupby $orderby $limits";
|
||||
$this->request = $old_request;
|
||||
|
||||
if ( ! $q['suppress_filters'] ) {
|
||||
/**
|
||||
|
@ -3400,7 +3404,8 @@ class WP_Query {
|
|||
*/
|
||||
public function query( $query ) {
|
||||
$this->init();
|
||||
$this->query = $this->query_vars = wp_parse_args( $query );
|
||||
$this->query = wp_parse_args( $query );
|
||||
$this->query_vars = $this->query;
|
||||
return $this->get_posts();
|
||||
}
|
||||
|
||||
|
|
|
@ -1834,7 +1834,9 @@ class WP_Rewrite {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public function init() {
|
||||
$this->extra_rules = $this->non_wp_rules = $this->endpoints = array();
|
||||
$this->extra_rules = array();
|
||||
$this->non_wp_rules = array();
|
||||
$this->endpoints = array();
|
||||
$this->permalink_structure = get_option( 'permalink_structure' );
|
||||
$this->front = substr( $this->permalink_structure, 0, strpos( $this->permalink_structure, '%' ) );
|
||||
$this->root = '';
|
||||
|
|
|
@ -361,7 +361,8 @@ class WP_Site_Query {
|
|||
// Fetch full site objects from the primed cache.
|
||||
$_sites = array();
|
||||
foreach ( $site_ids as $site_id ) {
|
||||
if ( $_site = get_site( $site_id ) ) {
|
||||
$_site = get_site( $site_id );
|
||||
if ( $_site ) {
|
||||
$_sites[] = $_site;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -388,7 +388,8 @@ class WP_Tax_Query {
|
|||
'join' => array(),
|
||||
);
|
||||
|
||||
$join = $where = '';
|
||||
$join = '';
|
||||
$where = '';
|
||||
|
||||
$this->clean_query( $clause );
|
||||
|
||||
|
|
|
@ -771,7 +771,8 @@ class WP_Term_Query {
|
|||
* removed.
|
||||
*/
|
||||
if ( ! empty( $args['object_ids'] ) && 'all_with_object_id' != $_fields ) {
|
||||
$_tt_ids = $_terms = array();
|
||||
$_tt_ids = array();
|
||||
$_terms = array();
|
||||
foreach ( $terms as $term ) {
|
||||
if ( isset( $_tt_ids[ $term->term_id ] ) ) {
|
||||
continue;
|
||||
|
|
|
@ -400,8 +400,9 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer {
|
|||
ksort( $final_matches );
|
||||
|
||||
// Stores rows and blanks for each column.
|
||||
$orig_rows = $orig_rows_copy = array_keys( $orig_matches );
|
||||
$final_rows = array_keys( $final_matches );
|
||||
$orig_rows = array_keys( $orig_matches );
|
||||
$orig_rows_copy = $orig_rows;
|
||||
$final_rows = array_keys( $final_matches );
|
||||
|
||||
// Interleaves rows with blanks to keep matches aligned.
|
||||
// We may end up with some extraneous blank rows, but we'll just ignore them later.
|
||||
|
|
|
@ -262,7 +262,8 @@ final class WP_Theme implements ArrayAccess {
|
|||
$this->headers = get_file_data( $this->theme_root . '/' . $theme_file, self::$file_headers, 'theme' );
|
||||
// Default themes always trump their pretenders.
|
||||
// Properly identify default themes that are inside a directory within wp-content/themes.
|
||||
if ( $default_theme_slug = array_search( $this->headers['Name'], self::$default_themes ) ) {
|
||||
$default_theme_slug = array_search( $this->headers['Name'], self::$default_themes );
|
||||
if ( $default_theme_slug ) {
|
||||
if ( basename( $this->stylesheet ) != $default_theme_slug ) {
|
||||
$this->headers['Name'] .= '/' . $this->stylesheet;
|
||||
}
|
||||
|
@ -285,7 +286,11 @@ final class WP_Theme implements ArrayAccess {
|
|||
}
|
||||
|
||||
// (If template is set from cache [and there are no errors], we know it's good.)
|
||||
if ( ! $this->template && ! ( $this->template = $this->headers['Template'] ) ) {
|
||||
if ( ! $this->template ) {
|
||||
$this->template = $this->headers['Template'];
|
||||
}
|
||||
|
||||
if ( ! $this->template ) {
|
||||
$this->template = $this->stylesheet;
|
||||
if ( ! file_exists( $this->theme_root . '/' . $this->stylesheet . '/index.php' ) ) {
|
||||
$error_message = sprintf(
|
||||
|
@ -313,10 +318,11 @@ final class WP_Theme implements ArrayAccess {
|
|||
if ( ! is_array( $cache ) && $this->template != $this->stylesheet && ! file_exists( $this->theme_root . '/' . $this->template . '/index.php' ) ) {
|
||||
// If we're in a directory of themes inside /themes, look for the parent nearby.
|
||||
// wp-content/themes/directory-of-themes/*
|
||||
$parent_dir = dirname( $this->stylesheet );
|
||||
$parent_dir = dirname( $this->stylesheet );
|
||||
$directories = search_theme_directories();
|
||||
if ( '.' != $parent_dir && file_exists( $this->theme_root . '/' . $parent_dir . '/' . $this->template . '/index.php' ) ) {
|
||||
$this->template = $parent_dir . '/' . $this->template;
|
||||
} elseif ( ( $directories = search_theme_directories() ) && isset( $directories[ $this->template ] ) ) {
|
||||
} elseif ( $directories && isset( $directories[ $this->template ] ) ) {
|
||||
// Look for the template in the search_theme_directories() results, in case it is in another theme root.
|
||||
// We don't look into directories of themes, just the theme root.
|
||||
$theme_root_template = $directories[ $this->template ]['theme_root'];
|
||||
|
@ -668,8 +674,14 @@ final class WP_Theme implements ArrayAccess {
|
|||
foreach ( array( 'theme', 'screenshot', 'headers', 'post_templates' ) as $key ) {
|
||||
wp_cache_delete( $key . '-' . $this->cache_hash, 'themes' );
|
||||
}
|
||||
$this->template = $this->textdomain_loaded = $this->theme_root_uri = $this->parent = $this->errors = $this->headers_sanitized = $this->name_translated = null;
|
||||
$this->headers = array();
|
||||
$this->template = null;
|
||||
$this->textdomain_loaded = null;
|
||||
$this->theme_root_uri = null;
|
||||
$this->parent = null;
|
||||
$this->errors = null;
|
||||
$this->headers_sanitized = null;
|
||||
$this->name_translated = null;
|
||||
$this->headers = array();
|
||||
$this->__construct( $this->stylesheet, $this->theme_root );
|
||||
}
|
||||
|
||||
|
@ -1317,8 +1329,9 @@ final class WP_Theme implements ArrayAccess {
|
|||
return true;
|
||||
}
|
||||
|
||||
$path = $this->get_stylesheet_directory();
|
||||
if ( $domainpath = $this->get( 'DomainPath' ) ) {
|
||||
$path = $this->get_stylesheet_directory();
|
||||
$domainpath = $this->get( 'DomainPath' );
|
||||
if ( $domainpath ) {
|
||||
$path .= $domainpath;
|
||||
} else {
|
||||
$path .= '/languages';
|
||||
|
|
|
@ -327,7 +327,8 @@ class WP_User_Query {
|
|||
);
|
||||
|
||||
// Prevent extra meta query.
|
||||
$qv['blog_id'] = $blog_id = 0;
|
||||
$qv['blog_id'] = 0;
|
||||
$blog_id = 0;
|
||||
|
||||
if ( empty( $this->meta_query->queries ) ) {
|
||||
$this->meta_query->queries = array( $who_query );
|
||||
|
|
|
@ -233,17 +233,19 @@ class WP_User {
|
|||
}
|
||||
|
||||
if ( false !== $user_id ) {
|
||||
if ( $user = wp_cache_get( $user_id, 'users' ) ) {
|
||||
$user = wp_cache_get( $user_id, 'users' );
|
||||
if ( $user ) {
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $user = $wpdb->get_row(
|
||||
$user = $wpdb->get_row(
|
||||
$wpdb->prepare(
|
||||
"SELECT * FROM $wpdb->users WHERE $db_field = %s LIMIT 1",
|
||||
$value
|
||||
)
|
||||
) ) {
|
||||
);
|
||||
if ( ! $user ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -206,7 +206,8 @@ class WP_Widget {
|
|||
* @return string Name attribute for $field_name
|
||||
*/
|
||||
public function get_field_name( $field_name ) {
|
||||
if ( false === $pos = strpos( $field_name, '[' ) ) {
|
||||
$pos = strpos( $field_name, '[' );
|
||||
if ( false === $pos ) {
|
||||
return 'widget-' . $this->id_base . '[' . $this->number . '][' . $field_name . ']';
|
||||
} else {
|
||||
return 'widget-' . $this->id_base . '[' . $this->number . '][' . substr_replace( $field_name, '][', $pos, strlen( '[' ) );
|
||||
|
|
|
@ -668,7 +668,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $args[0];
|
||||
$password = $args[1];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -1270,7 +1271,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$password = $args[2];
|
||||
$content_struct = $args[3];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -1672,7 +1674,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$post_id = (int) $args[3];
|
||||
$content_struct = $args[4];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -1744,7 +1747,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$password = $args[2];
|
||||
$post_id = (int) $args[3];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -1843,7 +1847,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' );
|
||||
}
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -1903,7 +1908,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' );
|
||||
}
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -2001,7 +2007,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$password = $args[2];
|
||||
$content_struct = $args[3];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -2105,7 +2112,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$term_id = (int) $args[3];
|
||||
$content_struct = $args[4];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -2220,7 +2228,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$taxonomy = $args[3];
|
||||
$term_id = (int) $args[4];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -2298,7 +2307,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$taxonomy = $args[3];
|
||||
$term_id = (int) $args[4];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -2362,7 +2372,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$taxonomy = $args[3];
|
||||
$filter = isset( $args[4] ) ? $args[4] : array();
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -2467,7 +2478,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' );
|
||||
}
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -2524,7 +2536,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' );
|
||||
}
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -2609,7 +2622,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' );
|
||||
}
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -2671,7 +2685,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' );
|
||||
}
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -2750,7 +2765,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' );
|
||||
}
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -2799,7 +2815,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$password = $args[2];
|
||||
$content_struct = $args[3];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -2878,7 +2895,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $args[2];
|
||||
$password = $args[3];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -2925,7 +2943,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$password = $args[2];
|
||||
$num_pages = isset( $args[3] ) ? (int) $args[3] : 10;
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -2983,7 +3002,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $this->escape( $args[1] );
|
||||
$password = $this->escape( $args[2] );
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -3019,7 +3039,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$password = $args[2];
|
||||
$page_id = (int) $args[3];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -3085,7 +3106,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$escaped_username = $this->escape( $username );
|
||||
$escaped_password = $this->escape( $password );
|
||||
|
||||
if ( ! $user = $this->login( $escaped_username, $escaped_password ) ) {
|
||||
$user = $this->login( $escaped_username, $escaped_password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -3143,7 +3165,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $args[1];
|
||||
$password = $args[2];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -3203,7 +3226,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $args[1];
|
||||
$password = $args[2];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -3246,7 +3270,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $args[1];
|
||||
$password = $args[2];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -3259,7 +3284,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
|
||||
$tags = array();
|
||||
|
||||
if ( $all_tags = get_tags() ) {
|
||||
$all_tags = get_tags();
|
||||
if ( $all_tags ) {
|
||||
foreach ( (array) $all_tags as $tag ) {
|
||||
$struct = array();
|
||||
$struct['tag_id'] = $tag->term_id;
|
||||
|
@ -3298,7 +3324,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$password = $args[2];
|
||||
$category = $args[3];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -3380,7 +3407,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$password = $args[2];
|
||||
$category_id = (int) $args[3];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -3432,7 +3460,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$category = $args[3];
|
||||
$max_results = (int) $args[4];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -3481,14 +3510,16 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$password = $args[2];
|
||||
$comment_id = (int) $args[3];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
|
||||
do_action( 'xmlrpc_call', 'wp.getComment' );
|
||||
|
||||
if ( ! $comment = get_comment( $comment_id ) ) {
|
||||
$comment = get_comment( $comment_id );
|
||||
if ( ! $comment ) {
|
||||
return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
|
||||
}
|
||||
|
||||
|
@ -3532,7 +3563,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$password = $args[2];
|
||||
$struct = isset( $args[3] ) ? $args[3] : array();
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -3618,7 +3650,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$password = $args[2];
|
||||
$comment_ID = (int) $args[3];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -3685,7 +3718,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$comment_ID = (int) $args[3];
|
||||
$content_struct = $args[4];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -3917,7 +3951,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $args[1];
|
||||
$password = $args[2];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -3953,7 +3988,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$password = $args[2];
|
||||
$post_id = (int) $args[3];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -3999,7 +4035,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $args[1];
|
||||
$password = $args[2];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -4033,7 +4070,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $args[1];
|
||||
$password = $args[2];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -4067,7 +4105,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $args[1];
|
||||
$password = $args[2];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -4103,7 +4142,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$password = $args[2];
|
||||
$options = isset( $args[3] ) ? (array) $args[3] : array();
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -4166,7 +4206,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$password = $args[2];
|
||||
$options = (array) $args[3];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -4222,7 +4263,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$password = $args[2];
|
||||
$attachment_id = (int) $args[3];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -4233,7 +4275,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
|
||||
do_action( 'xmlrpc_call', 'wp.getMediaItem' );
|
||||
|
||||
if ( ! $attachment = get_post( $attachment_id ) ) {
|
||||
$attachment = get_post( $attachment_id );
|
||||
if ( ! $attachment ) {
|
||||
return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
|
||||
}
|
||||
|
||||
|
@ -4273,7 +4316,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$password = $args[2];
|
||||
$struct = isset( $args[3] ) ? $args[3] : array();
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -4328,7 +4372,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $args[1];
|
||||
$password = $args[2];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -4411,7 +4456,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' );
|
||||
}
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -4467,7 +4513,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' );
|
||||
}
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -4536,14 +4583,16 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' );
|
||||
}
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
|
||||
do_action( 'xmlrpc_call', 'wp.getRevisions' );
|
||||
|
||||
if ( ! $post = get_post( $post_id ) ) {
|
||||
$post = get_post( $post_id );
|
||||
if ( ! $post ) {
|
||||
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
|
||||
}
|
||||
|
||||
|
@ -4608,14 +4657,16 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$password = $args[2];
|
||||
$revision_id = (int) $args[3];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
|
||||
do_action( 'xmlrpc_call', 'wp.restoreRevision' );
|
||||
|
||||
if ( ! $revision = wp_get_post_revision( $revision_id ) ) {
|
||||
$revision = wp_get_post_revision( $revision_id );
|
||||
if ( ! $revision ) {
|
||||
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
|
||||
}
|
||||
|
||||
|
@ -4623,7 +4674,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
|
||||
}
|
||||
|
||||
if ( ! $post = get_post( $revision->post_parent ) ) {
|
||||
$post = get_post( $revision->post_parent );
|
||||
if ( ! $post ) {
|
||||
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
|
||||
}
|
||||
|
||||
|
@ -4675,7 +4727,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $args[1];
|
||||
$password = $args[2];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -4756,7 +4809,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $args[1];
|
||||
$password = $args[2];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -4800,7 +4854,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $args[2];
|
||||
$password = $args[3];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -4861,7 +4916,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$query = array();
|
||||
}
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -4954,7 +5010,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$content = $args[4];
|
||||
$publish = $args[5];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -5030,7 +5087,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$content = $args[4];
|
||||
$publish = $args[5];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -5103,7 +5161,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $args[2];
|
||||
$password = $args[3];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -5189,7 +5248,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$content_struct = $args[3];
|
||||
$publish = isset( $args[4] ) ? $args[4] : 0;
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -5431,7 +5491,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
|
||||
$postdata = compact( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping', 'post_type', 'post_name', 'post_password', 'post_parent', 'menu_order', 'tags_input', 'page_template' );
|
||||
|
||||
$post_ID = $postdata['ID'] = get_default_post_to_edit( $post_type, true )->ID;
|
||||
$post_ID = get_default_post_to_edit( $post_type, true )->ID;
|
||||
$postdata['ID'] = $post_ID;
|
||||
|
||||
// Only posts can be sticky
|
||||
if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) {
|
||||
|
@ -5499,9 +5560,10 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
*/
|
||||
public function add_enclosure_if_new( $post_ID, $enclosure ) {
|
||||
if ( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) {
|
||||
$encstring = $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'] . "\n";
|
||||
$found = false;
|
||||
if ( $enclosures = get_post_meta( $post_ID, 'enclosure' ) ) {
|
||||
$encstring = $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'] . "\n";
|
||||
$found = false;
|
||||
$enclosures = get_post_meta( $post_ID, 'enclosure' );
|
||||
if ( $enclosures ) {
|
||||
foreach ( $enclosures as $enc ) {
|
||||
// This method used to omit the trailing new line. #23219
|
||||
if ( rtrim( $enc, "\n" ) == rtrim( $encstring, "\n" ) ) {
|
||||
|
@ -5565,7 +5627,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$content_struct = $args[3];
|
||||
$publish = isset( $args[4] ) ? $args[4] : 0;
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -5893,7 +5956,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $args[1];
|
||||
$password = $args[2];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -6038,7 +6102,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$query = array();
|
||||
}
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -6158,7 +6223,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $args[1];
|
||||
$password = $args[2];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -6171,7 +6237,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
|
||||
$categories_struct = array();
|
||||
|
||||
if ( $cats = get_categories( array( 'get' => 'all' ) ) ) {
|
||||
$cats = get_categories( array( 'get' => 'all' ) );
|
||||
if ( $cats ) {
|
||||
foreach ( $cats as $cat ) {
|
||||
$struct = array();
|
||||
$struct['categoryId'] = $cat->term_id;
|
||||
|
@ -6221,7 +6288,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$type = $data['type'];
|
||||
$bits = $data['bits'];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -6255,7 +6323,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
*
|
||||
* @param bool $error Whether to pre-empt the media upload. Default false.
|
||||
*/
|
||||
if ( $upload_err = apply_filters( 'pre_upload_error', false ) ) {
|
||||
$upload_err = apply_filters( 'pre_upload_error', false );
|
||||
if ( $upload_err ) {
|
||||
return new IXR_Error( 500, $upload_err );
|
||||
}
|
||||
|
||||
|
@ -6337,7 +6406,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$query = array();
|
||||
}
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -6394,7 +6464,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $args[1];
|
||||
$password = $args[2];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -6407,12 +6478,13 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
|
||||
$categories_struct = array();
|
||||
|
||||
if ( $cats = get_categories(
|
||||
$cats = get_categories(
|
||||
array(
|
||||
'hide_empty' => 0,
|
||||
'hierarchical' => 0,
|
||||
)
|
||||
) ) {
|
||||
);
|
||||
if ( $cats ) {
|
||||
foreach ( $cats as $cat ) {
|
||||
$struct = array();
|
||||
$struct['categoryId'] = $cat->term_id;
|
||||
|
@ -6446,7 +6518,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $args[1];
|
||||
$password = $args[2];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -6500,7 +6573,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$password = $args[2];
|
||||
$categories = $args[3];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -6623,7 +6697,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$username = $args[1];
|
||||
$password = $args[2];
|
||||
|
||||
if ( ! $user = $this->login( $username, $password ) ) {
|
||||
$user = $this->login( $username, $password );
|
||||
if ( ! $user ) {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
|
@ -6702,7 +6777,8 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
// FIXME: does url_to_postid() cover all these cases already?
|
||||
// if so, then let's use it and drop the old code.
|
||||
$urltest = parse_url( $pagelinkedto );
|
||||
if ( $post_ID = url_to_postid( $pagelinkedto ) ) {
|
||||
$post_ID = url_to_postid( $pagelinkedto );
|
||||
if ( $post_ID ) {
|
||||
// $way
|
||||
} elseif ( isset( $urltest['path'] ) && preg_match( '#p/[0-9]{1,}#', $urltest['path'], $match ) ) {
|
||||
// the path defines the post_ID (archives/p/XXXX)
|
||||
|
@ -6722,9 +6798,10 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
$post_ID = preg_replace( '/[^0-9]+/', '', $urltest['fragment'] );
|
||||
} elseif ( is_string( $urltest['fragment'] ) ) {
|
||||
// ...or a string #title, a little more complicated
|
||||
$title = preg_replace( '/[^a-z0-9]/i', '.', $urltest['fragment'] );
|
||||
$sql = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title RLIKE %s", $title );
|
||||
if ( ! ( $post_ID = $wpdb->get_var( $sql ) ) ) {
|
||||
$title = preg_replace( '/[^a-z0-9]/i', '.', $urltest['fragment'] );
|
||||
$sql = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title RLIKE %s", $title );
|
||||
$post_ID = $wpdb->get_var( $sql );
|
||||
if ( ! $post_ID ) {
|
||||
// returning unknown error '0' is better than die()ing
|
||||
return $this->pingback_error( 0, '' );
|
||||
}
|
||||
|
@ -6774,8 +6851,9 @@ class wp_xmlrpc_server extends IXR_Server {
|
|||
),
|
||||
);
|
||||
|
||||
$request = wp_safe_remote_get( $pagelinkedfrom, $http_api_args );
|
||||
$remote_source = $remote_source_original = wp_remote_retrieve_body( $request );
|
||||
$request = wp_safe_remote_get( $pagelinkedfrom, $http_api_args );
|
||||
$remote_source = wp_remote_retrieve_body( $request );
|
||||
$remote_source_original = $remote_source;
|
||||
|
||||
if ( ! $remote_source ) {
|
||||
return $this->pingback_error( 16, __( 'The source URL does not exist.' ) );
|
||||
|
|
|
@ -142,7 +142,8 @@ class WP_Dependencies {
|
|||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
public function all_deps( $handles, $recursion = false, $group = false ) {
|
||||
if ( ! $handles = (array) $handles ) {
|
||||
$handles = (array) $handles;
|
||||
if ( ! $handles ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -196,7 +196,8 @@ class WP_Scripts extends WP_Dependencies {
|
|||
* @return bool|string|void Void if no data exists, extra scripts if `$echo` is true, true otherwise.
|
||||
*/
|
||||
public function print_extra_script( $handle, $echo = true ) {
|
||||
if ( ! $output = $this->get_data( $handle, 'data' ) ) {
|
||||
$output = $this->get_data( $handle, 'data' );
|
||||
if ( ! $output ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -252,7 +253,8 @@ class WP_Scripts extends WP_Dependencies {
|
|||
}
|
||||
|
||||
$src = $obj->src;
|
||||
$cond_before = $cond_after = '';
|
||||
$cond_before = '';
|
||||
$cond_after = '';
|
||||
$conditional = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : '';
|
||||
|
||||
if ( $conditional ) {
|
||||
|
|
|
@ -144,7 +144,8 @@ class WP_Styles extends WP_Dependencies {
|
|||
}
|
||||
|
||||
$src = $obj->src;
|
||||
$cond_before = $cond_after = '';
|
||||
$cond_before = '';
|
||||
$cond_after = '';
|
||||
$conditional = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : '';
|
||||
|
||||
if ( $conditional ) {
|
||||
|
|
|
@ -25,7 +25,8 @@ function get_comment_author( $comment_ID = 0 ) {
|
|||
$comment = get_comment( $comment_ID );
|
||||
|
||||
if ( empty( $comment->comment_author ) ) {
|
||||
if ( $comment->user_id && $user = get_userdata( $comment->user_id ) ) {
|
||||
$user = $comment->user_id ? get_userdata( $comment->user_id ) : false;
|
||||
if ( $user ) {
|
||||
$author = $user->display_name;
|
||||
} else {
|
||||
$author = __( 'Anonymous' );
|
||||
|
@ -148,7 +149,8 @@ function comment_author_email( $comment_ID = 0 ) {
|
|||
* @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. Default is the current comment.
|
||||
*/
|
||||
function comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) {
|
||||
if ( $link = get_comment_author_email_link( $linktext, $before, $after, $comment ) ) {
|
||||
$link = get_comment_author_email_link( $linktext, $before, $after, $comment );
|
||||
if ( $link ) {
|
||||
echo $link;
|
||||
}
|
||||
}
|
||||
|
@ -466,11 +468,13 @@ function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {
|
|||
$classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type;
|
||||
|
||||
// Add classes for comment authors that are registered users.
|
||||
if ( $comment->user_id > 0 && $user = get_userdata( $comment->user_id ) ) {
|
||||
$user = $comment->user_id ? get_userdata( $comment->user_id ) : false;
|
||||
if ( $user ) {
|
||||
$classes[] = 'byuser';
|
||||
$classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id );
|
||||
// For comment authors who are the author of the post
|
||||
if ( $post = get_post( $post_id ) ) {
|
||||
$post = get_post( $post_id );
|
||||
if ( $post ) {
|
||||
if ( $comment->user_id === $post->post_author ) {
|
||||
$classes[] = 'bypostauthor';
|
||||
}
|
||||
|
@ -1989,8 +1993,9 @@ function wp_list_comments( $args = array(), $comments = null ) {
|
|||
|
||||
$in_comment_loop = true;
|
||||
|
||||
$comment_alt = $comment_thread_alt = 0;
|
||||
$comment_depth = 1;
|
||||
$comment_alt = 0;
|
||||
$comment_thread_alt = 0;
|
||||
$comment_depth = 1;
|
||||
|
||||
$defaults = array(
|
||||
'walker' => null,
|
||||
|
|
|
@ -48,7 +48,8 @@ function check_comment( $author, $email, $url, $comment, $user_ip, $user_agent,
|
|||
$comment = apply_filters( 'comment_text', $comment, null, array() );
|
||||
|
||||
// Check for the number of external links if a max allowed number is set.
|
||||
if ( $max_links = get_option( 'comment_max_links' ) ) {
|
||||
$max_links = get_option( 'comment_max_links' );
|
||||
if ( $max_links ) {
|
||||
$num_links = preg_match_all( '/<a [^>]*href/i', $comment, $out );
|
||||
|
||||
/**
|
||||
|
@ -1038,7 +1039,8 @@ function get_page_of_comment( $comment_ID, $args = array() ) {
|
|||
|
||||
$page = null;
|
||||
|
||||
if ( ! $comment = get_comment( $comment_ID ) ) {
|
||||
$comment = get_comment( $comment_ID );
|
||||
if ( ! $comment ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1359,7 +1361,8 @@ function wp_count_comments( $post_id = 0 ) {
|
|||
*/
|
||||
function wp_delete_comment( $comment_id, $force_delete = false ) {
|
||||
global $wpdb;
|
||||
if ( ! $comment = get_comment( $comment_id ) ) {
|
||||
$comment = get_comment( $comment_id );
|
||||
if ( ! $comment ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1435,7 +1438,8 @@ function wp_trash_comment( $comment_id ) {
|
|||
return wp_delete_comment( $comment_id, true );
|
||||
}
|
||||
|
||||
if ( ! $comment = get_comment( $comment_id ) ) {
|
||||
$comment = get_comment( $comment_id );
|
||||
if ( ! $comment ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2048,7 +2052,8 @@ function wp_new_comment( $commentdata, $avoid_die = false ) {
|
|||
global $wpdb;
|
||||
|
||||
if ( isset( $commentdata['user_ID'] ) ) {
|
||||
$commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
|
||||
$commentdata['user_ID'] = (int) $commentdata['user_ID'];
|
||||
$commentdata['user_id'] = $commentdata['user_ID'];
|
||||
}
|
||||
|
||||
$prefiltered_user_id = ( isset( $commentdata['user_id'] ) ) ? (int) $commentdata['user_id'] : 0;
|
||||
|
@ -2064,7 +2069,8 @@ function wp_new_comment( $commentdata, $avoid_die = false ) {
|
|||
|
||||
$commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
|
||||
if ( isset( $commentdata['user_ID'] ) && $prefiltered_user_id !== (int) $commentdata['user_ID'] ) {
|
||||
$commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
|
||||
$commentdata['user_ID'] = (int) $commentdata['user_ID'];
|
||||
$commentdata['user_id'] = $commentdata['user_ID'];
|
||||
} elseif ( isset( $commentdata['user_id'] ) ) {
|
||||
$commentdata['user_id'] = (int) $commentdata['user_id'];
|
||||
}
|
||||
|
@ -2475,7 +2481,8 @@ function wp_update_comment_count_now( $post_id ) {
|
|||
wp_cache_delete( 'comments-0', 'counts' );
|
||||
wp_cache_delete( "comments-{$post_id}", 'counts' );
|
||||
|
||||
if ( ! $post = get_post( $post_id ) ) {
|
||||
$post = get_post( $post_id );
|
||||
if ( ! $post ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2774,7 +2781,8 @@ function pingback( $content, $post_id ) {
|
|||
foreach ( (array) $post_links_temp as $link_test ) :
|
||||
if ( ! in_array( $link_test, $pung ) && ( url_to_postid( $link_test ) != $post->ID ) // If we haven't pung it already and it isn't a link to itself
|
||||
&& ! is_local_attachment( $link_test ) ) : // Also, let's never ping local attachments.
|
||||
if ( $test = @parse_url( $link_test ) ) {
|
||||
$test = @parse_url( $link_test );
|
||||
if ( $test ) {
|
||||
if ( isset( $test['query'] ) ) {
|
||||
$post_links[] = $link_test;
|
||||
} elseif ( isset( $test['path'] ) && ( $test['path'] != '/' ) && ( $test['path'] != '' ) ) {
|
||||
|
@ -3134,8 +3142,13 @@ function _close_comments_for_old_post( $open, $post_id ) {
|
|||
*/
|
||||
function wp_handle_comment_submission( $comment_data ) {
|
||||
|
||||
$comment_post_ID = $comment_parent = $user_ID = 0;
|
||||
$comment_author = $comment_author_email = $comment_author_url = $comment_content = null;
|
||||
$comment_post_ID = 0;
|
||||
$comment_parent = 0;
|
||||
$user_ID = 0;
|
||||
$comment_author = null;
|
||||
$comment_author_email = null;
|
||||
$comment_author_url = null;
|
||||
$comment_content = null;
|
||||
|
||||
if ( isset( $comment_data['comment_post_ID'] ) ) {
|
||||
$comment_post_ID = (int) $comment_data['comment_post_ID'];
|
||||
|
|
|
@ -57,7 +57,8 @@ class WP_Customize_Nav_Menu_Location_Control extends WP_Customize_Control {
|
|||
return;
|
||||
}
|
||||
|
||||
$value_hidden_class = $no_value_hidden_class = '';
|
||||
$value_hidden_class = '';
|
||||
$no_value_hidden_class = '';
|
||||
if ( $this->value() ) {
|
||||
$value_hidden_class = ' hidden';
|
||||
} else {
|
||||
|
|
|
@ -739,34 +739,37 @@ class WP_Date_Query {
|
|||
}
|
||||
// Specific value queries.
|
||||
|
||||
if ( isset( $query['year'] ) && $value = $this->build_value( $compare, $query['year'] ) ) {
|
||||
$where_parts[] = "YEAR( $column ) $compare $value";
|
||||
}
|
||||
$date_units = array(
|
||||
'YEAR' => array( 'year' ),
|
||||
'MONTH' => array( 'month', 'monthnum' ),
|
||||
'_wp_mysql_week' => array( 'week', 'w' ),
|
||||
'DAYOFYEAR' => array( 'dayofyear' ),
|
||||
'DAYOFMONTH' => array( 'day' ),
|
||||
'DAYOFWEEK' => array( 'dayofweek' ),
|
||||
'WEEKDAY' => array( 'dayofweek_iso' ),
|
||||
);
|
||||
|
||||
if ( isset( $query['month'] ) && $value = $this->build_value( $compare, $query['month'] ) ) {
|
||||
$where_parts[] = "MONTH( $column ) $compare $value";
|
||||
} elseif ( isset( $query['monthnum'] ) && $value = $this->build_value( $compare, $query['monthnum'] ) ) {
|
||||
$where_parts[] = "MONTH( $column ) $compare $value";
|
||||
}
|
||||
if ( isset( $query['week'] ) && false !== ( $value = $this->build_value( $compare, $query['week'] ) ) ) {
|
||||
$where_parts[] = _wp_mysql_week( $column ) . " $compare $value";
|
||||
} elseif ( isset( $query['w'] ) && false !== ( $value = $this->build_value( $compare, $query['w'] ) ) ) {
|
||||
$where_parts[] = _wp_mysql_week( $column ) . " $compare $value";
|
||||
}
|
||||
if ( isset( $query['dayofyear'] ) && $value = $this->build_value( $compare, $query['dayofyear'] ) ) {
|
||||
$where_parts[] = "DAYOFYEAR( $column ) $compare $value";
|
||||
}
|
||||
// Check of the possible date units and add them to the query
|
||||
foreach ( $date_units as $sql_part => $query_parts ) {
|
||||
foreach ( $query_parts as $query_part ) {
|
||||
if ( isset( $query[ $query_part ] ) ) {
|
||||
$value = $this->build_value( $compare, $query[ $query_part ] );
|
||||
if ( $value ) {
|
||||
switch ( $sql_part ) {
|
||||
case '_wp_mysql_week':
|
||||
$where_parts[] = _wp_mysql_week( $column ) . " $compare $value";
|
||||
break;
|
||||
case 'WEEKDAY':
|
||||
$where_parts[] = "$sql_part( $column ) + 1 $compare $value";
|
||||
break;
|
||||
default:
|
||||
$where_parts[] = "$sql_part( $column ) $compare $value";
|
||||
}
|
||||
|
||||
if ( isset( $query['day'] ) && $value = $this->build_value( $compare, $query['day'] ) ) {
|
||||
$where_parts[] = "DAYOFMONTH( $column ) $compare $value";
|
||||
}
|
||||
|
||||
if ( isset( $query['dayofweek'] ) && $value = $this->build_value( $compare, $query['dayofweek'] ) ) {
|
||||
$where_parts[] = "DAYOFWEEK( $column ) $compare $value";
|
||||
}
|
||||
|
||||
if ( isset( $query['dayofweek_iso'] ) && $value = $this->build_value( $compare, $query['dayofweek_iso'] ) ) {
|
||||
$where_parts[] = "WEEKDAY( $column ) + 1 $compare $value";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $query['hour'] ) || isset( $query['minute'] ) || isset( $query['second'] ) ) {
|
||||
|
@ -777,7 +780,8 @@ class WP_Date_Query {
|
|||
}
|
||||
}
|
||||
|
||||
if ( $time_query = $this->build_time_query( $column, $compare, $query['hour'], $query['minute'], $query['second'] ) ) {
|
||||
$time_query = $this->build_time_query( $column, $compare, $query['hour'], $query['minute'], $query['second'] );
|
||||
if ( $time_query ) {
|
||||
$where_parts[] = $time_query;
|
||||
}
|
||||
}
|
||||
|
@ -969,15 +973,18 @@ class WP_Date_Query {
|
|||
if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) {
|
||||
$return = array();
|
||||
|
||||
if ( isset( $hour ) && false !== ( $value = $this->build_value( $compare, $hour ) ) ) {
|
||||
$value = $this->build_value( $compare, $hour );
|
||||
if ( false !== $value ) {
|
||||
$return[] = "HOUR( $column ) $compare $value";
|
||||
}
|
||||
|
||||
if ( isset( $minute ) && false !== ( $value = $this->build_value( $compare, $minute ) ) ) {
|
||||
$value = $this->build_value( $compare, $minute );
|
||||
if ( false !== $value ) {
|
||||
$return[] = "MINUTE( $column ) $compare $value";
|
||||
}
|
||||
|
||||
if ( isset( $second ) && false !== ( $value = $this->build_value( $compare, $second ) ) ) {
|
||||
$value = $this->build_value( $compare, $second );
|
||||
if ( false !== $value ) {
|
||||
$return[] = "SECOND( $column ) $compare $value";
|
||||
}
|
||||
|
||||
|
@ -985,12 +992,21 @@ class WP_Date_Query {
|
|||
}
|
||||
|
||||
// Cases where just one unit is set
|
||||
if ( isset( $hour ) && ! isset( $minute ) && ! isset( $second ) && false !== ( $value = $this->build_value( $compare, $hour ) ) ) {
|
||||
return "HOUR( $column ) $compare $value";
|
||||
} elseif ( ! isset( $hour ) && isset( $minute ) && ! isset( $second ) && false !== ( $value = $this->build_value( $compare, $minute ) ) ) {
|
||||
return "MINUTE( $column ) $compare $value";
|
||||
} elseif ( ! isset( $hour ) && ! isset( $minute ) && isset( $second ) && false !== ( $value = $this->build_value( $compare, $second ) ) ) {
|
||||
return "SECOND( $column ) $compare $value";
|
||||
if ( isset( $hour ) && ! isset( $minute ) && ! isset( $second ) ) {
|
||||
$value = $this->build_value( $compare, $hour );
|
||||
if ( false !== $value ) {
|
||||
return "HOUR( $column ) $compare $value";
|
||||
}
|
||||
} elseif ( ! isset( $hour ) && isset( $minute ) && ! isset( $second ) ) {
|
||||
$value = $this->build_value( $compare, $minute );
|
||||
if ( false !== $value ) {
|
||||
return "MINUTE( $column ) $compare $value";
|
||||
}
|
||||
} elseif ( ! isset( $hour ) && ! isset( $minute ) && isset( $second ) ) {
|
||||
$value = $this->build_value( $compare, $second );
|
||||
if ( false !== $value ) {
|
||||
return "SECOND( $column ) $compare $value";
|
||||
}
|
||||
}
|
||||
|
||||
// Single units were already handled. Since hour & second isn't allowed, minute must to be set.
|
||||
|
@ -998,7 +1014,8 @@ class WP_Date_Query {
|
|||
return false;
|
||||
}
|
||||
|
||||
$format = $time = '';
|
||||
$format = '';
|
||||
$time = '';
|
||||
|
||||
// Hour
|
||||
if ( null !== $hour ) {
|
||||
|
|
|
@ -70,7 +70,8 @@ do_action( 'rss_tag_pre', 'atom-comments' );
|
|||
if ( have_comments() ) :
|
||||
while ( have_comments() ) :
|
||||
the_comment();
|
||||
$comment_post = $GLOBALS['post'] = get_post( $comment->comment_post_ID );
|
||||
$comment_post = get_post( $comment->comment_post_ID );
|
||||
$GLOBALS['post'] = $comment_post;
|
||||
?>
|
||||
<entry>
|
||||
<title>
|
||||
|
|
|
@ -73,7 +73,8 @@ do_action( 'rss_tag_pre', 'rss2-comments' );
|
|||
if ( have_comments() ) :
|
||||
while ( have_comments() ) :
|
||||
the_comment();
|
||||
$comment_post = $GLOBALS['post'] = get_post( $comment->comment_post_ID );
|
||||
$comment_post = get_post( $comment->comment_post_ID );
|
||||
$GLOBALS['post'] = $comment_post;
|
||||
?>
|
||||
<item>
|
||||
<title>
|
||||
|
|
|
@ -5851,7 +5851,8 @@ function sanitize_hex_color_no_hash( $color ) {
|
|||
* @return string
|
||||
*/
|
||||
function maybe_hash_hex_color( $color ) {
|
||||
if ( $unhashed = sanitize_hex_color_no_hash( $color ) ) {
|
||||
$unhashed = sanitize_hex_color_no_hash( $color );
|
||||
if ( $unhashed ) {
|
||||
return '#' . $unhashed;
|
||||
}
|
||||
|
||||
|
|
|
@ -744,7 +744,8 @@ function do_enclose( $content, $post_ID ) {
|
|||
foreach ( (array) $post_links as $url ) {
|
||||
if ( $url != '' && ! $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post_ID, $wpdb->esc_like( $url ) . '%' ) ) ) {
|
||||
|
||||
if ( $headers = wp_get_http_headers( $url ) ) {
|
||||
$headers = wp_get_http_headers( $url );
|
||||
if ( $headers ) {
|
||||
$len = isset( $headers['content-length'] ) ? (int) $headers['content-length'] : 0;
|
||||
$type = isset( $headers['content-type'] ) ? $headers['content-type'] : '';
|
||||
$allowed_types = array( 'video', 'audio' );
|
||||
|
@ -943,7 +944,8 @@ function add_query_arg() {
|
|||
}
|
||||
}
|
||||
|
||||
if ( $frag = strstr( $uri, '#' ) ) {
|
||||
$frag = strstr( $uri, '#' );
|
||||
if ( $frag ) {
|
||||
$uri = substr( $uri, 0, -strlen( $frag ) );
|
||||
} else {
|
||||
$frag = '';
|
||||
|
@ -1698,7 +1700,8 @@ function wp_referer_field( $echo = true ) {
|
|||
* @return string Original referer field.
|
||||
*/
|
||||
function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
|
||||
if ( ! $ref = wp_get_original_referer() ) {
|
||||
$ref = wp_get_original_referer();
|
||||
if ( ! $ref ) {
|
||||
$ref = 'previous' == $jump_back_to ? wp_get_referer() : wp_unslash( $_SERVER['REQUEST_URI'] );
|
||||
}
|
||||
$orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( $ref ) . '" />';
|
||||
|
@ -1810,7 +1813,8 @@ function wp_mkdir_p( $target ) {
|
|||
}
|
||||
|
||||
// Get the permission bits.
|
||||
if ( $stat = @stat( $target_parent ) ) {
|
||||
$stat = @stat( $target_parent );
|
||||
if ( $stat ) {
|
||||
$dir_perms = $stat['mode'] & 0007777;
|
||||
} else {
|
||||
$dir_perms = 0777;
|
||||
|
@ -2159,7 +2163,8 @@ function _wp_upload_dir( $time = null ) {
|
|||
$dir = $upload_path;
|
||||
}
|
||||
|
||||
if ( ! $url = get_option( 'upload_url_path' ) ) {
|
||||
$url = get_option( 'upload_url_path' );
|
||||
if ( ! $url ) {
|
||||
if ( empty( $upload_path ) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) ) {
|
||||
$url = WP_CONTENT_URL . '/uploads';
|
||||
} else {
|
||||
|
@ -2599,7 +2604,8 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
|
|||
if ( in_array( $real_mime, $nonspecific_types, true ) ) {
|
||||
// File is a non-specific binary type. That's ok if it's a type that generally tends to be binary.
|
||||
if ( ! in_array( substr( $type, 0, strcspn( $type, '/' ) ), array( 'application', 'video', 'audio' ) ) ) {
|
||||
$type = $ext = false;
|
||||
$type = false;
|
||||
$ext = false;
|
||||
}
|
||||
} elseif ( 0 === strpos( $real_mime, 'video/' ) || 0 === strpos( $real_mime, 'audio/' ) ) {
|
||||
/*
|
||||
|
@ -2608,7 +2614,8 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
|
|||
* and some media files are commonly named with the wrong extension (.mov instead of .mp4)
|
||||
*/
|
||||
if ( substr( $real_mime, 0, strcspn( $real_mime, '/' ) ) !== substr( $type, 0, strcspn( $type, '/' ) ) ) {
|
||||
$type = $ext = false;
|
||||
$type = false;
|
||||
$ext = false;
|
||||
}
|
||||
} elseif ( 'text/plain' === $real_mime ) {
|
||||
// A few common file types are occasionally detected as text/plain; allow those.
|
||||
|
@ -2623,7 +2630,8 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
|
|||
)
|
||||
)
|
||||
) {
|
||||
$type = $ext = false;
|
||||
$type = false;
|
||||
$ext = false;
|
||||
}
|
||||
} elseif ( 'text/rtf' === $real_mime ) {
|
||||
// Special casing for RTF files.
|
||||
|
@ -2636,7 +2644,8 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
|
|||
)
|
||||
)
|
||||
) {
|
||||
$type = $ext = false;
|
||||
$type = false;
|
||||
$ext = false;
|
||||
}
|
||||
} else {
|
||||
if ( $type !== $real_mime ) {
|
||||
|
@ -2644,7 +2653,8 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
|
|||
* Everything else including image/* and application/*:
|
||||
* If the real content type doesn't match the file extension, assume it's dangerous.
|
||||
*/
|
||||
$type = $ext = false;
|
||||
$type = false;
|
||||
$ext = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2654,7 +2664,8 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
|
|||
$allowed = get_allowed_mime_types();
|
||||
|
||||
if ( ! in_array( $type, $allowed ) ) {
|
||||
$type = $ext = false;
|
||||
$type = false;
|
||||
$ext = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5237,7 +5248,8 @@ function is_site_meta_supported() {
|
|||
* @return float|false Timezone GMT offset, false otherwise.
|
||||
*/
|
||||
function wp_timezone_override_offset() {
|
||||
if ( ! $timezone_string = get_option( 'timezone_string' ) ) {
|
||||
$timezone_string = get_option( 'timezone_string' );
|
||||
if ( ! $timezone_string ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -5602,7 +5614,8 @@ function get_file_data( $file, $default_headers, $context = '' ) {
|
|||
*
|
||||
* @param array $extra_context_headers Empty array by default.
|
||||
*/
|
||||
if ( $context && $extra_headers = apply_filters( "extra_{$context}_headers", array() ) ) {
|
||||
$extra_headers = $context ? apply_filters( "extra_{$context}_headers", array() ) : array();
|
||||
if ( $extra_headers ) {
|
||||
$extra_headers = array_combine( $extra_headers, $extra_headers ); // keys equal values
|
||||
$all_headers = array_merge( $extra_headers, (array) $default_headers );
|
||||
} else {
|
||||
|
@ -5726,7 +5739,8 @@ function send_nosniff_header() {
|
|||
* @return string SQL clause.
|
||||
*/
|
||||
function _wp_mysql_week( $column ) {
|
||||
switch ( $start_of_week = (int) get_option( 'start_of_week' ) ) {
|
||||
$start_of_week = (int) get_option( 'start_of_week' );
|
||||
switch ( $start_of_week ) {
|
||||
case 1:
|
||||
return "WEEK( $column, 1 )";
|
||||
case 2:
|
||||
|
@ -5757,7 +5771,8 @@ function _wp_mysql_week( $column ) {
|
|||
function wp_find_hierarchy_loop( $callback, $start, $start_parent, $callback_args = array() ) {
|
||||
$override = is_null( $start_parent ) ? array() : array( $start => $start_parent );
|
||||
|
||||
if ( ! $arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override, $callback_args ) ) {
|
||||
$arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override, $callback_args );
|
||||
if ( ! $arbitrary_loop_member ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
|
@ -5785,8 +5800,10 @@ function wp_find_hierarchy_loop( $callback, $start, $start_parent, $callback_arg
|
|||
* $_return_loop
|
||||
*/
|
||||
function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = array(), $callback_args = array(), $_return_loop = false ) {
|
||||
$tortoise = $hare = $evanescent_hare = $start;
|
||||
$return = array();
|
||||
$tortoise = $start;
|
||||
$hare = $start;
|
||||
$evanescent_hare = $start;
|
||||
$return = array();
|
||||
|
||||
// Set evanescent_hare to one past hare
|
||||
// Increment hare two steps
|
||||
|
@ -5798,7 +5815,9 @@ function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = ar
|
|||
( $hare = isset( $override[ $evanescent_hare ] ) ? $override[ $evanescent_hare ] : call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) )
|
||||
) {
|
||||
if ( $_return_loop ) {
|
||||
$return[ $tortoise ] = $return[ $evanescent_hare ] = $return[ $hare ] = true;
|
||||
$return[ $tortoise ] = true;
|
||||
$return[ $evanescent_hare ] = true;
|
||||
$return[ $hare ] = true;
|
||||
}
|
||||
|
||||
// tortoise got lapped - must be a loop
|
||||
|
@ -7133,7 +7152,8 @@ function recurse_dirsize( $directory, $exclude = null, $max_execution_time = nul
|
|||
}
|
||||
}
|
||||
|
||||
if ( $handle = opendir( $directory ) ) {
|
||||
$handle = opendir( $directory );
|
||||
if ( $handle ) {
|
||||
while ( ( $file = readdir( $handle ) ) !== false ) {
|
||||
$path = $directory . '/' . $file;
|
||||
if ( $file != '.' && $file != '..' ) {
|
||||
|
|
|
@ -1080,7 +1080,8 @@ function wp_get_document_title() {
|
|||
$title['title'] = single_term_title( '', false );
|
||||
|
||||
// If on an author archive, use the author's display name.
|
||||
} elseif ( is_author() && $author = get_queried_object() ) {
|
||||
} elseif ( is_author() && get_queried_object() ) {
|
||||
$author = get_queried_object();
|
||||
$title['title'] = $author->display_name;
|
||||
|
||||
// If it's a date archive, use the date as the title.
|
||||
|
@ -1874,10 +1875,11 @@ function wp_get_archives( $args = '' ) {
|
|||
$limit = $r['limit'];
|
||||
|
||||
if ( 'monthly' == $r['type'] ) {
|
||||
$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order $limit";
|
||||
$key = md5( $query );
|
||||
$key = "wp_get_archives:$key:$last_changed";
|
||||
if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
|
||||
$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order $limit";
|
||||
$key = md5( $query );
|
||||
$key = "wp_get_archives:$key:$last_changed";
|
||||
$results = wp_cache_get( $key, 'posts' );
|
||||
if ( ! $results ) {
|
||||
$results = $wpdb->get_results( $query );
|
||||
wp_cache_set( $key, $results, 'posts' );
|
||||
}
|
||||
|
@ -1898,10 +1900,11 @@ function wp_get_archives( $args = '' ) {
|
|||
}
|
||||
}
|
||||
} elseif ( 'yearly' == $r['type'] ) {
|
||||
$query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit";
|
||||
$key = md5( $query );
|
||||
$key = "wp_get_archives:$key:$last_changed";
|
||||
if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
|
||||
$query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit";
|
||||
$key = md5( $query );
|
||||
$key = "wp_get_archives:$key:$last_changed";
|
||||
$results = wp_cache_get( $key, 'posts' );
|
||||
if ( ! $results ) {
|
||||
$results = $wpdb->get_results( $query );
|
||||
wp_cache_set( $key, $results, 'posts' );
|
||||
}
|
||||
|
@ -1921,10 +1924,11 @@ function wp_get_archives( $args = '' ) {
|
|||
}
|
||||
}
|
||||
} elseif ( 'daily' == $r['type'] ) {
|
||||
$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit";
|
||||
$key = md5( $query );
|
||||
$key = "wp_get_archives:$key:$last_changed";
|
||||
if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
|
||||
$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit";
|
||||
$key = md5( $query );
|
||||
$key = "wp_get_archives:$key:$last_changed";
|
||||
$results = wp_cache_get( $key, 'posts' );
|
||||
if ( ! $results ) {
|
||||
$results = $wpdb->get_results( $query );
|
||||
wp_cache_set( $key, $results, 'posts' );
|
||||
}
|
||||
|
@ -1945,11 +1949,12 @@ function wp_get_archives( $args = '' ) {
|
|||
}
|
||||
}
|
||||
} elseif ( 'weekly' == $r['type'] ) {
|
||||
$week = _wp_mysql_week( '`post_date`' );
|
||||
$query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit";
|
||||
$key = md5( $query );
|
||||
$key = "wp_get_archives:$key:$last_changed";
|
||||
if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
|
||||
$week = _wp_mysql_week( '`post_date`' );
|
||||
$query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit";
|
||||
$key = md5( $query );
|
||||
$key = "wp_get_archives:$key:$last_changed";
|
||||
$results = wp_cache_get( $key, 'posts' );
|
||||
if ( ! $results ) {
|
||||
$results = $wpdb->get_results( $query );
|
||||
wp_cache_set( $key, $results, 'posts' );
|
||||
}
|
||||
|
@ -1987,7 +1992,8 @@ function wp_get_archives( $args = '' ) {
|
|||
$query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
|
||||
$key = md5( $query );
|
||||
$key = "wp_get_archives:$key:$last_changed";
|
||||
if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
|
||||
$results = wp_cache_get( $key, 'posts' );
|
||||
if ( ! $results ) {
|
||||
$results = $wpdb->get_results( $query );
|
||||
wp_cache_set( $key, $results, 'posts' );
|
||||
}
|
||||
|
@ -3830,7 +3836,8 @@ function get_language_attributes( $doctype = 'html' ) {
|
|||
$attributes[] = 'dir="rtl"';
|
||||
}
|
||||
|
||||
if ( $lang = get_bloginfo( 'language' ) ) {
|
||||
$lang = get_bloginfo( 'language' );
|
||||
if ( $lang ) {
|
||||
if ( get_option( 'html_type' ) == 'text/html' || $doctype == 'html' ) {
|
||||
$attributes[] = 'lang="' . esc_attr( $lang ) . '"';
|
||||
}
|
||||
|
|
|
@ -33,7 +33,8 @@ header( 'Vary: Accept-Encoding' ); // Handle proxies
|
|||
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expires_offset ) . ' GMT' );
|
||||
header( "Cache-Control: public, max-age=$expires_offset" );
|
||||
|
||||
if ( isset( $_GET['c'] ) && ( $file = get_file( $basepath . '/wp-tinymce.js' ) ) ) {
|
||||
$file = get_file( $basepath . '/wp-tinymce.js' );
|
||||
if ( isset( $_GET['c'] ) && $file ) {
|
||||
echo $file;
|
||||
} else {
|
||||
// Even further back compat.
|
||||
|
|
|
@ -1173,7 +1173,9 @@ function wp_kses_attr_check( &$name, &$value, &$whole, $vless, $element, $allowe
|
|||
*/
|
||||
$allowed_attr[ $match[0] ] = $allowed_attr['data-*'];
|
||||
} else {
|
||||
$name = $value = $whole = '';
|
||||
$name = '';
|
||||
$value = '';
|
||||
$whole = '';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1182,7 +1184,9 @@ function wp_kses_attr_check( &$name, &$value, &$whole, $vless, $element, $allowe
|
|||
$new_value = safecss_filter_attr( $value );
|
||||
|
||||
if ( empty( $new_value ) ) {
|
||||
$name = $value = $whole = '';
|
||||
$name = '';
|
||||
$value = '';
|
||||
$whole = '';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1194,7 +1198,9 @@ function wp_kses_attr_check( &$name, &$value, &$whole, $vless, $element, $allowe
|
|||
// there are some checks
|
||||
foreach ( $allowed_attr[ $name_low ] as $currkey => $currval ) {
|
||||
if ( ! wp_kses_check_attr_val( $value, $vless, $currkey, $currval ) ) {
|
||||
$name = $value = $whole = '';
|
||||
$name = '';
|
||||
$value = '';
|
||||
$whole = '';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1235,7 +1241,8 @@ function wp_kses_hair( $attr, $allowed_protocols ) {
|
|||
case 0:
|
||||
if ( preg_match( '/^([-a-zA-Z:]+)/', $attr, $match ) ) {
|
||||
$attrname = $match[1];
|
||||
$working = $mode = 1;
|
||||
$working = 1;
|
||||
$mode = 1;
|
||||
$attr = preg_replace( '/^[-a-zA-Z:]+/', '', $attr );
|
||||
}
|
||||
|
||||
|
|
|
@ -53,8 +53,13 @@ function get_locale() {
|
|||
// If multisite, check options.
|
||||
if ( is_multisite() ) {
|
||||
// Don't check blog option when installing.
|
||||
if ( wp_installing() || ( false === $ms_locale = get_option( 'WPLANG' ) ) ) {
|
||||
if ( wp_installing() ) {
|
||||
$ms_locale = get_site_option( 'WPLANG' );
|
||||
} else {
|
||||
$ms_locale = get_option( 'WPLANG' );
|
||||
if ( false === $ms_locale ) {
|
||||
$ms_locale = get_site_option( 'WPLANG' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $ms_locale !== false ) {
|
||||
|
|
|
@ -1197,7 +1197,9 @@ function get_search_comments_feed_link( $search_query = '', $feed = '' ) {
|
|||
*/
|
||||
function get_post_type_archive_link( $post_type ) {
|
||||
global $wp_rewrite;
|
||||
if ( ! $post_type_obj = get_post_type_object( $post_type ) ) {
|
||||
|
||||
$post_type_obj = get_post_type_object( $post_type );
|
||||
if ( ! $post_type_obj ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1256,7 +1258,8 @@ function get_post_type_archive_feed_link( $post_type, $feed = '' ) {
|
|||
$feed = $default_feed;
|
||||
}
|
||||
|
||||
if ( ! $link = get_post_type_archive_link( $post_type ) ) {
|
||||
$link = get_post_type_archive_link( $post_type );
|
||||
if ( ! $link ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1338,7 +1341,8 @@ function get_preview_post_link( $post = null, $query_args = array(), $preview_li
|
|||
* not allow an editing UI.
|
||||
*/
|
||||
function get_edit_post_link( $id = 0, $context = 'display' ) {
|
||||
if ( ! $post = get_post( $id ) ) {
|
||||
$post = get_post( $id );
|
||||
if ( ! $post ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1391,11 +1395,13 @@ function get_edit_post_link( $id = 0, $context = 'display' ) {
|
|||
* @param string $class Optional. Add custom class to link. Default 'post-edit-link'.
|
||||
*/
|
||||
function edit_post_link( $text = null, $before = '', $after = '', $id = 0, $class = 'post-edit-link' ) {
|
||||
if ( ! $post = get_post( $id ) ) {
|
||||
$post = get_post( $id );
|
||||
if ( ! $post ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $url = get_edit_post_link( $post->ID ) ) {
|
||||
$url = get_edit_post_link( $post->ID );
|
||||
if ( ! $url ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1434,7 +1440,8 @@ function get_delete_post_link( $id = 0, $deprecated = '', $force_delete = false
|
|||
_deprecated_argument( __FUNCTION__, '3.0.0' );
|
||||
}
|
||||
|
||||
if ( ! $post = get_post( $id ) ) {
|
||||
$post = get_post( $id );
|
||||
if ( ! $post ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1677,7 +1684,8 @@ function get_next_post( $in_same_term = false, $excluded_terms = '', $taxonomy =
|
|||
function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( ( ! $post = get_post() ) || ! taxonomy_exists( $taxonomy ) ) {
|
||||
$post = get_post();
|
||||
if ( ! $post || ! taxonomy_exists( $taxonomy ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1859,7 +1867,8 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo
|
|||
* @return string|void The adjacent post relational link URL.
|
||||
*/
|
||||
function get_adjacent_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {
|
||||
if ( $previous && is_attachment() && $post = get_post() ) {
|
||||
$post = get_post();
|
||||
if ( $previous && is_attachment() && $post ) {
|
||||
$post = get_post( $post->post_parent );
|
||||
} else {
|
||||
$post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy );
|
||||
|
@ -4083,7 +4092,8 @@ function get_avatar_data( $id_or_email, $args = null ) {
|
|||
}
|
||||
|
||||
$email_hash = '';
|
||||
$user = $email = false;
|
||||
$user = false;
|
||||
$email = false;
|
||||
|
||||
if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
|
||||
$id_or_email = get_comment( $id_or_email );
|
||||
|
|
|
@ -109,7 +109,8 @@ function wp_fix_server_vars() {
|
|||
// Fix empty PHP_SELF
|
||||
$PHP_SELF = $_SERVER['PHP_SELF'];
|
||||
if ( empty( $PHP_SELF ) ) {
|
||||
$_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace( '/(\?.*)?$/', '', $_SERVER['REQUEST_URI'] );
|
||||
$_SERVER['PHP_SELF'] = preg_replace( '/(\?.*)?$/', '', $_SERVER['REQUEST_URI'] );
|
||||
$PHP_SELF = $_SERVER['PHP_SELF'];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -634,7 +635,8 @@ function wp_get_mu_plugins() {
|
|||
if ( ! is_dir( WPMU_PLUGIN_DIR ) ) {
|
||||
return $mu_plugins;
|
||||
}
|
||||
if ( ! $dh = opendir( WPMU_PLUGIN_DIR ) ) {
|
||||
$dh = opendir( WPMU_PLUGIN_DIR );
|
||||
if ( ! $dh ) {
|
||||
return $mu_plugins;
|
||||
}
|
||||
while ( ( $plugin = readdir( $dh ) ) !== false ) {
|
||||
|
@ -1164,7 +1166,8 @@ function wp_load_translations_early() {
|
|||
// General libraries
|
||||
require_once ABSPATH . WPINC . '/plugin.php';
|
||||
|
||||
$locales = $locations = array();
|
||||
$locales = array();
|
||||
$locations = array();
|
||||
|
||||
while ( true ) {
|
||||
if ( defined( 'WPLANG' ) ) {
|
||||
|
|
|
@ -699,7 +699,8 @@ function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key =
|
|||
}
|
||||
|
||||
// Fetch the meta and go on if it's found.
|
||||
if ( $meta = get_metadata_by_mid( $meta_type, $meta_id ) ) {
|
||||
$meta = get_metadata_by_mid( $meta_type, $meta_id );
|
||||
if ( $meta ) {
|
||||
$original_key = $meta->meta_key;
|
||||
$object_id = $meta->{$column};
|
||||
|
||||
|
@ -811,7 +812,8 @@ function delete_metadata_by_mid( $meta_type, $meta_id ) {
|
|||
}
|
||||
|
||||
// Fetch the meta and go on if it's found.
|
||||
if ( $meta = get_metadata_by_mid( $meta_type, $meta_id ) ) {
|
||||
$meta = get_metadata_by_mid( $meta_type, $meta_id );
|
||||
if ( $meta ) {
|
||||
$object_id = (int) $meta->{$column};
|
||||
|
||||
/** This action is documented in wp-includes/meta.php */
|
||||
|
|
|
@ -2024,21 +2024,24 @@ function signup_nonce_check( $result ) {
|
|||
* @since MU (3.0.0)
|
||||
*/
|
||||
function maybe_redirect_404() {
|
||||
/**
|
||||
* Filters the redirect URL for 404s on the main site.
|
||||
*
|
||||
* The filter is only evaluated if the NOBLOGREDIRECT constant is defined.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $no_blog_redirect The redirect URL defined in NOBLOGREDIRECT.
|
||||
*/
|
||||
if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) && ( $destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT ) ) ) {
|
||||
if ( $destination == '%siteurl%' ) {
|
||||
$destination = network_home_url();
|
||||
if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) ) {
|
||||
/**
|
||||
* Filters the redirect URL for 404s on the main site.
|
||||
*
|
||||
* The filter is only evaluated if the NOBLOGREDIRECT constant is defined.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $no_blog_redirect The redirect URL defined in NOBLOGREDIRECT.
|
||||
*/
|
||||
$destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT );
|
||||
if ( $destination ) {
|
||||
if ( $destination == '%siteurl%' ) {
|
||||
$destination = network_home_url();
|
||||
}
|
||||
wp_redirect( $destination );
|
||||
exit();
|
||||
}
|
||||
wp_redirect( $destination );
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -324,7 +324,8 @@ function ms_load_current_site_and_network( $domain, $path, $subdomain = false )
|
|||
* If we're not dealing with one of these installations, then the important part is determining
|
||||
* the network first, because we need the network's path to identify any sites.
|
||||
*/
|
||||
if ( ! $current_site = wp_cache_get( 'current_network', 'site-options' ) ) {
|
||||
$current_site = wp_cache_get( 'current_network', 'site-options' );
|
||||
if ( ! $current_site ) {
|
||||
// Are there even two networks installed?
|
||||
$networks = get_networks( array( 'number' => 2 ) );
|
||||
if ( count( $networks ) === 1 ) {
|
||||
|
@ -388,7 +389,8 @@ function ms_load_current_site_and_network( $domain, $path, $subdomain = false )
|
|||
// During activation of a new subdomain, the requested site does not yet exist.
|
||||
if ( empty( $current_blog ) && wp_installing() ) {
|
||||
$current_blog = new stdClass;
|
||||
$current_blog->blog_id = $blog_id = 1;
|
||||
$current_blog->blog_id = 1;
|
||||
$blog_id = 1;
|
||||
$current_blog->public = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,8 @@ function wp_nav_menu( $args = array() ) {
|
|||
$menu = wp_get_nav_menu_object( $args->menu );
|
||||
|
||||
// Get the nav menu based on the theme_location
|
||||
if ( ! $menu && $args->theme_location && ( $locations = get_nav_menu_locations() ) && isset( $locations[ $args->theme_location ] ) ) {
|
||||
$locations = get_nav_menu_locations();
|
||||
if ( ! $menu && $args->theme_location && $locations && isset( $locations[ $args->theme_location ] ) ) {
|
||||
$menu = wp_get_nav_menu_object( $locations[ $args->theme_location ] );
|
||||
}
|
||||
|
||||
|
@ -124,7 +125,8 @@ function wp_nav_menu( $args = array() ) {
|
|||
if ( ! $menu && ! $args->theme_location ) {
|
||||
$menus = wp_get_nav_menus();
|
||||
foreach ( $menus as $menu_maybe ) {
|
||||
if ( $menu_items = wp_get_nav_menu_items( $menu_maybe->term_id, array( 'update_post_term_cache' => false ) ) ) {
|
||||
$menu_items = wp_get_nav_menu_items( $menu_maybe->term_id, array( 'update_post_term_cache' => false ) );
|
||||
if ( $menu_items ) {
|
||||
$menu = $menu_maybe;
|
||||
break;
|
||||
}
|
||||
|
@ -157,7 +159,8 @@ function wp_nav_menu( $args = array() ) {
|
|||
return false;
|
||||
}
|
||||
|
||||
$nav_menu = $items = '';
|
||||
$nav_menu = '';
|
||||
$items = '';
|
||||
|
||||
$show_container = false;
|
||||
if ( $args->container ) {
|
||||
|
@ -181,7 +184,8 @@ function wp_nav_menu( $args = array() ) {
|
|||
// Set up the $menu_item variables
|
||||
_wp_menu_item_classes_by_context( $menu_items );
|
||||
|
||||
$sorted_menu_items = $menu_items_with_children = array();
|
||||
$sorted_menu_items = array();
|
||||
$menu_items_with_children = array();
|
||||
foreach ( (array) $menu_items as $menu_item ) {
|
||||
$sorted_menu_items[ $menu_item->menu_order ] = $menu_item;
|
||||
if ( $menu_item->menu_item_parent ) {
|
||||
|
|
|
@ -198,8 +198,9 @@ function wp_load_alloptions() {
|
|||
}
|
||||
|
||||
if ( ! $alloptions ) {
|
||||
$suppress = $wpdb->suppress_errors();
|
||||
if ( ! $alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" ) ) {
|
||||
$suppress = $wpdb->suppress_errors();
|
||||
$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" );
|
||||
if ( ! $alloptions_db ) {
|
||||
$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" );
|
||||
}
|
||||
$wpdb->suppress_errors( $suppress );
|
||||
|
@ -913,7 +914,8 @@ function wp_user_settings() {
|
|||
return;
|
||||
}
|
||||
|
||||
if ( ! $user_id = get_current_user_id() ) {
|
||||
$user_id = get_current_user_id();
|
||||
if ( ! $user_id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1035,7 +1037,8 @@ function delete_user_setting( $names ) {
|
|||
function get_all_user_settings() {
|
||||
global $_updated_user_settings;
|
||||
|
||||
if ( ! $user_id = get_current_user_id() ) {
|
||||
$user_id = get_current_user_id();
|
||||
if ( ! $user_id ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
|
@ -1078,7 +1081,8 @@ function get_all_user_settings() {
|
|||
function wp_set_all_user_settings( $user_settings ) {
|
||||
global $_updated_user_settings;
|
||||
|
||||
if ( ! $user_id = get_current_user_id() ) {
|
||||
$user_id = get_current_user_id();
|
||||
if ( ! $user_id ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1111,7 +1115,8 @@ function wp_set_all_user_settings( $user_settings ) {
|
|||
* @since 2.7.0
|
||||
*/
|
||||
function delete_all_user_settings() {
|
||||
if ( ! $user_id = get_current_user_id() ) {
|
||||
$user_id = get_current_user_id();
|
||||
if ( ! $user_id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -217,7 +217,9 @@ if ( ! function_exists( 'wp_mail' ) ) :
|
|||
}
|
||||
|
||||
// Headers
|
||||
$cc = $bcc = $reply_to = array();
|
||||
$cc = array();
|
||||
$bcc = array();
|
||||
$reply_to = array();
|
||||
|
||||
if ( empty( $headers ) ) {
|
||||
$headers = array();
|
||||
|
@ -595,7 +597,8 @@ if ( ! function_exists( 'wp_validate_auth_cookie' ) ) :
|
|||
* @return false|int False if invalid cookie, User ID if valid.
|
||||
*/
|
||||
function wp_validate_auth_cookie( $cookie = '', $scheme = '' ) {
|
||||
if ( ! $cookie_elements = wp_parse_auth_cookie( $cookie, $scheme ) ) {
|
||||
$cookie_elements = wp_parse_auth_cookie( $cookie, $scheme );
|
||||
if ( ! $cookie_elements ) {
|
||||
/**
|
||||
* Fires if an authentication cookie is malformed.
|
||||
*
|
||||
|
@ -609,11 +612,12 @@ if ( ! function_exists( 'wp_validate_auth_cookie' ) ) :
|
|||
return false;
|
||||
}
|
||||
|
||||
$scheme = $cookie_elements['scheme'];
|
||||
$username = $cookie_elements['username'];
|
||||
$hmac = $cookie_elements['hmac'];
|
||||
$token = $cookie_elements['token'];
|
||||
$expired = $expiration = $cookie_elements['expiration'];
|
||||
$scheme = $cookie_elements['scheme'];
|
||||
$username = $cookie_elements['username'];
|
||||
$hmac = $cookie_elements['hmac'];
|
||||
$token = $cookie_elements['token'];
|
||||
$expired = $cookie_elements['expiration'];
|
||||
$expiration = $cookie_elements['expiration'];
|
||||
|
||||
// Allow a grace period for POST and Ajax requests
|
||||
if ( wp_doing_ajax() || 'POST' == $_SERVER['REQUEST_METHOD'] ) {
|
||||
|
@ -1036,7 +1040,8 @@ if ( ! function_exists( 'auth_redirect' ) ) :
|
|||
*/
|
||||
$scheme = apply_filters( 'auth_redirect_scheme', '' );
|
||||
|
||||
if ( $user_id = wp_validate_auth_cookie( '', $scheme ) ) {
|
||||
$user_id = wp_validate_auth_cookie( '', $scheme );
|
||||
if ( $user_id ) {
|
||||
/**
|
||||
* Fires before the authentication redirect.
|
||||
*
|
||||
|
@ -1380,7 +1385,8 @@ if ( ! function_exists( 'wp_validate_redirect' ) ) :
|
|||
}
|
||||
|
||||
// In php 5 parse_url may fail if the URL query part contains http://, bug #38143
|
||||
$test = ( $cut = strpos( $location, '?' ) ) ? substr( $location, 0, $cut ) : $location;
|
||||
$cut = strpos( $location, '?' );
|
||||
$test = $cut ? substr( $location, 0, $cut ) : $location;
|
||||
|
||||
// @-operator is used to prevent possible warnings in PHP < 5.3.3.
|
||||
$lp = @parse_url( $test );
|
||||
|
|
|
@ -240,7 +240,8 @@ class Plural_Forms {
|
|||
if ( isset( $this->cache[ $num ] ) ) {
|
||||
return $this->cache[ $num ];
|
||||
}
|
||||
return $this->cache[ $num ] = $this->execute( $num );
|
||||
$this->cache[ $num ] = $this->execute( $num );
|
||||
return $this->cache[ $num ];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1095,7 +1095,8 @@ function post_custom( $key = '' ) {
|
|||
* @internal This will probably change at some point...
|
||||
*/
|
||||
function the_meta() {
|
||||
if ( $keys = get_post_custom_keys() ) {
|
||||
$keys = get_post_custom_keys();
|
||||
if ( $keys ) {
|
||||
$li_html = '';
|
||||
foreach ( (array) $keys as $key ) {
|
||||
$keyt = trim( $key );
|
||||
|
@ -1603,10 +1604,12 @@ function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $
|
|||
function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false, $attr = '' ) {
|
||||
$_post = get_post( $id );
|
||||
|
||||
if ( empty( $_post ) || ( 'attachment' !== $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) ) {
|
||||
if ( empty( $_post ) || ( 'attachment' !== $_post->post_type ) || ! wp_get_attachment_url( $_post->ID ) ) {
|
||||
return __( 'Missing Attachment' );
|
||||
}
|
||||
|
||||
$url = wp_get_attachment_url( $_post->ID );
|
||||
|
||||
if ( $permalink ) {
|
||||
$url = get_attachment_link( $_post->ID );
|
||||
}
|
||||
|
@ -1807,7 +1810,8 @@ function get_page_template_slug( $post = null ) {
|
|||
* @return string|false i18n formatted datetimestamp or localized 'Current Revision'.
|
||||
*/
|
||||
function wp_post_revision_title( $revision, $link = true ) {
|
||||
if ( ! $revision = get_post( $revision ) ) {
|
||||
$revision = get_post( $revision );
|
||||
if ( ! $revision ) {
|
||||
return $revision;
|
||||
}
|
||||
|
||||
|
@ -1822,9 +1826,10 @@ function wp_post_revision_title( $revision, $link = true ) {
|
|||
/* translators: %s: revision date */
|
||||
$currentf = __( '%s [Current Revision]' );
|
||||
|
||||
$date = date_i18n( $datef, strtotime( $revision->post_modified ) );
|
||||
if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) ) {
|
||||
$date = "<a href='$link'>$date</a>";
|
||||
$date = date_i18n( $datef, strtotime( $revision->post_modified ) );
|
||||
$edit_link = get_edit_post_link( $revision->ID );
|
||||
if ( $link && current_user_can( 'edit_post', $revision->ID ) && $edit_link ) {
|
||||
$date = "<a href='$edit_link'>$date</a>";
|
||||
}
|
||||
|
||||
if ( ! wp_is_post_revision( $revision ) ) {
|
||||
|
@ -1846,7 +1851,8 @@ function wp_post_revision_title( $revision, $link = true ) {
|
|||
* @return string|false gravatar, user, i18n formatted datetimestamp or localized 'Current Revision'.
|
||||
*/
|
||||
function wp_post_revision_title_expanded( $revision, $link = true ) {
|
||||
if ( ! $revision = get_post( $revision ) ) {
|
||||
$revision = get_post( $revision );
|
||||
if ( ! $revision ) {
|
||||
return $revision;
|
||||
}
|
||||
|
||||
|
@ -1860,9 +1866,10 @@ function wp_post_revision_title_expanded( $revision, $link = true ) {
|
|||
|
||||
$gravatar = get_avatar( $revision->post_author, 24 );
|
||||
|
||||
$date = date_i18n( $datef, strtotime( $revision->post_modified ) );
|
||||
if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) ) {
|
||||
$date = "<a href='$link'>$date</a>";
|
||||
$date = date_i18n( $datef, strtotime( $revision->post_modified ) );
|
||||
$edit_link = get_edit_post_link( $revision->ID );
|
||||
if ( $link && current_user_can( 'edit_post', $revision->ID ) && $edit_link ) {
|
||||
$date = "<a href='$edit_link'>$date</a>";
|
||||
}
|
||||
|
||||
$revision_date_author = sprintf(
|
||||
|
@ -1910,7 +1917,8 @@ function wp_post_revision_title_expanded( $revision, $link = true ) {
|
|||
* @param string $type 'all' (default), 'revision' or 'autosave'
|
||||
*/
|
||||
function wp_list_post_revisions( $post_id = 0, $type = 'all' ) {
|
||||
if ( ! $post = get_post( $post_id ) ) {
|
||||
$post = get_post( $post_id );
|
||||
if ( ! $post ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1920,7 +1928,8 @@ function wp_list_post_revisions( $post_id = 0, $type = 'all' ) {
|
|||
_deprecated_argument( __FUNCTION__, '3.6.0' );
|
||||
}
|
||||
|
||||
if ( ! $revisions = wp_get_post_revisions( $post->ID ) ) {
|
||||
$revisions = wp_get_post_revisions( $post->ID );
|
||||
if ( ! $revisions ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,8 @@ function update_post_thumbnail_cache( $wp_query = null ) {
|
|||
|
||||
$thumb_ids = array();
|
||||
foreach ( $wp_query->posts as $post ) {
|
||||
if ( $id = get_post_thumbnail_id( $post->ID ) ) {
|
||||
$id = get_post_thumbnail_id( $post->ID );
|
||||
if ( $id ) {
|
||||
$thumb_ids[] = $id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -453,8 +453,11 @@ function get_attached_file( $attachment_id, $unfiltered = false ) {
|
|||
$file = get_post_meta( $attachment_id, '_wp_attached_file', true );
|
||||
|
||||
// If the file is relative, prepend upload dir.
|
||||
if ( $file && 0 !== strpos( $file, '/' ) && ! preg_match( '|^.:\\\|', $file ) && ( ( $uploads = wp_get_upload_dir() ) && false === $uploads['error'] ) ) {
|
||||
$file = $uploads['basedir'] . "/$file";
|
||||
if ( $file && 0 !== strpos( $file, '/' ) && ! preg_match( '|^.:\\\|', $file ) ) {
|
||||
$uploads = wp_get_upload_dir();
|
||||
if ( false === $uploads['error'] ) {
|
||||
$file = $uploads['basedir'] . "/$file";
|
||||
}
|
||||
}
|
||||
|
||||
if ( $unfiltered ) {
|
||||
|
@ -499,7 +502,8 @@ function update_attached_file( $attachment_id, $file ) {
|
|||
*/
|
||||
$file = apply_filters( 'update_attached_file', $file, $attachment_id );
|
||||
|
||||
if ( $file = _wp_relative_upload_path( $file ) ) {
|
||||
$file = _wp_relative_upload_path( $file );
|
||||
if ( $file ) {
|
||||
return update_post_meta( $attachment_id, '_wp_attached_file', $file );
|
||||
} else {
|
||||
return delete_post_meta( $attachment_id, '_wp_attached_file' );
|
||||
|
@ -755,7 +759,8 @@ function get_post_ancestors( $post ) {
|
|||
|
||||
$ancestors = array();
|
||||
|
||||
$id = $ancestors[] = $post->post_parent;
|
||||
$id = $post->post_parent;
|
||||
$ancestors[] = $id;
|
||||
|
||||
while ( $ancestor = get_post( $id ) ) {
|
||||
// Loop detection: If the ancestor has been seen before, break.
|
||||
|
@ -763,7 +768,8 @@ function get_post_ancestors( $post ) {
|
|||
break;
|
||||
}
|
||||
|
||||
$id = $ancestors[] = $ancestor->post_parent;
|
||||
$id = $ancestor->post_parent;
|
||||
$ancestors[] = $id;
|
||||
}
|
||||
|
||||
return $ancestors;
|
||||
|
@ -1148,7 +1154,8 @@ function post_type_exists( $post_type ) {
|
|||
* @return string|false Post type on success, false on failure.
|
||||
*/
|
||||
function get_post_type( $post = null ) {
|
||||
if ( $post = get_post( $post ) ) {
|
||||
$post = get_post( $post );
|
||||
if ( $post ) {
|
||||
return $post->post_type;
|
||||
}
|
||||
|
||||
|
@ -2154,7 +2161,8 @@ function get_post_custom_keys( $post_id = 0 ) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ( $keys = array_keys( $custom ) ) {
|
||||
$keys = array_keys( $custom );
|
||||
if ( $keys ) {
|
||||
return $keys;
|
||||
}
|
||||
}
|
||||
|
@ -4051,7 +4059,8 @@ function wp_update_post( $postarr = array(), $wp_error = false ) {
|
|||
function wp_publish_post( $post ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( ! $post = get_post( $post ) ) {
|
||||
$post = get_post( $post );
|
||||
if ( ! $post ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4227,22 +4236,26 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
|
|||
// Prevent new post slugs that could result in URLs that conflict with date archives.
|
||||
$post = get_post( $post_ID );
|
||||
$conflicts_with_date_archive = false;
|
||||
if ( 'post' === $post_type && ( ! $post || $post->post_name !== $slug ) && preg_match( '/^[0-9]+$/', $slug ) && $slug_num = intval( $slug ) ) {
|
||||
$permastructs = array_values( array_filter( explode( '/', get_option( 'permalink_structure' ) ) ) );
|
||||
$postname_index = array_search( '%postname%', $permastructs );
|
||||
if ( 'post' === $post_type && ( ! $post || $post->post_name !== $slug ) && preg_match( '/^[0-9]+$/', $slug ) ) {
|
||||
$slug_num = intval( $slug );
|
||||
|
||||
/*
|
||||
* Potential date clashes are as follows:
|
||||
*
|
||||
* - Any integer in the first permastruct position could be a year.
|
||||
* - An integer between 1 and 12 that follows 'year' conflicts with 'monthnum'.
|
||||
* - An integer between 1 and 31 that follows 'monthnum' conflicts with 'day'.
|
||||
*/
|
||||
if ( 0 === $postname_index ||
|
||||
( $postname_index && '%year%' === $permastructs[ $postname_index - 1 ] && 13 > $slug_num ) ||
|
||||
( $postname_index && '%monthnum%' === $permastructs[ $postname_index - 1 ] && 32 > $slug_num )
|
||||
) {
|
||||
$conflicts_with_date_archive = true;
|
||||
if ( $slug_num ) {
|
||||
$permastructs = array_values( array_filter( explode( '/', get_option( 'permalink_structure' ) ) ) );
|
||||
$postname_index = array_search( '%postname%', $permastructs );
|
||||
|
||||
/*
|
||||
* Potential date clashes are as follows:
|
||||
*
|
||||
* - Any integer in the first permastruct position could be a year.
|
||||
* - An integer between 1 and 12 that follows 'year' conflicts with 'monthnum'.
|
||||
* - An integer between 1 and 31 that follows 'monthnum' conflicts with 'day'.
|
||||
*/
|
||||
if ( 0 === $postname_index ||
|
||||
( $postname_index && '%year%' === $permastructs[ $postname_index - 1 ] && 13 > $slug_num ) ||
|
||||
( $postname_index && '%monthnum%' === $permastructs[ $postname_index - 1 ] && 32 > $slug_num )
|
||||
) {
|
||||
$conflicts_with_date_archive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5320,7 +5333,9 @@ function is_local_attachment( $url ) {
|
|||
if ( strpos( $url, home_url( '/?attachment_id=' ) ) !== false ) {
|
||||
return true;
|
||||
}
|
||||
if ( $id = url_to_postid( $url ) ) {
|
||||
|
||||
$id = url_to_postid( $url );
|
||||
if ( $id ) {
|
||||
$post = get_post( $id );
|
||||
if ( 'attachment' == $post->post_type ) {
|
||||
return true;
|
||||
|
@ -5544,7 +5559,8 @@ function wp_delete_attachment_files( $post_id, $meta, $backup_sizes, $file ) {
|
|||
*/
|
||||
function wp_get_attachment_metadata( $attachment_id = 0, $unfiltered = false ) {
|
||||
$attachment_id = (int) $attachment_id;
|
||||
if ( ! $post = get_post( $attachment_id ) ) {
|
||||
$post = get_post( $attachment_id );
|
||||
if ( ! $post ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -5577,7 +5593,8 @@ function wp_get_attachment_metadata( $attachment_id = 0, $unfiltered = false ) {
|
|||
*/
|
||||
function wp_update_attachment_metadata( $attachment_id, $data ) {
|
||||
$attachment_id = (int) $attachment_id;
|
||||
if ( ! $post = get_post( $attachment_id ) ) {
|
||||
$post = get_post( $attachment_id );
|
||||
if ( ! $post ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -5589,7 +5606,8 @@ function wp_update_attachment_metadata( $attachment_id, $data ) {
|
|||
* @param array $data Array of updated attachment meta data.
|
||||
* @param int $attachment_id Attachment post ID.
|
||||
*/
|
||||
if ( $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID ) ) {
|
||||
$data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID );
|
||||
if ( $data ) {
|
||||
return update_post_meta( $post->ID, '_wp_attachment_metadata', $data );
|
||||
} else {
|
||||
return delete_post_meta( $post->ID, '_wp_attachment_metadata' );
|
||||
|
@ -5608,7 +5626,8 @@ function wp_update_attachment_metadata( $attachment_id, $data ) {
|
|||
*/
|
||||
function wp_get_attachment_url( $attachment_id = 0 ) {
|
||||
$attachment_id = (int) $attachment_id;
|
||||
if ( ! $post = get_post( $attachment_id ) ) {
|
||||
$post = get_post( $attachment_id );
|
||||
if ( ! $post ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -5618,9 +5637,11 @@ function wp_get_attachment_url( $attachment_id = 0 ) {
|
|||
|
||||
$url = '';
|
||||
// Get attached file.
|
||||
if ( $file = get_post_meta( $post->ID, '_wp_attached_file', true ) ) {
|
||||
$file = get_post_meta( $post->ID, '_wp_attached_file', true );
|
||||
if ( $file ) {
|
||||
// Get upload directory.
|
||||
if ( ( $uploads = wp_get_upload_dir() ) && false === $uploads['error'] ) {
|
||||
$uploads = wp_get_upload_dir();
|
||||
if ( $uploads && false === $uploads['error'] ) {
|
||||
// Check that the upload base exists in the file location.
|
||||
if ( 0 === strpos( $file, $uploads['basedir'] ) ) {
|
||||
// Replace file location with url location.
|
||||
|
@ -5675,7 +5696,8 @@ function wp_get_attachment_url( $attachment_id = 0 ) {
|
|||
*/
|
||||
function wp_get_attachment_caption( $post_id = 0 ) {
|
||||
$post_id = (int) $post_id;
|
||||
if ( ! $post = get_post( $post_id ) ) {
|
||||
$post = get_post( $post_id );
|
||||
if ( ! $post ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -5706,25 +5728,31 @@ function wp_get_attachment_caption( $post_id = 0 ) {
|
|||
*/
|
||||
function wp_get_attachment_thumb_file( $post_id = 0 ) {
|
||||
$post_id = (int) $post_id;
|
||||
if ( ! $post = get_post( $post_id ) ) {
|
||||
$post = get_post( $post_id );
|
||||
if ( ! $post ) {
|
||||
return false;
|
||||
}
|
||||
if ( ! is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) ) {
|
||||
|
||||
$imagedata = wp_get_attachment_metadata( $post->ID );
|
||||
if ( ! is_array( $imagedata ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$file = get_attached_file( $post->ID );
|
||||
|
||||
if ( ! empty( $imagedata['thumb'] ) && ( $thumbfile = str_replace( wp_basename( $file ), $imagedata['thumb'], $file ) ) && file_exists( $thumbfile ) ) {
|
||||
/**
|
||||
* Filters the attachment thumbnail file path.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $thumbfile File path to the attachment thumbnail.
|
||||
* @param int $post_id Attachment ID.
|
||||
*/
|
||||
return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID );
|
||||
if ( ! empty( $imagedata['thumb'] ) ) {
|
||||
$thumbfile = str_replace( wp_basename( $file ), $imagedata['thumb'], $file );
|
||||
if ( file_exists( $thumbfile ) ) {
|
||||
/**
|
||||
* Filters the attachment thumbnail file path.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $thumbfile File path to the attachment thumbnail.
|
||||
* @param int $post_id Attachment ID.
|
||||
*/
|
||||
return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -5739,10 +5767,13 @@ function wp_get_attachment_thumb_file( $post_id = 0 ) {
|
|||
*/
|
||||
function wp_get_attachment_thumb_url( $post_id = 0 ) {
|
||||
$post_id = (int) $post_id;
|
||||
if ( ! $post = get_post( $post_id ) ) {
|
||||
$post = get_post( $post_id );
|
||||
if ( ! $post ) {
|
||||
return false;
|
||||
}
|
||||
if ( ! $url = wp_get_attachment_url( $post->ID ) ) {
|
||||
|
||||
$url = wp_get_attachment_url( $post->ID );
|
||||
if ( ! $url ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -5751,7 +5782,8 @@ function wp_get_attachment_thumb_url( $post_id = 0 ) {
|
|||
return $sized[0];
|
||||
}
|
||||
|
||||
if ( ! $thumb = wp_get_attachment_thumb_file( $post->ID ) ) {
|
||||
$thumb = wp_get_attachment_thumb_file( $post->ID );
|
||||
if ( ! $thumb ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -5778,11 +5810,13 @@ function wp_get_attachment_thumb_url( $post_id = 0 ) {
|
|||
* @return bool True if one of the accepted types, false otherwise.
|
||||
*/
|
||||
function wp_attachment_is( $type, $post = null ) {
|
||||
if ( ! $post = get_post( $post ) ) {
|
||||
$post = get_post( $post );
|
||||
if ( ! $post ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! $file = get_attached_file( $post->ID ) ) {
|
||||
$file = get_attached_file( $post->ID );
|
||||
if ( ! $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -5853,13 +5887,15 @@ function wp_mime_type_icon( $mime = 0 ) {
|
|||
$post_mimes = array();
|
||||
if ( is_numeric( $mime ) ) {
|
||||
$mime = (int) $mime;
|
||||
if ( $post = get_post( $mime ) ) {
|
||||
$post = get_post( $mime );
|
||||
if ( $post ) {
|
||||
$post_id = (int) $post->ID;
|
||||
$file = get_attached_file( $post_id );
|
||||
$ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $file );
|
||||
if ( ! empty( $ext ) ) {
|
||||
$post_mimes[] = $ext;
|
||||
if ( $ext_type = wp_ext2type( $ext ) ) {
|
||||
$ext_type = wp_ext2type( $ext );
|
||||
if ( $ext_type ) {
|
||||
$post_mimes[] = $ext_type;
|
||||
}
|
||||
}
|
||||
|
@ -5905,7 +5941,8 @@ function wp_mime_type_icon( $mime = 0 ) {
|
|||
$keys = array_keys( $dirs );
|
||||
$dir = array_shift( $keys );
|
||||
$uri = array_shift( $dirs );
|
||||
if ( $dh = opendir( $dir ) ) {
|
||||
$dh = opendir( $dir );
|
||||
if ( $dh ) {
|
||||
while ( false !== $file = readdir( $dh ) ) {
|
||||
$file = wp_basename( $file );
|
||||
if ( substr( $file, 0, 1 ) == '.' ) {
|
||||
|
@ -6112,7 +6149,8 @@ function get_posts_by_author_sql( $post_type, $full = true, $post_author = null,
|
|||
*
|
||||
* @param string $cap Capability.
|
||||
*/
|
||||
if ( ! $cap = apply_filters( 'pub_priv_sql_capability', '' ) ) {
|
||||
$cap = apply_filters( 'pub_priv_sql_capability', '' );
|
||||
if ( ! $cap ) {
|
||||
$cap = current_user_can( $post_type_obj->cap->read_private_posts );
|
||||
}
|
||||
|
||||
|
@ -6642,7 +6680,8 @@ function wp_check_post_hierarchy_for_loops( $post_parent, $post_ID ) {
|
|||
}
|
||||
|
||||
// Now look for larger loops.
|
||||
if ( ! $loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_ID, $post_parent ) ) {
|
||||
$loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_ID, $post_parent );
|
||||
if ( ! $loop ) {
|
||||
return $post_parent; // No loop
|
||||
}
|
||||
|
||||
|
@ -6728,7 +6767,8 @@ function wp_delete_auto_drafts() {
|
|||
* @param array $posts Array of WP_Post objects.
|
||||
*/
|
||||
function wp_queue_posts_for_term_meta_lazyload( $posts ) {
|
||||
$post_type_taxonomies = $term_ids = array();
|
||||
$post_type_taxonomies = array();
|
||||
$term_ids = array();
|
||||
foreach ( $posts as $post ) {
|
||||
if ( ! ( $post instanceof WP_Post ) ) {
|
||||
continue;
|
||||
|
|
|
@ -1579,7 +1579,8 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
}
|
||||
|
||||
if ( in_array( 'template', $fields, true ) ) {
|
||||
if ( $template = get_page_template_slug( $post->ID ) ) {
|
||||
$template = get_page_template_slug( $post->ID );
|
||||
if ( $template ) {
|
||||
$data['template'] = $template;
|
||||
} else {
|
||||
$data['template'] = '';
|
||||
|
@ -1747,7 +1748,8 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
|||
}
|
||||
|
||||
// If we have a featured media, add that.
|
||||
if ( $featured_media = get_post_thumbnail_id( $post->ID ) ) {
|
||||
$featured_media = get_post_thumbnail_id( $post->ID );
|
||||
if ( $featured_media ) {
|
||||
$image_url = rest_url( 'wp/v2/media/' . $featured_media );
|
||||
|
||||
$links['https://api.w.org/featuredmedia'] = array(
|
||||
|
|
|
@ -423,7 +423,8 @@ class WP_REST_Terms_Controller extends WP_REST_Controller {
|
|||
* If we're going to inform the client that the term already exists,
|
||||
* give them the identifier for future use.
|
||||
*/
|
||||
if ( $term_id = $term->get_error_data( 'term_exists' ) ) {
|
||||
$term_id = $term->get_error_data( 'term_exists' );
|
||||
if ( $term_id ) {
|
||||
$existing_term = get_term( $term_id, $this->taxonomy );
|
||||
$term->add_data( $existing_term->term_id, 'term_exists' );
|
||||
$term->add_data(
|
||||
|
|
|
@ -498,7 +498,8 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
|
|||
foreach ( $messages as $message ) {
|
||||
$error->add( $code, $message );
|
||||
}
|
||||
if ( $error_data = $error->get_error_data( $code ) ) {
|
||||
$error_data = $error->get_error_data( $code );
|
||||
if ( $error_data ) {
|
||||
$error->add_data( $error_data, $code );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,7 +113,8 @@ function wp_save_post_revision( $post_id ) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ( ! $post = get_post( $post_id ) ) {
|
||||
$post = get_post( $post_id );
|
||||
if ( ! $post ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -132,7 +133,8 @@ function wp_save_post_revision( $post_id ) {
|
|||
// Compare the proposed update with the last stored revision verifying that
|
||||
// they are different, unless a plugin tells us to always save regardless.
|
||||
// If no previous revisions, save one
|
||||
if ( $revisions = wp_get_post_revisions( $post_id ) ) {
|
||||
$revisions = wp_get_post_revisions( $post_id );
|
||||
if ( $revisions ) {
|
||||
// grab the last revision, but not an autosave
|
||||
foreach ( $revisions as $revision ) {
|
||||
if ( false !== strpos( $revision->post_name, "{$revision->post_parent}-revision" ) ) {
|
||||
|
@ -254,7 +256,8 @@ function wp_get_post_autosave( $post_id, $user_id = 0 ) {
|
|||
* @return false|int False if not a revision, ID of revision's parent otherwise.
|
||||
*/
|
||||
function wp_is_post_revision( $post ) {
|
||||
if ( ! $post = wp_get_post_revision( $post ) ) {
|
||||
$post = wp_get_post_revision( $post );
|
||||
if ( ! $post ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -270,7 +273,8 @@ function wp_is_post_revision( $post ) {
|
|||
* @return false|int False if not a revision, ID of autosave's parent otherwise
|
||||
*/
|
||||
function wp_is_post_autosave( $post ) {
|
||||
if ( ! $post = wp_get_post_revision( $post ) ) {
|
||||
$post = wp_get_post_revision( $post );
|
||||
if ( ! $post ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -340,7 +344,8 @@ function _wp_put_post_revision( $post = null, $autosave = false ) {
|
|||
* @return WP_Post|array|null WP_Post (or array) on success, or null on failure.
|
||||
*/
|
||||
function wp_get_post_revision( &$post, $output = OBJECT, $filter = 'raw' ) {
|
||||
if ( ! $revision = get_post( $post, OBJECT, $filter ) ) {
|
||||
$revision = get_post( $post, OBJECT, $filter );
|
||||
if ( ! $revision ) {
|
||||
return $revision;
|
||||
}
|
||||
if ( 'revision' !== $revision->post_type ) {
|
||||
|
@ -372,7 +377,8 @@ function wp_get_post_revision( &$post, $output = OBJECT, $filter = 'raw' ) {
|
|||
* @return int|false|null Null if error, false if no fields to restore, (int) post ID if success.
|
||||
*/
|
||||
function wp_restore_post_revision( $revision_id, $fields = null ) {
|
||||
if ( ! $revision = wp_get_post_revision( $revision_id, ARRAY_A ) ) {
|
||||
$revision = wp_get_post_revision( $revision_id, ARRAY_A );
|
||||
if ( ! $revision ) {
|
||||
return $revision;
|
||||
}
|
||||
|
||||
|
@ -425,7 +431,8 @@ function wp_restore_post_revision( $revision_id, $fields = null ) {
|
|||
* @return array|false|WP_Post|WP_Error|null Null or WP_Error if error, deleted post if success.
|
||||
*/
|
||||
function wp_delete_post_revision( $revision_id ) {
|
||||
if ( ! $revision = wp_get_post_revision( $revision_id ) ) {
|
||||
$revision = wp_get_post_revision( $revision_id );
|
||||
if ( ! $revision ) {
|
||||
return $revision;
|
||||
}
|
||||
|
||||
|
@ -482,7 +489,8 @@ function wp_get_post_revisions( $post_id = 0, $args = null ) {
|
|||
)
|
||||
);
|
||||
|
||||
if ( ! $revisions = get_children( $args ) ) {
|
||||
$revisions = get_children( $args );
|
||||
if ( ! $revisions ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
|
@ -601,7 +609,8 @@ function _show_post_preview() {
|
|||
* @return array
|
||||
*/
|
||||
function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) {
|
||||
if ( ! $post = get_post() ) {
|
||||
$post = get_post();
|
||||
if ( ! $post ) {
|
||||
return $terms;
|
||||
}
|
||||
|
||||
|
@ -611,8 +620,11 @@ function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) {
|
|||
|
||||
if ( 'standard' == $_REQUEST['post_format'] ) {
|
||||
$terms = array();
|
||||
} elseif ( $term = get_term_by( 'slug', 'post-format-' . sanitize_key( $_REQUEST['post_format'] ), 'post_format' ) ) {
|
||||
$terms = array( $term ); // Can only have one post format
|
||||
} else {
|
||||
$term = get_term_by( 'slug', 'post-format-' . sanitize_key( $_REQUEST['post_format'] ), 'post_format' );
|
||||
if ( $term ) {
|
||||
$terms = array( $term ); // Can only have one post format
|
||||
}
|
||||
}
|
||||
|
||||
return $terms;
|
||||
|
@ -630,7 +642,8 @@ function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) {
|
|||
* @return null|array The default return value or the post thumbnail meta array.
|
||||
*/
|
||||
function _wp_preview_post_thumbnail_filter( $value, $post_id, $meta_key ) {
|
||||
if ( ! $post = get_post() ) {
|
||||
$post = get_post();
|
||||
if ( ! $post ) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
|
|
@ -1403,14 +1403,16 @@ function term_exists( $term, $taxonomy = '', $parent = null ) {
|
|||
$where_fields[] = $taxonomy;
|
||||
$else_where_fields[] = $taxonomy;
|
||||
|
||||
if ( $result = $wpdb->get_row( $wpdb->prepare( "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s $orderby $limit", $where_fields ), ARRAY_A ) ) {
|
||||
$result = $wpdb->get_row( $wpdb->prepare( "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $where AND tt.taxonomy = %s $orderby $limit", $where_fields ), ARRAY_A );
|
||||
if ( $result ) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
return $wpdb->get_row( $wpdb->prepare( "SELECT tt.term_id, tt.term_taxonomy_id FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy as tt ON tt.term_id = t.term_id WHERE $else_where AND tt.taxonomy = %s $orderby $limit", $else_where_fields ), ARRAY_A );
|
||||
}
|
||||
|
||||
if ( $result = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms as t WHERE $where $orderby $limit", $where_fields ) ) ) {
|
||||
$result = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms as t WHERE $where $orderby $limit", $where_fields ) );
|
||||
if ( $result ) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -1750,7 +1752,8 @@ function wp_delete_term( $term, $taxonomy, $args = array() ) {
|
|||
|
||||
$term = (int) $term;
|
||||
|
||||
if ( ! $ids = term_exists( $term, $taxonomy ) ) {
|
||||
$ids = term_exists( $term, $taxonomy );
|
||||
if ( ! $ids ) {
|
||||
return false;
|
||||
}
|
||||
if ( is_wp_error( $ids ) ) {
|
||||
|
@ -2448,7 +2451,8 @@ function wp_set_object_terms( $object_id, $terms, $taxonomy, $append = false ) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( ! $term_info = term_exists( $term, $taxonomy ) ) {
|
||||
$term_info = term_exists( $term, $taxonomy );
|
||||
if ( ! $term_info ) {
|
||||
// Skip if a non-existent term ID is passed.
|
||||
if ( is_int( $term ) ) {
|
||||
continue;
|
||||
|
@ -2607,7 +2611,8 @@ function wp_remove_object_terms( $object_id, $terms, $taxonomy ) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( ! $term_info = term_exists( $term, $taxonomy ) ) {
|
||||
$term_info = term_exists( $term, $taxonomy );
|
||||
if ( ! $term_info ) {
|
||||
// Skip if a non-existent term ID is passed.
|
||||
if ( is_int( $term ) ) {
|
||||
continue;
|
||||
|
@ -3543,7 +3548,8 @@ function _get_term_children( $term_id, $terms, $taxonomy, &$ancestors = array()
|
|||
|
||||
$ancestors[ $term->term_id ] = 1;
|
||||
|
||||
if ( $children = _get_term_children( $term->term_id, $terms, $taxonomy, $ancestors ) ) {
|
||||
$children = _get_term_children( $term->term_id, $terms, $taxonomy, $ancestors );
|
||||
if ( $children ) {
|
||||
$term_list = array_merge( $term_list, $children );
|
||||
}
|
||||
}
|
||||
|
@ -3680,7 +3686,8 @@ function _update_post_term_count( $terms, $taxonomy ) {
|
|||
|
||||
$object_types = array_unique( $object_types );
|
||||
|
||||
if ( false !== ( $check_attachments = array_search( 'attachment', $object_types ) ) ) {
|
||||
$check_attachments = array_search( 'attachment', $object_types );
|
||||
if ( false !== $check_attachments ) {
|
||||
unset( $object_types[ $check_attachments ] );
|
||||
$check_attachments = true;
|
||||
}
|
||||
|
@ -3948,7 +3955,8 @@ function _wp_batch_split_terms() {
|
|||
|
||||
// Split term data recording is slow, so we do it just once, outside the loop.
|
||||
$split_term_data = get_option( '_split_terms', array() );
|
||||
$skipped_first_term = $taxonomies = array();
|
||||
$skipped_first_term = array();
|
||||
$taxonomies = array();
|
||||
foreach ( $shared_tts as $shared_tt ) {
|
||||
$term_id = intval( $shared_tt->term_id );
|
||||
|
||||
|
@ -4385,7 +4393,8 @@ function get_post_taxonomies( $post = 0 ) {
|
|||
* @return bool|WP_Error WP_Error on input error.
|
||||
*/
|
||||
function is_object_in_term( $object_id, $taxonomy, $terms = null ) {
|
||||
if ( ! $object_id = (int) $object_id ) {
|
||||
$object_id = (int) $object_id;
|
||||
if ( ! $object_id ) {
|
||||
return new WP_Error( 'invalid_object', __( 'Invalid object ID.' ) );
|
||||
}
|
||||
|
||||
|
@ -4411,7 +4420,8 @@ function is_object_in_term( $object_id, $taxonomy, $terms = null ) {
|
|||
|
||||
$terms = (array) $terms;
|
||||
|
||||
if ( $ints = array_filter( $terms, 'is_int' ) ) {
|
||||
$ints = array_filter( $terms, 'is_int' );
|
||||
if ( $ints ) {
|
||||
$strs = array_diff( $terms, $ints );
|
||||
} else {
|
||||
$strs =& $terms;
|
||||
|
@ -4558,7 +4568,8 @@ function wp_check_term_hierarchy_for_loops( $parent, $term_id, $taxonomy ) {
|
|||
}
|
||||
|
||||
// Now look for larger loops.
|
||||
if ( ! $loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent, array( $taxonomy ) ) ) {
|
||||
$loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent, array( $taxonomy ) );
|
||||
if ( ! $loop ) {
|
||||
return $parent; // No loop
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ if ( 'HEAD' === $_SERVER['REQUEST_METHOD'] && apply_filters( 'exit_on_http_head'
|
|||
}
|
||||
|
||||
// Process feeds and trackbacks even if not using themes.
|
||||
if ( is_robots() ) :
|
||||
if ( is_robots() ) {
|
||||
/**
|
||||
* Fired when the template loader determines a robots.txt request.
|
||||
*
|
||||
|
@ -36,37 +36,56 @@ if ( is_robots() ) :
|
|||
*/
|
||||
do_action( 'do_robots' );
|
||||
return;
|
||||
elseif ( is_feed() ) :
|
||||
} elseif ( is_feed() ) {
|
||||
do_feed();
|
||||
return;
|
||||
elseif ( is_trackback() ) :
|
||||
} elseif ( is_trackback() ) {
|
||||
include( ABSPATH . 'wp-trackback.php' );
|
||||
return;
|
||||
endif;
|
||||
}
|
||||
|
||||
if ( wp_using_themes() ) :
|
||||
$template = false;
|
||||
if ( is_embed() && $template = get_embed_template() ) :
|
||||
elseif ( is_404() && $template = get_404_template() ) :
|
||||
elseif ( is_search() && $template = get_search_template() ) :
|
||||
elseif ( is_front_page() && $template = get_front_page_template() ) :
|
||||
elseif ( is_home() && $template = get_home_template() ) :
|
||||
elseif ( is_privacy_policy() && $template = get_privacy_policy_template() ) :
|
||||
elseif ( is_post_type_archive() && $template = get_post_type_archive_template() ) :
|
||||
elseif ( is_tax() && $template = get_taxonomy_template() ) :
|
||||
elseif ( is_attachment() && $template = get_attachment_template() ) :
|
||||
remove_filter( 'the_content', 'prepend_attachment' );
|
||||
elseif ( is_single() && $template = get_single_template() ) :
|
||||
elseif ( is_page() && $template = get_page_template() ) :
|
||||
elseif ( is_singular() && $template = get_singular_template() ) :
|
||||
elseif ( is_category() && $template = get_category_template() ) :
|
||||
elseif ( is_tag() && $template = get_tag_template() ) :
|
||||
elseif ( is_author() && $template = get_author_template() ) :
|
||||
elseif ( is_date() && $template = get_date_template() ) :
|
||||
elseif ( is_archive() && $template = get_archive_template() ) :
|
||||
else :
|
||||
if ( wp_using_themes() ) {
|
||||
|
||||
$tag_templates = array(
|
||||
'is_embed' => 'get_embed_template',
|
||||
'is_404' => 'get_404_template',
|
||||
'is_search' => 'get_search_template',
|
||||
'is_front_page' => 'get_front_page_template',
|
||||
'is_home' => 'get_home_template',
|
||||
'is_privacy_policy' => 'get_privacy_policy_template',
|
||||
'is_post_type_archive' => 'get_post_type_archive_template',
|
||||
'is_tax' => 'get_taxonomy_template',
|
||||
'is_attachment' => 'get_attachment_template',
|
||||
'is_single' => 'get_single_template',
|
||||
'is_page' => 'get_page_template',
|
||||
'is_singular' => 'get_singular_template',
|
||||
'is_category' => 'get_category_template',
|
||||
'is_tag' => 'get_tag_template',
|
||||
'is_author' => 'get_author_template',
|
||||
'is_date' => 'get_date_template',
|
||||
'is_archive' => 'get_archive_template',
|
||||
);
|
||||
$template = false;
|
||||
|
||||
// Loop through each of the template conditionals, and find the appropriate template file.
|
||||
foreach ( $tag_templates as $tag => $template_getter ) {
|
||||
if ( call_user_func( $tag ) ) {
|
||||
$template = call_user_func( $template_getter );
|
||||
}
|
||||
|
||||
if ( $template ) {
|
||||
if ( 'is_attachment' === $tag ) {
|
||||
remove_filter( 'the_content', 'prepend_attachment' );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $template ) {
|
||||
$template = get_index_template();
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the path of the current template before including it.
|
||||
*
|
||||
|
@ -74,7 +93,8 @@ if ( wp_using_themes() ) :
|
|||
*
|
||||
* @param string $template The path of the template to include.
|
||||
*/
|
||||
if ( $template = apply_filters( 'template_include', $template ) ) {
|
||||
$template = apply_filters( 'template_include', $template );
|
||||
if ( $template ) {
|
||||
include( $template );
|
||||
} elseif ( current_user_can( 'switch_themes' ) ) {
|
||||
$theme = wp_get_theme();
|
||||
|
@ -83,4 +103,4 @@ if ( wp_using_themes() ) :
|
|||
}
|
||||
}
|
||||
return;
|
||||
endif;
|
||||
}
|
||||
|
|
|
@ -79,7 +79,8 @@ function wp_get_themes( $args = array() ) {
|
|||
if ( isset( $_themes[ $theme_root['theme_root'] . '/' . $theme ] ) ) {
|
||||
$themes[ $theme ] = $_themes[ $theme_root['theme_root'] . '/' . $theme ];
|
||||
} else {
|
||||
$themes[ $theme ] = $_themes[ $theme_root['theme_root'] . '/' . $theme ] = new WP_Theme( $theme, $theme_root['theme_root'] );
|
||||
$themes[ $theme ] = new WP_Theme( $theme, $theme_root['theme_root'] );
|
||||
$_themes[ $theme_root['theme_root'] . '/' . $theme ] = $themes[ $theme ];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -463,7 +464,8 @@ function search_theme_directories( $force = false ) {
|
|||
* @param bool $cache_expiration Whether to get the cache of the theme directories. Default false.
|
||||
* @param string $cache_directory Directory to be searched for the cache.
|
||||
*/
|
||||
if ( $cache_expiration = apply_filters( 'wp_cache_themes_persistently', false, 'search_theme_directories' ) ) {
|
||||
$cache_expiration = apply_filters( 'wp_cache_themes_persistently', false, 'search_theme_directories' );
|
||||
if ( $cache_expiration ) {
|
||||
$cached_roots = get_site_transient( 'theme_roots' );
|
||||
if ( is_array( $cached_roots ) ) {
|
||||
foreach ( $cached_roots as $theme_dir => $theme_root ) {
|
||||
|
@ -570,13 +572,20 @@ function search_theme_directories( $force = false ) {
|
|||
function get_theme_root( $stylesheet_or_template = false ) {
|
||||
global $wp_theme_directories;
|
||||
|
||||
if ( $stylesheet_or_template && $theme_root = get_raw_theme_root( $stylesheet_or_template ) ) {
|
||||
// Always prepend WP_CONTENT_DIR unless the root currently registered as a theme directory.
|
||||
// This gives relative theme roots the benefit of the doubt when things go haywire.
|
||||
if ( ! in_array( $theme_root, (array) $wp_theme_directories ) ) {
|
||||
$theme_root = WP_CONTENT_DIR . $theme_root;
|
||||
$theme_root = '';
|
||||
|
||||
if ( $stylesheet_or_template ) {
|
||||
$theme_root = get_raw_theme_root( $stylesheet_or_template );
|
||||
if ( $theme_root ) {
|
||||
// Always prepend WP_CONTENT_DIR unless the root currently registered as a theme directory.
|
||||
// This gives relative theme roots the benefit of the doubt when things go haywire.
|
||||
if ( ! in_array( $theme_root, (array) $wp_theme_directories ) ) {
|
||||
$theme_root = WP_CONTENT_DIR . $theme_root;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
if ( ! $theme_root ) {
|
||||
$theme_root = WP_CONTENT_DIR . '/themes';
|
||||
}
|
||||
|
||||
|
@ -1312,9 +1321,10 @@ function get_custom_header() {
|
|||
} else {
|
||||
$data = get_theme_mod( 'header_image_data' );
|
||||
if ( ! $data && current_theme_supports( 'custom-header', 'default-image' ) ) {
|
||||
$directory_args = array( get_template_directory_uri(), get_stylesheet_directory_uri() );
|
||||
$data = array();
|
||||
$data['url'] = $data['thumbnail_url'] = vsprintf( get_theme_support( 'custom-header', 'default-image' ), $directory_args );
|
||||
$directory_args = array( get_template_directory_uri(), get_stylesheet_directory_uri() );
|
||||
$data = array();
|
||||
$data['url'] = vsprintf( get_theme_support( 'custom-header', 'default-image' ), $directory_args );
|
||||
$data['thumbnail_url'] = $data['url'];
|
||||
if ( ! empty( $_wp_default_headers ) ) {
|
||||
foreach ( (array) $_wp_default_headers as $default_header ) {
|
||||
$url = vsprintf( $default_header['url'], $directory_args );
|
||||
|
@ -2900,7 +2910,8 @@ function _delete_attachment_theme_mod( $id ) {
|
|||
* @since 3.3.0
|
||||
*/
|
||||
function check_theme_switched() {
|
||||
if ( $stylesheet = get_option( 'theme_switched' ) ) {
|
||||
$stylesheet = get_option( 'theme_switched' );
|
||||
if ( $stylesheet ) {
|
||||
$old_theme = wp_get_theme( $stylesheet );
|
||||
|
||||
// Prevent widget & menu mapping from running since Customizer already called it up front
|
||||
|
|
|
@ -132,8 +132,10 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
|
|||
$post_body = array_merge( $post_body, $extra_stats );
|
||||
}
|
||||
|
||||
$url = $http_url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, null, '&' );
|
||||
if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
|
||||
$url = 'http://api.wordpress.org/core/version-check/1.7/?' . http_build_query( $query, null, '&' );
|
||||
$http_url = $url;
|
||||
$ssl = wp_http_supports( array( 'ssl' ) );
|
||||
if ( $ssl ) {
|
||||
$url = set_url_scheme( $url, 'https' );
|
||||
}
|
||||
|
||||
|
@ -368,8 +370,10 @@ function wp_update_plugins( $extra_stats = array() ) {
|
|||
$options['body']['update_stats'] = wp_json_encode( $extra_stats );
|
||||
}
|
||||
|
||||
$url = $http_url = 'http://api.wordpress.org/plugins/update-check/1.1/';
|
||||
if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
|
||||
$url = 'http://api.wordpress.org/plugins/update-check/1.1/';
|
||||
$http_url = $url;
|
||||
$ssl = wp_http_supports( array( 'ssl' ) );
|
||||
if ( $ssl ) {
|
||||
$url = set_url_scheme( $url, 'https' );
|
||||
}
|
||||
|
||||
|
@ -447,7 +451,9 @@ function wp_update_themes( $extra_stats = array() ) {
|
|||
$last_update = new stdClass;
|
||||
}
|
||||
|
||||
$themes = $checked = $request = array();
|
||||
$themes = array();
|
||||
$checked = array();
|
||||
$request = array();
|
||||
|
||||
// Put slug of current theme into request.
|
||||
$request['active'] = get_option( 'stylesheet' );
|
||||
|
@ -553,8 +559,10 @@ function wp_update_themes( $extra_stats = array() ) {
|
|||
$options['body']['update_stats'] = wp_json_encode( $extra_stats );
|
||||
}
|
||||
|
||||
$url = $http_url = 'http://api.wordpress.org/themes/update-check/1.1/';
|
||||
if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
|
||||
$url = 'http://api.wordpress.org/themes/update-check/1.1/';
|
||||
$http_url = $url;
|
||||
$ssl = wp_http_supports( array( 'ssl' ) );
|
||||
if ( $ssl ) {
|
||||
$url = set_url_scheme( $url, 'https' );
|
||||
}
|
||||
|
||||
|
@ -644,21 +652,24 @@ function wp_get_update_data() {
|
|||
'translations' => 0,
|
||||
);
|
||||
|
||||
if ( $plugins = current_user_can( 'update_plugins' ) ) {
|
||||
$plugins = current_user_can( 'update_plugins' );
|
||||
if ( $plugins ) {
|
||||
$update_plugins = get_site_transient( 'update_plugins' );
|
||||
if ( ! empty( $update_plugins->response ) ) {
|
||||
$counts['plugins'] = count( $update_plugins->response );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $themes = current_user_can( 'update_themes' ) ) {
|
||||
$themes = current_user_can( 'update_themes' );
|
||||
if ( $themes ) {
|
||||
$update_themes = get_site_transient( 'update_themes' );
|
||||
if ( ! empty( $update_themes->response ) ) {
|
||||
$counts['themes'] = count( $update_themes->response );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( $core = current_user_can( 'update_core' ) ) && function_exists( 'get_core_updates' ) ) {
|
||||
$core = current_user_can( 'update_core' );
|
||||
if ( $core && function_exists( 'get_core_updates' ) ) {
|
||||
$update_wordpress = get_core_updates( array( 'dismissed' => false ) );
|
||||
if ( ! empty( $update_wordpress ) && ! in_array( $update_wordpress[0]->response, array( 'development', 'latest' ) ) && current_user_can( 'update_core' ) ) {
|
||||
$counts['wordpress'] = 1;
|
||||
|
|
|
@ -480,7 +480,8 @@ function get_user_option( $option, $user = 0, $deprecated = '' ) {
|
|||
$user = get_current_user_id();
|
||||
}
|
||||
|
||||
if ( ! $user = get_userdata( $user ) ) {
|
||||
$user = get_userdata( $user );
|
||||
if ( ! $user ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1013,10 +1014,13 @@ function setup_userdata( $for_user_id = 0 ) {
|
|||
$user = get_userdata( $for_user_id );
|
||||
|
||||
if ( ! $user ) {
|
||||
$user_ID = 0;
|
||||
$user_level = 0;
|
||||
$userdata = null;
|
||||
$user_login = $user_email = $user_url = $user_identity = '';
|
||||
$user_ID = 0;
|
||||
$user_level = 0;
|
||||
$userdata = null;
|
||||
$user_login = '';
|
||||
$user_email = '';
|
||||
$user_url = '';
|
||||
$user_identity = '';
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,16 @@ if ( is_admin() ) {
|
|||
unset( $self_matches );
|
||||
|
||||
// Simple browser detection
|
||||
$is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = $is_safari = $is_chrome = $is_iphone = $is_edge = false;
|
||||
$is_lynx = false;
|
||||
$is_gecko = false;
|
||||
$is_winIE = false;
|
||||
$is_macIE = false;
|
||||
$is_opera = false;
|
||||
$is_NS4 = false;
|
||||
$is_safari = false;
|
||||
$is_chrome = false;
|
||||
$is_iphone = false;
|
||||
$is_edge = false;
|
||||
|
||||
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
||||
if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Lynx' ) !== false ) {
|
||||
|
@ -68,7 +77,8 @@ if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
|||
*
|
||||
* @param bool $is_admin Whether to use the Google Chrome Frame. Default is the value of is_admin().
|
||||
*/
|
||||
if ( $is_chrome = apply_filters( 'use_google_chrome_frame', $is_admin ) ) {
|
||||
$is_chrome = apply_filters( 'use_google_chrome_frame', $is_admin );
|
||||
if ( $is_chrome ) {
|
||||
header( 'X-UA-Compatible: chrome=1' );
|
||||
}
|
||||
$is_winIE = ! $is_chrome;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.3-alpha-45589';
|
||||
$wp_version = '5.3-alpha-45590';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
|
@ -1026,7 +1026,8 @@ function wp_get_widget_defaults() {
|
|||
*/
|
||||
function wp_convert_widget_settings( $base_name, $option_name, $settings ) {
|
||||
// This test may need expanding.
|
||||
$single = $changed = false;
|
||||
$single = false;
|
||||
$changed = false;
|
||||
if ( empty( $settings ) ) {
|
||||
$single = true;
|
||||
} else {
|
||||
|
|
|
@ -120,7 +120,8 @@ class WP_Nav_Menu_Widget extends WP_Widget {
|
|||
// Get menus
|
||||
$menus = wp_get_nav_menus();
|
||||
|
||||
$empty_menus_style = $not_empty_menus_style = '';
|
||||
$empty_menus_style = '';
|
||||
$not_empty_menus_style = '';
|
||||
if ( empty( $menus ) ) {
|
||||
$empty_menus_style = ' style="display:none" ';
|
||||
} else {
|
||||
|
|
|
@ -138,7 +138,8 @@ class WP_Widget_Links extends WP_Widget {
|
|||
)
|
||||
);
|
||||
$link_cats = get_terms( 'link_category' );
|
||||
if ( ! $limit = intval( $instance['limit'] ) ) {
|
||||
$limit = intval( $instance['limit'] );
|
||||
if ( ! $limit ) {
|
||||
$limit = -1;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1438,7 +1438,8 @@ class wpdb {
|
|||
|
||||
wp_load_translations_early();
|
||||
|
||||
if ( $caller = $this->get_caller() ) {
|
||||
$caller = $this->get_caller();
|
||||
if ( $caller ) {
|
||||
/* translators: 1: Database error message, 2: SQL query, 3: Name of the calling function */
|
||||
$error_str = sprintf( __( 'WordPress database error %1$s for query %2$s made by %3$s' ), $str, $this->last_query, $caller );
|
||||
} else {
|
||||
|
@ -1543,7 +1544,8 @@ class wpdb {
|
|||
$this->last_result = array();
|
||||
$this->col_info = null;
|
||||
$this->last_query = null;
|
||||
$this->rows_affected = $this->num_rows = 0;
|
||||
$this->rows_affected = 0;
|
||||
$this->num_rows = 0;
|
||||
$this->last_error = '';
|
||||
|
||||
if ( $this->use_mysqli && $this->result instanceof mysqli_result ) {
|
||||
|
@ -1594,7 +1596,8 @@ class wpdb {
|
|||
$socket = null;
|
||||
$is_ipv6 = false;
|
||||
|
||||
if ( $host_data = $this->parse_db_host( $this->dbhost ) ) {
|
||||
$host_data = $this->parse_db_host( $this->dbhost );
|
||||
if ( $host_data ) {
|
||||
list( $host, $port, $socket, $is_ipv6 ) = $host_data;
|
||||
}
|
||||
|
||||
|
@ -2161,7 +2164,8 @@ class wpdb {
|
|||
return false;
|
||||
}
|
||||
|
||||
$formats = $values = array();
|
||||
$formats = array();
|
||||
$values = array();
|
||||
foreach ( $data as $value ) {
|
||||
if ( is_null( $value['value'] ) ) {
|
||||
$formats[] = 'NULL';
|
||||
|
@ -2225,7 +2229,9 @@ class wpdb {
|
|||
return false;
|
||||
}
|
||||
|
||||
$fields = $conditions = $values = array();
|
||||
$fields = array();
|
||||
$conditions = array();
|
||||
$values = array();
|
||||
foreach ( $data as $field => $value ) {
|
||||
if ( is_null( $value['value'] ) ) {
|
||||
$fields[] = "`$field` = NULL";
|
||||
|
@ -2286,7 +2292,8 @@ class wpdb {
|
|||
return false;
|
||||
}
|
||||
|
||||
$conditions = $values = array();
|
||||
$conditions = array();
|
||||
$values = array();
|
||||
foreach ( $where as $field => $value ) {
|
||||
if ( is_null( $value['value'] ) ) {
|
||||
$conditions[] = "`$field` IS NULL";
|
||||
|
@ -2358,7 +2365,8 @@ class wpdb {
|
|||
* of 'value' and 'format' keys.
|
||||
*/
|
||||
protected function process_field_formats( $data, $format ) {
|
||||
$formats = $original_formats = (array) $format;
|
||||
$formats = (array) $format;
|
||||
$original_formats = $formats;
|
||||
|
||||
foreach ( $data as $field => $value ) {
|
||||
$value = array(
|
||||
|
@ -2650,7 +2658,8 @@ class wpdb {
|
|||
return $this->table_charset[ $tablekey ];
|
||||
}
|
||||
|
||||
$charsets = $columns = array();
|
||||
$charsets = array();
|
||||
$columns = array();
|
||||
|
||||
$table_parts = explode( '.', $table );
|
||||
$table = '`' . implode( '`.`', $table_parts ) . '`';
|
||||
|
@ -3048,7 +3057,8 @@ class wpdb {
|
|||
}
|
||||
|
||||
// We couldn't use any local conversions, send it to the DB.
|
||||
$value['db'] = $db_check_string = true;
|
||||
$value['db'] = true;
|
||||
$db_check_string = true;
|
||||
}
|
||||
unset( $value ); // Remove by reference.
|
||||
|
||||
|
|
Loading…
Reference in New Issue