Changeset 50282
- Timestamp:
- 02/10/2021 05:38:23 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/post.php
r50255 r50282 1358 1358 $original_name = $post->post_name; 1359 1359 1360 // Hack: get_permalink() would return uglypermalink for drafts, so we will fake that our post is published.1360 // Hack: get_permalink() would return plain permalink for drafts, so we will fake that our post is published. 1361 1361 if ( in_array( $post->post_status, array( 'draft', 'pending', 'future' ), true ) ) { 1362 1362 $post->post_status = 'publish'; -
trunk/src/wp-includes/link-template.php
r50168 r50282 91 91 92 92 /** 93 * Determine whether post should always use a n uglypermalink structure.93 * Determine whether post should always use a plain permalink structure. 94 94 * 95 95 * @since 5.7.0 … … 99 99 * If omitted, a sample link is generated if a post object is passed 100 100 * with the filter property set to 'sample'. 101 * @return bool Whether to use a n uglypermalink structure.102 */ 103 function wp_force_ ugly_post_permalink( $post = null, $sample = null ) {101 * @return bool Whether to use a plain permalink structure. 102 */ 103 function wp_force_plain_post_permalink( $post = null, $sample = null ) { 104 104 if ( 105 105 null === $sample && … … 126 126 127 127 if ( 128 // Publicly viewable links never have uglypermalinks.128 // Publicly viewable links never have plain permalinks. 129 129 is_post_status_viewable( $post_status_obj ) || 130 130 ( 131 // Private posts don't have uglylinks if the user can read them.131 // Private posts don't have plain permalinks if the user can read them. 132 132 $post_status_obj->private && 133 133 current_user_can( 'read_post', $post->ID ) 134 134 ) || 135 // Protected posts don't have uglylinks if getting a sample URL.135 // Protected posts don't have plain links if getting a sample URL. 136 136 ( $post_status_obj->protected && $sample ) 137 137 ) { … … 219 219 if ( 220 220 $permalink && 221 ! wp_force_ ugly_post_permalink( $post )221 ! wp_force_plain_post_permalink( $post ) 222 222 ) { 223 223 … … 330 330 $slug = $post->post_name; 331 331 332 $force_ ugly_link = wp_force_ugly_post_permalink( $post );332 $force_plain_link = wp_force_plain_post_permalink( $post ); 333 333 334 334 $post_type = get_post_type_object( $post->post_type ); … … 338 338 } 339 339 340 if ( ! empty( $post_link ) && ( ! $force_ ugly_link || $sample ) ) {340 if ( ! empty( $post_link ) && ( ! $force_plain_link || $sample ) ) { 341 341 if ( ! $leavename ) { 342 342 $post_link = str_replace( "%$post->post_type%", $slug, $post_link ); … … 344 344 $post_link = home_url( user_trailingslashit( $post_link ) ); 345 345 } else { 346 if ( $post_type->query_var && ( isset( $post->post_status ) && ! $force_ ugly_link ) ) {346 if ( $post_type->query_var && ( isset( $post->post_status ) && ! $force_plain_link ) ) { 347 347 $post_link = add_query_arg( $post_type->query_var, $slug, '' ); 348 348 } else { … … 426 426 $post = get_post( $post ); 427 427 428 $force_ ugly_link = wp_force_ugly_post_permalink( $post );428 $force_plain_link = wp_force_plain_post_permalink( $post ); 429 429 430 430 $link = $wp_rewrite->get_page_permastruct(); 431 431 432 if ( ! empty( $link ) && ( ( isset( $post->post_status ) && ! $force_ ugly_link ) || $sample ) ) {432 if ( ! empty( $link ) && ( ( isset( $post->post_status ) && ! $force_plain_link ) || $sample ) ) { 433 433 if ( ! $leavename ) { 434 434 $link = str_replace( '%pagename%', get_page_uri( $post ), $link ); … … 470 470 $link = false; 471 471 472 $post = get_post( $post );473 $force_ ugly_link = wp_force_ugly_post_permalink( $post );474 $parent_id = $post->post_parent;475 $parent = $parent_id ? get_post( $parent_id ) : false;476 $parent_valid = true; // Default for no parent.472 $post = get_post( $post ); 473 $force_plain_link = wp_force_plain_post_permalink( $post ); 474 $parent_id = $post->post_parent; 475 $parent = $parent_id ? get_post( $parent_id ) : false; 476 $parent_valid = true; // Default for no parent. 477 477 if ( 478 478 $parent_id && … … 487 487 } 488 488 489 if ( $force_ ugly_link || ! $parent_valid ) {489 if ( $force_plain_link || ! $parent_valid ) { 490 490 $link = false; 491 491 } elseif ( $wp_rewrite->using_permalinks() && $parent ) { -
trunk/tests/phpunit/tests/canonical/postStatus.php
r50132 r50282 216 216 * 217 217 * @ticket 5272 218 * @dataProvider data_canonical_redirects_to_ ugly_permalinks218 * @dataProvider data_canonical_redirects_to_plain_permalinks 219 219 * 220 220 * @param string $post_key Post key used for creating fixtures. … … 223 223 * @param string $expected Expected URL. 224 224 */ 225 public function test_canonical_redirects_to_ ugly_permalinks( $post_key, $user_role, $requested, $expected ) {225 public function test_canonical_redirects_to_plain_permalinks( $post_key, $user_role, $requested, $expected ) { 226 226 wp_set_current_user( self::$users[ $user_role ] ); 227 227 $this->set_permalink_structure( '' ); … … 240 240 241 241 /** 242 * Data provider for test_canonical_redirects_to_ ugly_permalinks.242 * Data provider for test_canonical_redirects_to_plain_permalinks. 243 243 * 244 244 * @return array[] Array of arguments for tests { … … 249 249 * } 250 250 */ 251 function data_canonical_redirects_to_ ugly_permalinks() {251 function data_canonical_redirects_to_plain_permalinks() { 252 252 $data = array(); 253 253 $all_user_list = array( 'anon', 'subscriber', 'content_author', 'editor' ); … … 264 264 foreach ( $all_user_list as $user ) { 265 265 /* 266 * In the event `redirect_canonical()` is updated to redirect uglypermalinks267 * to a canonical uglyversion, these expected values can be changed.266 * In the event `redirect_canonical()` is updated to redirect plain permalinks 267 * to a canonical plain version, these expected values can be changed. 268 268 */ 269 269 $data[] = array( … … 302 302 foreach ( $select_allow_list as $user ) { 303 303 /* 304 * In the event `redirect_canonical()` is updated to redirect uglypermalinks305 * to a canonical uglyversion, these expected values can be changed.304 * In the event `redirect_canonical()` is updated to redirect plain permalinks 305 * to a canonical plain version, these expected values can be changed. 306 306 */ 307 307 $data[] = array( … … 338 338 foreach ( $select_block_list as $user ) { 339 339 /* 340 * In the event `redirect_canonical()` is updated to redirect uglypermalinks341 * to a canonical uglyversion, these expected values MUST NOT be changed.340 * In the event `redirect_canonical()` is updated to redirect plain permalinks 341 * to a canonical plain version, these expected values MUST NOT be changed. 342 342 */ 343 343 $data[] = array( … … 376 376 foreach ( $all_user_list as $user ) { 377 377 /* 378 * In the event `redirect_canonical()` is updated to redirect uglypermalinks379 * to a canonical uglyversion, these expected values MUST NOT be changed.378 * In the event `redirect_canonical()` is updated to redirect plain permalinks 379 * to a canonical plain version, these expected values MUST NOT be changed. 380 380 */ 381 381 $data[] = array( … … 414 414 foreach ( $all_user_list as $user ) { 415 415 /* 416 * In the event `redirect_canonical()` is updated to redirect uglypermalinks417 * to a canonical uglyversion, these expected values MUST NOT be changed.416 * In the event `redirect_canonical()` is updated to redirect plain permalinks 417 * to a canonical plain version, these expected values MUST NOT be changed. 418 418 */ 419 419 $data[] = array(
Note: See TracChangeset
for help on using the changeset viewer.