brook-tribe

Strip HTML from Google Calendar links descriptions

Sep 21st, 2014
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. // Strips HTML code from Google Calendar descriptions
  2. function tribe_strip_gcal_description_html ($params) {
  3.     // Decode content
  4.     $params['details'] = html_entity_decode(urldecode($params['details']));
  5.  
  6.     // Hack: Add space after paragraph
  7.     // Normally Google Cal understands the newline character %0a
  8.     // And that character will automatically replace newlines on urlencode()
  9.     // However, WP' esc_url() function strips %0a from URLs
  10.     $params['details'] = str_replace ('</p>', '</p> ', $params['details']);
  11.  
  12.     // Remove HTML
  13.     $params['details'] = strip_tags($params['details']);
  14.  
  15.     // Encode for URl
  16.     $params['details'] = urlencode($params['details']);
  17.  
  18.     return $params;
  19. }
  20. add_filter('tribe_google_calendar_parameters', 'tribe_strip_gcal_description_html');
Add Comment
Please, Sign In to add comment