| 331 | |
| 332 | public function test_shortlink_post_statuses_filter() { |
| 333 | update_option( 'permalink_structure','/%postname%/' ); |
| 334 | register_post_type( 'wptests_pt', array( 'public' => true, 'rewrite' => array( 'slug' => 'wptests_pt' ) ) ); |
| 335 | flush_rewrite_rules(); |
| 336 | |
| 337 | $p = $this->factory->post->create( array( |
| 338 | 'post_title' => 'from the future', |
| 339 | 'post_status' => 'publish', |
| 340 | 'post_date' => strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 day' ) ) |
| 341 | ) ); |
| 342 | $cpt_p = $this->factory->post->create( array( |
| 343 | 'post_title' => 'cpt from the future', |
| 344 | 'post_type' => 'wptests_pt', |
| 345 | 'post_status' => 'publish', |
| 346 | 'post_date' => strftime( '%Y-%m-%d %H:%M:%S', strtotime( '+1 day' ) ) |
| 347 | ) ); |
| 348 | |
| 349 | $pretty_permalink = site_url( 'from-the-future' ); |
| 350 | $cpt_pretty_permalink = add_query_arg( array( |
| 351 | 'wptests_pt' => 'cpt-from-the-future', |
| 352 | ), trailingslashit( home_url() ) ); |
| 353 | |
| 354 | add_filter( 'shortlink_post_statuses', function( $statuses ) { |
| 355 | unset( $statuses[ array_search( 'future', $statuses ) ] ); |
| 356 | return $statuses; |
| 357 | } ); |
| 358 | |
| 359 | $this->assertEquals( $pretty_permalink, get_permalink( $p ) ); |
| 360 | $this->assertEquals( $cpt_pretty_permalink, get_permalink( $cpt_p ) ); |
| 361 | } |