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
0
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
0
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
4ea4afd2
Commit
4ea4afd2
authored
8 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Hide posts pending purge
parent
6a5fcb38
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
includes/class-delete-all.php
+27
-4
27 additions, 4 deletions
includes/class-delete-all.php
with
27 additions
and
4 deletions
includes/class-delete-all.php
+
27
−
4
View file @
4ea4afd2
...
...
@@ -15,15 +15,15 @@ class Delete_All {
*/
public
static
function
register_hooks
()
{
add_action
(
self
::
CRON_EVENT
,
array
(
__CLASS__
,
'process_via_cron'
)
);
add_filter
(
'posts_where'
,
array
(
__CLASS__
,
'hide_posts_pending_delete'
),
999
,
2
);
add_action
(
'admin_notices'
,
array
(
__CLASS__
,
'admin_notices'
)
);
}
/**
*
*
Handle a request to delete all trashed items for a given post type
*/
public
static
function
process
(
$vars
)
{
// TODO: Add hook to hide posts when their deletion is pending
$action_scheduled
=
self
::
action_next_scheduled
(
self
::
CRON_EVENT
,
$vars
->
post_type
);
if
(
empty
(
$action_scheduled
)
)
{
...
...
@@ -75,7 +75,7 @@ class Delete_All {
}
/**
*
*
Cron callback to delete trashed items in a given post type
*/
public
static
function
process_via_cron
(
$vars
)
{
global
$wpdb
;
...
...
@@ -143,6 +143,29 @@ class Delete_All {
exit
;
}
/**
* When a delete is pending for a given post type, hide those posts in the admin
*/
public
static
function
hide_posts_pending_delete
(
$where
,
$q
)
{
if
(
!
is_admin
()
||
!
$q
->
is_main_query
()
)
{
return
$where
;
}
if
(
'edit'
!==
get_current_screen
()
->
base
)
{
return
$where
;
}
if
(
'trash'
!==
$q
->
get
(
'post_status'
)
)
{
return
$where
;
}
if
(
self
::
action_next_scheduled
(
self
::
CRON_EVENT
,
$q
->
get
(
'post_type'
)
)
)
{
$where
.
=
' AND 0=1'
;
}
return
$where
;
}
/**
* Let the user know what's going on
*/
...
...
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