-
-
Save krishna19/a15470f95781afc8b74c0d6fa734728b to your computer and use it in GitHub Desktop.
Simple method for recovering redux values if you wish to not use the global variable.
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
<? | |
function redux_get_variables( $name, $key = false ) { | |
global $MY_VAR_NAME; // Update to your opt_name or global_variable name | |
$options = $MY_VAR_NAME; // Update to your opt_name or global_variable name | |
$var = ""; // Set this to your preferred default value | |
if ( empty( $name ) && !empty( $options ) ) { | |
$var = $options; | |
} else { | |
if ( !empty( $options[$name] ) ) { | |
if ( !empty( $key ) && !empty( $options[$name][$key] ) ) { | |
$var = $options[$name][$key]; | |
} else { | |
$var = $options[$name]; | |
} | |
} | |
} | |
return $var; | |
} | |
// To use this, you'd call anywhere you want redux_get_variables(). | |
// You can specify the name of the option by id, and a key within it to return. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment