Post Template: Pass the post ID to `the_guid` and `get_the_guid` filters.

Props danielbachhuber for initial patch.
Fixes #35015.
Built from https://develop.svn.wordpress.org/trunk@35867


git-svn-id: http://core.svn.wordpress.org/trunk@35831 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2015-12-11 16:39:26 +00:00
parent 70330165c4
commit 6d90a7b0cb
2 changed files with 20 additions and 10 deletions

View File

@ -169,9 +169,14 @@ function get_the_title( $post = 0 ) {
* *
* @since 1.5.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. * Filter the escaped Global Unique Identifier (guid) of the post.
* *
@ -179,9 +184,10 @@ function the_guid( $id = 0 ) {
* *
* @see get_the_guid() * @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 * @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 * @return string
*/ */
function get_the_guid( $id = 0 ) { function get_the_guid( $post = 0 ) {
$post = get_post($id); $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. * Filter the Global Unique Identifier (guid) of the post.
* *
* @since 1.5.0 * @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 );
} }
/** /**

View File

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