Make WordPress Core


Ignore:
Timestamp:
07/10/2020 04:02:00 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Administration: Bring some consistency to handling list table view modes.

  • Remove duplicate variables and DocBlocks.
  • Add missing description for the $mode global.
  • Use sentence case for "Compact view" and "Extended view" labels.

Follow-up to [48398], [48423].

Props afercia, Offereins, SergeyBiryukov.
See #49715.

File:
1 edited

Legend:

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

    r48415 r48424  
    8181     * @global int    $post_id
    8282     * @global string $comment_status
     83     * @global string $comment_type
    8384     * @global string $search
    84      * @global string $comment_type
    8585     */
    8686    public function prepare_items() {
    87         global $post_id, $comment_status, $search, $comment_type;
     87        global $post_id, $comment_status, $comment_type, $search;
     88
     89        if ( ! empty( $_REQUEST['mode'] ) ) {
     90            $mode = 'extended' === $_REQUEST['mode'] ? 'extended' : 'list';
     91            set_user_setting( 'posts_list_mode', $mode );
     92        }
    8893
    8994        $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
     
    123128        if ( $doing_ajax && isset( $_REQUEST['offset'] ) ) {
    124129            $start += $_REQUEST['offset'];
    125         }
    126 
    127         if ( ! empty( $_REQUEST['mode'] ) ) {
    128             $mode = 'extended' === $_REQUEST['mode'] ? 'extended' : 'list';
    129             set_user_setting( 'posts_list_mode', $mode );
    130         } else {
    131             $mode = get_user_setting( 'posts_list_mode', 'list' );
    132130        }
    133131
     
    760758
    761759        $always_visible = false;
    762         $mode           = get_user_setting( 'posts_list_mode', 'list' );
     760
     761        $mode = get_user_setting( 'posts_list_mode', 'list' );
     762
    763763        if ( 'extended' === $mode ) {
    764764            $always_visible = true;
    765765        }
    766766
    767         $i    = 0;
    768767        $out .= '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
     768
     769        $i = 0;
     770
    769771        foreach ( $actions as $action => $link ) {
    770772            ++$i;
    771             ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
    772 
    773             // Reply and quickedit need a hide-if-no-js span when not added with ajax.
     773
     774            if ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i )
     775                || 1 === $i
     776            ) {
     777                $sep = '';
     778            } else {
     779                $sep = ' | ';
     780            }
     781
     782            // Reply and quickedit need a hide-if-no-js span when not added with Ajax.
    774783            if ( ( 'reply' === $action || 'quickedit' === $action ) && ! wp_doing_ajax() ) {
    775784                $action .= ' hide-if-no-js';
    776             } elseif ( ( 'untrash' === $action && 'trash' === $the_comment_status ) || ( 'unspam' === $action && 'spam' === $the_comment_status ) ) {
     785            } elseif ( ( 'untrash' === $action && 'trash' === $the_comment_status )
     786                || ( 'unspam' === $action && 'spam' === $the_comment_status )
     787            ) {
    777788                if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) ) {
    778789                    $action .= ' approve';
     
    784795            $out .= "<span class='$action'>$sep$link</span>";
    785796        }
     797
    786798        $out .= '</div>';
    787799
Note: See TracChangeset for help on using the changeset viewer.