WordPress.org

Make WordPress Core

Changeset 36319


Ignore:
Timestamp:
01/15/2016 02:47:00 PM (4 years ago)
Author:
swissspidy
Message:

Posts: Add a $post parameter to get_the_excerpt().

This allows getting the excerpt for a specific post, similar to how most other template tags work.
A deprecation notice is thrown if a boolean value is passed, which is deprecated since 2.3 and has not been used for a long time.
Adds unit tests.

Fixes #27246.

File:
1 edited

Legend:

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

    r36112 r36319  
    358358 *
    359359 * @since 0.71
    360  *
    361  * @param mixed $deprecated Not used.
    362  * @return string
    363  */
    364 function get_the_excerpt( $deprecated = '' ) {
    365     if ( !empty( $deprecated ) )
     360 * @since 4.5.0 Introduced the `$post` parameter.
     361 *
     362 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
     363 * @return string Post excerpt.
     364 */
     365function get_the_excerpt( $post = null ) {
     366    if ( is_bool( $post ) ) {
    366367        _deprecated_argument( __FUNCTION__, '2.3' );
    367 
    368     $post = get_post();
     368    }
     369
     370    $post = get_post( $post );
    369371    if ( empty( $post ) ) {
    370372        return '';
Note: See TracChangeset for help on using the changeset viewer.