Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- this snippet will check if custom event attribute contains http:// or not
- Sample Usage:
- {is_not_valid_url}
- <a href="http://#_ATT{test}">#_ATT{test}</a>
- {/is_not_valid_url}
- {is_valid_url}
- <a href="#_ATT{test}">#_ATT{test}</a>
- {/is_valid_url}
- **Replace "test" with your custom event attribute
- */
- function filterEventOutputCondition($replacement, $condition, $match, $EM_Event){
- if (is_object($EM_Event)) {
- switch ($condition) {
- case 'is_valid_url':
- if (is_array($EM_Event->event_attributes) && substr($EM_Event->event_attributes['test'], 0, 7) == 'http://' )
- $replacement = preg_replace('/\{\/?is_valid_url\}/', '', $match);
- else
- $replacement = '';
- break;
- case 'is_not_valid_url':
- if (is_array($EM_Event->event_attributes) && substr($EM_Event->event_attributes['test'], 0, 7) != 'http://' )
- $replacement = preg_replace('/\{\/?is_not_valid_url\}/', '', $match);
- else
- $replacement = '';
- break;
- }
- }
- return $replacement;
- }
- add_filter('em_event_output_condition', 'filterEventOutputCondition', 100, 4);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement