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
a2c13272
Commit
a2c13272
authored
7 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Standardize admin notice output
parent
2dc9274d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
includes/class-delete-all.php
+7
-13
7 additions, 13 deletions
includes/class-delete-all.php
includes/class-main.php
+33
-13
33 additions, 13 deletions
includes/class-main.php
includes/class-move-to-trash.php
+7
-13
7 additions, 13 deletions
includes/class-move-to-trash.php
with
47 additions
and
39 deletions
includes/class-delete-all.php
+
7
−
13
View file @
a2c13272
...
...
@@ -112,31 +112,25 @@ class Delete_All {
public
static
function
admin_notices
()
{
$screen
=
get_current_screen
();
$type
=
''
;
$message
=
''
;
if
(
isset
(
$_REQUEST
[
self
::
ADMIN_NOTICE_KEY
]
)
)
{
if
(
1
===
(
int
)
$_REQUEST
[
self
::
ADMIN_NOTICE_KEY
]
)
{
$
class
=
'
notice-
success'
;
$
type
=
'success'
;
$message
=
__
(
'Success! The trash will be emptied shortly.'
,
'bulk-edit-cron-offload'
);
}
else
{
$
class
=
'
notice-
error'
;
$
type
=
'error'
;
$message
=
__
(
'A request to empty the trash is already pending for this post type.'
,
'bulk-edit-cron-offload'
);
}
}
elseif
(
'edit'
===
$screen
->
base
&&
isset
(
$_REQUEST
[
'post_status'
]
)
&&
'trash'
===
$_REQUEST
[
'post_status'
]
)
{
if
(
self
::
action_next_scheduled
(
$screen
->
post_type
)
)
{
$
class
=
'
notice-
warning'
;
$
type
=
'warning'
;
$message
=
__
(
'A pending request to empty the trash will be processed soon.'
,
'bulk-edit-cron-offload'
);
}
}
// Nothing to display.
if
(
!
isset
(
$class
)
||
!
isset
(
$message
)
)
{
return
;
}
?>
<div
class=
"notice
<?php
echo
esc_attr
(
$class
);
?>
"
>
<p>
<?php
echo
esc_html
(
$message
);
?>
</p>
</div>
<?php
Main
::
render_admin_notice
(
$type
,
$message
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
includes/class-main.php
+
33
−
13
View file @
a2c13272
...
...
@@ -191,6 +191,25 @@ class Main {
unset
(
$_REQUEST
[
'delete_all2'
]
);
}
/**
* Create cron event
*
* @param object $vars Bulk-request variables.
* @return bool
*/
public
static
function
schedule_processing
(
$vars
)
{
return
false
!==
wp_schedule_single_event
(
time
(),
self
::
CRON_EVENT
,
array
(
$vars
)
);
}
/**
*
* @param object $vars Bulk-request variables.
* @return int
*/
public
static
function
next_scheduled
(
$vars
)
{
return
(
int
)
wp_next_scheduled
(
self
::
CRON_EVENT
,
array
(
$vars
)
);
}
/**
* Redirect, including a flag to indicate if the bulk process was scheduled successfully
*
...
...
@@ -215,22 +234,23 @@ class Main {
}
/**
*
Create cron event
*
Render an admin message of a given type
*
* @param object $vars Bulk-request variables.
* @return bool
* @param string $type Message type.
* @param string $message Message to output.
* @return void
*/
public
static
function
schedule_processing
(
$vars
)
{
return
false
!==
wp_schedule_single_event
(
time
(),
self
::
CRON_EVENT
,
array
(
$vars
)
);
}
public
static
function
render_admin_notice
(
$type
,
$message
)
{
// Lacking what's required.
if
(
empty
(
$type
)
||
empty
(
$message
)
)
{
return
;
}
/**
*
* @param object $vars Bulk-request variables.
* @return int
*/
public
static
function
next_scheduled
(
$vars
)
{
return
(
int
)
wp_next_scheduled
(
self
::
CRON_EVENT
,
array
(
$vars
)
);
?>
<div
class=
"notice
<?php
echo
esc_attr
(
'notice-'
.
$type
);
?>
"
>
<p>
<?php
echo
esc_html
(
$message
);
?>
</p>
</div>
<?php
}
}
...
...
This diff is collapsed.
Click to expand it.
includes/class-move-to-trash.php
+
7
−
13
View file @
a2c13272
...
...
@@ -100,12 +100,15 @@ class Move_To_Trash {
public
static
function
admin_notices
()
{
$screen
=
get_current_screen
();
$type
=
''
;
$message
=
''
;
if
(
isset
(
$_REQUEST
[
self
::
ADMIN_NOTICE_KEY
]
)
)
{
if
(
1
===
(
int
)
$_REQUEST
[
self
::
ADMIN_NOTICE_KEY
]
)
{
$
class
=
'
notice-
success'
;
$
type
=
'success'
;
$message
=
__
(
'Success! The selected posts will be moved to the trash shortly.'
,
'bulk-edit-cron-offload'
);
}
else
{
$
class
=
'
notice-
error'
;
$
type
=
'error'
;
$message
=
__
(
'The selected posts are already scheduled to be moved to the trash.'
,
'bulk-edit-cron-offload'
);
}
}
elseif
(
'edit'
===
$screen
->
base
)
{
...
...
@@ -116,21 +119,12 @@ class Move_To_Trash {
$status
=
isset
(
$_REQUEST
[
'post_status'
]
)
?
$_REQUEST
[
'post_status'
]
:
'all'
;
if
(
self
::
get_all_pending_actions
(
$screen
->
post_type
,
$status
)
)
{
$
class
=
'
notice-
warning'
;
$
type
=
'warning'
;
$message
=
__
(
'Some items that would normally be shown here are waiting to be moved to the trash. These items are hidden until they are moved.'
,
'bulk-edit-cron-offload'
);
}
}
// Nothing to display.
if
(
!
isset
(
$class
)
||
!
isset
(
$message
)
)
{
return
;
}
?>
<div
class=
"notice
<?php
echo
esc_attr
(
$class
);
?>
"
>
<p>
<?php
echo
esc_html
(
$message
);
?>
</p>
</div>
<?php
Main
::
render_admin_notice
(
$type
,
$message
);
}
/**
...
...
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