Beispiel #1
0
 private static function uninstall_plugin()
 {
     global $wpdb;
     $cf = WpssoConfig::get_config();
     $slug = $cf['plugin'][$cf['lca']]['slug'];
     $options = get_option($cf['lca'] . '_options');
     if (empty($options['plugin_preserve'])) {
         delete_option($cf['lca'] . '_options');
         delete_post_meta_by_key('_' . $cf['lca'] . '_meta');
         WpssoUser::delete_metabox_prefs();
     }
     // delete update related options
     delete_option('external_updates-' . $slug);
     delete_option($cf['lca'] . '_umsg');
     delete_option($cf['lca'] . '_utime');
     // delete stored admin notices
     foreach (array('nag', 'err', 'inf') as $type) {
         $msg_opt = $cf['lca'] . '_notices_' . $type;
         delete_option($msg_opt);
         foreach (get_users(array('meta_key' => $msg_opt)) as $user) {
             delete_user_option($user->ID, $msg_opt);
         }
     }
     // delete transients
     $dbquery = 'SELECT option_name FROM ' . $wpdb->options . ' WHERE option_name LIKE \'_transient_timeout_' . $cf['lca'] . '_%\';';
     $expired = $wpdb->get_col($dbquery);
     foreach ($expired as $transient) {
         $key = str_replace('_transient_timeout_', '', $transient);
         if (!empty($key)) {
             delete_transient($key);
         }
     }
 }
Beispiel #2
0
 public function set_config()
 {
     $this->cf = WpssoConfig::get_config(null, true);
     // apply filters - define the $cf['*'] array
 }
Beispiel #3
0
 public static function delete_metabox_prefs($user_id = false)
 {
     $user_id = $user_id === false ? get_current_user_id() : $user_id;
     $cf = WpssoConfig::get_config(false, true);
     $parent_slug = 'options-general.php';
     foreach (array_keys($cf['*']['lib']['setting']) as $id) {
         $menu_slug = $cf['lca'] . '-' . $id;
         self::delete_metabox_pagehook($user_id, $menu_slug, $parent_slug);
     }
     $parent_slug = $cf['lca'] . '-' . key($cf['*']['lib']['submenu']);
     foreach (array_keys($cf['*']['lib']['submenu']) as $id) {
         $menu_slug = $cf['lca'] . '-' . $id;
         self::delete_metabox_pagehook($user_id, $menu_slug, $parent_slug);
     }
 }
 private static function uninstall_plugin()
 {
     $cf = WpssoConfig::get_config();
     if (!defined('WPSSO_OPTIONS_NAME')) {
         define('WPSSO_OPTIONS_NAME', $cf['lca'] . '_options');
     }
     if (!defined('WPSSO_META_NAME')) {
         define('WPSSO_META_NAME', '_' . $cf['lca'] . '_meta');
     }
     if (!defined('WPSSO_PREF_NAME')) {
         define('WPSSO_PREF_NAME', '_' . $cf['lca'] . '_pref');
     }
     $slug = $cf['plugin'][$cf['lca']]['slug'];
     $opts = get_option(WPSSO_OPTIONS_NAME);
     if (empty($opts['plugin_preserve'])) {
         delete_option(WPSSO_OPTIONS_NAME);
         delete_post_meta_by_key(WPSSO_META_NAME);
         foreach (array(WPSSO_META_NAME, WPSSO_PREF_NAME) as $meta_key) {
             foreach (get_users(array('meta_key' => $meta_key)) as $user) {
                 delete_user_option($user->ID, $meta_key);
                 WpssoUser::delete_metabox_prefs($user->ID);
             }
         }
         foreach (WpssoTaxonomy::get_public_terms() as $term_id) {
             WpssoTaxonomy::delete_term_meta($term_id, WPSSO_META_NAME);
         }
     }
     // delete transients
     global $wpdb;
     $dbquery = 'SELECT option_name FROM ' . $wpdb->options . ' WHERE option_name LIKE \'_transient_timeout_' . $cf['lca'] . '_%\';';
     $expired = $wpdb->get_col($dbquery);
     foreach ($expired as $transient) {
         $key = str_replace('_transient_timeout_', '', $transient);
         if (!empty($key)) {
             delete_transient($key);
         }
     }
 }