WordPress.org

Make WordPress Core

Changeset 49975


Ignore:
Timestamp:
01/18/2021 09:48:23 AM (9 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Improve code layout in wp-admin/includes/class-wp-media-list-table.php.

This allows for better readability and easier understanding of where each section opens and closes.

Props laxman-prajapati, hansjovisyoast, audrasjb.
Fixes #51014.

File:
1 edited

Legend:

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

    r49720 r49975  
    197197        ?>
    198198        <div class="actions">
    199         <?php
    200         if ( ! $this->is_trash ) {
    201             $this->months_dropdown( 'attachment' );
    202         }
    203 
    204         /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */
    205         do_action( 'restrict_manage_posts', $this->screen->post_type, $which );
    206 
    207         submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
    208 
    209         if ( $this->is_trash && current_user_can( 'edit_others_posts' ) && $this->has_items() ) {
    210             submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
    211         }
    212         ?>
     199            <?php
     200            if ( ! $this->is_trash ) {
     201                $this->months_dropdown( 'attachment' );
     202            }
     203
     204            /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */
     205            do_action( 'restrict_manage_posts', $this->screen->post_type, $which );
     206
     207            submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
     208
     209            if ( $this->is_trash && current_user_can( 'edit_others_posts' ) && $this->has_items() ) {
     210                submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
     211            }
     212            ?>
    213213        </div>
    214214        <?php
     
    263263        $this->screen->render_screen_reader_content( 'heading_views' );
    264264        ?>
    265 <div class="wp-filter">
    266     <div class="filter-items">
    267         <?php $this->view_switcher( $mode ); ?>
    268 
    269         <label for="attachment-filter" class="screen-reader-text"><?php _e( 'Filter by type' ); ?></label>
    270         <select class="attachment-filters" name="attachment-filter" id="attachment-filter">
    271             <?php
    272             if ( ! empty( $views ) ) {
    273                 foreach ( $views as $class => $view ) {
    274                     echo "\t$view\n";
     265        <div class="wp-filter">
     266            <div class="filter-items">
     267                <?php $this->view_switcher( $mode ); ?>
     268
     269                <label for="attachment-filter" class="screen-reader-text"><?php _e( 'Filter by type' ); ?></label>
     270                <select class="attachment-filters" name="attachment-filter" id="attachment-filter">
     271                    <?php
     272                    if ( ! empty( $views ) ) {
     273                        foreach ( $views as $class => $view ) {
     274                            echo "\t$view\n";
     275                        }
     276                    }
     277                    ?>
     278                </select>
     279
     280                <?php
     281                $this->extra_tablenav( 'bar' );
     282
     283                /** This filter is documented in wp-admin/inclues/class-wp-list-table.php */
     284                $views = apply_filters( "views_{$this->screen->id}", array() );
     285
     286                // Back compat for pre-4.0 view links.
     287                if ( ! empty( $views ) ) {
     288                    echo '<ul class="filter-links">';
     289                    foreach ( $views as $class => $view ) {
     290                        echo "<li class='$class'>$view</li>";
     291                    }
     292                    echo '</ul>';
    275293                }
    276             }
    277             ?>
    278         </select>
    279 
    280         <?php
    281         $this->extra_tablenav( 'bar' );
    282 
    283         /** This filter is documented in wp-admin/inclues/class-wp-list-table.php */
    284         $views = apply_filters( "views_{$this->screen->id}", array() );
    285 
    286         // Back compat for pre-4.0 view links.
    287         if ( ! empty( $views ) ) {
    288             echo '<ul class="filter-links">';
    289             foreach ( $views as $class => $view ) {
    290                 echo "<li class='$class'>$view</li>";
    291             }
    292             echo '</ul>';
    293         }
    294         ?>
    295     </div>
    296 
    297     <div class="search-form">
    298         <label for="media-search-input" class="media-search-input-label"><?php esc_html_e( 'Search' ); ?></label>
    299         <input type="search" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>"></div>
    300     </div>
     294                ?>
     295            </div>
     296
     297            <div class="search-form">
     298                <label for="media-search-input" class="media-search-input-label"><?php esc_html_e( 'Search' ); ?></label>
     299                <input type="search" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>">
     300            </div>
     301        </div>
    301302        <?php
    302303    }
     
    513514
    514515            if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) {
    515                 ?>
    516                 <strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>">
    517                     <?php echo $title; ?></a></strong>
    518                                 <?php
     516                printf( '<strong><a href="%s">%s</a></strong>', get_edit_post_link( $post->post_parent ), $title );
    519517            } elseif ( $parent_type && current_user_can( 'read_post', $post->post_parent ) ) {
    520                 ?>
    521                 <strong><?php echo $title; ?></strong>
    522                                     <?php
     518                printf( '<strong>%s</strong>', $title );
    523519            } else {
    524520                _e( '(Private post)' );
     
    651647        while ( have_posts() ) :
    652648            the_post();
    653             if (
    654                 ( $this->is_trash && 'trash' !== $post->post_status )
    655                 || ( ! $this->is_trash && 'trash' === $post->post_status )
     649            if ( $this->is_trash && 'trash' !== $post->post_status
     650                || ! $this->is_trash && 'trash' === $post->post_status
    656651            ) {
    657652                continue;
Note: See TracChangeset for help on using the changeset viewer.