Make WordPress Core

Changeset 33270


Ignore:
Timestamp:
07/14/2015 05:46:13 PM (9 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.

Location:
trunk/src/wp-admin/includes
Files:
8 edited

Legend:

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

    r33155 r33270  
    463463        global $comment_status;
    464464
     465        if ( $primary !== $column_name ) {
     466            return '';
     467        }
     468
    465469        if ( ! $this->user_can ) {
    466470            return;
    467         }
    468 
    469         if ( $primary !== $column_name ) {
    470             return '';
    471471        }
    472472
  • trunk/src/wp-admin/includes/class-wp-links-list-table.php

    r33204 r33270  
    311311     */
    312312    protected function handle_row_actions( $link, $column_name, $primary ) {
    313         if ( $primary === $column_name ) {
    314             $edit_link = get_edit_bookmark_link( $link );
    315 
    316             $actions = array();
    317             $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
    318             $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id) . "' onclick=\"if ( confirm( '" . esc_js(sprintf(__("You are about to delete this link '%s'\n  'Cancel' to stop, 'OK' to delete."), $link->link_name)) . "' ) ) { return true;}return false;\">" . __('Delete') . "</a>";
    319             return $this->row_actions($actions);
     313        if ( $primary !== $column_name ) {
     314            return '';
    320315        }
     316
     317        $edit_link = get_edit_bookmark_link( $link );
     318
     319        $actions = array();
     320        $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
     321        $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id) . "' onclick=\"if ( confirm( '" . esc_js(sprintf(__("You are about to delete this link '%s'\n  'Cancel' to stop, 'OK' to delete."), $link->link_name)) . "' ) ) { return true;}return false;\">" . __('Delete') . "</a>";
     322        return $this->row_actions( $actions );
    321323    }
    322324}
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r33266 r33270  
    12251225                echo $this->column_cb( $item );
    12261226                echo '</th>';
    1227             }
    1228             elseif ( method_exists( $this, 'column_' . $column_name ) ) {
     1227            } elseif ( method_exists( $this, '_column_' . $column_name ) ) {
     1228                echo call_user_func(
     1229                    array( $this, '_column_' . $column_name ),
     1230                    $item,
     1231                    $classes,
     1232                    $data,
     1233                    $primary
     1234                );
     1235            } elseif ( method_exists( $this, 'column_' . $column_name ) ) {
    12291236                echo "<td $attributes>";
    12301237                echo call_user_func( array( $this, 'column_' . $column_name ), $item );
    12311238                echo $this->handle_row_actions( $item, $column_name, $primary );
    12321239                echo "</td>";
    1233             }
    1234             else {
     1240            } else {
    12351241                echo "<td $attributes>";
    12361242                echo $this->column_default( $item, $column_name );
  • trunk/src/wp-admin/includes/class-wp-media-list-table.php

    r33269 r33270  
    648648     */
    649649    protected function handle_row_actions( $post, $column_name, $primary ) {
    650         if ( $primary === $column_name ) {
    651             $att_title = _draft_or_post_title();
    652             return $this->row_actions( $this->_get_row_actions( $post, $att_title ) );
    653         }
     650        if ( $primary !== $column_name ) {
     651            return '';
     652        }
     653
     654        $att_title = _draft_or_post_title();
     655        return $this->row_actions( $this->_get_row_actions( $post, $att_title ) );
    654656    }
    655657}
  • trunk/src/wp-admin/includes/class-wp-ms-sites-list-table.php

    r33199 r33270  
    410410
    411411    /**
    412      * Handles columns output for a single row.
    413      *
    414      * @since 4.3.0
    415      * @access public
    416      *
    417      * @param array $item Current site.
    418      */
    419     public function single_row_columns( $item ) {
    420         list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
    421 
    422         foreach ( $columns as $column_name => $column_display_name ) {
    423             $classes = "$column_name column-$column_name";
    424             if ( $primary === $column_name ) {
    425                 $classes .= ' has-row-actions column-primary';
    426             }
    427 
    428             if ( in_array( $column_name, $hidden ) ) {
    429                 $classes .= ' hidden';
    430             }
    431 
    432             $data = 'data-colname="' . wp_strip_all_tags( $column_display_name ) . '"';
    433 
    434             $attributes = "class='$classes' $data";
    435 
    436             if ( 'cb' === $column_name ) {
    437                 echo '<th scope="row" class="check-column">';
    438 
    439                 $this->column_cb( $item );
    440 
    441                 echo '</th>';
    442             } elseif ( 'id' === $column_name ) {
    443 ?>
    444                 <th scope="row">
    445                     <?php echo $item['blog_id'] ?>
    446                 </th>
    447 <?php
    448             } elseif ( method_exists( $this, 'column_' . $column_name ) ) {
    449                 echo "<td $attributes>";
    450 
    451                 echo call_user_func( array( $this, 'column_' . $column_name ), $item );
    452 
    453                 echo $this->handle_row_actions( $item, $column_name, $primary );
    454                 echo "</td>";
    455             } else {
    456                 echo "<td $attributes>";
    457 
    458                 echo $this->column_default( $item, $column_name );
    459 
    460                 echo $this->handle_row_actions( $item, $column_name, $primary );
    461                 echo "</td>";
    462             }
    463         }
    464     }
    465 
    466     /**
    467412     *
    468413     * @global string $mode
     
    511456     */
    512457    protected function handle_row_actions( $blog, $column_name, $primary ) {
    513         if ( $primary === $column_name ) {
    514             $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
    515 
    516             // Preordered.
    517             $actions = array(
    518                 'edit' => '', 'backend' => '',
    519                 'activate' => '', 'deactivate' => '',
    520                 'archive' => '', 'unarchive' => '',
    521                 'spam' => '', 'unspam' => '',
    522                 'delete' => '',
    523                 'visit' => '',
    524             );
    525 
    526             $actions['edit']    = '<span class="edit"><a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>';
    527             $actions['backend'] = "<span class='backend'><a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a></span>';
    528             if ( get_current_site()->blog_id != $blog['blog_id'] ) {
    529                 if ( $blog['deleted'] == '1' ) {
    530                     $actions['activate']   = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] ), 'activateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Activate' ) . '</a></span>';
    531                 } else {
    532                     $actions['deactivate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] ), 'deactivateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Deactivate' ) . '</a></span>';
    533                 }
    534 
    535                 if ( $blog['archived'] == '1' ) {
    536                     $actions['unarchive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unarchiveblog&amp;id=' . $blog['blog_id'] ), 'unarchiveblog_' . $blog['blog_id'] ) ) . '">' . __( 'Unarchive' ) . '</a></span>';
    537                 } else {
    538                     $actions['archive']   = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] ), 'archiveblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a></span>';
    539                 }
    540 
    541                 if ( $blog['spam'] == '1' ) {
    542                     $actions['unspam'] = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] ), 'unspamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a></span>';
    543                 } else {
    544                     $actions['spam']   = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] ), 'spamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Spam', 'site' ) . '</a></span>';
    545                 }
    546 
    547                 if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) {
    548                     $actions['delete'] = '<span class="delete"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] ), 'deleteblog_' . $blog['blog_id'] ) ) . '">' . __( 'Delete' ) . '</a></span>';
    549                 }
    550             }
    551 
    552             $actions['visit']   = "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a></span>';
    553 
    554             /**
    555              * Filter the action links displayed for each site in the Sites list table.
    556              *
    557              * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by
    558              * default for each site. The site's status determines whether to show the
    559              * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and
    560              * 'Not Spam' or 'Spam' link for each site.
    561              *
    562              * @since 3.1.0
    563              *
    564              * @param array  $actions  An array of action links to be displayed.
    565              * @param int    $blog_id  The site ID.
    566              * @param string $blogname Site path, formatted depending on whether it is a sub-domain
    567              *                         or subdirectory multisite install.
    568              */
    569             $actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname );
    570             return $this->row_actions( $actions );
    571         }
     458        if ( $primary !== $column_name ) {
     459            return;
     460        }
     461
     462        $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
     463
     464        // Preordered.
     465        $actions = array(
     466            'edit' => '', 'backend' => '',
     467            'activate' => '', 'deactivate' => '',
     468            'archive' => '', 'unarchive' => '',
     469            'spam' => '', 'unspam' => '',
     470            'delete' => '',
     471            'visit' => '',
     472        );
     473
     474        $actions['edit']    = '<span class="edit"><a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>';
     475        $actions['backend'] = "<span class='backend'><a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a></span>';
     476        if ( get_current_site()->blog_id != $blog['blog_id'] ) {
     477            if ( $blog['deleted'] == '1' ) {
     478                $actions['activate']   = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=activateblog&amp;id=' . $blog['blog_id'] ), 'activateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Activate' ) . '</a></span>';
     479            } else {
     480                $actions['deactivate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deactivateblog&amp;id=' . $blog['blog_id'] ), 'deactivateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Deactivate' ) . '</a></span>';
     481            }
     482
     483            if ( $blog['archived'] == '1' ) {
     484                $actions['unarchive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unarchiveblog&amp;id=' . $blog['blog_id'] ), 'unarchiveblog_' . $blog['blog_id'] ) ) . '">' . __( 'Unarchive' ) . '</a></span>';
     485            } else {
     486                $actions['archive']   = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=archiveblog&amp;id=' . $blog['blog_id'] ), 'archiveblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a></span>';
     487            }
     488
     489            if ( $blog['spam'] == '1' ) {
     490                $actions['unspam'] = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=unspamblog&amp;id=' . $blog['blog_id'] ), 'unspamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a></span>';
     491            } else {
     492                $actions['spam']   = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=spamblog&amp;id=' . $blog['blog_id'] ), 'spamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Spam', 'site' ) . '</a></span>';
     493            }
     494
     495            if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) {
     496                $actions['delete'] = '<span class="delete"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&amp;action2=deleteblog&amp;id=' . $blog['blog_id'] ), 'deleteblog_' . $blog['blog_id'] ) ) . '">' . __( 'Delete' ) . '</a></span>';
     497            }
     498        }
     499
     500        $actions['visit']   = "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a></span>';
     501
     502        /**
     503         * Filter the action links displayed for each site in the Sites list table.
     504         *
     505         * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by
     506         * default for each site. The site's status determines whether to show the
     507         * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and
     508         * 'Not Spam' or 'Spam' link for each site.
     509         *
     510         * @since 3.1.0
     511         *
     512         * @param array  $actions  An array of action links to be displayed.
     513         * @param int    $blog_id  The site ID.
     514         * @param string $blogname Site path, formatted depending on whether it is a sub-domain
     515         *                         or subdirectory multisite install.
     516         */
     517        $actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname );
     518        return $this->row_actions( $actions );
    572519    }
    573520}
  • trunk/src/wp-admin/includes/class-wp-ms-users-list-table.php

    r33195 r33270  
    258258
    259259    /**
     260     * @since 4.3.0
     261     * @access protected
     262     *
     263     * @param WP_User $user
     264     * @param string  $classes
     265     * @param string  $data
     266     * @param string  $primary
     267     */
     268    protected function _column_blogs( $user, $classes, $data, $primary ) {
     269        echo '<td class="', $classes, ' has-row-actions" ', $data, '>';
     270        echo $this->column_blogs( $user );
     271        echo $this->handle_row_actions( $user, 'blogs', $primary );
     272        echo '</td>';
     273    }
     274
     275    /**
    260276     * Handles the blogs/sites column output.
    261277     *
     
    336352    }
    337353
    338     /**
    339      * Handles columns output for a single row in the table.
    340      *
    341      * @since 4.3.0
    342      * @access public
    343      *
    344      * @param WP_User $item The current WP_User object.
    345      */
    346     public function single_row_columns( $item ) {
    347         list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
    348 
    349         foreach ( $columns as $column_name => $column_display_name ) {
    350             $classes = "$column_name column-$column_name";
    351             if ( $primary === $column_name || 'blogs' === $column_name ) {
    352                 $classes .= ' has-row-actions';
    353             }
    354 
    355             if ( $primary === $column_name ) {
    356                 $classes .= ' column-primary';
    357             }
    358 
    359             if ( in_array( $column_name, $hidden ) ) {
    360                 $classes .= ' hidden';
    361             }
    362 
    363             $data = 'data-colname="' . wp_strip_all_tags( $column_display_name ) . '"';
    364 
    365             $attributes = "class='$classes' $data";
    366 
    367             if ( 'cb' === $column_name ) {
    368                 echo '<th scope="row" class="check-column">';
    369 
    370                 $this->column_cb( $item );
    371 
    372                 echo '</th>';
    373             } elseif ( method_exists( $this, 'column_' . $column_name ) ) {
    374                 echo "<td $attributes>";
    375 
    376                 call_user_func( array( $this, 'column_' . $column_name ), $item );
    377 
    378                 echo $this->handle_row_actions( $item, $column_name, $primary );
    379                 echo "</td>";
    380             } else {
    381                 echo "<td $attributes>";
    382 
    383                 $this->column_default( $item, $column_name );
    384 
    385                 echo $this->handle_row_actions( $item, $column_name, $primary );
    386                 echo "</td>";
    387             }
    388         }
    389     }
    390 
    391354    public function display_rows() {
    392355        foreach ( $this->items as $user ) {
     
    433396     */
    434397    protected function handle_row_actions( $user, $column_name, $primary ) {
     398        if ( $primary !== $column_name ) {
     399            return '';
     400        }
     401
    435402        $super_admins = get_super_admins();
    436403        $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
    437404
    438         if ( $primary === $column_name ) {
    439             $actions = array();
    440             $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
    441 
    442             if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) {
    443                 $actions['delete'] = '<a href="' . $delete = esc_url( network_admin_url( add_query_arg( '_wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'users.php', 'deleteuser' ) . '&amp;action=deleteuser&amp;id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>';
    444             }
    445 
    446             /**
    447              * Filter the action links displayed under each user in the Network Admin Users list table.
    448              *
    449              * @since 3.2.0
    450              *
    451              * @param array   $actions An array of action links to be displayed.
    452              *                         Default 'Edit', 'Delete'.
    453              * @param WP_User $user    WP_User object.
    454              */
    455             $actions = apply_filters( 'ms_user_row_actions', $actions, $user );
    456             return $this->row_actions( $actions );
    457         }
     405        $actions = array();
     406        $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
     407
     408        if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) {
     409            $actions['delete'] = '<a href="' . $delete = esc_url( network_admin_url( add_query_arg( '_wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'users.php', 'deleteuser' ) . '&amp;action=deleteuser&amp;id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>';
     410        }
     411
     412        /**
     413         * Filter the action links displayed under each user in the Network Admin Users list table.
     414         *
     415         * @since 3.2.0
     416         *
     417         * @param array   $actions An array of action links to be displayed.
     418         *                         Default 'Edit', 'Delete'.
     419         * @param WP_User $user    WP_User object.
     420         */
     421        $actions = apply_filters( 'ms_user_row_actions', $actions, $user );
     422        return $this->row_actions( $actions );
    458423    }
    459424}
  • trunk/src/wp-admin/includes/class-wp-posts-list-table.php

    r33266 r33270  
    696696            <div class="locked-indicator"></div>
    697697        <?php endif;
     698    }
     699
     700    /**
     701     * @since 4.3.0
     702     * @access protected
     703     *
     704     * @param WP_Post $post
     705     * @param string  $classes
     706     * @param string  $data
     707     * @param string  $primary
     708     */
     709    protected function _column_title( $post, $classes, $data, $primary ) {
     710        echo '<td class="' . $classes . ' page-title" ', $data, '>';
     711        echo $this->column_title( $post );
     712        echo $this->handle_row_actions( $post, 'title', $primary );
     713        echo '</td>';
    698714    }
    699715
     
    974990
    975991    /**
    976      * Handles columns output for a single row in the table.
    977      *
    978      * @since 4.3.0
    979      * @access public
    980      *
    981      * @param WP_Post $item The current WP_Post object.
    982      */
    983     public function single_row_columns( $item ) {
    984         list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
    985 
    986         foreach ( $columns as $column_name => $column_display_name ) {
    987             $classes = "$column_name column-$column_name";
    988             if ( $primary === $column_name ) {
    989                 $classes .= ' has-row-actions column-primary';
    990             }
    991 
    992             if ( 'title' === $column_name ) {
    993                 $classes .= ' page-title'; // Special addition for title column
    994             }
    995 
    996             if ( in_array( $column_name, $hidden ) ) {
    997                 $classes .= ' hidden';
    998             }
    999 
    1000             // Comments column uses HTML in the display name with screen reader text.
    1001             // Instead of using esc_attr(), we strip tags to get closer to a user-friendly string.
    1002             $data = 'data-colname="' . wp_strip_all_tags( $column_display_name ) . '"';
    1003 
    1004             $attributes = "class='$classes' $data";
    1005 
    1006             if ( 'cb' === $column_name ) {
    1007                 echo '<th scope="row" class="check-column">';
    1008 
    1009                 $this->column_cb( $item );
    1010 
    1011                 echo '</th>';
    1012             } else {
    1013                 echo "<td $attributes>";
    1014 
    1015                 if ( method_exists( $this, 'column_' . $column_name ) ) {
    1016                     call_user_func( array( $this, 'column_' . $column_name ), $item );
    1017                 } else {
    1018                     $this->column_default( $item, $column_name );
    1019                 }
    1020 
    1021                 echo $this->handle_row_actions( $item, $column_name, $primary );
    1022                 echo '</td>';
    1023             }
    1024         }
    1025     }
    1026 
    1027     /**
    1028992     * @global WP_Post $post
    1029993     *
     
    10851049     */
    10861050    protected function handle_row_actions( $post, $column_name, $primary ) {
    1087         $title = _draft_or_post_title();
    1088 
    1089         if ( $primary === $column_name ) {
    1090             $post_type_object = get_post_type_object( $post->post_type );
    1091             $can_edit_post = current_user_can( 'edit_post', $post->ID );
    1092             $actions = array();
    1093 
    1094             if ( $can_edit_post && 'trash' != $post->post_status ) {
    1095                 $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . esc_attr__( 'Edit this item' ) . '">' . __( 'Edit' ) . '</a>';
    1096                 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr__( 'Edit this item inline' ) . '">' . __( 'Quick&nbsp;Edit' ) . '</a>';
     1051        if ( $primary !== $column_name ) {
     1052            return '';
     1053        }
     1054
     1055        $post_type_object = get_post_type_object( $post->post_type );
     1056        $can_edit_post = current_user_can( 'edit_post', $post->ID );
     1057        $actions = array();
     1058
     1059        if ( $can_edit_post && 'trash' != $post->post_status ) {
     1060            $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . esc_attr__( 'Edit this item' ) . '">' . __( 'Edit' ) . '</a>';
     1061            $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr__( 'Edit this item inline' ) . '">' . __( 'Quick&nbsp;Edit' ) . '</a>';
     1062        }
     1063
     1064        if ( current_user_can( 'delete_post', $post->ID ) ) {
     1065            if ( 'trash' == $post->post_status )
     1066                $actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash' ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
     1067            elseif ( EMPTY_TRASH_DAYS )
     1068                $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash' ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
     1069            if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
     1070                $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently' ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
     1071        }
     1072
     1073        if ( $post_type_object->public ) {
     1074            $title = _draft_or_post_title();
     1075            if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
     1076                if ( $can_edit_post ) {
     1077                    $preview_link = set_url_scheme( get_permalink( $post->ID ) );
     1078                    /** This filter is documented in wp-admin/includes/meta-boxes.php */
     1079                    $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post );
     1080                    $actions['view'] = '<a href="' . esc_url( $preview_link ) . '" title="' . esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
     1081                }
     1082            } elseif ( 'trash' != $post->post_status ) {
     1083                $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
    10971084            }
    1098 
    1099             if ( current_user_can( 'delete_post', $post->ID ) ) {
    1100                 if ( 'trash' == $post->post_status )
    1101                     $actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash' ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
    1102                 elseif ( EMPTY_TRASH_DAYS )
    1103                     $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash' ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
    1104                 if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
    1105                     $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently' ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
    1106             }
    1107 
    1108             if ( $post_type_object->public ) {
    1109                 if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
    1110                     if ( $can_edit_post ) {
    1111                         $preview_link = set_url_scheme( get_permalink( $post->ID ) );
    1112                         /** This filter is documented in wp-admin/includes/meta-boxes.php */
    1113                         $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post );
    1114                         $actions['view'] = '<a href="' . esc_url( $preview_link ) . '" title="' . esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
    1115                     }
    1116                 } elseif ( 'trash' != $post->post_status ) {
    1117                     $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
    1118                 }
    1119             }
    1120 
    1121             if ( is_post_type_hierarchical( $post->post_type ) ) {
    1122 
    1123                 /**
    1124                  * Filter the array of row action links on the Pages list table.
    1125                  *
    1126                  * The filter is evaluated only for hierarchical post types.
    1127                  *
    1128                  * @since 2.8.0
    1129                  *
    1130                  * @param array $actions An array of row action links. Defaults are
    1131                  *                         'Edit', 'Quick Edit', 'Restore, 'Trash',
    1132                  *                         'Delete Permanently', 'Preview', and 'View'.
    1133                  * @param WP_Post $post The post object.
    1134                  */
    1135                 $actions = apply_filters( 'page_row_actions', $actions, $post );
    1136             } else {
    1137 
    1138                 /**
    1139                  * Filter the array of row action links on the Posts list table.
    1140                  *
    1141                  * The filter is evaluated only for non-hierarchical post types.
    1142                  *
    1143                  * @since 2.8.0
    1144                  *
    1145                  * @param array $actions An array of row action links. Defaults are
    1146                  *                         'Edit', 'Quick Edit', 'Restore, 'Trash',
    1147                  *                         'Delete Permanently', 'Preview', and 'View'.
    1148                  * @param WP_Post $post The post object.
    1149                  */
    1150                 $actions = apply_filters( 'post_row_actions', $actions, $post );
    1151             }
    1152 
    1153             return $this->row_actions( $actions );
    1154         }
     1085        }
     1086
     1087        if ( is_post_type_hierarchical( $post->post_type ) ) {
     1088
     1089            /**
     1090             * Filter the array of row action links on the Pages list table.
     1091             *
     1092             * The filter is evaluated only for hierarchical post types.
     1093             *
     1094             * @since 2.8.0
     1095             *
     1096             * @param array $actions An array of row action links. Defaults are
     1097             *                         'Edit', 'Quick Edit', 'Restore, 'Trash',
     1098             *                         'Delete Permanently', 'Preview', and 'View'.
     1099             * @param WP_Post $post The post object.
     1100             */
     1101            $actions = apply_filters( 'page_row_actions', $actions, $post );
     1102        } else {
     1103
     1104            /**
     1105             * Filter the array of row action links on the Posts list table.
     1106             *
     1107             * The filter is evaluated only for non-hierarchical post types.
     1108             *
     1109             * @since 2.8.0
     1110             *
     1111             * @param array $actions An array of row action links. Defaults are
     1112             *                         'Edit', 'Quick Edit', 'Restore, 'Trash',
     1113             *                         'Delete Permanently', 'Preview', and 'View'.
     1114             * @param WP_Post $post The post object.
     1115             */
     1116            $actions = apply_filters( 'post_row_actions', $actions, $post );
     1117        }
     1118
     1119        return $this->row_actions( $actions );
    11551120    }
    11561121
  • 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.