Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sjaved87/75dff81ebeea158bc441 to your computer and use it in GitHub Desktop.
Save sjaved87/75dff81ebeea158bc441 to your computer and use it in GitHub Desktop.
use this mu-plugin to add two seperate buttons for export as paid, not paid and all.
<?php
function wpmu_bookings_export_filter_by_ps($export_data, $event, $booking, $user_data){
//if export all then don't bother.
if(! isset( $_GET['paid'] ) ) return $export_data;
//check if paid event if yes then proceed other wise return.
if ($event->is_premium()) {
$payment_status = $event->user_paid($booking->user_id) ? __('Yes', Eab_EventsHub::TEXT_DOMAIN) : __('No', Eab_EventsHub::TEXT_DOMAIN);
//check what user want paid or not paid.
if ( $_GET['paid'] == 1 ) {
//Check if its paid then send paid one only
if ($payment_status == "Yes") {
return $export_data;
}else {
return '';
}
}else {
//Check if its not paid then send not paid only
if ($payment_status == "Yes") {
return '';
}else {
return $export_data;
}
}
}else {
return $export_data;
}
}
add_filter("eab-exporter-csv-row", "wpmu_bookings_export_filter_by_ps", 10, 4);
function wpmu_admin_inline_js(){
global $post;
//check if its events page. no! then return.
if( 'incsub_event' != get_post_type( $post ) and $_GET['post_type'] == 'incsub_event' ) return;
$event = new Eab_EventModel(get_post($post->ID));
if (!$event->is_premium()) return;
?>
<script type='text/javascript'>
jQuery(document).ready(function($) {
$('#incsub-event-bookings .button').text('Export All');
var $get_url = $('#incsub-event-bookings .button').attr('href');
$('#incsub-event-bookings .button').after('<a class="button" href="'+ $get_url + '&paid=1">Export Paid</a><a class="button" href="'+ $get_url + '&paid=0">Export Not Paid</a>');
});
</script>
<?php }
add_action( 'admin_print_scripts', 'wpmu_admin_inline_js', 100 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment