/** * Loads the Omega theme settings once and allows the input of the specific field the user would * like to show. Omega theme settings are added with 'autoload' set to 'yes', so the settings are * only loaded once on each page load. * * @since 0.7.0 * @access public * @uses get_option() Gets an option from the database. * @global object $omega The global Omega object. * @param string $option The specific theme setting the user wants. * @return mixed $settings[$option] Specific setting asked for. */ function omega_get_setting($option = '') { global $omega; /* If no specific option was requested, return false. */ if (!$option) { return false; } /* Get the default settings. */ $defaults = omega_get_default_theme_settings(); /* If the settings array hasn't been set, call get_option() to get an array of theme settings. */ if (!isset($omega->settings) || !is_array($omega->settings)) { $omega->settings = get_option('omega_theme_settings', $defaults); } /* If the option isn't set but the default is, set the option to the default. */ if (!isset($omega->settings[$option]) && isset($defaults[$option])) { $omega->settings[$option] = $defaults[$option]; } /* If no option is found at this point, return false. */ if (!isset($omega->settings[$option])) { return false; } /* If the specific option is an array, return it. */ if (is_array($omega->settings[$option])) { return $omega->settings[$option]; } else { return wp_kses_stripslashes($omega->settings[$option]); } }
/** * Saves the scripts meta box settings by filtering the "sanitize_option_omega_theme_settings" hook. * * @since 0.3.0 * @param array $settings Array of theme settings passed by the Settings API for validation. * @return array $settings */ function omega_theme_validate_settings($settings) { if (isset($_POST['reset'])) { $settings = omega_get_default_theme_settings(); add_settings_error('omega-framework', 'restore_defaults', __('Default setting restored.', 'omega'), 'updated fade'); } /* Return the theme settings. */ return $settings; }