Advertisement
Guest User

config.php

a guest
Apr 8th, 2021
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.27 KB | None | 0 0
  1. <?php
  2.  
  3. if ( ! defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly
  4.  
  5.  
  6. //if either calendar plugin or modified version of the plugin that is included in the theme is available we can make use of it, otherwise return
  7.  
  8. if( ! class_exists( 'Tribe__Events__Main' ) )
  9. {
  10. return false;
  11. }
  12.  
  13. define( 'AVIA_EVENT_PATH', AVIA_BASE . 'config-events-calendar/' );
  14.  
  15. include( 'event-mod-css-dynamic.php');
  16.  
  17.  
  18. //register my own styles
  19. if( ! function_exists( 'avia_events_register_assets' ) )
  20. {
  21. if( ! is_admin() )
  22. {
  23. add_action( 'wp_enqueue_scripts', 'avia_events_register_assets', 15 );
  24. }
  25.  
  26. function avia_events_register_assets( $styleUrl )
  27. {
  28. wp_enqueue_style( 'avia-events-cal', AVIA_BASE_URL . 'config-events-calendar/event-mod.css' );
  29. }
  30. }
  31.  
  32.  
  33. //register own default template
  34. if( ! function_exists( 'avia_events_template_paths' ) )
  35. {
  36. add_action( 'tribe_events_template', 'avia_events_template_paths', 10, 2 );
  37.  
  38. function avia_events_template_paths( $file, $template )
  39. {
  40. $redirect = array( 'default-template.php', 'single-event.php', 'pro/map.php' );
  41.  
  42. if( in_array( $template, $redirect ) )
  43. {
  44. $file = AVIA_EVENT_PATH . 'views/' . $template;
  45.  
  46. /**
  47. * https://github.com/KriesiMedia/wp-themes/issues/1676
  48. *
  49. * with 4.2.5 we added a better support for mobile view, which broke output of this plugin. We revert to old style.
  50. *
  51. * @since 4.2.7
  52. */
  53. if( class_exists( 'Tribe__Tickets_Plus__Main' ) )
  54. {
  55. if( 'single-event.php' == $template )
  56. {
  57. $file = AVIA_EVENT_PATH . 'views/single-event-no-mobile.php';
  58. }
  59. }
  60. }
  61.  
  62. return $file;
  63. }
  64. }
  65.  
  66. if( ! function_exists( 'avia_events_template_paths_v2' ) )
  67. {
  68. add_filter( 'tribe_template_file', 'avia_events_template_paths_v2', 10, 2 );
  69.  
  70. /**
  71. * Register default v2 templates
  72. * https://github.com/KriesiMedia/wp-themes/issues/3088
  73. *
  74. * @since 4.8.2
  75. * @param string $found_file
  76. * @param array $name
  77. * @return string
  78. */
  79. function avia_events_template_paths_v2( $found_file, $name )
  80. {
  81. if( ! is_array( $name ) || empty( $name ) )
  82. {
  83. return $found_file;
  84. }
  85.  
  86. if( $name[0] == 'default-template' && is_single() )
  87. {
  88. $found_file = AVIA_EVENT_PATH . 'views/' . $name[0] . '.php';
  89. }
  90.  
  91. return $found_file;
  92. }
  93. }
  94.  
  95.  
  96.  
  97.  
  98. //remove ability to change some of the avialble options (eg: template choice)
  99.  
  100. if( ! function_exists( 'avia_events_perma_options' ) )
  101. {
  102. add_action( 'option_tribe_events_calendar_options', 'avia_events_perma_options', 10 );
  103.  
  104. function avia_events_perma_options( $options )
  105. {
  106. $edit_elements = array(
  107. 'tribeEventsTemplate' => '',
  108. 'stylesheetOption' => 'full' ,
  109. 'tribeDisableTribeBar' => false
  110. ); // stylesheetOption: skeleton, full, tribe
  111.  
  112. $options = array_merge( $options, $edit_elements );
  113.  
  114. return $options;
  115. }
  116. }
  117.  
  118. //edit/remove some of the options from general tab
  119. if( ! function_exists( 'avia_events_general_tab' ) )
  120. {
  121. add_action( 'tribe_general_settings_tab_fields', 'avia_events_general_tab', 10 );
  122.  
  123. function avia_events_general_tab( $options )
  124. {
  125. $edit_elements = array(
  126. 'info-start' => array( 'html' => '<div id="modern-tribe-info">' ),
  127. 'upsell-info',
  128. 'upsell-info',
  129. 'donate-link-info',
  130. 'donate-link-pro-info',
  131. 'donate-link-heading',
  132. 'donate-link',
  133. 'info-end' => array( 'html' => avia_tribe_ref() . '</div>' ) );
  134.  
  135. $options = avia_events_modify_options( $options, $edit_elements );
  136.  
  137. return $options;
  138. }
  139. }
  140.  
  141. //edit/remove some of the options from display tab
  142. if( ! function_exists( 'avia_events_display_tab' ) )
  143. {
  144. add_action( 'tribe_display_settings_tab_fields', 'avia_events_display_tab', 10 );
  145.  
  146. function avia_events_display_tab( $options )
  147. {
  148. $edit_elements = array(
  149. 'info-start',
  150. 'info-box-title',
  151. 'info-box-description',
  152. 'info-end',
  153. 'stylesheetOption',
  154. 'tribeEventsTemplate',
  155. 'tribeDisableTribeBar'
  156. );
  157.  
  158. $options = avia_events_modify_options( $options, $edit_elements );
  159.  
  160. return $options;
  161. }
  162. }
  163.  
  164.  
  165. if( ! function_exists( 'avia_events_modify_options' ) )
  166. {
  167. function avia_events_modify_options( $options, $edit_elements )
  168. {
  169. foreach( $edit_elements as $key => $element )
  170. {
  171. if( is_array( $element ) )
  172. {
  173. $options[ $key ] = array_merge_recursive( $options, $element );
  174. }
  175. else
  176. {
  177. if( array_key_exists( $element, $options ) )
  178. {
  179. unset( $options[ $element ] );
  180. }
  181. }
  182. }
  183.  
  184. return $options;
  185. }
  186. }
  187.  
  188.  
  189. if( ! function_exists( 'avia_events_upsell' ) )
  190. {
  191. $tec = Tribe__Events__Main::instance();
  192.  
  193. remove_action( 'tribe_events_cost_table', array( $tec, 'maybeShowMetaUpsell' ) );
  194. add_action( 'tribe_events_cost_table', 'avia_events_upsell', 10 );
  195.  
  196. function avia_events_upsell()
  197. {
  198. if( ! class_exists( 'Tribe__Events__Pro__Main' ) )
  199. {
  200.  
  201. ?><tr class="eventBritePluginPlug">
  202. <td colspan="2" class="tribe_sectionheader">
  203. <h4><?php _e( 'Additional Functionality', 'avia_framework' ); ?></h4>
  204. </td>
  205. </tr>
  206. <tr class="eventBritePluginPlug">
  207. <td colspan="2">
  208. <?php echo avia_tribe_ref(); ?>
  209. </td>
  210. </tr><?php
  211.  
  212. }
  213. }
  214. }
  215.  
  216. if( ! function_exists( 'avia_tribe_ref' ) )
  217. {
  218. function avia_tribe_ref()
  219. {
  220. if( class_exists( 'Tribe__Events__Pro__Main' ) )
  221. {
  222. return '';
  223. }
  224.  
  225. $output = '<p>';
  226. $output .= __( 'Looking for additional functionality including recurring events, ticket sales, publicly submitted events, new views and more?', 'avia_framework' ) . ' ';
  227. $output .= __( 'Check out the', 'avia_framework' ).
  228. ' <a href="http://mbsy.co/6cr37">' .
  229. __( 'available add-ons', 'avia_framework' ).
  230. '</a>';
  231.  
  232. $output .= '</p>';
  233.  
  234. return $output;
  235. }
  236. }
  237.  
  238.  
  239. if( ! function_exists( 'avia_events_custom_post_nav' ) )
  240. {
  241. add_filter( 'avf_post_nav_entries', 'avia_events_custom_post_nav', 10, 3 );
  242.  
  243. /**
  244. * Modfiy post navigation
  245. *
  246. * @since < 4.0 modified 4.5.6
  247. * @param array $entry
  248. * @param array $settings
  249. * @param array $queried_entries
  250. * @return array
  251. */
  252. function avia_events_custom_post_nav( array $entry, array $settings, array $queried_entries )
  253. {
  254. if( tribe_is_event() )
  255. {
  256. $final = $links = array();
  257. $entry = array(
  258. 'prev' => '',
  259. 'next' => ''
  260. );
  261.  
  262. if( version_compare( Tribe__Events__Main::VERSION, '4.6.22', '>=' ) )
  263. {
  264. $old_prev = tribe( 'tec.adjacent-events' )->previous_event_link;
  265. $old_next = tribe( 'tec.adjacent-events' )->next_event_link;
  266.  
  267. tribe( 'tec.adjacent-events' )->previous_event_link = '';
  268. tribe( 'tec.adjacent-events' )->next_event_link = '';
  269. }
  270.  
  271. $links['prev'] = tribe_get_prev_event_link( '{-{%title%}-}' );
  272. $links['next'] = tribe_get_next_event_link( '{-{%title%}-}' );
  273.  
  274. foreach( $links as $key => $link )
  275. {
  276. if( empty( $link ) )
  277. {
  278. continue;
  279. }
  280.  
  281. preg_match( '/^<a.*?href=(["\'])(.*?)\1.*$/', $link, $m );
  282. $final[ $key ]['link_url'] = ! empty( $m[2] ) ? $m[2] : '';
  283.  
  284. preg_match( '/\{\-\{(.+)\}\-\}/', $link, $m2 );
  285. $final[ $key ]['link_text'] = ! empty( $m2[1] ) ? $m2[1] : '';
  286.  
  287. if( ! empty( $final[ $key ]['link_text'] ) )
  288. {
  289. $mode = 'prev' == $key ? 'previous' : 'next';
  290. $event = tribe( 'tec.adjacent-events' )->get_closest_event( $mode );
  291.  
  292. $entry[ $key ] = new stdClass();
  293. $entry[ $key ]->av_custom_link = $final[ $key ]['link_url'];
  294. $entry[ $key ]->av_custom_title = $final[ $key ]['link_text'];
  295. $entry[ $key ]->av_custom_image = get_the_post_thumbnail( $event->ID, 'thumbnail' );
  296. }
  297. }
  298.  
  299. if( version_compare( Tribe__Events__Main::VERSION, '4.6.22', '>=' ) )
  300. {
  301. tribe( 'tec.adjacent-events' )->previous_event_link = $old_prev;
  302. tribe( 'tec.adjacent-events' )->next_event_link = $old_next;
  303. }
  304. }
  305.  
  306. return $entry;
  307. }
  308. }
  309.  
  310. /*modfiy breadcrumb navigation*/
  311. if( ! function_exists( 'avia_events_breadcrumb') )
  312. {
  313. add_filter( 'avia_breadcrumbs_trail', 'avia_events_breadcrumb' );
  314.  
  315. function avia_events_breadcrumb( $trail )
  316. {
  317. global $avia_config, $wp_query;
  318.  
  319. if( is_404() && isset( $wp_query ) && ! empty( $wp_query->tribe_is_event ) )
  320. {
  321. $events = __( 'Events','avia_framework' );
  322. $events_link = '<a href="' . tribe_get_events_link().'">' . $events . '</a>';
  323. $last = array_pop( $trail );
  324. $trail[] = $events_link;
  325. $trail['trail_end'] = __( 'No Events Found', 'avia_framework' );
  326. }
  327.  
  328. if( ( isset( $avia_config['currently_viewing'] ) && $avia_config['currently_viewing'] == 'events' ) || tribe_is_month() || get_post_type() === Tribe__Events__Main::POSTTYPE || is_tax( Tribe__Events__Main::TAXONOMY ) )
  329. {
  330. $events = __( 'Events', 'avia_framework' );
  331. $events_link = '<a href="' . tribe_get_events_link() . '" title="' . $events . '">' . $events . '</a>';
  332.  
  333. if( is_tax( Tribe__Events__Main::TAXONOMY ) )
  334. {
  335. $last = array_pop( $trail );
  336. $trail[] = $events_link;
  337. $trail[] = $last;
  338. }
  339. else if( tribe_is_month() || ( tribe_is_upcoming() && ! is_singular() ) )
  340. {
  341. $trail[] = $events_link;
  342. }
  343. else if( tribe_is_event() )
  344. {
  345. $last = array_pop( $trail );
  346. $trail[] = $events_link;
  347. $trail[] = $last;
  348. }
  349.  
  350. if( isset( $avia_config['events_trail'] ) )
  351. {
  352. $trail = $avia_config['events_trail'] ;
  353. }
  354. }
  355.  
  356. return $trail;
  357. }
  358.  
  359. }
  360.  
  361.  
  362. /*additional markup*/
  363. if( ! function_exists( 'avia_events_content_wrap' ) )
  364. {
  365. add_action( 'tribe_events_before_the_event_title', 'avia_events_content_wrap', 10 );
  366.  
  367. function avia_events_content_wrap()
  368. {
  369. echo "<div class='av-tribe-events-content-wrap'>";
  370. }
  371. }
  372.  
  373. if( ! function_exists( 'avia_events_open_outer_wrap' ) )
  374. {
  375. add_action( 'tribe_events_after_the_event_title', 'avia_events_open_outer_wrap', 10 );
  376.  
  377. function avia_events_open_outer_wrap()
  378. {
  379. echo "<div class='av-tribe-events-outer-content-wrap'>";
  380. }
  381. }
  382.  
  383. if( ! function_exists( 'avia_events_open_inner_wrap' ) )
  384. {
  385. add_action( 'tribe_events_after_the_meta', 'avia_events_open_inner_wrap', 10 );
  386.  
  387. function avia_events_open_inner_wrap()
  388. {
  389. echo "<div class='av-tribe-events-inner-content-wrap'>";
  390. }
  391. }
  392.  
  393.  
  394. if( ! function_exists( 'avia_events_close_div' ) )
  395. {
  396. /*call 3 times, once for wrappper, outer and inner wrap*/
  397. add_action( 'tribe_events_after_the_content', 'avia_events_close_div', 1000 );
  398. add_action( 'tribe_events_after_the_content', 'avia_events_close_div', 1001 );
  399. add_action( 'tribe_events_after_the_content', 'avia_events_close_div', 1003 );
  400.  
  401. function avia_events_close_div()
  402. {
  403. echo '</div>';
  404. }
  405. }
  406.  
  407.  
  408. /*PRO PLUGIN*/
  409. if ( ! class_exists( 'Tribe__Events__Pro__Main' ) )
  410. {
  411. return false;
  412. }
  413.  
  414. /*move related events*/
  415. $tec = Tribe__Events__Pro__Main::instance();
  416.  
  417. remove_action( 'tribe_events_single_event_after_the_meta', array( $tec, 'register_related_events_view' ) );
  418. add_action( 'tribe_events_single_event_after_the_content', array( $tec, 'register_related_events_view' ) );
  419.  
  420.  
  421. if( ! function_exists( 'avia_events_modify_recurring_event_query' ) )
  422. {
  423. /**
  424. * Selecting checkbox Recurring event instances in Events -> Settings -> General might might break our queries because of GROUP BY clause.
  425. * Reason is probably if multiple posttypes are part of the query.
  426. *
  427. * @added_by Günter
  428. * @since 4.2.4
  429. * @param array $query
  430. * @param array $params
  431. * @return array
  432. */
  433. function avia_events_modify_recurring_event_query( array $query, array $params )
  434. {
  435. remove_filter( 'posts_request', array( 'Tribe__Events__Pro__Recurrence__Queries', 'collapse_sql' ), 10, 2 );
  436.  
  437. return $query;
  438. }
  439. }
  440.  
  441. if( ! function_exists( 'avia_events_reset_recurring_event_query' ) )
  442. {
  443. /**
  444. * Add the previously removed filter again
  445. *
  446. * @added_by Günter
  447. * @since 4.2.4
  448. */
  449. function avia_events_reset_recurring_event_query()
  450. {
  451. if( false === has_filter( 'posts_request', array( 'Tribe__Events__Pro__Recurrence__Queries', 'collapse_sql' ) ) )
  452. {
  453. add_filter( 'posts_request', array( 'Tribe__Events__Pro__Recurrence__Queries', 'collapse_sql' ), 10, 2 );
  454. }
  455. }
  456. }
  457.  
  458. add_filter( 'avia_masonry_entries_query', 'avia_events_modify_recurring_event_query', 10, 2 );
  459. add_action( 'ava_after_masonry_entries_query', 'avia_events_reset_recurring_event_query', 10 );
  460.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement