Exemplo n.º 1
0
 private static function uninstall_plugin()
 {
     $var_const = NgfbConfig::get_variable_constants();
     $opts = get_option($var_const['NGFB_OPTIONS_NAME'], array());
     delete_option($var_const['NGFB_TS_NAME']);
     delete_option($var_const['NGFB_NOTICE_NAME']);
     if (empty($opts['plugin_preserve'])) {
         delete_option($var_const['NGFB_OPTIONS_NAME']);
         delete_post_meta_by_key($var_const['NGFB_META_NAME']);
         foreach (get_users() as $user) {
             // site specific user options
             delete_user_option($user->ID, $var_const['NGFB_NOTICE_NAME']);
             delete_user_option($user->ID, $var_const['NGFB_DISMISS_NAME']);
             // global / network user options
             delete_user_meta($user->ID, $var_const['NGFB_META_NAME']);
             delete_user_meta($user->ID, $var_const['NGFB_PREF_NAME']);
             NgfbUser::delete_metabox_prefs($user->ID);
         }
         foreach (NgfbTaxonomy::get_public_terms() as $term_id) {
             NgfbTaxonomy::delete_term_meta($term_id, $var_const['NGFB_META_NAME']);
         }
     }
     // delete transients
     global $wpdb;
     $dbquery = 'SELECT option_name FROM ' . $wpdb->options . ' WHERE option_name LIKE \'_transient_timeout_ngfb_%\';';
     $expired = $wpdb->get_col($dbquery);
     foreach ($expired as $transient) {
         $key = str_replace('_transient_timeout_', '', $transient);
         if (!empty($key)) {
             delete_transient($key);
         }
     }
 }
Exemplo n.º 2
0
 private static function uninstall_plugin()
 {
     $cf = NgfbConfig::get_config();
     if (!defined('NGFB_OPTIONS_NAME')) {
         define('NGFB_OPTIONS_NAME', $cf['lca'] . '_options');
     }
     if (!defined('NGFB_META_NAME')) {
         define('NGFB_META_NAME', '_' . $cf['lca'] . '_meta');
     }
     if (!defined('NGFB_PREF_NAME')) {
         define('NGFB_PREF_NAME', '_' . $cf['lca'] . '_pref');
     }
     $slug = $cf['plugin'][$cf['lca']]['slug'];
     $opts = get_option(NGFB_OPTIONS_NAME);
     if (empty($opts['plugin_preserve'])) {
         delete_option(NGFB_OPTIONS_NAME);
         delete_post_meta_by_key(NGFB_META_NAME);
         foreach (array(NGFB_META_NAME, NGFB_PREF_NAME) as $meta_key) {
             foreach (get_users(array('meta_key' => $meta_key)) as $user) {
                 delete_user_option($user->ID, $meta_key);
                 NgfbUser::delete_metabox_prefs($user->ID);
             }
         }
         foreach (NgfbTaxonomy::get_public_terms() as $term_id) {
             NgfbTaxonomy::delete_term_meta($term_id, NGFB_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);
         }
     }
 }