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.

git-svn-id: https://develop.svn.wordpress.org/trunk@36319 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Pascal Birchler 2016-01-15 14:47:00 +00:00
parent 63e442bbb8
commit 57978063cf

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 '';
}