WordPress.org

Make WordPress Core

Changeset 35233


Ignore:
Timestamp:
10/17/2015 12:43:54 AM (4 years ago)
Author:
jorbin
Message:

Improve get_post_permalink compatibility with non standard post status

This adds a new filter named get_post_status to the function named get_post_status which can be used to make additional post types behave like unpublished post status in get_post_permalink.

Props misterbisson, antpb, iamfriendly
Fixes #23458

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/link-template.php

    r35170 r35233  
    260260    $slug = $post->post_name;
    261261
    262     $draft_or_pending = isset( $post->post_status ) && in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ) );
     262    $draft_or_pending = get_post_status( $id ) && in_array( get_post_status( $id ), array( 'draft', 'pending', 'auto-draft', 'future' ) );
    263263
    264264    $post_type = get_post_type_object($post->post_type);
  • trunk/src/wp-includes/post-functions.php

    r35170 r35233  
    574574    }
    575575
    576     return $post->post_status;
     576    /**
     577     * Filters the post status.
     578     *
     579     * @since 4.4.0
     580     *
     581     * @param string  $post->post_status The status of the post.
     582     */
     583    return apply_filters( 'get_post_status', $post->post_status, $post );
    577584}
    578585
Note: See TracChangeset for help on using the changeset viewer.