Advertisement
Guest User

Untitled

a guest
Sep 27th, 2021
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.26 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Site plugin for blog.mycabcorner.com
  4. Description: Site specific code for blog.mycabcorner.com
  5. */
  6.  
  7. // Hook into Event Espresso before template_tags is loaded and declared any pluggable functions.
  8. add_action('AHEE__EE_System__core_loaded_and_ready', 'ee_custom_load_pluggable_functions');
  9.  
  10. // Add any plugin functions within this function
  11. function ee_custom_load_pluggable_functions() {
  12.  
  13. // Override espresso_list_of_event_dates
  14. function espresso_list_of_event_dates( $EVT_ID = FALSE, $dt_frmt = '', $tm_frmt = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE ) {
  15. $dt_frmt = ! empty( $dt_frmt ) ? $dt_frmt : get_option('date_format');
  16. $tm_frmt = ! empty( $tm_frmt ) ? $tm_frmt : get_option('time_format');
  17. $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID ,$show_expired );
  18. //d( $datetimes );
  19. if ( is_array( $datetimes ) && ! empty( $datetimes )) {
  20. global $post;
  21. $html = $format ? '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul">' : '';
  22. foreach ( $datetimes as $datetime ) {
  23. if ( $datetime instanceof EE_Datetime ) {
  24. if ( $format ) {
  25. $html .= '<li id="ee-event-datetimes-li-' . $datetime->ID() . '" class="ee-event-datetimes-li">';
  26. $datetime_name = $datetime->name();
  27. $html .= ! empty( $datetime_name ) ? '<strong>' . $datetime_name . '</strong>' : '';
  28. $html .= ! empty( $datetime_name ) && $add_breaks ? '<br />' : '';
  29. $html .= '<span class="dashicons dashicons-calendar"></span>' . $datetime->date_range( $dt_frmt ) . '';
  30. if(! get_post_meta( $EVT_ID, 'hide-event-times', true ) ) {
  31. $html .= ! empty( $datetime_name ) && $add_breaks ? '<br />' : '';
  32. $html .= '<br /><span class="dashicons dashicons-clock"></span>' . $datetime->time_range( $tm_frmt );
  33. }
  34. $datetime_description = $datetime->description();
  35. $html .= ! empty( $datetime_description ) && $add_breaks ? '<br />' : '';
  36. $html .= ! empty( $datetime_description ) ? ' - ' . $datetime_description : '';
  37. $html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime );
  38. $html .= '</li>';
  39. } else {
  40. $html .= $datetime;
  41. $html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime );
  42. }
  43. }
  44. }
  45. $html .= $format ? '</ul>' : '';
  46. } else {
  47. $html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>' . __( 'There are no upcoming dates for this event.', 'event_espresso' ) . '</p><br/>' : '';
  48. }
  49. if ( $echo ) {
  50. echo $html;
  51. } else {
  52. return $html;
  53. }
  54. }
  55. // End espresso_list_of_event_dates
  56.  
  57. // Add other pluggable functions before } below.
  58. }
  59.  
  60. // Add any additional custom functions below here.
  61.  
  62. add_filter(
  63. 'FHEE__EED_Espresso_Calendar__get_calendar_events__query_params',
  64. 'mdeyerinkc_remove_category_calendar_filter',
  65. 10,
  66. 7
  67. );
  68.  
  69. function mdeyerinkc_remove_category_calendar_filter(
  70. $query_params,
  71. $category_id_or_slug,
  72. $venue_id_or_slug,
  73. $public_event_stati,
  74. $start_date,
  75. $end_date,
  76. $show_expired
  77. ) {
  78. // is a category set in the shortcode?
  79. if(is_array($unlisted )) {
  80. return $query_params; // yes, get out!
  81. }
  82. // still here, so there must be a category to exclude
  83. // get all cat ids
  84. $event_category_ids = array();
  85. // create loop to insert IDs to array
  86. $event_categories = get_terms( array(
  87. 'taxonomy' => 'espresso_event_categories',
  88. 'hide_empty' => false
  89. ) );
  90. foreach( $event_categories as $cat ) {
  91. if ($cat->term_id != 70) { // exclude this category only!
  92. $event_category_ids[] = $cat->term_id;
  93. }
  94. }
  95. $query_params[0]['OR*category'] = array(
  96. 'Event.Term_Taxonomy.term_id' => array( 'in', $event_category_ids ),
  97. );
  98. return $query_params;
  99. }
  100.  
  101. add_filter('FHEE__EE_Calendar__get_calendar_events__event_time_html', 'tw_ee_filter_calendar_event_time_html', 10, 3);
  102. function tw_ee_filter_calendar_event_time_html( $html, $datetime, $event ) {
  103. // Don't show event times if the event has a 'hide-event-times' custom field set.
  104. if( get_post_meta( $event->ID(), 'hide-event-times', true ) ) {
  105. return false;
  106. }
  107. return $html;
  108. }
  109.  
  110. function tw_ee_cal_remove_anchors(){
  111. wp_add_inline_script(
  112. 'espresso_calendar',
  113. 'jQuery( \'#ee-category-legend-ul a[href*="#espresso_calendar"]\' ).each(function() {
  114. this.href = this.href.split("#")[0];
  115. });'
  116. );
  117. }
  118. add_action( 'wp_enqueue_scripts', 'tw_ee_cal_remove_anchors', 20);
  119.  
  120. function tw_ee_cal_remove_js_click_events(){
  121. wp_add_inline_script(
  122. 'espresso_calendar',
  123. 'jQuery(\'.ee-category a\').off(\'click\');'
  124. );
  125. }
  126. add_action( 'wp_enqueue_scripts', 'tw_ee_cal_remove_js_click_events', 20);
  127.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement