diff --git a/wp-admin/includes/default-list-tables.php b/wp-admin/includes/default-list-tables.php
index 85a6f68c30..973fe3de35 100644
--- a/wp-admin/includes/default-list-tables.php
+++ b/wp-admin/includes/default-list-tables.php
@@ -455,15 +455,7 @@ class WP_Posts_Table extends WP_List_Table {
}
$actions = apply_filters( $this->hierarchical_display ? 'page_row_actions' : 'post_row_actions', $actions, $post );
- $action_count = count( $actions );
- $i = 0;
- echo '
';
- foreach ( $actions as $action => $link ) {
- ++$i;
- ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
- echo "$link$sep ";
- }
- echo '
';
+ echo $this->row_actions( $actions );
get_inline_data( $post );
break;
@@ -1115,14 +1107,7 @@ foreach ( $columns as $column_name => $column_display_name ) {
$actions['view'] = '' . __( 'View' ) . ' ';
}
$actions = apply_filters( 'media_row_actions', $actions, $post );
- $action_count = count( $actions );
- $i = 0;
- echo '';
- foreach ( $actions as $action => $link ) {
- $sep = ( ++$i == $action_count ) ? '' : ' | ';
- echo "$link$sep ";
- }
- echo '
';
+ echo $this->row_actions( $actions );
?>
$column_display_name ) {
else
echo strtoupper( str_replace( 'image/', '', get_post_mime_type() ) );
?>
-
ID ) )
@@ -1285,14 +1269,8 @@ foreach ( $columns as $column_name => $column_display_name ) {
$actions['attach'] = '
'.__( 'Attach' ).' ';
$actions = apply_filters( 'media_row_actions', $actions, $post );
- $action_count = count( $actions );
- $i = 0;
- foreach ( $actions as $action => $link ) {
- $sep = ( ++$i == $action_count ) ? '' : ' | ';
- echo "
$link$sep ";
- }
+ echo $this->row_actions( $actions );
?>
-
post_author ); echo $author->display_name; ?>
@@ -1564,6 +1542,7 @@ class WP_Terms_Table extends WP_List_Table {
break;
case 'name':
$out .= ' ' . $name . ' ';
+
$actions = array();
if ( current_user_can( $tax->cap->edit_terms ) ) {
$actions['edit'] = '' . __( 'Edit' ) . ' ';
@@ -1575,15 +1554,7 @@ class WP_Terms_Table extends WP_List_Table {
$actions = apply_filters( 'tag_row_actions', $actions, $tag );
$actions = apply_filters( "${taxonomy}_row_actions", $actions, $tag );
- $action_count = count( $actions );
- $i = 0;
- $out .= '';
- foreach ( $actions as $action => $link ) {
- ++$i;
- ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
- $out .= "$link$sep ";
- }
- $out .= '
';
+ $out .= $this->row_actions( $actions );
$out .= '';
$out .= '
' . $qe_data->name . '
';
$out .= '
' . apply_filters( 'editable_slug', $qe_data->slug ) . '
';
@@ -1844,15 +1815,7 @@ class WP_Users_Table extends WP_List_Table {
if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'remove_user', $user_object->ID ) )
$actions['remove'] = "
" . __( 'Remove' ) . " ";
$actions = apply_filters( 'user_row_actions', $actions, $user_object );
- $action_count = count( $actions );
- $i = 0;
- $edit .= '
';
- foreach ( $actions as $action => $link ) {
- ++$i;
- ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
- $edit .= "$link$sep ";
- }
- $edit .= '
';
+ $edit .= $this->row_actions( $actions );
// Set up the checkbox ( because the user is editable, otherwise its empty )
$checkbox = "
";
@@ -2460,18 +2423,12 @@ class WP_Links_Table extends WP_List_Table {
case 'name':
echo "
link_name ) ) . "'>$link->link_name ";
+
$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' ) . " ";
- $action_count = count( $actions );
- $i = 0;
- echo '';
- foreach ( $actions as $action => $linkaction ) {
- ++$i;
- ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
- echo "$linkaction$sep ";
- }
- echo '
';
+ echo $this->row_actions( $actions );
+
echo '';
break;
case 'url':
@@ -2727,11 +2684,8 @@ class WP_Sites_Table extends WP_List_Table {
$actions['visit'] = "
" . __( 'Visit' ) . ' ';
$actions = array_filter( $actions );
- if ( count( $actions ) ) : ?>
-
-
-
-
+ echo $this->row_actions( $actions );
+ ?>
-
-
-
- |
-
+ ' . __( 'Edit' ) . '';
+
+ if ( ! in_array( $user['user_login'], $super_admins ) ) {
+ $actions['delete'] = '
' . __( 'Delete' ) . ' ';
+ }
+
+ echo $this->row_actions( $actions );
+ ?>
\n";
}
+ /**
+ * Generate row actions div
+ *
+ * @since 3.1.0
+ * @access protected
+ *
+ * @param array $actions The list of actions
+ * @return string
+ */
+ function row_actions( $actions ) {
+ $action_count = count( $actions );
+ $i = 0;
+
+ if ( !$action_count )
+ return '';
+
+ $out = '';
+ foreach ( $actions as $action => $link ) {
+ ++$i;
+ ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
+ $out .= "$link$sep ";
+ }
+ $out .= '
';
+
+ return $out;
+ }
+
/**
* Display a monthly dropdown for filtering items
*