Created
December 14, 2022 12:33
-
-
Save Pebblo/b5609caedb245c43089c86eb47baec18 to your computer and use it in GitHub Desktop.
An example of how you can add a 'Featured Image' column to the Event Espresso -> Events list table.
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 //Do not include the opening PHP tag if you already have one | |
//Add the featured image column | |
function tw_ee_add_event_feature_image_column( $columns, $screen ) { | |
$columns = EEH_Array::insert_into_array( | |
$columns, | |
array( 'event_feature_image' => 'Feature Image' ), | |
'name' | |
); | |
return $columns; | |
} | |
add_filter( 'FHEE_manage_toplevel_page_espresso_events_columns', 'tw_ee_add_event_feature_image_column', 10, 2 ); | |
// Display the featured image. | |
function tw_ee_add_event_feature_image_column_output( $event, $screen ) { | |
if ( ! $event instanceof EE_Event ) { | |
return ''; | |
} | |
echo get_the_post_thumbnail( $event->ID(), 'thumbnail'); | |
} | |
add_action( 'AHEE__EE_Admin_List_Table__column_event_feature_image__toplevel_page_espresso_events', 'tw_ee_add_event_feature_image_column_output', 10, 2 ); | |
// Add CSS to the events admin for the feature image column width. | |
function tw_ee_custom_events_columns() { | |
$css = | |
'#Extend_Events_Admin_List_Table-table-frm .column-event_feature_image { | |
width: 10%; | |
}'; | |
wp_add_inline_style('events-admin-css', $css); | |
} | |
add_action( 'admin_enqueue_scripts', 'tw_ee_custom_events_columns', 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment