Make WordPress Core

Changeset 16227


Ignore:
Timestamp:
11/06/2010 10:47:12 PM (14 years ago)
Author:
scribu
Message:

WP_Media_List_Table: Use class property instead of $detached global. See #14579

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-media-list-table.php

    r16205 r16227  
    1010
    1111    function WP_Media_List_Table() {
    12         global $detached;
    13 
    14         $detached = isset( $_REQUEST['detached'] ) || isset( $_REQUEST['find_detached'] );
     12        $this->detached = isset( $_REQUEST['detached'] ) || isset( $_REQUEST['find_detached'] );
    1513
    1614        parent::WP_List_Table( array(
    17             'screen' => $detached ? 'upload-detached' : 'upload',
    1815            'plural' => 'media'
    1916        ) );
     
    4542
    4643    function get_views() {
    47         global $wpdb, $post_mime_types, $detached, $avail_post_mime_types;
     44        global $wpdb, $post_mime_types, $avail_post_mime_types;
    4845
    4946        $type_links = array();
     
    5754                $num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real];
    5855
    59         $class = ( empty($_GET['post_mime_type']) && !$detached && !isset($_GET['status']) ) ? ' class="current"' : '';
     56        $class = ( empty($_GET['post_mime_type']) && !$this->detached && !isset($_GET['status']) ) ? ' class="current"' : '';
    6057        $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>';
    6158        foreach ( $post_mime_types as $mime_type => $label ) {
     
    7067                $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>';
    7168        }
    72         $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>';
     69        $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>';
    7370
    7471        if ( !empty($_num_posts['trash']) )
     
    7976
    8077    function get_bulk_actions() {
    81         global $detached;
    82 
    8378        $actions = array();
    8479        $actions['delete'] = __( 'Delete Permanently' );
    85         if ( $detached )
     80        if ( $this->detached )
    8681            $actions['attach'] = __( 'Attach to a post' );
    8782
     
    9085
    9186    function extra_tablenav( $which ) {
    92         global $post_type, $detached;
     87        global $post_type;
    9388        $post_type_obj = get_post_type_object( $post_type );
    9489?>
    9590        <div class="alignleft actions">
    9691<?php
    97         if ( 'top' == $which && !is_singular() && !$detached && !$this->is_trash ) {
     92        if ( 'top' == $which && !is_singular() && !$this->detached && !$this->is_trash ) {
    9893            $this->months_dropdown( $post_type );
    9994
     
    10297        }
    10398
    104         if ( $detached ) {
     99        if ( $this->detached ) {
    105100            submit_button( __( 'Scan for lost attachments' ), 'secondary', 'find_detached', false );
    106101        } elseif ( $this->is_trash && current_user_can( 'edit_others_posts' ) ) {
     
    129124
    130125    function no_items() {
    131         global $detached;
    132        
    133         if ( $detached ) {
     126        if ( $this->detached ) {
    134127?>
    135128        <div class="tablenav">
     
    152145        //$posts_columns['tags'] = _x( 'Tags', 'column name' );
    153146        /* translators: column name */
    154         if ( 'upload' == $this->screen->id ) {
     147        if ( !$this->detached ) {
    155148            $posts_columns['parent'] = _x( 'Attached to', 'column name' );
    156149            $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="' . esc_url( admin_url( 'images/comment-grey-bubble.png' ) ) . '" /></div>';
     
    158151        /* translators: column name */
    159152        $posts_columns['date'] = _x( 'Date', 'column name' );
    160         $posts_columns = apply_filters( 'manage_media_columns', $posts_columns, 'upload' != $this->screen->id );
     153        $posts_columns = apply_filters( 'manage_media_columns', $posts_columns, $this->detached );
    161154
    162155        return $posts_columns;
     
    174167
    175168    function display_rows() {
    176         global $detached, $post, $id;
    177 
    178         if ( $detached ) {
     169        global $post, $id;
     170
     171        if ( $this->detached ) {
    179172            $this->display_orphans();
    180173            return;
Note: See TracChangeset for help on using the changeset viewer.