Skip to content

Instantly share code, notes, and snippets.

@saqibsarwar
Created April 11, 2016 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saqibsarwar/96874e44edaa6f5d97dbf2d4aacea7ad to your computer and use it in GitHub Desktop.
Save saqibsarwar/96874e44edaa6f5d97dbf2d4aacea7ad to your computer and use it in GitHub Desktop.
<?php
if ( ! function_exists( 'inspiry_initialize_defaults' ) ) :
/**
* Helper function to initialize default values for settings as customizer api do not do so by default.
*
* @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 ) ) {
foreach ( $inspiry_settings_ids as $setting_id ) {
$setting = $wp_customize->get_setting( $setting_id );
if ( $setting ) {
add_option( $setting->id, $setting->default );
}
}
}
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment