public function load_form_page() { wp_enqueue_script('postbox'); $upload_dir = wp_upload_dir(); // returns assoc array with path info $user_opts = $this->p->addons['util']['user']->get_options(); if (!empty($_GET['action'])) { if (empty($_GET[NGFB_NONCE])) { $this->p->debug->log('Nonce token validation query field missing.'); } elseif (!wp_verify_nonce($_GET[NGFB_NONCE], $this->get_nonce())) { $this->p->notice->err(__('Nonce token validation failed for plugin action (action ignored).', NGFB_TEXTDOM)); } else { switch ($_GET['action']) { case 'check_for_updates': if (!empty($this->p->options['plugin_' . $this->p->cf['lca'] . '_tid'])) { $this->readme_info = array(); $this->p->update->check_for_updates(null, true); } break; case 'clear_all_cache': $deleted_cache = $this->p->util->delete_expired_file_cache(true); $deleted_transient = $this->p->util->delete_expired_transients(true); wp_cache_flush(); if (function_exists('w3tc_pgcache_flush')) { w3tc_pgcache_flush(); } elseif (function_exists('wp_cache_clear_cache')) { wp_cache_clear_cache(); } $this->p->notice->inf(__('Cached files, WP object cache, transient cache, and any additional caches, ' . 'like APC, Memcache, Xcache, W3TC, Super Cache, etc. have all been cleared.', NGFB_TEXTDOM)); break; case 'clear_metabox_prefs': NgfbUser::delete_metabox_prefs(get_current_user_id()); break; case 'change_display_options': if (isset($this->p->cf['form']['display_options'][$_GET['display_options']])) { $this->p->options['plugin_display'] = $_GET['display_options']; } $this->p->opt->save_options(NGFB_OPTIONS_NAME, $this->p->options); break; } } } // the plugin information metabox on all settings pages needs this $this->p->admin->set_readme_info($this->feed_cache_expire()); // add child metaboxes first, since they contain the default reset_metabox_prefs() $this->p->admin->submenu[$this->menu_id]->add_meta_boxes(); if (empty($this->p->options['plugin_' . $this->p->cf['lca'] . '_tid']) || !$this->p->check->aop()) { add_meta_box($this->pagehook . '_purchase', __('Pro Version', NGFB_TEXTDOM), array(&$this, 'show_metabox_purchase'), $this->pagehook, 'side'); add_filter('postbox_classes_' . $this->pagehook . '_' . $this->pagehook . '_purchase', array(&$this, 'add_class_postbox_highlight_side')); $this->p->addons['util']['user']->reset_metabox_prefs($this->pagehook, array('purchase'), null, 'side', true); } add_meta_box($this->pagehook . '_help', __('Help and Support', NGFB_TEXTDOM), array(&$this, 'show_metabox_help'), $this->pagehook, 'side'); add_meta_box($this->pagehook . '_info', __('Version Information', NGFB_TEXTDOM), array(&$this, 'show_metabox_info'), $this->pagehook, 'side'); add_meta_box($this->pagehook . '_status_gpl', __('Standard Features', NGFB_TEXTDOM), array(&$this, 'show_metabox_status_gpl'), $this->pagehook, 'side'); add_meta_box($this->pagehook . '_status_pro', __('Pro Features', NGFB_TEXTDOM), array(&$this, 'show_metabox_status_pro'), $this->pagehook, 'side'); }
public function load_form_page() { wp_enqueue_script('postbox'); if (!empty($_GET['action'])) { if (empty($_GET[NGFB_NONCE])) { $this->p->debug->log('nonce token validation query field missing'); } elseif (!wp_verify_nonce($_GET[NGFB_NONCE], $this->get_nonce())) { $this->p->notice->err(__('Nonce token validation failed for plugin action (action ignored).', NGFB_TEXTDOM)); } else { switch ($_GET['action']) { case 'check_for_updates': if ($this->p->is_avail['util']['um']) { $this->readme_info = array(); $ngfbum = NgfbUm::get_instance(); $ngfbum->update->check_for_updates(null, true, false); } else { $um_lca = $this->p->cf['lca'] . 'um'; $um_name = $this->p->cf['plugin'][$um_lca]['name']; $this->p->notice->err('The <strong>' . $um_name . '</strong> extension plugin is required to check for plugin and extension updates.'); } break; case 'clear_all_cache': $this->p->util->clear_all_cache(); break; case 'clear_metabox_prefs': NgfbUser::delete_metabox_prefs(get_current_user_id()); break; case 'change_show_options': if (isset($this->p->cf['form']['show_options'][$_GET['show_opts']])) { NgfbUser::save_pref(array('show_opts' => $_GET['show_opts'])); } break; } } } // the plugin information metabox on all settings pages needs this $this->p->admin->set_readme_info($this->p->cf['feed_cache_exp']); // add child metaboxes first, since they contain the default reset_metabox_prefs() $this->p->admin->submenu[$this->menu_id]->add_meta_boxes(); if (empty($this->p->options['plugin_' . $this->p->cf['lca'] . '_tid']) || !$this->p->check->aop()) { add_meta_box($this->pagehook . '_purchase', __('Pro Version', NGFB_TEXTDOM), array(&$this, 'show_metabox_purchase'), $this->pagehook, 'side'); add_filter('postbox_classes_' . $this->pagehook . '_' . $this->pagehook . '_purchase', array(&$this, 'add_class_postbox_highlight_side')); $this->p->mods['util']['user']->reset_metabox_prefs($this->pagehook, array('purchase'), null, 'side', true); } add_meta_box($this->pagehook . '_info', __('Version Information', NGFB_TEXTDOM), array(&$this, 'show_metabox_info'), $this->pagehook, 'side'); add_meta_box($this->pagehook . '_status_gpl', __('Basic / Common Features', NGFB_TEXTDOM), array(&$this, 'show_metabox_status_gpl'), $this->pagehook, 'side'); add_meta_box($this->pagehook . '_status_pro', __('Pro Version Features', NGFB_TEXTDOM), array(&$this, 'show_metabox_status_pro'), $this->pagehook, 'side'); add_meta_box($this->pagehook . '_help', __('Help and Support', NGFB_TEXTDOM), array(&$this, 'show_metabox_help'), $this->pagehook, 'side'); }
private static function uninstall_plugin() { global $wpdb; $cf = NgfbConfig::get_config(); $options = get_option($cf['lca'] . '_options'); if (empty($options['plugin_preserve'])) { delete_option($cf['lca'] . '_options'); delete_post_meta_by_key('_' . $cf['lca'] . '_meta'); NgfbUser::delete_metabox_prefs(); } // delete update related options delete_option('external_updates-' . $cf['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); } } }
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); } } }
public function load_setting_page() { $lca = $this->p->cf['lca']; $action_query = $lca . '-action'; wp_enqueue_script('postbox'); if (!empty($_GET[$action_query])) { $action_name = SucomUtil::sanitize_hookname($_GET[$action_query]); if (empty($_GET[NGFB_NONCE])) { if ($this->p->debug->enabled) { $this->p->debug->log('nonce token validation query field missing'); } } elseif (!wp_verify_nonce($_GET[NGFB_NONCE], self::get_nonce())) { $this->p->notice->err(__('Nonce token validation failed for action \\"' . $action_name . '\\".', 'nextgen-facebook')); } else { $_SERVER['REQUEST_URI'] = remove_query_arg(array($action_query, NGFB_NONCE)); switch ($action_name) { case 'check_for_updates': if ($this->p->is_avail['util']['um']) { self::$readme_info = array(); $ngfbum = NgfbUm::get_instance(); $ngfbum->update->check_for_updates(null, true, false); } else { $this->p->notice->err(sprintf(__('The <b>%s</b> extension is required to check for Pro version updates.', 'nextgen-facebook'), $this->p->cf['plugin'][$lca . 'um']['name'])); } break; case 'clear_all_cache': $this->p->util->clear_all_cache(); break; case 'clear_metabox_prefs': $user_id = get_current_user_id(); $user = get_userdata($user_id); //$user_name = trim( $user->first_name.' '.$user->last_name ); $user_name = $user->display_name; NgfbUser::delete_metabox_prefs($user_id); $this->p->notice->inf(sprintf(__('Metabox layout preferences for user ID #%d "%s" have been reset.', 'nextgen-facebook'), $user_id, $user_name)); break; case 'clear_hidden_notices': $user_id = get_current_user_id(); $user = get_userdata($user_id); //$user_name = trim( $user->first_name.' '.$user->last_name ); $user_name = $user->display_name; delete_user_option($user_id, NGFB_DISMISS_NAME); $this->p->notice->inf(sprintf(__('Hidden notices for user ID #%d "%s" have been cleared.', 'nextgen-facebook'), $user_id, $user_name)); break; case 'change_show_options': if (isset($this->p->cf['form']['show_options'][$_GET['show-opts']])) { $this->p->notice->inf(sprintf('Option preference saved — viewing "%s" by default.', $this->p->cf['form']['show_options'][$_GET['show-opts']])); NgfbUser::save_pref(array('show_opts' => $_GET['show-opts'])); } $_SERVER['REQUEST_URI'] = remove_query_arg(array('show-opts')); break; case 'modify_tmpl_head_elements': $this->modify_tmpl_head_elements(); break; default: do_action($lca . '_load_setting_page_' . $action_name, $this->pagehook, $this->menu_id, $this->menu_name, $this->menu_lib); break; } } } // the plugin information metabox on all settings pages needs this $this->p->admin->set_readme_info($this->p->cf['feed_cache_exp']); // add child metaboxes first, since they contain the default reset_metabox_prefs() $this->p->admin->submenu[$this->menu_id]->add_meta_boxes(); if (empty($this->p->options['plugin_' . $lca . '_tid']) || !$this->p->check->aop($lca, true, $this->p->is_avail['aop'])) { add_meta_box($this->pagehook . '_purchase', _x('Pro / Power-User Version', 'metabox title (side)', 'nextgen-facebook'), array(&$this, 'show_metabox_purchase'), $this->pagehook, 'side'); $this->p->mods['util']['user']->reset_metabox_prefs($this->pagehook, array('purchase'), null, 'side', true); } add_meta_box($this->pagehook . '_help', _x('Help and Support', 'metabox title (side)', 'nextgen-facebook'), array(&$this, 'show_metabox_help'), $this->pagehook, 'side'); if ($this->menu_lib === 'submenu') { add_meta_box($this->pagehook . '_status_gpl', _x('Standard Features', 'metabox title (side)', 'nextgen-facebook'), array(&$this, 'show_metabox_status_gpl'), $this->pagehook, 'side'); add_meta_box($this->pagehook . '_status_pro', _x('Pro Version Features', 'metabox title (side)', 'nextgen-facebook'), array(&$this, 'show_metabox_status_pro'), $this->pagehook, 'side'); } if ($this->menu_lib === 'submenu' || $this->menu_lib === 'sitesubmenu') { add_meta_box($this->pagehook . '_version_info', _x('Version Information', 'metabox title (side)', 'nextgen-facebook'), array(&$this, 'show_metabox_version_info'), $this->pagehook, 'side'); } }
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); } } }