diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php index 87f1fcac5c..20a3fb1354 100644 --- a/src/wp-admin/includes/post.php +++ b/src/wp-admin/includes/post.php @@ -1357,7 +1357,7 @@ function get_sample_permalink( $id, $title = null, $name = null ) { $original_date = $post->post_date; $original_name = $post->post_name; - // Hack: get_permalink() would return ugly permalink for drafts, so we will fake that our post is published. + // Hack: get_permalink() would return plain permalink for drafts, so we will fake that our post is published. if ( in_array( $post->post_status, array( 'draft', 'pending', 'future' ), true ) ) { $post->post_status = 'publish'; $post->post_name = sanitize_title( $post->post_name ? $post->post_name : $post->post_title, $post->ID ); diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php index 5bbfc53c60..4f4fbe6cb8 100644 --- a/src/wp-includes/link-template.php +++ b/src/wp-includes/link-template.php @@ -90,7 +90,7 @@ function permalink_anchor( $mode = 'id' ) { } /** - * Determine whether post should always use an ugly permalink structure. + * Determine whether post should always use a plain permalink structure. * * @since 5.7.0 * @@ -98,9 +98,9 @@ function permalink_anchor( $mode = 'id' ) { * @param bool|null $sample Optional. Whether to force consideration based on sample links. * If omitted, a sample link is generated if a post object is passed * with the filter property set to 'sample'. - * @return bool Whether to use an ugly permalink structure. + * @return bool Whether to use a plain permalink structure. */ -function wp_force_ugly_post_permalink( $post = null, $sample = null ) { +function wp_force_plain_post_permalink( $post = null, $sample = null ) { if ( null === $sample && is_object( $post ) && @@ -125,14 +125,14 @@ function wp_force_ugly_post_permalink( $post = null, $sample = null ) { } if ( - // Publicly viewable links never have ugly permalinks. + // Publicly viewable links never have plain permalinks. is_post_status_viewable( $post_status_obj ) || ( - // Private posts don't have ugly links if the user can read them. + // Private posts don't have plain permalinks if the user can read them. $post_status_obj->private && current_user_can( 'read_post', $post->ID ) ) || - // Protected posts don't have ugly links if getting a sample URL. + // Protected posts don't have plain links if getting a sample URL. ( $post_status_obj->protected && $sample ) ) { return false; @@ -218,7 +218,7 @@ function get_permalink( $post = 0, $leavename = false ) { if ( $permalink && - ! wp_force_ugly_post_permalink( $post ) + ! wp_force_plain_post_permalink( $post ) ) { $category = ''; @@ -329,7 +329,7 @@ function get_post_permalink( $id = 0, $leavename = false, $sample = false ) { $slug = $post->post_name; - $force_ugly_link = wp_force_ugly_post_permalink( $post ); + $force_plain_link = wp_force_plain_post_permalink( $post ); $post_type = get_post_type_object( $post->post_type ); @@ -337,13 +337,13 @@ function get_post_permalink( $id = 0, $leavename = false, $sample = false ) { $slug = get_page_uri( $post ); } - if ( ! empty( $post_link ) && ( ! $force_ugly_link || $sample ) ) { + if ( ! empty( $post_link ) && ( ! $force_plain_link || $sample ) ) { if ( ! $leavename ) { $post_link = str_replace( "%$post->post_type%", $slug, $post_link ); } $post_link = home_url( user_trailingslashit( $post_link ) ); } else { - if ( $post_type->query_var && ( isset( $post->post_status ) && ! $force_ugly_link ) ) { + if ( $post_type->query_var && ( isset( $post->post_status ) && ! $force_plain_link ) ) { $post_link = add_query_arg( $post_type->query_var, $slug, '' ); } else { $post_link = add_query_arg( @@ -425,11 +425,11 @@ function _get_page_link( $post = false, $leavename = false, $sample = false ) { $post = get_post( $post ); - $force_ugly_link = wp_force_ugly_post_permalink( $post ); + $force_plain_link = wp_force_plain_post_permalink( $post ); $link = $wp_rewrite->get_page_permastruct(); - if ( ! empty( $link ) && ( ( isset( $post->post_status ) && ! $force_ugly_link ) || $sample ) ) { + if ( ! empty( $link ) && ( ( isset( $post->post_status ) && ! $force_plain_link ) || $sample ) ) { if ( ! $leavename ) { $link = str_replace( '%pagename%', get_page_uri( $post ), $link ); } @@ -469,11 +469,11 @@ function get_attachment_link( $post = null, $leavename = false ) { $link = false; - $post = get_post( $post ); - $force_ugly_link = wp_force_ugly_post_permalink( $post ); - $parent_id = $post->post_parent; - $parent = $parent_id ? get_post( $parent_id ) : false; - $parent_valid = true; // Default for no parent. + $post = get_post( $post ); + $force_plain_link = wp_force_plain_post_permalink( $post ); + $parent_id = $post->post_parent; + $parent = $parent_id ? get_post( $parent_id ) : false; + $parent_valid = true; // Default for no parent. if ( $parent_id && ( @@ -486,7 +486,7 @@ function get_attachment_link( $post = null, $leavename = false ) { $parent_valid = false; } - if ( $force_ugly_link || ! $parent_valid ) { + if ( $force_plain_link || ! $parent_valid ) { $link = false; } elseif ( $wp_rewrite->using_permalinks() && $parent ) { if ( 'page' === $parent->post_type ) { diff --git a/tests/phpunit/tests/canonical/postStatus.php b/tests/phpunit/tests/canonical/postStatus.php index e189a72f1c..159c3792f0 100644 --- a/tests/phpunit/tests/canonical/postStatus.php +++ b/tests/phpunit/tests/canonical/postStatus.php @@ -215,14 +215,14 @@ class Tests_Canonical_PostStatus extends WP_Canonical_UnitTestCase { * Test canonical redirect does not reveal private posts presence. * * @ticket 5272 - * @dataProvider data_canonical_redirects_to_ugly_permalinks + * @dataProvider data_canonical_redirects_to_plain_permalinks * * @param string $post_key Post key used for creating fixtures. * @param string $user_role User role. * @param string $requested Requested URL. * @param string $expected Expected URL. */ - public function test_canonical_redirects_to_ugly_permalinks( $post_key, $user_role, $requested, $expected ) { + public function test_canonical_redirects_to_plain_permalinks( $post_key, $user_role, $requested, $expected ) { wp_set_current_user( self::$users[ $user_role ] ); $this->set_permalink_structure( '' ); $post = self::$posts[ $post_key ]; @@ -239,7 +239,7 @@ class Tests_Canonical_PostStatus extends WP_Canonical_UnitTestCase { } /** - * Data provider for test_canonical_redirects_to_ugly_permalinks. + * Data provider for test_canonical_redirects_to_plain_permalinks. * * @return array[] Array of arguments for tests { * @type string $post_key Post key used for creating fixtures. @@ -248,7 +248,7 @@ class Tests_Canonical_PostStatus extends WP_Canonical_UnitTestCase { * @type string $expected Expected URL. * } */ - function data_canonical_redirects_to_ugly_permalinks() { + function data_canonical_redirects_to_plain_permalinks() { $data = array(); $all_user_list = array( 'anon', 'subscriber', 'content_author', 'editor' ); $select_allow_list = array( 'content_author', 'editor' ); @@ -263,8 +263,8 @@ class Tests_Canonical_PostStatus extends WP_Canonical_UnitTestCase { foreach ( $all_user_post_status_keys as $post_key ) { foreach ( $all_user_list as $user ) { /* - * In the event `redirect_canonical()` is updated to redirect ugly permalinks - * to a canonical ugly version, these expected values can be changed. + * In the event `redirect_canonical()` is updated to redirect plain permalinks + * to a canonical plain version, these expected values can be changed. */ $data[] = array( "$post_key-page", @@ -301,8 +301,8 @@ class Tests_Canonical_PostStatus extends WP_Canonical_UnitTestCase { foreach ( $select_user_post_status_keys as $post_key ) { foreach ( $select_allow_list as $user ) { /* - * In the event `redirect_canonical()` is updated to redirect ugly permalinks - * to a canonical ugly version, these expected values can be changed. + * In the event `redirect_canonical()` is updated to redirect plain permalinks + * to a canonical plain version, these expected values can be changed. */ $data[] = array( "$post_key-page", @@ -337,8 +337,8 @@ class Tests_Canonical_PostStatus extends WP_Canonical_UnitTestCase { foreach ( $select_block_list as $user ) { /* - * In the event `redirect_canonical()` is updated to redirect ugly permalinks - * to a canonical ugly version, these expected values MUST NOT be changed. + * In the event `redirect_canonical()` is updated to redirect plain permalinks + * to a canonical plain version, these expected values MUST NOT be changed. */ $data[] = array( "$post_key-page", @@ -375,8 +375,8 @@ class Tests_Canonical_PostStatus extends WP_Canonical_UnitTestCase { foreach ( $no_user_post_status_keys as $post_key ) { foreach ( $all_user_list as $user ) { /* - * In the event `redirect_canonical()` is updated to redirect ugly permalinks - * to a canonical ugly version, these expected values MUST NOT be changed. + * In the event `redirect_canonical()` is updated to redirect plain permalinks + * to a canonical plain version, these expected values MUST NOT be changed. */ $data[] = array( "$post_key-page", @@ -413,8 +413,8 @@ class Tests_Canonical_PostStatus extends WP_Canonical_UnitTestCase { foreach ( array( 'trash' ) as $post_key ) { foreach ( $all_user_list as $user ) { /* - * In the event `redirect_canonical()` is updated to redirect ugly permalinks - * to a canonical ugly version, these expected values MUST NOT be changed. + * In the event `redirect_canonical()` is updated to redirect plain permalinks + * to a canonical plain version, these expected values MUST NOT be changed. */ $data[] = array( "$post_key-page",