Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Site plugin for blog.mycabcorner.com
- Description: Site specific code for blog.mycabcorner.com
- */
- // Hook into Event Espresso before template_tags is loaded and declared any pluggable functions.
- add_action('AHEE__EE_System__core_loaded_and_ready', 'ee_custom_load_pluggable_functions');
- // Add any plugin functions within this function
- function ee_custom_load_pluggable_functions() {
- // Override espresso_list_of_event_dates
- function espresso_list_of_event_dates( $EVT_ID = FALSE, $dt_frmt = '', $tm_frmt = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE ) {
- $dt_frmt = ! empty( $dt_frmt ) ? $dt_frmt : get_option('date_format');
- $tm_frmt = ! empty( $tm_frmt ) ? $tm_frmt : get_option('time_format');
- $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID ,$show_expired );
- //d( $datetimes );
- if ( is_array( $datetimes ) && ! empty( $datetimes )) {
- global $post;
- $html = $format ? '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul">' : '';
- foreach ( $datetimes as $datetime ) {
- if ( $datetime instanceof EE_Datetime ) {
- if ( $format ) {
- $html .= '<li id="ee-event-datetimes-li-' . $datetime->ID() . '" class="ee-event-datetimes-li">';
- $datetime_name = $datetime->name();
- $html .= ! empty( $datetime_name ) ? '<strong>' . $datetime_name . '</strong>' : '';
- $html .= ! empty( $datetime_name ) && $add_breaks ? '<br />' : '';
- $html .= '<span class="dashicons dashicons-calendar"></span>' . $datetime->date_range( $dt_frmt ) . '';
- if(! get_post_meta( $EVT_ID, 'hide-event-times', true ) ) {
- $html .= ! empty( $datetime_name ) && $add_breaks ? '<br />' : '';
- $html .= '<br /><span class="dashicons dashicons-clock"></span>' . $datetime->time_range( $tm_frmt );
- }
- $datetime_description = $datetime->description();
- $html .= ! empty( $datetime_description ) && $add_breaks ? '<br />' : '';
- $html .= ! empty( $datetime_description ) ? ' - ' . $datetime_description : '';
- $html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime );
- $html .= '</li>';
- } else {
- $html .= $datetime;
- $html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime );
- }
- }
- }
- $html .= $format ? '</ul>' : '';
- } else {
- $html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>' . __( 'There are no upcoming dates for this event.', 'event_espresso' ) . '</p><br/>' : '';
- }
- if ( $echo ) {
- echo $html;
- } else {
- return $html;
- }
- }
- // End espresso_list_of_event_dates
- // Add other pluggable functions before } below.
- }
- // Add any additional custom functions below here.
- add_filter(
- 'FHEE__EED_Espresso_Calendar__get_calendar_events__query_params',
- 'mdeyerinkc_remove_category_calendar_filter',
- 10,
- 7
- );
- function mdeyerinkc_remove_category_calendar_filter(
- $query_params,
- $category_id_or_slug,
- $venue_id_or_slug,
- $public_event_stati,
- $start_date,
- $end_date,
- $show_expired
- ) {
- // is a category set in the shortcode?
- if(is_array($unlisted )) {
- return $query_params; // yes, get out!
- }
- // still here, so there must be a category to exclude
- // get all cat ids
- $event_category_ids = array();
- // create loop to insert IDs to array
- $event_categories = get_terms( array(
- 'taxonomy' => 'espresso_event_categories',
- 'hide_empty' => false
- ) );
- foreach( $event_categories as $cat ) {
- if ($cat->term_id != 70) { // exclude this category only!
- $event_category_ids[] = $cat->term_id;
- }
- }
- $query_params[0]['OR*category'] = array(
- 'Event.Term_Taxonomy.term_id' => array( 'in', $event_category_ids ),
- );
- return $query_params;
- }
- add_filter('FHEE__EE_Calendar__get_calendar_events__event_time_html', 'tw_ee_filter_calendar_event_time_html', 10, 3);
- function tw_ee_filter_calendar_event_time_html( $html, $datetime, $event ) {
- // Don't show event times if the event has a 'hide-event-times' custom field set.
- if( get_post_meta( $event->ID(), 'hide-event-times', true ) ) {
- return false;
- }
- return $html;
- }
- function tw_ee_cal_remove_anchors(){
- wp_add_inline_script(
- 'espresso_calendar',
- 'jQuery( \'#ee-category-legend-ul a[href*="#espresso_calendar"]\' ).each(function() {
- this.href = this.href.split("#")[0];
- });'
- );
- }
- add_action( 'wp_enqueue_scripts', 'tw_ee_cal_remove_anchors', 20);
- function tw_ee_cal_remove_js_click_events(){
- wp_add_inline_script(
- 'espresso_calendar',
- 'jQuery(\'.ee-category a\').off(\'click\');'
- );
- }
- add_action( 'wp_enqueue_scripts', 'tw_ee_cal_remove_js_click_events', 20);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement