Advertisement
BakerMan

Linking URLs in TEC Custom Fields

Aug 31st, 2012
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.42 KB | None | 0 0
  1. function linkURLsInCustomFields($html) {
  2.     $matches = array();
  3.     $pattern = '#<dd.*>(https?:\\/\\/[a-zA-Z0-9-\\.]+\\.[a-zA-Z0-9-\\.]+)<\/dd>#';
  4.  
  5.     preg_match($pattern, $html, $matches);
  6.  
  7.     if (count($matches) == 2) {
  8.         $match = $matches[1];
  9.         $link = '<a href="'.$match.'">'.$match.'</a>';
  10.         $html = str_replace($match, $link, $html);
  11.     }
  12.  
  13.     return $html;
  14. }
  15.  
  16. add_filter('tribe_the_custom_fields', 'linkURLsInCustomFields');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement