Changeset 33773
- Timestamp:
- 08/27/2015 08:56:54 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/post.php
r33734 r33773 1309 1309 $post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>'; 1310 1310 $display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, urldecode( $permalink ) ); 1311 $pretty_permalink = str_replace( array( '%pagename%', '%postname%' ), $post_name, urldecode( $permalink ) );1312 1311 1313 1312 $return = '<strong>' . __( 'Permalink:' ) . "</strong>\n"; … … 1325 1324 $return .= "<span id='view-post-btn'><a href='" . esc_url( $preview_link ) . "' class='button button-small' target='wp-preview-{$post->ID}'>$view_post</a></span>\n"; 1326 1325 } else { 1327 if ( empty( $pretty_permalink ) ) { 1328 $pretty_permalink = $permalink; 1326 if ( 'publish' === $post->post_status ) { 1327 // View Post button should always go to the saved permalink. 1328 $pretty_permalink = get_permalink( $post ); 1329 } else { 1330 // Allow non-published (private, future) to be viewed at a pretty permalink. 1331 $pretty_permalink = str_replace( array( '%pagename%', '%postname%' ), $post->post_name, urldecode( $permalink ) ); 1329 1332 } 1330 1333 -
trunk/tests/phpunit/tests/admin/includesPost.php
r32647 r33773 316 316 317 317 /** 318 * @ticket 32954 319 */ 320 public function test_get_sample_permalink_html_should_use_correct_permalink_for_view_post_button_when_changing_slug() { 321 global $wp_rewrite; 322 $old_permalink_structure = get_option( 'permalink_structure' ); 323 $permalink_structure = '%postname%'; 324 $wp_rewrite->set_permalink_structure( "/$permalink_structure/" ); 325 flush_rewrite_rules(); 326 327 wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); 328 329 // Published posts should use published permalink 330 $p = $this->factory->post->create( array( 'post_status' => 'publish', 'post_name' => 'foo' ) ); 331 332 $found = get_sample_permalink_html( $p, null, 'new_slug' ); 333 $post = get_post( $p ); 334 $this->assertContains( "span id='view-post-btn'><a href='" . get_option( 'home' ) . "/" . $post->post_name . "/'", $found ); 335 336 // Scheduled posts should use published permalink 337 $future_date = date( 'Y-m-d H:i:s', time() + 100 ); 338 $p = $this->factory->post->create( array( 'post_status' => 'future', 'post_name' => 'bar', 'post_date' => $future_date ) ); 339 340 $found = get_sample_permalink_html( $p, null, 'new_slug' ); 341 $post = get_post( $p ); 342 $this->assertContains( "span id='view-post-btn'><a href='" . get_option( 'home' ) . "/" . $post->post_name . "/'", $found ); 343 344 // Draft posts should use preview link 345 $p = $this->factory->post->create( array( 'post_status' => 'draft', 'post_name' => 'baz' ) ); 346 347 $found = get_sample_permalink_html( $p, null, 'new_slug' ); 348 $post = get_post( $p ); 349 350 $preview_link = get_permalink( $post->ID ); 351 $preview_link = add_query_arg( 'preview', 'true', $preview_link ); 352 353 $this->assertContains( "span id='view-post-btn'><a href='" . esc_url( $preview_link ) . "'", $found ); 354 355 $wp_rewrite->set_permalink_structure( $old_permalink_structure ); 356 flush_rewrite_rules(); 357 } 358 359 /** 318 360 * @ticket 5305 319 361 */
Note: See TracChangeset
for help on using the changeset viewer.