Last active
April 24, 2020 00:21
-
-
Save Pebblo/f5d95b5a04077247d3ca97f481a8468d to your computer and use it in GitHub Desktop.
Example of how to add a column that lists the current number of regs vs the total number of spaces currently available on the event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //Please do not include the opening PHP tag if you already have one. | |
//This code adds a column for 'Pending Payment Registrations'. | |
function tw_ee_add_pending_payment_registrations_count_column( $columns, $screen ) { | |
$columns = EEH_Array::insert_into_array( | |
$columns, | |
array( 'registrations_pending_payment' => '<span class="dashicons dashicons-groups ee-icon-color-ee-blue ee-icon-size-20"><span class="screen-reader-text">' . esc_html__('Pending Payment Registrations', 'event_espresso') . '</span></span>' ), | |
'actions' | |
); | |
return $columns; | |
} | |
add_filter( 'FHEE_manage_toplevel_page_espresso_events_columns', 'tw_ee_add_pending_payment_registrations_count_column', 10, 2 ); | |
function tw_ee_add_pending_payment_registrations_count_column_data( $event, $screen ) { | |
if ( ! $event instanceof EE_Event ) { | |
return ''; | |
} | |
$pending_payment_regs = $event->count_related( | |
'Registration', | |
array( | |
array( | |
'REG_deleted' => 0, | |
'STS_ID' => EEM_Registration::status_id_pending_payment, | |
), | |
) | |
); | |
echo $pending_payment_regs; | |
} | |
add_action( 'AHEE__EE_Admin_List_Table__column_registrations_pending_payment__toplevel_page_espresso_events', 'tw_ee_add_pending_payment_registrations_count_column_data', 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //Please do not include the opening PHP tag if you already have one. | |
//This code adds an additional column 'Regs sold/total'. | |
function tw_ee_add_registrations_sold_total_column( $columns, $screen ) { | |
$columns = EEH_Array::insert_into_array( | |
$columns, | |
array( 'registrations_sold_total' => 'Regs sold/total' ), | |
'actions' | |
); | |
return $columns; | |
} | |
add_filter( 'FHEE_manage_toplevel_page_espresso_events_columns', 'tw_ee_add_registrations_sold_total_column', 10, 2 ); | |
function tw_ee_add_registrations_sold_total_column_data( $event, $screen ) { | |
if ( ! $event instanceof EE_Event ) { | |
return ''; | |
} | |
$registered_attendees = EEM_Registration::instance()->get_event_registration_count($event->ID()); | |
$total_spaces = $event->total_available_spaces() == EE_INF ? '∞' : $event->total_available_spaces(); | |
echo $registered_attendees . '/' . $total_spaces; | |
} | |
add_action( 'AHEE__EE_Admin_List_Table__column_registrations_sold_total__toplevel_page_espresso_events', 'tw_ee_add_registrations_sold_total_column_data', 10, 2 ); | |
// Add some CSS to style the column | |
add_action( 'admin_enqueue_scripts', 'tw_ee_custom_events_columns', 20 ); | |
function tw_ee_custom_events_columns() { | |
$css = | |
'#Extend_Events_Admin_List_Table-table-frm .column-registrations_sold_total { | |
width: 10%; | |
}'; | |
wp_add_inline_style('events-admin-css', $css); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment