mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Coding Standards: Use strict type check for in_array() and array_search().
This addresses all the remaining `WordPress.PHP.StrictInArray.MissingTrueStrict` issues in core. Includes minor code layout fixes for better readability. Follow-up to [47550]. See #49542. git-svn-id: https://develop.svn.wordpress.org/trunk@47557 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -83,7 +83,7 @@ class Walker_Category_Checklist extends Walker {
|
||||
|
||||
$args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats'];
|
||||
|
||||
$class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : '';
|
||||
$class = in_array( $category->term_id, $args['popular_cats'], true ) ? ' class="popular-category"' : '';
|
||||
|
||||
$args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats'];
|
||||
|
||||
@@ -91,7 +91,7 @@ class Walker_Category_Checklist extends Walker {
|
||||
$aria_checked = 'false';
|
||||
$inner_class = 'category';
|
||||
|
||||
if ( in_array( $category->term_id, $args['selected_cats'] ) ) {
|
||||
if ( in_array( $category->term_id, $args['selected_cats'], true ) ) {
|
||||
$inner_class .= ' selected';
|
||||
$aria_checked = 'true';
|
||||
}
|
||||
@@ -102,10 +102,13 @@ class Walker_Category_Checklist extends Walker {
|
||||
/** This filter is documented in wp-includes/category-template.php */
|
||||
esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</div>';
|
||||
} else {
|
||||
$is_selected = in_array( $category->term_id, $args['selected_cats'], true );
|
||||
$is_disabled = ! empty( $args['disabled'] );
|
||||
|
||||
$output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" .
|
||||
'<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="' . $name . '[]" id="in-' . $taxonomy . '-' . $category->term_id . '"' .
|
||||
checked( in_array( $category->term_id, $args['selected_cats'] ), true, false ) .
|
||||
disabled( empty( $args['disabled'] ), false, false ) . ' /> ' .
|
||||
checked( $is_selected, true, false ) .
|
||||
disabled( $is_disabled, true, false ) . ' /> ' .
|
||||
/** This filter is documented in wp-includes/category-template.php */
|
||||
esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</label>';
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ class WP_Filesystem_Base {
|
||||
$attarray = preg_split( '//', $mode );
|
||||
|
||||
for ( $i = 0, $c = count( $attarray ); $i < $c; $i++ ) {
|
||||
$key = array_search( $attarray[ $i ], $legal );
|
||||
$key = array_search( $attarray[ $i ], $legal, true );
|
||||
if ( $key ) {
|
||||
$realmode .= $legal[ $key ];
|
||||
}
|
||||
|
||||
@@ -505,7 +505,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
||||
$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
|
||||
}
|
||||
|
||||
if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) {
|
||||
if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins, true ) ) {
|
||||
$actions['delete'] = '<a href="' . esc_url( network_admin_url( add_query_arg( '_wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'users.php', 'deleteuser' ) . '&action=deleteuser&id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>';
|
||||
}
|
||||
|
||||
|
||||
@@ -300,7 +300,7 @@ class WP_Terms_List_Table extends WP_List_Table {
|
||||
$my_parent = get_term( $p, $taxonomy );
|
||||
$my_parents[] = $my_parent;
|
||||
$p = $my_parent->parent;
|
||||
if ( in_array( $p, $parent_ids ) ) { // Prevent parent loops.
|
||||
if ( in_array( $p, $parent_ids, true ) ) { // Prevent parent loops.
|
||||
break;
|
||||
}
|
||||
$parent_ids[] = $p;
|
||||
|
||||
@@ -519,7 +519,7 @@ function wp_dashboard_quick_press( $error_msg = false ) {
|
||||
$post = get_default_post_to_edit( 'post', true );
|
||||
$user_id = get_current_user_id();
|
||||
// Don't create an option if this is a super admin who does not belong to this site.
|
||||
if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) {
|
||||
if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ), true ) ) {
|
||||
update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -922,19 +922,23 @@ function confirm_delete_users( $users ) {
|
||||
'fields' => array( 'ID', 'user_login' ),
|
||||
)
|
||||
);
|
||||
|
||||
if ( is_array( $blog_users ) && ! empty( $blog_users ) ) {
|
||||
$user_site = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>";
|
||||
$user_dropdown = '<label for="reassign_user" class="screen-reader-text">' . __( 'Select a user' ) . '</label>';
|
||||
$user_dropdown .= "<select name='blog[$user_id][$key]' id='reassign_user'>";
|
||||
$user_list = '';
|
||||
|
||||
foreach ( $blog_users as $user ) {
|
||||
if ( ! in_array( $user->ID, $allusers ) ) {
|
||||
if ( ! in_array( (int) $user->ID, $allusers, true ) ) {
|
||||
$user_list .= "<option value='{$user->ID}'>{$user->user_login}</option>";
|
||||
}
|
||||
}
|
||||
|
||||
if ( '' == $user_list ) {
|
||||
$user_list = $admin_out;
|
||||
}
|
||||
|
||||
$user_dropdown .= $user_list;
|
||||
$user_dropdown .= "</select>\n";
|
||||
?>
|
||||
|
||||
@@ -1149,8 +1149,10 @@ function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selecte
|
||||
'post_status' => 'draft,publish',
|
||||
)
|
||||
);
|
||||
$messages = array();
|
||||
$menu_items = array();
|
||||
|
||||
$messages = array();
|
||||
$menu_items = array();
|
||||
|
||||
// Index menu items by DB ID.
|
||||
foreach ( $unsorted_menu_items as $_item ) {
|
||||
$menu_items[ $_item->db_id ] = $_item;
|
||||
@@ -1173,6 +1175,7 @@ function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selecte
|
||||
);
|
||||
|
||||
wp_defer_term_counting( true );
|
||||
|
||||
// Loop through all the menu items' POST variables.
|
||||
if ( ! empty( $_POST['menu-item-db-id'] ) ) {
|
||||
foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) {
|
||||
@@ -1209,19 +1212,22 @@ function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selecte
|
||||
// Store 'auto-add' pages.
|
||||
$auto_add = ! empty( $_POST['auto-add-pages'] );
|
||||
$nav_menu_option = (array) get_option( 'nav_menu_options' );
|
||||
|
||||
if ( ! isset( $nav_menu_option['auto_add'] ) ) {
|
||||
$nav_menu_option['auto_add'] = array();
|
||||
}
|
||||
|
||||
if ( $auto_add ) {
|
||||
if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) {
|
||||
if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'], true ) ) {
|
||||
$nav_menu_option['auto_add'][] = $nav_menu_selected_id;
|
||||
}
|
||||
} else {
|
||||
$key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] );
|
||||
$key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'], true );
|
||||
if ( false !== $key ) {
|
||||
unset( $nav_menu_option['auto_add'][ $key ] );
|
||||
}
|
||||
}
|
||||
|
||||
// Remove non-existent/deleted menus.
|
||||
$nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) );
|
||||
update_option( 'nav_menu_options', $nav_menu_option );
|
||||
|
||||
@@ -2170,7 +2170,7 @@ function add_option_whitelist( $new_options, $options = '' ) {
|
||||
$whitelist_options[ $page ] = array();
|
||||
$whitelist_options[ $page ][] = $key;
|
||||
} else {
|
||||
$pos = array_search( $key, $whitelist_options[ $page ] );
|
||||
$pos = array_search( $key, $whitelist_options[ $page ], true );
|
||||
if ( false === $pos ) {
|
||||
$whitelist_options[ $page ][] = $key;
|
||||
}
|
||||
@@ -2202,7 +2202,7 @@ function remove_option_whitelist( $del_options, $options = '' ) {
|
||||
foreach ( $del_options as $page => $keys ) {
|
||||
foreach ( $keys as $key ) {
|
||||
if ( isset( $whitelist_options[ $page ] ) && is_array( $whitelist_options[ $page ] ) ) {
|
||||
$pos = array_search( $key, $whitelist_options[ $page ] );
|
||||
$pos = array_search( $key, $whitelist_options[ $page ], true );
|
||||
if ( false !== $pos ) {
|
||||
unset( $whitelist_options[ $page ][ $pos ] );
|
||||
}
|
||||
|
||||
@@ -548,8 +548,8 @@ function bulk_edit_posts( $post_data = null ) {
|
||||
$children[] = $parent;
|
||||
|
||||
foreach ( $pages as $page ) {
|
||||
if ( $page->ID == $parent ) {
|
||||
$parent = $page->post_parent;
|
||||
if ( (int) $page->ID === $parent ) {
|
||||
$parent = (int) $page->post_parent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -568,7 +568,7 @@ function bulk_edit_posts( $post_data = null ) {
|
||||
$post_type_object = get_post_type_object( get_post_type( $post_ID ) );
|
||||
|
||||
if ( ! isset( $post_type_object )
|
||||
|| ( isset( $children ) && in_array( $post_ID, $children ) )
|
||||
|| ( isset( $children ) && in_array( $post_ID, $children, true ) )
|
||||
|| ! current_user_can( 'edit_post', $post_ID )
|
||||
) {
|
||||
$skipped[] = $post_ID;
|
||||
|
||||
@@ -314,7 +314,7 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
|
||||
// Now, grab the initial diff.
|
||||
$compare_two_mode = is_numeric( $from );
|
||||
if ( ! $compare_two_mode ) {
|
||||
$found = array_search( $selected_revision_id, array_keys( $revisions ) );
|
||||
$found = array_search( $selected_revision_id, array_keys( $revisions ), true );
|
||||
if ( $found ) {
|
||||
$from = array_keys( array_slice( $revisions, $found - 1, 1, true ) );
|
||||
$from = reset( $from );
|
||||
|
||||
@@ -128,10 +128,12 @@ function meta_box_prefs( $screen ) {
|
||||
$widget_title = $box['args']['__widget_basename'];
|
||||
}
|
||||
|
||||
$is_hidden = in_array( $box['id'], $hidden, true );
|
||||
|
||||
printf(
|
||||
'<label for="%1$s-hide"><input class="hide-postbox-tog" name="%1$s-hide" type="checkbox" id="%1$s-hide" value="%1$s" %2$s />%3$s</label>',
|
||||
esc_attr( $box['id'] ),
|
||||
checked( in_array( $box['id'], $hidden, true ), false, false ),
|
||||
checked( $is_hidden, false, false ),
|
||||
$widget_title
|
||||
);
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ function wp_terms_checklist( $post_id = 0, $args = array() ) {
|
||||
$keys = array_keys( $categories );
|
||||
|
||||
foreach ( $keys as $k ) {
|
||||
if ( in_array( $categories[ $k ]->term_id, $args['selected_cats'] ) ) {
|
||||
if ( in_array( $categories[ $k ]->term_id, $args['selected_cats'], true ) ) {
|
||||
$checked_categories[] = $categories[ $k ];
|
||||
unset( $categories[ $k ] );
|
||||
}
|
||||
@@ -228,13 +228,14 @@ function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $ech
|
||||
$tax = get_taxonomy( $taxonomy );
|
||||
|
||||
$popular_ids = array();
|
||||
|
||||
foreach ( (array) $terms as $term ) {
|
||||
$popular_ids[] = $term->term_id;
|
||||
if ( ! $echo ) { // Hack for Ajax use.
|
||||
continue;
|
||||
}
|
||||
$id = "popular-$taxonomy-$term->term_id";
|
||||
$checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : '';
|
||||
$checked = in_array( $term->term_id, $checked_terms, true ) ? 'checked="checked"' : '';
|
||||
?>
|
||||
|
||||
<li id="<?php echo $id; ?>" class="popular-category">
|
||||
@@ -291,7 +292,7 @@ function wp_link_category_checklist( $link_id = 0 ) {
|
||||
|
||||
/** This filter is documented in wp-includes/category-template.php */
|
||||
$name = esc_html( apply_filters( 'the_category', $category->name, '', '' ) );
|
||||
$checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : '';
|
||||
$checked = in_array( $cat_id, $checked_categories, true ) ? ' checked="checked"' : '';
|
||||
echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', $checked, '/> ', $name, '</label></li>';
|
||||
}
|
||||
}
|
||||
@@ -339,6 +340,7 @@ function get_inline_data( $post ) {
|
||||
}
|
||||
|
||||
$taxonomy_names = get_object_taxonomies( $post->post_type );
|
||||
|
||||
foreach ( $taxonomy_names as $taxonomy_name ) {
|
||||
$taxonomy = get_taxonomy( $taxonomy_name );
|
||||
|
||||
@@ -721,7 +723,6 @@ function meta_form( $post = null ) {
|
||||
<select id="metakeyselect" name="metakeyselect">
|
||||
<option value="#NONE#"><?php _e( '— Select —' ); ?></option>
|
||||
<?php
|
||||
|
||||
foreach ( $keys as $key ) {
|
||||
if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'add_post_meta', $post->ID, $key ) ) {
|
||||
continue;
|
||||
@@ -834,6 +835,7 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
|
||||
}
|
||||
|
||||
echo "\n\n";
|
||||
|
||||
$map = array(
|
||||
'mm' => array( $mm, $cur_mm ),
|
||||
'jj' => array( $jj, $cur_jj ),
|
||||
@@ -841,6 +843,7 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
|
||||
'hh' => array( $hh, $cur_hh ),
|
||||
'mn' => array( $mn, $cur_mn ),
|
||||
);
|
||||
|
||||
foreach ( $map as $timeunit => $value ) {
|
||||
list( $unit, $curr ) = $value;
|
||||
|
||||
@@ -868,7 +871,9 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
|
||||
*/
|
||||
function page_template_dropdown( $default = '', $post_type = 'page' ) {
|
||||
$templates = get_page_templates( null, $post_type );
|
||||
|
||||
ksort( $templates );
|
||||
|
||||
foreach ( array_keys( $templates ) as $template ) {
|
||||
$selected = selected( $default, $templates[ $template ], false );
|
||||
echo "\n\t<option value='" . esc_attr( $templates[ $template ] ) . "' $selected>" . esc_html( $template ) . '</option>';
|
||||
@@ -1195,11 +1200,13 @@ function _get_plugin_from_callback( $callback ) {
|
||||
// Only show errors if the meta box was registered by a plugin.
|
||||
$filename = wp_normalize_path( $reflection->getFileName() );
|
||||
$plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
|
||||
|
||||
if ( strpos( $filename, $plugin_dir ) === 0 ) {
|
||||
$filename = str_replace( $plugin_dir, '', $filename );
|
||||
$filename = preg_replace( '|^/([^/]*/).*$|', '\\1', $filename );
|
||||
|
||||
$plugins = get_plugins();
|
||||
|
||||
foreach ( $plugins as $name => $plugin ) {
|
||||
if ( strpos( $name, $filename ) === 0 ) {
|
||||
return $plugin;
|
||||
@@ -1249,6 +1256,7 @@ function do_meta_boxes( $screen, $context, $object ) {
|
||||
// Grab the ones the user has manually sorted.
|
||||
// Pull them out of their previous context/priority and into the one the user chose.
|
||||
$sorted = get_user_option( "meta-box-order_$page" );
|
||||
|
||||
if ( ! $already_sorted && $sorted ) {
|
||||
foreach ( $sorted as $box_context => $ids ) {
|
||||
foreach ( explode( ',', $ids ) as $id ) {
|
||||
@@ -1780,11 +1788,13 @@ function get_settings_errors( $setting = '', $sanitize = false ) {
|
||||
// Filter the results to those of a specific setting if one was set.
|
||||
if ( $setting ) {
|
||||
$setting_errors = array();
|
||||
|
||||
foreach ( (array) $wp_settings_errors as $key => $details ) {
|
||||
if ( $setting == $details['setting'] ) {
|
||||
$setting_errors[] = $wp_settings_errors[ $key ];
|
||||
}
|
||||
}
|
||||
|
||||
return $setting_errors;
|
||||
}
|
||||
|
||||
@@ -1833,6 +1843,7 @@ function settings_errors( $setting = '', $sanitize = false, $hide_on_update = fa
|
||||
}
|
||||
|
||||
$output = '';
|
||||
|
||||
foreach ( $settings_errors as $key => $details ) {
|
||||
if ( 'updated' === $details['type'] ) {
|
||||
$details['type'] = 'success';
|
||||
@@ -1855,6 +1866,7 @@ function settings_errors( $setting = '', $sanitize = false, $hide_on_update = fa
|
||||
$output .= "<p><strong>{$details['message']}</strong></p>";
|
||||
$output .= "</div> \n";
|
||||
}
|
||||
|
||||
echo $output;
|
||||
}
|
||||
|
||||
@@ -2084,6 +2096,7 @@ function _post_states( $post, $echo = true ) {
|
||||
$i = 0;
|
||||
|
||||
$post_states_string .= ' — ';
|
||||
|
||||
foreach ( $post_states as $state ) {
|
||||
++$i;
|
||||
( $i == $state_count ) ? $sep = '' : $sep = ', ';
|
||||
@@ -2188,7 +2201,7 @@ function _media_states( $post ) {
|
||||
if ( is_random_header_image() ) {
|
||||
$header_images = wp_list_pluck( get_uploaded_header_images(), 'attachment_id' );
|
||||
|
||||
if ( $meta_header == $stylesheet && in_array( $post->ID, $header_images ) ) {
|
||||
if ( $meta_header == $stylesheet && in_array( $post->ID, $header_images, true ) ) {
|
||||
$media_states[] = __( 'Header Image' );
|
||||
}
|
||||
} else {
|
||||
@@ -2242,7 +2255,9 @@ function _media_states( $post ) {
|
||||
if ( ! empty( $media_states ) ) {
|
||||
$state_count = count( $media_states );
|
||||
$i = 0;
|
||||
|
||||
echo ' — ';
|
||||
|
||||
foreach ( $media_states as $state ) {
|
||||
++$i;
|
||||
( $i == $state_count ) ? $sep = '' : $sep = ', ';
|
||||
@@ -2369,12 +2384,15 @@ function get_submit_button( $text = '', $type = 'primary large', $name = 'submit
|
||||
|
||||
$button_shorthand = array( 'primary', 'small', 'large' );
|
||||
$classes = array( 'button' );
|
||||
|
||||
foreach ( $type as $t ) {
|
||||
if ( 'secondary' === $t || 'button-secondary' === $t ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$classes[] = in_array( $t, $button_shorthand, true ) ? 'button-' . $t : $t;
|
||||
}
|
||||
|
||||
// Remove empty items, remove duplicate items, and finally build a string.
|
||||
$class = implode( ' ', array_unique( array_filter( $classes ) ) );
|
||||
|
||||
|
||||
@@ -104,8 +104,11 @@ switch ( $action ) {
|
||||
$next_item_data['menu_item_parent'] != $menu_item_data['menu_item_parent']
|
||||
)
|
||||
) {
|
||||
|
||||
$parent_db_id = in_array( $menu_item_data['menu_item_parent'], $orders_to_dbids ) ? (int) $menu_item_data['menu_item_parent'] : 0;
|
||||
if ( in_array( (int) $menu_item_data['menu_item_parent'], $orders_to_dbids, true ) ) {
|
||||
$parent_db_id = (int) $menu_item_data['menu_item_parent'];
|
||||
} else {
|
||||
$parent_db_id = 0;
|
||||
}
|
||||
|
||||
$parent_object = wp_setup_nav_menu_item( get_post( $parent_db_id ) );
|
||||
|
||||
@@ -131,7 +134,7 @@ switch ( $action ) {
|
||||
// The item is last but still has a parent, so bubble up.
|
||||
} elseif (
|
||||
! empty( $menu_item_data['menu_item_parent'] ) &&
|
||||
in_array( $menu_item_data['menu_item_parent'], $orders_to_dbids )
|
||||
in_array( (int) $menu_item_data['menu_item_parent'], $orders_to_dbids, true )
|
||||
) {
|
||||
$menu_item_data['menu_item_parent'] = (int) get_post_meta( $menu_item_data['menu_item_parent'], '_menu_item_menu_item_parent', true );
|
||||
update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
|
||||
@@ -168,11 +171,16 @@ switch ( $action ) {
|
||||
// If this menu item is a child of the previous.
|
||||
if (
|
||||
! empty( $menu_item_data['menu_item_parent'] ) &&
|
||||
in_array( $menu_item_data['menu_item_parent'], array_keys( $dbids_to_orders ) ) &&
|
||||
in_array( (int) $menu_item_data['menu_item_parent'], array_keys( $dbids_to_orders ), true ) &&
|
||||
isset( $orders_to_dbids[ $dbids_to_orders[ $menu_item_id ] - 1 ] ) &&
|
||||
( $menu_item_data['menu_item_parent'] == $orders_to_dbids[ $dbids_to_orders[ $menu_item_id ] - 1 ] )
|
||||
) {
|
||||
$parent_db_id = in_array( $menu_item_data['menu_item_parent'], $orders_to_dbids ) ? (int) $menu_item_data['menu_item_parent'] : 0;
|
||||
if ( in_array( (int) $menu_item_data['menu_item_parent'], $orders_to_dbids, true ) ) {
|
||||
$parent_db_id = (int) $menu_item_data['menu_item_parent'];
|
||||
} else {
|
||||
$parent_db_id = 0;
|
||||
}
|
||||
|
||||
$parent_object = wp_setup_nav_menu_item( get_post( $parent_db_id ) );
|
||||
|
||||
if ( ! is_wp_error( $parent_object ) ) {
|
||||
@@ -198,7 +206,7 @@ switch ( $action ) {
|
||||
! empty( $orders_to_dbids[ $dbids_to_orders[ $parent_db_id ] - 1 ] )
|
||||
) {
|
||||
$_possible_parent_id = (int) get_post_meta( $orders_to_dbids[ $dbids_to_orders[ $parent_db_id ] - 1 ], '_menu_item_menu_item_parent', true );
|
||||
if ( in_array( $_possible_parent_id, array_keys( $dbids_to_orders ) ) ) {
|
||||
if ( in_array( $_possible_parent_id, array_keys( $dbids_to_orders ), true ) ) {
|
||||
$menu_item_data['menu_item_parent'] = $_possible_parent_id;
|
||||
} else {
|
||||
$menu_item_data['menu_item_parent'] = 0;
|
||||
@@ -225,7 +233,7 @@ switch ( $action ) {
|
||||
} elseif (
|
||||
empty( $menu_item_data['menu_order'] ) ||
|
||||
empty( $menu_item_data['menu_item_parent'] ) ||
|
||||
! in_array( $menu_item_data['menu_item_parent'], array_keys( $dbids_to_orders ) ) ||
|
||||
! in_array( (int) $menu_item_data['menu_item_parent'], array_keys( $dbids_to_orders ), true ) ||
|
||||
empty( $orders_to_dbids[ $dbids_to_orders[ $menu_item_id ] - 1 ] ) ||
|
||||
$orders_to_dbids[ $dbids_to_orders[ $menu_item_id ] - 1 ] != $menu_item_data['menu_item_parent']
|
||||
) {
|
||||
@@ -800,9 +808,10 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
|
||||
<?php
|
||||
echo esc_html( $_nav_menu->truncated_name );
|
||||
|
||||
if ( ! empty( $menu_locations ) && in_array( $_nav_menu->term_id, $menu_locations ) ) {
|
||||
if ( ! empty( $menu_locations ) && in_array( $_nav_menu->term_id, $menu_locations, true ) ) {
|
||||
$locations_assigned_to_this_menu = array();
|
||||
foreach ( array_keys( $menu_locations, $_nav_menu->term_id ) as $menu_location_key ) {
|
||||
|
||||
foreach ( array_keys( $menu_locations, $_nav_menu->term_id, true ) as $menu_location_key ) {
|
||||
if ( isset( $locations[ $menu_location_key ] ) ) {
|
||||
$locations_assigned_to_this_menu[] = $locations[ $menu_location_key ];
|
||||
}
|
||||
@@ -815,7 +824,9 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
|
||||
*
|
||||
* @param int $locations Number of menu locations to list. Default 3.
|
||||
*/
|
||||
$assigned_locations = array_slice( $locations_assigned_to_this_menu, 0, absint( apply_filters( 'wp_nav_locations_listed_per_menu', 3 ) ) );
|
||||
$locations_listed_per_menu = absint( apply_filters( 'wp_nav_locations_listed_per_menu', 3 ) );
|
||||
|
||||
$assigned_locations = array_slice( $locations_assigned_to_this_menu, 0, $locations_listed_per_menu );
|
||||
|
||||
// Adds ellipses following the number of locations defined in $assigned_locations.
|
||||
if ( ! empty( $assigned_locations ) ) {
|
||||
@@ -956,9 +967,10 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
|
||||
<?php
|
||||
if ( ! isset( $auto_add ) ) {
|
||||
$auto_add = get_option( 'nav_menu_options' );
|
||||
|
||||
if ( ! isset( $auto_add['auto_add'] ) ) {
|
||||
$auto_add = false;
|
||||
} elseif ( false !== array_search( $nav_menu_selected_id, $auto_add['auto_add'] ) ) {
|
||||
} elseif ( false !== array_search( $nav_menu_selected_id, $auto_add['auto_add'], true ) ) {
|
||||
$auto_add = true;
|
||||
} else {
|
||||
$auto_add = false;
|
||||
|
||||
@@ -72,8 +72,9 @@ if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] ) {
|
||||
|
||||
$existing_details = get_site( $id );
|
||||
$blog_data_checkboxes = array( 'public', 'archived', 'spam', 'mature', 'deleted' );
|
||||
|
||||
foreach ( $blog_data_checkboxes as $c ) {
|
||||
if ( ! in_array( $existing_details->$c, array( 0, 1 ) ) ) {
|
||||
if ( ! in_array( (int) $existing_details->$c, array( 0, 1 ), true ) ) {
|
||||
$blog_data[ $c ] = $existing_details->$c;
|
||||
} else {
|
||||
$blog_data[ $c ] = isset( $_POST['blog'][ $c ] ) ? 1 : 0;
|
||||
@@ -194,7 +195,7 @@ if ( ! empty( $messages ) ) {
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text"><?php _e( 'Set site attributes' ); ?></legend>
|
||||
<?php foreach ( $attribute_fields as $field_key => $field_label ) : ?>
|
||||
<label><input type="checkbox" name="blog[<?php echo $field_key; ?>]" value="1" <?php checked( (bool) $details->$field_key, true ); ?> <?php disabled( ! in_array( $details->$field_key, array( 0, 1 ) ) ); ?> />
|
||||
<label><input type="checkbox" name="blog[<?php echo $field_key; ?>]" value="1" <?php checked( (bool) $details->$field_key, true ); ?> <?php disabled( ! in_array( (int) $details->$field_key, array( 0, 1 ), true ) ); ?> />
|
||||
<?php echo $field_label; ?></label><br/>
|
||||
<?php endforeach; ?>
|
||||
<fieldset>
|
||||
|
||||
@@ -237,7 +237,7 @@ switch ( $wp_list_table->current_action() ) {
|
||||
|
||||
$all_userids = $userids;
|
||||
|
||||
if ( in_array( $current_user->ID, $userids ) ) {
|
||||
if ( in_array( $current_user->ID, $userids, true ) ) {
|
||||
$userids = array_diff( $userids, array( $current_user->ID ) );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user