Guest User

Untitled

a guest
Jan 16th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. /**
  2. * Tell tribe how to find the compiled path of {template}.blade.php
  3. */
  4. add_filter('tribe_events_template', function ($file, $template) {
  5. return template_path(locate_template(filter_templates(["views/tribe-events/{$template}", $template])) ?: $template);
  6. }, 10, 2);
  7.  
  8. /**
  9. * Remove everything from the include, so we can render ourselfves afterwards.
  10. */
  11. add_action('tribe_events_before_view', function(){
  12. ob_start();
  13. }, PHP_INT_MIN); // This runs as lasts, prevent conflicts with others that hook in to there.
  14. add_action('tribe_events_after_view', function(){
  15. ob_end_clean();
  16. }, PHP_INT_MAX-10); // This runs as first, prevent conflicts with others that hook in to there.
  17.  
  18. // Replace the filter below:
  19. /**
  20. * Render page using Blade
  21. */
  22. array_map(
  23. 'add_filter',
  24. ['template_include', 'tribe_events_after_view'],
  25. array_fill(0, 2, function ($template) {
  26. $data = collect(get_body_class())->reduce(function ($data, $class) use ($template) {
  27. return apply_filters("sage/template/{$class}/data", $data, $template);
  28. }, []);
  29.  
  30. if ($template) {
  31. echo template($template, $data);
  32. return get_stylesheet_directory().'/index.php';
  33. }
  34. return $template;
  35. }),
  36. array_fill(0, 2, PHP_INT_MAX)
  37. );
Add Comment
Please, Sign In to add comment