From e01a52e878cc6e6638c1e1b161fc91dc51125fb2 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 11 Dec 2015 16:38:15 +0000 Subject: [PATCH] Post Template: Pass the post ID to `the_guid` and `get_the_guid` filters. Props danielbachhuber for initial patch. Fixes #35015. git-svn-id: https://develop.svn.wordpress.org/trunk@35867 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/post-template.php | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php index 3164509b8e..185bb98f8f 100644 --- a/src/wp-includes/post-template.php +++ b/src/wp-includes/post-template.php @@ -169,9 +169,14 @@ function get_the_title( $post = 0 ) { * * @since 1.5.0 * - * @param int|WP_Post $id Optional. Post ID or post object. + * @param int|WP_Post $post Optional. Post ID or post object. Default is global $post. */ -function the_guid( $id = 0 ) { +function the_guid( $post = 0 ) { + $post = get_post( $post ); + + $guid = isset( $post->guid ) ? get_the_guid( $post ) : ''; + $id = isset( $post->ID ) ? $post->ID : 0; + /** * Filter the escaped Global Unique Identifier (guid) of the post. * @@ -179,9 +184,10 @@ function the_guid( $id = 0 ) { * * @see get_the_guid() * - * @param string $post_guid Escaped Global Unique Identifier (guid) of the post. + * @param string $guid Escaped Global Unique Identifier (guid) of the post. + * @param int $id The post ID. */ - echo apply_filters( 'the_guid', get_the_guid( $id ) ); + echo apply_filters( 'the_guid', $guid, $id ); } /** @@ -193,20 +199,24 @@ function the_guid( $id = 0 ) { * * @since 1.5.0 * - * @param int|WP_Post $id Optional. Post ID or post object. + * @param int|WP_Post $post Optional. Post ID or post object. Default is global $post. * @return string */ -function get_the_guid( $id = 0 ) { - $post = get_post($id); +function get_the_guid( $post = 0 ) { + $post = get_post( $post ); + + $guid = isset( $post->guid ) ? $post->guid : ''; + $id = isset( $post->ID ) ? $post->ID : 0; /** * Filter the Global Unique Identifier (guid) of the post. * * @since 1.5.0 * - * @param string $post_guid Global Unique Identifier (guid) of the post. + * @param string $guid Global Unique Identifier (guid) of the post. + * @param int $id The post ID. */ - return apply_filters( 'get_the_guid', $post->guid ); + return apply_filters( 'get_the_guid', $guid, $id ); } /**