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

Move another common function to the trait

parent c1959f2c
No related branches found
No related tags found
No related merge requests found
......@@ -55,34 +55,6 @@ class Custom_Action {
do_action( 'bulk_actions_cron_offload_custom_request_completed', $results, $vars );
}
/**
* Let the user know what's going on
*
* Not used for post-request redirect
*/
public static function admin_notices() {
$screen = get_current_screen();
$type = '';
$message = '';
if ( 'edit' === $screen->base ) {
if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) {
return;
}
$status = isset( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
$pending = Main::get_post_ids_for_pending_events( self::ACTION, $screen->post_type, $status );
if ( ! empty( $pending ) ) {
$type = 'warning';
$message = __( 'Some items that would normally be shown here are waiting to be processed. These items are hidden until processing completes.', 'bulk-actions-cron-offload' );
}
}
Main::render_admin_notice( $type, $message );
}
/**
* Provide post-redirect success message
*
......@@ -101,6 +73,15 @@ class Custom_Action {
return __( 'The requested processing is already pending for the chosen posts.', 'bulk-actions-cron-offload' );
}
/**
* Provide message when posts are hidden pending processing
*
* @return string
*/
public static function admin_notice_hidden_pending_processing() {
return __( 'Some items that would normally be shown here are waiting to be processed. These items are hidden until processing completes.', 'bulk-actions-cron-offload' );
}
/**
* When an edit is pending for a given post type, hide those posts in the admin
*
......
......@@ -75,34 +75,6 @@ class Edit {
do_action( 'bulk_actions_cron_offload_edit_request_completed', $results, $vars );
}
/**
* Let the user know what's going on
*
* Not used for post-request redirect
*/
public static function admin_notices() {
$screen = get_current_screen();
$type = '';
$message = '';
if ( 'edit' === $screen->base ) {
if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) {
return;
}
$status = isset( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
$pending = Main::get_post_ids_for_pending_events( self::ACTION, $screen->post_type, $status );
if ( ! empty( $pending ) ) {
$type = 'warning';
$message = __( 'Some items that would normally be shown here are waiting to be edited. These items are hidden until they are processed.', 'bulk-actions-cron-offload' );
}
}
Main::render_admin_notice( $type, $message );
}
/**
* Provide post-redirect success message
*
......@@ -121,6 +93,15 @@ class Edit {
return __( 'The requested edits are already pending for the chosen posts.', 'bulk-actions-cron-offload' );
}
/**
* Provide notice when posts are hidden pending edits
*
* @return string
*/
public static function admin_notice_hidden_pending_processing() {
return __( 'Some items that would normally be shown here are waiting to be edited. These items are hidden until they are processed.', 'bulk-actions-cron-offload' );
}
/**
* When an edit is pending for a given post type, hide those posts in the admin
*
......
......@@ -67,6 +67,34 @@ trait Bulk_Actions {
self::admin_notices();
}
/**
* Let the user know what's going on
*
* Not used for post-request redirect
*/
public static function admin_notices() {
$screen = get_current_screen();
$type = '';
$message = '';
if ( 'edit' === $screen->base ) {
if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) {
return;
}
$status = isset( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
$pending = Main::get_post_ids_for_pending_events( self::ACTION, $screen->post_type, $status );
if ( ! empty( $pending ) ) {
$type = 'warning';
$message = self::admin_notice_hidden_pending_processing();
}
}
Main::render_admin_notice( $type, $message );
}
/**
* Provide translated success message for bulk action
*
......@@ -85,6 +113,15 @@ trait Bulk_Actions {
return '';
}
/**
* Provide translated message when posts are hidden pending processing
*
* @return string
*/
public static function admin_notice_hidden_pending_processing() {
return '';
}
/**
* When an edit is pending for a given post type, hide those posts in the admin
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment