diff --git a/bulk-actions-cron-offload.php b/bulk-actions-cron-offload.php index 3431ffc4018ccd93fa16049198f606d4f01d7212..1565e26a7d8e0c0e339cd4088a3e024e7063873d 100644 --- a/bulk-actions-cron-offload.php +++ b/bulk-actions-cron-offload.php @@ -15,6 +15,7 @@ namespace Automattic\WP\Bulk_Actions_Cron_Offload; // Plugin dependencies. +require __DIR__ . '/includes/trait-remove-one-time-args.php'; require __DIR__ . '/includes/trait-bulk-actions.php'; require __DIR__ . '/includes/utils.php'; diff --git a/includes/class-main.php b/includes/class-main.php index 1eb93b196d2dc14f19ed722103188d54a2a84553..8a24a431654e704297dd72d1d99705a71b0ab496 100644 --- a/includes/class-main.php +++ b/includes/class-main.php @@ -11,6 +11,11 @@ namespace Automattic\WP\Bulk_Actions_Cron_Offload; * Class Main */ class Main { + /** + * Strip notice arguments after the initial redirect + */ + use Remove_One_Time_Args; + /** * Prefix for bulk-process hook invoked by request-specific classes */ @@ -36,6 +41,7 @@ class Main { add_action( 'load-edit.php', array( __CLASS__, 'intercept' ) ); add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) ); + add_filter( 'removable_query_args', array( __CLASS__, 'remove_notice_arg' ) ); } /** diff --git a/includes/trait-bulk-actions.php b/includes/trait-bulk-actions.php index a504c2bfe4ec5fb9b249743ef2495a7cbf3280f5..a5d99c6d3689c0a27d288923ea3ab410be80fe42 100644 --- a/includes/trait-bulk-actions.php +++ b/includes/trait-bulk-actions.php @@ -11,6 +11,11 @@ namespace Automattic\WP\Bulk_Actions_Cron_Offload; * Trait Bulk_Actions */ trait Bulk_Actions { + /** + * Strip notice arguments after the initial redirect + */ + use Remove_One_Time_Args; + /** * Register this bulk process' hooks */ @@ -174,16 +179,4 @@ trait Bulk_Actions { return $where; } - - /** - * Strip the custom notice key, otherwise it turns up in pagination and other unwanted places. - * - * @param array $args Array of one-time query args. - * @return array - */ - public static function remove_notice_arg( $args ) { - $args[] = self::ADMIN_NOTICE_KEY; - - return $args; - } } diff --git a/includes/trait-remove-one-time-args.php b/includes/trait-remove-one-time-args.php new file mode 100644 index 0000000000000000000000000000000000000000..547dc3f84d6d184120133820388327039a553cd8 --- /dev/null +++ b/includes/trait-remove-one-time-args.php @@ -0,0 +1,25 @@ +<?php +/** + * Strip one-time arguments after redirects + * + * @package Bulk_Actions_Cron_Offload + */ + +namespace Automattic\WP\Bulk_Actions_Cron_Offload; + +/** + * Trait Remove_One_Time_Args + */ +trait Remove_One_Time_Args { + /** + * Strip the custom notice key, otherwise it turns up in pagination and other unwanted places. + * + * @param array $args Array of one-time query args. + * @return array + */ + public static function remove_notice_arg( $args ) { + $args[] = self::ADMIN_NOTICE_KEY; + + return $args; + } +}