Make WordPress Core


Ignore:
Timestamp:
02/10/2021 05:38:23 AM (4 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 ) {
Note: See TracChangeset for help on using the changeset viewer.