WordPress.org

Make WordPress Core

Changeset 35867


Ignore:
Timestamp:
12/11/2015 04:38:15 PM (6 years ago)
Author:
SergeyBiryukov
Message:

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

Props danielbachhuber for initial patch.
Fixes #35015.

File:
1 edited

Legend:

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

    r35737 r35867  
    170170 * @since 1.5.0
    171171 *
    172  * @param int|WP_Post $id Optional. Post ID or post object.
    173  */
    174 function the_guid( $id = 0 ) {
     172 * @param int|WP_Post $post Optional. Post ID or post object. Default is global $post.
     173 */
     174function the_guid( $post = 0 ) {
     175    $post = get_post( $post );
     176
     177    $guid = isset( $post->guid ) ? get_the_guid( $post ) : '';
     178    $id   = isset( $post->ID ) ? $post->ID : 0;
     179
    175180    /**
    176181     * Filter the escaped Global Unique Identifier (guid) of the post.
     
    180185     * @see get_the_guid()
    181186     *
    182      * @param string $post_guid Escaped Global Unique Identifier (guid) of the post.
     187     * @param string $guid Escaped Global Unique Identifier (guid) of the post.
     188     * @param int    $id   The post ID.
    183189     */
    184     echo apply_filters( 'the_guid', get_the_guid( $id ) );
     190    echo apply_filters( 'the_guid', $guid, $id );
    185191}
    186192
     
    194200 * @since 1.5.0
    195201 *
    196  * @param int|WP_Post $id Optional. Post ID or post object.
     202 * @param int|WP_Post $post Optional. Post ID or post object. Default is global $post.
    197203 * @return string
    198204 */
    199 function get_the_guid( $id = 0 ) {
    200     $post = get_post($id);
     205function get_the_guid( $post = 0 ) {
     206    $post = get_post( $post );
     207
     208    $guid = isset( $post->guid ) ? $post->guid : '';
     209    $id   = isset( $post->ID ) ? $post->ID : 0;
    201210
    202211    /**
     
    205214     * @since 1.5.0
    206215     *
    207      * @param string $post_guid Global Unique Identifier (guid) of the post.
     216     * @param string $guid Global Unique Identifier (guid) of the post.
     217     * @param int    $id   The post ID.
    208218     */
    209     return apply_filters( 'get_the_guid', $post->guid );
     219    return apply_filters( 'get_the_guid', $guid, $id );
    210220}
    211221
Note: See TracChangeset for help on using the changeset viewer.