mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Introduce WP_List_Table::current_action() and use throughout admin list screens. See #14579
git-svn-id: http://svn.automattic.com/wordpress/trunk@15642 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f3d45472d2
commit
e975e650cf
@ -12,20 +12,21 @@ require_once('./admin.php');
|
|||||||
$wp_list_table = get_list_table('comments');
|
$wp_list_table = get_list_table('comments');
|
||||||
$wp_list_table->check_permissions();
|
$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' );
|
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'] );
|
$comment_status = $wpdb->escape( $_REQUEST['comment_status'] );
|
||||||
$delete_time = $wpdb->escape( $_REQUEST['pagegen_timestamp'] );
|
$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" );
|
$comment_ids = $wpdb->get_col( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = '$comment_status' AND '$delete_time' > comment_date_gmt" );
|
||||||
$doaction = 'delete';
|
$doaction = 'delete';
|
||||||
} elseif ( ( $_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1 ) && isset( $_REQUEST['delete_comments'] ) ) {
|
} elseif ( isset( $_REQUEST['delete_comments'] ) ) {
|
||||||
$comment_ids = $_REQUEST['delete_comments'];
|
$comment_ids = $_REQUEST['delete_comments'];
|
||||||
$doaction = ( $_REQUEST['action'] != -1 ) ? $_REQUEST['action'] : $_REQUEST['action2'];
|
$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'] ) );
|
$comment_ids = array_map( 'absint', explode( ',', $_REQUEST['ids'] ) );
|
||||||
$doaction = $_REQUEST['action'];
|
|
||||||
} else {
|
} else {
|
||||||
wp_redirect( wp_get_referer() );
|
wp_redirect( wp_get_referer() );
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,7 @@ if ( 'post' != $post_type ) {
|
|||||||
$submenu_file = "edit-tags.php?taxonomy=$taxonomy";
|
$submenu_file = "edit-tags.php?taxonomy=$taxonomy";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' == $_REQUEST['action'] || 'delete' == $_REQUEST['action2'] ) )
|
switch ( $wp_list_table->current_action() ) {
|
||||||
$action = 'bulk-delete';
|
|
||||||
|
|
||||||
switch ( $action ) {
|
|
||||||
|
|
||||||
case 'add-tag':
|
case 'add-tag':
|
||||||
|
|
||||||
|
@ -21,21 +21,25 @@ if ( $_redirect = intval( max( @$_REQUEST['p'], @$_REQUEST['attachment_id'], @$_
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle bulk actions
|
// 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');
|
check_admin_referer('bulk-posts');
|
||||||
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
|
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
|
||||||
|
|
||||||
if ( strpos($sendback, 'post.php') !== false )
|
if ( strpos($sendback, 'post.php') !== false )
|
||||||
$sendback = admin_url($post_new_file);
|
$sendback = admin_url($post_new_file);
|
||||||
|
|
||||||
if ( isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2']) ) {
|
if ( 'delete_all' == $doaction ) {
|
||||||
$post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['post_status']);
|
$post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'" );
|
||||||
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) );
|
|
||||||
$doaction = 'delete';
|
$doaction = 'delete';
|
||||||
} elseif ( ( $_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1 ) && ( isset($_REQUEST['post']) || isset($_REQUEST['ids']) ) ) {
|
} elseif ( isset( $_REQUEST['media'] ) ) {
|
||||||
$post_ids = isset($_REQUEST['post']) ? array_map( 'intval', (array) $_REQUEST['post'] ) : explode(',', $_REQUEST['ids']);
|
$post_ids = $_REQUEST['media'];
|
||||||
$doaction = ($_REQUEST['action'] != -1) ? $_REQUEST['action'] : $_REQUEST['action2'];
|
} elseif ( isset( $_REQUEST['ids'] ) ) {
|
||||||
} else {
|
$post_ids = explode( ',', $_REQUEST['ids'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !isset( $post_ids ) ) {
|
||||||
wp_redirect( admin_url("edit.php?post_type=$post_type") );
|
wp_redirect( admin_url("edit.php?post_type=$post_type") );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +101,6 @@ if ( isset($_REQUEST['doaction']) || isset($_REQUEST['doaction2']) || isset($_RE
|
|||||||
break;
|
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 );
|
$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);
|
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 ) {
|
function pagination( $which ) {
|
||||||
global $post_type_object, $mode;
|
global $post_type_object, $mode;
|
||||||
|
|
||||||
@ -1080,6 +1087,19 @@ class WP_Media_Table extends WP_List_Table {
|
|||||||
<?php
|
<?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() {
|
function has_items() {
|
||||||
return have_posts();
|
return have_posts();
|
||||||
}
|
}
|
||||||
@ -1482,6 +1502,13 @@ class WP_Terms_Table extends WP_List_Table {
|
|||||||
return $actions;
|
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() {
|
function get_columns() {
|
||||||
global $taxonomy;
|
global $taxonomy;
|
||||||
|
|
||||||
@ -1862,6 +1889,13 @@ class WP_Users_Table extends WP_List_Table {
|
|||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function current_action() {
|
||||||
|
if ( isset($_REQUEST['changeit']) && !empty($_REQUEST['new_role']) )
|
||||||
|
return 'promote';
|
||||||
|
|
||||||
|
return parent::current_action();
|
||||||
|
}
|
||||||
|
|
||||||
function get_columns() {
|
function get_columns() {
|
||||||
return array(
|
return array(
|
||||||
'cb' => '<input type="checkbox" />',
|
'cb' => '<input type="checkbox" />',
|
||||||
@ -2214,6 +2248,13 @@ class WP_Comments_Table extends WP_List_Table {
|
|||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function current_action() {
|
||||||
|
if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
|
||||||
|
return 'delete_all';
|
||||||
|
|
||||||
|
return parent::current_action();
|
||||||
|
}
|
||||||
|
|
||||||
function get_columns() {
|
function get_columns() {
|
||||||
global $mode;
|
global $mode;
|
||||||
|
|
||||||
@ -3458,6 +3499,13 @@ class WP_Plugins_Table extends WP_List_Table {
|
|||||||
<?php }
|
<?php }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function current_action() {
|
||||||
|
if ( isset($_POST['clear-recent-list']) )
|
||||||
|
return 'clear-recent-list';
|
||||||
|
|
||||||
|
return parent::current_action();
|
||||||
|
}
|
||||||
|
|
||||||
function display_rows() {
|
function display_rows() {
|
||||||
global $status, $page;
|
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";
|
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
|
* Generate row actions div
|
||||||
*
|
*
|
||||||
|
@ -13,10 +13,10 @@ $wp_list_table = get_list_table('links');
|
|||||||
$wp_list_table->check_permissions();
|
$wp_list_table->check_permissions();
|
||||||
|
|
||||||
// Handle bulk deletes
|
// Handle bulk deletes
|
||||||
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['linkcheck'] ) ) {
|
$doaction = $wp_list_table->current_action();
|
||||||
check_admin_referer( 'bulk-bookmarks' );
|
|
||||||
|
|
||||||
$doaction = $_REQUEST['action'] ? $_REQUEST['action'] : $_REQUEST['action2'];
|
if ( $doaction && isset( $_REQUEST['linkcheck'] ) ) {
|
||||||
|
check_admin_referer( 'bulk-bookmarks' );
|
||||||
|
|
||||||
if ( 'delete' == $doaction ) {
|
if ( 'delete' == $doaction ) {
|
||||||
$bulklinks = (array) $_REQUEST['linkcheck'];
|
$bulklinks = (array) $_REQUEST['linkcheck'];
|
||||||
|
@ -12,21 +12,14 @@ require_once('./admin.php');
|
|||||||
$wp_list_table = get_list_table('plugins');
|
$wp_list_table = get_list_table('plugins');
|
||||||
$wp_list_table->check_permissions();
|
$wp_list_table->check_permissions();
|
||||||
|
|
||||||
if ( isset($_POST['clear-recent-list']) )
|
$action = $wp_list_table->current_action();
|
||||||
$action = 'clear-recent-list';
|
|
||||||
elseif ( !empty($_REQUEST['action']) )
|
|
||||||
$action = $_REQUEST['action'];
|
|
||||||
elseif ( !empty($_REQUEST['action2']) )
|
|
||||||
$action = $_REQUEST['action2'];
|
|
||||||
else
|
|
||||||
$action = false;
|
|
||||||
|
|
||||||
$plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '';
|
$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']);
|
$_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;
|
$network_wide = false;
|
||||||
if ( ( isset( $_GET['networkwide'] ) || 'network-activate-selected' == $action ) && is_multisite() && current_user_can( 'manage_network_plugins' ) )
|
if ( ( isset( $_GET['networkwide'] ) || 'network-activate-selected' == $action ) && is_multisite() && current_user_can( 'manage_network_plugins' ) )
|
||||||
$network_wide = true;
|
$network_wide = true;
|
||||||
|
@ -13,9 +13,28 @@ $wp_list_table = get_list_table('media');
|
|||||||
$wp_list_table->check_permissions();
|
$wp_list_table->check_permissions();
|
||||||
|
|
||||||
// Handle bulk actions
|
// Handle bulk actions
|
||||||
if ( isset($_REQUEST['find_detached']) ) {
|
$doaction = $wp_list_table->current_action();
|
||||||
|
|
||||||
|
if ( $doaction ) {
|
||||||
check_admin_referer('bulk-media');
|
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') )
|
if ( !current_user_can('edit_posts') )
|
||||||
wp_die( __('You are not allowed to scan for lost attachments.') );
|
wp_die( __('You are not allowed to scan for lost attachments.') );
|
||||||
|
|
||||||
@ -29,10 +48,8 @@ if ( isset($_REQUEST['find_detached']) ) {
|
|||||||
" );
|
" );
|
||||||
|
|
||||||
$_REQUEST['detached'] = 1;
|
$_REQUEST['detached'] = 1;
|
||||||
|
break;
|
||||||
} elseif ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) ) {
|
case 'attach':
|
||||||
check_admin_referer( 'bulk-media' );
|
|
||||||
|
|
||||||
$parent_id = (int) $_REQUEST['found_post_id'];
|
$parent_id = (int) $_REQUEST['found_post_id'];
|
||||||
if ( !$parent_id )
|
if ( !$parent_id )
|
||||||
return;
|
return;
|
||||||
@ -68,27 +85,7 @@ if ( isset($_REQUEST['find_detached']) ) {
|
|||||||
wp_redirect( $location );
|
wp_redirect( $location );
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
} 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 ) {
|
|
||||||
case 'trash':
|
case 'trash':
|
||||||
foreach ( (array) $post_ids as $post_id ) {
|
foreach ( (array) $post_ids as $post_id ) {
|
||||||
if ( !current_user_can( 'delete_post', $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>'
|
'<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) ) {
|
if ( empty($_REQUEST) ) {
|
||||||
$referer = '<input type="hidden" name="wp_http_referer" value="'. esc_attr(stripslashes($_SERVER['REQUEST_URI'])) . '" />';
|
$referer = '<input type="hidden" name="wp_http_referer" value="'. esc_attr(stripslashes($_SERVER['REQUEST_URI'])) . '" />';
|
||||||
} elseif ( isset($_REQUEST['wp_http_referer']) ) {
|
} elseif ( isset($_REQUEST['wp_http_referer']) ) {
|
||||||
@ -48,7 +39,9 @@ if ( empty($_REQUEST) ) {
|
|||||||
$referer = '';
|
$referer = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($doaction) {
|
$update = '';
|
||||||
|
|
||||||
|
switch ( $wp_list_table->current_action() ) {
|
||||||
|
|
||||||
/* Bulk Dropdown menu Role changes */
|
/* Bulk Dropdown menu Role changes */
|
||||||
case 'promote':
|
case 'promote':
|
||||||
|
Loading…
Reference in New Issue
Block a user