function wdi_set_options_defaults() { $db_options = array(); $options = get_option(WDI_OPT); $wdi_plugin_uninstalled = isset($options['wdi_plugin_uninstalled']) ? $options['wdi_plugin_uninstalled'] : ''; $old_access_token = isset($options['wdi_access_token']) ? $options['wdi_access_token'] : ''; $old_user_name = isset($options['wdi_user_name']) ? $options['wdi_user_name'] : ''; $settings = wdi_get_settings(); foreach ($settings as $setting) { $settingDefault = isset($setting['default']) ? $setting['default'] : ''; if (!$settingDefault == '') { if ($setting['default'] != NULL) { $db_options[$setting['name']] = $setting['default']; } } } //check if deactivation/activation occured that keep settings instead of deleting if ($wdi_plugin_uninstalled == 'false') { $db_options['wdi_access_token'] = $old_access_token; $db_options['wdi_user_name'] = $old_user_name; } // $db_options['wdi_plugin_uninstalled'] = 'false'; add_option(WDI_OPT, $db_options, '', 'yes'); update_option(WDI_OPT, $db_options, 'yes'); wdi_get_options(); }
function wdi_register_settings() { //gettings settings for registering $settings = wdi_get_settings(); //adding configure section add_settings_section('wdi_configure_section', __('Configure', "wdi"), 'wdi_configure_section_callback', 'settings_wdi'); //adding customize section add_settings_section('wdi_customize_section', __('Customize', "wdi"), 'wdi_customize_section_callback', 'settings_wdi'); //adding settings fileds form getted settings foreach ($settings as $setting_name => $setting) { if (isset($setting['field_or_not']) == true && $setting['field_or_not'] != 'no_field') { add_settings_field($setting_name, $setting['title'], 'wdi_field_callback', 'settings_wdi', $setting['section'], array($setting)); } } //registering all settings register_setting('wdi_all_settings', 'wdi_instagram_options', 'wdi_sanitize_options'); wdi_get_options(); }
function wdi_set_options_defaults() { $db_options = array(); $options = get_option(WDI_OPT); $settings = wdi_get_settings(); foreach ($settings as $setting) { $settingDefault = isset($setting['default']) ? $setting['default'] : ''; $db_options[$setting['name']] = $setting['default']; } $options = wp_parse_args($options, $db_options); if (isset($options['wdi_plugin_uninstalled']) && $options['wdi_plugin_uninstalled'] == 'true') { $options['wdi_plugin_uninstalled'] = 'false'; } add_option(WDI_OPT, $options, '', 'yes'); update_option(WDI_OPT, $options, 'yes'); wdi_get_options(); }