Advertisement
BakerMan

Avoid "spawning" of extra mini cal divs

Nov 12th, 2013
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. add_filter( 'tribe_get_template_part_content', 'mini_cal_stop_div_spawning', 10, 5 );
  2.  
  3. function mini_cal_stop_div_spawning( $html, $template, $file, $slug, $name ) {
  4.     // Only interfere with the mini calendar widget
  5.     if ( 'pro/widgets/mini-calendar-widget.php' !== $template ) return $html;
  6.  
  7.     // ... and only during ajax requests
  8.     if ( ! defined('DOING_AJAX') || ! DOING_AJAX ) return $html;
  9.  
  10.     // Figure out which parts we want to discard and which we want to keep
  11.     $opening_div = '<div class="tribe-mini-calendar-wrapper">';
  12.     $closing_div = '</div>';
  13.     $start = strpos( $html, $opening_div ) + strlen( $opening_div );
  14.     $close = strrpos( $html, $closing_div );
  15.  
  16.     // Return the good part
  17.     return substr( $html, $start, $close - $start );
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement