Make WordPress Core

Ticket #28946: 28946.2.patch

File 28946.2.patch, 9.7 KB (added by michalzuber, 12 years ago)

Rewrite, dont't touch wp-admin/includes/class-wp-list-table.php

  • src/wp-admin/includes/class-wp-media-list-table.php

     
    4343                ) );
    4444        }
    4545
     46        public function search_box( $text, $input_id ) {
     47                if ( empty( $_REQUEST['s'] ) && !$this->has_items() )
     48                        return;
     49
     50                $input_id = $input_id . '-search-input';
     51
     52                if ( ! empty( $_REQUEST['orderby'] ) )
     53                        echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
     54                if ( ! empty( $_REQUEST['order'] ) )
     55                        echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
     56                if ( ! empty( $_REQUEST['post_mime_type'] ) )
     57                        echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />';
     58                if ( ! empty( $_REQUEST['detached'] ) )
     59                        echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />';
     60?>
     61<div class="media-toolbar-primary">
     62        <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
     63        <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
     64        <?php submit_button( $text, 'button', false, false, array('id' => 'search-submit') ); ?>
     65</div>
     66<?php
     67        }
     68
    4669        protected function get_views() {
    4770                global $wpdb, $post_mime_types, $avail_post_mime_types;
    4871
     
    85108                return $actions;
    86109        }
    87110
    88         protected function extra_tablenav( $which ) {
    89 ?>
    90                 <div class="alignleft actions">
    91 <?php
    92                 if ( 'top' == $which && !is_singular() && !$this->detached && !$this->is_trash ) {
     111        protected function display_tablenav( $which ) {
     112                $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
     113
     114                if ( 'bottom' === $which ) {
     115                        ?>
     116                        <div class="media-toolbar">
     117                                <div class="media-toolbar-secondary">
     118                                        <?php $this->bulk_actions(); ?>
     119                                </div>
     120                        </div>
     121                        <?php
     122
     123                        return;
     124                }
     125               
     126                $this->pagination( $which );
     127                ?>
     128                <div class="media-toolbar">
     129                        <div class="media-toolbar-secondary">
     130                                <?php $this->view_switcher( $mode ); ?>
     131                                <?php $this->extra_tablenav(); ?>
     132                                <?php $this->bulk_actions(); ?>
     133                        </div>
     134               
     135                        <?php $this->search_box( __( 'Search Media' ), 'media' ); ?>
     136                </div>
     137                <?php
     138        }
     139
     140        protected function extra_tablenav() {
     141
     142                echo '<div class="filters">';
     143
     144                if ( !is_singular() && !$this->detached && !$this->is_trash ) {
    93145                        $this->months_dropdown( 'attachment' );
    94146
    95147                        /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */
     
    101153                        submit_button( __( 'Scan for lost attachments' ), 'secondary', 'find_detached', false );
    102154                } elseif ( $this->is_trash && current_user_can( 'edit_others_posts' ) ) {
    103155                        submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
    104                 } ?>
    105                 </div>
    106 <?php
     156                }
     157
     158                echo '</div>';
     159
    107160        }
    108161
    109162        public function current_action() {
     
    128181        }
    129182
    130183        protected function pagination( $which ) {
    131                 global $mode;
     184                if ( empty( $this->_pagination_args ) ) {
     185                        return;
     186                }
    132187
    133                 parent::pagination( $which );
     188                $total_items = $this->_pagination_args['total_items'];
     189                $total_pages = $this->_pagination_args['total_pages'];
     190                $infinite_scroll = false;
     191                if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
     192                        $infinite_scroll = $this->_pagination_args['infinite_scroll'];
     193                }
    134194
    135                 $this->view_switcher( $mode );
     195                $output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
     196
     197                $current = $this->get_pagenum();
     198
     199                $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
     200
     201                $current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
     202
     203                $page_links = array();
     204
     205                $disable_first = $disable_last = '';
     206                if ( $current == 1 ) {
     207                        $disable_first = ' disabled';
     208                }
     209                if ( $current == $total_pages ) {
     210                        $disable_last = ' disabled';
     211                }
     212                $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
     213                        'first-page' . $disable_first,
     214                        esc_attr__( 'Go to the first page' ),
     215                        esc_url( remove_query_arg( 'paged', $current_url ) ),
     216                        '&laquo;'
     217                );
     218
     219                $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
     220                        'prev-page' . $disable_first,
     221                        esc_attr__( 'Go to the previous page' ),
     222                        esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
     223                        '&lsaquo;'
     224                );
     225
     226                if ( 'bottom' == $which ) {
     227                        $html_current_page = $current;
     228                } else {
     229                        $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name='paged' value='%s' size='%d' />",
     230                                esc_attr__( 'Current page' ),
     231                                $current,
     232                                strlen( $total_pages )
     233                        );
     234                }
     235                $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
     236                $page_links[] = '<span class="paging-input">' . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . '</span>';
     237
     238                $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
     239                        'next-page' . $disable_last,
     240                        esc_attr__( 'Go to the next page' ),
     241                        esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
     242                        '&rsaquo;'
     243                );
     244
     245                $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
     246                        'last-page' . $disable_last,
     247                        esc_attr__( 'Go to the last page' ),
     248                        esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
     249                        '&raquo;'
     250                );
     251
     252                $pagination_links_class = 'pagination-links';
     253                if ( ! empty( $infinite_scroll ) ) {
     254                        $pagination_links_class = ' hide-if-js';
     255                }
     256                $output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';
     257
     258                $this->_pagination = "<div class='alignright tablenav-pages'>$output</div>";
     259
     260                echo $this->_pagination;
    136261        }
    137262
    138263        /**
  • src/wp-admin/upload.php

     
    200200$parent_file = 'upload.php';
    201201
    202202wp_enqueue_script( 'media' );
     203wp_enqueue_style( 'media-views' );
    203204
    204205add_screen_option( 'per_page', array('label' => _x( 'Media items', 'items per page (screen options)' )) );
    205206
     
    288289
    289290<?php $wp_list_table->views(); ?>
    290291
    291 <form id="posts-filter" action="" method="get">
     292<form id="posts-filter" class="<?php echo $mode; ?>-view" action="" method="get">
    292293
    293 <?php $wp_list_table->search_box( __( 'Search Media' ), 'media' ); ?>
    294 
    295294<?php $wp_list_table->display(); ?>
    296295
    297296<div id="ajax-response"></div>
  • src/wp-includes/css/media-views.css

     
    1919        line-height: 16px;
    2020}
    2121
    22 .media-frame select,
    23 .wp-admin .media-frame select {
    24         line-height: 28px;
    25         margin-top: 3px;
    26 }
    27 
    2822.media-frame a {
    2923        border-bottom: none;
    3024        color: #21759b;
     
    218212        height: 100%;
    219213}
    220214
     215.wp-admin .media-toolbar select {
     216        height: 32px;
     217        line-height: 30px;
     218        margin-top: 1px;
     219}
     220
     221.post-php .media-toolbar-secondary select {
     222        margin-top: 10px;
     223}
     224
    221225.media-toolbar-primary > .media-button,
    222226.media-toolbar-primary > .media-button-group {
    223227        margin-left: 10px;
     
    628632        max-height: 100%;
    629633}
    630634
    631 .media-frame-content .crop-content .upload-errors
    632 {
     635.media-frame-content .crop-content .upload-errors {
    633636        position: absolute;
    634637        width: 300px;
    635638        top: 50%;
     
    657660 * Attachment Browser Filters
    658661 */
    659662.media-frame select.attachment-filters {
    660         margin-top: 11px;
    661663        margin-right: 10px;
    662664}
    663665
     
    10091011}
    10101012
    10111013.attachments-browser .attachments,
    1012 .attachments-browser .uploader-inline {
     1014.attachments-browser .uploader-inline,
     1015.post-php .attachments-browser .media-toolbar {
    10131016        position: absolute;
    10141017        top: 50px;
    10151018        left: 0;
     
    10191022        outline: none;
    10201023}
    10211024
     1025.attachments-browser .attachments {
     1026        margin-top: 10px;
     1027}
     1028
     1029.post-php .attachments-browser .media-toolbar {
     1030        top: 0;
     1031        margin: 0;
     1032        width: auto;
     1033}
     1034
    10221035.attachments-browser .uploader-inline:not(.hidden) + .attachments {
    10231036        top: 350px;
    10241037}
     
    26252638        margin-top: 0;
    26262639}
    26272640
    2628 .media-grid-view .media-toolbar select {
    2629         margin-top: 1px;
    2630         font-size: inherit;
    2631 }
    2632 
    2633 .media-grid-view .attachments-browser .bulk-select {
     2641.media-toolbar .filters,
     2642.media-toolbar .bulk-select {
    26342643        display: inline-block;
    26352644}
    26362645
     
    26392648 *
    26402649 * This should be OOCSS'd so both use a shared selector.
    26412650 */
    2642 .media-grid-view .attachments-browser .media-toolbar {
     2651.media-toolbar {
    26432652        background: #fff;
    26442653        -webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
    26452654        box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
     
    26572666        border: none;
    26582667}
    26592668
    2660 .media-grid-view input[type="search"] {
     2669.list-view .media-toolbar {
     2670        margin-top: 0;
     2671}
     2672
     2673.list-view .media-toolbar-primary {
     2674        padding-top: 10px;
     2675}
     2676
     2677.media-toolbar input[type="search"] {
    26612678        margin: 1px;
    26622679        padding: 3px 5px;
    26632680        position: absolute;
     
    26672684        font-weight: 300;
    26682685        line-height: 1.5;
    26692686        width: 280px;
     2687        -webkit-border-radius: 3px;
     2688           -moz-border-radius: 3px;
     2689                        border-radius: 3px;
    26702690}
    26712691
    2672 .media-grid-view .view-switch {
     2692.wp-core-ui .media-toolbar .button {
     2693        height: 32px;
     2694        line-height: 30px;
     2695        vertical-align: middle;
     2696}
     2697
     2698.list-view .media-toolbar input[type="search"] {
     2699        position: static;
     2700}
     2701
     2702.media-toolbar .view-switch {
    26732703        display: inline-block;
    26742704        float: none;
    26752705        vertical-align: middle;
     
    26772707        margin: 0 20px 0 0;
    26782708}
    26792709
    2680 .media-grid-view select {
     2710.media-toolbar select {
    26812711        margin: 0 10px 0 0;
     2712        font-size: inherit;
    26822713}
    26832714
    26842715.media-grid-view .spinner {