From fe1c79b88c0d2368ed7f479a096e116afc6e9935 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 19 Jan 2023 15:54:37 +0300 Subject: [PATCH 001/125] Use strict comparison in ajax-actions.php --- src/wp-admin/includes/ajax-actions.php | 54 ++++++++++++++------------ 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index 995433eaba27a..9cdd75d753426 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -148,7 +148,7 @@ function wp_ajax_ajax_tag_search() { * Require $term_search_min_chars chars for matching (default: 2) * ensure it's a non-negative, non-zero integer. */ - if ( ( 0 == $term_search_min_chars ) || ( strlen( $search ) < $term_search_min_chars ) ) { + if ( ( 0 === $term_search_min_chars ) || ( strlen( $search ) < $term_search_min_chars ) ) { wp_die(); } @@ -200,10 +200,10 @@ function wp_ajax_wp_compression_test() { $force_gzip = ( defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ); $test_str = '"wpCompressionTest Lorem ipsum dolor sit amet consectetuer mollis sapien urna ut a. Eu nonummy condimentum fringilla tempor pretium platea vel nibh netus Maecenas. Hac molestie amet justo quis pellentesque est ultrices interdum nibh Morbi. Cras mattis pretium Phasellus ante ipsum ipsum ut sociis Suspendisse Lorem. Ante et non molestie. Porta urna Vestibulum egestas id congue nibh eu risus gravida sit. Ac augue auctor Ut et non a elit massa id sodales. Elit eu Nulla at nibh adipiscing mattis lacus mauris at tempus. Netus nibh quis suscipit nec feugiat eget sed lorem et urna. Pellentesque lacus at ut massa consectetuer ligula ut auctor semper Pellentesque. Ut metus massa nibh quam Curabitur molestie nec mauris congue. Volutpat molestie elit justo facilisis neque ac risus Ut nascetur tristique. Vitae sit lorem tellus et quis Phasellus lacus tincidunt nunc Fusce. Pharetra wisi Suspendisse mus sagittis libero lacinia Integer consequat ac Phasellus. Et urna ac cursus tortor aliquam Aliquam amet tellus volutpat Vestibulum. Justo interdum condimentum In augue congue tellus sollicitudin Quisque quis nibh."'; - if ( 1 == $_GET['test'] ) { + if ( '1' === $_GET['test'] ) { echo $test_str; wp_die(); - } elseif ( 2 == $_GET['test'] ) { + } elseif ( '2' === $_GET['test'] ) { if ( ! isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) { wp_die( -1 ); } @@ -494,7 +494,7 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) { } // Only do the expensive stuff on a page-break, and about 1 other time per page. - if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) { + if ( 0 === $total % $per_page || 1 === mt_rand( 1, $per_page ) ) { $post_id = 0; // What type of comment count are we looking for? $status = 'all'; @@ -714,13 +714,13 @@ function wp_ajax_delete_comment() { $status = wp_get_comment_status( $comment ); $delta = -1; - if ( isset( $_POST['trash'] ) && 1 == $_POST['trash'] ) { + if ( isset( $_POST['trash'] ) && '1' === $_POST['trash'] ) { if ( 'trash' === $status ) { wp_die( time() ); } $r = wp_trash_comment( $comment ); - } elseif ( isset( $_POST['untrash'] ) && 1 == $_POST['untrash'] ) { + } elseif ( isset( $_POST['untrash'] ) && '1' === $_POST['untrash'] ) { if ( 'trash' !== $status ) { wp_die( time() ); } @@ -731,13 +731,13 @@ function wp_ajax_delete_comment() { if ( ! isset( $_POST['comment_status'] ) || 'trash' !== $_POST['comment_status'] ) { $delta = 1; } - } elseif ( isset( $_POST['spam'] ) && 1 == $_POST['spam'] ) { + } elseif ( isset( $_POST['spam'] ) && '1' === $_POST['spam'] ) { if ( 'spam' === $status ) { wp_die( time() ); } $r = wp_spam_comment( $comment ); - } elseif ( isset( $_POST['unspam'] ) && 1 == $_POST['unspam'] ) { + } elseif ( isset( $_POST['unspam'] ) && '1' === $_POST['unspam'] ) { if ( 'spam' !== $status ) { wp_die( time() ); } @@ -748,7 +748,7 @@ function wp_ajax_delete_comment() { if ( ! isset( $_POST['comment_status'] ) || 'spam' !== $_POST['comment_status'] ) { $delta = 1; } - } elseif ( isset( $_POST['delete'] ) && 1 == $_POST['delete'] ) { + } elseif ( isset( $_POST['delete'] ) && '1' === $_POST['delete'] ) { $r = wp_delete_comment( $comment ); } else { wp_die( -1 ); @@ -981,7 +981,7 @@ function wp_ajax_dim_comment() { $current = wp_get_comment_status( $comment ); - if ( isset( $_POST['new'] ) && $_POST['new'] == $current ) { + if ( isset( $_POST['new'] ) && $_POST['new'] === $current ) { wp_die( time() ); } @@ -1320,7 +1320,7 @@ function wp_ajax_replyto_comment( $action ) { $_POST['_wp_unfiltered_html_comment'] = ''; } - if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) { + if ( wp_create_nonce( 'unfiltered-html-comment' ) !== $_POST['_wp_unfiltered_html_comment'] ) { kses_remove_filters(); // Start with a clean slate. kses_init_filters(); // Set up the filters. remove_filter( 'pre_comment_content', 'wp_filter_post_kses' ); @@ -1365,7 +1365,7 @@ function wp_ajax_replyto_comment( $action ) { if ( ! empty( $_POST['approve_parent'] ) ) { $parent = get_comment( $comment_parent ); - if ( $parent && '0' === $parent->comment_approved && $parent->comment_post_ID == $comment_post_id ) { + if ( $parent && '0' === $parent->comment_approved && (int) $parent->comment_post_ID === $comment_post_id ) { if ( ! current_user_can( 'edit_comment', $parent->comment_ID ) ) { wp_die( -1 ); } @@ -1463,8 +1463,12 @@ function wp_ajax_edit_comment() { wp_die( $updated->get_error_message() ); } - $position = ( isset( $_POST['position'] ) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1'; - $checkbox = ( isset( $_POST['checkbox'] ) && true == $_POST['checkbox'] ) ? 1 : 0; + $position = ( isset( $_POST['position'] ) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1'; + /* + * Checkbox is used to differentiate between the Comments section on the Edit Post screen + * and the Edit Comments screen. + */ + $checkbox = ( isset( $_POST['checkbox'] ) && '1' === $_POST['checkbox'] ) ? 1 : 0; $wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); $comment = get_comment( $comment_id ); @@ -1673,7 +1677,7 @@ function wp_ajax_add_meta() { wp_die( -1 ); } - if ( $meta->meta_value != $value || $meta->meta_key != $key ) { + if ( $meta->meta_value !== $value || $meta->meta_key !== $key ) { $u = update_metadata_by_mid( 'post', $mid, $value, $key ); if ( ! $u ) { wp_die( 0 ); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems). @@ -1771,7 +1775,7 @@ function wp_ajax_closed_postboxes() { $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; - if ( sanitize_key( $page ) != $page ) { + if ( sanitize_key( $page ) !== $page ) { wp_die( 0 ); } @@ -1802,7 +1806,7 @@ function wp_ajax_hidden_columns() { check_ajax_referer( 'screen-options-nonce', 'screenoptionnonce' ); $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; - if ( sanitize_key( $page ) != $page ) { + if ( sanitize_key( $page ) !== $page ) { wp_die( 0 ); } @@ -1957,7 +1961,7 @@ function wp_ajax_meta_box_order() { $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; - if ( sanitize_key( $page ) != $page ) { + if ( sanitize_key( $page ) !== $page ) { wp_die( 0 ); } @@ -2386,7 +2390,7 @@ function wp_ajax_save_widget() { foreach ( (array) $wp_registered_widget_updates as $name => $control ) { - if ( $name == $id_base ) { + if ( $name === $id_base ) { if ( ! is_callable( $control['callback'] ) ) { continue; } @@ -2712,7 +2716,7 @@ function wp_ajax_set_post_thumbnail() { check_ajax_referer( "set_post_thumbnail-$post_ID" ); } - if ( '-1' == $thumbnail_id ) { + if ( -1 === $thumbnail_id ) { if ( delete_post_thumbnail( $post_ID ) ) { $return = _wp_post_thumbnail_html( null, $post_ID ); $json ? wp_send_json_success( $return ) : wp_die( $return ); @@ -2892,7 +2896,7 @@ function wp_ajax_wp_remove_post_lock() { $active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) ); - if ( get_current_user_id() != $active_lock[1] ) { + if ( get_current_user_id() !== $active_lock[1] ) { wp_die( 0 ); } @@ -2917,7 +2921,7 @@ function wp_ajax_wp_remove_post_lock() { function wp_ajax_dismiss_wp_pointer() { $pointer = $_POST['pointer']; - if ( sanitize_key( $pointer ) != $pointer ) { + if ( sanitize_key( $pointer ) !== $pointer ) { wp_die( 0 ); } @@ -3289,7 +3293,7 @@ function wp_ajax_send_attachment_to_editor() { // If this attachment is unattached, attach it. Primarily a back compat thing. $insert_into_post_id = (int) $_POST['post_id']; - if ( 0 == $post->post_parent && $insert_into_post_id ) { + if ( 0 === $post->post_parent && $insert_into_post_id ) { wp_update_post( array( 'ID' => $id, @@ -3300,7 +3304,7 @@ function wp_ajax_send_attachment_to_editor() { } $url = empty( $attachment['url'] ) ? '' : $attachment['url']; - $rel = ( strpos( $url, 'attachment_id' ) || get_attachment_link( $id ) == $url ); + $rel = ( strpos( $url, 'attachment_id' ) || get_attachment_link( $id ) === $url ); remove_filter( 'media_send_to_editor', 'image_media_send_to_editor' ); @@ -3969,7 +3973,7 @@ function wp_ajax_crop_image() { $wp_site_icon = new WP_Site_Icon(); // Skip creating a new attachment if the attachment is a Site Icon. - if ( get_post_meta( $attachment_id, '_wp_attachment_context', true ) == $context ) { + if ( get_post_meta( $attachment_id, '_wp_attachment_context', true ) === $context ) { // Delete the temporary cropped file, we don't need it. wp_delete_file( $cropped ); From a616c6d6608eca3ab6f702df1f18c195e2b83ac1 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 19 Jan 2023 15:57:34 +0300 Subject: [PATCH 002/125] Use strict comparison in class-wp-importer.php --- src/wp-admin/includes/class-wp-importer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/includes/class-wp-importer.php b/src/wp-admin/includes/class-wp-importer.php index 4804c888b23f3..0c4a7ffe6b85f 100644 --- a/src/wp-admin/includes/class-wp-importer.php +++ b/src/wp-admin/includes/class-wp-importer.php @@ -41,7 +41,7 @@ public function get_imported_posts( $importer_name, $blog_id ) { $hashtable[ $r->meta_value ] = (int) $r->post_id; } } - } while ( count( $results ) == $limit ); + } while ( count( $results ) === $limit ); return $hashtable; } @@ -105,12 +105,12 @@ public function get_imported_comments( $blog_id ) { $source_comment_id = (int) $source_comment_id; // Check if this comment came from this blog. - if ( $blog_id == $comment_agent_blog_id ) { + if ( (int) $blog_id === (int) $comment_agent_blog_id ) { $hashtable[ $source_comment_id ] = (int) $r->comment_ID; } } } - } while ( count( $results ) == $limit ); + } while ( count( $results ) === $limit ); return $hashtable; } From 15767a0ce3b955684e79a1b35e56c39a07e48188 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 19 Jan 2023 16:06:34 +0300 Subject: [PATCH 003/125] Use strict comparison in class-wp-list-table.php --- src/wp-admin/includes/class-wp-list-table.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/wp-admin/includes/class-wp-list-table.php b/src/wp-admin/includes/class-wp-list-table.php index a043af12d1507..f420efef4b63b 100644 --- a/src/wp-admin/includes/class-wp-list-table.php +++ b/src/wp-admin/includes/class-wp-list-table.php @@ -599,7 +599,7 @@ public function current_action() { return false; } - if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) { + if ( isset( $_REQUEST['action'] ) && '-1' !== $_REQUEST['action'] ) { return $_REQUEST['action']; } @@ -716,7 +716,7 @@ protected function months_dropdown( $post_type ) { $month_count = count( $months ); - if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) { + if ( ! $month_count || ( 1 === $month_count && 0 === (int) $months[0]->month ) ) { return; } @@ -727,7 +727,7 @@ protected function months_dropdown( $post_type ) { value="0"> year ) { + if ( 0 === (int) $arc_row->year ) { continue; } @@ -979,11 +979,11 @@ protected function pagination( $which ) { $disable_prev = false; $disable_next = false; - if ( 1 == $current ) { + if ( 1 === $current ) { $disable_first = true; $disable_prev = true; } - if ( $total_pages == $current ) { + if ( (int) $total_pages === $current ) { $disable_last = true; $disable_next = true; } From 6147444ccd275a8e30f09618de7a9e8e63308301 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 19 Jan 2023 16:15:35 +0300 Subject: [PATCH 004/125] Use strict comparison in class-wp-ms-sites-list-table.php --- src/wp-admin/includes/class-wp-ms-sites-list-table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/class-wp-ms-sites-list-table.php b/src/wp-admin/includes/class-wp-ms-sites-list-table.php index 3d4583f1ecdf7..0fbddf42e5c85 100644 --- a/src/wp-admin/includes/class-wp-ms-sites-list-table.php +++ b/src/wp-admin/includes/class-wp-ms-sites-list-table.php @@ -586,7 +586,7 @@ public function display_rows() { reset( $this->status_list ); foreach ( $this->status_list as $status => $col ) { - if ( 1 == $blog[ $status ] ) { + if ( 1 === (int) $blog[ $status ] ) { $class = " class='{$col[0]}'"; } } From f3e34de7db2a309fa657bf475ec07b3e9d3ad866 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 19 Jan 2023 16:20:07 +0300 Subject: [PATCH 005/125] Add ignore annotation to class-wp-privacy-policy-content.php --- src/wp-admin/includes/class-wp-privacy-policy-content.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/class-wp-privacy-policy-content.php b/src/wp-admin/includes/class-wp-privacy-policy-content.php index 9b11d09a66f02..c51bfa7804702 100644 --- a/src/wp-admin/includes/class-wp-privacy-policy-content.php +++ b/src/wp-admin/includes/class-wp-privacy-policy-content.php @@ -105,7 +105,7 @@ public static function text_change_check() { // The == operator (equal, not identical) was used intentionally. // See http://php.net/manual/en/language.operators.array.php - if ( $new != $old ) { + if ( $new != $old ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison // A plugin was activated or deactivated, or some policy text has changed. // Show a notice on the relevant screens to inform the admin. add_action( 'admin_notices', array( 'WP_Privacy_Policy_Content', 'policy_text_changed_notice' ) ); From 51f2cad1f1487cbe6c27c9b7fd2ff6a693d6136b Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 19 Jan 2023 16:26:05 +0300 Subject: [PATCH 006/125] Use strict comparison in class-wp-site-icon.php --- src/wp-admin/includes/class-wp-site-icon.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/class-wp-site-icon.php b/src/wp-admin/includes/class-wp-site-icon.php index e799c7fb7980d..ae015f5762a76 100644 --- a/src/wp-admin/includes/class-wp-site-icon.php +++ b/src/wp-admin/includes/class-wp-site-icon.php @@ -203,7 +203,7 @@ public function intermediate_image_sizes( $sizes = array() ) { public function delete_attachment_data( $post_id ) { $site_icon_id = get_option( 'site_icon' ); - if ( $site_icon_id && $post_id == $site_icon_id ) { + if ( $site_icon_id && $post_id === (int) $site_icon_id ) { delete_option( 'site_icon' ); } } @@ -224,7 +224,7 @@ public function get_post_metadata( $value, $post_id, $meta_key, $single ) { if ( $single && '_wp_attachment_backup_sizes' === $meta_key ) { $site_icon_id = get_option( 'site_icon' ); - if ( $post_id == $site_icon_id ) { + if ( $post_id === (int) $site_icon_id ) { add_filter( 'intermediate_image_sizes', array( $this, 'intermediate_image_sizes' ) ); } } From df2167315d19a1f69d0b407e248ca0aa38550793 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 19 Jan 2023 16:34:34 +0300 Subject: [PATCH 007/125] Use strict comparison in image-edit.php --- src/wp-admin/includes/image-edit.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/wp-admin/includes/image-edit.php b/src/wp-admin/includes/image-edit.php index 746c0bafbd46c..c4d0c01649225 100644 --- a/src/wp-admin/includes/image-edit.php +++ b/src/wp-admin/includes/image-edit.php @@ -596,7 +596,7 @@ function image_edit_apply_changes( $image, $changes ) { $filtered = array( $changes[0] ); for ( $i = 0, $j = 1, $c = count( $changes ); $j < $c; $j++ ) { $combined = false; - if ( $filtered[ $i ]->type == $changes[ $j ]->type ) { + if ( $filtered[ $i ]->type === $changes[ $j ]->type ) { switch ( $filtered[ $i ]->type ) { case 'rotate': $filtered[ $i ]->angle += $changes[ $j ]->angle; @@ -753,7 +753,7 @@ function wp_restore_image( $post_id ) { if ( isset( $backup_sizes['full-orig'] ) && is_array( $backup_sizes['full-orig'] ) ) { $data = $backup_sizes['full-orig']; - if ( $parts['basename'] != $data['file'] ) { + if ( $parts['basename'] !== $data['file'] ) { if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE ) { // Delete only if it's an edited image. @@ -780,7 +780,7 @@ function wp_restore_image( $post_id ) { foreach ( $default_sizes as $default_size ) { if ( isset( $backup_sizes[ "$default_size-orig" ] ) ) { $data = $backup_sizes[ "$default_size-orig" ]; - if ( isset( $meta['sizes'][ $default_size ] ) && $meta['sizes'][ $default_size ]['file'] != $data['file'] ) { + if ( isset( $meta['sizes'][ $default_size ] ) && $meta['sizes'][ $default_size ]['file'] !== $data['file'] ) { if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE ) { // Delete only if it's an edited image. @@ -895,7 +895,7 @@ function wp_save_image( $post_id ) { $suffix = time() . rand( 100, 999 ); if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE && - isset( $backup_sizes['full-orig'] ) && $backup_sizes['full-orig']['file'] != $basename ) { + isset( $backup_sizes['full-orig'] ) && $backup_sizes['full-orig']['file'] !== $basename ) { if ( 'thumbnail' === $target ) { $new_path = "{$dirname}/{$filename}-temp.{$ext}"; @@ -994,7 +994,7 @@ function wp_save_image( $post_id ) { $tag = false; if ( isset( $meta['sizes'][ $size ] ) ) { if ( isset( $backup_sizes[ "$size-orig" ] ) ) { - if ( ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) && $backup_sizes[ "$size-orig" ]['file'] != $meta['sizes'][ $size ]['file'] ) { + if ( ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) && $backup_sizes[ "$size-orig" ]['file'] !== $meta['sizes'][ $size ]['file'] ) { $tag = "$size-$suffix"; } } else { From 6f5d04b3f2b092f6f4422d9252c6d4494d8bb163 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 19 Jan 2023 17:01:51 +0300 Subject: [PATCH 008/125] Use strict comparison in media.php --- src/wp-admin/includes/media.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php index 0938257da760e..6139b74d1a662 100644 --- a/src/wp-admin/includes/media.php +++ b/src/wp-admin/includes/media.php @@ -93,7 +93,7 @@ function the_media_upload_tabs() { foreach ( $tabs as $callback => $text ) { $class = ''; - if ( $current == $callback ) { + if ( $current === $callback ) { $class = " class='current'"; } @@ -764,7 +764,7 @@ function media_upload_form_handler() { $post['menu_order'] = $attachment['menu_order']; } - if ( isset( $send_id ) && $attachment_id == $send_id ) { + if ( isset( $send_id ) && (int) $attachment_id === $send_id ) { if ( isset( $attachment['post_parent'] ) ) { $post['post_parent'] = $attachment['post_parent']; } @@ -798,7 +798,9 @@ function media_upload_form_handler() { unset( $post['errors'] ); } - if ( $post != $_post ) { + // The == operator (equal, not identical) was used intentionally. + // See http://php.net/manual/en/language.operators.array.php + if ( $post != $_post ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison wp_update_post( $post ); } @@ -828,7 +830,7 @@ function media_upload_form_handler() { if ( ! empty( $attachment['url'] ) ) { $rel = ''; - if ( strpos( $attachment['url'], 'attachment_id' ) || get_attachment_link( $send_id ) == $attachment['url'] ) { + if ( strpos( $attachment['url'], 'attachment_id' ) || get_attachment_link( $send_id ) === $attachment['url'] ) { $rel = " rel='attachment wp-att-" . esc_attr( $send_id ) . "'"; } @@ -1163,7 +1165,7 @@ function image_align_input_fields( $post, $checked = '' ) { foreach ( $alignments as $name => $label ) { $name = esc_attr( $name ); $output[] = ""; } @@ -1213,7 +1215,7 @@ function image_size_input_fields( $post, $check = '' ) { $css_id = "image-size-{$size}-{$post->ID}"; // If this size is the default but that's not available, don't select it. - if ( $size == $check ) { + if ( $size === $check ) { if ( $enabled ) { $checked = " checked='checked'"; } else { @@ -1752,7 +1754,7 @@ function get_media_item( $attachment_id, $args = null ) { if ( 'image' === $type && $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) ) && post_type_supports( get_post_type( $calling_post_id ), 'thumbnail' ) - && get_post_thumbnail_id( $calling_post_id ) != $attachment_id + && get_post_thumbnail_id( $calling_post_id ) !== $attachment_id ) { $calling_post = get_post( $calling_post_id ); @@ -2830,20 +2832,20 @@ function media_upload_library_form( $errors ) { $month_count = count( $arc_result ); $selected_month = isset( $_GET['m'] ) ? $_GET['m'] : 0; - if ( $month_count && ! ( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { + if ( $month_count && ! ( 1 === $month_count && 0 === (int) $arc_result[0]->mmonth ) ) { ?> - +

@@ -533,7 +533,7 @@ case 'del': case 'del_many': $delete_count = isset( $_GET['delete_count'] ) ? (int) $_GET['delete_count'] : 0; - if ( 1 == $delete_count ) { + if ( 1 === $delete_count ) { $message = __( 'User deleted.' ); } else { /* translators: %s: Number of users. */ From a519e5d556f8e1b58a9c1ce60e753269521857fe Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Feb 2023 15:16:53 +0300 Subject: [PATCH 030/125] Use correct default values in class-wp-comment.php --- src/wp-includes/class-wp-comment.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-comment.php b/src/wp-includes/class-wp-comment.php index c5f8cc49f4076..1e4a9fdc179c6 100644 --- a/src/wp-includes/class-wp-comment.php +++ b/src/wp-includes/class-wp-comment.php @@ -134,7 +134,7 @@ final class WP_Comment { * @since 4.4.0 * @var string */ - public $comment_parent = 0; + public $comment_parent = '0'; /** * Comment author ID. @@ -144,7 +144,7 @@ final class WP_Comment { * @since 4.4.0 * @var string */ - public $user_id = 0; + public $user_id = '0'; /** * Comment children. From 19906b8971fdf13dd9d2cdf5970fe644b4476c40 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Feb 2023 15:17:53 +0300 Subject: [PATCH 031/125] Use strict comparison in twentyeleven/functions.php --- src/wp-content/themes/twentyeleven/functions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wp-content/themes/twentyeleven/functions.php b/src/wp-content/themes/twentyeleven/functions.php index fffa55c966cf7..58f690e612393 100644 --- a/src/wp-content/themes/twentyeleven/functions.php +++ b/src/wp-content/themes/twentyeleven/functions.php @@ -322,7 +322,7 @@ function twentyeleven_header_style() { $text_color = get_header_textcolor(); // If no custom options for text are set, let's bail. - if ( HEADER_TEXTCOLOR == $text_color ) { + if ( HEADER_TEXTCOLOR === $text_color ) { return; } @@ -386,7 +386,7 @@ function twentyeleven_admin_header_style() { } #site-title a, #site-description { @@ -724,7 +724,7 @@ function twentyeleven_comment( $comment, $args, $depth ) { comment_parent ) { + if ( '0' !== $comment->comment_parent ) { $avatar_size = 39; } @@ -756,7 +756,7 @@ function twentyeleven_comment( $comment, $args, $depth ) { } ?> - comment_approved ) : ?> + comment_approved ) : ?>
From 432e1c4bd41382a813e7892d964735aa65122c21 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Feb 2023 15:19:15 +0300 Subject: [PATCH 032/125] Use strict comparison in twentyeleven/image.php --- src/wp-content/themes/twentyeleven/image.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-content/themes/twentyeleven/image.php b/src/wp-content/themes/twentyeleven/image.php index 097ff19cc3986..a727ea147acfc 100644 --- a/src/wp-content/themes/twentyeleven/image.php +++ b/src/wp-content/themes/twentyeleven/image.php @@ -70,7 +70,7 @@ ) ); foreach ( $attachments as $k => $attachment ) { - if ( $attachment->ID == $post->ID ) { + if ( $attachment->ID === $post->ID ) { break; } } From 81ebb862c59e0014250be3086434a5dce953c82d Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Feb 2023 15:21:13 +0300 Subject: [PATCH 033/125] Use strict comparison in twentyeleven/inc/theme-options.php --- src/wp-content/themes/twentyeleven/inc/theme-options.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-content/themes/twentyeleven/inc/theme-options.php b/src/wp-content/themes/twentyeleven/inc/theme-options.php index bb521d00113b9..b9baf5ab8d9b2 100644 --- a/src/wp-content/themes/twentyeleven/inc/theme-options.php +++ b/src/wp-content/themes/twentyeleven/inc/theme-options.php @@ -446,7 +446,7 @@ function twentyeleven_print_link_color_style() { $default_options = twentyeleven_get_default_theme_options(); // Don't do anything if the current link color is the default. - if ( $default_options['link_color'] == $link_color ) { + if ( $default_options['link_color'] === $link_color ) { return; } ?> From ab2583beeba1236d63c68dd3645472ec15672c40 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Feb 2023 15:22:04 +0300 Subject: [PATCH 034/125] Use strict comparison in twentyeleven/showcase.php --- src/wp-content/themes/twentyeleven/showcase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-content/themes/twentyeleven/showcase.php b/src/wp-content/themes/twentyeleven/showcase.php index 7bcf05df9f02d..a51d53e1003a1 100644 --- a/src/wp-content/themes/twentyeleven/showcase.php +++ b/src/wp-content/themes/twentyeleven/showcase.php @@ -154,7 +154,7 @@ while ( $featured->have_posts() ) : $featured->the_post(); $counter_slider++; - if ( 1 == $counter_slider ) { + if ( 1 === $counter_slider ) { $class = ' class="active"'; } else { $class = ''; From c4fdcb62d75c8743cc81b49865145141ab97ae41 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Feb 2023 15:24:52 +0300 Subject: [PATCH 035/125] Use strict comparison in twentyfourteen/functions.php --- src/wp-content/themes/twentyfourteen/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-content/themes/twentyfourteen/functions.php b/src/wp-content/themes/twentyfourteen/functions.php index 100a7f88db57e..1811980cb8797 100644 --- a/src/wp-content/themes/twentyfourteen/functions.php +++ b/src/wp-content/themes/twentyfourteen/functions.php @@ -461,7 +461,7 @@ function twentyfourteen_the_attached_image() { // If there is more than 1 attachment in a gallery... if ( count( $attachment_ids ) > 1 ) { foreach ( $attachment_ids as $idx => $attachment_id ) { - if ( $attachment_id == $post->ID ) { + if ( $attachment_id === $post->ID ) { $next_id = $attachment_ids[ ( $idx + 1 ) % count( $attachment_ids ) ]; break; } From 089463e31f2c101938aa369dc6198006c86e5b6b Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Feb 2023 15:27:02 +0300 Subject: [PATCH 036/125] Use strict comparison in twentyfourteen/inc/custom-header.php --- src/wp-content/themes/twentyfourteen/inc/custom-header.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-content/themes/twentyfourteen/inc/custom-header.php b/src/wp-content/themes/twentyfourteen/inc/custom-header.php index dc34e0244e7da..d6692dbb4104a 100644 --- a/src/wp-content/themes/twentyfourteen/inc/custom-header.php +++ b/src/wp-content/themes/twentyfourteen/inc/custom-header.php @@ -82,7 +82,7 @@ function twentyfourteen_header_style() { } .site-title a { color: #; From 3c8099c343be64967df639951366525ba3c48bda Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Feb 2023 15:28:48 +0300 Subject: [PATCH 037/125] Use strict comparison in twentyfourteen/inc/featured-content.php --- src/wp-content/themes/twentyfourteen/inc/featured-content.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-content/themes/twentyfourteen/inc/featured-content.php b/src/wp-content/themes/twentyfourteen/inc/featured-content.php index da8b76f715a04..ed7c661c42adc 100644 --- a/src/wp-content/themes/twentyfourteen/inc/featured-content.php +++ b/src/wp-content/themes/twentyfourteen/inc/featured-content.php @@ -262,7 +262,7 @@ public static function pre_get_posts( $query ) { public static function delete_post_tag( $tag_id ) { $settings = self::get_setting(); - if ( empty( $settings['tag-id'] ) || $tag_id != $settings['tag-id'] ) { + if ( empty( $settings['tag-id'] ) || $tag_id !== $settings['tag-id'] ) { return; } From 077c34cb60f76820eab357e4422a4ea2a42f7fce Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Feb 2023 15:31:17 +0300 Subject: [PATCH 038/125] Use strict comparison in twentynineteen/classes/class-twentynineteen-walker-comment.php --- .../classes/class-twentynineteen-walker-comment.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-walker-comment.php b/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-walker-comment.php index f501de695a977..3ab2c4bf29955 100644 --- a/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-walker-comment.php +++ b/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-walker-comment.php @@ -36,7 +36,7 @@ protected function html5_comment( $comment, $depth, $args ) { $comment_author_url = get_comment_author_url( $comment ); $comment_author = get_comment_author( $comment ); $avatar = get_avatar( $comment, $args['avatar_size'] ); - if ( 0 != $args['avatar_size'] ) { + if ( 0 !== (int) $args['avatar_size'] ) { if ( empty( $comment_author_url ) ) { echo $avatar; } else { @@ -98,7 +98,7 @@ protected function html5_comment( $comment, $depth, $args ) { } ?> - comment_approved ) : ?> + comment_approved ) : ?>

From 843c1095f3ec228cc7abac3523ba6f1e0c1674ad Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Feb 2023 15:34:19 +0300 Subject: [PATCH 039/125] Use strict comparison in twentynineteen/comments.php --- src/wp-content/themes/twentynineteen/comments.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-content/themes/twentynineteen/comments.php b/src/wp-content/themes/twentynineteen/comments.php index 9ef3fd6accfd7..5e734d417eddd 100644 --- a/src/wp-content/themes/twentynineteen/comments.php +++ b/src/wp-content/themes/twentynineteen/comments.php @@ -35,7 +35,7 @@ _e( 'Leave a comment', 'twentynineteen' ); } } else { - if ( '1' == $discussion->responses ) { + if ( '1' === (string) $discussion->responses ) { /* translators: %s: Post title. */ printf( _x( 'One reply on “%s”', 'comments title', 'twentynineteen' ), get_the_title() ); } else { From 825eb5119b3e2735f6181a76288c2ffbea091a96 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Feb 2023 15:35:02 +0300 Subject: [PATCH 040/125] Use strict comparison in twentyten/functions.php --- src/wp-content/themes/twentyten/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-content/themes/twentyten/functions.php b/src/wp-content/themes/twentyten/functions.php index 7e55972549394..8bda350d40597 100644 --- a/src/wp-content/themes/twentyten/functions.php +++ b/src/wp-content/themes/twentyten/functions.php @@ -439,7 +439,7 @@ function twentyten_comment( $comment, $args, $depth ) { } ?> - comment_approved ) : ?> + comment_approved ) : ?>
From f94f3d8d5cce5240f79fc8c6af40e2f932e610c3 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Feb 2023 15:35:32 +0300 Subject: [PATCH 041/125] Use strict comparison in twentyten/loop-attachment.php --- src/wp-content/themes/twentyten/loop-attachment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-content/themes/twentyten/loop-attachment.php b/src/wp-content/themes/twentyten/loop-attachment.php index d3f6eb487165d..007b5aa036f9d 100644 --- a/src/wp-content/themes/twentyten/loop-attachment.php +++ b/src/wp-content/themes/twentyten/loop-attachment.php @@ -100,7 +100,7 @@ ) ); foreach ( $attachments as $k => $attachment ) { - if ( $attachment->ID == $post->ID ) { + if ( $attachment->ID === $post->ID ) { break; } } From 6ec38e422ffbe2731ddad06257479404522d92c5 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Feb 2023 15:36:38 +0300 Subject: [PATCH 042/125] Use strict comparison in twentythirteen/functions.php --- src/wp-content/themes/twentythirteen/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-content/themes/twentythirteen/functions.php b/src/wp-content/themes/twentythirteen/functions.php index cd1d3e1f4962e..118281817d440 100644 --- a/src/wp-content/themes/twentythirteen/functions.php +++ b/src/wp-content/themes/twentythirteen/functions.php @@ -635,7 +635,7 @@ function twentythirteen_the_attached_image() { // If there is more than 1 attachment in a gallery... if ( count( $attachment_ids ) > 1 ) { foreach ( $attachment_ids as $idx => $attachment_id ) { - if ( $attachment_id == $post->ID ) { + if ( $attachment_id === $post->ID ) { $next_id = $attachment_ids[ ( $idx + 1 ) % count( $attachment_ids ) ]; break; } From 7255e98f99545444fc047e4fdc5e803638152b5d Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Feb 2023 15:37:23 +0300 Subject: [PATCH 043/125] Use strict comparison in twentythirteen/image.php --- src/wp-content/themes/twentythirteen/image.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-content/themes/twentythirteen/image.php b/src/wp-content/themes/twentythirteen/image.php index 886eb225bf4ba..26ca20a094429 100644 --- a/src/wp-content/themes/twentythirteen/image.php +++ b/src/wp-content/themes/twentythirteen/image.php @@ -30,7 +30,7 @@ $published_text = __( 'Published on in %5$s', 'twentythirteen' ); $published_text = '' . $published_text . ''; $post_title = get_the_title( $post->post_parent ); - if ( empty( $post_title ) || 0 == $post->post_parent ) { + if ( empty( $post_title ) || 0 === $post->post_parent ) { $published_text = ''; } From fcd207574e200fc146f30a44bf2b0c33632c6d8e Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Feb 2023 15:38:09 +0300 Subject: [PATCH 044/125] Use strict comparison in twentythirteen/inc/custom-header.php --- src/wp-content/themes/twentythirteen/inc/custom-header.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-content/themes/twentythirteen/inc/custom-header.php b/src/wp-content/themes/twentythirteen/inc/custom-header.php index 7bbb50ec35d7a..b87eaa058f830 100644 --- a/src/wp-content/themes/twentythirteen/inc/custom-header.php +++ b/src/wp-content/themes/twentythirteen/inc/custom-header.php @@ -90,7 +90,7 @@ function twentythirteen_header_style() { $text_color = get_header_textcolor(); // If no custom options for text are set, let's bail. - if ( empty( $header_image ) && get_theme_support( 'custom-header', 'default-text-color' ) == $text_color ) { + if ( empty( $header_image ) && get_theme_support( 'custom-header', 'default-text-color' ) === $text_color ) { return; } @@ -136,7 +136,7 @@ function twentythirteen_header_style() { endif; // If the user has set a custom color for the text, use that. - elseif ( get_theme_support( 'custom-header', 'default-text-color' ) != $text_color ) : + elseif ( get_theme_support( 'custom-header', 'default-text-color' ) !== $text_color ) : ?> .site-title, .site-description { From 5fa077491f82777a90223655cf2e73f1886a0ed7 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Feb 2023 15:38:43 +0300 Subject: [PATCH 045/125] Use strict comparison in twentytwelve/functions.php --- src/wp-content/themes/twentytwelve/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-content/themes/twentytwelve/functions.php b/src/wp-content/themes/twentytwelve/functions.php index d0e9280bce813..6223ce7bb4d76 100644 --- a/src/wp-content/themes/twentytwelve/functions.php +++ b/src/wp-content/themes/twentytwelve/functions.php @@ -476,7 +476,7 @@ function twentytwelve_comment( $comment, $args, $depth ) { } ?> - comment_approved ) : ?> + comment_approved ) : ?>

From 49a875c9fa6d40677e81f5aa9de10435d6a204cc Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Feb 2023 15:39:20 +0300 Subject: [PATCH 046/125] Use strict comparison in twentytwelve/image.php --- src/wp-content/themes/twentytwelve/image.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-content/themes/twentytwelve/image.php b/src/wp-content/themes/twentytwelve/image.php index 8958092c87221..ffdde2c00d23a 100644 --- a/src/wp-content/themes/twentytwelve/image.php +++ b/src/wp-content/themes/twentytwelve/image.php @@ -70,7 +70,7 @@ ) ); foreach ( $attachments as $k => $attachment ) : - if ( $attachment->ID == $post->ID ) { + if ( $attachment->ID === $post->ID ) { break; } endforeach; From dc91c386d0829729a3ec9cf90a45c04d357e8bc4 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Feb 2023 15:40:08 +0300 Subject: [PATCH 047/125] Use strict comparison in twentytwelve/inc/custom-header.php --- src/wp-content/themes/twentytwelve/inc/custom-header.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-content/themes/twentytwelve/inc/custom-header.php b/src/wp-content/themes/twentytwelve/inc/custom-header.php index 693883ca7a4b3..84b3556c244aa 100644 --- a/src/wp-content/themes/twentytwelve/inc/custom-header.php +++ b/src/wp-content/themes/twentytwelve/inc/custom-header.php @@ -71,7 +71,7 @@ function twentytwelve_header_style() { $text_color = get_header_textcolor(); // If no custom options for text are set, let's bail. - if ( get_theme_support( 'custom-header', 'default-text-color' ) == $text_color ) { + if ( get_theme_support( 'custom-header', 'default-text-color' ) === $text_color ) { return; } From 78316161e9b9169561da96fb0fe3ba329d045f32 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Feb 2023 15:42:28 +0300 Subject: [PATCH 048/125] Use empty() in bookmark-template.php --- src/wp-includes/bookmark-template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/bookmark-template.php b/src/wp-includes/bookmark-template.php index 4c9cbeebc080b..6c37ac4455001 100644 --- a/src/wp-includes/bookmark-template.php +++ b/src/wp-includes/bookmark-template.php @@ -124,7 +124,7 @@ function _walk_bookmarks( $bookmarks, $args = '' ) { $output .= $parsed_args['link_before']; - if ( null != $bookmark->link_image && $parsed_args['show_images'] ) { + if ( ! empty( $bookmark->link_image ) && $parsed_args['show_images'] ) { if ( strpos( $bookmark->link_image, 'http' ) === 0 ) { $output .= "link_image\" $alt $title />"; } else { // If it's a relative path. From 17ee88d6985262e7a455f356149dff4044b34938 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Feb 2023 15:45:41 +0300 Subject: [PATCH 049/125] Use strict comparison in wp-includes/bookmark.php --- src/wp-includes/bookmark.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/bookmark.php b/src/wp-includes/bookmark.php index 37a25a80f61ff..3f4708c6958de 100644 --- a/src/wp-includes/bookmark.php +++ b/src/wp-includes/bookmark.php @@ -33,7 +33,7 @@ function get_bookmark( $bookmark, $output = OBJECT, $filter = 'raw' ) { wp_cache_add( $bookmark->link_id, $bookmark, 'bookmark' ); $_bookmark = $bookmark; } else { - if ( isset( $GLOBALS['link'] ) && ( $GLOBALS['link']->link_id == $bookmark ) ) { + if ( isset( $GLOBALS['link'] ) && ( $GLOBALS['link']->link_id === $bookmark ) ) { $_bookmark = & $GLOBALS['link']; } else { $_bookmark = wp_cache_get( $bookmark, 'bookmark' ); @@ -306,7 +306,7 @@ function get_bookmarks( $args = '' ) { $query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query"; $query .= " $exclusions $inclusions $search"; $query .= " ORDER BY $orderby $order"; - if ( -1 != $parsed_args['limit'] ) { + if ( -1 !== (int) $parsed_args['limit'] ) { $query .= ' LIMIT ' . absint( $parsed_args['limit'] ); } From 3635caea96aa19e1a0f41fb5a52f2e0051def3d4 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Mar 2023 15:33:17 +0300 Subject: [PATCH 050/125] Use strict comparison in wp-includes/capabilities.php --- src/wp-includes/capabilities.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/wp-includes/capabilities.php b/src/wp-includes/capabilities.php index 2b16174666f44..c1dafc9251323 100644 --- a/src/wp-includes/capabilities.php +++ b/src/wp-includes/capabilities.php @@ -47,7 +47,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) { switch ( $cap ) { case 'remove_user': // In multisite the user must be a super admin to remove themselves. - if ( isset( $args[0] ) && $user_id == $args[0] && ! is_super_admin( $user_id ) ) { + if ( isset( $args[0] ) && $user_id === (int) $args[0] && ! is_super_admin( $user_id ) ) { $caps[] = 'do_not_allow'; } else { $caps[] = 'remove_users'; @@ -60,7 +60,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) { case 'edit_user': case 'edit_users': // Allow user to edit themselves. - if ( 'edit_user' === $cap && isset( $args[0] ) && $user_id == $args[0] ) { + if ( 'edit_user' === $cap && isset( $args[0] ) && $user_id === (int) $args[0] ) { break; } @@ -103,7 +103,9 @@ function map_meta_cap( $cap, $user_id, ...$args ) { break; } - if ( ( get_option( 'page_for_posts' ) == $post->ID ) || ( get_option( 'page_on_front' ) == $post->ID ) ) { + if ( ( (int) get_option( 'page_for_posts' ) === $post->ID ) + || ( (int) get_option( 'page_on_front' ) === $post->ID ) + ) { $caps[] = 'manage_options'; break; } @@ -137,7 +139,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) { } // If the post author is set and the user is the author... - if ( $post->post_author && $user_id == $post->post_author ) { + if ( $post->post_author && $user_id === (int) $post->post_author ) { // If the post is published or scheduled... if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { $caps[] = $post_type->cap->delete_published_posts; @@ -238,7 +240,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) { } // If the post author is set and the user is the author... - if ( $post->post_author && $user_id == $post->post_author ) { + if ( $post->post_author && $user_id === (int) $post->post_author ) { // If the post is published or scheduled... if ( in_array( $post->post_status, array( 'publish', 'future' ), true ) ) { $caps[] = $post_type->cap->edit_published_posts; @@ -360,7 +362,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) { break; } - if ( $post->post_author && $user_id == $post->post_author ) { + if ( $post->post_author && $user_id === (int) $post->post_author ) { $caps[] = $post_type->cap->read; } elseif ( $status_obj->private ) { $caps[] = $post_type->cap->read_private_posts; @@ -726,8 +728,8 @@ function map_meta_cap( $cap, $user_id, ...$args ) { } if ( 'delete_term' === $cap - && ( get_option( 'default_' . $term->taxonomy ) == $term->term_id - || get_option( 'default_term_' . $term->taxonomy ) == $term->term_id ) + && ( (int) get_option( 'default_' . $term->taxonomy ) === $term->term_id + || (int) get_option( 'default_term_' . $term->taxonomy ) === $term->term_id ) ) { $caps[] = 'do_not_allow'; break; From e7c63e98983bd944ba87f97d16be58f9c89445a0 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Mar 2023 15:35:17 +0300 Subject: [PATCH 051/125] Use strict comparison in wp-includes/category-template.php --- src/wp-includes/category-template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/category-template.php b/src/wp-includes/category-template.php index dcc32c417f864..9dd8cf018092a 100644 --- a/src/wp-includes/category-template.php +++ b/src/wp-includes/category-template.php @@ -568,7 +568,7 @@ function wp_list_categories( $args = '' ) { } // Descendants of exclusions should be excluded too. - if ( true == $parsed_args['hierarchical'] ) { + if ( true === (bool) $parsed_args['hierarchical'] ) { $exclude_tree = array(); if ( $parsed_args['exclude_tree'] ) { From 670dfeb558ec4c5cd4a825b025a4a3be482e0e04 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Mar 2023 15:36:47 +0300 Subject: [PATCH 052/125] Use strict comparison in wp-includes/category.php --- src/wp-includes/category.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/category.php b/src/wp-includes/category.php index 0c06c4c6ea353..ede676b5d50b2 100644 --- a/src/wp-includes/category.php +++ b/src/wp-includes/category.php @@ -149,7 +149,7 @@ function get_category_by_path( $category_path, $full_match = true, $output = OBJ foreach ( $categories as $category ) { $path = '/' . $leaf_path; $curcategory = $category; - while ( ( 0 != $curcategory->parent ) && ( $curcategory->parent != $curcategory->term_id ) ) { + while ( ( 0 !== $curcategory->parent ) && ( $curcategory->parent !== $curcategory->term_id ) ) { $curcategory = get_term( $curcategory->parent, 'category' ); if ( is_wp_error( $curcategory ) ) { @@ -159,7 +159,7 @@ function get_category_by_path( $category_path, $full_match = true, $output = OBJ $path = '/' . $curcategory->slug . $path; } - if ( $path == $full_path ) { + if ( $path === $full_path ) { $category = get_term( $category->term_id, 'category', $output ); _make_cat_compat( $category ); From e1ce1db919f0b93d4ae970844734f6df2a4dbed4 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Mar 2023 15:38:33 +0300 Subject: [PATCH 053/125] Use strict comparison in wp-includes/class-walker-category.php --- src/wp-includes/class-walker-category.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/class-walker-category.php b/src/wp-includes/class-walker-category.php index dd7252cffe386..f7b0d60d177e5 100644 --- a/src/wp-includes/class-walker-category.php +++ b/src/wp-includes/class-walker-category.php @@ -210,14 +210,14 @@ public function start_el( &$output, $data_object, $depth = 0, $args = array(), $ ); foreach ( $_current_terms as $_current_term ) { - if ( $category->term_id == $_current_term->term_id ) { + if ( $category->term_id === $_current_term->term_id ) { $css_classes[] = 'current-cat'; $link = str_replace( 'term_id == $_current_term->parent ) { + } elseif ( $category->term_id === $_current_term->parent ) { $css_classes[] = 'current-cat-parent'; } while ( $_current_term->parent ) { - if ( $category->term_id == $_current_term->parent ) { + if ( $category->term_id === $_current_term->parent ) { $css_classes[] = 'current-cat-ancestor'; break; } From 210cfc629974e973b294cd35d61d8d3e90153599 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Mar 2023 15:41:46 +0300 Subject: [PATCH 054/125] Use strict comparison wp-includes/class-walker-comment.php --- src/wp-includes/class-walker-comment.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/wp-includes/class-walker-comment.php b/src/wp-includes/class-walker-comment.php index dfc8ccd39daf4..bd29728942ce5 100644 --- a/src/wp-includes/class-walker-comment.php +++ b/src/wp-includes/class-walker-comment.php @@ -279,7 +279,7 @@ public function filter_comment_text( $comment_text, $comment ) { $commenter = wp_get_current_commenter(); $show_pending_links = ! empty( $commenter['comment_author'] ); - if ( $comment && '0' == $comment->comment_approved && ! $show_pending_links ) { + if ( $comment && '0' === $comment->comment_approved && ! $show_pending_links ) { $comment_text = wp_kses( $comment_text, array() ); } @@ -321,14 +321,14 @@ protected function comment( $comment, $depth, $args ) {
comment_approved && ! $show_pending_links ) { + if ( '0' === $comment->comment_approved && ! $show_pending_links ) { $comment_author = get_comment_author( $comment ); } @@ -339,7 +339,7 @@ protected function comment( $comment, $depth, $args ) { ); ?>
- comment_approved ) : ?> + comment_approved ) : ?>
@@ -424,14 +424,14 @@ protected function html5_comment( $comment, $depth, $args ) {
comment_approved && ! $show_pending_links ) { + if ( '0' === $comment->comment_approved && ! $show_pending_links ) { $comment_author = get_comment_author( $comment ); } @@ -461,7 +461,7 @@ protected function html5_comment( $comment, $depth, $args ) { ?>
- comment_approved ) : ?> + comment_approved ) : ?>
@@ -471,7 +471,7 @@ protected function html5_comment( $comment, $depth, $args ) { comment_approved || $show_pending_links ) { + if ( '1' === $comment->comment_approved || $show_pending_links ) { comment_reply_link( array_merge( $args, From 3f665dfdccdf4ed0230fbb48ab78008124859379 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 2 Mar 2023 15:42:53 +0300 Subject: [PATCH 055/125] Use strict comparison in wp-includes/class-walker-page-dropdown.php --- src/wp-includes/class-walker-page-dropdown.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/class-walker-page-dropdown.php b/src/wp-includes/class-walker-page-dropdown.php index 5e77d2dd260d2..4c940c1722006 100644 --- a/src/wp-includes/class-walker-page-dropdown.php +++ b/src/wp-includes/class-walker-page-dropdown.php @@ -69,7 +69,7 @@ public function start_el( &$output, $data_object, $depth = 0, $args = array(), $ } $output .= "\t