WordPress.org

Make WordPress Core

Ticket #17134: 17134.diff

File 17134.diff, 1.3 KB (added by iandunn, 3 years ago)
  • wp-includes/post-template.php

     
    119119} 
    120120 
    121121/** 
     122 * Display the slug of the current post in the WordPress Loop, or an arbitrary post. 
     123 * 
     124 * @since  
     125 * 
     126 * @param int $id Optional. ID of an arbitrary post. If none is given, uses the value of the current post inside the Loop 
     127 */ 
     128function the_slug( $id = 0 ) { 
     129        echo apply_filters( 'the_slug', get_the_slug( $id ) ); 
     130} 
     131 
     132/** 
     133 * Retrieve the slug of the current post in the WordPress Loop, or an arbitrary post. 
     134 * 
     135 * @since  
     136 *  
     137 * @uses $post 
     138 * @param int $id Optional. ID of an arbitrary post. If none is given, uses the value of the current post inside the Loop  
     139 * @return string|false String if post slug was retrieved, or false if it wasn't 
     140 */ 
     141function get_the_slug( $id = 0 ) { 
     142        global $post; 
     143                         
     144        if( $id ) { 
     145                $arbitrary_post = get_post( $id ); 
     146                $slug = is_a( $arbitrary_post, 'WP_Post' ) ? $arbitrary_post->post_name : false; 
     147        } else { 
     148                $slug = isset( $post->post_name ) ? $post->post_name : false; 
     149        } 
     150         
     151        return apply_filters( 'get_the_slug', $slug ); 
     152} 
     153 
     154/** 
    122155 * Display the Post Global Unique Identifier (guid). 
    123156 * 
    124157 * The guid will appear to be a link, but should not be used as an link to the