diff --git a/wp-activate.php b/wp-activate.php index 446cb7382c..3258c07d32 100644 --- a/wp-activate.php +++ b/wp-activate.php @@ -57,7 +57,7 @@ if ( null === $result || ( is_wp_error( $result ) && 'invalid_key' === $result-> } elseif ( is_wp_error( $result ) ) { $error_code = $result->get_error_code(); - if ( ! in_array( $error_code, $valid_error_codes ) ) { + if ( ! in_array( $error_code, $valid_error_codes, true ) ) { status_header( 400 ); } } @@ -136,7 +136,7 @@ get_header( 'wp-activate' ); get_error_code(), $valid_error_codes ) ) { + if ( is_wp_error( $result ) && in_array( $result->get_error_code(), $valid_error_codes, true ) ) { $signup = $result->get_error_data(); ?>

diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index d3dc4da2a5..4f41a31bd6 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -146,11 +146,11 @@ $core_actions_post_deprecated = array( 'wp-fullscreen-save-post', 'press-this-sa $core_actions_post = array_merge( $core_actions_post, $core_actions_post_deprecated ); // Register core Ajax calls. -if ( ! empty( $_GET['action'] ) && in_array( $_GET['action'], $core_actions_get ) ) { +if ( ! empty( $_GET['action'] ) && in_array( $_GET['action'], $core_actions_get, true ) ) { add_action( 'wp_ajax_' . $_GET['action'], 'wp_ajax_' . str_replace( '-', '_', $_GET['action'] ), 1 ); } -if ( ! empty( $_POST['action'] ) && in_array( $_POST['action'], $core_actions_post ) ) { +if ( ! empty( $_POST['action'] ) && in_array( $_POST['action'], $core_actions_post, true ) ) { add_action( 'wp_ajax_' . $_POST['action'], 'wp_ajax_' . str_replace( '-', '_', $_POST['action'] ), 1 ); } diff --git a/wp-admin/comment.php b/wp-admin/comment.php index 3f20c3cc2e..fea0b8a37c 100644 --- a/wp-admin/comment.php +++ b/wp-admin/comment.php @@ -255,7 +255,7 @@ switch ( $action ) { case 'unapprovecomment': $comment_id = absint( $_REQUEST['c'] ); - if ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) { + if ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ), true ) ) { check_admin_referer( 'approve-comment_' . $comment_id ); } else { check_admin_referer( 'delete-comment_' . $comment_id ); @@ -275,7 +275,7 @@ switch ( $action ) { $redir = wp_get_referer(); } elseif ( '' != wp_get_original_referer() && ! $noredir ) { $redir = wp_get_original_referer(); - } elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) { + } elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ), true ) ) { $redir = admin_url( 'edit-comments.php?p=' . absint( $comment->comment_post_ID ) ); } else { $redir = admin_url( 'edit-comments.php' ); diff --git a/wp-admin/edit-tags.php b/wp-admin/edit-tags.php index aedd70c1c5..cb1ac29fdb 100644 --- a/wp-admin/edit-tags.php +++ b/wp-admin/edit-tags.php @@ -19,7 +19,7 @@ if ( ! $tax ) { wp_die( __( 'Invalid taxonomy.' ) ); } -if ( ! in_array( $tax->name, get_taxonomies( array( 'show_ui' => true ) ) ) ) { +if ( ! in_array( $tax->name, get_taxonomies( array( 'show_ui' => true ) ), true ) ) { wp_die( __( 'Sorry, you are not allowed to edit terms in this taxonomy.' ) ); } diff --git a/wp-admin/edit.php b/wp-admin/edit.php index 1fb89e1e95..bc562d47cb 100644 --- a/wp-admin/edit.php +++ b/wp-admin/edit.php @@ -13,7 +13,7 @@ if ( ! $typenow ) { wp_die( __( 'Invalid post type.' ) ); } -if ( ! in_array( $typenow, get_post_types( array( 'show_ui' => true ) ) ) ) { +if ( ! in_array( $typenow, get_post_types( array( 'show_ui' => true ) ), true ) ) { wp_die( __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); } diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index ea33d9d792..d46e94ff24 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -976,7 +976,7 @@ function wp_ajax_dim_comment() { check_ajax_referer( "approve-comment_$id" ); - if ( in_array( $current, array( 'unapproved', 'spam' ) ) ) { + if ( in_array( $current, array( 'unapproved', 'spam' ), true ) ) { $result = wp_set_comment_status( $comment, 'approve', true ); } else { $result = wp_set_comment_status( $comment, 'hold', true ); @@ -1271,7 +1271,7 @@ function wp_ajax_replyto_comment( $action ) { if ( empty( $post->post_status ) ) { wp_die( 1 ); - } elseif ( in_array( $post->post_status, array( 'draft', 'pending', 'trash' ) ) ) { + } elseif ( in_array( $post->post_status, array( 'draft', 'pending', 'trash' ), true ) ) { wp_die( __( 'Error: You are replying to a comment on a draft post.' ) ); } @@ -2057,7 +2057,7 @@ function wp_ajax_inline_save() { } // Hack: wp_unique_post_slug() doesn't work for drafts, so we will fake that our post is published. - if ( ! empty( $data['post_name'] ) && in_array( $post['post_status'], array( 'draft', 'pending' ) ) ) { + if ( ! empty( $data['post_name'] ) && in_array( $post['post_status'], array( 'draft', 'pending' ), true ) ) { $post['post_status'] = 'publish'; $data['post_name'] = wp_unique_post_slug( $data['post_name'], $post['ID'], $post['post_status'], $post['post_type'], $post['post_parent'] ); } @@ -2525,7 +2525,7 @@ function wp_ajax_upload_attachment() { } // If the context is custom header or background, make sure the uploaded file is an image. - if ( isset( $post_data['context'] ) && in_array( $post_data['context'], array( 'custom-header', 'custom-background' ) ) ) { + if ( isset( $post_data['context'] ) && in_array( $post_data['context'], array( 'custom-header', 'custom-background' ), true ) ) { $wp_filetype = wp_check_filetype_and_ext( $_FILES['async-upload']['tmp_name'], $_FILES['async-upload']['name'] ); if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) { @@ -2852,7 +2852,7 @@ function wp_ajax_dismiss_wp_pointer() { $dismissed = array_filter( explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) ); - if ( in_array( $pointer, $dismissed ) ) { + if ( in_array( $pointer, $dismissed, true ) ) { wp_die( 0 ); } diff --git a/wp-admin/includes/class-custom-background.php b/wp-admin/includes/class-custom-background.php index 30a05bf607..b62db4fb05 100644 --- a/wp-admin/includes/class-custom-background.php +++ b/wp-admin/includes/class-custom-background.php @@ -601,7 +601,7 @@ class Custom_Background { ); $size = 'thumbnail'; - if ( in_array( $_POST['size'], $sizes ) ) { + if ( in_array( $_POST['size'], $sizes, true ) ) { $size = esc_attr( $_POST['size'] ); } diff --git a/wp-admin/includes/class-custom-image-header.php b/wp-admin/includes/class-custom-image-header.php index 841dccc319..a8264d5bb7 100644 --- a/wp-admin/includes/class-custom-image-header.php +++ b/wp-admin/includes/class-custom-image-header.php @@ -1097,7 +1097,7 @@ endif; return; } - if ( in_array( $choice, array( 'remove-header', 'random-default-image', 'random-uploaded-image' ) ) ) { + if ( in_array( $choice, array( 'remove-header', 'random-default-image', 'random-uploaded-image' ), true ) ) { set_theme_mod( 'header_image', $choice ); remove_theme_mod( 'header_image_data' ); return; diff --git a/wp-admin/includes/class-walker-category-checklist.php b/wp-admin/includes/class-walker-category-checklist.php index 488d34d134..3647d8770b 100644 --- a/wp-admin/includes/class-walker-category-checklist.php +++ b/wp-admin/includes/class-walker-category-checklist.php @@ -82,7 +82,8 @@ 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'] ) ? ' class="popular-category"' : ''; $args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats']; diff --git a/wp-admin/includes/class-wp-automatic-updater.php b/wp-admin/includes/class-wp-automatic-updater.php index d6ec70e85b..10461f8f50 100644 --- a/wp-admin/includes/class-wp-automatic-updater.php +++ b/wp-admin/includes/class-wp-automatic-updater.php @@ -577,7 +577,7 @@ class WP_Automatic_Updater { */ $send = true; $transient_failures = array( 'incompatible_archive', 'download_failed', 'insane_distro', 'locked' ); - if ( in_array( $error_code, $transient_failures ) && ! get_site_option( 'auto_core_update_failed' ) ) { + if ( in_array( $error_code, $transient_failures, true ) && ! get_site_option( 'auto_core_update_failed' ) ) { wp_schedule_single_event( time() + HOUR_IN_SECONDS, 'wp_maybe_auto_update' ); $send = false; } @@ -596,7 +596,7 @@ class WP_Automatic_Updater { 'error_code' => $error_code, 'error_data' => $result->get_error_data(), 'timestamp' => time(), - 'retry' => in_array( $error_code, $transient_failures ), + 'retry' => in_array( $error_code, $transient_failures, true ), ) ); diff --git a/wp-admin/includes/class-wp-comments-list-table.php b/wp-admin/includes/class-wp-comments-list-table.php index be00e1f7b2..9b273f42fb 100644 --- a/wp-admin/includes/class-wp-comments-list-table.php +++ b/wp-admin/includes/class-wp-comments-list-table.php @@ -87,7 +87,7 @@ class WP_Comments_List_Table extends WP_List_Table { global $post_id, $comment_status, $search, $comment_type; $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all'; - if ( ! in_array( $comment_status, array( 'all', 'mine', 'moderated', 'approved', 'spam', 'trash' ) ) ) { + if ( ! in_array( $comment_status, array( 'all', 'mine', 'moderated', 'approved', 'spam', 'trash' ), true ) ) { $comment_status = 'all'; } @@ -344,13 +344,13 @@ class WP_Comments_List_Table extends WP_List_Table { global $comment_status; $actions = array(); - if ( in_array( $comment_status, array( 'all', 'approved' ) ) ) { + if ( in_array( $comment_status, array( 'all', 'approved' ), true ) ) { $actions['unapprove'] = __( 'Unapprove' ); } - if ( in_array( $comment_status, array( 'all', 'moderated' ) ) ) { + if ( in_array( $comment_status, array( 'all', 'moderated' ), true ) ) { $actions['approve'] = __( 'Approve' ); } - if ( in_array( $comment_status, array( 'all', 'moderated', 'approved', 'trash' ) ) ) { + if ( in_array( $comment_status, array( 'all', 'moderated', 'approved', 'trash' ), true ) ) { $actions['spam'] = _x( 'Mark as Spam', 'comment' ); } @@ -360,7 +360,7 @@ class WP_Comments_List_Table extends WP_List_Table { $actions['unspam'] = _x( 'Not Spam', 'comment' ); } - if ( in_array( $comment_status, array( 'trash', 'spam' ) ) || ! EMPTY_TRASH_DAYS ) { + if ( in_array( $comment_status, array( 'trash', 'spam' ), true ) || ! EMPTY_TRASH_DAYS ) { $actions['delete'] = __( 'Delete Permanently' ); } else { $actions['trash'] = __( 'Move to Trash' ); diff --git a/wp-admin/includes/class-wp-community-events.php b/wp-admin/includes/class-wp-community-events.php index 443968f4d7..7e9c7fdbb1 100644 --- a/wp-admin/includes/class-wp-community-events.php +++ b/wp-admin/includes/class-wp-community-events.php @@ -466,7 +466,7 @@ class WP_Community_Events { $trimmed_event_types = wp_list_pluck( $response_body['events'], 'type' ); // Make sure the soonest upcoming WordCamp is pinned in the list. - if ( ! in_array( 'wordcamp', $trimmed_event_types ) && $wordcamps ) { + if ( ! in_array( 'wordcamp', $trimmed_event_types, true ) && $wordcamps ) { array_pop( $response_body['events'] ); array_push( $response_body['events'], $wordcamps[0] ); } diff --git a/wp-admin/includes/class-wp-list-table.php b/wp-admin/includes/class-wp-list-table.php index c423eebbca..791ee7c159 100644 --- a/wp-admin/includes/class-wp-list-table.php +++ b/wp-admin/includes/class-wp-list-table.php @@ -181,7 +181,7 @@ class WP_List_Table { * @return mixed Property. */ public function __get( $name ) { - if ( in_array( $name, $this->compat_fields ) ) { + if ( in_array( $name, $this->compat_fields, true ) ) { return $this->$name; } } @@ -196,7 +196,7 @@ class WP_List_Table { * @return mixed Newly-set property. */ public function __set( $name, $value ) { - if ( in_array( $name, $this->compat_fields ) ) { + if ( in_array( $name, $this->compat_fields, true ) ) { return $this->$name = $value; } } @@ -210,7 +210,7 @@ class WP_List_Table { * @return bool Whether the property is set. */ public function __isset( $name ) { - if ( in_array( $name, $this->compat_fields ) ) { + if ( in_array( $name, $this->compat_fields, true ) ) { return isset( $this->$name ); } } @@ -223,7 +223,7 @@ class WP_List_Table { * @param string $name Property to unset. */ public function __unset( $name ) { - if ( in_array( $name, $this->compat_fields ) ) { + if ( in_array( $name, $this->compat_fields, true ) ) { unset( $this->$name ); } } @@ -238,7 +238,7 @@ class WP_List_Table { * @return mixed|bool Return value of the callback, false otherwise. */ public function __call( $name, $arguments ) { - if ( in_array( $name, $this->compat_methods ) ) { + if ( in_array( $name, $this->compat_methods, true ) ) { return $this->$name( ...$arguments ); } return false; @@ -1133,13 +1133,13 @@ class WP_List_Table { foreach ( $columns as $column_key => $column_display_name ) { $class = array( 'manage-column', "column-$column_key" ); - if ( in_array( $column_key, $hidden ) ) { + if ( in_array( $column_key, $hidden, true ) ) { $class[] = 'hidden'; } if ( 'cb' === $column_key ) { $class[] = 'check-column'; - } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) { + } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ), true ) ) { $class[] = 'num'; } @@ -1329,7 +1329,7 @@ class WP_List_Table { $classes .= ' has-row-actions column-primary'; } - if ( in_array( $column_name, $hidden ) ) { + if ( in_array( $column_name, $hidden, true ) ) { $classes .= ' hidden'; } diff --git a/wp-admin/includes/class-wp-ms-themes-list-table.php b/wp-admin/includes/class-wp-ms-themes-list-table.php index 6cce71439e..03441acbe6 100644 --- a/wp-admin/includes/class-wp-ms-themes-list-table.php +++ b/wp-admin/includes/class-wp-ms-themes-list-table.php @@ -45,7 +45,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table { ); $status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all'; - if ( ! in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ) ) ) { + if ( ! in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ), true ) ) { $status = 'all'; } @@ -143,7 +143,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table { $totals[ $type ] = count( $list ); } - if ( empty( $themes[ $status ] ) && ! in_array( $status, array( 'all', 'search' ) ) ) { + if ( empty( $themes[ $status ] ) && ! in_array( $status, array( 'all', 'search' ), true ) ) { $status = 'all'; } @@ -674,7 +674,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table { foreach ( $columns as $column_name => $column_display_name ) { $extra_classes = ''; - if ( in_array( $column_name, $hidden ) ) { + if ( in_array( $column_name, $hidden, true ) ) { $extra_classes .= ' hidden'; } diff --git a/wp-admin/includes/class-wp-ms-users-list-table.php b/wp-admin/includes/class-wp-ms-users-list-table.php index 1a66738d47..4f2932acdc 100644 --- a/wp-admin/includes/class-wp-ms-users-list-table.php +++ b/wp-admin/includes/class-wp-ms-users-list-table.php @@ -281,7 +281,7 @@ class WP_MS_Users_List_Table extends WP_List_Table { user_login, $super_admins ) ) { + if ( in_array( $user->user_login, $super_admins, true ) ) { echo ' — ' . __( 'Super Admin' ); } ?> diff --git a/wp-admin/includes/class-wp-plugin-install-list-table.php b/wp-admin/includes/class-wp-plugin-install-list-table.php index efb46b5dba..ff172b80d0 100644 --- a/wp-admin/includes/class-wp-plugin-install-list-table.php +++ b/wp-admin/includes/class-wp-plugin-install-list-table.php @@ -136,7 +136,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table { $nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs ); // If a non-valid menu tab has been selected, And it's not a non-menu action. - if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs ) ) ) { + if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs, true ) ) ) { $tab = key( $tabs ); } diff --git a/wp-admin/includes/class-wp-plugins-list-table.php b/wp-admin/includes/class-wp-plugins-list-table.php index 3ec88eb7c2..ba8584ecc6 100644 --- a/wp-admin/includes/class-wp-plugins-list-table.php +++ b/wp-admin/includes/class-wp-plugins-list-table.php @@ -39,8 +39,10 @@ class WP_Plugins_List_Table extends WP_List_Table { ) ); + $status_whitelist = array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search', 'paused' ); + $status = 'all'; - if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search', 'paused' ) ) ) { + if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], $status_whitelist, true ) ) { $status = $_REQUEST['plugin_status']; } @@ -243,7 +245,7 @@ class WP_Plugins_List_Table extends WP_List_Table { $totals[ $type ] = count( $list ); } - if ( empty( $plugins[ $status ] ) && ! in_array( $status, array( 'all', 'search' ) ) ) { + if ( empty( $plugins[ $status ] ) && ! in_array( $status, array( 'all', 'search' ), true ) ) { $status = 'all'; } @@ -398,7 +400,7 @@ class WP_Plugins_List_Table extends WP_List_Table { global $status; return array( - 'cb' => ! in_array( $status, array( 'mustuse', 'dropins' ) ) ? '' : '', + 'cb' => ! in_array( $status, array( 'mustuse', 'dropins' ), true ) ? '' : '', 'name' => __( 'Plugin' ), 'description' => __( 'Description' ), ); @@ -542,7 +544,7 @@ class WP_Plugins_List_Table extends WP_List_Table { public function bulk_actions( $which = '' ) { global $status; - if ( in_array( $status, array( 'mustuse', 'dropins' ) ) ) { + if ( in_array( $status, array( 'mustuse', 'dropins' ), true ) ) { return; } @@ -556,7 +558,7 @@ class WP_Plugins_List_Table extends WP_List_Table { protected function extra_tablenav( $which ) { global $status; - if ( ! in_array( $status, array( 'recently_activated', 'mustuse', 'dropins' ) ) ) { + if ( ! in_array( $status, array( 'recently_activated', 'mustuse', 'dropins' ), true ) ) { return; } @@ -597,7 +599,7 @@ class WP_Plugins_List_Table extends WP_List_Table { public function display_rows() { global $status; - if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && in_array( $status, array( 'mustuse', 'dropins' ) ) ) { + if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && in_array( $status, array( 'mustuse', 'dropins' ), true ) ) { return; } @@ -831,7 +833,7 @@ class WP_Plugins_List_Table extends WP_List_Table { $compatible_php = is_php_version_compatible( $requires_php ); $class = $is_active ? 'active' : 'inactive'; $checkbox_id = 'checkbox_' . md5( $plugin_data['Name'] ); - if ( $restrict_network_active || $restrict_network_only || in_array( $status, array( 'mustuse', 'dropins' ) ) || ! $compatible_php ) { + if ( $restrict_network_active || $restrict_network_only || in_array( $status, array( 'mustuse', 'dropins' ), true ) || ! $compatible_php ) { $checkbox = ''; } else { $checkbox = sprintf( @@ -870,7 +872,7 @@ class WP_Plugins_List_Table extends WP_List_Table { foreach ( $columns as $column_name => $column_display_name ) { $extra_classes = ''; - if ( in_array( $column_name, $hidden ) ) { + if ( in_array( $column_name, $hidden, true ) ) { $extra_classes = ' hidden'; } diff --git a/wp-admin/includes/class-wp-posts-list-table.php b/wp-admin/includes/class-wp-posts-list-table.php index b1aec0f793..871feeb84e 100644 --- a/wp-admin/includes/class-wp-posts-list-table.php +++ b/wp-admin/includes/class-wp-posts-list-table.php @@ -161,7 +161,7 @@ class WP_Posts_List_Table extends WP_List_Table { } else { $post_counts = (array) wp_count_posts( $post_type, 'readable' ); - if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'], $avail_post_stati ) ) { + if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'], $avail_post_stati, true ) ) { $total_items = $post_counts[ $_REQUEST['post_status'] ]; } elseif ( isset( $_REQUEST['show_sticky'] ) && $_REQUEST['show_sticky'] ) { $total_items = $this->sticky_posts_count; @@ -346,7 +346,7 @@ class WP_Posts_List_Table extends WP_List_Table { $status_name = $status->name; - if ( ! in_array( $status_name, $avail_post_stati ) || empty( $num_posts->$status_name ) ) { + if ( ! in_array( $status_name, $avail_post_stati, true ) || empty( $num_posts->$status_name ) ) { continue; } @@ -391,7 +391,7 @@ class WP_Posts_List_Table extends WP_List_Table { ); // Sticky comes after Publish, or if not listed, after All. - $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) ); + $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ), true ); $status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) ); } @@ -646,7 +646,7 @@ class WP_Posts_List_Table extends WP_List_Table { } $post_status = ! empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all'; - if ( post_type_supports( $post_type, 'comments' ) && ! in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) { + if ( post_type_supports( $post_type, 'comments' ) && ! in_array( $post_status, array( 'pending', 'draft', 'future' ), true ) ) { $posts_columns['comments'] = '' . __( 'Comments' ) . ''; } @@ -1384,7 +1384,7 @@ class WP_Posts_List_Table extends WP_List_Table { } if ( is_post_type_viewable( $post_type_object ) ) { - if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) { + if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ), true ) ) { if ( $can_edit_post ) { $preview_link = get_preview_post_link( $post ); $actions['view'] = sprintf( diff --git a/wp-admin/includes/class-wp-screen.php b/wp-admin/includes/class-wp-screen.php index 3a06e3a34a..e983ffef80 100644 --- a/wp-admin/includes/class-wp-screen.php +++ b/wp-admin/includes/class-wp-screen.php @@ -1157,7 +1157,7 @@ final class WP_Screen { foreach ( $columns as $column => $title ) { // Can't hide these for they are special. - if ( in_array( $column, $special ) ) { + if ( in_array( $column, $special, true ) ) { continue; } @@ -1174,7 +1174,7 @@ final class WP_Screen { $id = "$column-hide"; echo '\n"; } ?> @@ -1310,7 +1310,7 @@ final class WP_Screen { */ $view_mode_post_types = apply_filters( 'view_mode_post_types', $view_mode_post_types ); - if ( ! in_array( $this->post_type, $view_mode_post_types ) ) { + if ( ! in_array( $this->post_type, $view_mode_post_types, true ) ) { return; } diff --git a/wp-admin/includes/class-wp-terms-list-table.php b/wp-admin/includes/class-wp-terms-list-table.php index 9af2f0e502..03b997a443 100644 --- a/wp-admin/includes/class-wp-terms-list-table.php +++ b/wp-admin/includes/class-wp-terms-list-table.php @@ -61,7 +61,7 @@ class WP_Terms_List_Table extends WP_List_Table { $tax = get_taxonomy( $taxonomy ); // @todo Still needed? Maybe just the show_ui part. - if ( empty( $post_type ) || ! in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) ) { + if ( empty( $post_type ) || ! in_array( $post_type, get_post_types( array( 'show_ui' => true ) ), true ) ) { $post_type = 'post'; } diff --git a/wp-admin/includes/class-wp-theme-install-list-table.php b/wp-admin/includes/class-wp-theme-install-list-table.php index 04594edaa0..824e213a0c 100644 --- a/wp-admin/includes/class-wp-theme-install-list-table.php +++ b/wp-admin/includes/class-wp-theme-install-list-table.php @@ -82,7 +82,7 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table { $nonmenu_tabs = apply_filters( 'install_themes_nonmenu_tabs', $nonmenu_tabs ); // If a non-valid menu tab has been selected, And it's not a non-menu action. - if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs ) ) ) { + if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs, true ) ) ) { $tab = key( $tabs ); } diff --git a/wp-admin/includes/class-wp-themes-list-table.php b/wp-admin/includes/class-wp-themes-list-table.php index 73143f393f..c9d943549a 100644 --- a/wp-admin/includes/class-wp-themes-list-table.php +++ b/wp-admin/includes/class-wp-themes-list-table.php @@ -302,14 +302,14 @@ class WP_Themes_List_Table extends WP_List_Table { public function search_theme( $theme ) { // Search the features. foreach ( $this->features as $word ) { - if ( ! in_array( $word, $theme->get( 'Tags' ) ) ) { + if ( ! in_array( $word, $theme->get( 'Tags' ), true ) ) { return false; } } // Match all phrases. foreach ( $this->search_terms as $word ) { - if ( in_array( $word, $theme->get( 'Tags' ) ) ) { + if ( in_array( $word, $theme->get( 'Tags' ), true ) ) { continue; } diff --git a/wp-admin/includes/class-wp-upgrader.php b/wp-admin/includes/class-wp-upgrader.php index a399bad07f..760d598515 100644 --- a/wp-admin/includes/class-wp-upgrader.php +++ b/wp-admin/includes/class-wp-upgrader.php @@ -545,7 +545,7 @@ class WP_Upgrader { $protected_directories = array_merge( $protected_directories, $wp_theme_directories ); } - if ( in_array( $destination, $protected_directories ) ) { + if ( in_array( $destination, $protected_directories, true ) ) { $remote_destination = trailingslashit( $remote_destination ) . trailingslashit( basename( $source ) ); $destination = trailingslashit( $destination ) . trailingslashit( basename( $source ) ); } diff --git a/wp-admin/includes/class-wp-users-list-table.php b/wp-admin/includes/class-wp-users-list-table.php index 505aa9a435..018654bdd2 100644 --- a/wp-admin/includes/class-wp-users-list-table.php +++ b/wp-admin/includes/class-wp-users-list-table.php @@ -517,7 +517,7 @@ class WP_Users_List_Table extends WP_List_Table { $classes .= ' num'; // Special case for that column. } - if ( in_array( $column_name, $hidden ) ) { + if ( in_array( $column_name, $hidden, true ) ) { $classes .= ' hidden'; } diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index ef2e833132..2a31c6c0b3 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -195,7 +195,7 @@ function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_ $side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' ); $location = 'normal'; - if ( in_array( $widget_id, $side_widgets ) ) { + if ( in_array( $widget_id, $side_widgets, true ) ) { $location = 'side'; } diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index be67f664f3..53967c6dfb 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -1215,7 +1215,7 @@ function verify_file_signature( $filename, $signatures, $filename_for_errors = f } // Check we can process signatures. - if ( ! function_exists( 'sodium_crypto_sign_verify_detached' ) || ! in_array( 'sha384', array_map( 'strtolower', hash_algos() ) ) ) { + if ( ! function_exists( 'sodium_crypto_sign_verify_detached' ) || ! in_array( 'sha384', array_map( 'strtolower', hash_algos() ), true ) ) { return new WP_Error( 'signature_verification_unsupported', sprintf( @@ -1540,7 +1540,7 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) { } $parent_folder = dirname( $dir ); - while ( ! empty( $parent_folder ) && untrailingslashit( $to ) != $parent_folder && ! in_array( $parent_folder, $needed_dirs ) ) { + while ( ! empty( $parent_folder ) && untrailingslashit( $to ) != $parent_folder && ! in_array( $parent_folder, $needed_dirs, true ) ) { $needed_dirs[] = $parent_folder; $parent_folder = dirname( $parent_folder ); } @@ -1666,7 +1666,7 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) { } $parent_folder = dirname( $dir ); - while ( ! empty( $parent_folder ) && untrailingslashit( $to ) != $parent_folder && ! in_array( $parent_folder, $needed_dirs ) ) { + while ( ! empty( $parent_folder ) && untrailingslashit( $to ) != $parent_folder && ! in_array( $parent_folder, $needed_dirs, true ) ) { $needed_dirs[] = $parent_folder; $parent_folder = dirname( $parent_folder ); } diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index eba2c8b8db..c50666f6eb 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -950,7 +950,7 @@ function wp_media_upload_handler() { if ( isset( $_GET['tab'] ) && 'type_url' === $_GET['tab'] ) { $type = 'image'; - if ( isset( $_GET['type'] ) && in_array( $_GET['type'], array( 'video', 'audio', 'file' ) ) ) { + if ( isset( $_GET['type'] ) && in_array( $_GET['type'], array( 'video', 'audio', 'file' ), true ) ) { $type = $_GET['type']; } diff --git a/wp-admin/includes/meta-boxes.php b/wp-admin/includes/meta-boxes.php index 8e3ec6fb1c..2b4760a6da 100644 --- a/wp-admin/includes/meta-boxes.php +++ b/wp-admin/includes/meta-boxes.php @@ -334,7 +334,7 @@ endif;
post_status, array( 'publish', 'future', 'private' ) ) || 0 == $post->ID ) { + if ( ! in_array( $post->post_status, array( 'publish', 'future', 'private' ), true ) || 0 == $post->ID ) { if ( $can_publish ) : if ( ! empty( $post->post_date_gmt ) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?> @@ -471,7 +471,7 @@ function post_format_meta_box( $post, $box ) { $post_format = '0'; } // Add in the current one if it isn't there yet, in case the current theme doesn't support it. - if ( $post_format && ! in_array( $post_format, $post_formats[0] ) ) { + if ( $post_format && ! in_array( $post_format, $post_formats[0], true ) ) { $post_formats[0][] = $post_format; } ?> @@ -847,7 +847,7 @@ function post_comment_meta_box( $post ) { echo '

' . __( 'No comments yet.' ) . '

'; } else { $hidden = get_hidden_meta_boxes( get_current_screen() ); - if ( ! in_array( 'commentsdiv', $hidden ) ) { + if ( ! in_array( 'commentsdiv', $hidden, true ) ) { ?> link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: ''; $rels = preg_split( '/\s+/', $link_rel ); - if ( '' != $value && in_array( $value, $rels ) ) { + if ( '' != $value && in_array( $value, $rels, true ) ) { echo ' checked="checked"'; } @@ -1196,7 +1196,7 @@ function xfn_check( $class, $value = '', $deprecated = '' ) { if ( 'geographical' == $class && strpos( $link_rel, 'co-resident' ) === false && strpos( $link_rel, 'neighbor' ) === false ) { echo ' checked="checked"'; } - if ( 'identity' == $class && in_array( 'me', $rels ) ) { + if ( 'identity' == $class && in_array( 'me', $rels, true ) ) { echo ' checked="checked"'; } } @@ -1535,7 +1535,7 @@ function register_and_do_post_meta_boxes( $post ) { } $stati[] = 'private'; - if ( in_array( get_post_status( $post ), $stati ) ) { + if ( in_array( get_post_status( $post ), $stati, true ) ) { // If the post type support comments, or the post has comments, // allow the Comments meta box. if ( comments_open( $post ) || pings_open( $post ) || $post->comment_count > 0 || post_type_supports( $post_type, 'comments' ) ) { diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index 736dba8f3e..ba10e55f0e 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -599,7 +599,9 @@ function wp_doc_link_parse( $content ) { if ( T_STRING == $tokens[ $t ][0] && ( '(' == $tokens[ $t + 1 ] || '(' == $tokens[ $t + 2 ] ) ) { // If it's a function or class defined locally, there's not going to be any docs available. - if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ) ) ) || ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR == $tokens[ $t - 1 ][0] ) ) { + if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ), true ) ) + || ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR == $tokens[ $t - 1 ][0] ) + ) { $ignore_functions[] = $tokens[ $t ][1]; } // Add this to our stack of unique references. @@ -623,7 +625,7 @@ function wp_doc_link_parse( $content ) { $out = array(); foreach ( $functions as $function ) { - if ( in_array( $function, $ignore_functions ) ) { + if ( in_array( $function, $ignore_functions, true ) ) { continue; } $out[] = $function; @@ -656,9 +658,9 @@ function set_screen_options() { $map_option = $option; $type = str_replace( 'edit_', '', $map_option ); $type = str_replace( '_per_page', '', $type ); - if ( in_array( $type, get_taxonomies() ) ) { + if ( in_array( $type, get_taxonomies(), true ) ) { $map_option = 'edit_tags_per_page'; - } elseif ( in_array( $type, get_post_types() ) ) { + } elseif ( in_array( $type, get_post_types(), true ) ) { $map_option = 'edit_per_page'; } else { $option = str_replace( '-', '_', $option ); diff --git a/wp-admin/includes/ms.php b/wp-admin/includes/ms.php index d66433a2e5..f1567cb5d4 100644 --- a/wp-admin/includes/ms.php +++ b/wp-admin/includes/ms.php @@ -886,7 +886,7 @@ function confirm_delete_users( $users ) { ); } - if ( in_array( $delete_user->user_login, $site_admins ) ) { + if ( in_array( $delete_user->user_login, $site_admins, true ) ) { wp_die( sprintf( /* translators: %s: User login. */ diff --git a/wp-admin/includes/nav-menu.php b/wp-admin/includes/nav-menu.php index be068c21eb..e3d1053f77 100644 --- a/wp-admin/includes/nav-menu.php +++ b/wp-admin/includes/nav-menu.php @@ -25,7 +25,11 @@ function _wp_ajax_menu_quick_search( $request = array() ) { $type = isset( $request['type'] ) ? $request['type'] : ''; $object_type = isset( $request['object_type'] ) ? $request['object_type'] : ''; $query = isset( $request['q'] ) ? $request['q'] : ''; - $response_format = isset( $request['response-format'] ) && in_array( $request['response-format'], array( 'json', 'markup' ) ) ? $request['response-format'] : 'json'; + $response_format = isset( $request['response-format'] ) ? $request['response-format'] : ''; + + if ( ! $response_format || ! in_array( $response_format, array( 'json', 'markup' ), true ) ) { + $response_format = 'json'; + } if ( 'markup' == $response_format ) { $args['walker'] = new Walker_Nav_Menu_Checklist; @@ -184,7 +188,7 @@ function wp_initial_nav_menu_meta_boxes() { foreach ( array_keys( $wp_meta_boxes['nav-menus'] ) as $context ) { foreach ( array_keys( $wp_meta_boxes['nav-menus'][ $context ] ) as $priority ) { foreach ( $wp_meta_boxes['nav-menus'][ $context ][ $priority ] as $box ) { - if ( in_array( $box['id'], $initial_meta_boxes ) ) { + if ( in_array( $box['id'], $initial_meta_boxes, true ) ) { unset( $box['id'] ); } else { $hidden_meta_boxes[] = $box['id']; @@ -336,10 +340,11 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) { $post_type_name = $box['args']->name; $post_type = get_post_type_object( $post_type_name ); + $tab_name = $post_type_name . '-tab'; // Paginate browsing for large numbers of post objects. $per_page = 50; - $pagenum = isset( $_REQUEST[ $post_type_name . '-tab' ] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1; + $pagenum = isset( $_REQUEST[ $tab_name ] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1; $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0; $args = array( @@ -447,10 +452,10 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) { array( 'base' => add_query_arg( array( - $post_type_name . '-tab' => 'all', - 'paged' => '%#%', - 'item-type' => 'post_type', - 'item-object' => $post_type_name, + $tab_name => 'all', + 'paged' => '%#%', + 'item-type' => 'post_type', + 'item-object' => $post_type_name, ) ), 'format' => '', @@ -473,8 +478,9 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) { $walker = new Walker_Nav_Menu_Checklist( $db_fields ); $current_tab = 'most-recent'; - if ( isset( $_REQUEST[ $post_type_name . '-tab' ] ) && in_array( $_REQUEST[ $post_type_name . '-tab' ], array( 'all', 'search' ) ) ) { - $current_tab = $_REQUEST[ $post_type_name . '-tab' ]; + + if ( isset( $_REQUEST[ $tab_name ] ) && in_array( $_REQUEST[ $tab_name ], array( 'all', 'search' ), true ) ) { + $current_tab = $_REQUEST[ $tab_name ]; } if ( ! empty( $_REQUEST[ 'quick-search-posttype-' . $post_type_name ] ) ) { @@ -494,9 +500,9 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) { $view_all_url = ''; $search_url = ''; if ( $nav_menu_selected_id ) { - $most_recent_url = esc_url( add_query_arg( $post_type_name . '-tab', 'most-recent', remove_query_arg( $removed_args ) ) ); - $view_all_url = esc_url( add_query_arg( $post_type_name . '-tab', 'all', remove_query_arg( $removed_args ) ) ); - $search_url = esc_url( add_query_arg( $post_type_name . '-tab', 'search', remove_query_arg( $removed_args ) ) ); + $most_recent_url = esc_url( add_query_arg( $tab_name, 'most-recent', remove_query_arg( $removed_args ) ) ); + $view_all_url = esc_url( add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args ) ) ); + $search_url = esc_url( add_query_arg( $tab_name, 'search', remove_query_arg( $removed_args ) ) ); } ?>
@@ -652,8 +658,8 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {

- id="" class="select-all" /> - + id="" class="select-all" /> + @@ -688,10 +694,11 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) { $taxonomy_name = $box['args']->name; $taxonomy = get_taxonomy( $taxonomy_name ); + $tab_name = $taxonomy_name . '-tab'; // Paginate browsing for large numbers of objects. $per_page = 50; - $pagenum = isset( $_REQUEST[ $taxonomy_name . '-tab' ] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1; + $pagenum = isset( $_REQUEST[ $tab_name ] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1; $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0; $args = array( @@ -732,10 +739,10 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) { array( 'base' => add_query_arg( array( - $taxonomy_name . '-tab' => 'all', - 'paged' => '%#%', - 'item-type' => 'taxonomy', - 'item-object' => $taxonomy_name, + $tab_name => 'all', + 'paged' => '%#%', + 'item-type' => 'taxonomy', + 'item-object' => $taxonomy_name, ) ), 'format' => '', @@ -758,8 +765,9 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) { $walker = new Walker_Nav_Menu_Checklist( $db_fields ); $current_tab = 'most-used'; - if ( isset( $_REQUEST[ $taxonomy_name . '-tab' ] ) && in_array( $_REQUEST[ $taxonomy_name . '-tab' ], array( 'all', 'most-used', 'search' ) ) ) { - $current_tab = $_REQUEST[ $taxonomy_name . '-tab' ]; + + if ( isset( $_REQUEST[ $tab_name ] ) && in_array( $_REQUEST[ $tab_name ], array( 'all', 'most-used', 'search' ), true ) ) { + $current_tab = $_REQUEST[ $tab_name ]; } if ( ! empty( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name ] ) ) { @@ -779,9 +787,9 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) { $view_all_url = ''; $search_url = ''; if ( $nav_menu_selected_id ) { - $most_used_url = esc_url( add_query_arg( $taxonomy_name . '-tab', 'most-used', remove_query_arg( $removed_args ) ) ); - $view_all_url = esc_url( add_query_arg( $taxonomy_name . '-tab', 'all', remove_query_arg( $removed_args ) ) ); - $search_url = esc_url( add_query_arg( $taxonomy_name . '-tab', 'search', remove_query_arg( $removed_args ) ) ); + $most_used_url = esc_url( add_query_arg( $tab_name, 'most-used', remove_query_arg( $removed_args ) ) ); + $view_all_url = esc_url( add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args ) ) ); + $search_url = esc_url( add_query_arg( $tab_name, 'search', remove_query_arg( $removed_args ) ) ); } ?>

@@ -882,8 +890,8 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) {

- id="" class="select-all" /> - + id="" class="select-all" /> + @@ -920,7 +928,7 @@ function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) { // And item type either isn't set. ! isset( $_item_object_data['menu-item-type'] ) || // Or URL is the default. - in_array( $_item_object_data['menu-item-url'], array( 'https://', 'http://', '' ) ) || + in_array( $_item_object_data['menu-item-url'], array( 'https://', 'http://', '' ), true ) || // Or it's not a custom menu item (but not the custom home page). ! ( 'custom' == $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) || // Or it *is* a custom menu item that already exists. diff --git a/wp-admin/includes/network.php b/wp-admin/includes/network.php index f2a51347fe..70cb14ea93 100644 --- a/wp-admin/includes/network.php +++ b/wp-admin/includes/network.php @@ -135,7 +135,7 @@ function network_step1( $errors = false ) { $hostname = get_clean_basedomain(); $has_ports = strstr( $hostname, ':' ); - if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ) ) ) ) { + if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ), true ) ) ) { echo '

' . __( 'Error:' ) . ' ' . __( 'You cannot install a network of sites with your server address.' ) . '

'; echo '

' . sprintf( /* translators: %s: Port number. */ @@ -162,14 +162,14 @@ function network_step1( $errors = false ) { $error_codes = $errors->get_error_codes(); } - if ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes ) ) { + if ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes, true ) ) { $site_name = $_POST['sitename']; } else { /* translators: %s: Default network title. */ $site_name = sprintf( __( '%s Sites' ), get_option( 'blogname' ) ); } - if ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes ) ) { + if ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes, true ) ) { $admin_email = $_POST['email']; } else { $admin_email = get_option( 'admin_email' ); diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index 9ba6203a53..67f3d9bd40 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -523,7 +523,7 @@ function _get_dropins() { * @return bool True, if in the active plugins list. False, not in the list. */ function is_plugin_active( $plugin ) { - return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || is_plugin_active_for_network( $plugin ); + return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || is_plugin_active_for_network( $plugin ); } /** @@ -644,7 +644,7 @@ function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silen return $requirements; } - if ( ( $network_wide && ! isset( $current[ $plugin ] ) ) || ( ! $network_wide && ! in_array( $plugin, $current ) ) ) { + if ( ( $network_wide && ! isset( $current[ $plugin ] ) ) || ( ! $network_wide && ! in_array( $plugin, $current, true ) ) ) { if ( ! empty( $redirect ) ) { // We'll override this later if the plugin can be included without fatal error. wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) ); @@ -783,7 +783,7 @@ function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) { } if ( true !== $network_wide ) { - $key = array_search( $plugin, $current ); + $key = array_search( $plugin, $current, true ); if ( false !== $key ) { $do_blog = true; unset( $current[ $key ] ); diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 774bd1ea34..b2143d61eb 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -134,8 +134,11 @@ function _wp_translate_postdata( $update = false, $post_data = null ) { // Posts 'submitted for approval' are submitted to $_POST the same as if they were being published. // Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts. - if ( isset( $post_data['post_status'] ) && ( in_array( $post_data['post_status'], $published_statuses ) && ! current_user_can( $ptype->cap->publish_posts ) ) ) { - if ( ! in_array( $previous_status, $published_statuses ) || ! current_user_can( 'edit_post', $post_id ) ) { + if ( isset( $post_data['post_status'] ) + && ( in_array( $post_data['post_status'], $published_statuses, true ) + && ! current_user_can( $ptype->cap->publish_posts ) ) + ) { + if ( ! in_array( $previous_status, $published_statuses, true ) || ! current_user_can( 'edit_post', $post_id ) ) { $post_data['post_status'] = 'pending'; } } @@ -564,7 +567,10 @@ 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 ) ) || ! current_user_can( 'edit_post', $post_ID ) ) { + if ( ! isset( $post_type_object ) + || ( isset( $children ) && in_array( $post_ID, $children ) ) + || ! current_user_can( 'edit_post', $post_ID ) + ) { $skipped[] = $post_ID; continue; } @@ -593,7 +599,7 @@ function bulk_edit_posts( $post_data = null ) { $post_data['tax_input'][ $tax_name ] = array_merge( $current_terms, $new_terms ); } - if ( isset( $new_cats ) && in_array( 'category', $tax_names ) ) { + if ( isset( $new_cats ) && in_array( 'category', $tax_names, true ) ) { $cats = (array) wp_get_post_categories( $post_ID ); $post_data['post_category'] = array_unique( array_merge( $cats, $new_cats ) ); unset( $post_data['tax_input']['category'] ); @@ -1037,7 +1043,7 @@ function _fix_attachment_links( $post ) { $content = $post['post_content']; // Don't run if no pretty permalinks or post is not published, scheduled, or privately published. - if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ) ) ) { + if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ), true ) ) { return; } @@ -1110,7 +1116,7 @@ function wp_edit_posts_query( $q = false ) { $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0; $post_stati = get_post_stati(); - if ( isset( $q['post_type'] ) && in_array( $q['post_type'], get_post_types() ) ) { + if ( isset( $q['post_type'] ) && in_array( $q['post_type'], get_post_types(), true ) ) { $post_type = $q['post_type']; } else { $post_type = 'post'; @@ -1120,7 +1126,7 @@ function wp_edit_posts_query( $q = false ) { $post_status = ''; $perm = ''; - if ( isset( $q['post_status'] ) && in_array( $q['post_status'], $post_stati ) ) { + if ( isset( $q['post_status'] ) && in_array( $q['post_status'], $post_stati, true ) ) { $post_status = $q['post_status']; $perm = 'readable'; } @@ -1129,7 +1135,7 @@ function wp_edit_posts_query( $q = false ) { if ( isset( $q['orderby'] ) ) { $orderby = $q['orderby']; - } elseif ( isset( $q['post_status'] ) && in_array( $q['post_status'], array( 'pending', 'draft' ) ) ) { + } elseif ( isset( $q['post_status'] ) && in_array( $q['post_status'], array( 'pending', 'draft' ), true ) ) { $orderby = 'modified'; } @@ -1294,7 +1300,7 @@ function postbox_classes( $box_id, $screen_id ) { if ( ! is_array( $closed ) ) { $classes = array( '' ); } else { - $classes = in_array( $box_id, $closed ) ? array( 'closed' ) : array( '' ); + $classes = in_array( $box_id, $closed, true ) ? array( 'closed' ) : array( '' ); } } else { $classes = array( '' ); @@ -1342,7 +1348,7 @@ function get_sample_permalink( $id, $title = null, $name = null ) { $original_name = $post->post_name; // Hack: get_permalink() would return ugly permalink for drafts, so we will fake that our post is published. - if ( in_array( $post->post_status, array( 'draft', 'pending', 'future' ) ) ) { + if ( in_array( $post->post_status, array( 'draft', 'pending', 'future' ), true ) ) { $post->post_status = 'publish'; $post->post_name = sanitize_title( $post->post_name ? $post->post_name : $post->post_title, $post->ID ); } diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index bb993f2617..614a37457a 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -400,7 +400,7 @@ function populate_options( array $options = array() ) { $offset_or_tz = _x( '0', 'default GMT offset or timezone string' ); // phpcs:ignore WordPress.WP.I18n.NoEmptyStrings if ( is_numeric( $offset_or_tz ) ) { $gmt_offset = $offset_or_tz; - } elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list() ) ) { + } elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list(), true ) ) { $timezone_string = $offset_or_tz; } @@ -563,11 +563,13 @@ function populate_options( array $options = array() ) { $existing_options = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name in ( $keys )" ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared $insert = ''; + foreach ( $options as $option => $value ) { - if ( in_array( $option, $existing_options ) ) { + if ( in_array( $option, $existing_options, true ) ) { continue; } - if ( in_array( $option, $fat_options ) ) { + + if ( in_array( $option, $fat_options, true ) ) { $autoload = 'no'; } else { $autoload = 'yes'; @@ -576,9 +578,11 @@ function populate_options( array $options = array() ) { if ( is_array( $value ) ) { $value = serialize( $value ); } + if ( ! empty( $insert ) ) { $insert .= ', '; } + $insert .= $wpdb->prepare( '(%s, %s, %s)', $option, $value, $autoload ); } diff --git a/wp-admin/includes/screen.php b/wp-admin/includes/screen.php index 42a19ec91e..db6abfb5ce 100644 --- a/wp-admin/includes/screen.php +++ b/wp-admin/includes/screen.php @@ -131,7 +131,7 @@ function meta_box_prefs( $screen ) { printf( '', esc_attr( $box['id'] ), - checked( in_array( $box['id'], $hidden ), false, false ), + checked( in_array( $box['id'], $hidden, true ), false, false ), $widget_title ); } diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index a6f74722cf..882af9e149 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -783,7 +783,7 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { $post = get_post(); if ( $for_post ) { - $edit = ! ( in_array( $post->post_status, array( 'draft', 'pending' ) ) && ( ! $post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ); + $edit = ! ( in_array( $post->post_status, array( 'draft', 'pending' ), true ) && ( ! $post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ); } $tab_index_attribute = ''; @@ -1297,7 +1297,7 @@ function do_meta_boxes( $screen, $context, $object ) { $i++; // get_hidden_meta_boxes() doesn't apply in the block editor. - $hidden_class = ( ! $screen->is_block_editor() && in_array( $box['id'], $hidden ) ) ? ' hide-if-js' : ''; + $hidden_class = ( ! $screen->is_block_editor() && in_array( $box['id'], $hidden, true ) ) ? ' hide-if-js' : ''; echo '

' . "\n"; if ( 'dashboard_browser_nag' != $box['id'] ) { $widget_title = $box['title']; @@ -1453,7 +1453,7 @@ function do_accordion_sections( $screen, $context, $object ) { continue; } $i++; - $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; + $hidden_class = in_array( $box['id'], $hidden, true ) ? 'hide-if-js' : ''; $open_class = ''; if ( ! $first_open && empty( $hidden_class ) ) { @@ -1838,7 +1838,7 @@ function settings_errors( $setting = '', $sanitize = false, $hide_on_update = fa $details['type'] = 'success'; } - if ( in_array( $details['type'], array( 'error', 'success', 'warning', 'info' ) ) ) { + if ( in_array( $details['type'], array( 'error', 'success', 'warning', 'info' ), true ) ) { $details['type'] = 'notice-' . $details['type']; } @@ -2373,7 +2373,7 @@ function get_submit_button( $text = '', $type = 'primary large', $name = 'submit if ( 'secondary' === $t || 'button-secondary' === $t ) { continue; } - $classes[] = in_array( $t, $button_shorthand ) ? 'button-' . $t : $t; + $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 ) ) ); diff --git a/wp-admin/includes/translation-install.php b/wp-admin/includes/translation-install.php index 7de027045b..716567c21a 100644 --- a/wp-admin/includes/translation-install.php +++ b/wp-admin/includes/translation-install.php @@ -20,7 +20,7 @@ function translations_api( $type, $args = null ) { // Include an unmodified $wp_version. require ABSPATH . WPINC . '/version.php'; - if ( ! in_array( $type, array( 'plugins', 'themes', 'core' ) ) ) { + if ( ! in_array( $type, array( 'plugins', 'themes', 'core' ), true ) ) { return new WP_Error( 'invalid_type', __( 'Invalid translation type.' ) ); } @@ -176,7 +176,7 @@ function wp_install_language_form( $languages ) { esc_attr( $language['language'] ), esc_attr( current( $language['iso'] ) ), esc_attr( $language['strings']['continue'] ?: 'Continue' ), - in_array( $language['language'], $installed_languages ) ? ' data-installed="1"' : '', + in_array( $language['language'], $installed_languages, true ) ? ' data-installed="1"' : '', esc_html( $language['native_name'] ) ); @@ -190,7 +190,7 @@ function wp_install_language_form( $languages ) { esc_attr( $language['language'] ), esc_attr( current( $language['iso'] ) ), esc_attr( $language['strings']['continue'] ?: 'Continue' ), - in_array( $language['language'], $installed_languages ) ? ' data-installed="1"' : '', + in_array( $language['language'], $installed_languages, true ) ? ' data-installed="1"' : '', esc_html( $language['native_name'] ) ); } @@ -211,7 +211,7 @@ function wp_install_language_form( $languages ) { */ function wp_download_language_pack( $download ) { // Check if the translation is already installed. - if ( in_array( $download, get_available_languages() ) ) { + if ( in_array( $download, get_available_languages(), true ) ) { return $download; } diff --git a/wp-admin/includes/update-core.php b/wp-admin/includes/update-core.php index 9dbe8bead1..76e19bf81d 100644 --- a/wp-admin/includes/update-core.php +++ b/wp-admin/includes/update-core.php @@ -1045,7 +1045,7 @@ function update_core( $from, $to ) { if ( ! file_exists( $working_dir_local . $file ) ) { continue; } - if ( '.' === dirname( $file ) && in_array( pathinfo( $file, PATHINFO_EXTENSION ), array( 'html', 'txt' ) ) ) { + if ( '.' === dirname( $file ) && in_array( pathinfo( $file, PATHINFO_EXTENSION ), array( 'html', 'txt' ), true ) ) { continue; } if ( md5_file( ABSPATH . $file ) === $checksum ) { @@ -1115,7 +1115,7 @@ function update_core( $from, $to ) { if ( ! file_exists( $working_dir_local . $file ) ) { continue; } - if ( '.' === dirname( $file ) && in_array( pathinfo( $file, PATHINFO_EXTENSION ), array( 'html', 'txt' ) ) ) { + if ( '.' === dirname( $file ) && in_array( pathinfo( $file, PATHINFO_EXTENSION ), array( 'html', 'txt' ), true ) ) { $skip[] = $file; continue; } diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 26614c9634..8e3d78cc62 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -1913,7 +1913,7 @@ function upgrade_400() { global $wp_current_db_version; if ( $wp_current_db_version < 29630 ) { if ( ! is_multisite() && false === get_option( 'WPLANG' ) ) { - if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && in_array( WPLANG, get_available_languages() ) ) { + if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && in_array( WPLANG, get_available_languages(), true ) ) { update_option( 'WPLANG', WPLANG ); } else { update_option( 'WPLANG', '' ); @@ -2635,7 +2635,7 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N $global_tables = $wpdb->tables( 'global' ); foreach ( $cqueries as $table => $qry ) { // Upgrade global tables only for the main site. Don't upgrade at all if conditions are not optimal. - if ( in_array( $table, $global_tables ) && ! wp_should_upgrade_global_tables() ) { + if ( in_array( $table, $global_tables, true ) && ! wp_should_upgrade_global_tables() ) { unset( $cqueries[ $table ], $for_update[ $table ] ); continue; } @@ -2799,14 +2799,14 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N // Is actual field type different from the field type in query? if ( $tablefield->Type != $fieldtype ) { $do_change = true; - if ( in_array( $fieldtype_lowercased, $text_fields ) && in_array( $tablefield_type_lowercased, $text_fields ) ) { - if ( array_search( $fieldtype_lowercased, $text_fields ) < array_search( $tablefield_type_lowercased, $text_fields ) ) { + if ( in_array( $fieldtype_lowercased, $text_fields, true ) && in_array( $tablefield_type_lowercased, $text_fields, true ) ) { + if ( array_search( $fieldtype_lowercased, $text_fields, true ) < array_search( $tablefield_type_lowercased, $text_fields, true ) ) { $do_change = false; } } - if ( in_array( $fieldtype_lowercased, $blob_fields ) && in_array( $tablefield_type_lowercased, $blob_fields ) ) { - if ( array_search( $fieldtype_lowercased, $blob_fields ) < array_search( $tablefield_type_lowercased, $blob_fields ) ) { + if ( in_array( $fieldtype_lowercased, $blob_fields, true ) && in_array( $tablefield_type_lowercased, $blob_fields, true ) ) { + if ( array_search( $fieldtype_lowercased, $blob_fields, true ) < array_search( $tablefield_type_lowercased, $blob_fields, true ) ) { $do_change = false; } } @@ -2901,7 +2901,7 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N $index_string .= " ($index_columns)"; // Check if the index definition exists, ignoring subparts. - $aindex = array_search( $index_string, $indices_without_subparts ); + $aindex = array_search( $index_string, $indices_without_subparts, true ); if ( false !== $aindex ) { // If the index already exists (even with different subparts), we don't need to create it. unset( $indices_without_subparts[ $aindex ] ); @@ -3245,7 +3245,7 @@ function maybe_disable_automattic_widgets() { foreach ( (array) $plugins as $plugin ) { if ( basename( $plugin ) == 'widgets.php' ) { - array_splice( $plugins, array_search( $plugin, $plugins ), 1 ); + array_splice( $plugins, array_search( $plugin, $plugins, true ), 1 ); update_option( 'active_plugins', $plugins ); break; } diff --git a/wp-admin/includes/widgets.php b/wp-admin/includes/widgets.php index 7add657333..f8f16ac79c 100644 --- a/wp-admin/includes/widgets.php +++ b/wp-admin/includes/widgets.php @@ -192,7 +192,7 @@ function wp_widget_control( $sidebar_args ) { $widget_id = $sidebar_args['widget_id']; $sidebar_id = isset( $sidebar_args['id'] ) ? $sidebar_args['id'] : false; - $key = $sidebar_id ? array_search( $widget_id, $sidebars_widgets[ $sidebar_id ] ) : '-1'; // Position of widget in sidebar. + $key = $sidebar_id ? array_search( $widget_id, $sidebars_widgets[ $sidebar_id ], true ) : '-1'; // Position of widget in sidebar. $control = isset( $wp_registered_widget_controls[ $widget_id ] ) ? $wp_registered_widget_controls[ $widget_id ] : array(); $widget = $wp_registered_widgets[ $widget_id ]; diff --git a/wp-admin/load-scripts.php b/wp-admin/load-scripts.php index b7881e0655..cdb890d817 100644 --- a/wp-admin/load-scripts.php +++ b/wp-admin/load-scripts.php @@ -15,7 +15,7 @@ if ( ! defined( 'ABSPATH' ) ) { define( 'WPINC', 'wp-includes' ); $protocol = $_SERVER['SERVER_PROTOCOL']; -if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) { +if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ), true ) ) { $protocol = 'HTTP/1.0'; } diff --git a/wp-admin/load-styles.php b/wp-admin/load-styles.php index 59cd1d713e..7c3d083878 100644 --- a/wp-admin/load-styles.php +++ b/wp-admin/load-styles.php @@ -19,7 +19,7 @@ require ABSPATH . WPINC . '/script-loader.php'; require ABSPATH . WPINC . '/version.php'; $protocol = $_SERVER['SERVER_PROTOCOL']; -if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) { +if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ), true ) ) { $protocol = 'HTTP/1.0'; } diff --git a/wp-admin/menu.php b/wp-admin/menu.php index 1064e7b85c..2248a75164 100644 --- a/wp-admin/menu.php +++ b/wp-admin/menu.php @@ -135,7 +135,7 @@ foreach ( array_merge( $builtin, $types ) as $ptype ) { } else { $menu_icon = esc_url( $ptype_obj->menu_icon ); } - } elseif ( in_array( $ptype, $builtin ) ) { + } elseif ( in_array( $ptype, $builtin, true ) ) { $menu_icon = 'dashicons-admin-' . $ptype; } @@ -152,7 +152,7 @@ foreach ( array_merge( $builtin, $types ) as $ptype ) { $edit_tags_file = "edit-tags.php?taxonomy=%s&post_type=$ptype"; } - if ( in_array( $ptype, $builtin ) ) { + if ( in_array( $ptype, $builtin, true ) ) { $ptype_menu_id = 'menu-' . $ptype_for_id . 's'; } else { $ptype_menu_id = 'menu-posts-' . $ptype_for_id; @@ -162,7 +162,7 @@ foreach ( array_merge( $builtin, $types ) as $ptype ) { * by a hard-coded value below, increment the position. */ $core_menu_positions = array( 59, 60, 65, 70, 75, 80, 85, 99 ); - while ( isset( $menu[ $ptype_menu_position ] ) || in_array( $ptype_menu_position, $core_menu_positions ) ) { + while ( isset( $menu[ $ptype_menu_position ] ) || in_array( $ptype_menu_position, $core_menu_positions, true ) ) { $ptype_menu_position++; } diff --git a/wp-admin/my-sites.php b/wp-admin/my-sites.php index 888cb12360..154e591c9a 100644 --- a/wp-admin/my-sites.php +++ b/wp-admin/my-sites.php @@ -66,7 +66,7 @@ echo esc_html( $title ); %s', esc_url( $sign_up_url ), esc_html_x( 'Add New', 'site' ) ); diff --git a/wp-admin/network/settings.php b/wp-admin/network/settings.php index 2a26b48ab5..188ce1309c 100644 --- a/wp-admin/network/settings.php +++ b/wp-admin/network/settings.php @@ -416,7 +416,7 @@ if ( isset( $_GET['updated'] ) ) { $val ) { $key = wp_unslash( $key ); $val = wp_unslash( $val ); - if ( 0 === $key || is_array( $val ) || in_array( $key, $skip_options ) ) { + if ( 0 === $key || is_array( $val ) || in_array( $key, $skip_options, true ) ) { continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options. } update_option( $key, $val ); @@ -149,7 +149,7 @@ if ( ! empty( $messages ) ) { ?> - option_name, array( 'siteurl', 'home' ) ) ) { ?> + option_name, array( 'siteurl', 'home' ), true ) ) { ?> option_value ); ?> /> diff --git a/wp-admin/network/update.php b/wp-admin/network/update.php index 2a8bccc709..edaa4fa9d3 100644 --- a/wp-admin/network/update.php +++ b/wp-admin/network/update.php @@ -7,7 +7,7 @@ * @since 3.1.0 */ -if ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'update-selected', 'activate-plugin', 'update-selected-themes' ) ) ) { +if ( isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'update-selected', 'activate-plugin', 'update-selected-themes' ), true ) ) { define( 'IFRAME_REQUEST', true ); } diff --git a/wp-admin/options-general.php b/wp-admin/options-general.php index 5a2ef1b6c6..975e01937e 100644 --- a/wp-admin/options-general.php +++ b/wp-admin/options-general.php @@ -157,7 +157,7 @@ if ( $new_admin_email && get_option( 'admin_email' ) !== $new_admin_email ) : $languages = get_available_languages(); $translations = wp_get_available_translations(); -if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG && ! in_array( WPLANG, $languages ) ) { +if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG && ! in_array( WPLANG, $languages, true ) ) { $languages[] = WPLANG; } if ( ! empty( $languages ) || ! empty( $translations ) ) { @@ -167,7 +167,7 @@ if ( ! empty( $languages ) || ! empty( $translations ) ) {
-