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
84e6cae4
Commit
84e6cae4
authored
7 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Reduce duplication
parent
3f98b389
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
+6
-4
6 additions, 4 deletions
includes/class-delete-all.php
includes/class-move-to-trash.php
+5
-3
5 additions, 3 deletions
includes/class-move-to-trash.php
with
11 additions
and
7 deletions
includes/class-delete-all.php
+
6
−
4
View file @
84e6cae4
...
@@ -14,14 +14,16 @@ class Delete_All {
...
@@ -14,14 +14,16 @@ class Delete_All {
/**
/**
* Class constants
* Class constants
*/
*/
const
ACTION
=
'delete_all'
;
const
ADMIN_NOTICE_KEY
=
'bulk_edit_cron_offload_deleted_all'
;
const
ADMIN_NOTICE_KEY
=
'bulk_edit_cron_offload_deleted_all'
;
/**
/**
* Register this bulk process' hooks
* Register this bulk process' hooks
*/
*/
public
static
function
register_hooks
()
{
public
static
function
register_hooks
()
{
add_action
(
Main
::
build_hook
(
'delete_all'
),
array
(
__CLASS__
,
'process'
)
);
add_action
(
Main
::
build_hook
(
self
::
ACTION
),
array
(
__CLASS__
,
'process'
)
);
add_action
(
Main
::
build_cron_hook
(
'delete_all'
),
array
(
__CLASS__
,
'process_via_cron'
)
);
add_action
(
Main
::
build_cron_hook
(
self
::
ACTION
),
array
(
__CLASS__
,
'process_via_cron'
)
);
add_action
(
'admin_notices'
,
array
(
__CLASS__
,
'admin_notices'
)
);
add_action
(
'admin_notices'
,
array
(
__CLASS__
,
'admin_notices'
)
);
add_filter
(
'posts_where'
,
array
(
__CLASS__
,
'hide_posts_pending_delete'
),
999
,
2
);
add_filter
(
'posts_where'
,
array
(
__CLASS__
,
'hide_posts_pending_delete'
),
999
,
2
);
...
@@ -39,7 +41,7 @@ class Delete_All {
...
@@ -39,7 +41,7 @@ class Delete_All {
*/
*/
public
static
function
process
(
$vars
)
{
public
static
function
process
(
$vars
)
{
// Special keys are used to trigger this request, and we need to remove them on redirect.
// Special keys are used to trigger this request, and we need to remove them on redirect.
$extra_keys
=
array
(
'delete_all'
,
'delete_all
2'
);
$extra_keys
=
array
(
self
::
ACTION
,
self
::
ACTION
.
'
2'
);
$action_scheduled
=
self
::
action_next_scheduled
(
$vars
->
post_type
);
$action_scheduled
=
self
::
action_next_scheduled
(
$vars
->
post_type
);
...
@@ -224,7 +226,7 @@ class Delete_All {
...
@@ -224,7 +226,7 @@ class Delete_All {
foreach
(
$action_instances
as
$instance
=>
$instance_args
)
{
foreach
(
$action_instances
as
$instance
=>
$instance_args
)
{
$vars
=
array_shift
(
$instance_args
[
'args'
]
);
$vars
=
array_shift
(
$instance_args
[
'args'
]
);
if
(
'delete_all'
===
$vars
->
action
&&
$post_type
===
$vars
->
post_type
)
{
if
(
self
::
ACTION
===
$vars
->
action
&&
$post_type
===
$vars
->
post_type
)
{
return
array
(
return
array
(
'timestamp'
=>
$timestamp
,
'timestamp'
=>
$timestamp
,
'args'
=>
$vars
,
'args'
=>
$vars
,
...
...
This diff is collapsed.
Click to expand it.
includes/class-move-to-trash.php
+
5
−
3
View file @
84e6cae4
...
@@ -14,14 +14,16 @@ class Move_To_Trash {
...
@@ -14,14 +14,16 @@ class Move_To_Trash {
/**
/**
* Class constants
* Class constants
*/
*/
const
ACTION
=
'trash'
;
const
ADMIN_NOTICE_KEY
=
'bulk_edit_cron_offload_move_to_trash'
;
const
ADMIN_NOTICE_KEY
=
'bulk_edit_cron_offload_move_to_trash'
;
/**
/**
* Register this bulk process' hooks
* Register this bulk process' hooks
*/
*/
public
static
function
register_hooks
()
{
public
static
function
register_hooks
()
{
add_action
(
Main
::
build_hook
(
'trash'
),
array
(
__CLASS__
,
'process'
)
);
add_action
(
Main
::
build_hook
(
self
::
ACTION
),
array
(
__CLASS__
,
'process'
)
);
add_action
(
Main
::
build_cron_hook
(
'trash'
),
array
(
__CLASS__
,
'process_via_cron'
)
);
add_action
(
Main
::
build_cron_hook
(
self
::
ACTION
),
array
(
__CLASS__
,
'process_via_cron'
)
);
add_action
(
'admin_notices'
,
array
(
__CLASS__
,
'admin_notices'
)
);
add_action
(
'admin_notices'
,
array
(
__CLASS__
,
'admin_notices'
)
);
add_filter
(
'posts_where'
,
array
(
__CLASS__
,
'hide_posts_pending_move'
),
999
,
2
);
add_filter
(
'posts_where'
,
array
(
__CLASS__
,
'hide_posts_pending_move'
),
999
,
2
);
...
@@ -187,7 +189,7 @@ class Move_To_Trash {
...
@@ -187,7 +189,7 @@ class Move_To_Trash {
foreach
(
$action_instances
as
$instance
=>
$instance_args
)
{
foreach
(
$action_instances
as
$instance
=>
$instance_args
)
{
$vars
=
array_shift
(
$instance_args
[
'args'
]
);
$vars
=
array_shift
(
$instance_args
[
'args'
]
);
if
(
'trash'
===
$vars
->
action
&&
$post_type
===
$vars
->
post_type
)
{
if
(
self
::
ACTION
===
$vars
->
action
&&
$post_type
===
$vars
->
post_type
)
{
if
(
$post_status
===
$vars
->
post_status
||
'all'
===
$vars
->
post_status
||
'all'
===
$post_status
)
{
if
(
$post_status
===
$vars
->
post_status
||
'all'
===
$vars
->
post_status
||
'all'
===
$post_status
)
{
$ids
[]
=
array
(
$ids
[]
=
array
(
'timestamp'
=>
$timestamp
,
'timestamp'
=>
$timestamp
,
...
...
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