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. Built from https://develop.svn.wordpress.org/trunk@33270 git-svn-id: http://core.svn.wordpress.org/trunk@33242 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4f94d3a969
commit
4d34e37311
|
@ -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 );
|
||||
|
|
|
@ -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'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
|
||||
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&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>";
|
||||
return $this->row_actions($actions);
|
||||
if ( $primary !== $column_name ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$edit_link = get_edit_bookmark_link( $link );
|
||||
|
||||
$actions = array();
|
||||
$actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
|
||||
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&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>";
|
||||
return $this->row_actions( $actions );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1224,14 +1224,20 @@ class WP_List_Table {
|
|||
echo '<th scope="row" class="check-column">';
|
||||
echo $this->column_cb( $item );
|
||||
echo '</th>';
|
||||
}
|
||||
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 "<td $attributes>";
|
||||
echo call_user_func( array( $this, 'column_' . $column_name ), $item );
|
||||
echo $this->handle_row_actions( $item, $column_name, $primary );
|
||||
echo "</td>";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
echo "<td $attributes>";
|
||||
echo $this->column_default( $item, $column_name );
|
||||
echo $this->handle_row_actions( $item, $column_name, $primary );
|
||||
|
|
|
@ -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 ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 '<th scope="row" class="check-column">';
|
||||
|
||||
$this->column_cb( $item );
|
||||
|
||||
echo '</th>';
|
||||
} elseif ( 'id' === $column_name ) {
|
||||
?>
|
||||
<th scope="row">
|
||||
<?php echo $item['blog_id'] ?>
|
||||
</th>
|
||||
<?php
|
||||
} elseif ( method_exists( $this, 'column_' . $column_name ) ) {
|
||||
echo "<td $attributes>";
|
||||
|
||||
echo call_user_func( array( $this, 'column_' . $column_name ), $item );
|
||||
|
||||
echo $this->handle_row_actions( $item, $column_name, $primary );
|
||||
echo "</td>";
|
||||
} else {
|
||||
echo "<td $attributes>";
|
||||
|
||||
echo $this->column_default( $item, $column_name );
|
||||
|
||||
echo $this->handle_row_actions( $item, $column_name, $primary );
|
||||
echo "</td>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @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'] = '<span class="edit"><a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>';
|
||||
$actions['backend'] = "<span class='backend'><a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a></span>';
|
||||
if ( get_current_site()->blog_id != $blog['blog_id'] ) {
|
||||
if ( $blog['deleted'] == '1' ) {
|
||||
$actions['activate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] ), 'activateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Activate' ) . '</a></span>';
|
||||
} else {
|
||||
$actions['deactivate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deactivateblog&id=' . $blog['blog_id'] ), 'deactivateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Deactivate' ) . '</a></span>';
|
||||
}
|
||||
// Preordered.
|
||||
$actions = array(
|
||||
'edit' => '', 'backend' => '',
|
||||
'activate' => '', 'deactivate' => '',
|
||||
'archive' => '', 'unarchive' => '',
|
||||
'spam' => '', 'unspam' => '',
|
||||
'delete' => '',
|
||||
'visit' => '',
|
||||
);
|
||||
|
||||
if ( $blog['archived'] == '1' ) {
|
||||
$actions['unarchive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unarchiveblog&id=' . $blog['blog_id'] ), 'unarchiveblog_' . $blog['blog_id'] ) ) . '">' . __( 'Unarchive' ) . '</a></span>';
|
||||
} else {
|
||||
$actions['archive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] ), 'archiveblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a></span>';
|
||||
}
|
||||
|
||||
if ( $blog['spam'] == '1' ) {
|
||||
$actions['unspam'] = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unspamblog&id=' . $blog['blog_id'] ), 'unspamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a></span>';
|
||||
} else {
|
||||
$actions['spam'] = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] ), 'spamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Spam', 'site' ) . '</a></span>';
|
||||
}
|
||||
|
||||
if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) {
|
||||
$actions['delete'] = '<span class="delete"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deleteblog&id=' . $blog['blog_id'] ), 'deleteblog_' . $blog['blog_id'] ) ) . '">' . __( 'Delete' ) . '</a></span>';
|
||||
}
|
||||
$actions['edit'] = '<span class="edit"><a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>';
|
||||
$actions['backend'] = "<span class='backend'><a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a></span>';
|
||||
if ( get_current_site()->blog_id != $blog['blog_id'] ) {
|
||||
if ( $blog['deleted'] == '1' ) {
|
||||
$actions['activate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] ), 'activateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Activate' ) . '</a></span>';
|
||||
} else {
|
||||
$actions['deactivate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deactivateblog&id=' . $blog['blog_id'] ), 'deactivateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Deactivate' ) . '</a></span>';
|
||||
}
|
||||
|
||||
$actions['visit'] = "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a></span>';
|
||||
if ( $blog['archived'] == '1' ) {
|
||||
$actions['unarchive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unarchiveblog&id=' . $blog['blog_id'] ), 'unarchiveblog_' . $blog['blog_id'] ) ) . '">' . __( 'Unarchive' ) . '</a></span>';
|
||||
} else {
|
||||
$actions['archive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] ), 'archiveblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a></span>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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'] = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unspamblog&id=' . $blog['blog_id'] ), 'unspamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a></span>';
|
||||
} else {
|
||||
$actions['spam'] = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] ), 'spamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Spam', 'site' ) . '</a></span>';
|
||||
}
|
||||
|
||||
if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) {
|
||||
$actions['delete'] = '<span class="delete"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deleteblog&id=' . $blog['blog_id'] ), 'deleteblog_' . $blog['blog_id'] ) ) . '">' . __( 'Delete' ) . '</a></span>';
|
||||
}
|
||||
}
|
||||
|
||||
$actions['visit'] = "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a></span>';
|
||||
|
||||
/**
|
||||
* 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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 '<td class="', $classes, ' has-row-actions" ', $data, '>';
|
||||
echo $this->column_blogs( $user );
|
||||
echo $this->handle_row_actions( $user, 'blogs', $primary );
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 '<th scope="row" class="check-column">';
|
||||
|
||||
$this->column_cb( $item );
|
||||
|
||||
echo '</th>';
|
||||
} elseif ( method_exists( $this, 'column_' . $column_name ) ) {
|
||||
echo "<td $attributes>";
|
||||
|
||||
call_user_func( array( $this, 'column_' . $column_name ), $item );
|
||||
|
||||
echo $this->handle_row_actions( $item, $column_name, $primary );
|
||||
echo "</td>";
|
||||
} else {
|
||||
echo "<td $attributes>";
|
||||
|
||||
$this->column_default( $item, $column_name );
|
||||
|
||||
echo $this->handle_row_actions( $item, $column_name, $primary );
|
||||
echo "</td>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
|
||||
$actions = array();
|
||||
$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
|
||||
|
||||
if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) {
|
||||
$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' ) . '&action=deleteuser&id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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'] = '<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' ) . '&action=deleteuser&id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -697,6 +697,22 @@ class WP_Posts_List_Table extends WP_List_Table {
|
|||
<?php endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.3.0
|
||||
* @access protected
|
||||
*
|
||||
* @param WP_Post $post
|
||||
* @param string $classes
|
||||
* @param string $data
|
||||
* @param string $primary
|
||||
*/
|
||||
protected function _column_title( $post, $classes, $data, $primary ) {
|
||||
echo '<td class="' . $classes . ' page-title" ', $data, '>';
|
||||
echo $this->column_title( $post );
|
||||
echo $this->handle_row_actions( $post, 'title', $primary );
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 '<th scope="row" class="check-column">';
|
||||
|
||||
$this->column_cb( $item );
|
||||
|
||||
echo '</th>';
|
||||
} else {
|
||||
echo "<td $attributes>";
|
||||
|
||||
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 '</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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'] = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . esc_attr__( 'Edit this item' ) . '">' . __( 'Edit' ) . '</a>';
|
||||
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr__( 'Edit this item inline' ) . '">' . __( 'Quick Edit' ) . '</a>';
|
||||
}
|
||||
|
||||
if ( current_user_can( 'delete_post', $post->ID ) ) {
|
||||
if ( 'trash' == $post->post_status )
|
||||
$actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash' ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
|
||||
elseif ( EMPTY_TRASH_DAYS )
|
||||
$actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash' ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
|
||||
if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
|
||||
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently' ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
|
||||
}
|
||||
|
||||
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'] = '<a href="' . esc_url( $preview_link ) . '" title="' . esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
|
||||
}
|
||||
} elseif ( 'trash' != $post->post_status ) {
|
||||
$actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
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'] = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . esc_attr__( 'Edit this item' ) . '">' . __( 'Edit' ) . '</a>';
|
||||
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr__( 'Edit this item inline' ) . '">' . __( 'Quick Edit' ) . '</a>';
|
||||
}
|
||||
|
||||
if ( current_user_can( 'delete_post', $post->ID ) ) {
|
||||
if ( 'trash' == $post->post_status )
|
||||
$actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash' ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
|
||||
elseif ( EMPTY_TRASH_DAYS )
|
||||
$actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash' ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
|
||||
if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
|
||||
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently' ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
|
||||
}
|
||||
|
||||
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'] = '<a href="' . esc_url( $preview_link ) . '" title="' . esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
|
||||
}
|
||||
} elseif ( 'trash' != $post->post_status ) {
|
||||
$actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
|
||||
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick Edit' ) . '</a>';
|
||||
}
|
||||
if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
|
||||
$actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) . "'>" . __( 'Delete' ) . "</a>";
|
||||
if ( $tax->public )
|
||||
$actions['view'] = '<a href="' . get_term_link( $tag ) . '">' . __( 'View' ) . '</a>';
|
||||
|
||||
/**
|
||||
* 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'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
|
||||
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick Edit' ) . '</a>';
|
||||
}
|
||||
if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
|
||||
$actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) . "'>" . __( 'Delete' ) . "</a>";
|
||||
if ( $tax->public )
|
||||
$actions['view'] = '<a href="' . get_term_link( $tag ) . '">' . __( 'View' ) . '</a>';
|
||||
|
||||
/**
|
||||
* 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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.3-beta2-33269';
|
||||
$wp_version = '4.3-beta2-33270';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue