Skip to content

Instantly share code, notes, and snippets.

@sachyya
Created January 5, 2017 15:15
Show Gist options
  • Save sachyya/89aa6575bd355b0606d985bf6aa4e982 to your computer and use it in GitHub Desktop.
Save sachyya/89aa6575bd355b0606d985bf6aa4e982 to your computer and use it in GitHub Desktop.
<?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