WordPress.org

Make WordPress Core

Ticket #32322: link-template.diff

File link-template.diff, 1.1 KB (added by kdoole, 6 years ago)

adds a filter to the list of post types which should not receive fancy permalinks

  • wp-includes/link-template.php

     
    156156         */
    157157        $permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename );
    158158
    159         if ( '' != $permalink && !in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ) ) ) {
     159        $statuses_which_should_shortlink = apply_filters( 'shortlink_post_statuses', array(
     160                'draft',
     161                'pending',
     162                'auto-draft',
     163                'future'
     164        ) );
     165        $use_shortlink = '' === $permalink || in_array( $post->post_status, $statuses_which_should_shortlink );
     166
     167        if ( $use_shortlink ) {
     168                $permalink = home_url('?p=' . $post->ID);
     169        } else {
    160170                $unixtime = strtotime($post->post_date);
    161171
    162172                $category = '';
     
    212222                );
    213223                $permalink = home_url( str_replace($rewritecode, $rewritereplace, $permalink) );
    214224                $permalink = user_trailingslashit($permalink, 'single');
    215         } else { // if they're not using the fancy permalink option
    216                 $permalink = home_url('?p=' . $post->ID);
    217225        }
    218226
    219227        /**