<!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" />
<title>[21735] trunk: Use get_post() instead of global $post.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { 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 #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#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>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/21735">21735</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2012-09-04 16:29:28 +0000 (Tue, 04 Sep 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use get_post() instead of global $post.
Make the $post argument to get_post() optional, defaulting to the current post in The Loop.

Props nacin
see <a href="http://core.trac.wordpress.org/ticket/21309">#21309</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesclasswpcommentslisttablephp">trunk/wp-admin/includes/class-wp-comments-list-table.php</a></li>
<li><a href="#trunkwpadminincludesclasswpmedialisttablephp">trunk/wp-admin/includes/class-wp-media-list-table.php</a></li>
<li><a href="#trunkwpadminincludesclasswppostslisttablephp">trunk/wp-admin/includes/class-wp-posts-list-table.php</a></li>
<li><a href="#trunkwpadminincludesexportphp">trunk/wp-admin/includes/export.php</a></li>
<li><a href="#trunkwpadminincludesmetaboxesphp">trunk/wp-admin/includes/meta-boxes.php</a></li>
<li><a href="#trunkwpadminincludespostphp">trunk/wp-admin/includes/post.php</a></li>
<li><a href="#trunkwpadminincludestemplatephp">trunk/wp-admin/includes/template.php</a></li>
<li><a href="#trunkwpincludesadminbarphp">trunk/wp-includes/admin-bar.php</a></li>
<li><a href="#trunkwpincludesauthortemplatephp">trunk/wp-includes/author-template.php</a></li>
<li><a href="#trunkwpincludescategorytemplatephp">trunk/wp-includes/category-template.php</a></li>
<li><a href="#trunkwpincludesclasswpatomserverphp">trunk/wp-includes/class-wp-atom-server.php</a></li>
<li><a href="#trunkwpincludesclasswpeditorphp">trunk/wp-includes/class-wp-editor.php</a></li>
<li><a href="#trunkwpincludescommenttemplatephp">trunk/wp-includes/comment-template.php</a></li>
<li><a href="#trunkwpincludesdeprecatedphp">trunk/wp-includes/deprecated.php</a></li>
<li><a href="#trunkwpincludesgeneraltemplatephp">trunk/wp-includes/general-template.php</a></li>
<li><a href="#trunkwpincludeslinktemplatephp">trunk/wp-includes/link-template.php</a></li>
<li><a href="#trunkwpincludesmediaphp">trunk/wp-includes/media.php</a></li>
<li><a href="#trunkwpincludesposttemplatephp">trunk/wp-includes/post-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="trunkwpadminincludesclasswpcommentslisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-comments-list-table.php (21734 => 21735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-comments-list-table.php        2012-09-04 14:44:17 UTC (rev 21734)
+++ trunk/wp-admin/includes/class-wp-comments-list-table.php        2012-09-04 16:29:28 UTC (rev 21735)
</span><span class="lines">@@ -302,7 +302,8 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function single_row( $a_comment ) {
</span><del>-                global $post, $comment;
</del><ins>+                global $comment;
+                $post = get_post();
</ins><span class="cx"> 
</span><span class="cx">                 $comment = $a_comment;
</span><span class="cx">                 $the_comment_class = join( ' ', get_comment_class( wp_get_comment_status( $comment-&gt;comment_ID ) ) );
</span><span class="lines">@@ -325,7 +326,8 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function column_comment( $comment ) {
</span><del>-                global $post, $comment_status;
</del><ins>+                global $comment_status;
+                $post = get_post();
</ins><span class="cx"> 
</span><span class="cx">                 $user_can = $this-&gt;user_can;
</span><span class="cx"> 
</span><span class="lines">@@ -479,7 +481,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function column_response( $comment ) {
</span><del>-                global $post;
</del><ins>+                $post = get_post();
</ins><span class="cx"> 
</span><span class="cx">                 if ( isset( $this-&gt;pending_count[$post-&gt;ID] ) ) {
</span><span class="cx">                         $pending_comments = $this-&gt;pending_count[$post-&gt;ID];
</span></span></pre></div>
<a id="trunkwpadminincludesclasswpmedialisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-media-list-table.php (21734 => 21735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-media-list-table.php        2012-09-04 14:44:17 UTC (rev 21734)
+++ trunk/wp-admin/includes/class-wp-media-list-table.php        2012-09-04 16:29:28 UTC (rev 21735)
</span><span class="lines">@@ -156,7 +156,8 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function display_rows() {
</span><del>-                global $post, $id;
</del><ins>+                $post = get_post();
+                $id = $post-&gt;ID;
</ins><span class="cx"> 
</span><span class="cx">                 add_filter( 'the_title','esc_html' );
</span><span class="cx">                 $alt = '';
</span></span></pre></div>
<a id="trunkwpadminincludesclasswppostslisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-posts-list-table.php (21734 => 21735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-posts-list-table.php        2012-09-04 14:44:17 UTC (rev 21734)
+++ trunk/wp-admin/includes/class-wp-posts-list-table.php        2012-09-04 16:29:28 UTC (rev 21735)
</span><span class="lines">@@ -316,7 +316,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function _display_rows( $posts, $level = 0 ) {
</span><del>-                global $post, $mode;
</del><ins>+                global $mode;
</ins><span class="cx"> 
</span><span class="cx">                 // Create array of post IDs.
</span><span class="cx">                 $post_ids = array();
</span><span class="lines">@@ -458,12 +458,12 @@
</span><span class="cx">                 unset( $children_pages[$parent] ); //required in order to keep track of orphans
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function single_row( $a_post, $level = 0 ) {
-                global $post, $mode;
</del><ins>+        function single_row( $post, $level = 0 ) {
+                global $mode;
</ins><span class="cx">                 static $alternate;
</span><span class="cx"> 
</span><del>-                $global_post = $post;
-                $post = $a_post;
</del><ins>+                $global_post = get_post();
+                $GLOBALS['post'] = $post;
</ins><span class="cx">                 setup_postdata( $post );
</span><span class="cx"> 
</span><span class="cx">                 $edit_link = get_edit_post_link( $post-&gt;ID );
</span><span class="lines">@@ -529,7 +529,7 @@
</span><span class="cx">                                 }
</span><span class="cx">                                 else {
</span><span class="cx">                                         $attributes = 'class=&quot;post-title page-title column-title&quot;' . $style;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         $pad = str_repeat( '&amp;#8212; ', $level );
</span><span class="cx"> ?&gt;
</span><span class="cx">                         &lt;td &lt;?php echo $attributes ?&gt;&gt;&lt;strong&gt;&lt;?php if ( $can_edit_post &amp;&amp; $post-&gt;post_status != 'trash' ) { ?&gt;&lt;a class=&quot;row-title&quot; href=&quot;&lt;?php echo $edit_link; ?&gt;&quot; title=&quot;&lt;?php echo esc_attr( sprintf( __( 'Edit &amp;#8220;%s&amp;#8221;' ), $title ) ); ?&gt;&quot;&gt;&lt;?php echo $pad; echo $title ?&gt;&lt;/a&gt;&lt;?php } else { echo $pad; echo $title; }; _post_states( $post ); ?&gt;&lt;/strong&gt;
</span><span class="lines">@@ -684,7 +684,7 @@
</span><span class="cx">         ?&gt;
</span><span class="cx">                 &lt;/tr&gt;
</span><span class="cx">         &lt;?php
</span><del>-                $post = $global_post;
</del><ins>+                $GLOBALS['post'] = $global_post;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span></span></pre></div>
<a id="trunkwpadminincludesexportphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/export.php (21734 => 21735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/export.php        2012-09-04 14:44:17 UTC (rev 21734)
+++ trunk/wp-admin/includes/export.php        2012-09-04 16:29:28 UTC (rev 21735)
</span><span class="lines">@@ -279,7 +279,7 @@
</span><span class="cx">          * @since 2.3.0
</span><span class="cx">          */
</span><span class="cx">         function wxr_post_taxonomy() {
</span><del>-                global $post;
</del><ins>+                $post = get_post();
</ins><span class="cx"> 
</span><span class="cx">                 $taxonomies = get_object_taxonomies( $post-&gt;post_type );
</span><span class="cx">                 if ( empty( $taxonomies ) )
</span></span></pre></div>
<a id="trunkwpadminincludesmetaboxesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/meta-boxes.php (21734 => 21735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/meta-boxes.php        2012-09-04 14:44:17 UTC (rev 21734)
+++ trunk/wp-admin/includes/meta-boxes.php        2012-09-04 16:29:28 UTC (rev 21735)
</span><span class="lines">@@ -466,15 +466,15 @@
</span><span class="cx">  *
</span><span class="cx">  * @param object $post
</span><span class="cx">  */
</span><del>-function post_comment_meta_box($post) {
-        global $wpdb, $post_ID;
</del><ins>+function post_comment_meta_box( $post ) {
+        global $wpdb;
</ins><span class="cx"> 
</span><span class="cx">         wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
</span><span class="cx">         ?&gt;
</span><del>-        &lt;p class=&quot;hide-if-no-js&quot; id=&quot;add-new-comment&quot;&gt;&lt;a href=&quot;#commentstatusdiv&quot; onclick=&quot;commentReply.addcomment(&lt;?php echo $post_ID; ?&gt;);return false;&quot;&gt;&lt;?php _e('Add comment'); ?&gt;&lt;/a&gt;&lt;/p&gt;
</del><ins>+        &lt;p class=&quot;hide-if-no-js&quot; id=&quot;add-new-comment&quot;&gt;&lt;a href=&quot;#commentstatusdiv&quot; onclick=&quot;commentReply.addcomment(&lt;?php echo $post-&gt;ID; ?&gt;);return false;&quot;&gt;&lt;?php _e('Add comment'); ?&gt;&lt;/a&gt;&lt;/p&gt;
</ins><span class="cx">         &lt;?php
</span><span class="cx"> 
</span><del>-        $total = get_comments( array( 'post_id' =&gt; $post_ID, 'number' =&gt; 1, 'count' =&gt; true ) );
</del><ins>+        $total = get_comments( array( 'post_id' =&gt; $post-&gt;ID, 'number' =&gt; 1, 'count' =&gt; true ) );
</ins><span class="cx">         $wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
</span><span class="cx">         $wp_list_table-&gt;display( true );
</span><span class="cx"> 
</span><span class="lines">@@ -910,8 +910,7 @@
</span><span class="cx">  *
</span><span class="cx">  * @since 2.9.0
</span><span class="cx">  */
</span><del>-function post_thumbnail_meta_box() {
-        global $post;
</del><ins>+function post_thumbnail_meta_box( $post ) {
</ins><span class="cx">         $thumbnail_id = get_post_meta( $post-&gt;ID, '_thumbnail_id', true );
</span><span class="cx">         echo _wp_post_thumbnail_html( $thumbnail_id );
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpadminincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/post.php (21734 => 21735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/post.php        2012-09-04 14:44:17 UTC (rev 21734)
+++ trunk/wp-admin/includes/post.php        2012-09-04 16:29:28 UTC (rev 21735)
</span><span class="lines">@@ -1121,16 +1121,15 @@
</span><span class="cx">  * @since 2.9.0
</span><span class="cx">  *
</span><span class="cx">  * @param int $thumbnail_id ID of the attachment used for thumbnail
</span><del>- * @param int $post_id ID of the post associated with the thumbnail, defaults to global $post_ID
</del><ins>+ * @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post.
</ins><span class="cx">  * @return string html
</span><span class="cx">  */
</span><del>-function _wp_post_thumbnail_html( $thumbnail_id = null, $post_id = null ) {
-        global $content_width, $_wp_additional_image_sizes, $post_ID;
</del><ins>+function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) {
+        global $content_width, $_wp_additional_image_sizes;
</ins><span class="cx"> 
</span><del>-        if ( empty( $post_id ) )
-                $post_id = $post_ID;
</del><ins>+        $post = get_post( $post );
</ins><span class="cx"> 
</span><del>-        $upload_iframe_src = esc_url( get_upload_iframe_src('image', $post_id) );
</del><ins>+        $upload_iframe_src = esc_url( get_upload_iframe_src('image', $post-&gt;ID ) );
</ins><span class="cx">         $set_thumbnail_link = '&lt;p class=&quot;hide-if-no-js&quot;&gt;&lt;a title=&quot;' . esc_attr__( 'Set featured image' ) . '&quot; href=&quot;%s&quot; id=&quot;set-post-thumbnail&quot; class=&quot;thickbox&quot;&gt;%s&lt;/a&gt;&lt;/p&gt;';
</span><span class="cx">         $content = sprintf( $set_thumbnail_link, $upload_iframe_src, esc_html__( 'Set featured image' ) );
</span><span class="cx"> 
</span><span class="lines">@@ -1142,14 +1141,14 @@
</span><span class="cx">                 else
</span><span class="cx">                         $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' );
</span><span class="cx">                 if ( !empty( $thumbnail_html ) ) {
</span><del>-                        $ajax_nonce = wp_create_nonce( &quot;set_post_thumbnail-$post_id&quot; );
</del><ins>+                        $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post-&gt;ID );
</ins><span class="cx">                         $content = sprintf( $set_thumbnail_link, $upload_iframe_src, $thumbnail_html );
</span><span class="cx">                         $content .= '&lt;p class=&quot;hide-if-no-js&quot;&gt;&lt;a href=&quot;#&quot; id=&quot;remove-post-thumbnail&quot; onclick=&quot;WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;&quot;&gt;' . esc_html__( 'Remove featured image' ) . '&lt;/a&gt;&lt;/p&gt;';
</span><span class="cx">                 }
</span><span class="cx">                 $content_width = $old_content_width;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        return apply_filters( 'admin_post_thumbnail_html', $content, $post_id );
</del><ins>+        return apply_filters( 'admin_post_thumbnail_html', $content, $post-&gt;ID );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -1207,8 +1206,7 @@
</span><span class="cx">  * @return none
</span><span class="cx">  */
</span><span class="cx"> function _admin_notice_post_locked() {
</span><del>-        global $post;
-
</del><ins>+        $post = get_post();
</ins><span class="cx">         $lock = explode( ':', get_post_meta( $post-&gt;ID, '_edit_lock', true ) );
</span><span class="cx">         $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post-&gt;ID, '_edit_last', true );
</span><span class="cx">         $last_user = get_userdata( $user );
</span></span></pre></div>
<a id="trunkwpadminincludestemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/template.php (21734 => 21735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/template.php        2012-09-04 14:44:17 UTC (rev 21734)
+++ trunk/wp-admin/includes/template.php        2012-09-04 16:29:28 UTC (rev 21735)
</span><span class="lines">@@ -166,10 +166,9 @@
</span><span class="cx">  * @return array List of popular term IDs.
</span><span class="cx">  */
</span><span class="cx"> function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
</span><del>-        global $post_ID;
-
-        if ( $post_ID )
-                $checked_terms = wp_get_object_terms($post_ID, $taxonomy, array('fields'=&gt;'ids'));
</del><ins>+        $post = get_post();
+        if ( $post-&gt;ID )
+                $checked_terms = wp_get_object_terms($post-&gt;ID, $taxonomy, array('fields'=&gt;'ids'));
</ins><span class="cx">         else
</span><span class="cx">                 $checked_terms = array();
</span><span class="cx"> 
</span><span class="lines">@@ -575,7 +574,8 @@
</span><span class="cx">  * @param unknown_type $multi
</span><span class="cx">  */
</span><span class="cx"> function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
</span><del>-        global $wp_locale, $post, $comment;
</del><ins>+        global $wp_locale, $comment;
+        $post = get_post();
</ins><span class="cx"> 
</span><span class="cx">         if ( $for_post )
</span><span class="cx">                 $edit = ! ( in_array($post-&gt;post_status, array('draft', 'pending') ) &amp;&amp; (!$post-&gt;post_date_gmt || '0000-00-00 00:00:00' == $post-&gt;post_date_gmt ) );
</span><span class="lines">@@ -670,17 +670,16 @@
</span><span class="cx">  * @return unknown
</span><span class="cx">  */
</span><span class="cx"> function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
</span><del>-        global $wpdb, $post_ID;
</del><ins>+        global $wpdb;
+        $post = get_post();
</ins><span class="cx">         $items = $wpdb-&gt;get_results( $wpdb-&gt;prepare(&quot;SELECT ID, post_parent, post_title FROM $wpdb-&gt;posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order&quot;, $parent) );
</span><span class="cx"> 
</span><span class="cx">         if ( $items ) {
</span><span class="cx">                 foreach ( $items as $item ) {
</span><span class="cx">                         // A page cannot be its own parent.
</span><del>-                        if (!empty ( $post_ID ) ) {
-                                if ( $item-&gt;ID == $post_ID ) {
-                                        continue;
-                                }
-                        }
</del><ins>+                        if ( $post-&gt;ID &amp;&amp; $item-&gt;ID == $post-&gt;ID )
+                                continue;
+
</ins><span class="cx">                         $pad = str_repeat( '&amp;nbsp;', $level * 3 );
</span><span class="cx">                         if ( $item-&gt;ID == $default)
</span><span class="cx">                                 $current = ' selected=&quot;selected&quot;';
</span><span class="lines">@@ -1345,8 +1344,9 @@
</span><span class="cx">  * @since 2.7.0
</span><span class="cx">  */
</span><span class="cx"> function the_post_password() {
</span><del>-        global $post;
-        if ( isset( $post-&gt;post_password ) ) echo esc_attr( $post-&gt;post_password );
</del><ins>+        $post = get_post();
+        if ( isset( $post-&gt;post_password ) )
+                echo esc_attr( $post-&gt;post_password );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -1356,13 +1356,13 @@
</span><span class="cx">  * returned.
</span><span class="cx">  *
</span><span class="cx">  * @since 2.7.0
</span><del>- * @param int $post_id The post id. If not supplied the global $post is used.
</del><ins>+ * @param mixed $post Post id or object. If not supplied the global $post is used.
</ins><span class="cx">  * @return string The post title if set
</span><span class="cx">  */
</span><del>-function _draft_or_post_title( $post_id = 0 ) {
-        $title = get_the_title($post_id);
-        if ( empty($title) )
-                $title = __('(no title)');
</del><ins>+function _draft_or_post_title( $post = 0 ) {
+        $title = get_the_title( $post );
+        if ( empty( $title ) )
+                $title = __( '(no title)' );
</ins><span class="cx">         return $title;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludesadminbarphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/admin-bar.php (21734 => 21735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/admin-bar.php        2012-09-04 14:44:17 UTC (rev 21734)
+++ trunk/wp-includes/admin-bar.php        2012-09-04 16:29:28 UTC (rev 21735)
</span><span class="lines">@@ -419,10 +419,11 @@
</span><span class="cx">  * @since 3.1.0
</span><span class="cx">  */
</span><span class="cx"> function wp_admin_bar_edit_menu( $wp_admin_bar ) {
</span><del>-        global $post, $tag, $wp_the_query;
</del><ins>+        global $tag, $wp_the_query;
</ins><span class="cx"> 
</span><span class="cx">         if ( is_admin() ) {
</span><span class="cx">                 $current_screen = get_current_screen();
</span><ins>+                $post = get_post();
</ins><span class="cx"> 
</span><span class="cx">                 if ( 'post' == $current_screen-&gt;base
</span><span class="cx">                         &amp;&amp; 'add' != $current_screen-&gt;action
</span><span class="lines">@@ -619,7 +620,7 @@
</span><span class="cx">                 return;
</span><span class="cx"> 
</span><span class="cx">         $title = '&lt;span class=&quot;ab-icon&quot;&gt;&lt;/span&gt;&lt;span class=&quot;ab-label&quot;&gt;' . number_format_i18n( $update_data['counts']['total'] ) . '&lt;/span&gt;';
</span><del>-        $title .= '&lt;span class=&quot;screen-reader-text&quot;&gt;' . $update_data['title'] . '&lt;/span&gt;'; 
</del><ins>+        $title .= '&lt;span class=&quot;screen-reader-text&quot;&gt;' . $update_data['title'] . '&lt;/span&gt;';
</ins><span class="cx"> 
</span><span class="cx">         $wp_admin_bar-&gt;add_menu( array(
</span><span class="cx">                 'id'    =&gt; 'updates',
</span></span></pre></div>
<a id="trunkwpincludesauthortemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/author-template.php (21734 => 21735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/author-template.php        2012-09-04 14:44:17 UTC (rev 21734)
+++ trunk/wp-includes/author-template.php        2012-09-04 16:29:28 UTC (rev 21735)
</span><span class="lines">@@ -69,8 +69,7 @@
</span><span class="cx">  * @return string The author's display name.
</span><span class="cx">  */
</span><span class="cx"> function get_the_modified_author() {
</span><del>-        global $post;
-        if ( $last_id = get_post_meta($post-&gt;ID, '_edit_last', true) ) {
</del><ins>+        if ( $last_id = get_post_meta( get_post()-&gt;ID, '_edit_last', true) ) {
</ins><span class="cx">                 $last_user = get_userdata($last_id);
</span><span class="cx">                 return apply_filters('the_modified_author', $last_user-&gt;display_name);
</span><span class="cx">         }
</span><span class="lines">@@ -164,8 +163,7 @@
</span><span class="cx">  * @return int The number of posts by the author.
</span><span class="cx">  */
</span><span class="cx"> function get_the_author_posts() {
</span><del>-        global $post;
-        return count_user_posts($post-&gt;post_author);
</del><ins>+        return count_user_posts( get_post()-&gt;post_author );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span></span></pre></div>
<a id="trunkwpincludescategorytemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/category-template.php (21734 => 21735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/category-template.php        2012-09-04 14:44:17 UTC (rev 21734)
+++ trunk/wp-includes/category-template.php        2012-09-04 16:29:28 UTC (rev 21735)
</span><span class="lines">@@ -1054,29 +1054,21 @@
</span><span class="cx">  *
</span><span class="cx">  * @since 2.5.0
</span><span class="cx">  *
</span><del>- * @param int $id Post ID.
</del><ins>+ * @param mixed $post Post ID or object.
</ins><span class="cx">  * @param string $taxonomy Taxonomy name.
</span><span class="cx">  * @return array|bool False on failure. Array of term objects on success.
</span><span class="cx">  */
</span><del>-function get_the_terms( $id, $taxonomy ) {
-        global $post;
</del><ins>+function get_the_terms( $post, $taxonomy ) {
+        if ( ! $post = get_post( $post ) )
+                return false;
</ins><span class="cx"> 
</span><del>-         $id = (int) $id;
-
-        if ( !$id ) {
-                if ( empty( $post-&gt;ID ) )
-                        return false;
-                else
-                        $id = (int) $post-&gt;ID;
-        }
-
-        $terms = get_object_term_cache( $id, $taxonomy );
</del><ins>+        $terms = get_object_term_cache( $post-&gt;ID, $taxonomy );
</ins><span class="cx">         if ( false === $terms ) {
</span><del>-                $terms = wp_get_object_terms( $id, $taxonomy );
-                wp_cache_add($id, $terms, $taxonomy . '_relationships');
</del><ins>+                $terms = wp_get_object_terms( $post-&gt;ID, $taxonomy );
+                wp_cache_add($post-&gt;ID, $terms, $taxonomy . '_relationships');
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        $terms = apply_filters( 'get_the_terms', $terms, $id, $taxonomy );
</del><ins>+        $terms = apply_filters( 'get_the_terms', $terms, $post-&gt;ID, $taxonomy );
</ins><span class="cx"> 
</span><span class="cx">         if ( empty( $terms ) )
</span><span class="cx">                 return false;
</span></span></pre></div>
<a id="trunkwpincludesclasswpatomserverphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/class-wp-atom-server.php (21734 => 21735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-wp-atom-server.php        2012-09-04 14:44:17 UTC (rev 21734)
+++ trunk/wp-includes/class-wp-atom-server.php        2012-09-04 16:29:28 UTC (rev 21735)
</span><span class="lines">@@ -846,10 +846,9 @@
</span><span class="cx">          * @param int $postID Post ID.
</span><span class="cx">          * @return string
</span><span class="cx">          */
</span><del>-        function get_entry_url($postID = null) {
</del><ins>+        function get_entry_url( $postID = null ) {
</ins><span class="cx">                 if (!isset($postID)) {
</span><del>-                        global $post;
-                        $postID = (int) $post-&gt;ID;
</del><ins>+                        $postID = (int) get_post()-&gt;ID;
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 $url = $this-&gt;app_base . $this-&gt;ENTRY_PATH . &quot;/$postID&quot;;
</span><span class="lines">@@ -878,8 +877,7 @@
</span><span class="cx">          */
</span><span class="cx">         function get_media_url($postID = null) {
</span><span class="cx">                 if (!isset($postID)) {
</span><del>-                        global $post;
-                        $postID = (int) $post-&gt;ID;
</del><ins>+                        $postID = (int) get_post()-&gt;ID;
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 $url = $this-&gt;app_base . $this-&gt;MEDIA_SINGLE_PATH .&quot;/file/$postID&quot;;
</span></span></pre></div>
<a id="trunkwpincludesclasswpeditorphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/class-wp-editor.php (21734 => 21735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-wp-editor.php        2012-09-04 14:44:17 UTC (rev 21734)
+++ trunk/wp-includes/class-wp-editor.php        2012-09-04 16:29:28 UTC (rev 21735)
</span><span class="lines">@@ -126,7 +126,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         public static function editor_settings($editor_id, $set) {
</span><del>-                global $editor_styles, $post;
</del><ins>+                global $editor_styles;
</ins><span class="cx">                 $first_run = false;
</span><span class="cx"> 
</span><span class="cx">                 if ( empty(self::$first_init) ) {
</span><span class="lines">@@ -370,8 +370,8 @@
</span><span class="cx"> 
</span><span class="cx">                         $body_class = $editor_id;
</span><span class="cx"> 
</span><del>-                        if ( isset($post) )
-                                $body_class .= &quot; post-type-$post-&gt;post_type&quot;;
</del><ins>+                        if ( $post = get_post() )
+                                $body_class .= ' post-type-' . $post-&gt;post_type;
</ins><span class="cx"> 
</span><span class="cx">                         if ( !empty($set['tinymce']['body_class']) ) {
</span><span class="cx">                                 $body_class .= ' ' . $set['tinymce']['body_class'];
</span><span class="lines">@@ -612,7 +612,8 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         public static function wp_fullscreen_html() {
</span><del>-                global $content_width, $post;
</del><ins>+                global $content_width;
+                $post = get_post();
</ins><span class="cx"> 
</span><span class="cx">                 $width = isset($content_width) &amp;&amp; 800 &gt; $content_width ? $content_width : 800;
</span><span class="cx">                 $width = $width + 22; // compensate for the padding and border
</span></span></pre></div>
<a id="trunkwpincludescommenttemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/comment-template.php (21734 => 21735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/comment-template.php        2012-09-04 14:44:17 UTC (rev 21734)
+++ trunk/wp-includes/comment-template.php        2012-09-04 16:29:28 UTC (rev 21735)
</span><span class="lines">@@ -810,12 +810,9 @@
</span><span class="cx">  * @uses $post Gets the ID of the current post for the token
</span><span class="cx">  */
</span><span class="cx"> function wp_comment_form_unfiltered_html_nonce() {
</span><del>-        global $post;
</del><ins>+        $post = get_post();
+        $post_id = $post ? $post-&gt;ID : 0;
</ins><span class="cx"> 
</span><del>-        $post_id = 0;
-        if ( !empty($post) )
-                $post_id = $post-&gt;ID;
-
</del><span class="cx">         if ( current_user_can( 'unfiltered_html' ) ) {
</span><span class="cx">                 wp_nonce_field( 'unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment_disabled', false );
</span><span class="cx">                 echo &quot;&lt;script&gt;(function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();&lt;/script&gt;\n&quot;;
</span></span></pre></div>
<a id="trunkwpincludesdeprecatedphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/deprecated.php (21734 => 21735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/deprecated.php        2012-09-04 14:44:17 UTC (rev 21734)
+++ trunk/wp-includes/deprecated.php        2012-09-04 16:29:28 UTC (rev 21735)
</span><span class="lines">@@ -57,14 +57,14 @@
</span><span class="cx">  * @deprecated Use The Loop - {@link http://codex.wordpress.org/The_Loop Use new WordPress Loop}
</span><span class="cx">  */
</span><span class="cx"> function start_wp() {
</span><del>-        global $wp_query, $post;
</del><ins>+        global $wp_query;
</ins><span class="cx"> 
</span><span class="cx">         _deprecated_function( __FUNCTION__, '1.5', __('new WordPress Loop') );
</span><span class="cx"> 
</span><span class="cx">         // Since the old style loop is being used, advance the query iterator here.
</span><span class="cx">         $wp_query-&gt;next_post();
</span><span class="cx"> 
</span><del>-        setup_postdata($post);
</del><ins>+        setup_postdata( get_post() );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span></span></pre></div>
<a id="trunkwpincludesgeneraltemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/general-template.php (21734 => 21735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/general-template.php        2012-09-04 14:44:17 UTC (rev 21734)
+++ trunk/wp-includes/general-template.php        2012-09-04 16:29:28 UTC (rev 21735)
</span><span class="lines">@@ -1311,8 +1311,7 @@
</span><span class="cx">  * @since 1.0.0
</span><span class="cx">  */
</span><span class="cx"> function the_date_xml() {
</span><del>-        global $post;
-        echo mysql2date('Y-m-d', $post-&gt;post_date, false);
</del><ins>+        echo mysql2date( 'Y-m-d', get_post()-&gt;post_date, false );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -1367,7 +1366,7 @@
</span><span class="cx">  * @return string|null Null if displaying, string if retrieving.
</span><span class="cx">  */
</span><span class="cx"> function get_the_date( $d = '' ) {
</span><del>-        global $post;
</del><ins>+        $post = get_post();
</ins><span class="cx">         $the_date = '';
</span><span class="cx"> 
</span><span class="cx">         if ( '' == $d )
</span><span class="lines">@@ -1528,8 +1527,8 @@
</span><span class="cx">  * @uses $post
</span><span class="cx">  */
</span><span class="cx"> function the_weekday() {
</span><del>-        global $wp_locale, $post;
-        $the_weekday = $wp_locale-&gt;get_weekday(mysql2date('w', $post-&gt;post_date, false));
</del><ins>+        global $wp_locale;
+        $the_weekday = $wp_locale-&gt;get_weekday( mysql2date( 'w', get_post()-&gt;post_date, false ) );
</ins><span class="cx">         $the_weekday = apply_filters('the_weekday', $the_weekday);
</span><span class="cx">         echo $the_weekday;
</span><span class="cx"> }
</span><span class="lines">@@ -1546,11 +1545,11 @@
</span><span class="cx">  * @param string $after Optional Output after the date.
</span><span class="cx">  */
</span><span class="cx"> function the_weekday_date($before='',$after='') {
</span><del>-        global $wp_locale, $post, $day, $previousweekday;
</del><ins>+        global $wp_locale, $day, $previousweekday;
</ins><span class="cx">         $the_weekday_date = '';
</span><span class="cx">         if ( $currentday != $previousweekday ) {
</span><span class="cx">                 $the_weekday_date .= $before;
</span><del>-                $the_weekday_date .= $wp_locale-&gt;get_weekday(mysql2date('w', $post-&gt;post_date, false));
</del><ins>+                $the_weekday_date .= $wp_locale-&gt;get_weekday( mysql2date( 'w', get_post()-&gt;post_date, false ) );
</ins><span class="cx">                 $the_weekday_date .= $after;
</span><span class="cx">                 $previousweekday = $currentday;
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkwpincludeslinktemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/link-template.php (21734 => 21735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/link-template.php        2012-09-04 14:44:17 UTC (rev 21734)
+++ trunk/wp-includes/link-template.php        2012-09-04 16:29:28 UTC (rev 21735)
</span><span class="lines">@@ -54,11 +54,11 @@
</span><span class="cx">  *
</span><span class="cx">  * @param string $mode Permalink mode can be either 'title', 'id', or default, which is 'id'.
</span><span class="cx">  */
</span><del>-function permalink_anchor($mode = 'id') {
-        global $post;
-        switch ( strtolower($mode) ) {
</del><ins>+function permalink_anchor( $mode = 'id' ) {
+        $post = get_post();
+        switch ( strtolower( $mode ) ) {
</ins><span class="cx">                 case 'title':
</span><del>-                        $title = sanitize_title($post-&gt;post_title) . '-' . $post-&gt;ID;
</del><ins>+                        $title = sanitize_title( $post-&gt;post_title ) . '-' . $post-&gt;ID;
</ins><span class="cx">                         echo '&lt;a id=&quot;'.$title.'&quot;&gt;&lt;/a&gt;';
</span><span class="cx">                         break;
</span><span class="cx">                 case 'id':
</span><span class="lines">@@ -77,7 +77,7 @@
</span><span class="cx">  * @param bool $leavename Optional, defaults to false. Whether to keep post name or page name.
</span><span class="cx">  * @return string
</span><span class="cx">  */
</span><del>-function get_permalink($id = 0, $leavename = false) {
</del><ins>+function get_permalink( $id = 0, $leavename = false ) {
</ins><span class="cx">         $rewritecode = array(
</span><span class="cx">                 '%year%',
</span><span class="cx">                 '%monthnum%',
</span><span class="lines">@@ -232,24 +232,20 @@
</span><span class="cx">  *
</span><span class="cx">  * @since 1.5.0
</span><span class="cx">  *
</span><del>- * @param int $id Optional. Post ID.
</del><ins>+ * @param mixed $post Optional. Post ID or object.
</ins><span class="cx">  * @param bool $leavename Optional, defaults to false. Whether to keep page name.
</span><span class="cx">  * @param bool $sample Optional, defaults to false. Is it a sample permalink.
</span><span class="cx">  * @return string
</span><span class="cx">  */
</span><del>-function get_page_link( $id = false, $leavename = false, $sample = false ) {
-        global $post;
</del><ins>+function get_page_link( $post = false, $leavename = false, $sample = false ) {
+        $post = get_post( $post );
</ins><span class="cx"> 
</span><del>-        $id = (int) $id;
-        if ( !$id )
-                $id = (int) $post-&gt;ID;
-
-        if ( 'page' == get_option('show_on_front') &amp;&amp; $id == get_option('page_on_front') )
</del><ins>+        if ( 'page' == get_option( 'show_on_front' ) &amp;&amp; $post-&gt;ID == get_option( 'page_on_front' ) )
</ins><span class="cx">                 $link = home_url('/');
</span><span class="cx">         else
</span><del>-                $link = _get_page_link( $id , $leavename, $sample );
</del><ins>+                $link = _get_page_link( $post, $leavename, $sample );
</ins><span class="cx"> 
</span><del>-        return apply_filters('page_link', $link, $id, $sample);
</del><ins>+        return apply_filters( 'page_link', $link, $post-&gt;ID, $sample );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -260,15 +256,15 @@
</span><span class="cx">  * @since 2.1.0
</span><span class="cx">  * @access private
</span><span class="cx">  *
</span><del>- * @param int $id Optional. Post ID.
</del><ins>+ * @param mixed $post Optional. Post ID or object.
</ins><span class="cx">  * @param bool $leavename Optional. Leave name.
</span><span class="cx">  * @param bool $sample Optional. Sample permalink.
</span><span class="cx">  * @return string
</span><span class="cx">  */
</span><del>-function _get_page_link( $id = false, $leavename = false, $sample = false ) {
</del><ins>+function _get_page_link( $post = false, $leavename = false, $sample = false ) {
</ins><span class="cx">         global $wp_rewrite;
</span><span class="cx"> 
</span><del>-        $post = get_post( $id );
</del><ins>+        $post = get_post( $post );
</ins><span class="cx"> 
</span><span class="cx">         $draft_or_pending = in_array( $post-&gt;post_status, array( 'draft', 'pending', 'auto-draft' ) );
</span><span class="cx"> 
</span><span class="lines">@@ -276,16 +272,16 @@
</span><span class="cx"> 
</span><span class="cx">         if ( !empty($link) &amp;&amp; ( ( isset($post-&gt;post_status) &amp;&amp; !$draft_or_pending ) || $sample ) ) {
</span><span class="cx">                 if ( ! $leavename ) {
</span><del>-                        $link = str_replace('%pagename%', get_page_uri($id), $link);
</del><ins>+                        $link = str_replace('%pagename%', get_page_uri( $post ), $link);
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 $link = home_url($link);
</span><span class="cx">                 $link = user_trailingslashit($link, 'page');
</span><span class="cx">         } else {
</span><del>-                $link = home_url(&quot;?page_id=$id&quot;);
</del><ins>+                $link = home_url( '?page_id=' . $post-&gt;ID );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        return apply_filters( '_get_page_link', $link, $id );
</del><ins>+        return apply_filters( '_get_page_link', $link, $post-&gt;ID );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -295,38 +291,36 @@
</span><span class="cx">  *
</span><span class="cx">  * @since 2.0.0
</span><span class="cx">  *
</span><del>- * @param int $id Optional. Post ID.
</del><ins>+ * @param mixed $post Optional. Post ID or object.
</ins><span class="cx">  * @return string
</span><span class="cx">  */
</span><del>-function get_attachment_link($id = false) {
-        global $post, $wp_rewrite;
</del><ins>+function get_attachment_link( $post = null ) {
+        global $wp_rewrite;
</ins><span class="cx"> 
</span><span class="cx">         $link = false;
</span><span class="cx"> 
</span><del>-        if ( ! $id)
-                $id = (int) $post-&gt;ID;
</del><ins>+        $post = get_post( $post );
</ins><span class="cx"> 
</span><del>-        $object = get_post($id);
-        if ( $wp_rewrite-&gt;using_permalinks() &amp;&amp; ($object-&gt;post_parent &gt; 0) &amp;&amp; ($object-&gt;post_parent != $id) ) {
-                $parent = get_post($object-&gt;post_parent);
</del><ins>+        if ( $wp_rewrite-&gt;using_permalinks() &amp;&amp; ( $post-&gt;post_parent &gt; 0 ) &amp;&amp; ( $post-&gt;post_parent != $post-&gt;ID ) ) {
+                $parent = get_post($post-&gt;post_parent);
</ins><span class="cx">                 if ( 'page' == $parent-&gt;post_type )
</span><del>-                        $parentlink = _get_page_link( $object-&gt;post_parent ); // Ignores page_on_front
</del><ins>+                        $parentlink = _get_page_link( $post-&gt;post_parent ); // Ignores page_on_front
</ins><span class="cx">                 else
</span><del>-                        $parentlink = get_permalink( $object-&gt;post_parent );
</del><ins>+                        $parentlink = get_permalink( $post-&gt;post_parent );
</ins><span class="cx"> 
</span><del>-                if ( is_numeric($object-&gt;post_name) || false !== strpos(get_option('permalink_structure'), '%category%') )
-                        $name = 'attachment/' . $object-&gt;post_name; // &lt;permalink&gt;/&lt;int&gt;/ is paged so we use the explicit attachment marker
</del><ins>+                if ( is_numeric($post-&gt;post_name) || false !== strpos(get_option('permalink_structure'), '%category%') )
+                        $name = 'attachment/' . $post-&gt;post_name; // &lt;permalink&gt;/&lt;int&gt;/ is paged so we use the explicit attachment marker
</ins><span class="cx">                 else
</span><del>-                        $name = $object-&gt;post_name;
</del><ins>+                        $name = $post-&gt;post_name;
</ins><span class="cx"> 
</span><span class="cx">                 if ( strpos($parentlink, '?') === false )
</span><span class="cx">                         $link = user_trailingslashit( trailingslashit($parentlink) . $name );
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if ( ! $link )
</span><del>-                $link = home_url( &quot;/?attachment_id=$id&quot; );
</del><ins>+                $link = home_url( '/?attachment_id=' . $post-&gt;ID );
</ins><span class="cx"> 
</span><del>-        return apply_filters('attachment_link', $link, $id);
</del><ins>+        return apply_filters( 'attachment_link', $link, $post-&gt;ID );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -895,7 +889,7 @@
</span><span class="cx">  * @return string
</span><span class="cx">  */
</span><span class="cx"> function get_edit_post_link( $id = 0, $context = 'display' ) {
</span><del>-        if ( !$post = get_post( $id ) )
</del><ins>+        if ( ! $post = get_post( $id ) )
</ins><span class="cx">                 return;
</span><span class="cx"> 
</span><span class="cx">         if ( 'display' == $context )
</span><span class="lines">@@ -1122,9 +1116,9 @@
</span><span class="cx">  * @return mixed Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists.
</span><span class="cx">  */
</span><span class="cx"> function get_adjacent_post( $in_same_cat = false, $excluded_categories = '', $previous = true ) {
</span><del>-        global $post, $wpdb;
</del><ins>+        global $wpdb;
</ins><span class="cx"> 
</span><del>-        if ( empty( $post ) )
</del><ins>+        if ( ! $post = get_post() )
</ins><span class="cx">                 return null;
</span><span class="cx"> 
</span><span class="cx">         $current_post_date = $post-&gt;post_date;
</span><span class="lines">@@ -1207,10 +1201,10 @@
</span><span class="cx">  * @return string
</span><span class="cx">  */
</span><span class="cx"> function get_adjacent_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $previous = true) {
</span><del>-        if ( $previous &amp;&amp; is_attachment() &amp;&amp; is_object( $GLOBALS['post'] ) )
-                $post = get_post($GLOBALS['post']-&gt;post_parent);
</del><ins>+        if ( $previous &amp;&amp; is_attachment() &amp;&amp; $post = get_post() )
+                $post = get_post( $post-&gt;post_parent );
</ins><span class="cx">         else
</span><del>-                $post = get_adjacent_post($in_same_cat,$excluded_categories,$previous);
</del><ins>+                $post = get_adjacent_post( $in_same_cat, $excluded_categories, $previous );
</ins><span class="cx"> 
</span><span class="cx">         if ( empty($post) )
</span><span class="cx">                 return;
</span><span class="lines">@@ -1299,9 +1293,8 @@
</span><span class="cx">  * @return object
</span><span class="cx">  */
</span><span class="cx"> function get_boundary_post( $in_same_cat = false, $excluded_categories = '', $start = true ) {
</span><del>-        global $post;
-
-        if ( empty($post) || ! is_single() || is_attachment() )
</del><ins>+        $post = get_post();
+        if ( ! $post || ! is_single() || is_attachment() )
</ins><span class="cx">                 return null;
</span><span class="cx"> 
</span><span class="cx">         $cat_array = array();
</span><span class="lines">@@ -1373,7 +1366,7 @@
</span><span class="cx">  */
</span><span class="cx"> function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {
</span><span class="cx">         if ( $previous &amp;&amp; is_attachment() )
</span><del>-                $post = get_post($GLOBALS['post']-&gt;post_parent);
</del><ins>+                $post = get_post( get_post()-&gt;post_parent );
</ins><span class="cx">         else
</span><span class="cx">                 $post = get_adjacent_post($in_same_cat, $excluded_categories, $previous);
</span><span class="cx"> 
</span><span class="lines">@@ -1680,11 +1673,11 @@
</span><span class="cx">  * @return string
</span><span class="cx">  */
</span><span class="cx"> function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) {
</span><del>-        global $post, $wp_rewrite;
</del><ins>+        global $wp_rewrite;
</ins><span class="cx"> 
</span><span class="cx">         $pagenum = (int) $pagenum;
</span><span class="cx"> 
</span><del>-        $result = get_permalink( $post-&gt;ID );
</del><ins>+        $result = get_permalink();
</ins><span class="cx"> 
</span><span class="cx">         if ( 'newest' == get_option('default_comments_page') ) {
</span><span class="cx">                 if ( $pagenum != $max_page ) {
</span><span class="lines">@@ -2412,15 +2405,13 @@
</span><span class="cx">  * @param string $after Optional HTML to display after the link.
</span><span class="cx">  */
</span><span class="cx"> function the_shortlink( $text = '', $title = '', $before = '', $after = '' ) {
</span><del>-        global $post;
-
</del><span class="cx">         if ( empty( $text ) )
</span><span class="cx">                 $text = __('This is the short link.');
</span><span class="cx"> 
</span><span class="cx">         if ( empty( $title ) )
</span><span class="cx">                 $title = the_title_attribute( array( 'echo' =&gt; false ) );
</span><span class="cx"> 
</span><del>-        $shortlink = wp_get_shortlink( $post-&gt;ID );
</del><ins>+        $shortlink = wp_get_shortlink();
</ins><span class="cx"> 
</span><span class="cx">         if ( !empty( $shortlink ) ) {
</span><span class="cx">                 $link = '&lt;a rel=&quot;shortlink&quot; href=&quot;' . esc_url( $shortlink ) . '&quot; title=&quot;' . $title . '&quot;&gt;' . $text . '&lt;/a&gt;';
</span></span></pre></div>
<a id="trunkwpincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/media.php (21734 => 21735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/media.php        2012-09-04 14:44:17 UTC (rev 21734)
+++ trunk/wp-includes/media.php        2012-09-04 16:29:28 UTC (rev 21735)
</span><span class="lines">@@ -775,7 +775,7 @@
</span><span class="cx">  * @return string HTML content to display gallery.
</span><span class="cx">  */
</span><span class="cx"> function gallery_shortcode($attr) {
</span><del>-        global $post;
</del><ins>+        $post = get_post();
</ins><span class="cx"> 
</span><span class="cx">         static $instance = 0;
</span><span class="cx">         $instance++;
</span><span class="lines">@@ -928,9 +928,8 @@
</span><span class="cx">  * @param bool $prev Optional. Default is true to display previous link, false for next.
</span><span class="cx">  */
</span><span class="cx"> function adjacent_image_link($prev = true, $size = 'thumbnail', $text = false) {
</span><del>-        global $post;
-        $post = get_post($post);
-        $attachments = array_values(get_children( array('post_parent' =&gt; $post-&gt;post_parent, 'post_status' =&gt; 'inherit', 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'image', 'order' =&gt; 'ASC', 'orderby' =&gt; 'menu_order ID') ));
</del><ins>+        $post = get_post();
+        $attachments = array_values( get_children( array( 'post_parent' =&gt; $post-&gt;post_parent, 'post_status' =&gt; 'inherit', 'post_type' =&gt; 'attachment', 'post_mime_type' =&gt; 'image', 'order' =&gt; 'ASC', 'orderby' =&gt; 'menu_order ID' ) ) );
</ins><span class="cx"> 
</span><span class="cx">         foreach ( $attachments as $k =&gt; $attachment )
</span><span class="cx">                 if ( $attachment-&gt;ID == $post-&gt;ID )
</span><span class="lines">@@ -1102,16 +1101,16 @@
</span><span class="cx">          * an AJAX request that will call WP_Embed::cache_oembed().
</span><span class="cx">          */
</span><span class="cx">         function maybe_run_ajax_cache() {
</span><del>-                global $post_ID;
</del><ins>+                $post = get_post();
</ins><span class="cx"> 
</span><del>-                if ( empty($post_ID) || empty($_GET['message']) || 1 != $_GET['message'] )
</del><ins>+                if ( ! $post || empty($_GET['message']) || 1 != $_GET['message'] )
</ins><span class="cx">                         return;
</span><span class="cx"> 
</span><span class="cx"> ?&gt;
</span><span class="cx"> &lt;script type=&quot;text/javascript&quot;&gt;
</span><span class="cx"> /* &lt;![CDATA[ */
</span><span class="cx">         jQuery(document).ready(function($){
</span><del>-                $.get(&quot;&lt;?php echo admin_url( 'admin-ajax.php?action=oembed-cache&amp;post=' . $post_ID, 'relative' ); ?&gt;&quot;);
</del><ins>+                $.get(&quot;&lt;?php echo admin_url( 'admin-ajax.php?action=oembed-cache&amp;post=' . $post-&gt;ID, 'relative' ); ?&gt;&quot;);
</ins><span class="cx">         });
</span><span class="cx"> /* ]]&gt; */
</span><span class="cx"> &lt;/script&gt;
</span><span class="lines">@@ -1167,9 +1166,9 @@
</span><span class="cx">          * @return string The embed HTML on success, otherwise the original URL.
</span><span class="cx">          */
</span><span class="cx">         function shortcode( $attr, $url = '' ) {
</span><del>-                global $post;
</del><ins>+                $post = get_post();
</ins><span class="cx"> 
</span><del>-                if ( empty($url) )
</del><ins>+                if ( empty( $url ) )
</ins><span class="cx">                         return '';
</span><span class="cx"> 
</span><span class="cx">                 $rawattr = $attr;
</span><span class="lines">@@ -1190,8 +1189,8 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                $post_ID = ( !empty($post-&gt;ID) ) ? $post-&gt;ID : null;
-                if ( !empty($this-&gt;post_ID) ) // Potentially set by WP_Embed::cache_oembed()
</del><ins>+                $post_ID = ( ! empty( $post-&gt;ID ) ) ? $post-&gt;ID : null;
+                if ( ! empty( $this-&gt;post_ID ) ) // Potentially set by WP_Embed::cache_oembed()
</ins><span class="cx">                         $post_ID = $this-&gt;post_ID;
</span><span class="cx"> 
</span><span class="cx">                 // Unknown URL format. Let oEmbed have a go.
</span><span class="lines">@@ -1206,7 +1205,7 @@
</span><span class="cx">                                 if ( '{{unknown}}' === $cache )
</span><span class="cx">                                         return $this-&gt;maybe_make_link( $url );
</span><span class="cx"> 
</span><del>-                                if ( !empty($cache) )
</del><ins>+                                if ( ! empty( $cache ) )
</ins><span class="cx">                                         return apply_filters( 'embed_oembed_html', $cache, $url, $attr, $post_ID );
</span><span class="cx">                         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludesposttemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post-template.php (21734 => 21735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post-template.php        2012-09-04 14:44:17 UTC (rev 21734)
+++ trunk/wp-includes/post-template.php        2012-09-04 16:29:28 UTC (rev 21735)
</span><span class="lines">@@ -26,8 +26,7 @@
</span><span class="cx">  * @return int
</span><span class="cx">  */
</span><span class="cx"> function get_the_ID() {
</span><del>-        global $post;
-        return $post-&gt;ID;
</del><ins>+        return get_post()-&gt;ID;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -97,24 +96,25 @@
</span><span class="cx">  *
</span><span class="cx">  * @since 0.71
</span><span class="cx">  *
</span><del>- * @param int $id Optional. Post ID.
</del><ins>+ * @param mixed $post Optional. Post ID or object.
</ins><span class="cx">  * @return string
</span><span class="cx">  */
</span><del>-function get_the_title( $id = 0 ) {
-        $post = get_post($id);
</del><ins>+function get_the_title( $post = 0 ) {
+        $post = get_post( $post );
</ins><span class="cx"> 
</span><del>-        $title = isset($post-&gt;post_title) ? $post-&gt;post_title : '';
-        $id = isset($post-&gt;ID) ? $post-&gt;ID : (int) $id;
</del><ins>+        $title = isset( $post-&gt;post_title ) ? $post-&gt;post_title : '';
+        $id = isset( $post-&gt;ID ) ? $post-&gt;ID : 0;
</ins><span class="cx"> 
</span><del>-        if ( !is_admin() ) {
-                if ( !empty($post-&gt;post_password) ) {
-                        $protected_title_format = apply_filters('protected_title_format', __('Protected: %s'));
-                        $title = sprintf($protected_title_format, $title);
-                } else if ( isset($post-&gt;post_status) &amp;&amp; 'private' == $post-&gt;post_status ) {
-                        $private_title_format = apply_filters('private_title_format', __('Private: %s'));
-                        $title = sprintf($private_title_format, $title);
</del><ins>+        if ( ! is_admin() ) {
+                if ( ! empty( $post-&gt;post_password ) ) {
+                        $protected_title_format = apply_filters( 'protected_title_format', __( 'Protected: %s' ) );
+                        $title = sprintf( $protected_title_format, $title );
+                } else if ( isset( $post-&gt;post_status ) &amp;&amp; 'private' == $post-&gt;post_status ) {
+                        $private_title_format = apply_filters( 'private_title_format', __( 'Private: %s' ) );
+                        $title = sprintf( $private_title_format, $title );
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><ins>+
</ins><span class="cx">         return apply_filters( 'the_title', $title, $id );
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -177,9 +177,11 @@
</span><span class="cx">  * @param bool $stripteaser Optional. Strip teaser content before the more text. Default is false.
</span><span class="cx">  * @return string
</span><span class="cx">  */
</span><del>-function get_the_content($more_link_text = null, $stripteaser = false) {
-        global $post, $more, $page, $pages, $multipage, $preview;
</del><ins>+function get_the_content( $more_link_text = null, $stripteaser = false ) {
+        global $more, $page, $pages, $multipage, $preview;
</ins><span class="cx"> 
</span><ins>+        $post = get_post();
+
</ins><span class="cx">         if ( null === $more_link_text )
</span><span class="cx">                 $more_link_text = __( '(more...)' );
</span><span class="cx"> 
</span><span class="lines">@@ -187,7 +189,7 @@
</span><span class="cx">         $hasTeaser = false;
</span><span class="cx"> 
</span><span class="cx">         // If post password required and it doesn't match the cookie.
</span><del>-        if ( post_password_required($post) )
</del><ins>+        if ( post_password_required() )
</ins><span class="cx">                 return get_the_password_form();
</span><span class="cx"> 
</span><span class="cx">         if ( $page &gt; count($pages) ) // if the requested page doesn't exist
</span><span class="lines">@@ -259,8 +261,7 @@
</span><span class="cx">         if ( !empty( $deprecated ) )
</span><span class="cx">                 _deprecated_argument( __FUNCTION__, '2.3' );
</span><span class="cx"> 
</span><del>-        global $post;
-        if ( post_password_required($post) ) {
</del><ins>+        if ( post_password_required() ) {
</ins><span class="cx">                 return __( 'There is no excerpt because this is a protected post.' );
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -676,7 +677,8 @@
</span><span class="cx">  * @return string Link.
</span><span class="cx">  */
</span><span class="cx"> function _wp_link_page( $i ) {
</span><del>-        global $post, $wp_rewrite;
</del><ins>+        global $wp_rewrite;
+        $post = get_post();
</ins><span class="cx"> 
</span><span class="cx">         if ( 1 == $i ) {
</span><span class="cx">                 $url = get_permalink();
</span><span class="lines">@@ -1171,7 +1173,7 @@
</span><span class="cx">  * @return string
</span><span class="cx">  */
</span><span class="cx"> function prepend_attachment($content) {
</span><del>-        global $post;
</del><ins>+        $post = get_post();
</ins><span class="cx"> 
</span><span class="cx">         if ( empty($post-&gt;post_type) || $post-&gt;post_type != 'attachment' )
</span><span class="cx">                 return $content;
</span><span class="lines">@@ -1198,7 +1200,7 @@
</span><span class="cx">  * @return string HTML content for password form for password protected post.
</span><span class="cx">  */
</span><span class="cx"> function get_the_password_form() {
</span><del>-        global $post;
</del><ins>+        $post = get_post();
</ins><span class="cx">         $label = 'pwbox-' . ( empty($post-&gt;ID) ? rand() : $post-&gt;ID );
</span><span class="cx">         $output = '&lt;form action=&quot;' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '&quot; method=&quot;post&quot;&gt;
</span><span class="cx">         &lt;p&gt;' . __(&quot;This post is password protected. To view it please enter your password below:&quot;) . '&lt;/p&gt;
</span></span></pre></div>
<a id="trunkwpincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post.php (21734 => 21735)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post.php        2012-09-04 14:44:17 UTC (rev 21734)
+++ trunk/wp-includes/post.php        2012-09-04 16:29:28 UTC (rev 21735)
</span><span class="lines">@@ -372,12 +372,12 @@
</span><span class="cx">  * @uses $wpdb
</span><span class="cx">  * @link http://codex.wordpress.org/Function_Reference/get_post
</span><span class="cx">  *
</span><del>- * @param int|object $post Post ID or post object.
</del><ins>+ * @param int|object $post Post ID or post object. Optional, default is the current post from the loop.
</ins><span class="cx">  * @param string $output Optional, default is Object. Either OBJECT, ARRAY_A, or ARRAY_N.
</span><span class="cx">  * @param string $filter Optional, default is raw.
</span><span class="cx">  * @return WP_Post|null WP_Post on success or null on failure
</span><span class="cx">  */
</span><del>-function get_post( $post, $output = OBJECT, $filter = 'raw' ) {
</del><ins>+function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) {
</ins><span class="cx">         if ( empty( $post ) &amp;&amp; isset( $GLOBALS['post'] ) )
</span><span class="cx">                 $post = $GLOBALS['post'];
</span><span class="cx"> 
</span><span class="lines">@@ -945,20 +945,13 @@
</span><span class="cx">  *
</span><span class="cx">  * @uses $post The Loop current post global
</span><span class="cx">  *
</span><del>- * @param mixed $the_post Optional. Post object or post ID.
</del><ins>+ * @param mixed $post Optional. Post object or post ID.
</ins><span class="cx">  * @return bool|string post type or false on failure.
</span><span class="cx">  */
</span><del>-function get_post_type( $the_post = false ) {
-        global $post;
</del><ins>+function get_post_type( $post = null ) {
+        if ( $post = get_post( $post ) )
+                return $post-&gt;post_type;
</ins><span class="cx"> 
</span><del>-        if ( false === $the_post )
-                $the_post = $post;
-        elseif ( is_numeric($the_post) )
-                $the_post = get_post($the_post);
-
-        if ( is_object($the_post) )
-                return $the_post-&gt;post_type;
-
</del><span class="cx">         return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>