Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

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

    r42228 r42343  
    7575        global $post_type_object, $wpdb;
    7676
    77         parent::__construct( array(
    78             'plural' => 'posts',
    79             'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
    80         ) );
     77        parent::__construct(
     78            array(
     79                'plural' => 'posts',
     80                'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
     81            )
     82        );
    8183
    8284        $post_type        = $this->screen->post_type;
    8385        $post_type_object = get_post_type_object( $post_type );
    8486
    85         $exclude_states   = get_post_stati( array(
    86             'show_in_admin_all_list' => false,
    87         ) );
    88         $this->user_posts_count = intval( $wpdb->get_var( $wpdb->prepare( "
     87        $exclude_states         = get_post_stati(
     88            array(
     89                'show_in_admin_all_list' => false,
     90            )
     91        );
     92        $this->user_posts_count = intval(
     93            $wpdb->get_var(
     94                $wpdb->prepare(
     95                    "
    8996            SELECT COUNT( 1 )
    9097            FROM $wpdb->posts
     
    9299            AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' )
    93100            AND post_author = %d
    94         ", $post_type, get_current_user_id() ) ) );
     101        ", $post_type, get_current_user_id()
     102                )
     103            )
     104        );
    95105
    96106        if ( $this->user_posts_count && ! current_user_can( $post_type_object->cap->edit_others_posts ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) ) {
     
    99109
    100110        if ( 'post' === $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) {
    101             $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) );
     111            $sticky_posts             = implode( ', ', array_map( 'absint', (array) $sticky_posts ) );
    102112            $this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status NOT IN ('trash', 'auto-draft') AND ID IN ($sticky_posts)", $post_type ) );
    103113        }
     
    116126
    117127    /**
    118      *
    119128     * @return bool
    120129     */
     
    124133
    125134    /**
    126      *
    127135     * @global array    $avail_post_stati
    128136     * @global WP_Query $wp_query
     
    139147
    140148        $post_type = $this->screen->post_type;
    141         $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' );
     149        $per_page  = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' );
    142150
    143151        /** This filter is documented in wp-admin/includes/post.php */
    144         $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type );
     152        $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type );
    145153
    146154        if ( $this->hierarchical_display ) {
     
    151159            $post_counts = (array) wp_count_posts( $post_type, 'readable' );
    152160
    153             if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'] , $avail_post_stati ) ) {
     161            if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'], $avail_post_stati ) ) {
    154162                $total_items = $post_counts[ $_REQUEST['post_status'] ];
    155163            } elseif ( isset( $_REQUEST['show_sticky'] ) && $_REQUEST['show_sticky'] ) {
     
    176184        $this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] === 'trash';
    177185
    178         $this->set_pagination_args( array(
    179             'total_items' => $total_items,
    180             'per_page' => $per_page
    181         ) );
    182     }
    183 
    184     /**
    185      *
     186        $this->set_pagination_args(
     187            array(
     188                'total_items' => $total_items,
     189                'per_page'    => $per_page,
     190            )
     191        );
     192    }
     193
     194    /**
    186195     * @return bool
    187196     */
     
    193202     */
    194203    public function no_items() {
    195         if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] )
     204        if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) {
    196205            echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash;
    197         else
     206        } else {
    198207            echo get_post_type_object( $this->screen->post_type )->labels->not_found;
     208        }
    199209    }
    200210
     
    254264
    255265    /**
    256      *
    257266     * @global array $locked_post_status This seems to be deprecated.
    258267     * @global array $avail_post_stati
     
    264273        $post_type = $this->screen->post_type;
    265274
    266         if ( !empty($locked_post_status) )
     275        if ( ! empty( $locked_post_status ) ) {
    267276            return array();
     277        }
    268278
    269279        $status_links = array();
    270         $num_posts = wp_count_posts( $post_type, 'readable' );
    271         $total_posts = array_sum( (array) $num_posts );
    272         $class = '';
     280        $num_posts    = wp_count_posts( $post_type, 'readable' );
     281        $total_posts  = array_sum( (array) $num_posts );
     282        $class        = '';
    273283
    274284        $current_user_id = get_current_user_id();
    275         $all_args = array( 'post_type' => $post_type );
    276         $mine = '';
     285        $all_args        = array( 'post_type' => $post_type );
     286        $mine            = '';
    277287
    278288        // Subtract post types that are not included in the admin all list.
     
    288298            $mine_args = array(
    289299                'post_type' => $post_type,
    290                 'author' => $current_user_id
     300                'author'    => $current_user_id,
    291301            );
    292302
     
    304314
    305315            $all_args['all_posts'] = 1;
    306             $class = '';
     316            $class                 = '';
    307317        }
    308318
     
    326336        }
    327337
    328         foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) {
     338        foreach ( get_post_stati( array( 'show_in_admin_status_list' => true ), 'objects' ) as $status ) {
    329339            $class = '';
    330340
     
    335345            }
    336346
    337             if ( isset($_REQUEST['post_status']) && $status_name === $_REQUEST['post_status'] ) {
     347            if ( isset( $_REQUEST['post_status'] ) && $status_name === $_REQUEST['post_status'] ) {
    338348                $class = 'current';
    339349            }
     
    341351            $status_args = array(
    342352                'post_status' => $status_name,
    343                 'post_type' => $post_type,
     353                'post_type'   => $post_type,
    344354            );
    345355
     
    356366
    357367            $sticky_args = array(
    358                 'post_type' => $post_type,
    359                 'show_sticky' => 1
     368                'post_type'   => $post_type,
     369                'show_sticky' => 1,
    360370            );
    361371
     
    371381
    372382            $sticky_link = array(
    373                 'sticky' => $this->get_edit_link( $sticky_args, $sticky_inner_html, $class )
     383                'sticky' => $this->get_edit_link( $sticky_args, $sticky_inner_html, $class ),
    374384            );
    375385
    376386            // Sticky comes after Publish, or if not listed, after All.
    377             $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) );
     387            $split        = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) );
    378388            $status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) );
    379389        }
     
    383393
    384394    /**
    385      *
    386395     * @return array
    387396     */
    388397    protected function get_bulk_actions() {
    389         $actions = array();
     398        $actions       = array();
    390399        $post_type_obj = get_post_type_object( $this->screen->post_type );
    391400
     
    436445            $dropdown_options = array(
    437446                'show_option_all' => get_taxonomy( 'category' )->labels->all_items,
    438                 'hide_empty' => 0,
    439                 'hierarchical' => 1,
    440                 'show_count' => 0,
    441                 'orderby' => 'name',
    442                 'selected' => $cat
     447                'hide_empty'      => 0,
     448                'hierarchical'    => 1,
     449                'show_count'      => 0,
     450                'orderby'         => 'name',
     451                'selected'        => $cat,
    443452            );
    444453
     
    455464        <div class="alignleft actions">
    456465<?php
    457         if ( 'top' === $which && !is_singular() ) {
    458             ob_start();
    459 
    460             $this->months_dropdown( $this->screen->post_type );
    461             $this->categories_dropdown( $this->screen->post_type );
    462 
    463             /**
    464             * Fires before the Filter button on the Posts and Pages list tables.
    465             *
    466             * The Filter button allows sorting by date and/or category on the
    467             * Posts list table, and sorting by date on the Pages list table.
    468             *
    469             * @since 2.1.0
    470             * @since 4.4.0 The `$post_type` parameter was added.
    471             * @since 4.6.0 The `$which` parameter was added.
    472             *
    473             * @param string $post_type The post type slug.
    474             * @param string $which     The location of the extra table nav markup:
    475             *                          'top' or 'bottom' for WP_Posts_List_Table,
    476             *                          'bar' for WP_Media_List_Table.
    477             */
    478             do_action( 'restrict_manage_posts', $this->screen->post_type, $which );
    479 
    480             $output = ob_get_clean();
    481 
    482             if ( ! empty( $output ) ) {
    483                 echo $output;
    484                 submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
    485             }
    486         }
    487 
    488         if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) && $this->has_items() ) {
    489             submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
    490         }
     466if ( 'top' === $which && ! is_singular() ) {
     467    ob_start();
     468
     469    $this->months_dropdown( $this->screen->post_type );
     470    $this->categories_dropdown( $this->screen->post_type );
     471
     472    /**
     473    * Fires before the Filter button on the Posts and Pages list tables.
     474    *
     475    * The Filter button allows sorting by date and/or category on the
     476    * Posts list table, and sorting by date on the Pages list table.
     477    *
     478    * @since 2.1.0
     479    * @since 4.4.0 The `$post_type` parameter was added.
     480    * @since 4.6.0 The `$which` parameter was added.
     481    *
     482    * @param string $post_type The post type slug.
     483    * @param string $which     The location of the extra table nav markup:
     484    *                          'top' or 'bottom' for WP_Posts_List_Table,
     485    *                          'bar' for WP_Media_List_Table.
     486    */
     487    do_action( 'restrict_manage_posts', $this->screen->post_type, $which );
     488
     489    $output = ob_get_clean();
     490
     491    if ( ! empty( $output ) ) {
     492        echo $output;
     493        submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
     494    }
     495}
     496
     497if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) && $this->has_items() ) {
     498    submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
     499}
    491500?>
    492501        </div>
     
    504513
    505514    /**
    506      *
    507515     * @return string
    508516     */
    509517    public function current_action() {
    510         if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
     518        if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) {
    511519            return 'delete_all';
     520        }
    512521
    513522        return parent::current_action();
     
    515524
    516525    /**
    517      *
    518526     * @return array
    519527     */
     
    523531
    524532    /**
    525      *
    526533     * @return array
    527534     */
     
    558565
    559566        foreach ( $taxonomies as $taxonomy ) {
    560             if ( 'category' === $taxonomy )
     567            if ( 'category' === $taxonomy ) {
    561568                $column_key = 'categories';
    562             elseif ( 'post_tag' === $taxonomy )
     569            } elseif ( 'post_tag' === $taxonomy ) {
    563570                $column_key = 'tags';
    564             else
     571            } else {
    565572                $column_key = 'taxonomy-' . $taxonomy;
     573            }
    566574
    567575            $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name;
    568576        }
    569577
    570         $post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
    571         if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) )
     578        $post_status = ! empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
     579        if ( post_type_supports( $post_type, 'comments' ) && ! in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) {
    572580            $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>';
     581        }
    573582
    574583        $posts_columns['date'] = __( 'Date' );
     
    610619
    611620    /**
    612      *
    613621     * @return array
    614622     */
     
    618626            'parent'   => 'parent',
    619627            'comments' => 'comment_count',
    620             'date'     => array( 'date', true )
     628            'date'     => array( 'date', true ),
    621629        );
    622630    }
     
    631639        global $wp_query, $per_page;
    632640
    633         if ( empty( $posts ) )
     641        if ( empty( $posts ) ) {
    634642            $posts = $wp_query->posts;
     643        }
    635644
    636645        add_filter( 'the_title', 'esc_html' );
     
    651660        $post_ids = array();
    652661
    653         foreach ( $posts as $a_post )
     662        foreach ( $posts as $a_post ) {
    654663            $post_ids[] = $a_post->ID;
     664        }
    655665
    656666        $this->comment_pending_count = get_pending_comments_num( $post_ids );
    657667
    658         foreach ( $posts as $post )
     668        foreach ( $posts as $post ) {
    659669            $this->single_row( $post, $level );
     670        }
    660671    }
    661672
     
    675686            $pages = get_pages( array( 'sort_column' => 'menu_order' ) );
    676687
    677             if ( ! $pages )
     688            if ( ! $pages ) {
    678689                return;
     690            }
    679691        }
    680692
     
    689701
    690702            $top_level_pages = array();
    691             $children_pages = array();
     703            $children_pages  = array();
    692704
    693705            foreach ( $pages as $page ) {
     
    700712                }
    701713
    702                 if ( 0 == $page->post_parent )
     714                if ( 0 == $page->post_parent ) {
    703715                    $top_level_pages[] = $page;
    704                 else
     716                } else {
    705717                    $children_pages[ $page->post_parent ][] = $page;
     718                }
    706719            }
    707720
     
    709722        }
    710723
    711         $count = 0;
    712         $start = ( $pagenum - 1 ) * $per_page;
    713         $end = $start + $per_page;
     724        $count      = 0;
     725        $start      = ( $pagenum - 1 ) * $per_page;
     726        $end        = $start + $per_page;
    714727        $to_display = array();
    715728
    716729        foreach ( $pages as $page ) {
    717             if ( $count >= $end )
     730            if ( $count >= $end ) {
    718731                break;
     732            }
    719733
    720734            if ( $count >= $start ) {
    721                 $to_display[$page->ID] = $level;
     735                $to_display[ $page->ID ] = $level;
    722736            }
    723737
    724738            $count++;
    725739
    726             if ( isset( $children_pages ) )
     740            if ( isset( $children_pages ) ) {
    727741                $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
     742            }
    728743        }
    729744
    730745        // If it is the last pagenum and there are orphaned pages, display them with paging as well.
    731         if ( isset( $children_pages ) && $count < $end ){
    732             foreach ( $children_pages as $orphans ){
     746        if ( isset( $children_pages ) && $count < $end ) {
     747            foreach ( $children_pages as $orphans ) {
    733748                foreach ( $orphans as $op ) {
    734                     if ( $count >= $end )
     749                    if ( $count >= $end ) {
    735750                        break;
     751                    }
    736752
    737753                    if ( $count >= $start ) {
    738                         $to_display[$op->ID] = 0;
     754                        $to_display[ $op->ID ] = 0;
    739755                    }
    740756
     
    773789     */
    774790    private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) {
    775         if ( ! isset( $children_pages[$parent] ) )
     791        if ( ! isset( $children_pages[ $parent ] ) ) {
    776792            return;
     793        }
    777794
    778795        $start = ( $pagenum - 1 ) * $per_page;
    779         $end = $start + $per_page;
    780 
    781         foreach ( $children_pages[$parent] as $page ) {
    782             if ( $count >= $end )
     796        $end   = $start + $per_page;
     797
     798        foreach ( $children_pages[ $parent ] as $page ) {
     799            if ( $count >= $end ) {
    783800                break;
     801            }
    784802
    785803            // If the page starts in a subtree, print the parents.
    786804            if ( $count == $start && $page->post_parent > 0 ) {
    787805                $my_parents = array();
    788                 $my_parent = $page->post_parent;
     806                $my_parent  = $page->post_parent;
    789807                while ( $my_parent ) {
    790808                    // Get the ID from the list or the attribute if my_parent is an object
     
    794812                    }
    795813
    796                     $my_parent = get_post( $parent_id );
     814                    $my_parent    = get_post( $parent_id );
    797815                    $my_parents[] = $my_parent;
    798                     if ( !$my_parent->post_parent )
     816                    if ( ! $my_parent->post_parent ) {
    799817                        break;
     818                    }
    800819                    $my_parent = $my_parent->post_parent;
    801820                }
    802821                $num_parents = count( $my_parents );
    803822                while ( $my_parent = array_pop( $my_parents ) ) {
    804                     $to_display[$my_parent->ID] = $level - $num_parents;
     823                    $to_display[ $my_parent->ID ] = $level - $num_parents;
    805824                    $num_parents--;
    806825                }
     
    808827
    809828            if ( $count >= $start ) {
    810                 $to_display[$page->ID] = $level;
     829                $to_display[ $page->ID ] = $level;
    811830            }
    812831
     
    816835        }
    817836
    818         unset( $children_pages[$parent] ); //required in order to keep track of orphans
     837        unset( $children_pages[ $parent ] ); //required in order to keep track of orphans
    819838    }
    820839
     
    827846     */
    828847    public function column_cb( $post ) {
    829         if ( current_user_can( 'edit_post', $post->ID ) ): ?>
    830             <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php
    831                 printf( __( 'Select %s' ), _draft_or_post_title() );
    832             ?></label>
     848        if ( current_user_can( 'edit_post', $post->ID ) ) :
     849        ?>
     850            <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>">
     851                                                                                <?php
     852                                                                                printf( __( 'Select %s' ), _draft_or_post_title() );
     853            ?>
     854            </label>
    833855            <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
    834856            <div class="locked-indicator">
    835857                <span class="locked-indicator-icon" aria-hidden="true"></span>
    836                 <span class="screen-reader-text"><?php
     858                <span class="screen-reader-text">
     859                <?php
    837860                printf(
    838861                    /* translators: %s: post title */
     
    840863                    _draft_or_post_title()
    841864                );
    842                 ?></span>
     865                ?>
     866                </span>
    843867            </div>
    844         <?php endif;
     868        <?php
     869        endif;
    845870    }
    846871
     
    900925
    901926            if ( $lock_holder ) {
    902                 $lock_holder = get_userdata( $lock_holder );
     927                $lock_holder   = get_userdata( $lock_holder );
    903928                $locked_avatar = get_avatar( $lock_holder->ID, 18 );
    904                 $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
     929                $locked_text   = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
    905930            } else {
    906931                $locked_avatar = $locked_text = '';
     
    911936
    912937        $pad = str_repeat( '&#8212; ', $this->current_level );
    913         echo "<strong>";
     938        echo '<strong>';
    914939
    915940        $format = get_post_format( $post->ID );
     
    921946            $format_args = array(
    922947                'post_format' => $format,
    923                 'post_type' => $post->post_type
     948                'post_type'   => $post->post_type,
    924949            );
    925950
     
    973998
    974999        if ( '0000-00-00 00:00:00' === $post->post_date ) {
    975             $t_time = $h_time = __( 'Unpublished' );
     1000            $t_time    = $h_time = __( 'Unpublished' );
    9761001            $time_diff = 0;
    9771002        } else {
    9781003            $t_time = get_the_time( __( 'Y/m/d g:i:s a' ) );
    9791004            $m_time = $post->post_date;
    980             $time = get_post_time( 'G', true, $post );
     1005            $time   = get_post_time( 'G', true, $post );
    9811006
    9821007            $time_diff = time() - $time;
     
    10511076        <div class="post-com-count-wrapper">
    10521077        <?php
    1053             $pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0;
     1078            $pending_comments = isset( $this->comment_pending_count[ $post->ID ] ) ? $this->comment_pending_count[ $post->ID ] : 0;
    10541079
    10551080            $this->comments_bubble( $post->ID, $pending_comments );
     
    10691094        $args = array(
    10701095            'post_type' => $post->post_type,
    1071             'author' => get_the_author_meta( 'ID' )
     1096            'author'    => get_the_author_meta( 'ID' ),
    10721097        );
    10731098        echo $this->get_edit_link( $args, get_the_author() );
     
    10941119        if ( $taxonomy ) {
    10951120            $taxonomy_object = get_taxonomy( $taxonomy );
    1096             $terms = get_the_terms( $post->ID, $taxonomy );
     1121            $terms           = get_the_terms( $post->ID, $taxonomy );
    10971122            if ( is_array( $terms ) ) {
    10981123                $out = array();
     
    11061131                    } else {
    11071132                        $posts_in_term_qv['taxonomy'] = $taxonomy;
    1108                         $posts_in_term_qv['term'] = $t->slug;
     1133                        $posts_in_term_qv['term']     = $t->slug;
    11091134                    }
    11101135
     
    11721197        $global_post = get_post();
    11731198
    1174         $post = get_post( $post );
     1199        $post                = get_post( $post );
    11751200        $this->current_level = $level;
    11761201
     
    11861211
    11871212        if ( $post->post_parent ) {
    1188             $count = count( get_post_ancestors( $post->ID ) );
    1189             $classes .= ' level-'. $count;
     1213            $count    = count( get_post_ancestors( $post->ID ) );
     1214            $classes .= ' level-' . $count;
    11901215        } else {
    1191             $classes .= ' level-0';
     1216            $classes .= ' level-0';
    11921217        }
    11931218    ?>
     
    12261251
    12271252        $post_type_object = get_post_type_object( $post->post_type );
    1228         $can_edit_post = current_user_can( 'edit_post', $post->ID );
    1229         $actions = array();
    1230         $title = _draft_or_post_title();
     1253        $can_edit_post    = current_user_can( 'edit_post', $post->ID );
     1254        $actions          = array();
     1255        $title            = _draft_or_post_title();
    12311256
    12321257        if ( $can_edit_post && 'trash' != $post->post_status ) {
     
    12781303            if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
    12791304                if ( $can_edit_post ) {
    1280                     $preview_link = get_preview_post_link( $post );
     1305                    $preview_link    = get_preview_post_link( $post );
    12811306                    $actions['view'] = sprintf(
    12821307                        '<a href="%s" rel="bookmark" aria-label="%s">%s</a>',
     
    13451370        $screen = $this->screen;
    13461371
    1347         $post = get_default_post_to_edit( $screen->post_type );
     1372        $post             = get_default_post_to_edit( $screen->post_type );
    13481373        $post_type_object = get_post_type_object( $screen->post_type );
    13491374
    1350         $taxonomy_names = get_object_taxonomies( $screen->post_type );
     1375        $taxonomy_names          = get_object_taxonomies( $screen->post_type );
    13511376        $hierarchical_taxonomies = array();
    1352         $flat_taxonomies = array();
     1377        $flat_taxonomies         = array();
    13531378        foreach ( $taxonomy_names as $taxonomy_name ) {
    13541379
     
    13701395            }
    13711396
    1372             if ( $taxonomy->hierarchical )
     1397            if ( $taxonomy->hierarchical ) {
    13731398                $hierarchical_taxonomies[] = $taxonomy;
    1374             else
     1399            } else {
    13751400                $flat_taxonomies[] = $taxonomy;
    1376         }
    1377 
    1378         $m = ( isset( $mode ) && 'excerpt' === $mode ) ? 'excerpt' : 'list';
    1379         $can_publish = current_user_can( $post_type_object->cap->publish_posts );
    1380         $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
     1401            }
     1402        }
     1403
     1404        $m            = ( isset( $mode ) && 'excerpt' === $mode ) ? 'excerpt' : 'list';
     1405        $can_publish  = current_user_can( $post_type_object->cap->publish_posts );
     1406        $core_columns = array(
     1407            'cb'         => true,
     1408            'date'       => true,
     1409            'title'      => true,
     1410            'categories' => true,
     1411            'tags'       => true,
     1412            'comments'   => true,
     1413            'author'     => true,
     1414        );
    13811415
    13821416    ?>
     
    13841418    <form method="get"><table style="display: none"><tbody id="inlineedit">
    13851419        <?php
    1386         $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page';
     1420        $hclass              = count( $hierarchical_taxonomies ) ? 'post' : 'page';
    13871421        $inline_edit_classes = "inline-edit-row inline-edit-row-$hclass";
    13881422        $bulk_edit_classes   = "bulk-edit-row bulk-edit-row-$hclass bulk-edit-{$screen->post_type}";
     
    13901424
    13911425        $bulk = 0;
    1392         while ( $bulk < 2 ) { ?>
    1393 
    1394         <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="<?php echo $inline_edit_classes . ' ';
    1395             echo $bulk ? $bulk_edit_classes : $quick_edit_classes;
    1396         ?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
     1426        while ( $bulk < 2 ) {
     1427        ?>
     1428
     1429        <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="
     1430                            <?php
     1431                            echo $inline_edit_classes . ' ';
     1432                            echo $bulk ? $bulk_edit_classes : $quick_edit_classes;
     1433        ?>
     1434        " style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
    13971435
    13981436        <fieldset class="inline-edit-col-left">
     
    14021440
    14031441    if ( post_type_supports( $screen->post_type, 'title' ) ) :
    1404         if ( $bulk ) : ?>
     1442        if ( $bulk ) :
     1443        ?>
    14051444            <div id="bulk-title-div">
    14061445                <div id="bulk-titles"></div>
     
    14191458            </label>
    14201459
    1421     <?php endif; // $bulk
    1422     endif; // post_type_supports title ?>
    1423 
    1424     <?php if ( !$bulk ) : ?>
     1460    <?php
     1461    endif; // $bulk
     1462    endif; // post_type_supports title
     1463    ?>
     1464
     1465    <?php if ( ! $bulk ) : ?>
    14251466            <fieldset class="inline-edit-date">
    14261467            <legend><span class="title"><?php _e( 'Date' ); ?></span></legend>
     
    14281469            </fieldset>
    14291470            <br class="clear" />
    1430     <?php endif; // $bulk
    1431 
    1432         if ( post_type_supports( $screen->post_type, 'author' ) ) :
    1433             $authors_dropdown = '';
    1434 
    1435             if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) :
    1436                 $users_opt = array(
    1437                     'hide_if_only_one_author' => false,
    1438                     'who' => 'authors',
    1439                     'name' => 'post_author',
    1440                     'class'=> 'authors',
    1441                     'multi' => 1,
    1442                     'echo' => 0,
    1443                     'show' => 'display_name_with_login',
    1444                 );
    1445                 if ( $bulk )
    1446                     $users_opt['show_option_none'] = __( '&mdash; No Change &mdash;' );
    1447 
    1448                 if ( $authors = wp_dropdown_users( $users_opt ) ) :
    1449                     $authors_dropdown  = '<label class="inline-edit-author">';
    1450                     $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
    1451                     $authors_dropdown .= $authors;
    1452                     $authors_dropdown .= '</label>';
    1453                 endif;
    1454             endif; // authors
     1471    <?php
     1472    endif; // $bulk
     1473
     1474if ( post_type_supports( $screen->post_type, 'author' ) ) :
     1475    $authors_dropdown = '';
     1476
     1477    if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) :
     1478        $users_opt = array(
     1479            'hide_if_only_one_author' => false,
     1480            'who'                     => 'authors',
     1481            'name'                    => 'post_author',
     1482            'class'                   => 'authors',
     1483            'multi'                   => 1,
     1484            'echo'                    => 0,
     1485            'show'                    => 'display_name_with_login',
     1486        );
     1487        if ( $bulk ) {
     1488            $users_opt['show_option_none'] = __( '&mdash; No Change &mdash;' );
     1489        }
     1490
     1491        if ( $authors = wp_dropdown_users( $users_opt ) ) :
     1492            $authors_dropdown  = '<label class="inline-edit-author">';
     1493            $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
     1494            $authors_dropdown .= $authors;
     1495            $authors_dropdown .= '</label>';
     1496        endif;
     1497    endif; // authors
    14551498    ?>
    14561499
    1457     <?php if ( !$bulk ) echo $authors_dropdown;
     1500    <?php
     1501    if ( ! $bulk ) {
     1502        echo $authors_dropdown;}
    14581503    endif; // post_type_supports author
    14591504
    1460     if ( !$bulk && $can_publish ) :
     1505if ( ! $bulk && $can_publish ) :
    14611506    ?>
    14621507
    1463             <div class="inline-edit-group wp-clearfix">
    1464                 <label class="alignleft">
    1465                     <span class="title"><?php _e( 'Password' ); ?></span>
    1466                     <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
    1467                 </label>
    1468 
    1469                 <em class="alignleft inline-edit-or">
    1470                     <?php
    1471                     /* translators: Between password field and private checkbox on post quick edit interface */
    1472                     _e( '&ndash;OR&ndash;' );
    1473                     ?>
     1508        <div class="inline-edit-group wp-clearfix">
     1509            <label class="alignleft">
     1510                <span class="title"><?php _e( 'Password' ); ?></span>
     1511                <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
     1512            </label>
     1513
     1514            <em class="alignleft inline-edit-or">
     1515                <?php
     1516                /* translators: Between password field and private checkbox on post quick edit interface */
     1517                _e( '&ndash;OR&ndash;' );
     1518                ?>
    14741519                </em>
    14751520                <label class="alignleft inline-edit-private">
    1476                     <input type="checkbox" name="keep_private" value="private" />
    1477                     <span class="checkbox-title"><?php _e( 'Private' ); ?></span>
     1521                <input type="checkbox" name="keep_private" value="private" />
     1522                <span class="checkbox-title"><?php _e( 'Private' ); ?></span>
    14781523                </label>
    14791524            </div>
     
    14831528        </div></fieldset>
    14841529
    1485     <?php if ( count( $hierarchical_taxonomies ) && !$bulk ) : ?>
     1530    <?php if ( count( $hierarchical_taxonomies ) && ! $bulk ) : ?>
    14861531
    14871532        <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
     
    14891534    <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
    14901535
    1491             <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
     1536            <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ); ?></span>
    14921537            <input type="hidden" name="<?php echo ( $taxonomy->name === 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" />
    1493             <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist">
    1494                 <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?>
     1538            <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name ); ?>-checklist">
     1539                <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ); ?>
    14951540            </ul>
    14961541
     
    15041549
    15051550    <?php
    1506         if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
    1507             echo $authors_dropdown;
    1508 
    1509         if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
    1510 
    1511             if ( $post_type_object->hierarchical ) :
     1551    if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) {
     1552        echo $authors_dropdown;
     1553    }
     1554
     1555    if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
     1556
     1557        if ( $post_type_object->hierarchical ) :
    15121558        ?>
    1513             <label>
    1514                 <span class="title"><?php _e( 'Parent' ); ?></span>
     1559        <label>
     1560            <span class="title"><?php _e( 'Parent' ); ?></span>
    15151561    <?php
    1516         $dropdown_args = array(
    1517             'post_type'         => $post_type_object->name,
    1518             'selected'          => $post->post_parent,
    1519             'name'              => 'post_parent',
    1520             'show_option_none'  => __( 'Main Page (no parent)' ),
    1521             'option_none_value' => 0,
    1522             'sort_column'       => 'menu_order, post_title',
    1523         );
    1524 
    1525         if ( $bulk )
    1526             $dropdown_args['show_option_no_change'] =  __( '&mdash; No Change &mdash;' );
    1527 
    1528         /**
    1529          * Filters the arguments used to generate the Quick Edit page-parent drop-down.
    1530          *
    1531          * @since 2.7.0
    1532          *
    1533          * @see wp_dropdown_pages()
    1534          *
    1535          * @param array $dropdown_args An array of arguments.
    1536          */
    1537         $dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args );
    1538 
    1539         wp_dropdown_pages( $dropdown_args );
    1540     ?>
    1541             </label>
    1542 
    1543     <?php
    1544             endif; // hierarchical
    1545 
    1546             if ( !$bulk ) : ?>
     1562    $dropdown_args = array(
     1563        'post_type'         => $post_type_object->name,
     1564        'selected'          => $post->post_parent,
     1565        'name'              => 'post_parent',
     1566        'show_option_none'  => __( 'Main Page (no parent)' ),
     1567        'option_none_value' => 0,
     1568        'sort_column'       => 'menu_order, post_title',
     1569    );
     1570
     1571    if ( $bulk ) {
     1572        $dropdown_args['show_option_no_change'] = __( '&mdash; No Change &mdash;' );
     1573    }
     1574
     1575    /**
     1576     * Filters the arguments used to generate the Quick Edit page-parent drop-down.
     1577     *
     1578     * @since 2.7.0
     1579     *
     1580     * @see wp_dropdown_pages()
     1581     *
     1582     * @param array $dropdown_args An array of arguments.
     1583     */
     1584    $dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args );
     1585
     1586    wp_dropdown_pages( $dropdown_args );
     1587?>
     1588        </label>
     1589
     1590<?php
     1591        endif; // hierarchical
     1592
     1593        if ( ! $bulk ) :
     1594            ?>
    15471595
    15481596            <label>
    15491597                <span class="title"><?php _e( 'Order' ); ?></span>
    1550                 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
     1598                <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order; ?>" /></span>
    15511599            </label>
    15521600
    15531601    <?php
    1554             endif; // !$bulk
     1602        endif; // !$bulk
    15551603        endif; // page-attributes
    15561604    ?>
     
    15631611                <option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
    15641612<?php   endif; // $bulk ?>
    1565                 <?php
     1613                <?php
    15661614                /** This filter is documented in wp-admin/includes/meta-boxes.php */
    1567                 $default_title = apply_filters( 'default_page_template_title',  __( 'Default Template' ), 'quick-edit' );
    1568                 ?>
     1615                $default_title = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'quick-edit' );
     1616                ?>
    15691617                <option value="default"><?php echo esc_html( $default_title ); ?></option>
    1570                 <?php page_template_dropdown( '', $screen->post_type ) ?>
     1618                <?php page_template_dropdown( '', $screen->post_type ); ?>
    15711619            </select>
    15721620        </label>
    15731621    <?php endif; ?>
    15741622
    1575     <?php if ( count( $flat_taxonomies ) && !$bulk ) : ?>
     1623    <?php if ( count( $flat_taxonomies ) && ! $bulk ) : ?>
    15761624
    15771625    <?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
    1578         <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) :
     1626        <?php
     1627        if ( current_user_can( $taxonomy->cap->assign_terms ) ) :
    15791628            $taxonomy_name = esc_attr( $taxonomy->name );
    15801629
    15811630            ?>
    15821631            <label class="inline-edit-tags">
    1583                 <span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
     1632                <span class="title"><?php echo esc_html( $taxonomy->labels->name ); ?></span>
    15841633                <textarea data-wp-taxonomy="<?php echo $taxonomy_name; ?>" cols="22" rows="1" name="tax_input[<?php echo $taxonomy_name; ?>]" class="tax_input_<?php echo $taxonomy_name; ?>"></textarea>
    15851634            </label>
     
    15881637    <?php endforeach; //$flat_taxonomies as $taxonomy ?>
    15891638
    1590     <?php endif; // count( $flat_taxonomies ) && !$bulk  ?>
    1591 
    1592     <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
    1593         if ( $bulk ) : ?>
     1639    <?php endif; // count( $flat_taxonomies ) && !$bulk ?>
     1640
     1641    <?php
     1642    if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
     1643        if ( $bulk ) :
     1644        ?>
    15941645
    15951646            <div class="inline-edit-group wp-clearfix">
     
    16311682            </div>
    16321683
    1633     <?php endif; // $bulk
    1634     endif; // post_type_supports comments or pings ?>
     1684    <?php
     1685    endif; // $bulk
     1686    endif; // post_type_supports comments or pings
     1687    ?>
    16351688
    16361689            <div class="inline-edit-group wp-clearfix">
     
    16451698                        <option value="future"><?php _e( 'Scheduled' ); ?></option>
    16461699    <?php if ( $bulk ) : ?>
    1647                         <option value="private"><?php _e( 'Private' ) ?></option>
     1700                        <option value="private"><?php _e( 'Private' ); ?></option>
    16481701    <?php endif; // $bulk ?>
    16491702                    <?php endif; ?>
     
    17111764        list( $columns ) = $this->get_column_info();
    17121765
    1713         foreach ( $columns as $column_name => $column_display_name ) {
    1714             if ( isset( $core_columns[$column_name] ) )
    1715                 continue;
    1716 
    1717             if ( $bulk ) {
    1718 
    1719                 /**
    1720                  * Fires once for each column in Bulk Edit mode.
    1721                  *
    1722                  * @since 2.7.0
    1723                  *
    1724                  * @param string  $column_name Name of the column to edit.
    1725                  * @param WP_Post $post_type   The post type slug.
    1726                  */
    1727                 do_action( 'bulk_edit_custom_box', $column_name, $screen->post_type );
    1728             } else {
    1729 
    1730                 /**
    1731                  * Fires once for each column in Quick Edit mode.
    1732                  *
    1733                  * @since 2.7.0
    1734                  *
    1735                  * @param string $column_name Name of the column to edit.
    1736                  * @param string $post_type   The post type slug, or current screen name if this is a taxonomy list table.
    1737                  * @param string taxonomy     The taxonomy name, if any.
    1738                  */
    1739                 do_action( 'quick_edit_custom_box', $column_name, $screen->post_type, '' );
    1740             }
    1741 
    1742         }
     1766    foreach ( $columns as $column_name => $column_display_name ) {
     1767        if ( isset( $core_columns[ $column_name ] ) ) {
     1768            continue;
     1769        }
     1770
     1771        if ( $bulk ) {
     1772
     1773            /**
     1774             * Fires once for each column in Bulk Edit mode.
     1775             *
     1776             * @since 2.7.0
     1777             *
     1778             * @param string  $column_name Name of the column to edit.
     1779             * @param WP_Post $post_type   The post type slug.
     1780             */
     1781            do_action( 'bulk_edit_custom_box', $column_name, $screen->post_type );
     1782        } else {
     1783
     1784            /**
     1785             * Fires once for each column in Quick Edit mode.
     1786             *
     1787             * @since 2.7.0
     1788             *
     1789             * @param string $column_name Name of the column to edit.
     1790             * @param string $post_type   The post type slug, or current screen name if this is a taxonomy list table.
     1791             * @param string taxonomy     The taxonomy name, if any.
     1792             */
     1793            do_action( 'quick_edit_custom_box', $column_name, $screen->post_type, '' );
     1794        }
     1795    }
    17431796    ?>
    17441797        <div class="submit inline-edit-save">
    17451798            <button type="button" class="button cancel alignleft"><?php _e( 'Cancel' ); ?></button>
    1746             <?php if ( ! $bulk ) {
     1799            <?php
     1800            if ( ! $bulk ) {
    17471801                wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
    17481802                ?>
    17491803                <button type="button" class="button button-primary save alignright"><?php _e( 'Update' ); ?></button>
    17501804                <span class="spinner"></span>
    1751             <?php } else {
     1805            <?php
     1806            } else {
    17521807                submit_button( __( 'Update' ), 'primary alignright', 'bulk_edit', false );
    1753             } ?>
     1808            }
     1809            ?>
    17541810            <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
    17551811            <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
Note: See TracChangeset for help on using the changeset viewer.