Last active
April 11, 2016 13:01
-
-
Save saqibsarwar/5373e4186036c32263ea13e744bb781a to your computer and use it in GitHub Desktop.
Helper function to initialize default values for settings as customizer api do not do so.
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 | |
if ( ! function_exists( 'inspiry_initialize_defaults' ) ) : | |
/** | |
* Helper function to initialize default values for settings as customizer api do not do so. | |
* | |
* @param WP_Customize_Manager $wp_customize | |
* @param $inspiry_settings_ids | |
*/ | |
function inspiry_initialize_defaults( WP_Customize_Manager $wp_customize, $inspiry_settings_ids ) { | |
if ( is_array( $inspiry_settings_ids ) && ! empty( $inspiry_settings_ids ) ) { | |
$mods = get_theme_mods(); | |
foreach ( $inspiry_settings_ids as $setting_id ) { | |
$setting = $wp_customize->get_setting( $setting_id ); | |
if ( ! isset( $mods[ $setting->id ] ) ) { | |
set_theme_mod( $setting->id, $setting->default ); | |
} | |
} | |
} | |
} | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment