From d28dd189b8fd64c1ab7256d92d0179316fbef28a Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 22 Mar 2024 22:07:11 +0000 Subject: [PATCH] Coding Standards: Use strict comparison in `wp-includes/link-template.php`. Follow-up to [4475], [6365], [8706], [9296], [9318], [14141], [15819], [21364], [27802]. Props aristath, poena, afercia, SergeyBiryukov. See #60700. Built from https://develop.svn.wordpress.org/trunk@57867 git-svn-id: http://core.svn.wordpress.org/trunk@57368 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/link-template.php | 25 ++++++++++++++----------- wp-includes/version.php | 2 +- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index a782edfb85..faf07a8003 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -391,7 +391,7 @@ function get_post_permalink( $post = 0, $leavename = false, $sample = false ) { function get_page_link( $post = false, $leavename = false, $sample = false ) { $post = get_post( $post ); - if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID ) { + if ( 'page' === get_option( 'show_on_front' ) && (int) get_option( 'page_on_front' ) === $post->ID ) { $link = home_url( '/' ); } else { $link = _get_page_link( $post, $leavename, $sample ); @@ -701,7 +701,7 @@ function get_feed_link( $feed = '' ) { $permalink = $wp_rewrite->get_comment_feed_permastruct(); } - if ( get_default_feed() == $feed ) { + if ( get_default_feed() === $feed ) { $feed = ''; } @@ -763,7 +763,7 @@ function get_post_comments_feed_link( $post_id = 0, $feed = '' ) { $unattached = 'attachment' === $post->post_type && 0 === (int) $post->post_parent; if ( get_option( 'permalink_structure' ) ) { - if ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post_id ) { + if ( 'page' === get_option( 'show_on_front' ) && (int) get_option( 'page_on_front' ) === $post_id ) { $url = _get_page_link( $post_id ); } else { $url = get_permalink( $post_id ); @@ -777,7 +777,7 @@ function get_post_comments_feed_link( $post_id = 0, $feed = '' ) { $url = add_query_arg( 'attachment_id', $post_id, $url ); } else { $url = trailingslashit( $url ) . 'feed'; - if ( get_default_feed() != $feed ) { + if ( get_default_feed() !== $feed ) { $url .= "/$feed"; } $url = user_trailingslashit( $url, 'single_feed' ); @@ -879,7 +879,7 @@ function get_author_feed_link( $author_id, $feed = '' ) { $link = home_url( "?feed=$feed&author=" . $author_id ); } else { $link = get_author_posts_url( $author_id ); - if ( get_default_feed() == $feed ) { + if ( get_default_feed() === $feed ) { $feed_link = 'feed'; } else { $feed_link = "feed/$feed"; @@ -962,7 +962,7 @@ function get_term_feed_link( $term, $taxonomy = '', $feed = '' ) { } } else { $link = get_term_link( $term, $term->taxonomy ); - if ( get_default_feed() == $feed ) { + if ( get_default_feed() === $feed ) { $feed_link = 'feed'; } else { $feed_link = "feed/$feed"; @@ -1374,7 +1374,7 @@ function get_post_type_archive_feed_link( $post_type, $feed = '' ) { if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) && $post_type_obj->rewrite['feeds'] ) { $link = trailingslashit( $link ); $link .= 'feed/'; - if ( $feed != $default_feed ) { + if ( $feed !== $default_feed ) { $link .= "$feed/"; } } else { @@ -1737,7 +1737,7 @@ function get_edit_user_link( $user_id = null ) { return ''; } - if ( get_current_user_id() == $user->ID ) { + if ( get_current_user_id() === $user->ID ) { $link = get_edit_profile_url( $user->ID ); } else { $link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) ); @@ -3056,12 +3056,13 @@ function _navigation_markup( $links, $css_class = 'posts-navigation', $screen_re function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) { global $wp_rewrite; - $pagenum = (int) $pagenum; + $pagenum = (int) $pagenum; + $max_page = (int) $max_page; $result = get_permalink(); if ( 'newest' === get_option( 'default_comments_page' ) ) { - if ( $pagenum != $max_page ) { + if ( $pagenum !== $max_page ) { if ( $wp_rewrite->using_permalinks() ) { $result = user_trailingslashit( trailingslashit( $result ) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged' ); } else { @@ -4154,7 +4155,9 @@ function wp_get_shortlink( $id = 0, $context = 'post', $allow_slugs = true ) { if ( ! empty( $post_id ) ) { $post_type = get_post_type_object( $post->post_type ); - if ( 'page' === $post->post_type && get_option( 'page_on_front' ) == $post->ID && 'page' === get_option( 'show_on_front' ) ) { + if ( 'page' === $post->post_type + && 'page' === get_option( 'show_on_front' ) && (int) get_option( 'page_on_front' ) === $post->ID + ) { $shortlink = home_url( '/' ); } elseif ( $post_type && $post_type->public ) { $shortlink = home_url( '?p=' . $post_id ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 814a3fa3e4..473aedc297 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6-alpha-57865'; +$wp_version = '6.6-alpha-57867'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.