From db7fdcb603569ac3c771ff23400bf6401e29bb7c Mon Sep 17 00:00:00 2001
From: Erick Hitter <git-contrib@ethitter.com>
Date: Thu, 14 Sep 2017 18:37:59 -0700
Subject: [PATCH] Begin moving common bits to a trait

---
 bulk-actions-cron-offload.php   |  1 +
 includes/class-delete-all.php   | 16 +++++++---------
 includes/trait-bulk-actions.php | 28 ++++++++++++++++++++++++++++
 readme.txt                      |  1 +
 4 files changed, 37 insertions(+), 9 deletions(-)
 create mode 100644 includes/trait-bulk-actions.php

diff --git a/bulk-actions-cron-offload.php b/bulk-actions-cron-offload.php
index bea57ae..f3d05fa 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 4bf7231..5eb4ace 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 0000000..f262c55
--- /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 2b3dc8b..c451176 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
-- 
GitLab