コード例 #1
0
ファイル: update.php プロジェクト: kivivuori/jotain
/**
 * Initialize settings to default ones if they are not yet set
 *
 * @since 3.0
 */
function wprss_settings_initialize()
{
    // Get the settings from the new field in the database
    $settings = get_option('wprss_settings_general');
    // Get the default plugin settings.
    $default_settings = wprss_get_default_settings_general();
    // Loop through each of the default plugin settings.
    foreach ($default_settings as $setting_key => $setting_value) {
        // If the setting didn't previously exist, add the default value to the $settings array.
        if (!isset($settings[$setting_key])) {
            $settings[$setting_key] = $setting_value;
        }
    }
    // Update the plugin settings.
    update_option('wprss_settings_general', $settings);
}
コード例 #2
0
/**
 * Returns the given general setting option value form the database, or the default value if it is not found.
 *
 * @param option_name The name of the option to get
 * @return mixed
 * @since 3.7.1
 */
function wprss_get_general_setting($option_name)
{
    $options = get_option('wprss_settings_general', array());
    $defaults = wprss_get_default_settings_general();
    return isset($options[$option_name]) ? $options[$option_name] : $defaults[$option_name];
}