Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Bulk Actions Cron Offload
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
WP Plugins
Bulk Actions Cron Offload
Commits
944c9c64
Commit
944c9c64
authored
8 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Generalize redirect method as it'll be needed by other bulk processes
parent
af942186
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
includes/class-delete-all.php
+5
-21
5 additions, 21 deletions
includes/class-delete-all.php
includes/class-main.php
+23
-0
23 additions, 0 deletions
includes/class-main.php
with
28 additions
and
21 deletions
includes/class-delete-all.php
+
5
−
21
View file @
944c9c64
...
...
@@ -30,14 +30,17 @@ class Delete_All {
* Handle a request to delete all trashed items for a given post type
*/
public
static
function
process
(
$vars
)
{
// Special keys are used to trigger this request, and we need to remove them on redirect
$extra_keys
=
array
(
'delete_all'
,
'delete_all2'
,
);
$action_scheduled
=
self
::
action_next_scheduled
(
self
::
CRON_EVENT
,
$vars
->
post_type
);
if
(
empty
(
$action_scheduled
)
)
{
wp_schedule_single_event
(
time
(),
self
::
CRON_EVENT
,
array
(
$vars
)
);
self
::
redirect
(
true
);
Main
::
do_admin_redirect
(
self
::
ADMIN_NOTICE_KEY
,
true
,
$extra_keys
);
}
else
{
self
::
redirect
(
false
);
Main
::
do_admin_redirect
(
self
::
ADMIN_NOTICE_KEY
,
false
,
$extra_keys
);
}
}
...
...
@@ -92,25 +95,6 @@ class Delete_All {
}
}
/**
* Redirect, including a flag to indicate if the bulk process was scheduled successfully
*
* @param bool $succeeded Whether or not the bulk-delete was scheduled
*/
public
static
function
redirect
(
$succeeded
=
false
)
{
$redirect
=
wp_unslash
(
$_SERVER
[
'REQUEST_URI'
]
);
// Remove arguments that could re-trigger this bulk-edit
$redirect
=
remove_query_arg
(
array
(
'_wp_http_referer'
,
'_wpnonce'
,
'delete_all'
,
'delete_all2'
,
),
$redirect
);
// Add a flag for the admin notice
$redirect
=
add_query_arg
(
self
::
ADMIN_NOTICE_KEY
,
$succeeded
?
1
:
-
1
,
$redirect
);
$redirect
=
esc_url_raw
(
$redirect
);
wp_safe_redirect
(
$redirect
);
exit
;
}
/**
* Let the user know what's going on
*/
...
...
This diff is collapsed.
Click to expand it.
includes/class-main.php
+
23
−
0
View file @
944c9c64
...
...
@@ -154,6 +154,29 @@ class Main {
unset
(
$_REQUEST
[
'delete_all'
]
);
unset
(
$_REQUEST
[
'delete_all2'
]
);
}
/**
* Redirect, including a flag to indicate if the bulk process was scheduled successfully
*
* @param string $return_key Key to include in redirect URL to flag request's origin, use for admin feedback, etc.
* @param bool $succeeded Whether or not the bulk-delete was scheduled
* @param array $extra_keys Array of additional action keys to remove from redirect URL. Optional.
*/
public
static
function
do_admin_redirect
(
$return_key
,
$succeeded
=
false
,
$extra_keys
=
array
()
)
{
$redirect
=
wp_unslash
(
$_SERVER
[
'REQUEST_URI'
]
);
// Remove arguments that could re-trigger this bulk-edit
$action_keys
=
array
(
'_wp_http_referer'
,
'_wpnonce'
,
'action'
,
'action2'
,
);
$action_keys
=
array_merge
(
$action_keys
,
$extra_keys
);
$redirect
=
remove_query_arg
(
$action_keys
,
$redirect
);
// Add a flag for the admin notice
$redirect
=
add_query_arg
(
$return_key
,
$succeeded
?
1
:
-
1
,
$redirect
);
$redirect
=
esc_url_raw
(
$redirect
);
wp_safe_redirect
(
$redirect
);
exit
;
}
}
Main
::
load
();
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment