<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[15549] trunk/wp-includes: Don't use the  global anymore.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/15549">15549</a></dd>
<dt>Author</dt> <dd>scribu</dd>
<dt>Date</dt> <dd>2010-08-28 11:57:28 +0000 (Sat, 28 Aug 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Don't use the  global anymore. Fixes <a href="http://trac.wordpress.org/ticket/11624">#11624</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludescommenttemplatephp">trunk/wp-includes/comment-template.php</a></li>
<li><a href="#trunkwpincludeslinktemplatephp">trunk/wp-includes/link-template.php</a></li>
<li><a href="#trunkwpincludesposttemplatephp">trunk/wp-includes/post-template.php</a></li>
<li><a href="#trunkwpincludespostthumbnailtemplatephp">trunk/wp-includes/post-thumbnail-template.php</a></li>
<li><a href="#trunkwpincludespostphp">trunk/wp-includes/post.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludescommenttemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/comment-template.php (15548 => 15549)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/comment-template.php        2010-08-28 11:51:02 UTC (rev 15548)
+++ trunk/wp-includes/comment-template.php        2010-08-28 11:57:28 UTC (rev 15549)
</span><span class="lines">@@ -545,12 +545,11 @@
</span><span class="cx">  * @return int The number of comments a post has
</span><span class="cx">  */
</span><span class="cx"> function get_comments_number( $post_id = 0 ) {
</span><del>-        global $id;
-        $post_id = (int) $post_id;
-
</del><span class="cx">         if ( !$post_id )
</span><del>-                $post_id = (int) $id;
</del><ins>+                $post_id = get_the_ID();
</ins><span class="cx"> 
</span><ins>+        $post_id = absint($post_id);
+
</ins><span class="cx">         $post = get_post($post_id);
</span><span class="cx">         if ( ! isset($post-&gt;comment_count) )
</span><span class="cx">                 $count = 0;
</span><span class="lines">@@ -564,7 +563,6 @@
</span><span class="cx">  * Display the language string for the number of comments the current post has.
</span><span class="cx">  *
</span><span class="cx">  * @since 0.71
</span><del>- * @uses $id
</del><span class="cx">  * @uses apply_filters() Calls the 'comments_number' hook on the output and number of comments respectively.
</span><span class="cx">  *
</span><span class="cx">  * @param string $zero Text for no comments
</span><span class="lines">@@ -573,12 +571,10 @@
</span><span class="cx">  * @param string $deprecated Not used.
</span><span class="cx">  */
</span><span class="cx"> function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
</span><del>-        global $id;
-
</del><span class="cx">         if ( !empty( $deprecated ) )
</span><span class="cx">                 _deprecated_argument( __FUNCTION__, '1.3' );
</span><span class="cx"> 
</span><del>-        $number = get_comments_number($id);
</del><ins>+        $number = get_comments_number(get_the_ID());
</ins><span class="cx"> 
</span><span class="cx">         if ( $number &gt; 1 )
</span><span class="cx">                 $output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% Comments') : $more);
</span><span class="lines">@@ -703,16 +699,14 @@
</span><span class="cx">  *
</span><span class="cx">  * @since 1.5.0
</span><span class="cx">  * @uses apply_filters() Calls 'trackback_url' on the resulting trackback URL
</span><del>- * @uses $id
</del><span class="cx">  *
</span><span class="cx">  * @return string The trackback URL after being filtered
</span><span class="cx">  */
</span><span class="cx"> function get_trackback_url() {
</span><del>-        global $id;
</del><span class="cx">         if ( '' != get_option('permalink_structure') ) {
</span><span class="cx">                 $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback');
</span><span class="cx">         } else {
</span><del>-                $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . $id;
</del><ins>+                $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID();
</ins><span class="cx">         }
</span><span class="cx">         return apply_filters('trackback_url', $tb_url);
</span><span class="cx"> }
</span><span class="lines">@@ -844,7 +838,6 @@
</span><span class="cx">  * @since 1.5.0
</span><span class="cx">  * @global array $comment List of comment objects for the current post
</span><span class="cx">  * @uses $wpdb
</span><del>- * @uses $id
</del><span class="cx">  * @uses $post
</span><span class="cx">  * @uses $withcomments Will not try to get the comments if the post has none.
</span><span class="cx">  *
</span><span class="lines">@@ -961,7 +954,6 @@
</span><span class="cx">  * lists of posts
</span><span class="cx">  *
</span><span class="cx">  * @since 0.71
</span><del>- * @uses $id
</del><span class="cx">  * @uses $wpcommentspopupfile
</span><span class="cx">  * @uses $wpcommentsjavascript
</span><span class="cx">  * @uses $post
</span><span class="lines">@@ -974,8 +966,10 @@
</span><span class="cx">  * @return null Returns null on single posts and pages.
</span><span class="cx">  */
</span><span class="cx"> function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
</span><del>-        global $id, $wpcommentspopupfile, $wpcommentsjavascript;
</del><ins>+        global $wpcommentspopupfile, $wpcommentsjavascript;
</ins><span class="cx"> 
</span><ins>+        $id = get_the_ID();
+
</ins><span class="cx">         if ( false === $zero ) $zero = __( 'No Comments' );
</span><span class="cx">         if ( false === $one ) $one = __( '1 Comment' );
</span><span class="cx">         if ( false === $more ) $more = __( '% Comments' );
</span><span class="lines">@@ -1168,7 +1162,7 @@
</span><span class="cx">  * @return string Hidden input HTML for replying to comments
</span><span class="cx">  */
</span><span class="cx"> function get_comment_id_fields() {
</span><del>-        global $id;
</del><ins>+        $id = get_the_ID();
</ins><span class="cx"> 
</span><span class="cx">         $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
</span><span class="cx">         $result  = &quot;&lt;input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' /&gt;\n&quot;;
</span></span></pre></div>
<a id="trunkwpincludeslinktemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/link-template.php (15548 => 15549)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/link-template.php        2010-08-28 11:51:02 UTC (rev 15548)
+++ trunk/wp-includes/link-template.php        2010-08-28 11:57:28 UTC (rev 15549)
</span><span class="lines">@@ -462,10 +462,10 @@
</span><span class="cx">  * @return string
</span><span class="cx">  */
</span><span class="cx"> function get_post_comments_feed_link($post_id = '', $feed = '') {
</span><del>-        global $id;
</del><ins>+        if ( !$post_id )
+                $post_id = get_the_ID();
</ins><span class="cx"> 
</span><del>-        if ( empty($post_id) )
-                $post_id = (int) $id;
</del><ins>+        $post_id = absint($post_id);
</ins><span class="cx"> 
</span><span class="cx">         if ( empty($feed) )
</span><span class="cx">                 $feed = get_default_feed();
</span></span></pre></div>
<a id="trunkwpincludesposttemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post-template.php (15548 => 15549)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post-template.php        2010-08-28 11:51:02 UTC (rev 15548)
+++ trunk/wp-includes/post-template.php        2010-08-28 11:57:28 UTC (rev 15549)
</span><span class="lines">@@ -12,24 +12,22 @@
</span><span class="cx">  * Display the ID of the current item in the WordPress Loop.
</span><span class="cx">  *
</span><span class="cx">  * @since 0.71
</span><del>- * @uses $id
</del><span class="cx">  */
</span><span class="cx"> function the_ID() {
</span><del>-        global $id;
-        echo $id;
</del><ins>+        echo get_the_ID();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * Retrieve the ID of the current item in the WordPress Loop.
</span><span class="cx">  *
</span><span class="cx">  * @since 2.1.0
</span><del>- * @uses $id
</del><ins>+ * @uses $post
</ins><span class="cx">  *
</span><del>- * @return unknown
</del><ins>+ * @return int
</ins><span class="cx">  */
</span><span class="cx"> function get_the_ID() {
</span><del>-        global $id;
-        return $id;
</del><ins>+        global $post;
+        return $post-&gt;ID;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -181,7 +179,7 @@
</span><span class="cx">  * @return string
</span><span class="cx">  */
</span><span class="cx"> function get_the_content($more_link_text = null, $stripteaser = 0) {
</span><del>-        global $id, $post, $more, $page, $pages, $multipage, $preview;
</del><ins>+        global $post, $more, $page, $pages, $multipage, $preview;
</ins><span class="cx"> 
</span><span class="cx">         if ( null === $more_link_text )
</span><span class="cx">                 $more_link_text = __( '(more...)' );
</span><span class="lines">@@ -216,10 +214,10 @@
</span><span class="cx">         $output .= $teaser;
</span><span class="cx">         if ( count($content) &gt; 1 ) {
</span><span class="cx">                 if ( $more ) {
</span><del>-                        $output .= '&lt;span id=&quot;more-' . $id . '&quot;&gt;&lt;/span&gt;' . $content[1];
</del><ins>+                        $output .= '&lt;span id=&quot;more-' . $post-&gt;ID . '&quot;&gt;&lt;/span&gt;' . $content[1];
</ins><span class="cx">                 } else {
</span><span class="cx">                         if ( ! empty($more_link_text) )
</span><del>-                                $output .= apply_filters( 'the_content_more_link', ' &lt;a href=&quot;' . get_permalink() . &quot;#more-$id\&quot; class=\&quot;more-link\&quot;&gt;$more_link_text&lt;/a&gt;&quot;, $more_link_text );
</del><ins>+                                $output .= apply_filters( 'the_content_more_link', ' &lt;a href=&quot;' . get_permalink() . &quot;#more-{$post-&gt;ID}\&quot; class=\&quot;more-link\&quot;&gt;$more_link_text&lt;/a&gt;&quot;, $more_link_text );
</ins><span class="cx">                         $output = force_balance_tags($output);
</span><span class="cx">                 }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludespostthumbnailtemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post-thumbnail-template.php (15548 => 15549)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post-thumbnail-template.php        2010-08-28 11:51:02 UTC (rev 15548)
+++ trunk/wp-includes/post-thumbnail-template.php        2010-08-28 11:57:28 UTC (rev 15549)
</span><span class="lines">@@ -18,8 +18,7 @@
</span><span class="cx">  * @return bool Whether post has an image attached.
</span><span class="cx">  */
</span><span class="cx"> function has_post_thumbnail( $post_id = NULL ) {
</span><del>-        global $id;
-        $post_id = ( NULL === $post_id ) ? $id : $post_id;
</del><ins>+        $post_id = ( NULL === $post_id ) ? get_the_ID() : $post_id;
</ins><span class="cx">         return !! get_post_thumbnail_id( $post_id );
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -32,8 +31,7 @@
</span><span class="cx">  * @return int
</span><span class="cx">  */
</span><span class="cx"> function get_post_thumbnail_id( $post_id = NULL ) {
</span><del>-        global $id;
-        $post_id = ( NULL === $post_id ) ? $id : $post_id;
</del><ins>+        $post_id = ( NULL === $post_id ) ? get_the_ID() : $post_id;
</ins><span class="cx">         return get_post_meta( $post_id, '_thumbnail_id', true );
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -59,8 +57,7 @@
</span><span class="cx">  * @param string|array $attr Optional. Query string or array of attributes.
</span><span class="cx">  */
</span><span class="cx"> function get_the_post_thumbnail( $post_id = NULL, $size = 'post-thumbnail', $attr = '' ) {
</span><del>-        global $id;
-        $post_id = ( NULL === $post_id ) ? $id : $post_id;
</del><ins>+        $post_id = ( NULL === $post_id ) ? get_the_ID() : $post_id;
</ins><span class="cx">         $post_thumbnail_id = get_post_thumbnail_id( $post_id );
</span><span class="cx">         $size = apply_filters( 'post_thumbnail_size', $size );
</span><span class="cx">         if ( $post_thumbnail_id ) {
</span><span class="lines">@@ -73,4 +70,4 @@
</span><span class="cx">         return apply_filters( 'post_thumbnail_html', $html, $post_id, $post_thumbnail_id, $size, $attr );
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-?&gt;
</del><span class="cx">\ No newline at end of file
</span><ins>+?&gt;
</ins></span></pre></div>
<a id="trunkwpincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post.php (15548 => 15549)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post.php        2010-08-28 11:51:02 UTC (rev 15548)
+++ trunk/wp-includes/post.php        2010-08-28 11:57:28 UTC (rev 15549)
</span><span class="lines">@@ -1268,10 +1268,8 @@
</span><span class="cx">  * @return array
</span><span class="cx">  */
</span><span class="cx"> function get_post_custom($post_id = 0) {
</span><del>-        global $id;
-
</del><span class="cx">         if ( !$post_id )
</span><del>-                $post_id = (int) $id;
</del><ins>+                $post_id = get_the_ID();
</ins><span class="cx"> 
</span><span class="cx">         $post_id = (int) $post_id;
</span><span class="cx"> 
</span><span class="lines">@@ -1336,13 +1334,11 @@
</span><span class="cx">  * @return bool Whether post is sticky.
</span><span class="cx">  */
</span><span class="cx"> function is_sticky($post_id = null) {
</span><del>-        global $id;
</del><ins>+        if ( !$post_id )
+                $post_id = get_the_ID();
</ins><span class="cx"> 
</span><span class="cx">         $post_id = absint($post_id);
</span><span class="cx"> 
</span><del>-        if ( !$post_id )
-                $post_id = absint($id);
-
</del><span class="cx">         $stickies = get_option('sticky_posts');
</span><span class="cx"> 
</span><span class="cx">         if ( !is_array($stickies) )
</span></span></pre>
</div>
</div>

</body>
</html>