Skip to content
Snippets Groups Projects
Commit cbbf536b authored by Erick Hitter's avatar Erick Hitter
Browse files

Split post-redirect notices from the bits that are specific to the action

parent fbd89188
No related branches found
No related tags found
No related merge requests found
...@@ -108,6 +108,8 @@ class Delete_All { ...@@ -108,6 +108,8 @@ class Delete_All {
/** /**
* Let the user know what's going on * Let the user know what's going on
*
* Not used for post-request redirect
*/ */
public static function admin_notices() { public static function admin_notices() {
$screen = get_current_screen(); $screen = get_current_screen();
...@@ -115,15 +117,7 @@ class Delete_All { ...@@ -115,15 +117,7 @@ class Delete_All {
$type = ''; $type = '';
$message = ''; $message = '';
if ( isset( $_REQUEST[ self::ADMIN_NOTICE_KEY ] ) ) { if ( 'edit' === $screen->base && isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) {
if ( 1 === (int) $_REQUEST[ self::ADMIN_NOTICE_KEY ] ) {
$type = 'success';
$message = __( 'Success! The trash will be emptied shortly.', 'bulk-actions-cron-offload' );
} else {
$type = 'error';
$message = __( 'A request to empty the trash is already pending for this post type.', 'bulk-actions-cron-offload' );
}
} elseif ( 'edit' === $screen->base && isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) {
if ( Main::get_action_next_scheduled( self::ACTION, $screen->post_type ) ) { if ( Main::get_action_next_scheduled( self::ACTION, $screen->post_type ) ) {
$type = 'warning'; $type = 'warning';
$message = __( 'A pending request to empty the trash will be processed soon.', 'bulk-actions-cron-offload' ); $message = __( 'A pending request to empty the trash will be processed soon.', 'bulk-actions-cron-offload' );
...@@ -133,6 +127,24 @@ class Delete_All { ...@@ -133,6 +127,24 @@ class Delete_All {
Main::render_admin_notice( $type, $message ); Main::render_admin_notice( $type, $message );
} }
/**
* Provide post-redirect success message
*
* @retun string
*/
public static function admin_notice_success_message() {
return __( 'Success! The trash will be emptied shortly.', 'bulk-actions-cron-offload' );
}
/**
* Provide post-redirect error message
*
* @retun string
*/
public static function admin_notice_error_message() {
return __( 'A request to empty the trash is already pending for this post type.', 'bulk-actions-cron-offload' );
}
/** /**
* When a delete is pending for a given post type, hide those posts in the admin * When a delete is pending for a given post type, hide those posts in the admin
* *
......
...@@ -76,6 +76,8 @@ class Delete_Permanently { ...@@ -76,6 +76,8 @@ class Delete_Permanently {
/** /**
* Let the user know what's going on * Let the user know what's going on
*
* Not used for post-request redirect
*/ */
public static function admin_notices() { public static function admin_notices() {
$screen = get_current_screen(); $screen = get_current_screen();
...@@ -83,15 +85,7 @@ class Delete_Permanently { ...@@ -83,15 +85,7 @@ class Delete_Permanently {
$type = ''; $type = '';
$message = ''; $message = '';
if ( isset( $_REQUEST[ self::ADMIN_NOTICE_KEY ] ) ) { if ( 'edit' === $screen->base && isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) {
if ( 1 === (int) $_REQUEST[ self::ADMIN_NOTICE_KEY ] ) {
$type = 'success';
$message = __( 'Success! The selected posts will be deleted shortly.', 'bulk-actions-cron-offload' );
} else {
$type = 'error';
$message = __( 'The selected posts are already scheduled to be deleted.', 'bulk-actions-cron-offload' );
}
} elseif ( 'edit' === $screen->base && isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) {
if ( Main::get_post_ids_for_pending_events( self::ACTION, $screen->post_type, 'trash' ) ) { if ( Main::get_post_ids_for_pending_events( self::ACTION, $screen->post_type, 'trash' ) ) {
$type = 'warning'; $type = 'warning';
$message = __( 'Some items that would normally be shown here are waiting to be deleted permanently. These items are hidden until then.', 'bulk-actions-cron-offload' ); $message = __( 'Some items that would normally be shown here are waiting to be deleted permanently. These items are hidden until then.', 'bulk-actions-cron-offload' );
...@@ -101,6 +95,24 @@ class Delete_Permanently { ...@@ -101,6 +95,24 @@ class Delete_Permanently {
Main::render_admin_notice( $type, $message ); Main::render_admin_notice( $type, $message );
} }
/**
* Provide post-redirect success message
*
* @retun string
*/
public static function admin_notice_success_message() {
return __( 'Success! The selected posts will be deleted shortly.', 'bulk-actions-cron-offload' );
}
/**
* Provide post-redirect error message
*
* @retun string
*/
public static function admin_notice_error_message() {
return __( 'The selected posts are already scheduled to be deleted.', 'bulk-actions-cron-offload' );
}
/** /**
* When a delete is pending for a given post type, hide those posts in the admin * When a delete is pending for a given post type, hide those posts in the admin
* *
......
...@@ -77,6 +77,8 @@ class Edit { ...@@ -77,6 +77,8 @@ class Edit {
/** /**
* Let the user know what's going on * Let the user know what's going on
*
* Not used for post-request redirect
*/ */
public static function admin_notices() { public static function admin_notices() {
$screen = get_current_screen(); $screen = get_current_screen();
...@@ -84,15 +86,7 @@ class Edit { ...@@ -84,15 +86,7 @@ class Edit {
$type = ''; $type = '';
$message = ''; $message = '';
if ( isset( $_REQUEST[ self::ADMIN_NOTICE_KEY ] ) ) { if ( 'edit' === $screen->base ) {
if ( 1 === (int) $_REQUEST[ self::ADMIN_NOTICE_KEY ] ) {
$type = 'success';
$message = __( 'Success! The selected posts will be edited shortly.', 'bulk-actions-cron-offload' );
} else {
$type = 'error';
$message = __( 'The requested edits are already pending for the chosen posts.', 'bulk-actions-cron-offload' );
}
} elseif ( 'edit' === $screen->base ) {
if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) { if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) {
return; return;
} }
...@@ -109,6 +103,24 @@ class Edit { ...@@ -109,6 +103,24 @@ class Edit {
Main::render_admin_notice( $type, $message ); Main::render_admin_notice( $type, $message );
} }
/**
* Provide post-redirect success message
*
* @retun string
*/
public static function admin_notice_success_message() {
return __( 'Success! The selected posts will be edited shortly.', 'bulk-actions-cron-offload' );
}
/**
* Provide post-redirect error message
*
* @retun string
*/
public static function admin_notice_error_message() {
return __( 'The requested edits are already pending for the chosen posts.', 'bulk-actions-cron-offload' );
}
/** /**
* When an edit is pending for a given post type, hide those posts in the admin * When an edit is pending for a given post type, hide those posts in the admin
* *
......
...@@ -76,6 +76,8 @@ class Move_To_Trash { ...@@ -76,6 +76,8 @@ class Move_To_Trash {
/** /**
* Let the user know what's going on * Let the user know what's going on
*
* Not used for post-request redirect
*/ */
public static function admin_notices() { public static function admin_notices() {
$screen = get_current_screen(); $screen = get_current_screen();
...@@ -83,15 +85,7 @@ class Move_To_Trash { ...@@ -83,15 +85,7 @@ class Move_To_Trash {
$type = ''; $type = '';
$message = ''; $message = '';
if ( isset( $_REQUEST[ self::ADMIN_NOTICE_KEY ] ) ) { if ( 'edit' === $screen->base ) {
if ( 1 === (int) $_REQUEST[ self::ADMIN_NOTICE_KEY ] ) {
$type = 'success';
$message = __( 'Success! The selected posts will be moved to the trash shortly.', 'bulk-actions-cron-offload' );
} else {
$type = 'error';
$message = __( 'The selected posts are already scheduled to be moved to the trash.', 'bulk-actions-cron-offload' );
}
} elseif ( 'edit' === $screen->base ) {
if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) { if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) {
return; return;
} }
...@@ -108,6 +102,24 @@ class Move_To_Trash { ...@@ -108,6 +102,24 @@ class Move_To_Trash {
Main::render_admin_notice( $type, $message ); Main::render_admin_notice( $type, $message );
} }
/**
* Provide post-redirect success message
*
* @retun string
*/
public static function admin_notice_success_message() {
return __( 'Success! The selected posts will be moved to the trash shortly.', 'bulk-actions-cron-offload' );
}
/**
* Provide post-redirect error message
*
* @return string
*/
public static function admin_notice_error_message() {
return __( 'The selected posts are already scheduled to be moved to the trash.', 'bulk-actions-cron-offload' );
}
/** /**
* When a move is pending for a given post type, hide those posts in the admin * When a move is pending for a given post type, hide those posts in the admin
* *
......
...@@ -76,6 +76,8 @@ class Restore_From_Trash { ...@@ -76,6 +76,8 @@ class Restore_From_Trash {
/** /**
* Let the user know what's going on * Let the user know what's going on
*
* Not used for post-request redirect
*/ */
public static function admin_notices() { public static function admin_notices() {
$screen = get_current_screen(); $screen = get_current_screen();
...@@ -83,15 +85,7 @@ class Restore_From_Trash { ...@@ -83,15 +85,7 @@ class Restore_From_Trash {
$type = ''; $type = '';
$message = ''; $message = '';
if ( isset( $_REQUEST[ self::ADMIN_NOTICE_KEY ] ) ) { if ( 'edit' === $screen->base && isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) {
if ( 1 === (int) $_REQUEST[ self::ADMIN_NOTICE_KEY ] ) {
$type = 'success';
$message = __( 'Success! The selected posts will be restored shortly.', 'bulk-actions-cron-offload' );
} else {
$type = 'error';
$message = __( 'The selected posts are already scheduled to be restored.', 'bulk-actions-cron-offload' );
}
} elseif ( 'edit' === $screen->base && isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) {
if ( Main::get_post_ids_for_pending_events( self::ACTION, $screen->post_type, 'trash' ) ) { if ( Main::get_post_ids_for_pending_events( self::ACTION, $screen->post_type, 'trash' ) ) {
$type = 'warning'; $type = 'warning';
$message = __( 'Some items that would normally be shown here are waiting to be restored from the trash. These items are hidden until they are restored.', 'bulk-actions-cron-offload' ); $message = __( 'Some items that would normally be shown here are waiting to be restored from the trash. These items are hidden until they are restored.', 'bulk-actions-cron-offload' );
...@@ -101,6 +95,24 @@ class Restore_From_Trash { ...@@ -101,6 +95,24 @@ class Restore_From_Trash {
Main::render_admin_notice( $type, $message ); Main::render_admin_notice( $type, $message );
} }
/**
* Provide post-redirect success message
*
* @retun string
*/
public static function admin_notice_success_message() {
return __( 'Success! The selected posts will be restored shortly.', 'bulk-actions-cron-offload' );
}
/**
* Provide post-redirect error message
*
* @retun string
*/
public static function admin_notice_error_message() {
return __( 'The selected posts are already scheduled to be restored.', 'bulk-actions-cron-offload' );
}
/** /**
* When a restore is pending for a given post type, hide those posts in the admin * When a restore is pending for a given post type, hide those posts in the admin
* *
......
...@@ -15,7 +15,7 @@ trait Bulk_Actions { ...@@ -15,7 +15,7 @@ trait Bulk_Actions {
add_action( Main::build_hook( self::ACTION ), array( __CLASS__, 'process' ) ); add_action( Main::build_hook( self::ACTION ), array( __CLASS__, 'process' ) );
add_action( Main::build_cron_hook( self::ACTION ), 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__, 'render_admin_notices' ) );
add_filter( 'posts_where', array( __CLASS__, 'hide_posts' ), 999, 2 ); add_filter( 'posts_where', array( __CLASS__, 'hide_posts' ), 999, 2 );
add_filter( 'removable_query_args', array( __CLASS__, 'remove_notice_arg' ) ); add_filter( 'removable_query_args', array( __CLASS__, 'remove_notice_arg' ) );
...@@ -44,6 +44,44 @@ trait Bulk_Actions { ...@@ -44,6 +44,44 @@ trait Bulk_Actions {
} }
} }
/**
* Render the post-redirect notice, or hand off to class for other notices
*/
public static function render_admin_notices() {
if ( isset( $_REQUEST[ self::ADMIN_NOTICE_KEY ] ) ) {
if ( 1 === (int) $_REQUEST[ self::ADMIN_NOTICE_KEY ] ) {
$type = 'success';
$message = self::admin_notice_success_message();
} else {
$type = 'error';
$message = self::admin_notice_error_message();
}
Main::render_admin_notice( $type, $message );
return;
}
self::admin_notices();
}
/**
* Provide translated success message for bulk action
*
* @return string
*/
public static function admin_notice_success_message() {
return '';
}
/**
* Provide translated error message for bulk action
*
* @return string
*/
public static function admin_notice_error_message() {
return '';
}
/** /**
* When an edit is pending for a given post type, hide those posts in the admin * When an edit is pending for a given post type, hide those posts in the admin
* *
......
...@@ -5,7 +5,7 @@ msgstr "" ...@@ -5,7 +5,7 @@ msgstr ""
"Project-Id-Version: Bulk Actions Cron Offload 1.0\n" "Project-Id-Version: Bulk Actions Cron Offload 1.0\n"
"Report-Msgid-Bugs-To: " "Report-Msgid-Bugs-To: "
"https://wordpress.org/support/plugin/bulk-actions-cron-offload\n" "https://wordpress.org/support/plugin/bulk-actions-cron-offload\n"
"POT-Creation-Date: 2017-09-15 00:51:21+00:00\n" "POT-Creation-Date: 2017-09-15 02:51:23+00:00\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n" "Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
...@@ -26,77 +26,77 @@ msgstr "" ...@@ -26,77 +26,77 @@ msgstr ""
"X-Textdomain-Support: yes\n" "X-Textdomain-Support: yes\n"
#: includes/class-delete-all.php:123 #: includes/class-delete-all.php:123
msgid "A pending request to empty the trash will be processed soon."
msgstr ""
#: includes/class-delete-all.php:136
msgid "Success! The trash will be emptied shortly." msgid "Success! The trash will be emptied shortly."
msgstr "" msgstr ""
#: includes/class-delete-all.php:126 #: includes/class-delete-all.php:145
msgid "A request to empty the trash is already pending for this post type." msgid "A request to empty the trash is already pending for this post type."
msgstr "" msgstr ""
#: includes/class-delete-all.php:131 #: includes/class-delete-permanently.php:91
msgid "A pending request to empty the trash will be processed soon." msgid ""
"Some items that would normally be shown here are waiting to be deleted "
"permanently. These items are hidden until then."
msgstr "" msgstr ""
#: includes/class-delete-permanently.php:111 #: includes/class-delete-permanently.php:104
msgid "Success! The selected posts will be deleted shortly." msgid "Success! The selected posts will be deleted shortly."
msgstr "" msgstr ""
#: includes/class-delete-permanently.php:114 #: includes/class-delete-permanently.php:113
msgid "The selected posts are already scheduled to be deleted." msgid "The selected posts are already scheduled to be deleted."
msgstr "" msgstr ""
#: includes/class-delete-permanently.php:119 #: includes/class-edit.php:99
msgid "" msgid ""
"Some items that would normally be shown here are waiting to be deleted " "Some items that would normally be shown here are waiting to be edited. "
"permanently. These items are hidden until then." "These items are hidden until they are processed."
msgstr "" msgstr ""
#: includes/class-edit.php:112 #: includes/class-edit.php:112
msgid "Success! The selected posts will be edited shortly." msgid "Success! The selected posts will be edited shortly."
msgstr "" msgstr ""
#: includes/class-edit.php:115 #: includes/class-edit.php:121
msgid "The requested edits are already pending for the chosen posts." msgid "The requested edits are already pending for the chosen posts."
msgstr "" msgstr ""
#: includes/class-edit.php:127
msgid ""
"Some items that would normally be shown here are waiting to be edited. "
"These items are hidden until they are processed."
msgstr ""
#: includes/class-main.php:227 #: includes/class-main.php:227
msgid "The requested bulk action was not processed because no posts were selected." msgid "The requested bulk action was not processed because no posts were selected."
msgstr "" msgstr ""
#: includes/class-move-to-trash.php:98
msgid ""
"Some items that would normally be shown here are waiting to be moved to the "
"trash. These items are hidden until they are moved."
msgstr ""
#: includes/class-move-to-trash.php:111 #: includes/class-move-to-trash.php:111
msgid "Success! The selected posts will be moved to the trash shortly." msgid "Success! The selected posts will be moved to the trash shortly."
msgstr "" msgstr ""
#: includes/class-move-to-trash.php:114 #: includes/class-move-to-trash.php:120
msgid "The selected posts are already scheduled to be moved to the trash." msgid "The selected posts are already scheduled to be moved to the trash."
msgstr "" msgstr ""
#: includes/class-move-to-trash.php:126 #: includes/class-restore-from-trash.php:91
msgid "" msgid ""
"Some items that would normally be shown here are waiting to be moved to the " "Some items that would normally be shown here are waiting to be restored "
"trash. These items are hidden until they are moved." "from the trash. These items are hidden until they are restored."
msgstr "" msgstr ""
#: includes/class-restore-from-trash.php:111 #: includes/class-restore-from-trash.php:104
msgid "Success! The selected posts will be restored shortly." msgid "Success! The selected posts will be restored shortly."
msgstr "" msgstr ""
#: includes/class-restore-from-trash.php:114 #: includes/class-restore-from-trash.php:113
msgid "The selected posts are already scheduled to be restored." msgid "The selected posts are already scheduled to be restored."
msgstr "" msgstr ""
#: includes/class-restore-from-trash.php:119
msgid ""
"Some items that would normally be shown here are waiting to be restored "
"from the trash. These items are hidden until they are restored."
msgstr ""
#. Plugin Name of the plugin/theme #. Plugin Name of the plugin/theme
msgid "Bulk Actions Cron Offload" msgid "Bulk Actions Cron Offload"
msgstr "" msgstr ""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment