Make WordPress Core

Ticket #32322: 32322.diff

File 32322.diff, 2.1 KB (added by andraganescu, 6 years ago)

Refreshed patch

  • src/wp-includes/link-template.php

    diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php
    index 510d9a1..e092e1e 100644
    a b function get_permalink( $post = 0, $leavename = false ) { 
    165165         */
    166166        $permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename );
    167167
    168         if ( '' != $permalink && ! in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ) ) ) {
     168        /**
     169         * Filters the list of post statuses which should use shortlinks and avoid fancy permalinks.
     170         *
     171         * @since 4.3.0
     172         *
     173         * @param array $statuses The list of statuses
     174         */
     175        $auto_short_link_statuses = apply_filters( 'shortlink_post_statuses', array(
     176                'draft',
     177                'pending',
     178                'auto-draft',
     179                'future'
     180        ) );
     181
     182        if ( '' != $permalink && ! in_array( $post->post_status, $auto_short_link_statuses ) ) {
    169183                $unixtime = strtotime( $post->post_date );
    170184
    171185                $category = '';
    function get_post_permalink( $id = 0, $leavename = false, $sample = false ) { 
    272286
    273287        $slug = $post->post_name;
    274288
    275         $draft_or_pending = get_post_status( $post ) && in_array( get_post_status( $post ), array( 'draft', 'pending', 'auto-draft', 'future' ) );
     289        $auto_short_link_statuses = apply_filters( 'shortlink_post_statuses', array(
     290        'draft',
     291        'pending',
     292        'auto-draft',
     293        'future'
     294        ) );
     295        $draft_or_pending = get_post_status( $post ) && in_array( get_post_status( $post ), $auto_short_link_statuses );
    276296
    277297        $post_type = get_post_type_object( $post->post_type );
    278298
    function _get_page_link( $post = false, $leavename = false, $sample = false ) { 
    368388
    369389        $post = get_post( $post );
    370390
    371         $draft_or_pending = in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) );
     391        $auto_short_link_statuses = apply_filters( 'shortlink_post_statuses', array(
     392        'draft',
     393        'pending',
     394        'auto-draft',
     395        'future'
     396        ) );
     397
     398        $draft_or_pending = get_post_status( $post ) && in_array( get_post_status( $post ), $auto_short_link_statuses );
    372399
    373400        $link = $wp_rewrite->get_page_permastruct();
    374401