function swp_bitly_oauth_callback() { $options = swp_get_user_options(); // Set the premium code to null $options['bitly_access_token'] = $_GET['access_token']; // Update the options array with the premium code nulled swp_update_options($options); echo admin_url('admin.php?page=social-warfare'); }
/** * Update a single option. * * @since 2.1.0 * @param string $key The key to set in the array of options. * @param mixed $value The option value to be set. * @return bool True if the option has been updated. */ function swp_update_option($key, $value) { $options = get_option('socialWarfareOptions', array()); $options[$key] = $value; return swp_update_options($options); }
/** * Handle the options save request inside of admin-ajax.php * * @since unknown * @return void */ function swp_store_the_settings() { global $swp_user_options; if (!check_ajax_referer('swp_plugin_options_save', 'security', false)) { wp_send_json_error(esc_html__('Security failed.', 'social-warfare')); die; } $data = wp_unslash($_POST); if (empty($data['settings'])) { wp_send_json_error(esc_html__('No settings to save.', 'social-warfare')); die; } $settings = $data['settings']; $options = $swp_user_options; unset($options['newOrderOfIcons']['active']); unset($options['newOrderOfIcons']['inactive']); // Loop and check for checkbox values, convert them to boolean. foreach ($settings as $key => $value) { if ('true' == $value) { $options[$key] = true; } elseif ('false' == $value) { $options[$key] = false; } else { $options[$key] = $value; } } swp_update_options($options); die; }