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:
Boone Gorges
2015-04-04 01:26:08 +00:00
parent 468da41811
commit ddb33c9aed
2 changed files with 50 additions and 1 deletions

View File

@@ -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();
}
}