From fc8fa6a615083419689d36b785908b79ad153c73 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 8 Feb 2025 15:30:08 +0000 Subject: [PATCH] Coding Standards: Use strict comparison in `WP_Query::is_page()` and `::is_single()`. Follow-up to [29039]. Props aristath, poena, afercia, SergeyBiryukov. See #62279. git-svn-id: https://develop.svn.wordpress.org/trunk@59788 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-query.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-query.php b/src/wp-includes/class-wp-query.php index 51cd8b1084e2e..06b1e582a7b2c 100644 --- a/src/wp-includes/class-wp-query.php +++ b/src/wp-includes/class-wp-query.php @@ -4533,9 +4533,10 @@ public function is_page( $page = '' ) { if ( ! strpos( $pagepath, '/' ) ) { continue; } + $pagepath_obj = get_page_by_path( $pagepath ); - if ( $pagepath_obj && ( $pagepath_obj->ID == $page_obj->ID ) ) { + if ( $pagepath_obj && ( $pagepath_obj->ID === $page_obj->ID ) ) { return true; } } @@ -4643,9 +4644,10 @@ public function is_single( $post = '' ) { if ( ! strpos( $postpath, '/' ) ) { continue; } + $postpath_obj = get_page_by_path( $postpath, OBJECT, $post_obj->post_type ); - if ( $postpath_obj && ( $postpath_obj->ID == $post_obj->ID ) ) { + if ( $postpath_obj && ( $postpath_obj->ID === $post_obj->ID ) ) { return true; } }