WordPress.org

Make WordPress Core

Ticket #11624: 11624.2.diff

File 11624.2.diff, 7.3 KB (added by scribu, 8 years ago)

Replace all instances

  • wp-includes/post-template.php

     
    1212 * Display the ID of the current item in the WordPress Loop.
    1313 *
    1414 * @since 0.71
    15  * @uses $id
    1615 */
    1716function the_ID() {
    18         global $id;
    19         echo $id;
     17        echo get_the_ID();
    2018}
    2119
    2220/**
    2321 * Retrieve the ID of the current item in the WordPress Loop.
    2422 *
    2523 * @since 2.1.0
    26  * @uses $id
    2724 *
    28  * @return unknown
     25 * @return int
    2926 */
    3027function get_the_ID() {
    31         global $id;
    32         return $id;
     28        global $post;
     29        return $post->ID;
    3330}
    3431
    3532/**
     
    181178 * @return string
    182179 */
    183180function get_the_content($more_link_text = null, $stripteaser = 0) {
    184         global $id, $post, $more, $page, $pages, $multipage, $preview;
     181        global $post, $more, $page, $pages, $multipage, $preview;
    185182
    186183        if ( null === $more_link_text )
    187184                $more_link_text = __( '(more...)' );
     
    216213        $output .= $teaser;
    217214        if ( count($content) > 1 ) {
    218215                if ( $more ) {
    219                         $output .= '<span id="more-' . $id . '"></span>' . $content[1];
     216                        $output .= '<span id="more-' . $post->ID . '"></span>' . $content[1];
    220217                } else {
    221218                        if ( ! empty($more_link_text) )
    222                                 $output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink() . "#more-$id\" class=\"more-link\">$more_link_text</a>", $more_link_text );
     219                                $output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink() . "#more-{$post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text );
    223220                        $output = force_balance_tags($output);
    224221                }
    225222
  • wp-includes/post.php

     
    12671267 * @return array
    12681268 */
    12691269function get_post_custom($post_id = 0) {
    1270         global $id;
    1271 
    12721270        if ( !$post_id )
    1273                 $post_id = (int) $id;
     1271                $post_id = get_the_ID();
    12741272
    12751273        $post_id = (int) $post_id;
    12761274
     
    13351333 * @return bool Whether post is sticky.
    13361334 */
    13371335function is_sticky($post_id = null) {
    1338         global $id;
     1336        if ( !$post_id )
     1337                $post_id = get_the_ID();
    13391338
    13401339        $post_id = absint($post_id);
    13411340
    1342         if ( !$post_id )
    1343                 $post_id = absint($id);
    1344 
    13451341        $stickies = get_option('sticky_posts');
    13461342
    13471343        if ( !is_array($stickies) )
  • wp-includes/comment-template.php

     
    545545 * @return int The number of comments a post has
    546546 */
    547547function get_comments_number( $post_id = 0 ) {
    548         global $id;
    549         $post_id = (int) $post_id;
    550 
    551548        if ( !$post_id )
    552                 $post_id = (int) $id;
     549                $post_id = get_the_ID();
    553550
     551        $post_id = absint($post_id);
     552
    554553        $post = get_post($post_id);
    555554        if ( ! isset($post->comment_count) )
    556555                $count = 0;
     
    564563 * Display the language string for the number of comments the current post has.
    565564 *
    566565 * @since 0.71
    567  * @uses $id
    568566 * @uses apply_filters() Calls the 'comments_number' hook on the output and number of comments respectively.
    569567 *
    570568 * @param string $zero Text for no comments
     
    573571 * @param string $deprecated Not used.
    574572 */
    575573function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
    576         global $id;
    577 
    578574        if ( !empty( $deprecated ) )
    579575                _deprecated_argument( __FUNCTION__, '1.3' );
    580576
    581         $number = get_comments_number($id);
     577        $number = get_comments_number(get_the_ID());
    582578
    583579        if ( $number > 1 )
    584580                $output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% Comments') : $more);
     
    703699 *
    704700 * @since 1.5.0
    705701 * @uses apply_filters() Calls 'trackback_url' on the resulting trackback URL
    706  * @uses $id
    707702 *
    708703 * @return string The trackback URL after being filtered
    709704 */
    710705function get_trackback_url() {
    711         global $id;
    712706        if ( '' != get_option('permalink_structure') ) {
    713707                $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback');
    714708        } else {
    715                 $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . $id;
     709                $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID();
    716710        }
    717711        return apply_filters('trackback_url', $tb_url);
    718712}
     
    844838 * @since 1.5.0
    845839 * @global array $comment List of comment objects for the current post
    846840 * @uses $wpdb
    847  * @uses $id
    848841 * @uses $post
    849842 * @uses $withcomments Will not try to get the comments if the post has none.
    850843 *
     
    961954 * lists of posts
    962955 *
    963956 * @since 0.71
    964  * @uses $id
    965957 * @uses $wpcommentspopupfile
    966958 * @uses $wpcommentsjavascript
    967959 * @uses $post
     
    974966 * @return null Returns null on single posts and pages.
    975967 */
    976968function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
    977         global $id, $wpcommentspopupfile, $wpcommentsjavascript;
     969        global $wpcommentspopupfile, $wpcommentsjavascript;
    978970
     971        $id = get_the_ID();
     972
    979973        if ( false === $zero ) $zero = __( 'No Comments' );
    980974        if ( false === $one ) $one = __( '1 Comment' );
    981975        if ( false === $more ) $more = __( '% Comments' );
     
    11681162 * @return string Hidden input HTML for replying to comments
    11691163 */
    11701164function get_comment_id_fields() {
    1171         global $id;
     1165        $id = get_the_ID();
    11721166
    11731167        $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
    11741168        $result  = "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n";
  • wp-includes/post-thumbnail-template.php

     
    1818 * @return bool Whether post has an image attached.
    1919 */
    2020function has_post_thumbnail( $post_id = NULL ) {
    21         global $id;
    22         $post_id = ( NULL === $post_id ) ? $id : $post_id;
     21        $post_id = ( NULL === $post_id ) ? get_the_ID() : $post_id;
    2322        return !! get_post_thumbnail_id( $post_id );
    2423}
    2524
     
    3231 * @return int
    3332 */
    3433function get_post_thumbnail_id( $post_id = NULL ) {
    35         global $id;
    36         $post_id = ( NULL === $post_id ) ? $id : $post_id;
     34        $post_id = ( NULL === $post_id ) ? get_the_ID() : $post_id;
    3735        return get_post_meta( $post_id, '_thumbnail_id', true );
    3836}
    3937
     
    5957 * @param string|array $attr Optional. Query string or array of attributes.
    6058 */
    6159function get_the_post_thumbnail( $post_id = NULL, $size = 'post-thumbnail', $attr = '' ) {
    62         global $id;
    63         $post_id = ( NULL === $post_id ) ? $id : $post_id;
     60        $post_id = ( NULL === $post_id ) ? get_the_ID() : $post_id;
    6461        $post_thumbnail_id = get_post_thumbnail_id( $post_id );
    6562        $size = apply_filters( 'post_thumbnail_size', $size );
    6663        if ( $post_thumbnail_id ) {
     
    7370        return apply_filters( 'post_thumbnail_html', $html, $post_id, $post_thumbnail_id, $size, $attr );
    7471}
    7572
    76 ?>
    77  No newline at end of file
     73?>
  • wp-includes/link-template.php

     
    462462 * @return string
    463463 */
    464464function get_post_comments_feed_link($post_id = '', $feed = '') {
    465         global $id;
     465        if ( !$post_id )
     466                $post_id = get_the_ID();
    466467
    467         if ( empty($post_id) )
    468                 $post_id = (int) $id;
     468        $post_id = absint($post_id);
    469469
    470470        if ( empty($feed) )
    471471                $feed = get_default_feed();