Skip to content

Commit

Permalink
Coding Standards: Improve code layout in `wp-admin/includes/class-wp-…
Browse files Browse the repository at this point in the history
…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.

git-svn-id: https://develop.svn.wordpress.org/trunk@49975 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Jan 18, 2021
1 parent 5582e49 commit fa7f87b
Showing 1 changed file with 49 additions and 54 deletions.
103 changes: 49 additions & 54 deletions src/wp-admin/includes/class-wp-media-list-table.php
Expand Up @@ -196,20 +196,20 @@ protected function extra_tablenav( $which ) {
}
?>
<div class="actions">
<?php
if ( ! $this->is_trash ) {
$this->months_dropdown( 'attachment' );
}
<?php
if ( ! $this->is_trash ) {
$this->months_dropdown( 'attachment' );
}

/** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */
do_action( 'restrict_manage_posts', $this->screen->post_type, $which );
/** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */
do_action( 'restrict_manage_posts', $this->screen->post_type, $which );

submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );

if ( $this->is_trash && current_user_can( 'edit_others_posts' ) && $this->has_items() ) {
submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
}
?>
if ( $this->is_trash && current_user_can( 'edit_others_posts' ) && $this->has_items() ) {
submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
}
?>
</div>
<?php
}
Expand Down Expand Up @@ -262,42 +262,43 @@ public function views() {

$this->screen->render_screen_reader_content( 'heading_views' );
?>
<div class="wp-filter">
<div class="filter-items">
<?php $this->view_switcher( $mode ); ?>
<div class="wp-filter">
<div class="filter-items">
<?php $this->view_switcher( $mode ); ?>

<label for="attachment-filter" class="screen-reader-text"><?php _e( 'Filter by type' ); ?></label>
<select class="attachment-filters" name="attachment-filter" id="attachment-filter">
<?php
if ( ! empty( $views ) ) {
foreach ( $views as $class => $view ) {
echo "\t$view\n";
}
}
?>
</select>

<label for="attachment-filter" class="screen-reader-text"><?php _e( 'Filter by type' ); ?></label>
<select class="attachment-filters" name="attachment-filter" id="attachment-filter">
<?php
if ( ! empty( $views ) ) {
foreach ( $views as $class => $view ) {
echo "\t$view\n";
<?php
$this->extra_tablenav( 'bar' );

/** This filter is documented in wp-admin/inclues/class-wp-list-table.php */
$views = apply_filters( "views_{$this->screen->id}", array() );

// Back compat for pre-4.0 view links.
if ( ! empty( $views ) ) {
echo '<ul class="filter-links">';
foreach ( $views as $class => $view ) {
echo "<li class='$class'>$view</li>";
}
echo '</ul>';
}
}
?>
</select>

<?php
$this->extra_tablenav( 'bar' );

/** This filter is documented in wp-admin/inclues/class-wp-list-table.php */
$views = apply_filters( "views_{$this->screen->id}", array() );

// Back compat for pre-4.0 view links.
if ( ! empty( $views ) ) {
echo '<ul class="filter-links">';
foreach ( $views as $class => $view ) {
echo "<li class='$class'>$view</li>";
}
echo '</ul>';
}
?>
</div>
?>
</div>

<div class="search-form">
<label for="media-search-input" class="media-search-input-label"><?php esc_html_e( 'Search' ); ?></label>
<input type="search" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>"></div>
</div>
<div class="search-form">
<label for="media-search-input" class="media-search-input-label"><?php esc_html_e( 'Search' ); ?></label>
<input type="search" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>">
</div>
</div>
<?php
}

Expand Down Expand Up @@ -512,14 +513,9 @@ public function column_parent( $post ) {
$parent_type = get_post_type_object( $parent->post_type );

if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) {
?>
<strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>">
<?php echo $title; ?></a></strong>
<?php
printf( '<strong><a href="%s">%s</a></strong>', get_edit_post_link( $post->post_parent ), $title );
} elseif ( $parent_type && current_user_can( 'read_post', $post->post_parent ) ) {
?>
<strong><?php echo $title; ?></strong>
<?php
printf( '<strong>%s</strong>', $title );
} else {
_e( '(Private post)' );
}
Expand Down Expand Up @@ -650,9 +646,8 @@ public function display_rows() {

while ( have_posts() ) :
the_post();
if (
( $this->is_trash && 'trash' !== $post->post_status )
|| ( ! $this->is_trash && 'trash' === $post->post_status )
if ( $this->is_trash && 'trash' !== $post->post_status
|| ! $this->is_trash && 'trash' === $post->post_status
) {
continue;
}
Expand Down

0 comments on commit fa7f87b

Please sign in to comment.