Wordpress 3.6
[autoinstalls/wordpress.git] / wp-admin / includes / class-wp-list-table.php
index 446174d4dea6409f8a2ef7381caa485b3f05732a..22c35f5edcba29c84b29b9794f1db8af9f10f901 100644 (file)
@@ -72,7 +72,7 @@ class WP_List_Table {
        var $_pagination;
 
        /**
-        * Constructor. The child class should call this constructor from it's own constructor
+        * Constructor. The child class should call this constructor from its own constructor
         *
         * @param array $args An associative array with information about the current table
         * @access protected
@@ -81,15 +81,16 @@ class WP_List_Table {
                $args = wp_parse_args( $args, array(
                        'plural' => '',
                        'singular' => '',
-                       'ajax' => false
+                       'ajax' => false,
+                       'screen' => null,
                ) );
 
-               $screen = get_current_screen();
+               $this->screen = convert_to_screen( $args['screen'] );
 
-               add_filter( "manage_{$screen->id}_columns", array( &$this, 'get_columns' ), 0 );
+               add_filter( "manage_{$this->screen->id}_columns", array( &$this, 'get_columns' ), 0 );
 
                if ( !$args['plural'] )
-                       $args['plural'] = $screen->base;
+                       $args['plural'] = $this->screen->base;
 
                $args['plural'] = sanitize_key( $args['plural'] );
                $args['singular'] = sanitize_key( $args['singular'] );
@@ -209,10 +210,14 @@ class WP_List_Table {
                        echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
                if ( ! empty( $_REQUEST['order'] ) )
                        echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
+               if ( ! empty( $_REQUEST['post_mime_type'] ) )
+                       echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />';
+               if ( ! empty( $_REQUEST['detached'] ) )
+                       echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />';
 ?>
 <p class="search-box">
        <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
-       <input type="text" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
+       <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
        <?php submit_button( $text, 'button', false, false, array('id' => 'search-submit') ); ?>
 </p>
 <?php
@@ -238,10 +243,8 @@ class WP_List_Table {
         * @access public
         */
        function views() {
-               $screen = get_current_screen();
-
                $views = $this->get_views();
-               $views = apply_filters( 'views_' . $screen->id, $views );
+               $views = apply_filters( 'views_' . $this->screen->id, $views );
 
                if ( empty( $views ) )
                        return;
@@ -274,12 +277,10 @@ class WP_List_Table {
         * @access public
         */
        function bulk_actions() {
-               $screen = get_current_screen();
-
                if ( is_null( $this->_actions ) ) {
                        $no_new_actions = $this->_actions = $this->get_bulk_actions();
                        // This filter can currently only be used to remove actions.
-                       $this->_actions = apply_filters( 'bulk_actions-' . $screen->id, $this->_actions );
+                       $this->_actions = apply_filters( 'bulk_actions-' . $this->screen->id, $this->_actions );
                        $this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions );
                        $two = '';
                } else {
@@ -300,7 +301,7 @@ class WP_List_Table {
 
                echo "</select>\n";
 
-               submit_button( __( 'Apply' ), 'button-secondary action', false, false, array( 'id' => "doaction$two" ) );
+               submit_button( __( 'Apply' ), 'action', false, false, array( 'id' => "doaction$two" ) );
                echo "\n";
        }
 
@@ -386,7 +387,8 @@ class WP_List_Table {
                        printf( "<option %s value='%s'>%s</option>\n",
                                selected( $m, $year . $month, false ),
                                esc_attr( $arc_row->year . $month ),
-                               $wp_locale->get_month( $month ) . " $year"
+                               /* translators: 1: month name, 2: 4-digit year */
+                               sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year )
                        );
                }
 ?>
@@ -483,13 +485,13 @@ class WP_List_Table {
                if ( empty( $this->_pagination_args ) )
                        return;
 
-               extract( $this->_pagination_args );
+               extract( $this->_pagination_args, EXTR_SKIP );
 
                $output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
 
                $current = $this->get_pagenum();
 
-               $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+               $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
 
                $current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
 
@@ -518,9 +520,8 @@ class WP_List_Table {
                if ( 'bottom' == $which )
                        $html_current_page = $current;
                else
-                       $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name='%s' value='%s' size='%d' />",
+                       $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name='paged' value='%s' size='%d' />",
                                esc_attr__( 'Current page' ),
-                               esc_attr( 'paged' ),
                                $current,
                                strlen( $total_pages )
                        );
@@ -542,7 +543,10 @@ class WP_List_Table {
                        '&raquo;'
                );
 
-               $output .= "\n<span class='pagination-links'>" . join( "\n", $page_links ) . '</span>';
+               $pagination_links_class = 'pagination-links';
+               if ( ! empty( $infinite_scroll ) )
+                       $pagination_links_class = ' hide-if-js';
+               $output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';
 
                if ( $total_pages )
                        $page_class = $total_pages < 2 ? ' one-page' : '';
@@ -597,12 +601,10 @@ class WP_List_Table {
                if ( isset( $this->_column_headers ) )
                        return $this->_column_headers;
 
-               $screen = get_current_screen();
+               $columns = get_column_headers( $this->screen );
+               $hidden = get_hidden_columns( $this->screen );
 
-               $columns = get_column_headers( $screen );
-               $hidden = get_hidden_columns( $screen );
-
-               $_sortable = apply_filters( "manage_{$screen->id}_sortable_columns", $this->get_sortable_columns() );
+               $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $this->get_sortable_columns() );
 
                $sortable = array();
                foreach ( $_sortable as $id => $data ) {
@@ -644,11 +646,9 @@ class WP_List_Table {
         * @param bool $with_id Whether to set the id attribute or not
         */
        function print_column_headers( $with_id = true ) {
-               $screen = get_current_screen();
-
                list( $columns, $hidden, $sortable ) = $this->get_column_info();
 
-               $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+               $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
                $current_url = remove_query_arg( 'paged', $current_url );
 
                if ( isset( $_GET['orderby'] ) )
@@ -661,6 +661,13 @@ class WP_List_Table {
                else
                        $current_order = 'asc';
 
+               if ( ! empty( $columns['cb'] ) ) {
+                       static $cb_counter = 1;
+                       $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>'
+                               . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
+                       $cb_counter++;
+               }
+
                foreach ( $columns as $column_key => $column_display_name ) {
                        $class = array( 'manage-column', "column-$column_key" );
 
@@ -725,7 +732,7 @@ class WP_List_Table {
        </tr>
        </tfoot>
 
-       <tbody id="the-list"<?php if ( $singular ) echo " class='list:$singular'"; ?>>
+       <tbody id="the-list"<?php if ( $singular ) echo " data-wp-lists='list:$singular'"; ?>>
                <?php $this->display_rows_or_placeholder(); ?>
        </tbody>
 </table>
@@ -758,7 +765,7 @@ class WP_List_Table {
        <div class="tablenav <?php echo esc_attr( $which ); ?>">
 
                <div class="alignleft actions">
-                       <?php $this->bulk_actions( $which ); ?>
+                       <?php $this->bulk_actions(); ?>
                </div>
 <?php
                $this->extra_tablenav( $which );
@@ -819,7 +826,7 @@ class WP_List_Table {
                $row_class = ( $row_class == '' ? ' class="alternate"' : '' );
 
                echo '<tr' . $row_class . '>';
-               echo $this->single_row_columns( $item );
+               $this->single_row_columns( $item );
                echo '</tr>';
        }
 
@@ -871,7 +878,7 @@ class WP_List_Table {
                $this->prepare_items();
 
                extract( $this->_args );
-               extract( $this->_pagination_args );
+               extract( $this->_pagination_args, EXTR_SKIP );
 
                ob_start();
                if ( ! empty( $_REQUEST['no_placeholder'] ) )
@@ -900,17 +907,14 @@ class WP_List_Table {
         * @access private
         */
        function _js_vars() {
-               $current_screen = get_current_screen();
-
                $args = array(
                        'class'  => get_class( $this ),
                        'screen' => array(
-                               'id'   => $current_screen->id,
-                               'base' => $current_screen->base,
+                               'id'   => $this->screen->id,
+                               'base' => $this->screen->base,
                        )
                );
 
                printf( "<script type='text/javascript'>list_args = %s;</script>\n", json_encode( $args ) );
        }
 }
-?>