eventsmanager

Custom event attribute check http

Oct 17th, 2017
322
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. this snippet will check if custom event attribute contains http:// or not
  3.  
  4. Sample Usage:
  5.  
  6. {is_not_valid_url}
  7. <a href="http://#_ATT{test}">#_ATT{test}</a>
  8. {/is_not_valid_url}
  9.  
  10. {is_valid_url}
  11. <a href="#_ATT{test}">#_ATT{test}</a>
  12. {/is_valid_url}
  13.  
  14. **Replace "test" with your custom event attribute
  15.  
  16. */
  17. function filterEventOutputCondition($replacement, $condition, $match, $EM_Event){
  18. if (is_object($EM_Event)) {
  19.  
  20. switch ($condition) {
  21.  
  22.  
  23. case 'is_valid_url':
  24.  
  25. if (is_array($EM_Event->event_attributes) && substr($EM_Event->event_attributes['test'], 0, 7) == 'http://' )
  26. $replacement = preg_replace('/\{\/?is_valid_url\}/', '', $match);
  27. else
  28. $replacement = '';
  29. break;
  30.  
  31. case 'is_not_valid_url':
  32.  
  33. if (is_array($EM_Event->event_attributes) && substr($EM_Event->event_attributes['test'], 0, 7) != 'http://' )
  34. $replacement = preg_replace('/\{\/?is_not_valid_url\}/', '', $match);
  35. else
  36. $replacement = '';
  37. break;
  38.  
  39. }
  40.  
  41. }
  42.  
  43. return $replacement;
  44. }
  45.  
  46. add_filter('em_event_output_condition', 'filterEventOutputCondition', 100, 4);
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×