<!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->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' => $detached ? 'upload-detached' : 'upload',
</del><span class="cx">                         'plural' => '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']) && !$detached && !isset($_GET['status']) ) ? ' class="current"' : '';
</del><ins>+                $class = ( empty($_GET['post_mime_type']) && !$this->detached && !isset($_GET['status']) ) ? ' class="current"' : '';
</ins><span class="cx">                 $type_links['all'] = "<a href='upload.php'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $_total_posts, 'uploaded files' ), number_format_i18n( $_total_posts ) ) . '</a>';
</span><span class="cx">                 foreach ( $post_mime_types as $mime_type => $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] = "<a href='upload.php?post_mime_type=$mime_type'$class>" . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</a>';
</span><span class="cx">                 }
</span><del>-                $type_links['detached'] = '<a href="upload.php?detached=1"' . ( $detached ? ' class="current"' : '' ) . '>' . sprintf( _nx( 'Unattached <span class="count">(%s)</span>', 'Unattached <span class="count">(%s)</span>', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . '</a>';
</del><ins>+                $type_links['detached'] = '<a href="upload.php?detached=1"' . ( $this->detached ? ' class="current"' : '' ) . '>' . sprintf( _nx( 'Unattached <span class="count">(%s)</span>', 'Unattached <span class="count">(%s)</span>', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . '</a>';
</ins><span class="cx">
</span><span class="cx">                 if ( !empty($_num_posts['trash']) )
</span><span class="cx">                         $type_links['trash'] = '<a href="upload.php?status=trash"' . ( (isset($_GET['status']) && $_GET['status'] == 'trash' ) ? ' class="current"' : '') . '>' . sprintf( _nx( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', $_num_posts['trash'], 'uploaded files' ), number_format_i18n( $_num_posts['trash'] ) ) . '</a>';
</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->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"> ?>
</span><span class="cx">                 <div class="alignleft actions">
</span><span class="cx"> <?php
</span><del>-                if ( 'top' == $which && !is_singular() && !$detached && !$this->is_trash ) {
</del><ins>+                if ( 'top' == $which && !is_singular() && !$this->detached && !$this->is_trash ) {
</ins><span class="cx">                         $this->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->detached ) {
</ins><span class="cx">                         submit_button( __( 'Scan for lost attachments' ), 'secondary', 'find_detached', false );
</span><span class="cx">                 } elseif ( $this->is_trash && 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->detached ) {
</ins><span class="cx"> ?>
</span><span class="cx">                 <div class="tablenav">
</span><span class="cx">                         <?php $this->extra_tablenav( 'top' ); ?>
</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->screen->id ) {
</del><ins>+                if ( !$this->detached ) {
</ins><span class="cx">                         $posts_columns['parent'] = _x( 'Attached to', 'column name' );
</span><span class="cx">                         $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="' . esc_url( admin_url( 'images/comment-grey-bubble.png' ) ) . '" /></div>';
</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->screen->id );
</del><ins>+                $posts_columns = apply_filters( 'manage_media_columns', $posts_columns, $this->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->detached ) {
</ins><span class="cx">                         $this->display_orphans();
</span><span class="cx">                         return;
</span><span class="cx">                 }
</span></span></pre>
</div>
</div>
</body>
</html>