Created
July 2, 2013 13:45
-
-
Save gregrickaby/5909416 to your computer and use it in GitHub Desktop.
Get custom options from WordPress database
This file contains hidden or 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
/** | |
* Create helper function to easily get options from database | |
* | |
* @since Child 1.0 | |
*/ | |
function child_get_option( $key, $setting = null ) { | |
$setting = $setting ? $setting : 'child_options'; // this must match your custom options in the database. | |
$options = get_option( $setting ); | |
return is_array( $options[$key] ) ? stripslashes_deep( $options[$key] ) : stripslashes( wp_kses_decode_entities( $options[$key] ) ); | |
} | |
// Usage | |
$my_option = child_get_option( 'some_option' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment