Created
January 5, 2017 15:15
-
-
Save sachyya/89aa6575bd355b0606d985bf6aa4e982 to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* Collects all the default theme mods value in an array | |
* @return array All the default theme mods values | |
*/ | |
function prefix_get_theme_mods_defaults() { | |
$defaults = array( | |
// Site footer options | |
'option1' => 'value1', | |
'option2' => 'value2', | |
); | |
return apply_filters( 'prefix_get_theme_mods_defaults', $defaults ); | |
} | |
/** | |
* Making sane defaults for the theme mods to return | |
* @return mixed Return array of theme mods or other data type if theme mod id is passed | |
*/ | |
function prefix_get_theme_mods( $theme_mod_id='' ) { | |
// Theme Mods API: | |
$merged_theme_mods = wp_parse_args( | |
get_theme_mods(), | |
prefix_get_theme_mods_defaults() | |
); | |
if ( $theme_mod_id ) | |
return $merged_theme_mods[ $theme_mod_id ]; | |
else | |
return $merged_theme_mods; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment