<!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>[16227] trunk/wp-admin/includes/class-wp-media-list-table.php:
  WP_Media_List_Table: Use class property instead of $detached global.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/16227">16227</a></dd>
<dt>Author</dt> <dd>scribu</dd>
<dt>Date</dt> <dd>2010-11-06 22:47:12 +0000 (Sat, 06 Nov 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>WP_Media_List_Table: Use class property instead of $detached global. See <a href="http://trac.wordpress.org/ticket/14579">#14579</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesclasswpmedialisttablephp">trunk/wp-admin/includes/class-wp-media-list-table.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesclasswpmedialisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-media-list-table.php (16226 => 16227)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-media-list-table.php        2010-11-06 21:49:23 UTC (rev 16226)
+++ trunk/wp-admin/includes/class-wp-media-list-table.php        2010-11-06 22:47:12 UTC (rev 16227)
</span><span class="lines">@@ -9,12 +9,9 @@
</span><span class="cx"> class WP_Media_List_Table extends WP_List_Table {
</span><span class="cx"> 
</span><span class="cx">         function WP_Media_List_Table() {
</span><del>-                global $detached;
</del><ins>+                $this-&gt;detached = isset( $_REQUEST['detached'] ) || isset( $_REQUEST['find_detached'] );
</ins><span class="cx"> 
</span><del>-                $detached = isset( $_REQUEST['detached'] ) || isset( $_REQUEST['find_detached'] );
-
</del><span class="cx">                 parent::WP_List_Table( array(
</span><del>-                        'screen' =&gt; $detached ? 'upload-detached' : 'upload',
</del><span class="cx">                         'plural' =&gt; 'media'
</span><span class="cx">                 ) );
</span><span class="cx">         }
</span><span class="lines">@@ -44,7 +41,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function get_views() {
</span><del>-                global $wpdb, $post_mime_types, $detached, $avail_post_mime_types;
</del><ins>+                global $wpdb, $post_mime_types, $avail_post_mime_types;
</ins><span class="cx"> 
</span><span class="cx">                 $type_links = array();
</span><span class="cx">                 $_num_posts = (array) wp_count_attachments();
</span><span class="lines">@@ -56,7 +53,7 @@
</span><span class="cx">                         foreach ( $reals as $real )
</span><span class="cx">                                 $num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real];
</span><span class="cx"> 
</span><del>-                $class = ( empty($_GET['post_mime_type']) &amp;&amp; !$detached &amp;&amp; !isset($_GET['status']) ) ? ' class=&quot;current&quot;' : '';
</del><ins>+                $class = ( empty($_GET['post_mime_type']) &amp;&amp; !$this-&gt;detached &amp;&amp; !isset($_GET['status']) ) ? ' class=&quot;current&quot;' : '';
</ins><span class="cx">                 $type_links['all'] = &quot;&lt;a href='upload.php'$class&gt;&quot; . sprintf( _nx( 'All &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', 'All &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', $_total_posts, 'uploaded files' ), number_format_i18n( $_total_posts ) ) . '&lt;/a&gt;';
</span><span class="cx">                 foreach ( $post_mime_types as $mime_type =&gt; $label ) {
</span><span class="cx">                         $class = '';
</span><span class="lines">@@ -69,7 +66,7 @@
</span><span class="cx">                         if ( !empty( $num_posts[$mime_type] ) )
</span><span class="cx">                                 $type_links[$mime_type] = &quot;&lt;a href='upload.php?post_mime_type=$mime_type'$class&gt;&quot; . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '&lt;/a&gt;';
</span><span class="cx">                 }
</span><del>-                $type_links['detached'] = '&lt;a href=&quot;upload.php?detached=1&quot;' . ( $detached ? ' class=&quot;current&quot;' : '' ) . '&gt;' . sprintf( _nx( 'Unattached &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', 'Unattached &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . '&lt;/a&gt;';
</del><ins>+                $type_links['detached'] = '&lt;a href=&quot;upload.php?detached=1&quot;' . ( $this-&gt;detached ? ' class=&quot;current&quot;' : '' ) . '&gt;' . sprintf( _nx( 'Unattached &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', 'Unattached &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . '&lt;/a&gt;';
</ins><span class="cx"> 
</span><span class="cx">                 if ( !empty($_num_posts['trash']) )
</span><span class="cx">                         $type_links['trash'] = '&lt;a href=&quot;upload.php?status=trash&quot;' . ( (isset($_GET['status']) &amp;&amp; $_GET['status'] == 'trash' ) ? ' class=&quot;current&quot;' : '') . '&gt;' . sprintf( _nx( 'Trash &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', 'Trash &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', $_num_posts['trash'], 'uploaded files' ), number_format_i18n( $_num_posts['trash'] ) ) . '&lt;/a&gt;';
</span><span class="lines">@@ -78,30 +75,28 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function get_bulk_actions() {
</span><del>-                global $detached;
-
</del><span class="cx">                 $actions = array();
</span><span class="cx">                 $actions['delete'] = __( 'Delete Permanently' );
</span><del>-                if ( $detached )
</del><ins>+                if ( $this-&gt;detached )
</ins><span class="cx">                         $actions['attach'] = __( 'Attach to a post' );
</span><span class="cx"> 
</span><span class="cx">                 return $actions;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function extra_tablenav( $which ) {
</span><del>-                global $post_type, $detached;
</del><ins>+                global $post_type;
</ins><span class="cx">                 $post_type_obj = get_post_type_object( $post_type );
</span><span class="cx"> ?&gt;
</span><span class="cx">                 &lt;div class=&quot;alignleft actions&quot;&gt;
</span><span class="cx"> &lt;?php
</span><del>-                if ( 'top' == $which &amp;&amp; !is_singular() &amp;&amp; !$detached &amp;&amp; !$this-&gt;is_trash ) {
</del><ins>+                if ( 'top' == $which &amp;&amp; !is_singular() &amp;&amp; !$this-&gt;detached &amp;&amp; !$this-&gt;is_trash ) {
</ins><span class="cx">                         $this-&gt;months_dropdown( $post_type );
</span><span class="cx"> 
</span><span class="cx">                         do_action( 'restrict_manage_posts' );
</span><span class="cx">                         submit_button( __( 'Filter' ), 'secondary', 'post-query-submit', false );
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                if ( $detached ) {
</del><ins>+                if ( $this-&gt;detached ) {
</ins><span class="cx">                         submit_button( __( 'Scan for lost attachments' ), 'secondary', 'find_detached', false );
</span><span class="cx">                 } elseif ( $this-&gt;is_trash &amp;&amp; current_user_can( 'edit_others_posts' ) ) { 
</span><span class="cx">                         submit_button( __( 'Empty Trash' ), 'button-secondary apply', 'delete_all', false );
</span><span class="lines">@@ -128,9 +123,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function no_items() {
</span><del>-                global $detached;
-                
-                if ( $detached ) {
</del><ins>+                if ( $this-&gt;detached ) {
</ins><span class="cx"> ?&gt;
</span><span class="cx">                 &lt;div class=&quot;tablenav&quot;&gt;
</span><span class="cx">                         &lt;?php $this-&gt;extra_tablenav( 'top' ); ?&gt;
</span><span class="lines">@@ -151,13 +144,13 @@
</span><span class="cx">                 $posts_columns['author'] = __( 'Author' );
</span><span class="cx">                 //$posts_columns['tags'] = _x( 'Tags', 'column name' );
</span><span class="cx">                 /* translators: column name */
</span><del>-                if ( 'upload' == $this-&gt;screen-&gt;id ) {
</del><ins>+                if ( !$this-&gt;detached ) {
</ins><span class="cx">                         $posts_columns['parent'] = _x( 'Attached to', 'column name' );
</span><span class="cx">                         $posts_columns['comments'] = '&lt;div class=&quot;vers&quot;&gt;&lt;img alt=&quot;Comments&quot; src=&quot;' . esc_url( admin_url( 'images/comment-grey-bubble.png' ) ) . '&quot; /&gt;&lt;/div&gt;';
</span><span class="cx">                 }
</span><span class="cx">                 /* translators: column name */
</span><span class="cx">                 $posts_columns['date'] = _x( 'Date', 'column name' );
</span><del>-                $posts_columns = apply_filters( 'manage_media_columns', $posts_columns, 'upload' != $this-&gt;screen-&gt;id );
</del><ins>+                $posts_columns = apply_filters( 'manage_media_columns', $posts_columns, $this-&gt;detached );
</ins><span class="cx"> 
</span><span class="cx">                 return $posts_columns;
</span><span class="cx">         }
</span><span class="lines">@@ -173,9 +166,9 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function display_rows() {
</span><del>-                global $detached, $post, $id;
</del><ins>+                global $post, $id;
</ins><span class="cx"> 
</span><del>-                if ( $detached ) {
</del><ins>+                if ( $this-&gt;detached ) {
</ins><span class="cx">                         $this-&gt;display_orphans();
</span><span class="cx">                         return;
</span><span class="cx">                 }
</span></span></pre>
</div>
</div>

</body>
</html>