mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-05-16 17:24:27 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@47550 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -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.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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 ];
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 ) {
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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'.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 ] );
|
||||
|
||||
@@ -526,7 +526,7 @@ class WP_Tax_Query {
|
||||
}
|
||||
|
||||
// The sibling must both have compatible operator to share its alias.
|
||||
if ( in_array( strtoupper( $sibling['operator'] ), $compatible_operators ) ) {
|
||||
if ( in_array( strtoupper( $sibling['operator'] ), $compatible_operators, true ) ) {
|
||||
$alias = $sibling['alias'];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -502,7 +502,7 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer {
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
@@ -517,7 +517,7 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer {
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
@@ -531,7 +531,7 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer {
|
||||
* @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 );
|
||||
}
|
||||
}
|
||||
@@ -544,7 +544,7 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer {
|
||||
* @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 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +206,9 @@ final class WP_Theme implements ArrayAccess {
|
||||
$this->stylesheet = $theme_dir;
|
||||
|
||||
// Correct a situation where the theme is 'some-directory/some-theme' but 'some-directory' was passed in as part of the theme root instead.
|
||||
if ( ! in_array( $theme_root, (array) $wp_theme_directories ) && in_array( dirname( $theme_root ), (array) $wp_theme_directories ) ) {
|
||||
if ( ! in_array( $theme_root, (array) $wp_theme_directories, true )
|
||||
&& in_array( dirname( $theme_root ), (array) $wp_theme_directories, true )
|
||||
) {
|
||||
$this->stylesheet = basename( $this->theme_root ) . '/' . $this->stylesheet;
|
||||
$this->theme_root = dirname( $theme_root );
|
||||
}
|
||||
@@ -475,7 +477,7 @@ final class WP_Theme implements ArrayAccess {
|
||||
'theme_root_uri',
|
||||
);
|
||||
|
||||
return in_array( $offset, $properties );
|
||||
return in_array( $offset, $properties, true );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -574,7 +576,7 @@ final class WP_Theme implements ArrayAccess {
|
||||
'Parent Theme',
|
||||
);
|
||||
|
||||
return in_array( $offset, $keys );
|
||||
return in_array( $offset, $keys, true );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -661,7 +663,7 @@ final class WP_Theme implements ArrayAccess {
|
||||
* @return bool Whether the theme exists.
|
||||
*/
|
||||
public function exists() {
|
||||
return ! ( $this->errors() && in_array( 'theme_not_found', $this->errors()->get_error_codes() ) );
|
||||
return ! ( $this->errors() && in_array( 'theme_not_found', $this->errors()->get_error_codes(), true ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1029,7 +1031,7 @@ final class WP_Theme implements ArrayAccess {
|
||||
* @return string Absolute path of the stylesheet directory.
|
||||
*/
|
||||
public function get_stylesheet_directory() {
|
||||
if ( $this->errors() && in_array( 'theme_root_missing', $this->errors()->get_error_codes() ) ) {
|
||||
if ( $this->errors() && in_array( 'theme_root_missing', $this->errors()->get_error_codes(), true ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
@@ -756,9 +756,9 @@ class WP_User_Query {
|
||||
$meta_query_clauses = $this->meta_query->get_clauses();
|
||||
|
||||
$_orderby = '';
|
||||
if ( in_array( $orderby, array( 'login', 'nicename', 'email', 'url', 'registered' ) ) ) {
|
||||
if ( in_array( $orderby, array( 'login', 'nicename', 'email', 'url', 'registered' ), true ) ) {
|
||||
$_orderby = 'user_' . $orderby;
|
||||
} elseif ( in_array( $orderby, array( 'user_login', 'user_nicename', 'user_email', 'user_url', 'user_registered' ) ) ) {
|
||||
} elseif ( in_array( $orderby, array( 'user_login', 'user_nicename', 'user_email', 'user_url', 'user_registered' ), true ) ) {
|
||||
$_orderby = $orderby;
|
||||
} elseif ( 'name' == $orderby || 'display_name' == $orderby ) {
|
||||
$_orderby = 'display_name';
|
||||
@@ -828,7 +828,7 @@ class WP_User_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;
|
||||
}
|
||||
}
|
||||
@@ -843,7 +843,7 @@ class WP_User_Query {
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
@@ -857,7 +857,7 @@ class WP_User_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 );
|
||||
}
|
||||
}
|
||||
@@ -870,7 +870,7 @@ class WP_User_Query {
|
||||
* @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 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -559,7 +559,7 @@ class WP_User {
|
||||
* @param string $role Role name.
|
||||
*/
|
||||
public function remove_role( $role ) {
|
||||
if ( ! in_array( $role, $this->roles ) ) {
|
||||
if ( ! in_array( $role, $this->roles, true ) ) {
|
||||
return;
|
||||
}
|
||||
unset( $this->caps[ $role ] );
|
||||
@@ -750,7 +750,7 @@ class WP_User {
|
||||
|
||||
// Multisite super admin has all caps by definition, Unless specifically denied.
|
||||
if ( is_multisite() && is_super_admin( $this->ID ) ) {
|
||||
if ( in_array( 'do_not_allow', $caps ) ) {
|
||||
if ( in_array( 'do_not_allow', $caps, true ) ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -757,19 +757,19 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
'_builtin' => (bool) $taxonomy->_builtin,
|
||||
);
|
||||
|
||||
if ( in_array( 'labels', $fields ) ) {
|
||||
if ( in_array( 'labels', $fields, true ) ) {
|
||||
$_taxonomy['labels'] = (array) $taxonomy->labels;
|
||||
}
|
||||
|
||||
if ( in_array( 'cap', $fields ) ) {
|
||||
if ( in_array( 'cap', $fields, true ) ) {
|
||||
$_taxonomy['cap'] = (array) $taxonomy->cap;
|
||||
}
|
||||
|
||||
if ( in_array( 'menu', $fields ) ) {
|
||||
if ( in_array( 'menu', $fields, true ) ) {
|
||||
$_taxonomy['show_in_menu'] = (bool) $_taxonomy->show_in_menu;
|
||||
}
|
||||
|
||||
if ( in_array( 'object_type', $fields ) ) {
|
||||
if ( in_array( 'object_type', $fields, true ) ) {
|
||||
$_taxonomy['object_type'] = array_unique( (array) $taxonomy->object_type );
|
||||
}
|
||||
|
||||
@@ -902,16 +902,16 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
}
|
||||
|
||||
// Merge requested $post_fields fields into $_post.
|
||||
if ( in_array( 'post', $fields ) ) {
|
||||
if ( in_array( 'post', $fields, true ) ) {
|
||||
$_post = array_merge( $_post, $post_fields );
|
||||
} else {
|
||||
$requested_fields = array_intersect_key( $post_fields, array_flip( $fields ) );
|
||||
$_post = array_merge( $_post, $requested_fields );
|
||||
}
|
||||
|
||||
$all_taxonomy_fields = in_array( 'taxonomies', $fields );
|
||||
$all_taxonomy_fields = in_array( 'taxonomies', $fields, true );
|
||||
|
||||
if ( $all_taxonomy_fields || in_array( 'terms', $fields ) ) {
|
||||
if ( $all_taxonomy_fields || in_array( 'terms', $fields, true ) ) {
|
||||
$post_type_taxonomies = get_object_taxonomies( $post['post_type'], 'names' );
|
||||
$terms = wp_get_object_terms( $post['ID'], $post_type_taxonomies );
|
||||
$_post['terms'] = array();
|
||||
@@ -920,11 +920,11 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
}
|
||||
}
|
||||
|
||||
if ( in_array( 'custom_fields', $fields ) ) {
|
||||
if ( in_array( 'custom_fields', $fields, true ) ) {
|
||||
$_post['custom_fields'] = $this->get_custom_fields( $post['ID'] );
|
||||
}
|
||||
|
||||
if ( in_array( 'enclosure', $fields ) ) {
|
||||
if ( in_array( 'enclosure', $fields, true ) ) {
|
||||
$_post['enclosure'] = array();
|
||||
$enclosures = (array) get_post_meta( $post['ID'], 'enclosure' );
|
||||
if ( ! empty( $enclosures ) ) {
|
||||
@@ -969,22 +969,22 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
'supports' => get_all_post_type_supports( $post_type->name ),
|
||||
);
|
||||
|
||||
if ( in_array( 'labels', $fields ) ) {
|
||||
if ( in_array( 'labels', $fields, true ) ) {
|
||||
$_post_type['labels'] = (array) $post_type->labels;
|
||||
}
|
||||
|
||||
if ( in_array( 'cap', $fields ) ) {
|
||||
if ( in_array( 'cap', $fields, true ) ) {
|
||||
$_post_type['cap'] = (array) $post_type->cap;
|
||||
$_post_type['map_meta_cap'] = (bool) $post_type->map_meta_cap;
|
||||
}
|
||||
|
||||
if ( in_array( 'menu', $fields ) ) {
|
||||
if ( in_array( 'menu', $fields, true ) ) {
|
||||
$_post_type['menu_position'] = (int) $post_type->menu_position;
|
||||
$_post_type['menu_icon'] = $post_type->menu_icon;
|
||||
$_post_type['show_in_menu'] = (bool) $post_type->show_in_menu;
|
||||
}
|
||||
|
||||
if ( in_array( 'taxonomies', $fields ) ) {
|
||||
if ( in_array( 'taxonomies', $fields, true ) ) {
|
||||
$_post_type['taxonomies'] = get_object_taxonomies( $post_type->name, 'names' );
|
||||
}
|
||||
|
||||
@@ -1190,10 +1190,10 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
'roles' => $user->roles,
|
||||
);
|
||||
|
||||
if ( in_array( 'all', $fields ) ) {
|
||||
if ( in_array( 'all', $fields, true ) ) {
|
||||
$_user = array_merge( $_user, $user_fields );
|
||||
} else {
|
||||
if ( in_array( 'basic', $fields ) ) {
|
||||
if ( in_array( 'basic', $fields, true ) ) {
|
||||
$basic_fields = array( 'username', 'email', 'registered', 'display_name', 'nicename' );
|
||||
$fields = array_merge( $fields, $basic_fields );
|
||||
}
|
||||
@@ -1577,7 +1577,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
|
||||
$term_names = $post_data['terms_names'][ $taxonomy ];
|
||||
foreach ( $term_names as $term_name ) {
|
||||
if ( in_array( $term_name, $ambiguous_terms ) ) {
|
||||
if ( in_array( $term_name, $ambiguous_terms, true ) ) {
|
||||
return new IXR_Error( 401, __( 'Ambiguous term name used in a hierarchical taxonomy. Please use term ID instead.' ) );
|
||||
}
|
||||
|
||||
@@ -3757,7 +3757,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
$statuses = get_comment_statuses();
|
||||
$statuses = array_keys( $statuses );
|
||||
|
||||
if ( ! in_array( $content_struct['status'], $statuses ) ) {
|
||||
if ( ! in_array( $content_struct['status'], $statuses, true ) ) {
|
||||
return new IXR_Error( 401, __( 'Invalid comment status.' ) );
|
||||
}
|
||||
|
||||
@@ -5668,7 +5668,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
}
|
||||
|
||||
// Use wp.editPost to edit post types other than post and page.
|
||||
if ( ! in_array( $postdata['post_type'], array( 'post', 'page' ) ) ) {
|
||||
if ( ! in_array( $postdata['post_type'], array( 'post', 'page' ), true ) ) {
|
||||
return new IXR_Error( 401, __( 'Invalid post type.' ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ class WP {
|
||||
* @param string $qv Query variable name.
|
||||
*/
|
||||
public function add_query_var( $qv ) {
|
||||
if ( ! in_array( $qv, $this->public_query_vars ) ) {
|
||||
if ( ! in_array( $qv, $this->public_query_vars, true ) ) {
|
||||
$this->public_query_vars[] = $qv;
|
||||
}
|
||||
}
|
||||
@@ -348,7 +348,7 @@ class WP {
|
||||
if ( isset( $this->query_vars['post_type'] ) ) {
|
||||
$queryable_post_types = get_post_types( array( 'publicly_queryable' => true ) );
|
||||
if ( ! is_array( $this->query_vars['post_type'] ) ) {
|
||||
if ( ! in_array( $this->query_vars['post_type'], $queryable_post_types ) ) {
|
||||
if ( ! in_array( $this->query_vars['post_type'], $queryable_post_types, true ) ) {
|
||||
unset( $this->query_vars['post_type'] );
|
||||
}
|
||||
} else {
|
||||
@@ -412,7 +412,7 @@ class WP {
|
||||
$headers = array_merge( $headers, wp_get_nocache_headers() );
|
||||
}
|
||||
$headers['Content-Type'] = get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' );
|
||||
} elseif ( in_array( $status, array( 403, 500, 502, 503 ) ) ) {
|
||||
} elseif ( in_array( $status, array( 403, 500, 502, 503 ), true ) ) {
|
||||
$exit_required = true;
|
||||
}
|
||||
} elseif ( empty( $this->query_vars['feed'] ) ) {
|
||||
|
||||
@@ -1385,7 +1385,7 @@ function wp_delete_comment( $comment_id, $force_delete = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! $force_delete && EMPTY_TRASH_DAYS && ! in_array( wp_get_comment_status( $comment ), array( 'trash', 'spam' ) ) ) {
|
||||
if ( ! $force_delete && EMPTY_TRASH_DAYS && ! in_array( wp_get_comment_status( $comment ), array( 'trash', 'spam' ), true ) ) {
|
||||
return wp_trash_comment( $comment_id );
|
||||
}
|
||||
|
||||
@@ -2752,7 +2752,7 @@ function do_trackbacks( $post_id ) {
|
||||
if ( $to_ping ) {
|
||||
foreach ( (array) $to_ping as $tb_ping ) {
|
||||
$tb_ping = trim( $tb_ping );
|
||||
if ( ! in_array( $tb_ping, $pinged ) ) {
|
||||
if ( ! in_array( $tb_ping, $pinged, true ) ) {
|
||||
trackback( $tb_ping, $post_title, $excerpt, $post->ID );
|
||||
$pinged[] = $tb_ping;
|
||||
} else {
|
||||
@@ -2836,7 +2836,7 @@ function pingback( $content, $post_id ) {
|
||||
*/
|
||||
foreach ( (array) $post_links_temp as $link_test ) {
|
||||
// If we haven't pung it already and it isn't a link to itself.
|
||||
if ( ! in_array( $link_test, $pung ) && ( url_to_postid( $link_test ) != $post->ID )
|
||||
if ( ! in_array( $link_test, $pung, true ) && ( url_to_postid( $link_test ) != $post->ID )
|
||||
// Also, let's never ping local attachments.
|
||||
&& ! is_local_attachment( $link_test ) ) {
|
||||
$test = @parse_url( $link_test );
|
||||
@@ -3117,7 +3117,7 @@ function _close_comments_for_old_posts( $posts, $query ) {
|
||||
* @param string[] $post_types An array of post type names.
|
||||
*/
|
||||
$post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
|
||||
if ( ! in_array( $posts[0]->post_type, $post_types ) ) {
|
||||
if ( ! in_array( $posts[0]->post_type, $post_types, true ) ) {
|
||||
return $posts;
|
||||
}
|
||||
|
||||
@@ -3162,7 +3162,7 @@ function _close_comments_for_old_post( $open, $post_id ) {
|
||||
|
||||
/** This filter is documented in wp-includes/comment.php */
|
||||
$post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) );
|
||||
if ( ! in_array( $post->post_type, $post_types ) ) {
|
||||
if ( ! in_array( $post->post_type, $post_types, true ) ) {
|
||||
return $open;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ function _mb_substr( $str, $start, $length = null, $encoding = null ) {
|
||||
* The solution below works only for UTF-8, so in case of a different
|
||||
* charset just use built-in substr().
|
||||
*/
|
||||
if ( ! in_array( $encoding, array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) {
|
||||
if ( ! in_array( $encoding, array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ), true ) ) {
|
||||
return is_null( $length ) ? substr( $str, $start ) : substr( $str, $start, $length );
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ function _mb_strlen( $str, $encoding = null ) {
|
||||
* The solution below works only for UTF-8, so in case of a different charset
|
||||
* just use built-in strlen().
|
||||
*/
|
||||
if ( ! in_array( $encoding, array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) {
|
||||
if ( ! in_array( $encoding, array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ), true ) ) {
|
||||
return strlen( $str );
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,9 @@ class WP_Customize_Media_Control extends WP_Customize_Control {
|
||||
if ( $this->setting->default ) {
|
||||
// Fake an attachment model - needs all fields used by template.
|
||||
// Note that the default value must be a URL, NOT an attachment ID.
|
||||
$type = in_array( substr( $this->setting->default, -3 ), array( 'jpg', 'png', 'gif', 'bmp' ) ) ? 'image' : 'document';
|
||||
$ext = substr( $this->setting->default, -3 );
|
||||
$type = in_array( $ext, array( 'jpg', 'png', 'gif', 'bmp' ), true ) ? 'image' : 'document';
|
||||
|
||||
$default_attachment = array(
|
||||
'id' => 1,
|
||||
'url' => $this->setting->default,
|
||||
|
||||
@@ -800,7 +800,7 @@ function _oembed_create_xml( $data, $node = null ) {
|
||||
* @return string The filtered oEmbed result.
|
||||
*/
|
||||
function wp_filter_oembed_iframe_title_attribute( $result, $data, $url ) {
|
||||
if ( false === $result || ! in_array( $data->type, array( 'rich', 'video' ) ) ) {
|
||||
if ( false === $result || ! in_array( $data->type, array( 'rich', 'video' ), true ) ) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -854,7 +854,7 @@ function wp_filter_oembed_iframe_title_attribute( $result, $data, $url ) {
|
||||
* @return string The filtered and sanitized oEmbed result.
|
||||
*/
|
||||
function wp_filter_oembed_result( $result, $data, $url ) {
|
||||
if ( false === $result || ! in_array( $data->type, array( 'rich', 'video' ) ) ) {
|
||||
if ( false === $result || ! in_array( $data->type, array( 'rich', 'video' ), true ) ) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@@ -424,7 +424,7 @@ function _wptexturize_pushpop_element( $text, &$stack, $disabled_elements ) {
|
||||
$tag = substr( $text, $name_offset, $space );
|
||||
|
||||
// Handle disabled tags.
|
||||
if ( in_array( $tag, $disabled_elements ) ) {
|
||||
if ( in_array( $tag, $disabled_elements, true ) ) {
|
||||
if ( $opening_tag ) {
|
||||
/*
|
||||
* This disables texturize until we find a closing tag of our type
|
||||
@@ -978,7 +978,7 @@ function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = fals
|
||||
$charset = $_charset;
|
||||
}
|
||||
|
||||
if ( in_array( $charset, array( 'utf8', 'utf-8', 'UTF8' ) ) ) {
|
||||
if ( in_array( $charset, array( 'utf8', 'utf-8', 'UTF8' ), true ) ) {
|
||||
$charset = 'UTF-8';
|
||||
}
|
||||
|
||||
@@ -1123,7 +1123,7 @@ function wp_check_invalid_utf8( $string, $strip = false ) {
|
||||
// Store the site charset as a static to avoid multiple calls to get_option().
|
||||
static $is_utf8 = null;
|
||||
if ( ! isset( $is_utf8 ) ) {
|
||||
$is_utf8 = in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) );
|
||||
$is_utf8 = in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ), true );
|
||||
}
|
||||
if ( ! $is_utf8 ) {
|
||||
return $string;
|
||||
@@ -2876,8 +2876,9 @@ function _make_web_ftp_clickable_cb( $matches ) {
|
||||
$dest = 'http://' . $dest;
|
||||
|
||||
// Removed trailing [.,;:)] from URL.
|
||||
if ( in_array( substr( $dest, -1 ), array( '.', ',', ';', ':', ')' ) ) === true ) {
|
||||
$ret = substr( $dest, -1 );
|
||||
$last_char = substr( $dest, -1 );
|
||||
if ( in_array( $last_char, array( '.', ',', ';', ':', ')' ), true ) === true ) {
|
||||
$ret = $last_char;
|
||||
$dest = substr( $dest, 0, strlen( $dest ) - 1 );
|
||||
}
|
||||
|
||||
@@ -3305,7 +3306,7 @@ function translate_smiley( $matches ) {
|
||||
$image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' );
|
||||
|
||||
// Don't convert smilies that aren't images - they're probably emoji.
|
||||
if ( ! in_array( $ext, $image_exts ) ) {
|
||||
if ( ! in_array( $ext, $image_exts, true ) ) {
|
||||
return $img;
|
||||
}
|
||||
|
||||
@@ -4311,7 +4312,7 @@ function esc_url( $url, $protocols = null, $_context = 'display' ) {
|
||||
* it needs http:// prepended (unless it's a relative link
|
||||
* starting with /, # or ?, or a PHP file).
|
||||
*/
|
||||
if ( strpos( $url, ':' ) === false && ! in_array( $url[0], array( '/', '#', '?' ) ) &&
|
||||
if ( strpos( $url, ':' ) === false && ! in_array( $url[0], array( '/', '#', '?' ), true ) &&
|
||||
! preg_match( '/^[a-z0-9-]+?\.php/i', $url ) ) {
|
||||
$url = 'http://' . $url;
|
||||
}
|
||||
@@ -4715,7 +4716,7 @@ function sanitize_option( $option, $value ) {
|
||||
if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG ) {
|
||||
$allowed[] = WPLANG;
|
||||
}
|
||||
if ( ! in_array( $value, $allowed ) && ! empty( $value ) ) {
|
||||
if ( ! in_array( $value, $allowed, true ) && ! empty( $value ) ) {
|
||||
$value = get_option( $option );
|
||||
}
|
||||
break;
|
||||
@@ -4763,7 +4764,7 @@ function sanitize_option( $option, $value ) {
|
||||
|
||||
case 'timezone_string':
|
||||
$allowed_zones = timezone_identifiers_list();
|
||||
if ( ! in_array( $value, $allowed_zones ) && ! empty( $value ) ) {
|
||||
if ( ! in_array( $value, $allowed_zones, true ) && ! empty( $value ) ) {
|
||||
$error = __( 'The timezone you have entered is not valid. Please select a valid timezone.' );
|
||||
}
|
||||
break;
|
||||
@@ -5145,7 +5146,7 @@ function _links_add_base( $m ) {
|
||||
global $_links_add_base;
|
||||
// 1 = attribute name 2 = quotation mark 3 = URL.
|
||||
return $m[1] . '=' . $m[2] .
|
||||
( preg_match( '#^(\w{1,20}):#', $m[3], $protocol ) && in_array( $protocol[1], wp_allowed_protocols() ) ?
|
||||
( preg_match( '#^(\w{1,20}):#', $m[3], $protocol ) && in_array( $protocol[1], wp_allowed_protocols(), true ) ?
|
||||
$m[3] :
|
||||
WP_Http::make_absolute_url( $m[3], $_links_add_base )
|
||||
)
|
||||
|
||||
@@ -2734,7 +2734,7 @@ function wp_ext2type( $ext ) {
|
||||
|
||||
$ext2type = wp_get_ext_types();
|
||||
foreach ( $ext2type as $type => $exts ) {
|
||||
if ( in_array( $ext, $exts ) ) {
|
||||
if ( in_array( $ext, $exts, true ) ) {
|
||||
return $type;
|
||||
}
|
||||
}
|
||||
@@ -2881,7 +2881,7 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
|
||||
*/
|
||||
if ( in_array( $real_mime, $nonspecific_types, true ) ) {
|
||||
// File is a non-specific binary type. That's ok if it's a type that generally tends to be binary.
|
||||
if ( ! in_array( substr( $type, 0, strcspn( $type, '/' ) ), array( 'application', 'video', 'audio' ) ) ) {
|
||||
if ( ! in_array( substr( $type, 0, strcspn( $type, '/' ) ), array( 'application', 'video', 'audio' ), true ) ) {
|
||||
$type = false;
|
||||
$ext = false;
|
||||
}
|
||||
@@ -2905,7 +2905,8 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
|
||||
'text/richtext',
|
||||
'text/tsv',
|
||||
'text/vtt',
|
||||
)
|
||||
),
|
||||
true
|
||||
)
|
||||
) {
|
||||
$type = false;
|
||||
@@ -2919,7 +2920,8 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
|
||||
'text/rtf',
|
||||
'text/plain',
|
||||
'application/rtf',
|
||||
)
|
||||
),
|
||||
true
|
||||
)
|
||||
) {
|
||||
$type = false;
|
||||
@@ -2941,7 +2943,7 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
|
||||
if ( $type ) {
|
||||
$allowed = get_allowed_mime_types();
|
||||
|
||||
if ( ! in_array( $type, $allowed ) ) {
|
||||
if ( ! in_array( $type, $allowed, true ) ) {
|
||||
$type = false;
|
||||
$ext = false;
|
||||
}
|
||||
@@ -5235,7 +5237,7 @@ function apache_mod_loaded( $mod, $default = false ) {
|
||||
|
||||
if ( function_exists( 'apache_get_modules' ) ) {
|
||||
$mods = apache_get_modules();
|
||||
if ( in_array( $mod, $mods ) ) {
|
||||
if ( in_array( $mod, $mods, true ) ) {
|
||||
return true;
|
||||
}
|
||||
} elseif ( function_exists( 'phpinfo' ) && false === strpos( ini_get( 'disable_functions' ), 'phpinfo' ) ) {
|
||||
@@ -5317,7 +5319,7 @@ function validate_file( $file, $allowed_files = array() ) {
|
||||
}
|
||||
|
||||
// Files not in the allowed file list are not allowed:
|
||||
if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files ) ) {
|
||||
if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files, true ) ) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@@ -5728,7 +5730,7 @@ function wp_timezone_choice( $selected_zone, $locale = null ) {
|
||||
$zonen = array();
|
||||
foreach ( timezone_identifiers_list() as $zone ) {
|
||||
$zone = explode( '/', $zone );
|
||||
if ( ! in_array( $zone[0], $continents ) ) {
|
||||
if ( ! in_array( $zone[0], $continents, true ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -6316,9 +6318,9 @@ function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pr
|
||||
|
||||
$caller[] = "{$call['class']}{$call['type']}{$call['function']}";
|
||||
} else {
|
||||
if ( in_array( $call['function'], array( 'do_action', 'apply_filters', 'do_action_ref_array', 'apply_filters_ref_array' ) ) ) {
|
||||
if ( in_array( $call['function'], array( 'do_action', 'apply_filters', 'do_action_ref_array', 'apply_filters_ref_array' ), true ) ) {
|
||||
$caller[] = "{$call['function']}('{$call['args'][0]}')";
|
||||
} elseif ( in_array( $call['function'], array( 'include', 'include_once', 'require', 'require_once' ) ) ) {
|
||||
} elseif ( in_array( $call['function'], array( 'include', 'include_once', 'require', 'require_once' ), true ) ) {
|
||||
$filename = isset( $call['args'][0] ) ? $call['args'][0] : '';
|
||||
$caller[] = $call['function'] . "('" . str_replace( $truncate_paths, '', wp_normalize_path( $filename ) ) . "')";
|
||||
} else {
|
||||
@@ -6447,7 +6449,7 @@ function wp_auth_check_load() {
|
||||
|
||||
$screen = get_current_screen();
|
||||
$hidden = array( 'update', 'update-network', 'update-core', 'update-core-network', 'upgrade', 'upgrade-network', 'network' );
|
||||
$show = ! in_array( $screen->id, $hidden );
|
||||
$show = ! in_array( $screen->id, $hidden, true );
|
||||
|
||||
/**
|
||||
* Filters whether to load the authentication check.
|
||||
|
||||
@@ -249,7 +249,7 @@ function wp_deregister_script( $handle ) {
|
||||
if ( ( is_admin() && 'admin_enqueue_scripts' !== $current_filter ) ||
|
||||
( 'wp-login.php' === $GLOBALS['pagenow'] && 'login_enqueue_scripts' !== $current_filter )
|
||||
) {
|
||||
$no = array(
|
||||
$not_allowed = array(
|
||||
'jquery',
|
||||
'jquery-core',
|
||||
'jquery-migrate',
|
||||
@@ -277,7 +277,7 @@ function wp_deregister_script( $handle ) {
|
||||
'backbone',
|
||||
);
|
||||
|
||||
if ( in_array( $handle, $no ) ) {
|
||||
if ( in_array( $handle, $not_allowed, true ) ) {
|
||||
$message = sprintf(
|
||||
/* translators: 1: Script name, 2: wp_enqueue_scripts */
|
||||
__( 'Do not deregister the %1$s script in the administration area. To target the front-end theme, use the %2$s hook.' ),
|
||||
|
||||
@@ -3233,7 +3233,7 @@ function wp_resource_hints() {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( in_array( $relation_type, array( 'preconnect', 'dns-prefetch' ) ) ) {
|
||||
if ( in_array( $relation_type, array( 'preconnect', 'dns-prefetch' ), true ) ) {
|
||||
$parsed = wp_parse_url( $url );
|
||||
|
||||
if ( empty( $parsed['host'] ) ) {
|
||||
@@ -3258,8 +3258,9 @@ function wp_resource_hints() {
|
||||
$html = '';
|
||||
|
||||
foreach ( $atts as $attr => $value ) {
|
||||
if ( ! is_scalar( $value ) ||
|
||||
( ! in_array( $attr, array( 'as', 'crossorigin', 'href', 'pr', 'rel', 'type' ), true ) && ! is_numeric( $attr ) ) ) {
|
||||
if ( ! is_scalar( $value )
|
||||
|| ( ! in_array( $attr, array( 'as', 'crossorigin', 'href', 'pr', 'rel', 'type' ), true ) && ! is_numeric( $attr ) )
|
||||
) {
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -3303,7 +3304,9 @@ function wp_dependencies_unique_hosts() {
|
||||
$dependency = $dependencies->registered[ $handle ];
|
||||
$parsed = wp_parse_url( $dependency->src );
|
||||
|
||||
if ( ! empty( $parsed['host'] ) && ! in_array( $parsed['host'], $unique_hosts ) && $parsed['host'] !== $_SERVER['SERVER_NAME'] ) {
|
||||
if ( ! empty( $parsed['host'] )
|
||||
&& ! in_array( $parsed['host'], $unique_hosts, true ) && $parsed['host'] !== $_SERVER['SERVER_NAME']
|
||||
) {
|
||||
$unique_hosts[] = $parsed['host'];
|
||||
}
|
||||
}
|
||||
@@ -3371,7 +3374,7 @@ function wp_default_editor() {
|
||||
$r = user_can_richedit() ? 'tinymce' : 'html'; // Defaults.
|
||||
if ( wp_get_current_user() ) { // Look for cookie.
|
||||
$ed = get_user_setting( 'editor', 'tinymce' );
|
||||
$r = ( in_array( $ed, array( 'tinymce', 'html', 'test' ) ) ) ? $ed : $r;
|
||||
$r = ( in_array( $ed, array( 'tinymce', 'html', 'test' ), true ) ) ? $ed : $r;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -459,7 +459,7 @@ function is_allowed_http_origin( $origin = null ) {
|
||||
$origin = get_http_origin();
|
||||
}
|
||||
|
||||
if ( $origin && ! in_array( $origin, get_allowed_http_origins() ) ) {
|
||||
if ( $origin && ! in_array( $origin, get_allowed_http_origins(), true ) ) {
|
||||
$origin = '';
|
||||
}
|
||||
|
||||
|
||||
@@ -793,7 +793,7 @@ function wp_kses_one_attr( $string, $element ) {
|
||||
$value = esc_attr( $value );
|
||||
|
||||
// Sanitize URI values.
|
||||
if ( in_array( strtolower( $name ), $uris ) ) {
|
||||
if ( in_array( strtolower( $name ), $uris, true ) ) {
|
||||
$value = wp_kses_bad_protocol( $value, $allowed_protocols );
|
||||
}
|
||||
|
||||
@@ -1285,7 +1285,7 @@ function wp_kses_hair( $attr, $allowed_protocols ) {
|
||||
if ( preg_match( '%^"([^"]*)"(\s+|/?$)%', $attr, $match ) ) {
|
||||
// "value"
|
||||
$thisval = $match[1];
|
||||
if ( in_array( strtolower( $attrname ), $uris ) ) {
|
||||
if ( in_array( strtolower( $attrname ), $uris, true ) ) {
|
||||
$thisval = wp_kses_bad_protocol( $thisval, $allowed_protocols );
|
||||
}
|
||||
|
||||
@@ -1306,7 +1306,7 @@ function wp_kses_hair( $attr, $allowed_protocols ) {
|
||||
if ( preg_match( "%^'([^']*)'(\s+|/?$)%", $attr, $match ) ) {
|
||||
// 'value'
|
||||
$thisval = $match[1];
|
||||
if ( in_array( strtolower( $attrname ), $uris ) ) {
|
||||
if ( in_array( strtolower( $attrname ), $uris, true ) ) {
|
||||
$thisval = wp_kses_bad_protocol( $thisval, $allowed_protocols );
|
||||
}
|
||||
|
||||
@@ -1327,7 +1327,7 @@ function wp_kses_hair( $attr, $allowed_protocols ) {
|
||||
if ( preg_match( "%^([^\s\"']+)(\s+|/?$)%", $attr, $match ) ) {
|
||||
// value
|
||||
$thisval = $match[1];
|
||||
if ( in_array( strtolower( $attrname ), $uris ) ) {
|
||||
if ( in_array( strtolower( $attrname ), $uris, true ) ) {
|
||||
$thisval = wp_kses_bad_protocol( $thisval, $allowed_protocols );
|
||||
}
|
||||
|
||||
@@ -1782,7 +1782,7 @@ function wp_kses_named_entities( $matches ) {
|
||||
}
|
||||
|
||||
$i = $matches[1];
|
||||
return ( ! in_array( $i, $allowedentitynames ) ) ? "&$i;" : "&$i;";
|
||||
return ( ! in_array( $i, $allowedentitynames, true ) ) ? "&$i;" : "&$i;";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1208,12 +1208,12 @@ function _get_path_to_translation_from_lang_dir( $domain ) {
|
||||
$mofile = "{$domain}-{$locale}.mo";
|
||||
|
||||
$path = WP_LANG_DIR . '/plugins/' . $mofile;
|
||||
if ( in_array( $path, $cached_mofiles ) ) {
|
||||
if ( in_array( $path, $cached_mofiles, true ) ) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
$path = WP_LANG_DIR . '/themes/' . $mofile;
|
||||
if ( in_array( $path, $cached_mofiles ) ) {
|
||||
if ( in_array( $path, $cached_mofiles, true ) ) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
@@ -1366,7 +1366,7 @@ function wp_get_installed_translations( $type ) {
|
||||
if ( ! preg_match( '/(?:(.+)-)?([a-z]{2,3}(?:_[A-Z]{2})?(?:_[a-z0-9]+)?).po/', $file, $match ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( ! in_array( substr( $file, 0, -3 ) . '.mo', $files ) ) {
|
||||
if ( ! in_array( substr( $file, 0, -3 ) . '.mo', $files, true ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ function get_permalink( $post = 0, $leavename = false ) {
|
||||
return get_page_link( $post, $leavename, $sample );
|
||||
} elseif ( 'attachment' === $post->post_type ) {
|
||||
return get_attachment_link( $post, $leavename );
|
||||
} elseif ( in_array( $post->post_type, get_post_types( array( '_builtin' => false ) ) ) ) {
|
||||
} elseif ( in_array( $post->post_type, get_post_types( array( '_builtin' => false ) ), true ) ) {
|
||||
return get_post_permalink( $post, $leavename, $sample );
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ function get_permalink( $post = 0, $leavename = false ) {
|
||||
*/
|
||||
$permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename );
|
||||
|
||||
if ( '' != $permalink && ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ) ) ) {
|
||||
if ( '' != $permalink && ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ), true ) ) {
|
||||
|
||||
$category = '';
|
||||
if ( strpos( $permalink, '%category%' ) !== false ) {
|
||||
@@ -275,7 +275,7 @@ function get_post_permalink( $id = 0, $leavename = false, $sample = false ) {
|
||||
|
||||
$slug = $post->post_name;
|
||||
|
||||
$draft_or_pending = get_post_status( $post ) && in_array( get_post_status( $post ), array( 'draft', 'pending', 'auto-draft', 'future' ) );
|
||||
$draft_or_pending = get_post_status( $post ) && in_array( get_post_status( $post ), array( 'draft', 'pending', 'auto-draft', 'future' ), true );
|
||||
|
||||
$post_type = get_post_type_object( $post->post_type );
|
||||
|
||||
@@ -371,7 +371,7 @@ function _get_page_link( $post = false, $leavename = false, $sample = false ) {
|
||||
|
||||
$post = get_post( $post );
|
||||
|
||||
$draft_or_pending = in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) );
|
||||
$draft_or_pending = in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ), true );
|
||||
|
||||
$link = $wp_rewrite->get_page_permastruct();
|
||||
|
||||
@@ -417,7 +417,7 @@ function get_attachment_link( $post = null, $leavename = false ) {
|
||||
|
||||
$post = get_post( $post );
|
||||
$parent = ( $post->post_parent > 0 && $post->post_parent != $post->ID ) ? get_post( $post->post_parent ) : false;
|
||||
if ( $parent && ! in_array( $parent->post_type, get_post_types() ) ) {
|
||||
if ( $parent && ! in_array( $parent->post_type, get_post_types(), true ) ) {
|
||||
$parent = false;
|
||||
}
|
||||
|
||||
@@ -3182,7 +3182,7 @@ function get_home_url( $blog_id = null, $path = '', $scheme = null ) {
|
||||
restore_current_blog();
|
||||
}
|
||||
|
||||
if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) {
|
||||
if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ), true ) ) {
|
||||
if ( is_ssl() && ! is_admin() && 'wp-login.php' !== $pagenow ) {
|
||||
$scheme = 'https';
|
||||
} else {
|
||||
@@ -3497,7 +3497,7 @@ function network_home_url( $path = '', $scheme = null ) {
|
||||
$current_network = get_network();
|
||||
$orig_scheme = $scheme;
|
||||
|
||||
if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) {
|
||||
if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ), true ) ) {
|
||||
$scheme = is_ssl() && ! is_admin() ? 'https' : 'http';
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
function wp_get_server_protocol() {
|
||||
$protocol = isset( $_SERVER['SERVER_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';
|
||||
}
|
||||
return $protocol;
|
||||
@@ -40,7 +40,7 @@ function wp_unregister_GLOBALS() { // phpcs:ignore WordPress.NamingConventions.
|
||||
|
||||
$input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() );
|
||||
foreach ( $input as $k => $v ) {
|
||||
if ( ! in_array( $k, $no_unset ) && isset( $GLOBALS[ $k ] ) ) {
|
||||
if ( ! in_array( $k, $no_unset, true ) && isset( $GLOBALS[ $k ] ) ) {
|
||||
unset( $GLOBALS[ $k ] );
|
||||
}
|
||||
}
|
||||
@@ -683,7 +683,7 @@ function wp_get_active_and_valid_plugins() {
|
||||
&& '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'.
|
||||
&& file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist.
|
||||
// Not already included as a network plugin.
|
||||
&& ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) )
|
||||
&& ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins, true ) )
|
||||
) {
|
||||
$plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
|
||||
}
|
||||
|
||||
@@ -703,7 +703,9 @@ function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) {
|
||||
_deprecated_argument( __FUNCTION__, '3.1.0' );
|
||||
}
|
||||
|
||||
if ( ! in_array( $pref, array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ) ) ) {
|
||||
$pref_whitelist = array( 'site_id', 'domain', 'path', 'registered', 'last_updated', 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' );
|
||||
|
||||
if ( ! in_array( $pref, $pref_whitelist, true ) ) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
@@ -488,7 +488,7 @@ function wpmu_validate_user_signup( $user_name, $user_email ) {
|
||||
$illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' );
|
||||
add_site_option( 'illegal_names', $illegal_names );
|
||||
}
|
||||
if ( in_array( $user_name, $illegal_names ) ) {
|
||||
if ( in_array( $user_name, $illegal_names, true ) ) {
|
||||
$errors->add( 'user_name', __( 'Sorry, that username is not allowed.' ) );
|
||||
}
|
||||
|
||||
@@ -653,7 +653,7 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
|
||||
$errors->add( 'blogname', __( 'Site names can only contain lowercase letters (a-z) and numbers.' ) );
|
||||
}
|
||||
|
||||
if ( in_array( $blogname, $illegal_names ) ) {
|
||||
if ( in_array( $blogname, $illegal_names, true ) ) {
|
||||
$errors->add( 'blogname', __( 'That name is not allowed.' ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -174,7 +174,8 @@ function wp_nav_menu( $args = array() ) {
|
||||
* Default is array containing 'div' and 'nav'.
|
||||
*/
|
||||
$allowed_tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) );
|
||||
if ( is_string( $args->container ) && in_array( $args->container, $allowed_tags ) ) {
|
||||
|
||||
if ( is_string( $args->container ) && in_array( $args->container, $allowed_tags, true ) ) {
|
||||
$show_container = true;
|
||||
$class = $args->container_class ? ' class="' . esc_attr( $args->container_class ) . '"' : ' class="menu-' . $menu->slug . '-container"';
|
||||
$id = $args->container_id ? ' id="' . esc_attr( $args->container_id ) . '"' : '';
|
||||
@@ -223,7 +224,8 @@ function wp_nav_menu( $args = array() ) {
|
||||
$wrap_id = $args->menu_id;
|
||||
} else {
|
||||
$wrap_id = 'menu-' . $menu->slug;
|
||||
while ( in_array( $wrap_id, $menu_id_slugs ) ) {
|
||||
|
||||
while ( in_array( $wrap_id, $menu_id_slugs, true ) ) {
|
||||
if ( preg_match( '#-(\d+)$#', $wrap_id, $matches ) ) {
|
||||
$wrap_id = preg_replace( '#-(\d+)$#', '-' . ++$matches[1], $wrap_id );
|
||||
} else {
|
||||
@@ -397,11 +399,12 @@ function _wp_menu_item_classes_by_context( &$menu_items ) {
|
||||
|
||||
// If the menu item corresponds to the currently queried post or taxonomy object.
|
||||
} elseif (
|
||||
$menu_item->object_id == $queried_object_id &&
|
||||
(
|
||||
( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && $wp_query->is_home && $home_page_id == $menu_item->object_id ) ||
|
||||
( 'post_type' == $menu_item->type && $wp_query->is_singular ) ||
|
||||
( 'taxonomy' == $menu_item->type && ( $wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax ) && $queried_object->taxonomy == $menu_item->object )
|
||||
$menu_item->object_id == $queried_object_id
|
||||
&& (
|
||||
( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && $wp_query->is_home && $home_page_id == $menu_item->object_id )
|
||||
|| ( 'post_type' == $menu_item->type && $wp_query->is_singular )
|
||||
|| ( 'taxonomy' == $menu_item->type
|
||||
&& ( $wp_query->is_category || $wp_query->is_tag || $wp_query->is_tax ) && $queried_object->taxonomy == $menu_item->object )
|
||||
)
|
||||
) {
|
||||
$classes[] = 'current-menu-item';
|
||||
@@ -409,8 +412,8 @@ function _wp_menu_item_classes_by_context( &$menu_items ) {
|
||||
$_anc_id = (int) $menu_item->db_id;
|
||||
|
||||
while (
|
||||
( $_anc_id = get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) &&
|
||||
! in_array( $_anc_id, $active_ancestor_item_ids )
|
||||
( $_anc_id = (int) get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) )
|
||||
&& ! in_array( $_anc_id, $active_ancestor_item_ids, true )
|
||||
) {
|
||||
$active_ancestor_item_ids[] = $_anc_id;
|
||||
}
|
||||
@@ -428,16 +431,16 @@ function _wp_menu_item_classes_by_context( &$menu_items ) {
|
||||
|
||||
// If the menu item corresponds to the currently queried post type archive.
|
||||
} elseif (
|
||||
'post_type_archive' == $menu_item->type &&
|
||||
is_post_type_archive( array( $menu_item->object ) )
|
||||
'post_type_archive' == $menu_item->type
|
||||
&& is_post_type_archive( array( $menu_item->object ) )
|
||||
) {
|
||||
$classes[] = 'current-menu-item';
|
||||
$menu_items[ $key ]->current = true;
|
||||
$_anc_id = (int) $menu_item->db_id;
|
||||
|
||||
while (
|
||||
( $_anc_id = get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) &&
|
||||
! in_array( $_anc_id, $active_ancestor_item_ids )
|
||||
( $_anc_id = (int) get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) )
|
||||
&& ! in_array( $_anc_id, $active_ancestor_item_ids, true )
|
||||
) {
|
||||
$active_ancestor_item_ids[] = $_anc_id;
|
||||
}
|
||||
@@ -467,19 +470,19 @@ function _wp_menu_item_classes_by_context( &$menu_items ) {
|
||||
urldecode( $_root_relative_current ),
|
||||
);
|
||||
|
||||
if ( $raw_item_url && in_array( $item_url, $matches ) ) {
|
||||
if ( $raw_item_url && in_array( $item_url, $matches, true ) ) {
|
||||
$classes[] = 'current-menu-item';
|
||||
$menu_items[ $key ]->current = true;
|
||||
$_anc_id = (int) $menu_item->db_id;
|
||||
|
||||
while (
|
||||
( $_anc_id = get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) ) &&
|
||||
! in_array( $_anc_id, $active_ancestor_item_ids )
|
||||
( $_anc_id = (int) get_post_meta( $_anc_id, '_menu_item_menu_item_parent', true ) )
|
||||
&& ! in_array( $_anc_id, $active_ancestor_item_ids, true )
|
||||
) {
|
||||
$active_ancestor_item_ids[] = $_anc_id;
|
||||
}
|
||||
|
||||
if ( in_array( home_url(), array( untrailingslashit( $current_url ), untrailingslashit( $_indexless_current ) ) ) ) {
|
||||
if ( in_array( home_url(), array( untrailingslashit( $current_url ), untrailingslashit( $_indexless_current ) ), true ) ) {
|
||||
// Back compat for home link to match wp_page_menu().
|
||||
$classes[] = 'current_page_item';
|
||||
}
|
||||
@@ -515,50 +518,56 @@ function _wp_menu_item_classes_by_context( &$menu_items ) {
|
||||
$menu_items[ $key ]->current_item_parent = false;
|
||||
|
||||
if (
|
||||
isset( $parent_item->type ) &&
|
||||
(
|
||||
isset( $parent_item->type )
|
||||
&& (
|
||||
// Ancestral post object.
|
||||
(
|
||||
'post_type' == $parent_item->type &&
|
||||
! empty( $queried_object->post_type ) &&
|
||||
is_post_type_hierarchical( $queried_object->post_type ) &&
|
||||
in_array( $parent_item->object_id, $queried_object->ancestors ) &&
|
||||
$parent_item->object != $queried_object->ID
|
||||
'post_type' == $parent_item->type
|
||||
&& ! empty( $queried_object->post_type )
|
||||
&& is_post_type_hierarchical( $queried_object->post_type )
|
||||
&& in_array( $parent_item->object_id, $queried_object->ancestors )
|
||||
&& $parent_item->object != $queried_object->ID
|
||||
) ||
|
||||
|
||||
// Ancestral term.
|
||||
(
|
||||
'taxonomy' == $parent_item->type &&
|
||||
isset( $possible_taxonomy_ancestors[ $parent_item->object ] ) &&
|
||||
in_array( $parent_item->object_id, $possible_taxonomy_ancestors[ $parent_item->object ] ) &&
|
||||
(
|
||||
'taxonomy' == $parent_item->type
|
||||
&& isset( $possible_taxonomy_ancestors[ $parent_item->object ] )
|
||||
&& in_array( $parent_item->object_id, $possible_taxonomy_ancestors[ $parent_item->object ] )
|
||||
&& (
|
||||
! isset( $queried_object->term_id ) ||
|
||||
$parent_item->object_id != $queried_object->term_id
|
||||
)
|
||||
)
|
||||
)
|
||||
) {
|
||||
$classes[] = empty( $queried_object->taxonomy ) ? 'current-' . $queried_object->post_type . '-ancestor' : 'current-' . $queried_object->taxonomy . '-ancestor';
|
||||
if ( ! empty( $queried_object->taxonomy ) ) {
|
||||
$classes[] = 'current-' . $queried_object->taxonomy . '-ancestor';
|
||||
} else {
|
||||
$classes[] = 'current-' . $queried_object->post_type . '-ancestor';
|
||||
}
|
||||
}
|
||||
|
||||
if ( in_array( intval( $parent_item->db_id ), $active_ancestor_item_ids ) ) {
|
||||
$classes[] = 'current-menu-ancestor';
|
||||
if ( in_array( (int) $parent_item->db_id, $active_ancestor_item_ids, true ) ) {
|
||||
$classes[] = 'current-menu-ancestor';
|
||||
|
||||
$menu_items[ $key ]->current_item_ancestor = true;
|
||||
}
|
||||
if ( in_array( $parent_item->db_id, $active_parent_item_ids ) ) {
|
||||
$classes[] = 'current-menu-parent';
|
||||
if ( in_array( (int) $parent_item->db_id, $active_parent_item_ids, true ) ) {
|
||||
$classes[] = 'current-menu-parent';
|
||||
|
||||
$menu_items[ $key ]->current_item_parent = true;
|
||||
}
|
||||
if ( in_array( $parent_item->object_id, $active_parent_object_ids ) ) {
|
||||
if ( in_array( (int) $parent_item->object_id, $active_parent_object_ids, true ) ) {
|
||||
$classes[] = 'current-' . $active_object . '-parent';
|
||||
}
|
||||
|
||||
if ( 'post_type' == $parent_item->type && 'page' == $parent_item->object ) {
|
||||
// Back compat classes for pages to match wp_page_menu().
|
||||
if ( in_array( 'current-menu-parent', $classes ) ) {
|
||||
if ( in_array( 'current-menu-parent', $classes, true ) ) {
|
||||
$classes[] = 'current_page_parent';
|
||||
}
|
||||
if ( in_array( 'current-menu-ancestor', $classes ) ) {
|
||||
if ( in_array( 'current-menu-ancestor', $classes, true ) ) {
|
||||
$classes[] = 'current_page_ancestor';
|
||||
}
|
||||
}
|
||||
@@ -597,9 +606,12 @@ function walk_nav_menu_tree( $items, $depth, $r ) {
|
||||
*/
|
||||
function _nav_menu_item_id_use_once( $id, $item ) {
|
||||
static $_used_ids = array();
|
||||
if ( in_array( $item->ID, $_used_ids ) ) {
|
||||
|
||||
if ( in_array( $item->ID, $_used_ids, true ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$_used_ids[] = $item->ID;
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ function get_option( $option, $default = false ) {
|
||||
return get_option( 'siteurl' );
|
||||
}
|
||||
|
||||
if ( in_array( $option, array( 'siteurl', 'home', 'category_base', 'tag_base' ) ) ) {
|
||||
if ( in_array( $option, array( 'siteurl', 'home', 'category_base', 'tag_base' ), true ) ) {
|
||||
$value = untrailingslashit( $value );
|
||||
}
|
||||
|
||||
@@ -1772,7 +1772,7 @@ function get_site_transient( $transient ) {
|
||||
// Core transients that do not have a timeout. Listed here so querying timeouts can be avoided.
|
||||
$no_timeout = array( 'update_core', 'update_plugins', 'update_themes' );
|
||||
$transient_option = '_site_transient_' . $transient;
|
||||
if ( ! in_array( $transient, $no_timeout ) ) {
|
||||
if ( ! in_array( $transient, $no_timeout, true ) ) {
|
||||
$transient_timeout = '_site_transient_timeout_' . $transient;
|
||||
$timeout = get_site_option( $transient_timeout );
|
||||
if ( false !== $timeout && $timeout < time() ) {
|
||||
@@ -2232,7 +2232,7 @@ function unregister_setting( $option_group, $option_name, $deprecated = '' ) {
|
||||
$option_group = 'reading';
|
||||
}
|
||||
|
||||
$pos = array_search( $option_name, (array) $new_whitelist_options[ $option_group ] );
|
||||
$pos = array_search( $option_name, (array) $new_whitelist_options[ $option_group ], true );
|
||||
if ( false !== $pos ) {
|
||||
unset( $new_whitelist_options[ $option_group ][ $pos ] );
|
||||
}
|
||||
|
||||
@@ -454,7 +454,7 @@ if ( ! function_exists( 'wp_mail' ) ) :
|
||||
if ( ! empty( $headers ) ) {
|
||||
foreach ( (array) $headers as $name => $content ) {
|
||||
// Only add custom headers not added automatically by PHPMailer.
|
||||
if ( ! in_array( $name, array( 'MIME-Version', 'X-Mailer' ) ) ) {
|
||||
if ( ! in_array( $name, array( 'MIME-Version', 'X-Mailer' ), true ) ) {
|
||||
$phpmailer->addCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
|
||||
}
|
||||
}
|
||||
@@ -546,7 +546,7 @@ if ( ! function_exists( 'wp_authenticate' ) ) :
|
||||
|
||||
$ignore_codes = array( 'empty_username', 'empty_password' );
|
||||
|
||||
if ( is_wp_error( $user ) && ! in_array( $user->get_error_code(), $ignore_codes ) ) {
|
||||
if ( is_wp_error( $user ) && ! in_array( $user->get_error_code(), $ignore_codes, true ) ) {
|
||||
$error = $user;
|
||||
|
||||
/**
|
||||
@@ -1465,7 +1465,7 @@ if ( ! function_exists( 'wp_validate_redirect' ) ) :
|
||||
*/
|
||||
$allowed_hosts = (array) apply_filters( 'allowed_redirect_hosts', array( $wpp['host'] ), isset( $lp['host'] ) ? $lp['host'] : '' );
|
||||
|
||||
if ( isset( $lp['host'] ) && ( ! in_array( $lp['host'], $allowed_hosts ) && strtolower( $wpp['host'] ) !== $lp['host'] ) ) {
|
||||
if ( isset( $lp['host'] ) && ( ! in_array( $lp['host'], $allowed_hosts, true ) && strtolower( $wpp['host'] ) !== $lp['host'] ) ) {
|
||||
$location = $default;
|
||||
}
|
||||
|
||||
@@ -2271,7 +2271,7 @@ if ( ! function_exists( 'wp_salt' ) ) :
|
||||
$values['salt'] = SECRET_SALT;
|
||||
}
|
||||
|
||||
if ( in_array( $scheme, array( 'auth', 'secure_auth', 'logged_in', 'nonce' ) ) ) {
|
||||
if ( in_array( $scheme, array( 'auth', 'secure_auth', 'logged_in', 'nonce' ), true ) ) {
|
||||
foreach ( array( 'key', 'salt' ) as $type ) {
|
||||
$const = strtoupper( "{$scheme}_{$type}" );
|
||||
if ( defined( $const ) && constant( $const ) && empty( $duplicated_keys[ constant( $const ) ] ) ) {
|
||||
|
||||
@@ -364,7 +364,7 @@ function doing_filter( $filter = null ) {
|
||||
return ! empty( $wp_current_filter );
|
||||
}
|
||||
|
||||
return in_array( $filter, $wp_current_filter );
|
||||
return in_array( $filter, $wp_current_filter, true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -75,7 +75,7 @@ function set_post_format( $post, $format ) {
|
||||
|
||||
if ( ! empty( $format ) ) {
|
||||
$format = sanitize_key( $format );
|
||||
if ( 'standard' === $format || ! in_array( $format, get_post_format_slugs() ) ) {
|
||||
if ( 'standard' === $format || ! in_array( $format, get_post_format_slugs(), true ) ) {
|
||||
$format = '';
|
||||
} else {
|
||||
$format = 'post-format-' . $format;
|
||||
@@ -231,7 +231,7 @@ function _post_format_get_term( $term ) {
|
||||
* @return array
|
||||
*/
|
||||
function _post_format_get_terms( $terms, $taxonomies, $args ) {
|
||||
if ( in_array( 'post_format', (array) $taxonomies ) ) {
|
||||
if ( in_array( 'post_format', (array) $taxonomies, true ) ) {
|
||||
if ( isset( $args['fields'] ) && 'names' == $args['fields'] ) {
|
||||
foreach ( $terms as $order => $name ) {
|
||||
$terms[ $order ] = get_post_format_string( str_replace( 'post-format-', '', $name ) );
|
||||
|
||||
@@ -1032,7 +1032,7 @@ function _wp_link_page( $i ) {
|
||||
if ( 1 == $i ) {
|
||||
$url = get_permalink();
|
||||
} else {
|
||||
if ( '' == get_option( 'permalink_structure' ) || in_array( $post->post_status, array( 'draft', 'pending' ) ) ) {
|
||||
if ( '' == get_option( 'permalink_structure' ) || in_array( $post->post_status, array( 'draft', 'pending' ), true ) ) {
|
||||
$url = add_query_arg( 'page', $i, get_permalink() );
|
||||
} elseif ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID ) {
|
||||
$url = trailingslashit( get_permalink() ) . user_trailingslashit( "$wp_rewrite->pagination_base/" . $i, 'single_paged' );
|
||||
@@ -1395,7 +1395,7 @@ function wp_page_menu( $args = array() ) {
|
||||
);
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
if ( ! in_array( $args['item_spacing'], array( 'preserve', 'discard' ) ) ) {
|
||||
if ( ! in_array( $args['item_spacing'], array( 'preserve', 'discard' ), true ) ) {
|
||||
// Invalid value, fall back to default.
|
||||
$args['item_spacing'] = $defaults['item_spacing'];
|
||||
}
|
||||
@@ -1811,7 +1811,7 @@ function wp_post_revision_title( $revision, $link = true ) {
|
||||
return $revision;
|
||||
}
|
||||
|
||||
if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) ) {
|
||||
if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ), true ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1852,7 +1852,7 @@ function wp_post_revision_title_expanded( $revision, $link = true ) {
|
||||
return $revision;
|
||||
}
|
||||
|
||||
if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) ) {
|
||||
if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ), true ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -815,7 +815,7 @@ function get_post_ancestors( $post ) {
|
||||
|
||||
while ( $ancestor = get_post( $id ) ) {
|
||||
// Loop detection: If the ancestor has been seen before, break.
|
||||
if ( empty( $ancestor->post_parent ) || ( $ancestor->post_parent == $post->ID ) || in_array( $ancestor->post_parent, $ancestors ) ) {
|
||||
if ( empty( $ancestor->post_parent ) || ( $ancestor->post_parent == $post->ID ) || in_array( $ancestor->post_parent, $ancestors, true ) ) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1616,7 +1616,7 @@ function _post_type_meta_capabilities( $capabilities = null ) {
|
||||
global $post_type_meta_caps;
|
||||
|
||||
foreach ( $capabilities as $core => $custom ) {
|
||||
if ( in_array( $core, array( 'read_post', 'delete_post', 'edit_post' ) ) ) {
|
||||
if ( in_array( $core, array( 'read_post', 'delete_post', 'edit_post' ), true ) ) {
|
||||
$post_type_meta_caps[ $custom ] = $core;
|
||||
}
|
||||
}
|
||||
@@ -2362,13 +2362,13 @@ function sanitize_post( $post, $context = 'display' ) {
|
||||
*/
|
||||
function sanitize_post_field( $field, $value, $post_id, $context = 'display' ) {
|
||||
$int_fields = array( 'ID', 'post_parent', 'menu_order' );
|
||||
if ( in_array( $field, $int_fields ) ) {
|
||||
if ( in_array( $field, $int_fields, true ) ) {
|
||||
$value = (int) $value;
|
||||
}
|
||||
|
||||
// Fields which contain arrays of integers.
|
||||
$array_int_fields = array( 'ancestors' );
|
||||
if ( in_array( $field, $array_int_fields ) ) {
|
||||
if ( in_array( $field, $array_int_fields, true ) ) {
|
||||
$value = array_map( 'absint', $value );
|
||||
return $value;
|
||||
}
|
||||
@@ -2417,7 +2417,7 @@ function sanitize_post_field( $field, $value, $post_id, $context = 'display' ) {
|
||||
$value = apply_filters( "edit_post_{$field}", $value, $post_id );
|
||||
}
|
||||
|
||||
if ( in_array( $field, $format_to_edit ) ) {
|
||||
if ( in_array( $field, $format_to_edit, true ) ) {
|
||||
if ( 'post_content' == $field ) {
|
||||
$value = format_to_edit( $value, user_can_richedit() );
|
||||
} else {
|
||||
@@ -2778,7 +2778,7 @@ function get_post_mime_types() {
|
||||
$mime_types = wp_get_mime_types();
|
||||
|
||||
foreach ( $post_mime_types as $group => $labels ) {
|
||||
if ( in_array( $group, array( 'image', 'audio', 'video' ) ) ) {
|
||||
if ( in_array( $group, array( 'image', 'audio', 'video' ), true ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2904,7 +2904,7 @@ function wp_post_mime_type_where( $post_mime_types, $table_alias = '' ) {
|
||||
|
||||
$mime_pattern = preg_replace( '/\*+/', '%', $mime_pattern );
|
||||
|
||||
if ( in_array( $mime_type, $wildcards ) ) {
|
||||
if ( in_array( $mime_type, $wildcards, true ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -3697,7 +3697,7 @@ function wp_insert_post( $postarr, $wp_error = false ) {
|
||||
* an empty post name.
|
||||
*/
|
||||
if ( empty( $post_name ) ) {
|
||||
if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) ) {
|
||||
if ( ! in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ), true ) ) {
|
||||
$post_name = sanitize_title( $post_title );
|
||||
} else {
|
||||
$post_name = '';
|
||||
@@ -3946,7 +3946,7 @@ function wp_insert_post( $postarr, $wp_error = false ) {
|
||||
$where = array( 'ID' => $post_ID );
|
||||
}
|
||||
|
||||
if ( empty( $data['post_name'] ) && ! in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) {
|
||||
if ( empty( $data['post_name'] ) && ! in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ), true ) ) {
|
||||
$data['post_name'] = wp_unique_post_slug( sanitize_title( $data['post_title'], $post_ID ), $post_ID, $data['post_status'], $post_type, $post_parent );
|
||||
$wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where );
|
||||
clean_post_cache( $post_ID );
|
||||
@@ -4199,8 +4199,10 @@ function wp_update_post( $postarr = array(), $wp_error = false ) {
|
||||
}
|
||||
|
||||
// Drafts shouldn't be assigned a date unless explicitly done so by the user.
|
||||
if ( isset( $post['post_status'] ) && in_array( $post['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) && empty( $postarr['edit_date'] ) &&
|
||||
( '0000-00-00 00:00:00' == $post['post_date_gmt'] ) ) {
|
||||
if ( isset( $post['post_status'] )
|
||||
&& in_array( $post['post_status'], array( 'draft', 'pending', 'auto-draft' ), true )
|
||||
&& empty( $postarr['edit_date'] ) && ( '0000-00-00 00:00:00' == $post['post_date_gmt'] )
|
||||
) {
|
||||
$clear_date = true;
|
||||
} else {
|
||||
$clear_date = false;
|
||||
@@ -4330,7 +4332,9 @@ function check_and_publish_future_post( $post_id ) {
|
||||
* @return string Unique slug for the post, based on $post_name (with a -1, -2, etc. suffix)
|
||||
*/
|
||||
function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_parent ) {
|
||||
if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) || ( 'inherit' == $post_status && 'revision' == $post_type ) || 'user_request' === $post_type ) {
|
||||
if ( in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ), true )
|
||||
|| ( 'inherit' == $post_status && 'revision' == $post_type ) || 'user_request' === $post_type
|
||||
) {
|
||||
return $slug;
|
||||
}
|
||||
|
||||
@@ -4376,7 +4380,12 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
|
||||
* @param bool $bad_slug Whether the slug would be bad as an attachment slug.
|
||||
* @param string $slug The post slug.
|
||||
*/
|
||||
if ( $post_name_check || in_array( $slug, $feeds ) || 'embed' === $slug || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) ) {
|
||||
$is_bad_attachment_slug = apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug );
|
||||
|
||||
if ( $post_name_check
|
||||
|| in_array( $slug, $feeds, true ) || 'embed' === $slug
|
||||
|| $is_bad_attachment_slug
|
||||
) {
|
||||
$suffix = 2;
|
||||
do {
|
||||
$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
|
||||
@@ -4407,7 +4416,13 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
|
||||
* @param string $post_type Post type.
|
||||
* @param int $post_parent Post parent ID.
|
||||
*/
|
||||
if ( $post_name_check || in_array( $slug, $feeds ) || 'embed' === $slug || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug ) || apply_filters( 'wp_unique_post_slug_is_bad_hierarchical_slug', false, $slug, $post_type, $post_parent ) ) {
|
||||
$is_bad_hierarchical_slug = apply_filters( 'wp_unique_post_slug_is_bad_hierarchical_slug', false, $slug, $post_type, $post_parent );
|
||||
|
||||
if ( $post_name_check
|
||||
|| in_array( $slug, $feeds, true ) || 'embed' === $slug
|
||||
|| preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug )
|
||||
|| $is_bad_hierarchical_slug
|
||||
) {
|
||||
$suffix = 2;
|
||||
do {
|
||||
$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
|
||||
@@ -4456,7 +4471,13 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
|
||||
* @param string $slug The post slug.
|
||||
* @param string $post_type Post type.
|
||||
*/
|
||||
if ( $post_name_check || in_array( $slug, $feeds ) || 'embed' === $slug || $conflicts_with_date_archive || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) {
|
||||
$is_bad_flat_slug = apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type );
|
||||
|
||||
if ( $post_name_check
|
||||
|| in_array( $slug, $feeds, true ) || 'embed' === $slug
|
||||
|| $conflicts_with_date_archive
|
||||
|| $is_bad_flat_slug
|
||||
) {
|
||||
$suffix = 2;
|
||||
do {
|
||||
$alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
|
||||
@@ -5265,7 +5286,7 @@ function get_pages( $args = array() ) {
|
||||
|
||||
// Make sure the post type is hierarchical.
|
||||
$hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) );
|
||||
if ( ! in_array( $parsed_args['post_type'], $hierarchical_post_types ) ) {
|
||||
if ( ! in_array( $parsed_args['post_type'], $hierarchical_post_types, true ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -5403,7 +5424,7 @@ function get_pages( $args = array() ) {
|
||||
|
||||
foreach ( explode( ',', $parsed_args['sort_column'] ) as $orderby ) {
|
||||
$orderby = trim( $orderby );
|
||||
if ( ! in_array( $orderby, $allowed_keys ) ) {
|
||||
if ( ! in_array( $orderby, $allowed_keys, true ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -5433,7 +5454,7 @@ function get_pages( $args = array() ) {
|
||||
$sort_column = ! empty( $orderby_array ) ? implode( ',', $orderby_array ) : "$wpdb->posts.post_title";
|
||||
|
||||
$sort_order = strtoupper( $parsed_args['sort_order'] );
|
||||
if ( '' !== $sort_order && ! in_array( $sort_order, array( 'ASC', 'DESC' ) ) ) {
|
||||
if ( '' !== $sort_order && ! in_array( $sort_order, array( 'ASC', 'DESC' ), true ) ) {
|
||||
$sort_order = 'ASC';
|
||||
}
|
||||
|
||||
@@ -6069,13 +6090,13 @@ function wp_attachment_is( $type, $post = null ) {
|
||||
switch ( $type ) {
|
||||
case 'image':
|
||||
$image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' );
|
||||
return in_array( $ext, $image_exts );
|
||||
return in_array( $ext, $image_exts, true );
|
||||
|
||||
case 'audio':
|
||||
return in_array( $ext, wp_get_audio_extensions() );
|
||||
return in_array( $ext, wp_get_audio_extensions(), true );
|
||||
|
||||
case 'video':
|
||||
return in_array( $ext, wp_get_video_extensions() );
|
||||
return in_array( $ext, wp_get_video_extensions(), true );
|
||||
|
||||
default:
|
||||
return $type === $ext;
|
||||
@@ -6179,7 +6200,9 @@ function wp_mime_type_icon( $mime = 0 ) {
|
||||
if ( substr( $file, 0, 1 ) == '.' ) {
|
||||
continue;
|
||||
}
|
||||
if ( ! in_array( strtolower( substr( $file, -4 ) ), array( '.png', '.gif', '.jpg' ) ) ) {
|
||||
|
||||
$ext = strtolower( substr( $file, -4 ) );
|
||||
if ( ! in_array( $ext, array( '.png', '.gif', '.jpg' ), true ) ) {
|
||||
if ( is_dir( "$dir/$file" ) ) {
|
||||
$dirs[ "$dir/$file" ] = "$uri/$file";
|
||||
}
|
||||
@@ -6269,12 +6292,12 @@ function wp_check_for_changed_slugs( $post_id, $post, $post_before ) {
|
||||
$old_slugs = (array) get_post_meta( $post_id, '_wp_old_slug' );
|
||||
|
||||
// If we haven't added this old slug before, add it now.
|
||||
if ( ! empty( $post_before->post_name ) && ! in_array( $post_before->post_name, $old_slugs ) ) {
|
||||
if ( ! empty( $post_before->post_name ) && ! in_array( $post_before->post_name, $old_slugs, true ) ) {
|
||||
add_post_meta( $post_id, '_wp_old_slug', $post_before->post_name );
|
||||
}
|
||||
|
||||
// If the new slug was used previously, delete it from the list.
|
||||
if ( in_array( $post->post_name, $old_slugs ) ) {
|
||||
if ( in_array( $post->post_name, $old_slugs, true ) ) {
|
||||
delete_post_meta( $post_id, '_wp_old_slug', $post->post_name );
|
||||
}
|
||||
}
|
||||
@@ -6301,21 +6324,26 @@ function wp_check_for_changed_slugs( $post_id, $post, $post_before ) {
|
||||
function wp_check_for_changed_dates( $post_id, $post, $post_before ) {
|
||||
$previous_date = gmdate( 'Y-m-d', strtotime( $post_before->post_date ) );
|
||||
$new_date = gmdate( 'Y-m-d', strtotime( $post->post_date ) );
|
||||
|
||||
// Don't bother if it hasn't changed.
|
||||
if ( $new_date == $previous_date ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We're only concerned with published, non-hierarchical objects.
|
||||
if ( ! ( 'publish' === $post->post_status || ( 'attachment' === get_post_type( $post ) && 'inherit' === $post->post_status ) ) || is_post_type_hierarchical( $post->post_type ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$old_dates = (array) get_post_meta( $post_id, '_wp_old_date' );
|
||||
|
||||
// If we haven't added this old date before, add it now.
|
||||
if ( ! empty( $previous_date ) && ! in_array( $previous_date, $old_dates ) ) {
|
||||
if ( ! empty( $previous_date ) && ! in_array( $previous_date, $old_dates, true ) ) {
|
||||
add_post_meta( $post_id, '_wp_old_date', $previous_date );
|
||||
}
|
||||
|
||||
// If the new slug was used previously, delete it from the list.
|
||||
if ( in_array( $new_date, $old_dates ) ) {
|
||||
if ( in_array( $new_date, $old_dates, true ) ) {
|
||||
delete_post_meta( $post_id, '_wp_old_date', $new_date );
|
||||
}
|
||||
}
|
||||
@@ -6524,7 +6552,7 @@ function get_lastpostmodified( $timezone = 'server', $post_type = 'any' ) {
|
||||
function _get_last_post_time( $timezone, $field, $post_type = 'any' ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( ! in_array( $field, array( 'date', 'modified' ) ) ) {
|
||||
if ( ! in_array( $field, array( 'date', 'modified' ), true ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1322,7 +1322,7 @@ function rest_validate_value_from_schema( $value, $args, $param = '' ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( in_array( $args['type'], array( 'integer', 'number' ) ) && ! is_numeric( $value ) ) {
|
||||
if ( in_array( $args['type'], array( 'integer', 'number' ), true ) && ! is_numeric( $value ) ) {
|
||||
/* translators: 1: Parameter, 2: Type name. */
|
||||
return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $param, $args['type'] ) );
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ function remove_permastruct( $name ) {
|
||||
function add_feed( $feedname, $function ) {
|
||||
global $wp_rewrite;
|
||||
|
||||
if ( ! in_array( $feedname, $wp_rewrite->feeds ) ) {
|
||||
if ( ! in_array( $feedname, $wp_rewrite->feeds, true ) ) {
|
||||
$wp_rewrite->feeds[] = $feedname;
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ function wp_resolve_numeric_slug_conflicts( $query_vars = array() ) {
|
||||
|
||||
// Identify the 'postname' position in the permastruct array.
|
||||
$permastructs = array_values( array_filter( explode( '/', get_option( 'permalink_structure' ) ) ) );
|
||||
$postname_index = array_search( '%postname%', $permastructs );
|
||||
$postname_index = array_search( '%postname%', $permastructs, true );
|
||||
|
||||
if ( false === $postname_index ) {
|
||||
return $query_vars;
|
||||
@@ -596,7 +596,7 @@ function url_to_postid( $url ) {
|
||||
parse_str( $query, $query_vars );
|
||||
$query = array();
|
||||
foreach ( (array) $query_vars as $key => $value ) {
|
||||
if ( in_array( $key, $wp->public_query_vars ) ) {
|
||||
if ( in_array( $key, $wp->public_query_vars, true ) ) {
|
||||
$query[ $key ] = $value;
|
||||
if ( isset( $post_type_query_vars[ $key ] ) ) {
|
||||
$query['post_type'] = $post_type_query_vars[ $key ];
|
||||
|
||||
@@ -620,7 +620,7 @@ function register_taxonomy_for_object_type( $taxonomy, $object_type ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! in_array( $object_type, $wp_taxonomies[ $taxonomy ]->object_type ) ) {
|
||||
if ( ! in_array( $object_type, $wp_taxonomies[ $taxonomy ]->object_type, true ) ) {
|
||||
$wp_taxonomies[ $taxonomy ]->object_type[] = $object_type;
|
||||
}
|
||||
|
||||
@@ -1526,7 +1526,7 @@ function sanitize_term( $term, $taxonomy, $context = 'display' ) {
|
||||
*/
|
||||
function sanitize_term_field( $field, $value, $term_id, $taxonomy, $context ) {
|
||||
$int_fields = array( 'parent', 'term_id', 'count', 'term_group', 'term_taxonomy_id', 'object_id' );
|
||||
if ( in_array( $field, $int_fields ) ) {
|
||||
if ( in_array( $field, $int_fields, true ) ) {
|
||||
$value = (int) $value;
|
||||
if ( $value < 0 ) {
|
||||
$value = 0;
|
||||
@@ -2236,9 +2236,12 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
|
||||
);
|
||||
|
||||
$existing_term = null;
|
||||
if ( ( ! $slug_provided || $name_match->slug === $slug ) && in_array( $name, wp_list_pluck( $siblings, 'name' ) ) ) {
|
||||
$sibling_names = wp_list_pluck( $siblings, 'name' );
|
||||
$sibling_slugs = wp_list_pluck( $siblings, 'slug' );
|
||||
|
||||
if ( ( ! $slug_provided || $name_match->slug === $slug ) && in_array( $name, $sibling_names, true ) ) {
|
||||
$existing_term = $name_match;
|
||||
} elseif ( $slug_match && in_array( $slug, wp_list_pluck( $siblings, 'slug' ) ) ) {
|
||||
} elseif ( $slug_match && in_array( $slug, $sibling_slugs, true ) ) {
|
||||
$existing_term = $slug_match;
|
||||
}
|
||||
|
||||
@@ -3700,7 +3703,7 @@ function _update_post_term_count( $terms, $taxonomy ) {
|
||||
|
||||
$object_types = array_unique( $object_types );
|
||||
|
||||
$check_attachments = array_search( 'attachment', $object_types );
|
||||
$check_attachments = array_search( 'attachment', $object_types, true );
|
||||
if ( false !== $check_attachments ) {
|
||||
unset( $object_types[ $check_attachments ] );
|
||||
$check_attachments = true;
|
||||
@@ -4445,7 +4448,7 @@ function is_object_in_term( $object_id, $taxonomy, $terms = null ) {
|
||||
|
||||
foreach ( $object_terms as $object_term ) {
|
||||
// If term is an int, check against term_ids only.
|
||||
if ( $ints && in_array( $object_term->term_id, $ints ) ) {
|
||||
if ( $ints && in_array( $object_term->term_id, $ints, true ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4456,10 +4459,10 @@ function is_object_in_term( $object_id, $taxonomy, $terms = null ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( in_array( $object_term->name, $strs ) ) {
|
||||
if ( in_array( $object_term->name, $strs, true ) ) {
|
||||
return true;
|
||||
}
|
||||
if ( in_array( $object_term->slug, $strs ) ) {
|
||||
if ( in_array( $object_term->slug, $strs, true ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -4482,7 +4485,7 @@ function is_object_in_taxonomy( $object_type, $taxonomy ) {
|
||||
if ( empty( $taxonomies ) ) {
|
||||
return false;
|
||||
}
|
||||
return in_array( $taxonomy, $taxonomies );
|
||||
return in_array( $taxonomy, $taxonomies, true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,7 +48,7 @@ function wp_get_themes( $args = array() ) {
|
||||
$current_theme = get_stylesheet();
|
||||
if ( isset( $theme_directories[ $current_theme ] ) ) {
|
||||
$root_of_current_theme = get_raw_theme_root( $current_theme );
|
||||
if ( ! in_array( $root_of_current_theme, $wp_theme_directories ) ) {
|
||||
if ( ! in_array( $root_of_current_theme, $wp_theme_directories, true ) ) {
|
||||
$root_of_current_theme = WP_CONTENT_DIR . $root_of_current_theme;
|
||||
}
|
||||
$theme_directories[ $current_theme ]['theme_root'] = $root_of_current_theme;
|
||||
@@ -119,7 +119,7 @@ function wp_get_theme( $stylesheet = '', $theme_root = '' ) {
|
||||
$theme_root = get_raw_theme_root( $stylesheet );
|
||||
if ( false === $theme_root ) {
|
||||
$theme_root = WP_CONTENT_DIR . '/themes';
|
||||
} elseif ( ! in_array( $theme_root, (array) $wp_theme_directories ) ) {
|
||||
} elseif ( ! in_array( $theme_root, (array) $wp_theme_directories, true ) ) {
|
||||
$theme_root = WP_CONTENT_DIR . $theme_root;
|
||||
}
|
||||
}
|
||||
@@ -411,7 +411,7 @@ function register_theme_directory( $directory ) {
|
||||
}
|
||||
|
||||
$untrailed = untrailingslashit( $directory );
|
||||
if ( ! empty( $untrailed ) && ! in_array( $untrailed, $wp_theme_directories ) ) {
|
||||
if ( ! empty( $untrailed ) && ! in_array( $untrailed, $wp_theme_directories, true ) ) {
|
||||
$wp_theme_directories[] = $untrailed;
|
||||
}
|
||||
|
||||
@@ -583,7 +583,7 @@ function get_theme_root( $stylesheet_or_template = '' ) {
|
||||
if ( $theme_root ) {
|
||||
// Always prepend WP_CONTENT_DIR unless the root currently registered as a theme directory.
|
||||
// This gives relative theme roots the benefit of the doubt when things go haywire.
|
||||
if ( ! in_array( $theme_root, (array) $wp_theme_directories ) ) {
|
||||
if ( ! in_array( $theme_root, (array) $wp_theme_directories, true ) ) {
|
||||
$theme_root = WP_CONTENT_DIR . $theme_root;
|
||||
}
|
||||
}
|
||||
@@ -626,7 +626,7 @@ function get_theme_root_uri( $stylesheet_or_template = '', $theme_root = '' ) {
|
||||
}
|
||||
|
||||
if ( $stylesheet_or_template && $theme_root ) {
|
||||
if ( in_array( $theme_root, (array) $wp_theme_directories ) ) {
|
||||
if ( in_array( $theme_root, (array) $wp_theme_directories, true ) ) {
|
||||
// Absolute path. Make an educated guess. YMMV -- but note the filter below.
|
||||
if ( 0 === strpos( $theme_root, WP_CONTENT_DIR ) ) {
|
||||
$theme_root_uri = content_url( str_replace( WP_CONTENT_DIR, '', $theme_root ) );
|
||||
@@ -2738,7 +2738,7 @@ function get_theme_support( $feature, ...$args ) {
|
||||
*/
|
||||
function remove_theme_support( $feature ) {
|
||||
// Blacklist: for internal registrations not used directly by themes.
|
||||
if ( in_array( $feature, array( 'editor-style', 'widgets', 'menus' ) ) ) {
|
||||
if ( in_array( $feature, array( 'editor-style', 'widgets', 'menus' ), true ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2846,11 +2846,11 @@ function current_theme_supports( $feature, ...$args ) {
|
||||
* by passing an array of types to add_theme_support().
|
||||
* If no array was passed, then any type is accepted.
|
||||
*/
|
||||
if ( true === $_wp_theme_features[ $feature ] ) { // Registered for all types
|
||||
if ( true === $_wp_theme_features[ $feature ] ) { // Registered for all types.
|
||||
return true;
|
||||
}
|
||||
$content_type = $args[0];
|
||||
return in_array( $content_type, $_wp_theme_features[ $feature ][0] );
|
||||
return in_array( $content_type, $_wp_theme_features[ $feature ][0], true );
|
||||
|
||||
case 'html5':
|
||||
case 'post-formats':
|
||||
@@ -2861,7 +2861,7 @@ function current_theme_supports( $feature, ...$args ) {
|
||||
* Specific areas of HTML5 support *must* be passed via an array to add_theme_support().
|
||||
*/
|
||||
$type = $args[0];
|
||||
return in_array( $type, $_wp_theme_features[ $feature ][0] );
|
||||
return in_array( $type, $_wp_theme_features[ $feature ][0], true );
|
||||
|
||||
case 'custom-logo':
|
||||
case 'custom-header':
|
||||
|
||||
@@ -672,7 +672,10 @@ function wp_get_update_data() {
|
||||
$core = current_user_can( 'update_core' );
|
||||
if ( $core && function_exists( 'get_core_updates' ) ) {
|
||||
$update_wordpress = get_core_updates( array( 'dismissed' => false ) );
|
||||
if ( ! empty( $update_wordpress ) && ! in_array( $update_wordpress[0]->response, array( 'development', 'latest' ) ) && current_user_can( 'update_core' ) ) {
|
||||
if ( ! empty( $update_wordpress )
|
||||
&& ! in_array( $update_wordpress[0]->response, array( 'development', 'latest' ), true )
|
||||
&& current_user_can( 'update_core' )
|
||||
) {
|
||||
$counts['wordpress'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1238,7 +1238,7 @@ function wp_dropdown_users( $args = '' ) {
|
||||
*/
|
||||
function sanitize_user_field( $field, $value, $user_id, $context ) {
|
||||
$int_fields = array( 'ID' );
|
||||
if ( in_array( $field, $int_fields ) ) {
|
||||
if ( in_array( $field, $int_fields, true ) ) {
|
||||
$value = (int) $value;
|
||||
}
|
||||
|
||||
@@ -3111,7 +3111,7 @@ function wp_user_personal_data_exporter( $email_address ) {
|
||||
foreach ( $session_tokens_props_to_export as $key => $name ) {
|
||||
if ( ! empty( $session_token[ $key ] ) ) {
|
||||
$value = $session_token[ $key ];
|
||||
if ( in_array( $key, array( 'expiration', 'login' ) ) ) {
|
||||
if ( in_array( $key, array( 'expiration', 'login' ), true ) ) {
|
||||
$value = date_i18n( 'F d, Y H:i A', $value );
|
||||
}
|
||||
$session_tokens_data_to_export[] = array(
|
||||
|
||||
@@ -105,7 +105,7 @@ class WP_Widget_Links extends WP_Widget {
|
||||
}
|
||||
|
||||
$instance['orderby'] = 'name';
|
||||
if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ) ) ) {
|
||||
if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ), true ) ) {
|
||||
$instance['orderby'] = $new_instance['orderby'];
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ class WP_Widget_Pages extends WP_Widget {
|
||||
public function update( $new_instance, $old_instance ) {
|
||||
$instance = $old_instance;
|
||||
$instance['title'] = sanitize_text_field( $new_instance['title'] );
|
||||
if ( in_array( $new_instance['sortby'], array( 'post_title', 'menu_order', 'ID' ) ) ) {
|
||||
if ( in_array( $new_instance['sortby'], array( 'post_title', 'menu_order', 'ID' ), true ) ) {
|
||||
$instance['sortby'] = $new_instance['sortby'];
|
||||
} else {
|
||||
$instance['sortby'] = 'menu_order';
|
||||
|
||||
@@ -57,7 +57,7 @@ class WP_Widget_RSS extends WP_Widget {
|
||||
}
|
||||
|
||||
// Self-URL destruction sequence.
|
||||
if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) ) {
|
||||
if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ), true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -865,7 +865,7 @@ class wpdb {
|
||||
$incompatible_modes = (array) apply_filters( 'incompatible_sql_modes', $this->incompatible_modes );
|
||||
|
||||
foreach ( $modes as $i => $mode ) {
|
||||
if ( in_array( $mode, $incompatible_modes ) ) {
|
||||
if ( in_array( $mode, $incompatible_modes, true ) ) {
|
||||
unset( $modes[ $i ] );
|
||||
}
|
||||
}
|
||||
@@ -1039,7 +1039,7 @@ class wpdb {
|
||||
$base_prefix = $this->base_prefix;
|
||||
$global_tables = array_merge( $this->global_tables, $this->ms_global_tables );
|
||||
foreach ( $tables as $k => $table ) {
|
||||
if ( in_array( $table, $global_tables ) ) {
|
||||
if ( in_array( $table, $global_tables, true ) ) {
|
||||
$tables[ $table ] = $base_prefix . $table;
|
||||
} else {
|
||||
$tables[ $table ] = $blog_prefix . $table;
|
||||
@@ -2209,7 +2209,7 @@ class wpdb {
|
||||
function _insert_replace_helper( $table, $data, $format = null, $type = 'INSERT' ) {
|
||||
$this->insert_id = 0;
|
||||
|
||||
if ( ! in_array( strtoupper( $type ), array( 'REPLACE', 'INSERT' ) ) ) {
|
||||
if ( ! in_array( strtoupper( $type ), array( 'REPLACE', 'INSERT' ), true ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2743,7 +2743,7 @@ class wpdb {
|
||||
list( $type ) = explode( '(', $column->Type );
|
||||
|
||||
// A binary/blob means the whole query gets treated like this.
|
||||
if ( in_array( strtoupper( $type ), array( 'BINARY', 'VARBINARY', 'TINYBLOB', 'MEDIUMBLOB', 'BLOB', 'LONGBLOB' ) ) ) {
|
||||
if ( in_array( strtoupper( $type ), array( 'BINARY', 'VARBINARY', 'TINYBLOB', 'MEDIUMBLOB', 'BLOB', 'LONGBLOB' ), true ) ) {
|
||||
$this->table_charset[ $tablekey ] = 'binary';
|
||||
return 'binary';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user