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

Bail if nothing is chosen

parent 5682cb33
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,11 @@ class Main { ...@@ -16,6 +16,11 @@ class Main {
*/ */
const ACTION = 'bulk_actions_cron_offload_'; const ACTION = 'bulk_actions_cron_offload_';
/**
* Generic admin notices
*/
const ADMIN_NOTICE_KEY = 'bulk_actions_cron_offload_general';
/** /**
* Common cron action * Common cron action
*/ */
...@@ -28,6 +33,8 @@ class Main { ...@@ -28,6 +33,8 @@ class Main {
add_action( self::CRON_EVENT, array( __CLASS__, 'do_cron' ) ); add_action( self::CRON_EVENT, array( __CLASS__, 'do_cron' ) );
add_action( 'load-edit.php', array( __CLASS__, 'intercept' ) ); add_action( 'load-edit.php', array( __CLASS__, 'intercept' ) );
add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) );
} }
/** /**
...@@ -59,6 +66,11 @@ class Main { ...@@ -59,6 +66,11 @@ class Main {
return; return;
} }
// Nothing to do.
if ( empty( $vars->posts ) ) {
self::do_admin_redirect( self::ADMIN_NOTICE_KEY, false );
}
// Pass request to a class to handle offloading to cron, UX, etc. // Pass request to a class to handle offloading to cron, UX, etc.
do_action( $action, $vars ); do_action( $action, $vars );
...@@ -207,6 +219,15 @@ class Main { ...@@ -207,6 +219,15 @@ class Main {
return in_array( $action, $allowed_actions, true ); return in_array( $action, $allowed_actions, true );
} }
/**
* Let the user know what's going on
*/
public static function admin_notices() {
if ( isset( $_REQUEST[ self::ADMIN_NOTICE_KEY ] ) && '-1' === $_REQUEST[ self::ADMIN_NOTICE_KEY ] ) {
self::render_admin_notice( 'error', __( 'The requested bulk action was not processed because no posts were selected.', 'bulk-actions-cron-offload' ) );
}
}
/** /**
* Build a WP hook specific to a bulk request * Build a WP hook specific to a bulk request
* *
......
...@@ -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-14 22:18:30+00:00\n" "POT-Creation-Date: 2017-09-15 00:51:21+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"
...@@ -65,6 +65,10 @@ msgid "" ...@@ -65,6 +65,10 @@ msgid ""
"These items are hidden until they are processed." "These items are hidden until they are processed."
msgstr "" msgstr ""
#: includes/class-main.php:227
msgid "The requested bulk action was not processed because no posts were selected."
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 ""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment