diff --git a/bulk-actions-cron-offload.php b/bulk-actions-cron-offload.php index bea57ae64b065c754f6cbc76b68bbd2c571b6c4f..f3d05fae4508850319666fc6922f182ebe3d02f4 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-bulk-actions.php'; require __DIR__ . '/includes/utils.php'; // Plugin functionality. diff --git a/includes/class-delete-all.php b/includes/class-delete-all.php index 4bf72316ad2edbb12e83f2f24994a56d952a581b..5eb4ace791590c043140e9e3c23f99024c0801ab 100644 --- a/includes/class-delete-all.php +++ b/includes/class-delete-all.php @@ -11,6 +11,11 @@ namespace Automattic\WP\Bulk_Actions_Cron_Offload; * Class Delete_All */ class Delete_All { + /** + * Common hooks and such + */ + use Bulk_Actions; + /** * Class constants */ @@ -19,16 +24,9 @@ class Delete_All { const ADMIN_NOTICE_KEY = 'bulk_actions_cron_offload_deleted_all'; /** - * Register this bulk process' hooks + * Register this bulk process' custom hooks */ - public static function register_hooks() { - 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( 'admin_notices', array( __CLASS__, 'admin_notices' ) ); - add_filter( 'posts_where', array( __CLASS__, 'hide_posts' ), 999, 2 ); - - // Limit when caps are intercepted, given frequent execution of the `map_meta_cap` filter. + public static function register_extra_hooks() { add_action( 'load-edit.php', function() { add_filter( 'map_meta_cap', array( __CLASS__, 'hide_empty_trash_pending_delete' ), 10, 2 ); } ); diff --git a/includes/trait-bulk-actions.php b/includes/trait-bulk-actions.php new file mode 100644 index 0000000000000000000000000000000000000000..f262c55c6eb4d5c72bc980c686e2ec110f85f9c4 --- /dev/null +++ b/includes/trait-bulk-actions.php @@ -0,0 +1,28 @@ +<?php +/** + * Methods shared across requests + * + * @package Bulk_Actions_Cron_Offload + */ + +namespace Automattic\WP\Bulk_Actions_Cron_Offload; + +trait Bulk_Actions { + /** + * Register this bulk process' hooks + */ + public static function register_hooks() { + 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( 'admin_notices', array( __CLASS__, 'admin_notices' ) ); + add_filter( 'posts_where', array( __CLASS__, 'hide_posts' ), 999, 2 ); + + self::register_extra_hooks(); + } + + /** + * + */ + public static function register_extra_hooks() {} +} diff --git a/readme.txt b/readme.txt index 2b3dc8b9a766dcc27269950f571a5354202485e4..c451176063a7032b7a1c554539a2cd2fa4bedf06 100755 --- a/readme.txt +++ b/readme.txt @@ -3,6 +3,7 @@ Contributors: ethitter, automattic Tags: cron, bulk edit, bulk actions Requires at least: 4.8.1 Tested up to: 4.9 +Required PHP: 5.4 Stable tag: 1.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html