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.
Built from https://develop.svn.wordpress.org/trunk@36319


git-svn-id: http://core.svn.wordpress.org/trunk@36286 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Pascal Birchler 2016-01-15 14:47:26 +00:00
parent 19d4304565
commit 10be93190e
2 changed files with 8 additions and 6 deletions

View File

@ -357,15 +357,17 @@ function the_excerpt() {
* Retrieve the post excerpt.
*
* @since 0.71
* @since 4.5.0 Introduced the `$post` parameter.
*
* @param mixed $deprecated Not used.
* @return string
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
* @return string Post excerpt.
*/
function get_the_excerpt( $deprecated = '' ) {
if ( !empty( $deprecated ) )
function get_the_excerpt( $post = null ) {
if ( is_bool( $post ) ) {
_deprecated_argument( __FUNCTION__, '2.3' );
}
$post = get_post();
$post = get_post( $post );
if ( empty( $post ) ) {
return '';
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-alpha-1452865332638';
$wp_version = '4.5-alpha-1452869232832';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.