mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
After [31114] and [31323], 'View Post' generated in get_sample_permalink_html() should go to pretty permalink.
`get_permalink()` will return a non-pretty permalink for future posts, which breaks some user workflows that expect View Post to lead to a page with the pretty permalink. Fixes #30910. git-svn-id: https://develop.svn.wordpress.org/trunk@32002 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -269,4 +269,48 @@ class Tests_Admin_includesPost extends WP_UnitTestCase {
|
||||
$wp_rewrite->set_permalink_structure( $old_permalink_structure );
|
||||
flush_rewrite_rules();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 30910
|
||||
*/
|
||||
public function test_get_sample_permalink_html_should_use_default_permalink_for_view_post_button_when_pretty_permalinks_are_disabled() {
|
||||
global $wp_rewrite;
|
||||
$old_permalink_structure = get_option( 'permalink_structure' );
|
||||
$wp_rewrite->set_permalink_structure( '' );
|
||||
flush_rewrite_rules();
|
||||
|
||||
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
|
||||
|
||||
$future_date = date( 'Y-m-d H:i:s', time() + 100 );
|
||||
$p = $this->factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );
|
||||
|
||||
$found = get_sample_permalink_html( $p );
|
||||
$this->assertContains( "span id='view-post-btn'><a href='" . get_option( 'home' ) . "/?p=$p'", $found );
|
||||
|
||||
$wp_rewrite->set_permalink_structure( $old_permalink_structure );
|
||||
flush_rewrite_rules();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 30910
|
||||
*/
|
||||
public function test_get_sample_permalink_html_should_use_pretty_permalink_for_view_post_button_when_pretty_permalinks_are_enabled() {
|
||||
global $wp_rewrite;
|
||||
$old_permalink_structure = get_option( 'permalink_structure' );
|
||||
$permalink_structure = '%postname%';
|
||||
$wp_rewrite->set_permalink_structure( "/$permalink_structure/" );
|
||||
flush_rewrite_rules();
|
||||
|
||||
wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
|
||||
|
||||
$future_date = date( 'Y-m-d H:i:s', time() + 100 );
|
||||
$p = $this->factory->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );
|
||||
|
||||
$found = get_sample_permalink_html( $p );
|
||||
$post = get_post( $p );
|
||||
$this->assertContains( "span id='view-post-btn'><a href='" . get_option( 'home' ) . "/" . $post->post_name . "/'", $found );
|
||||
|
||||
$wp_rewrite->set_permalink_structure( $old_permalink_structure );
|
||||
flush_rewrite_rules();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user