Make WordPress Core

Changeset 50282


Ignore:
Timestamp:
02/10/2021 05:38:23 AM (6 years ago)
Author:
peterwilsoncc
Message:

Canonical: Rename wp_force_plain_ugly_permalink() to match UI terminology.

Rename wp_force_plain_ugly_permalink() to wp_force_plain_post_permalink() to match terminology used in the WordPress dashboard.

Follow up to [50132].
Props SergeyBiryukov.
Fixes #5272.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/post.php

    r50255 r50282  
    13581358        $original_name   = $post->post_name;
    13591359
    1360         // Hack: get_permalink() would return ugly permalink 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.
    13611361        if ( in_array( $post->post_status, array( 'draft', 'pending', 'future' ), true ) ) {
    13621362                $post->post_status = 'publish';
  • trunk/src/wp-includes/link-template.php

    r50168 r50282  
    9191
    9292/**
    93  * Determine whether post should always use an ugly permalink structure.
     93 * Determine whether post should always use a plain permalink structure.
    9494 *
    9595 * @since 5.7.0
     
    9999 *                                 If omitted, a sample link is generated if a post object is passed
    100100 *                                 with the filter property set to 'sample'.
    101  * @return bool Whether to use an ugly permalink structure.
    102  */
    103 function wp_force_ugly_post_permalink( $post = null, $sample = null ) {
     101 * @return bool Whether to use a plain permalink structure.
     102 */
     103function wp_force_plain_post_permalink( $post = null, $sample = null ) {
    104104        if (
    105105                null === $sample &&
     
    126126
    127127        if (
    128                 // Publicly viewable links never have ugly permalinks.
     128                // Publicly viewable links never have plain permalinks.
    129129                is_post_status_viewable( $post_status_obj ) ||
    130130                (
    131                         // Private posts don't have ugly links if the user can read them.
     131                        // Private posts don't have plain permalinks if the user can read them.
    132132                        $post_status_obj->private &&
    133133                        current_user_can( 'read_post', $post->ID )
    134134                ) ||
    135                 // Protected posts don't have ugly links if getting a sample URL.
     135                // Protected posts don't have plain links if getting a sample URL.
    136136                ( $post_status_obj->protected && $sample )
    137137        ) {
     
    219219        if (
    220220                $permalink &&
    221                 ! wp_force_ugly_post_permalink( $post )
     221                ! wp_force_plain_post_permalink( $post )
    222222        ) {
    223223
     
    330330        $slug = $post->post_name;
    331331
    332         $force_ugly_link = wp_force_ugly_post_permalink( $post );
     332        $force_plain_link = wp_force_plain_post_permalink( $post );
    333333
    334334        $post_type = get_post_type_object( $post->post_type );
     
    338338        }
    339339
    340         if ( ! empty( $post_link ) && ( ! $force_ugly_link || $sample ) ) {
     340        if ( ! empty( $post_link ) && ( ! $force_plain_link || $sample ) ) {
    341341                if ( ! $leavename ) {
    342342                        $post_link = str_replace( "%$post->post_type%", $slug, $post_link );
     
    344344                $post_link = home_url( user_trailingslashit( $post_link ) );
    345345        } 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 ) ) {
    347347                        $post_link = add_query_arg( $post_type->query_var, $slug, '' );
    348348                } else {
     
    426426        $post = get_post( $post );
    427427
    428         $force_ugly_link = wp_force_ugly_post_permalink( $post );
     428        $force_plain_link = wp_force_plain_post_permalink( $post );
    429429
    430430        $link = $wp_rewrite->get_page_permastruct();
    431431
    432         if ( ! empty( $link ) && ( ( isset( $post->post_status ) && ! $force_ugly_link ) || $sample ) ) {
     432        if ( ! empty( $link ) && ( ( isset( $post->post_status ) && ! $force_plain_link ) || $sample ) ) {
    433433                if ( ! $leavename ) {
    434434                        $link = str_replace( '%pagename%', get_page_uri( $post ), $link );
     
    470470        $link = false;
    471471
    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.
    477477        if (
    478478                $parent_id &&
     
    487487        }
    488488
    489         if ( $force_ugly_link || ! $parent_valid ) {
     489        if ( $force_plain_link || ! $parent_valid ) {
    490490                $link = false;
    491491        } elseif ( $wp_rewrite->using_permalinks() && $parent ) {
  • trunk/tests/phpunit/tests/canonical/postStatus.php

    r50132 r50282  
    216216         *
    217217         * @ticket 5272
    218          * @dataProvider data_canonical_redirects_to_ugly_permalinks
     218         * @dataProvider data_canonical_redirects_to_plain_permalinks
    219219         *
    220220         * @param string $post_key  Post key used for creating fixtures.
     
    223223         * @param string $expected  Expected URL.
    224224         */
    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 ) {
    226226                wp_set_current_user( self::$users[ $user_role ] );
    227227                $this->set_permalink_structure( '' );
     
    240240
    241241        /**
    242          * Data provider for test_canonical_redirects_to_ugly_permalinks.
     242         * Data provider for test_canonical_redirects_to_plain_permalinks.
    243243         *
    244244         * @return array[] Array of arguments for tests {
     
    249249         * }
    250250         */
    251         function data_canonical_redirects_to_ugly_permalinks() {
     251        function data_canonical_redirects_to_plain_permalinks() {
    252252                $data              = array();
    253253                $all_user_list     = array( 'anon', 'subscriber', 'content_author', 'editor' );
     
    264264                        foreach ( $all_user_list as $user ) {
    265265                                /*
    266                                  * In the event `redirect_canonical()` is updated to redirect ugly permalinks
    267                                  * to a canonical ugly version, 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.
    268268                                 */
    269269                                $data[] = array(
     
    302302                        foreach ( $select_allow_list as $user ) {
    303303                                /*
    304                                  * In the event `redirect_canonical()` is updated to redirect ugly permalinks
    305                                  * to a canonical ugly version, 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.
    306306                                 */
    307307                                $data[] = array(
     
    338338                        foreach ( $select_block_list as $user ) {
    339339                                /*
    340                                  * In the event `redirect_canonical()` is updated to redirect ugly permalinks
    341                                  * to a canonical ugly version, 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.
    342342                                 */
    343343                                $data[] = array(
     
    376376                        foreach ( $all_user_list as $user ) {
    377377                                /*
    378                                  * In the event `redirect_canonical()` is updated to redirect ugly permalinks
    379                                  * to a canonical ugly version, 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.
    380380                                 */
    381381                                $data[] = array(
     
    414414                        foreach ( $all_user_list as $user ) {
    415415                                /*
    416                                  * In the event `redirect_canonical()` is updated to redirect ugly permalinks
    417                                  * to a canonical ugly version, 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.
    418418                                 */
    419419                                $data[] = array(
Note: See TracChangeset for help on using the changeset viewer.