From aee18d2d3857936873c7ff3bf9ff5e01ae07ef48 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 14 Jul 2015 17:46:13 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@33270 602fd350-edb4-49c9-b593-d223f7449a82 --- .../includes/class-wp-comments-list-table.php | 8 +- .../includes/class-wp-links-list-table.php | 16 +- src/wp-admin/includes/class-wp-list-table.php | 14 +- .../includes/class-wp-media-list-table.php | 8 +- .../includes/class-wp-ms-sites-list-table.php | 161 +++++--------- .../includes/class-wp-ms-users-list-table.php | 107 ++++----- .../includes/class-wp-posts-list-table.php | 203 ++++++++---------- .../includes/class-wp-terms-list-table.php | 76 +++---- 8 files changed, 241 insertions(+), 352 deletions(-) diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php index 9922d6ca00..93ff8713ff 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -462,14 +462,14 @@ class WP_Comments_List_Table extends WP_List_Table { protected function handle_row_actions( $comment, $column_name, $primary ) { global $comment_status; - if ( ! $this->user_can ) { - return; - } - if ( $primary !== $column_name ) { return ''; } + if ( ! $this->user_can ) { + return; + } + $post = get_post(); $the_comment_status = wp_get_comment_status( $comment->comment_ID ); diff --git a/src/wp-admin/includes/class-wp-links-list-table.php b/src/wp-admin/includes/class-wp-links-list-table.php index d86b5a0e4d..9b917d1db4 100644 --- a/src/wp-admin/includes/class-wp-links-list-table.php +++ b/src/wp-admin/includes/class-wp-links-list-table.php @@ -310,13 +310,15 @@ class WP_Links_List_Table extends WP_List_Table { * @return string Row action output for links. */ protected function handle_row_actions( $link, $column_name, $primary ) { - if ( $primary === $column_name ) { - $edit_link = get_edit_bookmark_link( $link ); - - $actions = array(); - $actions['edit'] = '' . __('Edit') . ''; - $actions['delete'] = "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') . ""; - return $this->row_actions($actions); + if ( $primary !== $column_name ) { + return ''; } + + $edit_link = get_edit_bookmark_link( $link ); + + $actions = array(); + $actions['edit'] = '' . __('Edit') . ''; + $actions['delete'] = "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') . ""; + return $this->row_actions( $actions ); } } diff --git a/src/wp-admin/includes/class-wp-list-table.php b/src/wp-admin/includes/class-wp-list-table.php index e7a7855e8a..2dd437a185 100644 --- a/src/wp-admin/includes/class-wp-list-table.php +++ b/src/wp-admin/includes/class-wp-list-table.php @@ -1224,14 +1224,20 @@ class WP_List_Table { echo ''; echo $this->column_cb( $item ); echo ''; - } - elseif ( method_exists( $this, 'column_' . $column_name ) ) { + } elseif ( method_exists( $this, '_column_' . $column_name ) ) { + echo call_user_func( + array( $this, '_column_' . $column_name ), + $item, + $classes, + $data, + $primary + ); + } elseif ( method_exists( $this, 'column_' . $column_name ) ) { echo ""; echo call_user_func( array( $this, 'column_' . $column_name ), $item ); echo $this->handle_row_actions( $item, $column_name, $primary ); echo ""; - } - else { + } else { echo ""; echo $this->column_default( $item, $column_name ); echo $this->handle_row_actions( $item, $column_name, $primary ); diff --git a/src/wp-admin/includes/class-wp-media-list-table.php b/src/wp-admin/includes/class-wp-media-list-table.php index 04a043822a..9c61fc28ef 100644 --- a/src/wp-admin/includes/class-wp-media-list-table.php +++ b/src/wp-admin/includes/class-wp-media-list-table.php @@ -647,9 +647,11 @@ class WP_Media_List_Table extends WP_List_Table { * @return string Row actions output for media attachments. */ protected function handle_row_actions( $post, $column_name, $primary ) { - if ( $primary === $column_name ) { - $att_title = _draft_or_post_title(); - return $this->row_actions( $this->_get_row_actions( $post, $att_title ) ); + if ( $primary !== $column_name ) { + return ''; } + + $att_title = _draft_or_post_title(); + return $this->row_actions( $this->_get_row_actions( $post, $att_title ) ); } } diff --git a/src/wp-admin/includes/class-wp-ms-sites-list-table.php b/src/wp-admin/includes/class-wp-ms-sites-list-table.php index 24b08ebc89..9fe3f482d4 100644 --- a/src/wp-admin/includes/class-wp-ms-sites-list-table.php +++ b/src/wp-admin/includes/class-wp-ms-sites-list-table.php @@ -408,61 +408,6 @@ class WP_MS_Sites_List_Table extends WP_List_Table { do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] ); } - /** - * Handles columns output for a single row. - * - * @since 4.3.0 - * @access public - * - * @param array $item Current site. - */ - public function single_row_columns( $item ) { - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); - - foreach ( $columns as $column_name => $column_display_name ) { - $classes = "$column_name column-$column_name"; - if ( $primary === $column_name ) { - $classes .= ' has-row-actions column-primary'; - } - - if ( in_array( $column_name, $hidden ) ) { - $classes .= ' hidden'; - } - - $data = 'data-colname="' . wp_strip_all_tags( $column_display_name ) . '"'; - - $attributes = "class='$classes' $data"; - - if ( 'cb' === $column_name ) { - echo ''; - - $this->column_cb( $item ); - - echo ''; - } elseif ( 'id' === $column_name ) { -?> - - - -"; - - echo call_user_func( array( $this, 'column_' . $column_name ), $item ); - - echo $this->handle_row_actions( $item, $column_name, $primary ); - echo ""; - } else { - echo ""; - - echo $this->column_default( $item, $column_name ); - - echo $this->handle_row_actions( $item, $column_name, $primary ); - echo ""; - } - } - } - /** * * @global string $mode @@ -510,64 +455,66 @@ class WP_MS_Sites_List_Table extends WP_List_Table { * @return string Row actions output. */ protected function handle_row_actions( $blog, $column_name, $primary ) { - if ( $primary === $column_name ) { - $blogname = untrailingslashit( $blog['domain'] . $blog['path'] ); + if ( $primary !== $column_name ) { + return; + } - // Preordered. - $actions = array( - 'edit' => '', 'backend' => '', - 'activate' => '', 'deactivate' => '', - 'archive' => '', 'unarchive' => '', - 'spam' => '', 'unspam' => '', - 'delete' => '', - 'visit' => '', - ); + $blogname = untrailingslashit( $blog['domain'] . $blog['path'] ); - $actions['edit'] = '' . __( 'Edit' ) . ''; - $actions['backend'] = "" . __( 'Dashboard' ) . ''; - if ( get_current_site()->blog_id != $blog['blog_id'] ) { - if ( $blog['deleted'] == '1' ) { - $actions['activate'] = '' . __( 'Activate' ) . ''; - } else { - $actions['deactivate'] = '' . __( 'Deactivate' ) . ''; - } + // Preordered. + $actions = array( + 'edit' => '', 'backend' => '', + 'activate' => '', 'deactivate' => '', + 'archive' => '', 'unarchive' => '', + 'spam' => '', 'unspam' => '', + 'delete' => '', + 'visit' => '', + ); - if ( $blog['archived'] == '1' ) { - $actions['unarchive'] = '' . __( 'Unarchive' ) . ''; - } else { - $actions['archive'] = '' . _x( 'Archive', 'verb; site' ) . ''; - } - - if ( $blog['spam'] == '1' ) { - $actions['unspam'] = '' . _x( 'Not Spam', 'site' ) . ''; - } else { - $actions['spam'] = '' . _x( 'Spam', 'site' ) . ''; - } - - if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) { - $actions['delete'] = '' . __( 'Delete' ) . ''; - } + $actions['edit'] = '' . __( 'Edit' ) . ''; + $actions['backend'] = "" . __( 'Dashboard' ) . ''; + if ( get_current_site()->blog_id != $blog['blog_id'] ) { + if ( $blog['deleted'] == '1' ) { + $actions['activate'] = '' . __( 'Activate' ) . ''; + } else { + $actions['deactivate'] = '' . __( 'Deactivate' ) . ''; } - $actions['visit'] = "" . __( 'Visit' ) . ''; + if ( $blog['archived'] == '1' ) { + $actions['unarchive'] = '' . __( 'Unarchive' ) . ''; + } else { + $actions['archive'] = '' . _x( 'Archive', 'verb; site' ) . ''; + } - /** - * Filter the action links displayed for each site in the Sites list table. - * - * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by - * default for each site. The site's status determines whether to show the - * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and - * 'Not Spam' or 'Spam' link for each site. - * - * @since 3.1.0 - * - * @param array $actions An array of action links to be displayed. - * @param int $blog_id The site ID. - * @param string $blogname Site path, formatted depending on whether it is a sub-domain - * or subdirectory multisite install. - */ - $actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname ); - return $this->row_actions( $actions ); + if ( $blog['spam'] == '1' ) { + $actions['unspam'] = '' . _x( 'Not Spam', 'site' ) . ''; + } else { + $actions['spam'] = '' . _x( 'Spam', 'site' ) . ''; + } + + if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) { + $actions['delete'] = '' . __( 'Delete' ) . ''; + } } + + $actions['visit'] = "" . __( 'Visit' ) . ''; + + /** + * Filter the action links displayed for each site in the Sites list table. + * + * The 'Edit', 'Dashboard', 'Delete', and 'Visit' links are displayed by + * default for each site. The site's status determines whether to show the + * 'Activate' or 'Deactivate' link, 'Unarchive' or 'Archive' links, and + * 'Not Spam' or 'Spam' link for each site. + * + * @since 3.1.0 + * + * @param array $actions An array of action links to be displayed. + * @param int $blog_id The site ID. + * @param string $blogname Site path, formatted depending on whether it is a sub-domain + * or subdirectory multisite install. + */ + $actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname ); + return $this->row_actions( $actions ); } } diff --git a/src/wp-admin/includes/class-wp-ms-users-list-table.php b/src/wp-admin/includes/class-wp-ms-users-list-table.php index e09ff72ab0..39dadc788a 100644 --- a/src/wp-admin/includes/class-wp-ms-users-list-table.php +++ b/src/wp-admin/includes/class-wp-ms-users-list-table.php @@ -256,6 +256,22 @@ class WP_MS_Users_List_Table extends WP_List_Table { echo mysql2date( $date, $user->user_registered ); } + /** + * @since 4.3.0 + * @access protected + * + * @param WP_User $user + * @param string $classes + * @param string $data + * @param string $primary + */ + protected function _column_blogs( $user, $classes, $data, $primary ) { + echo ''; + echo $this->column_blogs( $user ); + echo $this->handle_row_actions( $user, 'blogs', $primary ); + echo ''; + } + /** * Handles the blogs/sites column output. * @@ -335,59 +351,6 @@ class WP_MS_Users_List_Table extends WP_List_Table { echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID ); } - /** - * Handles columns output for a single row in the table. - * - * @since 4.3.0 - * @access public - * - * @param WP_User $item The current WP_User object. - */ - public function single_row_columns( $item ) { - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); - - foreach ( $columns as $column_name => $column_display_name ) { - $classes = "$column_name column-$column_name"; - if ( $primary === $column_name || 'blogs' === $column_name ) { - $classes .= ' has-row-actions'; - } - - if ( $primary === $column_name ) { - $classes .= ' column-primary'; - } - - if ( in_array( $column_name, $hidden ) ) { - $classes .= ' hidden'; - } - - $data = 'data-colname="' . wp_strip_all_tags( $column_display_name ) . '"'; - - $attributes = "class='$classes' $data"; - - if ( 'cb' === $column_name ) { - echo ''; - - $this->column_cb( $item ); - - echo ''; - } elseif ( method_exists( $this, 'column_' . $column_name ) ) { - echo ""; - - call_user_func( array( $this, 'column_' . $column_name ), $item ); - - echo $this->handle_row_actions( $item, $column_name, $primary ); - echo ""; - } else { - echo ""; - - $this->column_default( $item, $column_name ); - - echo $this->handle_row_actions( $item, $column_name, $primary ); - echo ""; - } - } - } - public function display_rows() { foreach ( $this->items as $user ) { $class = ''; @@ -432,28 +395,30 @@ class WP_MS_Users_List_Table extends WP_List_Table { * @return string Row actions output for users in Multisite. */ protected function handle_row_actions( $user, $column_name, $primary ) { + if ( $primary !== $column_name ) { + return ''; + } + $super_admins = get_super_admins(); $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) ); - if ( $primary === $column_name ) { - $actions = array(); - $actions['edit'] = '' . __( 'Edit' ) . ''; + $actions = array(); + $actions['edit'] = '' . __( 'Edit' ) . ''; - if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) { - $actions['delete'] = '' . __( 'Delete' ) . ''; - } - - /** - * Filter the action links displayed under each user in the Network Admin Users list table. - * - * @since 3.2.0 - * - * @param array $actions An array of action links to be displayed. - * Default 'Edit', 'Delete'. - * @param WP_User $user WP_User object. - */ - $actions = apply_filters( 'ms_user_row_actions', $actions, $user ); - return $this->row_actions( $actions ); + if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) { + $actions['delete'] = '' . __( 'Delete' ) . ''; } + + /** + * Filter the action links displayed under each user in the Network Admin Users list table. + * + * @since 3.2.0 + * + * @param array $actions An array of action links to be displayed. + * Default 'Edit', 'Delete'. + * @param WP_User $user WP_User object. + */ + $actions = apply_filters( 'ms_user_row_actions', $actions, $user ); + return $this->row_actions( $actions ); } } diff --git a/src/wp-admin/includes/class-wp-posts-list-table.php b/src/wp-admin/includes/class-wp-posts-list-table.php index 571ad8a54e..04639347d2 100644 --- a/src/wp-admin/includes/class-wp-posts-list-table.php +++ b/src/wp-admin/includes/class-wp-posts-list-table.php @@ -697,6 +697,22 @@ class WP_Posts_List_Table extends WP_List_Table { '; + echo $this->column_title( $post ); + echo $this->handle_row_actions( $post, 'title', $primary ); + echo ''; + } + /** * Handles the title column output. * @@ -972,58 +988,6 @@ class WP_Posts_List_Table extends WP_List_Table { do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID ); } - /** - * Handles columns output for a single row in the table. - * - * @since 4.3.0 - * @access public - * - * @param WP_Post $item The current WP_Post object. - */ - public function single_row_columns( $item ) { - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); - - foreach ( $columns as $column_name => $column_display_name ) { - $classes = "$column_name column-$column_name"; - if ( $primary === $column_name ) { - $classes .= ' has-row-actions column-primary'; - } - - if ( 'title' === $column_name ) { - $classes .= ' page-title'; // Special addition for title column - } - - if ( in_array( $column_name, $hidden ) ) { - $classes .= ' hidden'; - } - - // Comments column uses HTML in the display name with screen reader text. - // Instead of using esc_attr(), we strip tags to get closer to a user-friendly string. - $data = 'data-colname="' . wp_strip_all_tags( $column_display_name ) . '"'; - - $attributes = "class='$classes' $data"; - - if ( 'cb' === $column_name ) { - echo ''; - - $this->column_cb( $item ); - - echo ''; - } else { - echo ""; - - if ( method_exists( $this, 'column_' . $column_name ) ) { - call_user_func( array( $this, 'column_' . $column_name ), $item ); - } else { - $this->column_default( $item, $column_name ); - } - - echo $this->handle_row_actions( $item, $column_name, $primary ); - echo ''; - } - } - } - /** * @global WP_Post $post * @@ -1084,74 +1048,75 @@ class WP_Posts_List_Table extends WP_List_Table { * @return string Row actions output for posts. */ protected function handle_row_actions( $post, $column_name, $primary ) { - $title = _draft_or_post_title(); - - if ( $primary === $column_name ) { - $post_type_object = get_post_type_object( $post->post_type ); - $can_edit_post = current_user_can( 'edit_post', $post->ID ); - $actions = array(); - - if ( $can_edit_post && 'trash' != $post->post_status ) { - $actions['edit'] = '' . __( 'Edit' ) . ''; - $actions['inline hide-if-no-js'] = '' . __( 'Quick Edit' ) . ''; - } - - if ( current_user_can( 'delete_post', $post->ID ) ) { - if ( 'trash' == $post->post_status ) - $actions['untrash'] = "ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . ""; - elseif ( EMPTY_TRASH_DAYS ) - $actions['trash'] = "" . __( 'Trash' ) . ""; - if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS ) - $actions['delete'] = "" . __( 'Delete Permanently' ) . ""; - } - - if ( $post_type_object->public ) { - if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) { - if ( $can_edit_post ) { - $preview_link = set_url_scheme( get_permalink( $post->ID ) ); - /** This filter is documented in wp-admin/includes/meta-boxes.php */ - $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post ); - $actions['view'] = '' . __( 'Preview' ) . ''; - } - } elseif ( 'trash' != $post->post_status ) { - $actions['view'] = '' . __( 'View' ) . ''; - } - } - - if ( is_post_type_hierarchical( $post->post_type ) ) { - - /** - * Filter the array of row action links on the Pages list table. - * - * The filter is evaluated only for hierarchical post types. - * - * @since 2.8.0 - * - * @param array $actions An array of row action links. Defaults are - * 'Edit', 'Quick Edit', 'Restore, 'Trash', - * 'Delete Permanently', 'Preview', and 'View'. - * @param WP_Post $post The post object. - */ - $actions = apply_filters( 'page_row_actions', $actions, $post ); - } else { - - /** - * Filter the array of row action links on the Posts list table. - * - * The filter is evaluated only for non-hierarchical post types. - * - * @since 2.8.0 - * - * @param array $actions An array of row action links. Defaults are - * 'Edit', 'Quick Edit', 'Restore, 'Trash', - * 'Delete Permanently', 'Preview', and 'View'. - * @param WP_Post $post The post object. - */ - $actions = apply_filters( 'post_row_actions', $actions, $post ); - } - - return $this->row_actions( $actions ); + if ( $primary !== $column_name ) { + return ''; } + + $post_type_object = get_post_type_object( $post->post_type ); + $can_edit_post = current_user_can( 'edit_post', $post->ID ); + $actions = array(); + + if ( $can_edit_post && 'trash' != $post->post_status ) { + $actions['edit'] = '' . __( 'Edit' ) . ''; + $actions['inline hide-if-no-js'] = '' . __( 'Quick Edit' ) . ''; + } + + if ( current_user_can( 'delete_post', $post->ID ) ) { + if ( 'trash' == $post->post_status ) + $actions['untrash'] = "ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . ""; + elseif ( EMPTY_TRASH_DAYS ) + $actions['trash'] = "" . __( 'Trash' ) . ""; + if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS ) + $actions['delete'] = "" . __( 'Delete Permanently' ) . ""; + } + + if ( $post_type_object->public ) { + $title = _draft_or_post_title(); + if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) { + if ( $can_edit_post ) { + $preview_link = set_url_scheme( get_permalink( $post->ID ) ); + /** This filter is documented in wp-admin/includes/meta-boxes.php */ + $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post ); + $actions['view'] = '' . __( 'Preview' ) . ''; + } + } elseif ( 'trash' != $post->post_status ) { + $actions['view'] = '' . __( 'View' ) . ''; + } + } + + if ( is_post_type_hierarchical( $post->post_type ) ) { + + /** + * Filter the array of row action links on the Pages list table. + * + * The filter is evaluated only for hierarchical post types. + * + * @since 2.8.0 + * + * @param array $actions An array of row action links. Defaults are + * 'Edit', 'Quick Edit', 'Restore, 'Trash', + * 'Delete Permanently', 'Preview', and 'View'. + * @param WP_Post $post The post object. + */ + $actions = apply_filters( 'page_row_actions', $actions, $post ); + } else { + + /** + * Filter the array of row action links on the Posts list table. + * + * The filter is evaluated only for non-hierarchical post types. + * + * @since 2.8.0 + * + * @param array $actions An array of row action links. Defaults are + * 'Edit', 'Quick Edit', 'Restore, 'Trash', + * 'Delete Permanently', 'Preview', and 'View'. + * @param WP_Post $post The post object. + */ + $actions = apply_filters( 'post_row_actions', $actions, $post ); + } + + return $this->row_actions( $actions ); } /** diff --git a/src/wp-admin/includes/class-wp-terms-list-table.php b/src/wp-admin/includes/class-wp-terms-list-table.php index b6f843282e..a4c81afbe7 100644 --- a/src/wp-admin/includes/class-wp-terms-list-table.php +++ b/src/wp-admin/includes/class-wp-terms-list-table.php @@ -396,50 +396,52 @@ class WP_Terms_List_Table extends WP_List_Table { * @return string Row actions output for terms. */ protected function handle_row_actions( $tag, $column_name, $primary ) { + if ( $primary !== $column_name ) { + return ''; + } + $taxonomy = $this->screen->taxonomy; $tax = get_taxonomy( $taxonomy ); $default_term = get_option( 'default_' . $taxonomy ); $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) ); - if ( $primary === $column_name ) { - $actions = array(); - if ( current_user_can( $tax->cap->edit_terms ) ) { - $actions['edit'] = '' . __( 'Edit' ) . ''; - $actions['inline hide-if-no-js'] = '' . __( 'Quick Edit' ) . ''; - } - if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term ) - $actions['delete'] = "term_id ) . "'>" . __( 'Delete' ) . ""; - if ( $tax->public ) - $actions['view'] = '' . __( 'View' ) . ''; - - /** - * Filter the action links displayed for each term in the Tags list table. - * - * @since 2.8.0 - * @deprecated 3.0.0 Use {$taxonomy}_row_actions instead. - * - * @param array $actions An array of action links to be displayed. Default - * 'Edit', 'Quick Edit', 'Delete', and 'View'. - * @param object $tag Term object. - */ - $actions = apply_filters( 'tag_row_actions', $actions, $tag ); - - /** - * Filter the action links displayed for each term in the terms list table. - * - * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. - * - * @since 3.0.0 - * - * @param array $actions An array of action links to be displayed. Default - * 'Edit', 'Quick Edit', 'Delete', and 'View'. - * @param object $tag Term object. - */ - $actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag ); - - return $this->row_actions( $actions ); + $actions = array(); + if ( current_user_can( $tax->cap->edit_terms ) ) { + $actions['edit'] = '' . __( 'Edit' ) . ''; + $actions['inline hide-if-no-js'] = '' . __( 'Quick Edit' ) . ''; } + if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term ) + $actions['delete'] = "term_id ) . "'>" . __( 'Delete' ) . ""; + if ( $tax->public ) + $actions['view'] = '' . __( 'View' ) . ''; + + /** + * Filter the action links displayed for each term in the Tags list table. + * + * @since 2.8.0 + * @deprecated 3.0.0 Use {$taxonomy}_row_actions instead. + * + * @param array $actions An array of action links to be displayed. Default + * 'Edit', 'Quick Edit', 'Delete', and 'View'. + * @param object $tag Term object. + */ + $actions = apply_filters( 'tag_row_actions', $actions, $tag ); + + /** + * Filter the action links displayed for each term in the terms list table. + * + * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. + * + * @since 3.0.0 + * + * @param array $actions An array of action links to be displayed. Default + * 'Edit', 'Quick Edit', 'Delete', and 'View'. + * @param object $tag Term object. + */ + $actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag ); + + return $this->row_actions( $actions ); } /**