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

Reduce duplication

parent 3f98b389
No related branches found
No related tags found
No related merge requests found
...@@ -14,14 +14,16 @@ class Delete_All { ...@@ -14,14 +14,16 @@ class Delete_All {
/** /**
* Class constants * Class constants
*/ */
const ACTION = 'delete_all';
const ADMIN_NOTICE_KEY = 'bulk_edit_cron_offload_deleted_all'; const ADMIN_NOTICE_KEY = 'bulk_edit_cron_offload_deleted_all';
/** /**
* Register this bulk process' hooks * Register this bulk process' hooks
*/ */
public static function register_hooks() { public static function register_hooks() {
add_action( Main::build_hook( 'delete_all' ), array( __CLASS__, 'process' ) ); add_action( Main::build_hook( self::ACTION ), array( __CLASS__, 'process' ) );
add_action( Main::build_cron_hook( 'delete_all' ), array( __CLASS__, 'process_via_cron' ) ); add_action( Main::build_cron_hook( self::ACTION ), array( __CLASS__, 'process_via_cron' ) );
add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) ); add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) );
add_filter( 'posts_where', array( __CLASS__, 'hide_posts_pending_delete' ), 999, 2 ); add_filter( 'posts_where', array( __CLASS__, 'hide_posts_pending_delete' ), 999, 2 );
...@@ -39,7 +41,7 @@ class Delete_All { ...@@ -39,7 +41,7 @@ class Delete_All {
*/ */
public static function process( $vars ) { public static function process( $vars ) {
// Special keys are used to trigger this request, and we need to remove them on redirect. // Special keys are used to trigger this request, and we need to remove them on redirect.
$extra_keys = array( 'delete_all', 'delete_all2' ); $extra_keys = array( self::ACTION, self::ACTION . '2' );
$action_scheduled = self::action_next_scheduled( $vars->post_type ); $action_scheduled = self::action_next_scheduled( $vars->post_type );
...@@ -224,7 +226,7 @@ class Delete_All { ...@@ -224,7 +226,7 @@ class Delete_All {
foreach ( $action_instances as $instance => $instance_args ) { foreach ( $action_instances as $instance => $instance_args ) {
$vars = array_shift( $instance_args['args'] ); $vars = array_shift( $instance_args['args'] );
if ( 'delete_all' === $vars->action && $post_type === $vars->post_type ) { if ( self::ACTION === $vars->action && $post_type === $vars->post_type ) {
return array( return array(
'timestamp' => $timestamp, 'timestamp' => $timestamp,
'args' => $vars, 'args' => $vars,
......
...@@ -14,14 +14,16 @@ class Move_To_Trash { ...@@ -14,14 +14,16 @@ class Move_To_Trash {
/** /**
* Class constants * Class constants
*/ */
const ACTION = 'trash';
const ADMIN_NOTICE_KEY = 'bulk_edit_cron_offload_move_to_trash'; const ADMIN_NOTICE_KEY = 'bulk_edit_cron_offload_move_to_trash';
/** /**
* Register this bulk process' hooks * Register this bulk process' hooks
*/ */
public static function register_hooks() { public static function register_hooks() {
add_action( Main::build_hook( 'trash' ), array( __CLASS__, 'process' ) ); add_action( Main::build_hook( self::ACTION ), array( __CLASS__, 'process' ) );
add_action( Main::build_cron_hook( 'trash' ), array( __CLASS__, 'process_via_cron' ) ); add_action( Main::build_cron_hook( self::ACTION ), array( __CLASS__, 'process_via_cron' ) );
add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) ); add_action( 'admin_notices', array( __CLASS__, 'admin_notices' ) );
add_filter( 'posts_where', array( __CLASS__, 'hide_posts_pending_move' ), 999, 2 ); add_filter( 'posts_where', array( __CLASS__, 'hide_posts_pending_move' ), 999, 2 );
...@@ -187,7 +189,7 @@ class Move_To_Trash { ...@@ -187,7 +189,7 @@ class Move_To_Trash {
foreach ( $action_instances as $instance => $instance_args ) { foreach ( $action_instances as $instance => $instance_args ) {
$vars = array_shift( $instance_args['args'] ); $vars = array_shift( $instance_args['args'] );
if ( 'trash' === $vars->action && $post_type === $vars->post_type ) { if ( self::ACTION === $vars->action && $post_type === $vars->post_type ) {
if ( $post_status === $vars->post_status || 'all' === $vars->post_status || 'all' === $post_status ) { if ( $post_status === $vars->post_status || 'all' === $vars->post_status || 'all' === $post_status ) {
$ids[] = array( $ids[] = array(
'timestamp' => $timestamp, 'timestamp' => $timestamp,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment