diff --git a/src/wp-includes/canonical.php b/src/wp-includes/canonical.php
index 184fb756e8..185f9bfec7 100644
a
|
b
|
function redirect_guess_404_permalink() { |
952 | 952 | } |
953 | 953 | |
954 | 954 | // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
955 | | $post_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE $where AND post_status = 'publish'" ); |
956 | | |
| 955 | $post_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE $where AND post_status IN ('" . implode( "', '", get_post_stati( array( 'public' => true ) ) ) . "')" ); |
957 | 956 | if ( ! $post_id ) { |
958 | 957 | return false; |
959 | 958 | } |
diff --git a/tests/phpunit/tests/canonical.php b/tests/phpunit/tests/canonical.php
index bd0b68c038..8cd0d973e8 100644
a
|
b
|
class Tests_Canonical extends WP_Canonical_UnitTestCase { |
275 | 275 | $this->assertFalse( redirect_guess_404_permalink() ); |
276 | 276 | } |
277 | 277 | |
| 278 | /** |
| 279 | * Ensure public posts with custom statuses are guessed |
| 280 | * |
| 281 | * @ticket 47911 |
| 282 | */ |
| 283 | public function test_redirect_guess_404_permalink_with_custom_status_public() { |
| 284 | register_post_status( 'custom', array( 'public' => true ) ); |
| 285 | |
| 286 | $post = self::factory()->post->create( |
| 287 | array( |
| 288 | 'post_title' => 'custom-status-public-guess-404-permalink', |
| 289 | 'post_status' => 'custom', |
| 290 | ) |
| 291 | ); |
| 292 | |
| 293 | $this->go_to( 'custom-status-public-guess-404-permalink' ); |
| 294 | |
| 295 | $this->assertSame( get_permalink( $post ), redirect_guess_404_permalink() ); |
| 296 | } |
| 297 | |
278 | 298 | /** |
279 | 299 | * Ensure multiple post types do not throw a notice. |
280 | 300 | * |