Make WordPress Core


Ignore:
Timestamp:
07/14/2015 05:46:13 PM (8 years ago)
Author:
wonderboymusic
Message:

List Tables:

  • In ->handle_row_actions(), bail immediately if $primary and $column_name do not match. Saves us a nesting level and avoids declaring code that is unusable.
  • In WP_List_Table::single_row_columns(), allow _column_{$name} to be called dynamically by core to avoid having to override the entirety of ->single_row_columns() in WP_MS_Users_List_Table and WP_Posts_List_Table
  • In WP_MS_Sites_List_Table, id is not a column.

Props wonderboymusic, paulwilde.
Fixes #29881.

File:
1 edited

Legend:

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

    r33207 r33270  
    397397     */
    398398    protected function handle_row_actions( $tag, $column_name, $primary ) {
     399        if ( $primary !== $column_name ) {
     400            return '';
     401        }
     402
    399403        $taxonomy = $this->screen->taxonomy;
    400404        $tax = get_taxonomy( $taxonomy );
     
    403407        $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) );
    404408
    405         if ( $primary === $column_name ) {
    406             $actions = array();
    407             if ( current_user_can( $tax->cap->edit_terms ) ) {
    408                 $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
    409                 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick&nbsp;Edit' ) . '</a>';
    410             }
    411             if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
    412                 $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url( "edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) . "'>" . __( 'Delete' ) . "</a>";
    413             if ( $tax->public )
    414                 $actions['view'] = '<a href="' . get_term_link( $tag ) . '">' . __( 'View' ) . '</a>';
    415 
    416             /**
    417              * Filter the action links displayed for each term in the Tags list table.
    418              *
    419              * @since 2.8.0
    420              * @deprecated 3.0.0 Use {$taxonomy}_row_actions instead.
    421              *
    422              * @param array  $actions An array of action links to be displayed. Default
    423              *                        'Edit', 'Quick Edit', 'Delete', and 'View'.
    424              * @param object $tag     Term object.
    425              */
    426             $actions = apply_filters( 'tag_row_actions', $actions, $tag );
    427 
    428             /**
    429              * Filter the action links displayed for each term in the terms list table.
    430              *
    431              * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
    432              *
    433              * @since 3.0.0
    434              *
    435              * @param array  $actions An array of action links to be displayed. Default
    436              *                        'Edit', 'Quick Edit', 'Delete', and 'View'.
    437              * @param object $tag     Term object.
    438              */
    439             $actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag );
    440 
    441             return $this->row_actions( $actions );
    442         }
     409        $actions = array();
     410        if ( current_user_can( $tax->cap->edit_terms ) ) {
     411            $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
     412            $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick&nbsp;Edit' ) . '</a>';
     413        }
     414        if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
     415            $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url( "edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) . "'>" . __( 'Delete' ) . "</a>";
     416        if ( $tax->public )
     417            $actions['view'] = '<a href="' . get_term_link( $tag ) . '">' . __( 'View' ) . '</a>';
     418
     419        /**
     420         * Filter the action links displayed for each term in the Tags list table.
     421         *
     422         * @since 2.8.0
     423         * @deprecated 3.0.0 Use {$taxonomy}_row_actions instead.
     424         *
     425         * @param array  $actions An array of action links to be displayed. Default
     426         *                        'Edit', 'Quick Edit', 'Delete', and 'View'.
     427         * @param object $tag     Term object.
     428         */
     429        $actions = apply_filters( 'tag_row_actions', $actions, $tag );
     430
     431        /**
     432         * Filter the action links displayed for each term in the terms list table.
     433         *
     434         * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
     435         *
     436         * @since 3.0.0
     437         *
     438         * @param array  $actions An array of action links to be displayed. Default
     439         *                        'Edit', 'Quick Edit', 'Delete', and 'View'.
     440         * @param object $tag     Term object.
     441         */
     442        $actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag );
     443
     444        return $this->row_actions( $actions );
    443445    }
    444446
Note: See TracChangeset for help on using the changeset viewer.