From a240b5f4f779ef7ce575ce6a1bada6bc8d104619 Mon Sep 17 00:00:00 2001 From: savvasha Date: Tue, 22 Dec 2020 07:07:00 +0200 Subject: [PATCH] Add bulk action to set events status On Time --- modules/sportspress-bulk-actions.php | 39 +++++++++++++++++++--------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/modules/sportspress-bulk-actions.php b/modules/sportspress-bulk-actions.php index 985ee569..f50edd77 100644 --- a/modules/sportspress-bulk-actions.php +++ b/modules/sportspress-bulk-actions.php @@ -97,6 +97,7 @@ class SportsPress_Bulk_Actions { public function event_actions( $bulk_actions ) { $bulk_actions['sp_postpone'] = __( 'Postpone events', 'sportspress' ); $bulk_actions['sp_cancel'] = __( 'Cancel events', 'sportspress' ); + $bulk_actions['sp_ok'] = __( 'Set events On Time', 'sportspress' ); return $bulk_actions; } @@ -104,21 +105,26 @@ class SportsPress_Bulk_Actions { * Handle form submission for event bulk actions. */ public function event_actions_handler( $redirect_to, $doaction, $post_ids ) { - if ( ! in_array( $doaction, array( 'sp_postpone', 'sp_cancel' ) ) ) { + if ( ! in_array( $doaction, array( 'sp_postpone', 'sp_cancel', 'sp_ok' ) ) ) { return $redirect_to; } - if ( 'sp_postpone' == $doaction ) { - foreach ( $post_ids as $post_id ) { - update_post_meta( $post_id, 'sp_status', 'postponed' ); - } - $redirect_to = add_query_arg( 'sp_bulk_postponed_events', count( $post_ids ), $redirect_to ); - } elseif ( 'sp_cancel' == $doaction ) { - foreach ( $post_ids as $post_id ) { - update_post_meta( $post_id, 'sp_status', 'cancelled' ); - } - $redirect_to = add_query_arg( 'sp_bulk_cancelled_events', count( $post_ids ), $redirect_to ); - } + if ( 'sp_postpone' == $doaction ) { + foreach ( $post_ids as $post_id ) { + update_post_meta( $post_id, 'sp_status', 'postponed' ); + } + $redirect_to = add_query_arg( 'sp_bulk_postponed_events', count( $post_ids ), $redirect_to ); + } elseif ( 'sp_cancel' == $doaction ) { + foreach ( $post_ids as $post_id ) { + update_post_meta( $post_id, 'sp_status', 'cancelled' ); + } + $redirect_to = add_query_arg( 'sp_bulk_cancelled_events', count( $post_ids ), $redirect_to ); + } elseif ( 'sp_ok' == $doaction ) { + foreach ( $post_ids as $post_id ) { + update_post_meta( $post_id, 'sp_status', 'ok' ); + } + $redirect_to = add_query_arg( 'sp_bulk_ok_events', count( $post_ids ), $redirect_to ); + } return $redirect_to; } @@ -154,6 +160,15 @@ class SportsPress_Bulk_Actions { $count, 'sportspress' ) . '

', $count ); + } elseif ( ! empty( $_REQUEST['sp_bulk_ok_events'] ) ) { + $count = intval( $_REQUEST['sp_bulk_ok_events'] ); + + printf( '

' . + _n( 'Set %s event as On Time.', + 'Set %s event as On Time.', + $count, + 'sportspress' + ) . '

', $count ); } } }