Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Last active February 22, 2017 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/d80ea24588fdc02ea21692aef89704d9 to your computer and use it in GitHub Desktop.
Save Pebblo/d80ea24588fdc02ea21692aef89704d9 to your computer and use it in GitHub Desktop.
Example of how you can alter the description used in the calendar tooltips to allow HTML tags
<?php //Please do not include the opening php tag if you have one.
function tw_ee_enable_tags_in_calendar_tooltip( $description, $datetime_in_calendar ){
$event = $datetime_in_calendar->event();
if( $event instanceof EE_Event ){
$description = $event->short_description( 55, NULL, TRUE );
if ( empty( $description )) {
$description = $event->description_filtered();
// better more tag detection (stolen from WP core)
if ( preg_match( '/<!--more(.*?)?-->/', $description, $matches ) ) {
$description = explode( $matches[0], $description, 2 );
$description = array_shift( $description );
$description = strip_tags( $description,'<em><p><br><strong>' );
}
}
$description = do_shortcode( $description );
}
return $description;
}
add_filter('FHEE__EE_Datetime_In_Calendar__to_array_for_json__description', 'tw_ee_enable_tags_in_calendar_tooltip', 10, 2 );
@Pebblo
Copy link
Author

Pebblo commented Feb 22, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment