Last active
August 15, 2022 10:30
-
-
Save Spellhammer/3e18a7d6f67e3c75516e3f127a802b44 to your computer and use it in GitHub Desktop.
Check for presence of URL parameter condition for Oxygen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if( function_exists('oxygen_vsb_register_condition') ) { | |
global $oxy_condition_operators; | |
// Condition to check if a URL parameter is present. | |
oxygen_vsb_register_condition('URL Param Exists', array('options'=>array(), 'custom'=>true), array('--'), 'oxy_url_param_exists_callback', 'Other'); | |
function oxy_url_param_exists_callback($value, $operator) { | |
if( isset($_GET[$value]) && $_GET[$value] ) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
// Condition to check if a URL parameter is NOT present. | |
oxygen_vsb_register_condition('URL Param Does Not Exist', array('options'=>array(), 'custom'=>true), array('--'), 'oxy_url_param_not_exists_callback', 'Other'); | |
function oxy_url_param_not_exists_callback($value, $operator) { | |
if( isset($_GET[$value]) && $_GET[$value] ) { | |
return false; | |
} else { | |
return true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For anyone who needs to check for a key equals value condition here is a useful helper function which you can add into your snippets and then use it with oxygen -> dynamic data -> php return value