Пример #1
0
/**
 * Update an option
 *
 * Updates an edd setting value in both the db and the global variable.
 * Warning: Passing in an empty, false or null string value will remove
 *          the key from the edd_options array.
 *
 * @since 2.3
 * @param string $key The Key to update
 * @param string|bool|int $value The value to set the key to
 * @return boolean True if updated, false if not.
 */
function edd_update_option($key = '', $value = false)
{
    // If no key, exit
    if (empty($key)) {
        return false;
    }
    if (empty($value)) {
        $remove_option = edd_delete_option($key);
        return $remove_option;
    }
    // First let's grab the current settings
    $options = get_option('edd_settings');
    // Let's let devs alter that value coming in
    $value = apply_filters('edd_update_option', $value, $key);
    // Next let's try to update the value
    $options[$key] = $value;
    $did_update = update_option('edd_settings', $options);
    // If it updated, let's update the global variable
    if ($did_update) {
        global $edd_options;
        $edd_options[$key] = $value;
    }
    return $did_update;
}
Пример #2
0
/**
 * Save enabled betas
 *
 * @since       2.6.11
 * @return      void
 */
function edd_tools_enabled_betas_save()
{
    if (!wp_verify_nonce($_POST['edd_save_betas_nonce'], 'edd_save_betas_nonce')) {
        return;
    }
    if (!current_user_can('manage_shop_settings')) {
        return;
    }
    if (!empty($_POST['enabled_betas'])) {
        $enabled_betas = array_filter(array_map('edd_tools_enabled_betas_sanitize_value', $_POST['enabled_betas']));
        edd_update_option('enabled_betas', $enabled_betas);
    } else {
        edd_delete_option('enabled_betas');
    }
}