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

Begin moving common bits to a trait

parent 228c30ff
Branches
No related tags found
No related merge requests found
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
namespace Automattic\WP\Bulk_Actions_Cron_Offload; namespace Automattic\WP\Bulk_Actions_Cron_Offload;
// Plugin dependencies. // Plugin dependencies.
require __DIR__ . '/includes/trait-bulk-actions.php';
require __DIR__ . '/includes/utils.php'; require __DIR__ . '/includes/utils.php';
// Plugin functionality. // Plugin functionality.
......
...@@ -11,6 +11,11 @@ namespace Automattic\WP\Bulk_Actions_Cron_Offload; ...@@ -11,6 +11,11 @@ namespace Automattic\WP\Bulk_Actions_Cron_Offload;
* Class Delete_All * Class Delete_All
*/ */
class Delete_All { class Delete_All {
/**
* Common hooks and such
*/
use Bulk_Actions;
/** /**
* Class constants * Class constants
*/ */
...@@ -19,16 +24,9 @@ class Delete_All { ...@@ -19,16 +24,9 @@ class Delete_All {
const ADMIN_NOTICE_KEY = 'bulk_actions_cron_offload_deleted_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() { public static function register_extra_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.
add_action( 'load-edit.php', function() { add_action( 'load-edit.php', function() {
add_filter( 'map_meta_cap', array( __CLASS__, 'hide_empty_trash_pending_delete' ), 10, 2 ); add_filter( 'map_meta_cap', array( __CLASS__, 'hide_empty_trash_pending_delete' ), 10, 2 );
} ); } );
......
<?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() {}
}
...@@ -3,6 +3,7 @@ Contributors: ethitter, automattic ...@@ -3,6 +3,7 @@ Contributors: ethitter, automattic
Tags: cron, bulk edit, bulk actions Tags: cron, bulk edit, bulk actions
Requires at least: 4.8.1 Requires at least: 4.8.1
Tested up to: 4.9 Tested up to: 4.9
Required PHP: 5.4
Stable tag: 1.0 Stable tag: 1.0
License: GPLv2 or later License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html License URI: http://www.gnu.org/licenses/gpl-2.0.html
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment