Introduce WP_List_Table::current_action() and use throughout admin list screens. See #14579
git-svn-id: https://develop.svn.wordpress.org/trunk@15642 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6121bb1234
commit
728285edbd
@ -12,20 +12,21 @@ require_once('./admin.php');
|
||||
$wp_list_table = get_list_table('comments');
|
||||
$wp_list_table->check_permissions();
|
||||
|
||||
if ( isset( $_REQUEST['doaction'] ) || isset( $_REQUEST['doaction2'] ) || isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) {
|
||||
$doaction = $wp_list_table->current_action();
|
||||
|
||||
if ( $doaction ) {
|
||||
check_admin_referer( 'bulk-comments' );
|
||||
|
||||
if ( ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) && !empty( $_REQUEST['pagegen_timestamp'] ) ) {
|
||||
if ( 'delete_all' == $do_action && !empty( $_REQUEST['pagegen_timestamp'] ) ) {
|
||||
$comment_status = $wpdb->escape( $_REQUEST['comment_status'] );
|
||||
$delete_time = $wpdb->escape( $_REQUEST['pagegen_timestamp'] );
|
||||
$comment_ids = $wpdb->get_col( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = '$comment_status' AND '$delete_time' > comment_date_gmt" );
|
||||
$doaction = 'delete';
|
||||
} elseif ( ( $_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1 ) && isset( $_REQUEST['delete_comments'] ) ) {
|
||||
} elseif ( isset( $_REQUEST['delete_comments'] ) ) {
|
||||
$comment_ids = $_REQUEST['delete_comments'];
|
||||
$doaction = ( $_REQUEST['action'] != -1 ) ? $_REQUEST['action'] : $_REQUEST['action2'];
|
||||
} elseif ( $_REQUEST['doaction'] == 'undo' && isset( $_REQUEST['ids'] ) ) {
|
||||
} elseif ( isset( $_REQUEST['ids'] ) ) {
|
||||
$comment_ids = array_map( 'absint', explode( ',', $_REQUEST['ids'] ) );
|
||||
$doaction = $_REQUEST['action'];
|
||||
} else {
|
||||
wp_redirect( wp_get_referer() );
|
||||
}
|
||||
|
@ -22,10 +22,7 @@ if ( 'post' != $post_type ) {
|
||||
$submenu_file = "edit-tags.php?taxonomy=$taxonomy";
|
||||
}
|
||||
|
||||
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' == $_REQUEST['action'] || 'delete' == $_REQUEST['action2'] ) )
|
||||
$action = 'bulk-delete';
|
||||
|
||||
switch ( $action ) {
|
||||
switch ( $wp_list_table->current_action() ) {
|
||||
|
||||
case 'add-tag':
|
||||
|
||||
|
@ -21,21 +21,25 @@ if ( $_redirect = intval( max( @$_REQUEST['p'], @$_REQUEST['attachment_id'], @$_
|
||||
}
|
||||
|
||||
// Handle bulk actions
|
||||
if ( isset($_REQUEST['doaction']) || isset($_REQUEST['doaction2']) || isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2']) || isset($_REQUEST['bulk_edit']) ) {
|
||||
$doaction = $wp_list_table->current_action();
|
||||
|
||||
if ( $doaction ) {
|
||||
check_admin_referer('bulk-posts');
|
||||
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
|
||||
|
||||
if ( strpos($sendback, 'post.php') !== false )
|
||||
$sendback = admin_url($post_new_file);
|
||||
|
||||
if ( isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2']) ) {
|
||||
$post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['post_status']);
|
||||
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) );
|
||||
if ( 'delete_all' == $doaction ) {
|
||||
$post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'" );
|
||||
$doaction = 'delete';
|
||||
} elseif ( ( $_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1 ) && ( isset($_REQUEST['post']) || isset($_REQUEST['ids']) ) ) {
|
||||
$post_ids = isset($_REQUEST['post']) ? array_map( 'intval', (array) $_REQUEST['post'] ) : explode(',', $_REQUEST['ids']);
|
||||
$doaction = ($_REQUEST['action'] != -1) ? $_REQUEST['action'] : $_REQUEST['action2'];
|
||||
} else {
|
||||
} elseif ( isset( $_REQUEST['media'] ) ) {
|
||||
$post_ids = $_REQUEST['media'];
|
||||
} elseif ( isset( $_REQUEST['ids'] ) ) {
|
||||
$post_ids = explode( ',', $_REQUEST['ids'] );
|
||||
}
|
||||
|
||||
if ( !isset( $post_ids ) ) {
|
||||
wp_redirect( admin_url("edit.php?post_type=$post_type") );
|
||||
}
|
||||
|
||||
@ -97,7 +101,6 @@ if ( isset($_REQUEST['doaction']) || isset($_REQUEST['doaction2']) || isset($_RE
|
||||
break;
|
||||
}
|
||||
|
||||
if ( isset($_REQUEST['action']) )
|
||||
$sendback = remove_query_arg( array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback );
|
||||
|
||||
wp_redirect($sendback);
|
||||
|
@ -215,6 +215,13 @@ class WP_Posts_Table extends WP_List_Table {
|
||||
}
|
||||
}
|
||||
|
||||
function current_action() {
|
||||
if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
|
||||
return 'delete_all';
|
||||
|
||||
return parent::current_action();
|
||||
}
|
||||
|
||||
function pagination( $which ) {
|
||||
global $post_type_object, $mode;
|
||||
|
||||
@ -1080,6 +1087,19 @@ class WP_Media_Table extends WP_List_Table {
|
||||
<?php
|
||||
}
|
||||
|
||||
function current_action() {
|
||||
if ( isset( $_REQUEST['find_detached'] ) )
|
||||
return 'find_detached';
|
||||
|
||||
if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) )
|
||||
return 'attach';
|
||||
|
||||
if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
|
||||
return 'delete_all';
|
||||
|
||||
return parent::current_action();
|
||||
}
|
||||
|
||||
function has_items() {
|
||||
return have_posts();
|
||||
}
|
||||
@ -1482,6 +1502,13 @@ class WP_Terms_Table extends WP_List_Table {
|
||||
return $actions;
|
||||
}
|
||||
|
||||
function current_action() {
|
||||
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' == $_REQUEST['action'] || 'delete' == $_REQUEST['action2'] ) )
|
||||
return 'bulk-delete';
|
||||
|
||||
return parent::current_action();
|
||||
}
|
||||
|
||||
function get_columns() {
|
||||
global $taxonomy;
|
||||
|
||||
@ -1862,6 +1889,13 @@ class WP_Users_Table extends WP_List_Table {
|
||||
<?php
|
||||
}
|
||||
|
||||
function current_action() {
|
||||
if ( isset($_REQUEST['changeit']) && !empty($_REQUEST['new_role']) )
|
||||
return 'promote';
|
||||
|
||||
return parent::current_action();
|
||||
}
|
||||
|
||||
function get_columns() {
|
||||
return array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
@ -2214,6 +2248,13 @@ class WP_Comments_Table extends WP_List_Table {
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
function current_action() {
|
||||
if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
|
||||
return 'delete_all';
|
||||
|
||||
return parent::current_action();
|
||||
}
|
||||
|
||||
function get_columns() {
|
||||
global $mode;
|
||||
|
||||
@ -3458,6 +3499,13 @@ class WP_Plugins_Table extends WP_List_Table {
|
||||
<?php }
|
||||
}
|
||||
|
||||
function current_action() {
|
||||
if ( isset($_POST['clear-recent-list']) )
|
||||
return 'clear-recent-list';
|
||||
|
||||
return parent::current_action();
|
||||
}
|
||||
|
||||
function display_rows() {
|
||||
global $status, $page;
|
||||
|
||||
|
@ -246,6 +246,24 @@ class WP_List_Table {
|
||||
echo "<input type='submit' value='" . esc_attr__( 'Apply' ) . "' name='doaction$two' id='doaction$two' class='button-secondary action' />\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current action selected from the bulk actions dropdown.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access public
|
||||
*
|
||||
* @return string|bool The action name or False if no action was selected
|
||||
*/
|
||||
function current_action() {
|
||||
if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] )
|
||||
return $_REQUEST['action'];
|
||||
|
||||
if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] )
|
||||
return $_REQUEST['action2'];
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate row actions div
|
||||
*
|
||||
|
@ -13,10 +13,10 @@ $wp_list_table = get_list_table('links');
|
||||
$wp_list_table->check_permissions();
|
||||
|
||||
// Handle bulk deletes
|
||||
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['linkcheck'] ) ) {
|
||||
check_admin_referer( 'bulk-bookmarks' );
|
||||
$doaction = $wp_list_table->current_action();
|
||||
|
||||
$doaction = $_REQUEST['action'] ? $_REQUEST['action'] : $_REQUEST['action2'];
|
||||
if ( $doaction && isset( $_REQUEST['linkcheck'] ) ) {
|
||||
check_admin_referer( 'bulk-bookmarks' );
|
||||
|
||||
if ( 'delete' == $doaction ) {
|
||||
$bulklinks = (array) $_REQUEST['linkcheck'];
|
||||
|
@ -12,21 +12,14 @@ require_once('./admin.php');
|
||||
$wp_list_table = get_list_table('plugins');
|
||||
$wp_list_table->check_permissions();
|
||||
|
||||
if ( isset($_POST['clear-recent-list']) )
|
||||
$action = 'clear-recent-list';
|
||||
elseif ( !empty($_REQUEST['action']) )
|
||||
$action = $_REQUEST['action'];
|
||||
elseif ( !empty($_REQUEST['action2']) )
|
||||
$action = $_REQUEST['action2'];
|
||||
else
|
||||
$action = false;
|
||||
$action = $wp_list_table->current_action();
|
||||
|
||||
$plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '';
|
||||
|
||||
//Clean up request URI from temporary args for screen options/paging uri's to work as expected.
|
||||
// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
|
||||
$_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce'), $_SERVER['REQUEST_URI']);
|
||||
|
||||
if ( !empty($action) ) {
|
||||
if ( $action ) {
|
||||
$network_wide = false;
|
||||
if ( ( isset( $_GET['networkwide'] ) || 'network-activate-selected' == $action ) && is_multisite() && current_user_can( 'manage_network_plugins' ) )
|
||||
$network_wide = true;
|
||||
|
@ -13,9 +13,28 @@ $wp_list_table = get_list_table('media');
|
||||
$wp_list_table->check_permissions();
|
||||
|
||||
// Handle bulk actions
|
||||
if ( isset($_REQUEST['find_detached']) ) {
|
||||
$doaction = $wp_list_table->current_action();
|
||||
|
||||
if ( $doaction ) {
|
||||
check_admin_referer('bulk-media');
|
||||
|
||||
if ( 'delete_all' == $doaction ) {
|
||||
$post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'" );
|
||||
$doaction = 'delete';
|
||||
} elseif ( isset( $_REQUEST['media'] ) ) {
|
||||
$post_ids = $_REQUEST['media'];
|
||||
} elseif ( isset( $_REQUEST['ids'] ) ) {
|
||||
$post_ids = explode( ',', $_REQUEST['ids'] );
|
||||
}
|
||||
|
||||
$location = 'upload.php';
|
||||
if ( $referer = wp_get_referer() ) {
|
||||
if ( false !== strpos( $referer, 'upload.php' ) )
|
||||
$location = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted' ), $referer );
|
||||
}
|
||||
|
||||
switch ( $doaction ) {
|
||||
case 'find_detached':
|
||||
if ( !current_user_can('edit_posts') )
|
||||
wp_die( __('You are not allowed to scan for lost attachments.') );
|
||||
|
||||
@ -29,10 +48,8 @@ if ( isset($_REQUEST['find_detached']) ) {
|
||||
" );
|
||||
|
||||
$_REQUEST['detached'] = 1;
|
||||
|
||||
} elseif ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) ) {
|
||||
check_admin_referer( 'bulk-media' );
|
||||
|
||||
break;
|
||||
case 'attach':
|
||||
$parent_id = (int) $_REQUEST['found_post_id'];
|
||||
if ( !$parent_id )
|
||||
return;
|
||||
@ -68,27 +85,7 @@ if ( isset($_REQUEST['find_detached']) ) {
|
||||
wp_redirect( $location );
|
||||
exit;
|
||||
}
|
||||
|
||||
} elseif ( isset( $_REQUEST['doaction'] ) || isset( $_REQUEST['doaction2'] ) || isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) {
|
||||
check_admin_referer( 'bulk-media' );
|
||||
|
||||
if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) {
|
||||
$post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'" );
|
||||
$doaction = 'delete';
|
||||
} elseif ( ( $_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1 ) && ( isset( $_REQUEST['media'] ) || isset( $_REQUEST['ids'] ) ) ) {
|
||||
$post_ids = isset( $_REQUEST['media'] ) ? $_REQUEST['media'] : explode( ',', $_REQUEST['ids'] );
|
||||
$doaction = ( $_REQUEST['action'] != -1 ) ? $_REQUEST['action'] : $_REQUEST['action2'];
|
||||
} else {
|
||||
wp_redirect( $_SERVER['HTTP_REFERER'] );
|
||||
}
|
||||
|
||||
$location = 'upload.php';
|
||||
if ( $referer = wp_get_referer() ) {
|
||||
if ( false !== strpos( $referer, 'upload.php' ) )
|
||||
$location = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted' ), $referer );
|
||||
}
|
||||
|
||||
switch ( $doaction ) {
|
||||
break;
|
||||
case 'trash':
|
||||
foreach ( (array) $post_ids as $post_id ) {
|
||||
if ( !current_user_can( 'delete_post', $post_id ) )
|
||||
|
@ -29,15 +29,6 @@ add_contextual_help($current_screen,
|
||||
'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
|
||||
);
|
||||
|
||||
$update = $doaction = '';
|
||||
if ( isset($_REQUEST['action']) )
|
||||
$doaction = $_REQUEST['action'] ? $_REQUEST['action'] : $_REQUEST['action2'];
|
||||
|
||||
if ( "-1" == $doaction ) {
|
||||
if ( isset($_REQUEST['changeit']) && !empty($_REQUEST['new_role']) )
|
||||
$doaction = 'promote';
|
||||
}
|
||||
|
||||
if ( empty($_REQUEST) ) {
|
||||
$referer = '<input type="hidden" name="wp_http_referer" value="'. esc_attr(stripslashes($_SERVER['REQUEST_URI'])) . '" />';
|
||||
} elseif ( isset($_REQUEST['wp_http_referer']) ) {
|
||||
@ -48,7 +39,9 @@ if ( empty($_REQUEST) ) {
|
||||
$referer = '';
|
||||
}
|
||||
|
||||
switch ($doaction) {
|
||||
$update = '';
|
||||
|
||||
switch ( $wp_list_table->current_action() ) {
|
||||
|
||||
/* Bulk Dropdown menu Role changes */
|
||||
case 'promote':
|
||||
|
Loading…
Reference in New Issue
Block a user