Coding Standards: Use strict type check for `in_array()` and `array_search()` where strings are involved.

This reduces the number of `WordPress.PHP.StrictInArray.MissingTrueStrict` issues from 486 to 50.

Includes minor code layout fixes for better readability.

See #49542.
Built from https://develop.svn.wordpress.org/trunk@47550


git-svn-id: http://core.svn.wordpress.org/trunk@47325 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-04-05 03:02:11 +00:00
parent 10e3e44219
commit 38676936ba
141 changed files with 585 additions and 485 deletions

View File

@ -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' );
<?php
} else {
if ( is_wp_error( $result ) && in_array( $result->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();
?>
<h2><?php _e( 'Your account is now active!' ); ?></h2>

View File

@ -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 );
}

View File

@ -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' );

View File

@ -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.' ) );
}

View File

@ -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.' ) );
}

View File

@ -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 );
}

View File

@ -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'] );
}

View File

@ -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;

View File

@ -82,6 +82,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"' : '';
$args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats'];

View File

@ -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 ),
)
);

View File

@ -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' );

View File

@ -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] );
}

View File

@ -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';
}

View File

@ -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';
}

View File

@ -281,7 +281,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
<?php
echo $edit;
if ( in_array( $user->user_login, $super_admins ) ) {
if ( in_array( $user->user_login, $super_admins, true ) ) {
echo ' &mdash; ' . __( 'Super Admin' );
}
?>

View File

@ -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 );
}

View File

@ -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' ) ) ? '<input type="checkbox" />' : '',
'cb' => ! in_array( $status, array( 'mustuse', 'dropins' ), true ) ? '<input type="checkbox" />' : '',
'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';
}

View File

@ -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'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>';
}
@ -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(

View File

@ -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 '<label>';
echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( ! in_array( $column, $hidden ), true, false ) . ' />';
echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( ! in_array( $column, $hidden, true ), true, false ) . ' />';
echo "$title</label>\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;
}

View File

@ -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';
}

View File

@ -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 );
}

View File

@ -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;
}

View File

@ -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 ) );
}

View File

@ -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';
}

View File

@ -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';
}

View File

@ -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 );
}

View File

@ -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'];
}

View File

@ -334,7 +334,7 @@ endif;
<div id="publishing-action">
<span class="spinner"></span>
<?php
if ( ! in_array( $post->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 '<p id="no-comments">' . __( 'No comments yet.' ) . '</p>';
} else {
$hidden = get_hidden_meta_boxes( get_current_screen() );
if ( ! in_array( 'commentsdiv', $hidden ) ) {
if ( ! in_array( 'commentsdiv', $hidden, true ) ) {
?>
<script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script>
<?php
@ -1182,7 +1182,7 @@ function xfn_check( $class, $value = '', $deprecated = '' ) {
$link_rel = isset( $link->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' ) ) {

View File

@ -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 );

View File

@ -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. */

View File

@ -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,7 +452,7 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
array(
'base' => add_query_arg(
array(
$post_type_name . '-tab' => 'all',
$tab_name => 'all',
'paged' => '%#%',
'item-type' => 'post_type',
'item-object' => $post_type_name,
@ -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 ) ) );
}
?>
<div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv">
@ -652,8 +658,8 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
<p class="button-controls wp-clearfix" data-items-type="posttype-<?php echo esc_attr( $post_type_name ); ?>">
<span class="list-controls hide-if-no-js">
<input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> id="<?php echo esc_attr( $post_type_name . '-tab' ); ?>" class="select-all" />
<label for="<?php echo esc_attr( $post_type_name . '-tab' ); ?>"><?php _e( 'Select All' ); ?></label>
<input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> id="<?php echo esc_attr( $tab_name ); ?>" class="select-all" />
<label for="<?php echo esc_attr( $tab_name ); ?>"><?php _e( 'Select All' ); ?></label>
</span>
<span class="add-to-menu">
@ -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,7 +739,7 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) {
array(
'base' => add_query_arg(
array(
$taxonomy_name . '-tab' => 'all',
$tab_name => 'all',
'paged' => '%#%',
'item-type' => 'taxonomy',
'item-object' => $taxonomy_name,
@ -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 ) ) );
}
?>
<div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv">
@ -882,8 +890,8 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) {
<p class="button-controls wp-clearfix" data-items-type="taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>">
<span class="list-controls hide-if-no-js">
<input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> id="<?php echo esc_attr( $taxonomy_name . '-tab' ); ?>" class="select-all" />
<label for="<?php echo esc_attr( $taxonomy_name . '-tab' ); ?>"><?php _e( 'Select All' ); ?></label>
<input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> id="<?php echo esc_attr( $tab_name ); ?>" class="select-all" />
<label for="<?php echo esc_attr( $tab_name ); ?>"><?php _e( 'Select All' ); ?></label>
</span>
<span class="add-to-menu">
@ -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.

View File

@ -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 '<div class="error"><p><strong>' . __( 'Error:' ) . '</strong> ' . __( 'You cannot install a network of sites with your server address.' ) . '</p></div>';
echo '<p>' . 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' );

View File

@ -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 ] );

View File

@ -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 );
}

View File

@ -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 );
}

View File

@ -131,7 +131,7 @@ function meta_box_prefs( $screen ) {
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 ), false, false ),
checked( in_array( $box['id'], $hidden, true ), false, false ),
$widget_title
);
}

View File

@ -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 '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes( $box['id'], $page ) . $hidden_class . '" ' . '>' . "\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 ) ) );

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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 ];

View File

@ -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';
}

View File

@ -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';
}

View File

@ -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&amp;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++;
}

View File

@ -66,7 +66,7 @@ echo esc_html( $title );
</h1>
<?php
if ( in_array( get_site_option( 'registration' ), array( 'all', 'blog' ) ) ) {
if ( in_array( get_site_option( 'registration' ), array( 'all', 'blog' ), true ) ) {
/** This filter is documented in wp-login.php */
$sign_up_url = apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) );
printf( ' <a href="%s" class="page-title-action">%s</a>', esc_url( $sign_up_url ), esc_html_x( 'Add New', 'site' ) );

View File

@ -416,7 +416,7 @@ if ( isset( $_GET['updated'] ) ) {
<td>
<?php
$lang = get_site_option( 'WPLANG' );
if ( ! in_array( $lang, $languages ) ) {
if ( ! in_array( $lang, $languages, true ) ) {
$lang = '';
}

View File

@ -52,7 +52,7 @@ if ( isset( $_REQUEST['action'] ) && 'add-site' == $_REQUEST['action'] ) {
if ( ! is_subdomain_install() ) {
$subdirectory_reserved_names = get_subdirectory_reserved_names();
if ( in_array( $domain, $subdirectory_reserved_names ) ) {
if ( in_array( $domain, $subdirectory_reserved_names, true ) ) {
wp_die(
sprintf(
/* translators: %s: Reserved names list. */
@ -73,7 +73,7 @@ if ( isset( $_REQUEST['action'] ) && 'add-site' == $_REQUEST['action'] ) {
if ( isset( $_POST['WPLANG'] ) ) {
if ( '' === $_POST['WPLANG'] ) {
$meta['WPLANG'] = ''; // en_US
} elseif ( in_array( $_POST['WPLANG'], get_available_languages() ) ) {
} elseif ( in_array( $_POST['WPLANG'], get_available_languages(), true ) ) {
$meta['WPLANG'] = $_POST['WPLANG'];
} elseif ( current_user_can( 'install_languages' ) && wp_can_install_language_pack() ) {
$language = wp_download_language_pack( wp_unslash( $_POST['WPLANG'] ) );
@ -260,7 +260,7 @@ printf(
$lang = get_site_option( 'WPLANG' );
// Use English if the default isn't available.
if ( ! in_array( $lang, $languages ) ) {
if ( ! in_array( $lang, $languages, true ) ) {
$lang = '';
}

View File

@ -43,7 +43,7 @@ if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] && is_
foreach ( (array) $_POST['option'] as $key => $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 ) ) {
?>
<tr class="form-field">
<th scope="row"><label for="<?php echo esc_attr( $option->option_name ); ?>"><?php echo esc_html( ucwords( str_replace( '_', ' ', $option->option_name ) ) ); ?></label></th>
<?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ) ) ) { ?>
<?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ), true ) ) { ?>
<td><code><?php echo esc_html( $option->option_value ); ?></code></td>
<?php } else { ?>
<td><input class="<?php echo $class; ?>" name="option[<?php echo esc_attr( $option->option_name ); ?>]" type="text" id="<?php echo esc_attr( $option->option_name ); ?>" value="<?php echo esc_attr( $option->option_value ); ?>" size="40" <?php disabled( $disabled ); ?> /></td>

View File

@ -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 );
}

View File

@ -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 ) ) {
<td>
<?php
$locale = get_locale();
if ( ! in_array( $locale, $languages ) ) {
if ( ! in_array( $locale, $languages, true ) ) {
$locale = '';
}
@ -276,7 +276,7 @@ if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists.
?>
<br />
<?php
if ( in_array( $tzstring, timezone_identifiers_list() ) ) {
if ( in_array( $tzstring, timezone_identifiers_list(), true ) ) {
$transitions = timezone_transitions_get( timezone_open( $tzstring ), time() );
// 0 index is the state at current time, 1 index is the next transition, if any.

View File

@ -240,7 +240,7 @@ $structures = array(
</tr>
<tr>
<th scope="row">
<label><input name="selection" id="custom_selection" type="radio" value="custom" <?php checked( ! in_array( $permalink_structure, $structures ) ); ?> />
<label><input name="selection" id="custom_selection" type="radio" value="custom" <?php checked( ! in_array( $permalink_structure, $structures, true ) ); ?> />
<?php _e( 'Custom Structure' ); ?>
</label>
</th>

View File

@ -62,7 +62,7 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
<?php
settings_fields( 'reading' );
if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) {
if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ), true ) ) {
add_settings_field( 'blog_charset', __( 'Encoding for pages and feeds' ), 'options_reading_blog_charset', 'reading', 'default', array( 'label_for' => 'blog_charset' ) );
}
?>

View File

@ -152,7 +152,7 @@ $whitelist_options['privacy'] = array();
$mail_options = array( 'mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass' );
if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) {
if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ), true ) ) {
$whitelist_options['reading'][] = 'blog_charset';
}

View File

@ -112,7 +112,7 @@ if ( ! is_file( $real_file ) ) {
if ( preg_match( '/\.([^.]+)$/', $real_file, $matches ) ) {
$ext = strtolower( $matches[1] );
// If extension is not in the acceptable list, skip it.
if ( ! in_array( $ext, $editable_extensions ) ) {
if ( ! in_array( $ext, $editable_extensions, true ) ) {
wp_die( sprintf( '<p>%s</p>', __( 'Files of this type are not editable.' ) ) );
}
}
@ -244,7 +244,7 @@ $content = esc_textarea( $content );
<?php
$plugin_editable_files = array();
foreach ( $plugin_files as $plugin_file ) {
if ( preg_match( '/\.([^.]+)$/', $plugin_file, $matches ) && in_array( $matches[1], $editable_extensions ) ) {
if ( preg_match( '/\.([^.]+)$/', $plugin_file, $matches ) && in_array( $matches[1], $editable_extensions, true ) ) {
$plugin_editable_files[] = $plugin_file;
}
}
@ -277,7 +277,7 @@ $content = esc_textarea( $content );
<?php if ( is_writeable( $real_file ) ) : ?>
<div class="editor-notices">
<?php if ( in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) ) { ?>
<?php if ( in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) ) { ?>
<div class="notice notice-warning inline active-plugin-edit-warning">
<p><?php _e( '<strong>Warning:</strong> Making changes to active plugins is not recommended.' ); ?></p>
</div>

View File

@ -18,7 +18,7 @@ global $post_type, $post_type_object, $post;
if ( ! isset( $_GET['post_type'] ) ) {
$post_type = 'post';
} elseif ( in_array( $_GET['post_type'], get_post_types( array( 'show_ui' => true ) ) ) ) {
} elseif ( in_array( $_GET['post_type'], get_post_types( array( 'show_ui' => true ) ), true ) ) {
$post_type = $_GET['post_type'];
} else {
wp_die( __( 'Invalid post type.' ) );

View File

@ -131,7 +131,7 @@ switch ( $action ) {
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.' ) );
}

View File

@ -35,9 +35,9 @@ $tax = get_taxonomy( $tag->taxonomy );
$taxonomy = $tax->name;
$title = $tax->labels->edit_item;
if ( ! in_array( $taxonomy, get_taxonomies( array( 'show_ui' => true ) ) ) ||
! current_user_can( 'edit_term', $tag->term_id ) ) {
if ( ! in_array( $taxonomy, get_taxonomies( array( 'show_ui' => true ) ), true )
|| ! current_user_can( 'edit_term', $tag->term_id )
) {
wp_die(
'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
'<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>',

View File

@ -177,7 +177,7 @@ if ( ! empty( $posted_content ) ) {
}
$file_description = get_file_description( $relative_file );
$file_show = array_search( $file, array_filter( $allowed_files ) );
$file_show = array_search( $file, array_filter( $allowed_files ), true );
$description = esc_html( $file_description );
if ( $file_description != $file_show ) {
$description .= ' <span>(' . esc_html( $file_show ) . ')</span>';

View File

@ -6,7 +6,9 @@
* @subpackage Administration
*/
if ( ! defined( 'IFRAME_REQUEST' ) && isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'update-selected', 'activate-plugin', 'update-selected-themes' ) ) ) {
if ( ! defined( 'IFRAME_REQUEST' )
&& isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'update-selected', 'activate-plugin', 'update-selected-themes' ), true )
) {
define( 'IFRAME_REQUEST', true );
}

View File

@ -16,7 +16,7 @@ if ( ! current_user_can( 'upload_files' ) ) {
$mode = get_user_option( 'media_library_mode', get_current_user_id() ) ? get_user_option( 'media_library_mode', get_current_user_id() ) : 'grid';
$modes = array( 'grid', 'list' );
if ( isset( $_GET['mode'] ) && in_array( $_GET['mode'], $modes ) ) {
if ( isset( $_GET['mode'] ) && in_array( $_GET['mode'], $modes, true ) ) {
$mode = $_GET['mode'];
update_user_option( get_current_user_id(), 'media_library_mode', $mode );
}
@ -34,7 +34,7 @@ if ( 'grid' === $mode ) {
$vars = wp_edit_attachments_query_vars( $q );
$ignore = array( 'mode', 'post_type', 'post_status', 'posts_per_page' );
foreach ( $vars as $key => $value ) {
if ( ! $value || in_array( $key, $ignore ) ) {
if ( ! $value || in_array( $key, $ignore, true ) ) {
unset( $vars[ $key ] );
}
}

View File

@ -477,7 +477,7 @@ endif;
$public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
}
if ( ! in_array( $profileuser->display_name, $public_display ) ) { // Only add this if it isn't duplicated elsewhere.
if ( ! in_array( $profileuser->display_name, $public_display, true ) ) { // Only add this if it isn't duplicated elsewhere.
$public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display;
}

View File

@ -493,7 +493,7 @@ function twentyeleven_layout_classes( $existing_classes ) {
$options = twentyeleven_get_theme_options();
$current_layout = $options['theme_layout'];
if ( in_array( $current_layout, array( 'content-sidebar', 'sidebar-content' ) ) ) {
if ( in_array( $current_layout, array( 'content-sidebar', 'sidebar-content' ), true ) ) {
$classes = array( 'two-column' );
} else {
$classes = array( 'one-column' );

View File

@ -61,7 +61,7 @@ if ( ! function_exists( 'twentyfifteen_entry_meta' ) ) :
);
}
if ( in_array( get_post_type(), array( 'post', 'attachment' ) ) ) {
if ( in_array( get_post_type(), array( 'post', 'attachment' ), true ) ) {
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {

View File

@ -12,7 +12,7 @@
<?php twentyfourteen_post_thumbnail(); ?>
<header class="entry-header">
<?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ) ) && twentyfourteen_categorized_blog() ) : ?>
<?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ), true ) && twentyfourteen_categorized_blog() ) : ?>
<div class="entry-meta">
<span class="cat-links"><?php echo get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfourteen' ) ); ?></span>
</div><!-- .entry-meta -->

View File

@ -12,7 +12,7 @@
<?php twentyfourteen_post_thumbnail(); ?>
<header class="entry-header">
<?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ) ) && twentyfourteen_categorized_blog() ) : ?>
<?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ), true ) && twentyfourteen_categorized_blog() ) : ?>
<div class="entry-meta">
<span class="cat-links"><?php echo get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfourteen' ) ); ?></span>
</div><!-- .entry-meta -->

View File

@ -23,7 +23,7 @@
</a>
<header class="entry-header">
<?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ) ) && twentyfourteen_categorized_blog() ) : ?>
<?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ), true ) && twentyfourteen_categorized_blog() ) : ?>
<div class="entry-meta">
<span class="cat-links"><?php echo get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfourteen' ) ); ?></span>
</div><!-- .entry-meta -->

View File

@ -12,7 +12,7 @@
<?php twentyfourteen_post_thumbnail(); ?>
<header class="entry-header">
<?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ) ) && twentyfourteen_categorized_blog() ) : ?>
<?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ), true ) && twentyfourteen_categorized_blog() ) : ?>
<div class="entry-meta">
<span class="cat-links"><?php echo get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfourteen' ) ); ?></span>
</div><!-- .entry-meta -->

View File

@ -12,7 +12,7 @@
<?php twentyfourteen_post_thumbnail(); ?>
<header class="entry-header">
<?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ) ) && twentyfourteen_categorized_blog() ) : ?>
<?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ), true ) && twentyfourteen_categorized_blog() ) : ?>
<div class="entry-meta">
<span class="cat-links"><?php echo get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfourteen' ) ); ?></span>
</div><!-- .entry-meta -->

View File

@ -12,7 +12,7 @@
<?php twentyfourteen_post_thumbnail(); ?>
<header class="entry-header">
<?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ) ) && twentyfourteen_categorized_blog() ) : ?>
<?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ), true ) && twentyfourteen_categorized_blog() ) : ?>
<div class="entry-meta">
<span class="cat-links"><?php echo get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfourteen' ) ); ?></span>
</div><!-- .entry-meta -->

View File

@ -12,7 +12,7 @@
<?php twentyfourteen_post_thumbnail(); ?>
<header class="entry-header">
<?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ) ) && twentyfourteen_categorized_blog() ) : ?>
<?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ), true ) && twentyfourteen_categorized_blog() ) : ?>
<div class="entry-meta">
<span class="cat-links"><?php echo get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfourteen' ) ); ?></span>
</div><!-- .entry-meta -->

View File

@ -12,7 +12,7 @@
<?php twentyfourteen_post_thumbnail(); ?>
<header class="entry-header">
<?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ) ) && twentyfourteen_categorized_blog() ) : ?>
<?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ), true ) && twentyfourteen_categorized_blog() ) : ?>
<div class="entry-meta">
<span class="cat-links"><?php echo get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfourteen' ) ); ?></span>
</div><!-- .entry-meta -->

View File

@ -14,7 +14,7 @@
<?php twentyfourteen_post_thumbnail(); ?>
<header class="entry-header">
<?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ) ) && twentyfourteen_categorized_blog() ) : ?>
<?php if ( in_array( 'category', get_object_taxonomies( get_post_type() ), true ) && twentyfourteen_categorized_blog() ) : ?>
<div class="entry-meta">
<span class="cat-links"><?php echo get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'twentyfourteen' ) ); ?></span>
</div>

View File

@ -544,7 +544,7 @@ function twentyfourteen_body_classes( $classes ) {
if ( get_header_image() ) {
$classes[] = 'header-image';
} elseif ( ! in_array( $GLOBALS['pagenow'], array( 'wp-activate.php', 'wp-signup.php' ) ) ) {
} elseif ( ! in_array( $GLOBALS['pagenow'], array( 'wp-activate.php', 'wp-signup.php' ), true ) ) {
$classes[] = 'masthead-fixed';
}

View File

@ -127,7 +127,7 @@ function twentyfourteen_customize_partial_blogdescription() {
* @return string Filtered layout type (grid|slider).
*/
function twentyfourteen_sanitize_layout( $layout ) {
if ( ! in_array( $layout, array( 'grid', 'slider' ) ) ) {
if ( ! in_array( $layout, array( 'grid', 'slider' ), true ) ) {
$layout = 'grid';
}

View File

@ -292,7 +292,7 @@ class Featured_Content {
}
// We only want to hide the featured tag.
if ( ! in_array( 'post_tag', $taxonomies ) ) {
if ( ! in_array( 'post_tag', $taxonomies, true ) ) {
return $terms;
}

View File

@ -71,7 +71,11 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget {
* @param array $instance An array of settings for this widget instance.
*/
public function widget( $args, $instance ) {
$format = isset( $instance['format'] ) && in_array( $instance['format'], $this->formats ) ? $instance['format'] : 'aside';
$format = isset( $instance['format'] ) ? $instance['format'] : '';
if ( ! $format || ! in_array( $format, $this->formats, true ) ) {
$format = 'aside';
}
switch ( $format ) {
case 'image':
@ -105,8 +109,9 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget {
break;
}
$number = empty( $instance['number'] ) ? 2 : absint( $instance['number'] );
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? $format_string : $instance['title'], $instance, $this->id_base );
$number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : 2;
$title = ! empty( $instance['title'] ) ? $instance['title'] : $format_string;
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
$ephemera = new WP_Query(
array(
@ -265,7 +270,8 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget {
function update( $new_instance, $instance ) {
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['number'] = empty( $new_instance['number'] ) ? 2 : absint( $new_instance['number'] );
if ( in_array( $new_instance['format'], $this->formats ) ) {
if ( in_array( $new_instance['format'], $this->formats, true ) ) {
$instance['format'] = $new_instance['format'];
}
@ -280,9 +286,13 @@ class Twenty_Fourteen_Ephemera_Widget extends WP_Widget {
* @param array $instance
*/
function form( $instance ) {
$title = empty( $instance['title'] ) ? '' : esc_attr( $instance['title'] );
$number = empty( $instance['number'] ) ? 2 : absint( $instance['number'] );
$format = isset( $instance['format'] ) && in_array( $instance['format'], $this->formats ) ? $instance['format'] : 'aside';
$title = ! empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
$number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : 2;
$format = isset( $instance['format'] ) ? $instance['format'] : '';
if ( ! $format || ! in_array( $format, $this->formats, true ) ) {
$format = 'aside';
}
?>
<p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:', 'twentyfourteen' ); ?></label>
<input id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>"></p>

View File

@ -165,7 +165,7 @@ add_filter( 'wp_nav_menu', 'twentynineteen_add_ellipses_to_nav', 10, 2 );
function twentynineteen_nav_menu_link_attributes( $atts, $item, $args, $depth ) {
// Add [aria-haspopup] and [aria-expanded] to menu items that have children.
$item_has_children = in_array( 'menu-item-has-children', $item->classes );
$item_has_children = in_array( 'menu-item-has-children', $item->classes, true );
if ( $item_has_children ) {
$atts['aria-haspopup'] = 'true';
$atts['aria-expanded'] = 'false';

View File

@ -29,7 +29,7 @@ if ( ! function_exists( 'twentysixteen_entry_meta' ) ) :
);
}
if ( in_array( get_post_type(), array( 'post', 'attachment' ) ) ) {
if ( in_array( get_post_type(), array( 'post', 'attachment' ), true ) ) {
twentysixteen_entry_date();
}

View File

@ -578,7 +578,7 @@ function twentytwelve_body_class( $classes ) {
if ( empty( $background_image ) ) {
if ( empty( $background_color ) ) {
$classes[] = 'custom-background-empty';
} elseif ( in_array( $background_color, array( 'fff', 'ffffff' ) ) ) {
} elseif ( in_array( $background_color, array( 'fff', 'ffffff' ), true ) ) {
$classes[] = 'custom-background-white';
}
}

View File

@ -167,7 +167,7 @@ function get_the_author_meta( $field = '', $user_id = false ) {
$authordata = get_userdata( $user_id );
}
if ( in_array( $field, array( 'login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status' ) ) ) {
if ( in_array( $field, array( 'login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status' ), true ) ) {
$field = 'user_' . $field;
}

View File

@ -279,9 +279,9 @@ function get_bookmarks( $args = '' ) {
foreach ( explode( ',', $orderby ) as $ordparam ) {
$ordparam = trim( $ordparam );
if ( in_array( 'link_' . $ordparam, $keys ) ) {
if ( in_array( 'link_' . $ordparam, $keys, true ) ) {
$orderparams[] = 'link_' . $ordparam;
} elseif ( in_array( $ordparam, $keys ) ) {
} elseif ( in_array( $ordparam, $keys, true ) ) {
$orderparams[] = $ordparam;
}
}
@ -293,7 +293,7 @@ function get_bookmarks( $args = '' ) {
}
$order = strtoupper( $parsed_args['order'] );
if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ) ) ) {
if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ), true ) ) {
$order = 'ASC';
}
@ -412,7 +412,7 @@ function sanitize_bookmark_field( $field, $value, $bookmark_id, $context ) {
break;
case 'link_target': // "enum"
$targets = array( '_top', '_blank' );
if ( ! in_array( $value, $targets ) ) {
if ( ! in_array( $value, $targets, true ) ) {
$value = '';
}
break;

View File

@ -42,7 +42,7 @@
function redirect_canonical( $requested_url = null, $do_redirect = true ) {
global $wp_rewrite, $is_IIS, $wp_query, $wpdb, $wp;
if ( isset( $_SERVER['REQUEST_METHOD'] ) && ! in_array( strtoupper( $_SERVER['REQUEST_METHOD'] ), array( 'GET', 'HEAD' ) ) ) {
if ( isset( $_SERVER['REQUEST_METHOD'] ) && ! in_array( strtoupper( $_SERVER['REQUEST_METHOD'] ), array( 'GET', 'HEAD' ), true ) ) {
return;
}
@ -331,7 +331,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
}
$addl_path = '';
if ( is_feed() && in_array( get_query_var( 'feed' ), $wp_rewrite->feeds ) ) {
if ( is_feed() && in_array( get_query_var( 'feed' ), $wp_rewrite->feeds, true ) ) {
$addl_path = ! empty( $addl_path ) ? trailingslashit( $addl_path ) : '';
if ( ! is_singular() && get_query_var( 'withcomments' ) ) {
$addl_path .= 'comments/';
@ -751,7 +751,7 @@ function wp_redirect_admin_locations() {
site_url( 'dashboard', 'relative' ),
site_url( 'admin', 'relative' ),
);
if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $admins ) ) {
if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $admins, true ) ) {
wp_redirect( admin_url() );
exit;
}
@ -761,7 +761,7 @@ function wp_redirect_admin_locations() {
home_url( 'login', 'relative' ),
site_url( 'login', 'relative' ),
);
if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $logins ) ) {
if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $logins, true ) ) {
wp_redirect( wp_login_url() );
exit;
}

View File

@ -879,7 +879,7 @@ function is_super_admin( $user_id = false ) {
if ( is_multisite() ) {
$super_admins = get_super_admins();
if ( is_array( $super_admins ) && in_array( $user->user_login, $super_admins ) ) {
if ( is_array( $super_admins ) && in_array( $user->user_login, $super_admins, true ) ) {
return true;
}
} else {
@ -921,7 +921,7 @@ function grant_super_admin( $user_id ) {
$super_admins = get_site_option( 'site_admins', array( 'admin' ) );
$user = get_userdata( $user_id );
if ( $user && ! in_array( $user->user_login, $super_admins ) ) {
if ( $user && ! in_array( $user->user_login, $super_admins, true ) ) {
$super_admins[] = $user->user_login;
update_site_option( 'site_admins', $super_admins );
@ -969,7 +969,7 @@ function revoke_super_admin( $user_id ) {
$user = get_userdata( $user_id );
if ( $user && 0 !== strcasecmp( $user->user_email, get_site_option( 'admin_email' ) ) ) {
$key = array_search( $user->user_login, $super_admins );
$key = array_search( $user->user_login, $super_admins, true );
if ( false !== $key ) {
unset( $super_admins[ $key ] );
update_site_option( 'site_admins', $super_admins );

View File

@ -590,7 +590,7 @@ function wp_list_categories( $args = '' ) {
// For taxonomies that belong only to custom post types, point to a valid archive.
$taxonomy_object = get_taxonomy( $parsed_args['taxonomy'] );
if ( ! in_array( 'post', $taxonomy_object->object_type ) && ! in_array( 'page', $taxonomy_object->object_type ) ) {
if ( ! in_array( 'post', $taxonomy_object->object_type, true ) && ! in_array( 'page', $taxonomy_object->object_type, true ) ) {
foreach ( $taxonomy_object->object_type as $object_type ) {
$_object_type = get_post_type_object( $object_type );

View File

@ -532,7 +532,7 @@ class WP_Http {
// Loop over each transport on each HTTP request looking for one which will serve this request's needs.
foreach ( $request_order as $transport ) {
if ( in_array( $transport, $transports ) ) {
if ( in_array( $transport, $transports, true ) ) {
$transport = ucfirst( $transport );
}
$class = 'WP_Http_' . $transport;
@ -904,7 +904,7 @@ class WP_Http {
if ( ! empty( $wildcard_regex ) ) {
return ! preg_match( $wildcard_regex, $check['host'] );
} else {
return ! in_array( $check['host'], $accessible_hosts ); // Inverse logic, if it's in the array, then don't block it.
return ! in_array( $check['host'], $accessible_hosts, true ); // Inverse logic, if it's in the array, then don't block it.
}
}

View File

@ -516,7 +516,7 @@ class WP_Comment_Query {
}
// 'any' overrides other statuses.
if ( ! in_array( 'any', $statuses ) ) {
if ( ! in_array( 'any', $statuses, true ) ) {
foreach ( $statuses as $status ) {
switch ( $status ) {
case 'hold':
@ -595,7 +595,7 @@ class WP_Comment_Query {
$_order = $_value;
}
if ( ! $found_orderby_comment_id && in_array( $_orderby, array( 'comment_ID', 'comment__in' ) ) ) {
if ( ! $found_orderby_comment_id && in_array( $_orderby, array( 'comment_ID', 'comment__in' ), true ) ) {
$found_orderby_comment_id = true;
}
@ -1145,7 +1145,7 @@ class WP_Comment_Query {
} elseif ( 'comment__in' === $orderby ) {
$comment__in = implode( ',', array_map( 'absint', $this->query_vars['comment__in'] ) );
$parsed = "FIELD( {$wpdb->comments}.comment_ID, $comment__in )";
} elseif ( in_array( $orderby, $allowed_keys ) ) {
} elseif ( in_array( $orderby, $allowed_keys, true ) ) {
if ( isset( $meta_query_clauses[ $orderby ] ) ) {
$meta_clause = $meta_query_clauses[ $orderby ];

View File

@ -343,7 +343,7 @@ final class WP_Comment {
* @return bool
*/
public function __isset( $name ) {
if ( in_array( $name, $this->post_fields ) && 0 !== (int) $this->comment_post_ID ) {
if ( in_array( $name, $this->post_fields, true ) && 0 !== (int) $this->comment_post_ID ) {
$post = get_post( $this->comment_post_ID );
return property_exists( $post, $name );
}
@ -360,7 +360,7 @@ final class WP_Comment {
* @return mixed
*/
public function __get( $name ) {
if ( in_array( $name, $this->post_fields ) ) {
if ( in_array( $name, $this->post_fields, true ) ) {
$post = get_post( $this->comment_post_ID );
return $post->$name;
}

View File

@ -5899,11 +5899,11 @@ final class WP_Customize_Manager {
*/
public function _sanitize_background_setting( $value, $setting ) {
if ( 'background_repeat' === $setting->id ) {
if ( ! in_array( $value, array( 'repeat-x', 'repeat-y', 'repeat', 'no-repeat' ) ) ) {
if ( ! in_array( $value, array( 'repeat-x', 'repeat-y', 'repeat', 'no-repeat' ), true ) ) {
return new WP_Error( 'invalid_value', __( 'Invalid value for background repeat.' ) );
}
} elseif ( 'background_attachment' === $setting->id ) {
if ( ! in_array( $value, array( 'fixed', 'scroll' ) ) ) {
if ( ! in_array( $value, array( 'fixed', 'scroll' ), true ) ) {
return new WP_Error( 'invalid_value', __( 'Invalid value for background attachment.' ) );
}
} elseif ( 'background_position_x' === $setting->id ) {

View File

@ -450,7 +450,7 @@ final class WP_Customize_Widgets {
$section_args = array(
'title' => $wp_registered_sidebars[ $sidebar_id ]['name'],
'description' => $wp_registered_sidebars[ $sidebar_id ]['description'],
'priority' => array_search( $sidebar_id, array_keys( $wp_registered_sidebars ) ),
'priority' => array_search( $sidebar_id, array_keys( $wp_registered_sidebars ), true ),
'panel' => 'widgets',
'sidebar_id' => $sidebar_id,
);
@ -577,7 +577,7 @@ final class WP_Customize_Widgets {
$parsed_widget_id = $this->parse_widget_id( $widget_id );
$width = $wp_registered_widget_controls[ $widget_id ]['width'];
$is_core = in_array( $parsed_widget_id['id_base'], $this->core_widget_id_bases );
$is_core = in_array( $parsed_widget_id['id_base'], $this->core_widget_id_bases, true );
$is_wide = ( $width > 250 && ! $is_core );
/**
@ -1220,7 +1220,7 @@ final class WP_Customize_Widgets {
* @return bool Whether the widget is rendered.
*/
public function is_widget_rendered( $widget_id ) {
return in_array( $widget_id, $this->rendered_widgets );
return in_array( $widget_id, $this->rendered_widgets, true );
}
/**
@ -1232,7 +1232,7 @@ final class WP_Customize_Widgets {
* @return bool Whether the sidebar is rendered.
*/
public function is_sidebar_rendered( $sidebar_id ) {
return in_array( $sidebar_id, $this->rendered_sidebars );
return in_array( $sidebar_id, $this->rendered_sidebars, true );
}
/**

View File

@ -259,7 +259,9 @@ class WP_Date_Query {
* @return string The comparison operator.
*/
public function get_compare( $query ) {
if ( ! empty( $query['compare'] ) && in_array( $query['compare'], array( '=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) {
if ( ! empty( $query['compare'] )
&& in_array( $query['compare'], array( '=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ), true )
) {
return strtoupper( $query['compare'] );
}
@ -500,7 +502,7 @@ class WP_Date_Query {
* 'post_modified_gmt', 'comment_date', 'comment_date_gmt',
* 'user_registered'
*/
if ( ! in_array( $column, apply_filters( 'date_query_valid_columns', $valid_columns ) ) ) {
if ( ! in_array( $column, apply_filters( 'date_query_valid_columns', $valid_columns ), true ) ) {
$column = 'post_date';
}
@ -526,7 +528,7 @@ class WP_Date_Query {
// If it's a known column name, add the appropriate table prefix.
foreach ( $known_columns as $table_name => $table_columns ) {
if ( in_array( $column, $table_columns ) ) {
if ( in_array( $column, $table_columns, true ) ) {
$column = $table_name . '.' . $column;
break;
}
@ -972,7 +974,7 @@ class WP_Date_Query {
}
// Complex combined queries aren't supported for multi-value queries.
if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) {
if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ), true ) ) {
$return = array();
$value = $this->build_value( $compare, $hour );

View File

@ -459,7 +459,7 @@ final class _WP_Editors {
*/
$plugins = array_unique( apply_filters( 'tiny_mce_plugins', $plugins, $editor_id ) );
$key = array_search( 'spellchecker', $plugins );
$key = array_search( 'spellchecker', $plugins, true );
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'.

View File

@ -370,6 +370,7 @@ class WP_Embed {
$post = get_post( $post_ID );
$post_types = get_post_types( array( 'show_ui' => true ) );
/**
* Filters the array of post types to cache oEmbed results for.
*
@ -377,7 +378,9 @@ class WP_Embed {
*
* @param string[] $post_types Array of post type names to cache oEmbed results for. Defaults to post types with `show_ui` set to true.
*/
if ( empty( $post->ID ) || ! in_array( $post->post_type, apply_filters( 'embed_cache_oembed_types', $post_types ) ) ) {
$cache_oembed_types = apply_filters( 'embed_cache_oembed_types', $post_types );
if ( empty( $post->ID ) || ! in_array( $post->post_type, $cache_oembed_types, true ) ) {
return;
}

View File

@ -400,7 +400,7 @@ class WP_Http_Streams {
}
// Exact hostname/IP matches.
if ( in_array( strtolower( $host ), $certificate_hostnames ) ) {
if ( in_array( strtolower( $host ), $certificate_hostnames, true ) ) {
return true;
}
@ -417,7 +417,7 @@ class WP_Http_Streams {
// Wildcard subdomains certs (*.example.com) are valid for a.example.com but not a.b.example.com.
$wildcard_host = preg_replace( '/^[^.]+\./', '*.', $host );
return in_array( strtolower( $wildcard_host ), $certificate_hostnames );
return in_array( strtolower( $wildcard_host ), $certificate_hostnames, true );
}
/**

View File

@ -545,7 +545,7 @@ abstract class WP_Image_Editor {
* @return string|false
*/
protected static function get_extension( $mime_type = null ) {
$extensions = explode( '|', array_search( $mime_type, wp_get_mime_types() ) );
$extensions = explode( '|', array_search( $mime_type, wp_get_mime_types(), true ) );
if ( empty( $extensions[0] ) ) {
return false;

View File

@ -687,7 +687,7 @@ class WP_Meta_Query {
if ( array_key_exists( 'value', $clause ) ) {
$meta_value = $clause['value'];
if ( in_array( $meta_compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) {
if ( in_array( $meta_compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ), true ) ) {
if ( ! is_array( $meta_value ) ) {
$meta_value = preg_split( '/[,\s]+/', $meta_value );
}
@ -811,7 +811,7 @@ class WP_Meta_Query {
$clause_compare = strtoupper( $clause['compare'] );
$sibling_compare = strtoupper( $sibling['compare'] );
if ( in_array( $clause_compare, $compatible_compares ) && in_array( $sibling_compare, $compatible_compares ) ) {
if ( in_array( $clause_compare, $compatible_compares, true ) && in_array( $sibling_compare, $compatible_compares, true ) ) {
$alias = $sibling['alias'];
break;
}

View File

@ -551,7 +551,7 @@ class WP_Network_Query {
} elseif ( 'domain_length' === $orderby || 'path_length' === $orderby ) {
$field = substr( $orderby, 0, -7 );
$parsed = "CHAR_LENGTH($wpdb->site.$field)";
} elseif ( in_array( $orderby, $allowed_keys ) ) {
} elseif ( in_array( $orderby, $allowed_keys, true ) ) {
$parsed = "$wpdb->site.$orderby";
}

View File

@ -235,7 +235,7 @@ class WP_oEmbed {
* @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;

View File

@ -454,7 +454,9 @@ final class WP_Post_Type {
}
// Back compat with quirky handling in version 3.0. #14122.
if ( empty( $args['capabilities'] ) && null === $args['map_meta_cap'] && in_array( $args['capability_type'], array( 'post', 'page' ) ) ) {
if ( empty( $args['capabilities'] )
&& null === $args['map_meta_cap'] && in_array( $args['capability_type'], array( 'post', 'page' ), true )
) {
$args['map_meta_cap'] = true;
}

View File

@ -2156,7 +2156,7 @@ class WP_Query {
}
$post_status_join = true;
} elseif ( in_array( 'attachment', (array) $post_type ) ) {
} elseif ( in_array( 'attachment', (array) $post_type, true ) ) {
$post_status_join = true;
}
}
@ -2177,7 +2177,7 @@ class WP_Query {
continue;
}
if ( ! in_array( $queried_taxonomy, array( 'category', 'post_tag' ) ) ) {
if ( ! in_array( $queried_taxonomy, array( 'category', 'post_tag' ), true ) ) {
$q['taxonomy'] = $queried_taxonomy;
if ( 'slug' === $queried_items['field'] ) {
@ -2463,15 +2463,15 @@ class WP_Query {
$r_status = array();
$p_status = array();
$e_status = array();
if ( in_array( 'any', $q_status ) ) {
if ( in_array( 'any', $q_status, true ) ) {
foreach ( get_post_stati( array( 'exclude_from_search' => true ) ) as $status ) {
if ( ! in_array( $status, $q_status ) ) {
if ( ! in_array( $status, $q_status, true ) ) {
$e_status[] = "{$wpdb->posts}.post_status <> '$status'";
}
}
} else {
foreach ( get_post_stati() as $status ) {
if ( in_array( $status, $q_status ) ) {
if ( in_array( $status, $q_status, true ) ) {
if ( 'private' == $status ) {
$p_status[] = "{$wpdb->posts}.post_status = '$status'";
} else {
@ -3083,7 +3083,7 @@ class WP_Query {
}
// If the post_status was specifically requested, let it pass through.
if ( ! in_array( $status, $q_status ) ) {
if ( ! in_array( $status, $q_status, true ) ) {
$post_status_obj = get_post_status_object( $status );
if ( $post_status_obj && ! $post_status_obj->public ) {
@ -3564,7 +3564,7 @@ class WP_Query {
* @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;
}
}
@ -3578,7 +3578,7 @@ class WP_Query {
* @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 );
}
}
@ -3593,7 +3593,7 @@ class WP_Query {
* @return mixed|false 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;
@ -3632,7 +3632,7 @@ class WP_Query {
}
$post_type_object = get_post_type_object( $post_type );
return in_array( $post_type_object->name, (array) $post_types );
return in_array( $post_type_object->name, (array) $post_types, true );
}
/**
@ -3657,11 +3657,11 @@ class WP_Query {
$post_obj = $this->get_queried_object();
if ( in_array( (string) $post_obj->ID, $attachment ) ) {
if ( in_array( (string) $post_obj->ID, $attachment, true ) ) {
return true;
} elseif ( in_array( $post_obj->post_title, $attachment ) ) {
} elseif ( in_array( $post_obj->post_title, $attachment, true ) ) {
return true;
} elseif ( in_array( $post_obj->post_name, $attachment ) ) {
} elseif ( in_array( $post_obj->post_name, $attachment, true ) ) {
return true;
}
return false;
@ -3692,11 +3692,11 @@ class WP_Query {
$author = array_map( 'strval', (array) $author );
if ( in_array( (string) $author_obj->ID, $author ) ) {
if ( in_array( (string) $author_obj->ID, $author, true ) ) {
return true;
} elseif ( in_array( $author_obj->nickname, $author ) ) {
} elseif ( in_array( $author_obj->nickname, $author, true ) ) {
return true;
} elseif ( in_array( $author_obj->user_nicename, $author ) ) {
} elseif ( in_array( $author_obj->user_nicename, $author, true ) ) {
return true;
}
@ -3728,11 +3728,11 @@ class WP_Query {
$category = array_map( 'strval', (array) $category );
if ( in_array( (string) $cat_obj->term_id, $category ) ) {
if ( in_array( (string) $cat_obj->term_id, $category, true ) ) {
return true;
} elseif ( in_array( $cat_obj->name, $category ) ) {
} elseif ( in_array( $cat_obj->name, $category, true ) ) {
return true;
} elseif ( in_array( $cat_obj->slug, $category ) ) {
} elseif ( in_array( $cat_obj->slug, $category, true ) ) {
return true;
}
@ -3764,11 +3764,11 @@ class WP_Query {
$tag = array_map( 'strval', (array) $tag );
if ( in_array( (string) $tag_obj->term_id, $tag ) ) {
if ( in_array( (string) $tag_obj->term_id, $tag, true ) ) {
return true;
} elseif ( in_array( $tag_obj->name, $tag ) ) {
} elseif ( in_array( $tag_obj->name, $tag, true ) ) {
return true;
} elseif ( in_array( $tag_obj->slug, $tag ) ) {
} elseif ( in_array( $tag_obj->slug, $tag, true ) ) {
return true;
}
@ -3812,7 +3812,7 @@ class WP_Query {
$term_array = (array) $term;
// Check that the taxonomy matches.
if ( ! ( isset( $queried_object->taxonomy ) && count( $tax_array ) && in_array( $queried_object->taxonomy, $tax_array ) ) ) {
if ( ! ( isset( $queried_object->taxonomy ) && count( $tax_array ) && in_array( $queried_object->taxonomy, $tax_array, true ) ) ) {
return false;
}
@ -3883,7 +3883,7 @@ class WP_Query {
if ( 'feed' == $qv ) {
$qv = get_default_feed();
}
return in_array( $qv, (array) $feeds );
return in_array( $qv, (array) $feeds, true );
}
/**
@ -4004,11 +4004,11 @@ class WP_Query {
$page = array_map( 'strval', (array) $page );
if ( in_array( (string) $page_obj->ID, $page ) ) {
if ( in_array( (string) $page_obj->ID, $page, true ) ) {
return true;
} elseif ( in_array( $page_obj->post_title, $page ) ) {
} elseif ( in_array( $page_obj->post_title, $page, true ) ) {
return true;
} elseif ( in_array( $page_obj->post_name, $page ) ) {
} elseif ( in_array( $page_obj->post_name, $page, true ) ) {
return true;
} else {
foreach ( $page as $pagepath ) {
@ -4111,11 +4111,11 @@ class WP_Query {
$post = array_map( 'strval', (array) $post );
if ( in_array( (string) $post_obj->ID, $post ) ) {
if ( in_array( (string) $post_obj->ID, $post, true ) ) {
return true;
} elseif ( in_array( $post_obj->post_title, $post ) ) {
} elseif ( in_array( $post_obj->post_title, $post, true ) ) {
return true;
} elseif ( in_array( $post_obj->post_name, $post ) ) {
} elseif ( in_array( $post_obj->post_name, $post, true ) ) {
return true;
} else {
foreach ( $post as $postpath ) {
@ -4156,7 +4156,7 @@ class WP_Query {
$post_obj = $this->get_queried_object();
return in_array( $post_obj->post_type, (array) $post_types );
return in_array( $post_obj->post_type, (array) $post_types, true );
}
/**

View File

@ -797,7 +797,7 @@ class WP_Rewrite {
* @param string $query String to append to the rewritten query. Must end in '='.
*/
public function add_rewrite_tag( $tag, $regex, $query ) {
$position = array_search( $tag, $this->rewritecode );
$position = array_search( $tag, $this->rewritecode, true );
if ( false !== $position && null !== $position ) {
$this->rewritereplace[ $position ] = $regex;
$this->queryreplace[ $position ] = $query;
@ -821,7 +821,7 @@ class WP_Rewrite {
* @param string $tag Name of the rewrite tag to remove.
*/
public function remove_rewrite_tag( $tag ) {
$position = array_search( $tag, $this->rewritecode );
$position = array_search( $tag, $this->rewritecode, true );
if ( false !== $position && null !== $position ) {
unset( $this->rewritecode[ $position ] );
unset( $this->rewritereplace[ $position ] );

Some files were not shown because too many files have changed in this diff Show More