public function network_admin_save() { check_admin_referer($this->parent->_token . '_settings-options'); // This is the list of registered options. global $new_whitelist_options; $options = $new_whitelist_options[$this->parent->_token . '_settings']; // Go through the posted data and save only our options. This is a generic // way to do this, but you may want to address the saving of each option // individually. foreach ($options as $option) { if (isset($_POST[$option])) { // If we registered a callback function to sanitizes the option's // value it is where we call it (see register_setting). $option_value = apply_filters('sanitize_option_' . $option_name, $_POST[$option]); // And finally we save our option with the site's options. update_site_option($option, $option_value); } else { // If the option is not here then delete it. It depends on how you // want to manage your defaults however. delete_site_option($option); } } $red = array('page' => $this->parent->_token . '_settings', 'settings-updated' => 'true'); if (isset($_POST['tab']) && $_POST['tab']) { $red['tab'] = $_POST['tab']; } // At last we redirect back to our options page. wp_redirect(add_query_arg($red, network_admin_url('settings.php'))); exit; }
/** * What to do when the plugin is activated * * @since 2.0.0 * @param boolean $network_wide */ public static function activate($network_wide) { if (function_exists('is_multisite') && is_multisite()) { if ($network_wide) { // Get all blog ids $blog_ids = self::get_blog_ids(); foreach ($blog_ids as $blog_id) { switch_to_blog($blog_id); self::single_activate($network_wide); restore_current_blog(); } // delete old options delete_site_option('wp-maintenance-mode'); delete_site_option('wp-maintenance-mode-msqld'); } else { self::single_activate(); // delete old options delete_option('wp-maintenance-mode'); delete_option('wp-maintenance-mode-msqld'); } } else { self::single_activate(); // delete old options delete_option('wp-maintenance-mode'); delete_option('wp-maintenance-mode-msqld'); } }
/** * Execute module uninstall * * @return void */ public function execute_uninstall() { $this->execute_deactivate(); delete_site_option('itsec_ssl'); delete_metadata('post', null, 'itsec_enable_ssl', null, true); delete_metadata('post', null, 'bwps_enable_ssl', null, true); }
function onp_updates_324_set_site_transient($transient, $value, $expiration = 0, $actions = false) { global $_wp_using_ext_object_cache; if ($actions) { $value = apply_filters('pre_set_site_transient_' . $transient, $value); } if ($_wp_using_ext_object_cache) { $result = wp_cache_set($transient, $value, 'site-transient', $expiration); } else { $transient_timeout = '_site_transient_timeout_' . $transient; $transient = '_site_transient_' . $transient; if (false === get_site_option($transient)) { if ($expiration) { add_site_option($transient_timeout, time() + $expiration); } $result = add_site_option($transient, $value); } else { if ($expiration) { update_site_option($transient_timeout, time() + $expiration); } delete_site_option($transient); $result = update_site_option($transient, $value); } } if ($result && $actions) { do_action('set_site_transient_' . $transient); do_action('setted_site_transient', $transient); } return $result; }
function ub_admin_menu_uninstall() { if (is_multisite() && is_plugin_active_for_network(plugin_basename(__FILE__))) { delete_site_option('ub_admin_menu'); } else { delete_option('ub_admin_menu'); } }
function __construct() { if (is_admin() && get_site_option('itsec_free_just_activated') && (!isset($_SERVER['HTTP_REFERER']) || strpos(sanitize_text_field($_SERVER['HTTP_REFERER']), 'action=upload-plugin') === false && strpos(sanitize_text_field($_SERVER['HTTP_REFERER']), 'action=install-plugin') === false)) { add_action('admin_init', array($this, 'deactivate_extra')); delete_site_option('itsec_free_just_activated'); } }
function kigo_plugin_deactivation() { if (!Kigo_Single_Sign_On::drop_table()) { wp_die('Error deactivating Kigo Sites plugin'); } delete_site_option('wp_plugin_kigo_sites_current_version'); }
static function uninstall() { global $wpdb; if (is_multisite()) { // Cleanup Network install foreach (wp_get_sites(array('limit' => apply_filters('gadwp_sites_limit', 100))) as $blog) { switch_to_blog($blog['blog_id']); $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_gadash%%'"); $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_gadash%%'"); $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_ga_dash%%'"); $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_ga_dash%%'"); delete_option('gadash_options'); delete_transient('ga_dash_lasterror'); delete_transient('ga_dash_refresh_token'); delete_transient('ga_dash_gapi_errors'); restore_current_blog(); } delete_site_option('gadash_network_options'); delete_site_transient('ga_dash_refresh_token'); } else { // Cleanup Single install $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_gadash%%'"); $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_gadash%%'"); $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_ga_dash%%'"); $sqlquery = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_ga_dash%%'"); delete_option('gadash_options'); delete_transient('ga_dash_lasterror'); delete_transient('ga_dash_refresh_token'); delete_transient('ga_dash_gapi_errors'); } }
function update_mu_htaccess($include_rs_rules = true) { //rs_errlog( "update_mu_htaccess: arg = $include_rs_rules" ); if (defined('SCOPER_NO_HTACCESS')) { return; } $include_rs_rules = $include_rs_rules && get_site_option('scoper_file_filtering'); // scoper_get_option is not reliable for initial execution following plugin activation if (!$include_rs_rules) { delete_site_option('scoper_file_filtered_sites'); } //rs_errlog( "update_mu_htaccess: $include_rs_rules" ); if (file_exists(ABSPATH . '/wp-admin/includes/file.php')) { include_once ABSPATH . '/wp-admin/includes/file.php'; } $home_path = get_home_path(); $htaccess_path = $home_path . '.htaccess'; if (!file_exists($htaccess_path)) { return; } $contents = file_get_contents($htaccess_path); if ($pos_def = ScoperRewriteMU::default_file_rule_pos($contents)) { $fp = fopen($htaccess_path, 'w'); if ($pos_rs_start = strpos($contents, "\n# BEGIN Role Scoper")) { fwrite($fp, substr($contents, 0, $pos_rs_start)); } else { fwrite($fp, substr($contents, 0, $pos_def)); } if ($include_rs_rules) { fwrite($fp, ScoperRewrite::build_site_rules(false)); } fwrite($fp, substr($contents, $pos_def)); fclose($fp); } }
public static function network_uninstall() { $sitewide = true; $lca = WpssoConfig::get_config('lca'); delete_site_option($lca . '_site_options'); self::do_multisite($sitewide, array(__CLASS__, 'uninstall_plugin')); }
function vaa_uninstall($blog_id = false) { // Delete all View Admin As options $option_keys = array('vaa_view_admin_as', 'vaa_role_defaults'); if ($blog_id) { if ($blog_id == 'site') { foreach ($option_keys as $option_key) { delete_site_option($option_key); } } else { foreach ($option_keys as $option_key) { delete_blog_option($blog_id, $option_key); } } } else { foreach ($option_keys as $option_key) { delete_option($option_key); } // Delete all View Admin As user metadata $user_meta_keys = array('vaa-view-admin-as'); // Older (not used anymore) keys $user_meta_keys[] = 'view-admin-as'; global $wpdb; $all_users = $wpdb->get_results("SELECT ID FROM {$wpdb->users}"); foreach ($all_users as $user) { foreach ($user_meta_keys as $user_meta_key) { delete_user_meta($user->ID, $user_meta_key); } } } }
public static function remote_request($args) { $name = x_addons_get_api_key_option_name(); $api_key = esc_attr(get_option($name)); if ($api_key == '') { $api_key = 'unverified'; } $args = wp_parse_args($args, array('action' => 'autoupdates', 'api-key' => $api_key, 'siteurl' => preg_replace('#(https?:)?//#', '', esc_attr(untrailingslashit(network_home_url()))), 'xversion' => X_VERSION)); $request_url = self::$base_url . trailingslashit($args['action']) . trailingslashit($args['api-key']); unset($args['action']); unset($args['api-key']); $uri = add_query_arg($args, $request_url); $request = wp_remote_get($uri, array('timeout' => 15)); $connection_error = array('code' => 4, 'message' => __('Could not establish connection. For assistance, please start by reviewing our article on troubleshooting <a href="https://community.theme.co/kb/connection-issues/">connection issues.</a>', '__x__')); if (is_wp_error($request) || $request['response']['code'] != 200) { self::store_error($request); return $connection_error; } $data = json_decode($request['body'], true); if (!isset($data['code'])) { return $connection_error; } // // Key was good but is now invalid (revoked). // if ($api_key != '' && $data['code'] == 3) { delete_option($name); delete_site_option('x_addon_list_cache'); } return $data; }
private static function multisite_uninstall() { delete_site_option(CLEF_OPTIONS_NAME); require_once CLEF_PATH . 'includes/class.clef-internal-settings.php'; delete_site_option(ClefInternalSettings::MS_OVERRIDE_OPTION); delete_site_option(ClefInternalSettings::MS_ENABLED_OPTION); }
function googlefontmgr_check_api_key($google_api_key) { global $is_networkactive; $message = ""; $api_url = "https://www.googleapis.com/webfonts/v1/webfonts?key="; $api_data = wp_remote_get($api_url . $google_api_key); //return codes if valid or not if (200 === $api_data['response']['code']) { if ($is_networkactive) { update_site_option('wp_googlefontmgr_globalkey', $google_api_key); } else { update_option('wp_googlefontmgr_apikey', $google_api_key); } echo "<div class='updated message'><p><strong>Success!</strong> Valid Google API Key...</p></div>"; return true; } else { $body = json_decode($api_data['body'], true); $response = $api_data['response']; $headers = $api_data['headers']; foreach ($body['error']['errors'] as $error) { if ("keyInvalid" == $error['reason']) { $message = "<div class='error message'><p><strong>ERROR:</strong> Invalid Google API Key</p></div>"; } } if ($message) { delete_site_option('wp_googlefontmgr_apikey'); delete_option('wp_googlefontmgr_apikey'); echo $message; return false; } } }
function rt_wp_nginx_helper_uninstall() { wp_clear_scheduled_hook('rt_wp_nginx_helper_check_log_file_size_daily'); delete_site_option('rt_wp_nginx_helper_options'); rt_wp_nginx_helper_remove_capability('Nginx Helper | Config'); rt_wp_nginx_helper_remove_capability('Nginx Helper | Purge cache'); }
function deleteData() { global $wpdb; delete_option('asgarosforum_options'); delete_option('asgarosforum_db_version'); // For site options in multisite delete_site_option('asgarosforum_options'); delete_site_option('asgarosforum_db_version'); // Delete user meta data delete_metadata('user', 0, 'asgarosforum_moderator', '', true); delete_metadata('user', 0, 'asgarosforum_banned', '', true); delete_metadata('user', 0, 'asgarosforum_subscription_topic', '', true); delete_metadata('user', 0, 'asgarosforum_subscription_forum', '', true); delete_metadata('user', 0, 'asgarosforum_subscription_global_topics', '', true); delete_metadata('user', 0, 'asgarosforum_unread_cleared', '', true); delete_metadata('user', 0, 'asgarosforum_unread_exclude', '', true); // Delete terms $terms = $wpdb->get_col('SELECT t.term_id FROM ' . $wpdb->terms . ' AS t INNER JOIN ' . $wpdb->term_taxonomy . ' AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = "asgarosforum-category";'); foreach ($terms as $term) { wp_delete_term($term, 'asgarosforum-category'); } // Drop custom tables $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}forum_forums;"); $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}forum_threads;"); $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}forum_posts;"); // Delete uploaded files $upload_dir = wp_upload_dir(); $upload_path = $upload_dir['basedir'] . '/asgarosforum/'; recursiveDelete($upload_path); // Delete themes $theme_path = WP_CONTENT_DIR . '/themes-asgarosforum'; recursiveDelete($theme_path); // Delete data which has been used in old versions of the plugin. delete_metadata('user', 0, 'asgarosforum_lastvisit', '', true); }
function update_admin_status() { global $wpdb; if (check_ajax_referer('pb-network-managers')) { $restricted = $wpdb->get_results('SELECT * FROM wp_sitemeta WHERE meta_key = "pressbooks_network_managers"'); if ($restricted) { $restricted = maybe_unserialize($restricted[0]->meta_value); } else { $restricted = array(); } $id = absint($_POST['admin_id']); if (1 === absint($_POST['status'])) { if (!in_array($id, $restricted)) { $restricted[] = $id; } } elseif (0 === absint($_POST['status'])) { if (($key = array_search($id, $restricted)) !== false) { unset($restricted[$key]); } } if (is_array($restricted) && !empty($restricted)) { update_site_option('pressbooks_network_managers', $restricted); } else { delete_site_option('pressbooks_network_managers'); } } }
function __construct() { $option_name = 'yalw_option'; delete_option($option_name); // For site options in Multisite delete_site_option($option_name); }
/** * Execute module upgrade * * @return void */ public function execute_upgrade($itsec_old_version) { if ($itsec_old_version < 4000) { global $itsec_bwps_options; $current_options = get_site_option('itsec_file_change'); if ($current_options === false) { $current_options = $this->defaults; } $current_options['enabled'] = isset($itsec_bwps_options['id_fileenabled']) && $itsec_bwps_options['id_fileenabled'] == 1 ? true : false; $current_options['email'] = isset($itsec_bwps_options['id_fileemailnotify']) && $itsec_bwps_options['id_fileemailnotify'] == 0 ? false : true; $current_options['notify_admin'] = isset($itsec_bwps_options['id_filedisplayerror']) && $itsec_bwps_options['id_filedisplayerror'] == 0 ? false : true; $current_options['method'] = isset($itsec_bwps_options['id_fileincex']) && $itsec_bwps_options['id_fileincex'] == 0 ? false : true; if (isset($itsec_bwps_options['id_specialfile']) && !is_array($itsec_bwps_options['id_specialfile']) && strlen($itsec_bwps_options['id_specialfile']) > 1) { $current_options['file_list'] .= explode(PHP_EOL, $itsec_bwps_options['id_specialfile']); } update_site_option('itsec_file_change', $current_options); } if ($itsec_old_version < 4028) { if (!is_multisite()) { $options = array('itsec_local_file_list', 'itsec_local_file_list_0', 'itsec_local_file_list_1', 'itsec_local_file_list_2', 'itsec_local_file_list_3', 'itsec_local_file_list_4', 'itsec_local_file_list_5', 'itsec_local_file_list_6'); foreach ($options as $option) { $list = get_site_option($option); if ($list !== false) { delete_site_option($option); add_option($option, $list, '', 'no'); } } } } }
public static function request($action, $query = array(), $data = array()) { if (false !== ($timeout_start = get_site_option('ithemes-updater-server-timed-out'))) { // Hold off updates for 30 minutes. $time_remaining = 1800 - (time() - $timeout_start); $minutes_remaining = ceil($time_remaining / 60); if ($time_remaining < 0) { delete_site_option('ithemes-updater-server-timed-out'); } else { return new WP_Error('ithemes-updater-timed-out-server', sprintf(_n('The server could not be contacted. Requests are delayed for %d minute to allow the server to recover.', 'The server could not be contacted. Requests are delayed for %d minutes to allow the server to recover.', $minutes_remaining, 'it-l10n-Builder-Madison'), $minutes_remaining)); } } if (isset($data['auth_token'])) { $data['iterations'] = self::$password_iterations; } $site_url = self::get_site_url(); $default_query = array('wp' => $GLOBALS['wp_version'], 'site' => $site_url, 'timestamp' => time()); if (is_multisite()) { $default_query['ms'] = 1; } $query = array_merge($default_query, $query); $request = "/{$action}/?" . http_build_query($query, '', '&'); $post_data = array('request' => json_encode($data)); $remote_post_args = array('timeout' => 10, 'body' => $post_data); $options = array('use_ca_patch' => false, 'use_ssl' => true); $patch_enabled = $GLOBALS['ithemes-updater-settings']->get_option('use_ca_patch'); if ($patch_enabled) { $GLOBALS['ithemes-updater-settings']->disable_ssl_ca_patch(); } $response = wp_remote_post(self::$secure_server_url . $request, $remote_post_args); if (is_wp_error($response) && 'connect() timed out!' != $response->get_error_message()) { $GLOBALS['ithemes-updater-settings']->enable_ssl_ca_patch(); $response = wp_remote_post(self::$secure_server_url . $request, $remote_post_args); if (!is_wp_error($response)) { $options['use_ca_patch'] = true; } } if (is_wp_error($response) && 'connect() timed out!' != $response->get_error_message()) { $response = wp_remote_post(self::$insecure_server_url . $request, $remote_post_args); $options['use_ssl'] = false; } if (!$options['use_ca_patch']) { $GLOBALS['ithemes-updater-settings']->disable_ssl_ca_patch(); } $GLOBALS['ithemes-updater-settings']->update_options($options); if (is_wp_error($response)) { if ('connect() timed out!' == $response->get_error_message()) { // Set option to delay server checks for a period of time. update_site_option('ithemes-updater-server-timed-out', time()); return new WP_Error('http_request_failed', __('The server was unable to be contacted.', 'it-l10n-Builder-Madison')); } return $response; } $body = json_decode($response['body'], true); if (!empty($body['error'])) { return new WP_Error($body['error']['type'], sprintf(__('An error occurred when communicating with the iThemes update server: %s (%s)', 'it-l10n-Builder-Madison'), $body['error']['message'], $body['error']['code'])); } return $body; }
/** * Unlink user callback in the database (ajax) */ function plugpress_unlink_callback() { $option_name = 'plugpress_account_user'; $transient_name = $option_name . '_check'; $user = delete_site_option($option_name); $user_check = delete_site_transient($transient_name); die; }
function ub_delete_option($option) { if (is_multisite() && function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('ultimate-branding/ultimate-branding.php')) { return delete_site_option($option); } else { return delete_option($option); } }
/** * Removes plugin options * @since 1.3.0 */ public static function delete_options() { delete_site_option('mucd_copy_files'); delete_site_option('mucd_keep_users'); delete_site_option('mucd_log'); delete_site_option('mucd_log_dir'); MUCD_Option::delete_duplicable_option(); }
function delete_option($key) { if (is_multisite()) { return delete_site_option($key); } else { return delete_option($key); } }
public static function delete_option($option) { if (defined('SP_ONMS')) { return delete_site_option($option); } else { return delete_option($option); } }
/** Delete plugin options */ function pp_delete_single_site_option() { delete_option('pp_settings_data'); delete_option('pp_plugin_lite_activated'); delete_option('pp_version'); delete_site_option('pp_db_ver'); delete_option('pp_db_lite_ver'); }
function delete_autoblog_option($key) { if (is_multisite() && function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('autoblog/autoblogpremium.php') && defined('AUTOBLOG_GLOBAL') && AUTOBLOG_GLOBAL == true) { return delete_site_option($key); } else { return delete_option($key); } }
function gsexpertsearch_uninstall() { global $wpdb; //$table = $wpdb->base_prefix."wp_options"; delete_site_option('gsexpertsearch_search_area'); delete_site_option('gsexpertsearch_apiurl'); delete_site_option('gsexpertsearch_apikey'); }
/** * Uninstall hook. * * Executed when (deactivated) plugin is deleted. Clean up custom * options, db tables. * * @return void */ public static function uninstall() { $options = ['bpdiff_settings']; foreach ($options as $option) { delete_option($option); delete_site_option($option); } }
/** * Save settings form data */ public static function save_post_form() { if (!current_user_can('backwpup_settings')) { return; } //set default options if button clicked if (isset($_POST['default_settings']) && $_POST['default_settings']) { delete_site_option('backwpup_cfg_showadminbar'); delete_site_option('backwpup_cfg_showfoldersize'); delete_site_option('backwpup_cfg_jobsteprestart'); delete_site_option('backwpup_cfg_jobstepretry'); delete_site_option('backwpup_cfg_jobmaxexecutiontime'); delete_site_option('backwpup_cfg_jobziparchivemethod'); delete_site_option('backwpup_cfg_jobnotranslate'); delete_site_option('backwpup_cfg_jobwaittimems'); delete_site_option('backwpup_cfg_maxlogs'); delete_site_option('backwpup_cfg_gzlogs'); delete_site_option('backwpup_cfg_protectfolders'); delete_site_option('backwpup_cfg_httpauthuser'); delete_site_option('backwpup_cfg_httpauthpassword'); delete_site_option('backwpup_cfg_logfolder'); BackWPup_Admin::message(__('Settings reset to default', 'backwpup')); return; } update_site_option('backwpup_cfg_showadminbar', isset($_POST['showadminbar']) ? 1 : 0); update_site_option('backwpup_cfg_showfoldersize', isset($_POST['showfoldersize']) ? 1 : 0); update_site_option('backwpup_cfg_jobsteprestart', isset($_POST['jobsteprestart']) ? 1 : 0); if (100 > $_POST['jobstepretry'] && 0 < $_POST['jobstepretry']) { $_POST['jobstepretry'] = abs((int) $_POST['jobstepretry']); } if (empty($_POST['jobstepretry']) or !is_int($_POST['jobstepretry'])) { $_POST['jobstepretry'] = 3; } update_site_option('backwpup_cfg_jobstepretry', $_POST['jobstepretry']); update_site_option('backwpup_cfg_jobmaxexecutiontime', abs((int) $_POST['jobmaxexecutiontime'])); update_site_option('backwpup_cfg_jobziparchivemethod', $_POST['jobziparchivemethod'] == '' || $_POST['jobziparchivemethod'] == 'PclZip' || $_POST['jobziparchivemethod'] == 'ZipArchive' ? $_POST['jobziparchivemethod'] : ''); update_site_option('backwpup_cfg_jobnotranslate', isset($_POST['jobnotranslate']) ? 1 : 0); update_site_option('backwpup_cfg_jobwaittimems', $_POST['jobwaittimems']); update_site_option('backwpup_cfg_maxlogs', abs((int) $_POST['maxlogs'])); update_site_option('backwpup_cfg_gzlogs', isset($_POST['gzlogs']) ? 1 : 0); update_site_option('backwpup_cfg_protectfolders', isset($_POST['protectfolders']) ? 1 : 0); update_site_option('backwpup_cfg_httpauthuser', $_POST['httpauthuser']); update_site_option('backwpup_cfg_httpauthpassword', BackWPup_Encryption::encrypt($_POST['httpauthpassword'])); $_POST['jobrunauthkey'] = preg_replace('/[^a-zA-Z0-9]/', '', trim($_POST['jobrunauthkey'])); update_site_option('backwpup_cfg_jobrunauthkey', $_POST['jobrunauthkey']); $_POST['logfolder'] = trailingslashit(str_replace('\\', '/', trim(stripslashes($_POST['logfolder'])))); if ($_POST['logfolder'][0] == '.' || $_POST['logfolder'][0] != '/' && !preg_match('#^[a-zA-Z]:/#', $_POST['logfolder'])) { $_POST['logfolder'] = trailingslashit(str_replace('\\', '/', ABSPATH)) . $_POST['logfolder']; } //set def. folders if (empty($_POST['logfolder']) || $_POST['logfolder'] == '/') { delete_site_option('backwpup_cfg_logfolder'); } else { update_site_option('backwpup_cfg_logfolder', $_POST['logfolder']); } do_action('backwpup_page_settings_save'); BackWPup_Admin::message(__('Settings saved', 'backwpup')); }