mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-07 14:14:36 +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:
@@ -161,7 +161,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
} else {
|
||||
$post_counts = (array) wp_count_posts( $post_type, 'readable' );
|
||||
|
||||
if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'], $avail_post_stati ) ) {
|
||||
if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'], $avail_post_stati, true ) ) {
|
||||
$total_items = $post_counts[ $_REQUEST['post_status'] ];
|
||||
} elseif ( isset( $_REQUEST['show_sticky'] ) && $_REQUEST['show_sticky'] ) {
|
||||
$total_items = $this->sticky_posts_count;
|
||||
@@ -346,7 +346,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
|
||||
$status_name = $status->name;
|
||||
|
||||
if ( ! in_array( $status_name, $avail_post_stati ) || empty( $num_posts->$status_name ) ) {
|
||||
if ( ! in_array( $status_name, $avail_post_stati, true ) || empty( $num_posts->$status_name ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
);
|
||||
|
||||
// Sticky comes after Publish, or if not listed, after All.
|
||||
$split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) );
|
||||
$split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ), true );
|
||||
$status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) );
|
||||
}
|
||||
|
||||
@@ -646,7 +646,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
$post_status = ! empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
|
||||
if ( post_type_supports( $post_type, 'comments' ) && ! in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) {
|
||||
if ( post_type_supports( $post_type, 'comments' ) && ! in_array( $post_status, array( 'pending', 'draft', 'future' ), true ) ) {
|
||||
$posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>';
|
||||
}
|
||||
|
||||
@@ -1384,7 +1384,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
if ( is_post_type_viewable( $post_type_object ) ) {
|
||||
if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
|
||||
if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ), true ) ) {
|
||||
if ( $can_edit_post ) {
|
||||
$preview_link = get_preview_post_link( $post );
|
||||
$actions['view'] = sprintf(
|
||||
|
||||
Reference in New Issue
Block a user