Advertisement
eventsmanager

Add new action link to Admin Booking Table Summary

Oct 9th, 2013
781
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.23 KB | None | 0 0
  1. <?php
  2. /*
  3.  * This snippet will add new action link at Events > Bookings
  4. * @param action array  $booking_actions
  5. * @param EM_Booking $EM_Booking
  6. */
  7. function em_mod_booking_resend($booking_actions, $EM_Booking){
  8.     $url = $EM_Booking->get_event()->get_bookings_url();
  9.     $booking_actions['send_email'] = '<a class="em-bookings-resend_email" href="'.em_add_get_params($url, array('action'=>'mod_booking_resend_email', 'booking_id'=>$EM_Booking->booking_id)).'">'.__('Re-send Email','dbem').'</a>';
  10.     return $booking_actions;
  11. }
  12. add_filter('em_bookings_table_cols_col_action','em_mod_booking_resend',10,2);
  13.  
  14.  
  15. /*
  16.  * This snippet will be responsible for handling request to re-send Booking Emails
  17. * based on the status of the event.
  18. */
  19. function em_mod_booking_resend_action(){
  20.     global $wpdb, $EM_Event, $EM_Booking, $EM_Notices;
  21.     if ( !empty($_REQUEST['action']) && $_REQUEST['action'] == 'mod_booking_resend_email' ){
  22.         if( $EM_Booking->can_manage('manage_bookings','manage_others_bookings') ){
  23.             if( $EM_Booking->email(false, true) ){
  24.                 if( $EM_Booking->mails_sent > 0 ) {
  25.                     $EM_Notices->add_confirm( __('Email Sent.','dbem'), true );
  26.                 }else{
  27.                     $EM_Notices->add_confirm( _x('No emails to send for this booking.', 'bookings', 'dbem'), true );
  28.                 }
  29.                 $redirect = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : wp_get_referer();
  30.                 wp_redirect( $redirect );
  31.                 exit();
  32.             }else{
  33.                 $result = false;
  34.                 $EM_Notices->add_error( __('ERROR : Email Not Sent.','dbem') );
  35.                 $feedback = $EM_Booking->feedback_message;
  36.             }
  37.         }
  38.     }
  39.  
  40. }
  41. add_action('init','em_mod_booking_resend_action',11);
  42.  
  43. /*
  44.  * This snippet will override the booking email templates
  45.  *
  46.  * Status:
  47.  * 0 = Pending
  48.  * 1 = Approved
  49.  * 2 = Rejected
  50.  * 3 = Cancelled
  51.  * 4 = Awaiting Online Payment
  52.  * 5 = Awaiting Payment
  53.  *
  54.  * eg.
  55.  * if ( $EM_Booking->get_status() == 0 ) {} // for Pending bookings
  56.  * if ( $EM_Booking->get_status() == 1 ) {} // for Approved bookings
  57.  *
  58.  */
  59. function my_event_messages( $msg, $EM_Booking ){
  60.     if ( $EM_Booking->get_status() == 0 ) {
  61.         $msg['user']['subject'] = 'New Subject';
  62.         $msg['user']['body'] = 'New email body';
  63.     }
  64.     return $msg;
  65. }
  66.  
  67. add_filter('em_booking_email_messages','my_event_messages',10,2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement