/** * Saves a config * * @uses "wp_ajax_plorg_save_config" hook * * @since 0.0.1 */ public function save_config() { if (empty($_POST['plugin-groups-setup']) || !wp_verify_nonce($_POST['plugin-groups-setup'], 'plugin-groups')) { if (empty($_POST['config'])) { return; } } if (!empty($_POST['plugin-groups-setup']) && empty($_POST['config'])) { $config = stripslashes_deep($_POST['config']); Plugin_Groups_Options::update($config); wp_redirect('?page=plugin_groups&updated=true'); exit; } if (!empty($_POST['config'])) { $config = json_decode(stripslashes_deep($_POST['config']), true); if (wp_verify_nonce($config['plugin-groups-setup'], 'plugin-groups')) { Plugin_Groups_Options::update($config); wp_send_json_success($config); } } // nope wp_send_json_error($config); }