Example #1
0
 private static function uninstall_plugin()
 {
     $var_const = WpssoConfig::get_variable_constants();
     $opts = get_option($var_const['WPSSO_OPTIONS_NAME'], array());
     delete_option($var_const['WPSSO_TS_NAME']);
     delete_option($var_const['WPSSO_NOTICE_NAME']);
     if (empty($opts['plugin_preserve'])) {
         delete_option($var_const['WPSSO_OPTIONS_NAME']);
         delete_post_meta_by_key($var_const['WPSSO_META_NAME']);
         foreach (get_users() as $user) {
             // site specific user options
             delete_user_option($user->ID, $var_const['WPSSO_NOTICE_NAME']);
             delete_user_option($user->ID, $var_const['WPSSO_DISMISS_NAME']);
             // global / network user options
             delete_user_meta($user->ID, $var_const['WPSSO_META_NAME']);
             delete_user_meta($user->ID, $var_const['WPSSO_PREF_NAME']);
             WpssoUser::delete_metabox_prefs($user->ID);
         }
         foreach (WpssoTaxonomy::get_public_terms() as $term_id) {
             WpssoTaxonomy::delete_term_meta($term_id, $var_const['WPSSO_META_NAME']);
         }
     }
     // delete transients
     global $wpdb;
     $dbquery = 'SELECT option_name FROM ' . $wpdb->options . ' WHERE option_name LIKE \'_transient_timeout_wpsso_%\';';
     $expired = $wpdb->get_col($dbquery);
     foreach ($expired as $transient) {
         $key = str_replace('_transient_timeout_', '', $transient);
         if (!empty($key)) {
             delete_transient($key);
         }
     }
 }
 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);
         }
     }
 }