Exemple #1
0
 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[WPSSO_NONCE])) {
             if ($this->p->debug->enabled) {
                 $this->p->debug->log('nonce token validation query field missing');
             }
         } elseif (!wp_verify_nonce($_GET[WPSSO_NONCE], self::get_nonce())) {
             $this->p->notice->err(__('Nonce token validation failed for action \\"' . $action_name . '\\".', 'wpsso'));
         } else {
             $_SERVER['REQUEST_URI'] = remove_query_arg(array($action_query, WPSSO_NONCE));
             switch ($action_name) {
                 case 'check_for_updates':
                     if ($this->p->is_avail['util']['um']) {
                         self::$readme_info = array();
                         $wpssoum = WpssoUm::get_instance();
                         $wpssoum->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.', 'wpsso'), $this->p->cf['plugin'][$lca . 'um']['name']));
                     }
                     break;
                 case 'clear_all_cache':
                     $this->p->util->clear_all_cache();
                     break;
                 case 'clear_metabox_prefs':
                     $user = get_userdata(get_current_user_id());
                     $user_name = $user->first_name . ' ' . $user->last_name;
                     WpssoUser::delete_metabox_prefs($user->ID);
                     $this->p->notice->inf(sprintf(__('Metabox layout preferences for user "%s" have been reset.', 'wpsso'), $user_name));
                     break;
                 case 'clear_hidden_notices':
                     $user = get_userdata(get_current_user_id());
                     $user_name = $user->first_name . ' ' . $user->last_name;
                     delete_user_option($user->ID, WPSSO_DISMISS_NAME);
                     $this->p->notice->inf(sprintf(__('Hidden notices for user "%s" have been cleared.', 'wpsso'), $user_name));
                     break;
                 case 'change_show_options':
                     if (isset($this->p->cf['form']['show_options'][$_GET['show-opts']])) {
                         WpssoUser::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);
                     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)', 'wpsso'), 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', _x('Version Information', 'metabox title (side)', 'wpsso'), array(&$this, 'show_metabox_info'), $this->pagehook, 'side');
     add_meta_box($this->pagehook . '_status_gpl', _x('Free / Basic Features', 'metabox title (side)', 'wpsso'), array(&$this, 'show_metabox_status_gpl'), $this->pagehook, 'side');
     add_meta_box($this->pagehook . '_status_pro', _x('Pro Version Features', 'metabox title (side)', 'wpsso'), array(&$this, 'show_metabox_status_pro'), $this->pagehook, 'side');
     add_meta_box($this->pagehook . '_help', _x('Help and Support', 'metabox title (side)', 'wpsso'), array(&$this, 'show_metabox_help'), $this->pagehook, 'side');
 }
 public function load_form_page()
 {
     wp_enqueue_script('postbox');
     if (!empty($_GET['action'])) {
         if (empty($_GET[WPSSO_NONCE])) {
             $this->p->debug->log('nonce token validation query field missing');
         } elseif (!wp_verify_nonce($_GET[WPSSO_NONCE], $this->get_nonce())) {
             $this->p->notice->err(__('Nonce token validation failed for plugin action (action ignored).', WPSSO_TEXTDOM));
         } else {
             switch ($_GET['action']) {
                 case 'check_for_updates':
                     if ($this->p->is_avail['util']['um']) {
                         $this->readme_info = array();
                         $wpssoum = WpssoUm::get_instance();
                         $wpssoum->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':
                     WpssoUser::delete_metabox_prefs(get_current_user_id());
                     break;
                 case 'change_show_options':
                     if (isset($this->p->cf['form']['show_options'][$_GET['show_opts']])) {
                         WpssoUser::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', WPSSO_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', WPSSO_TEXTDOM), array(&$this, 'show_metabox_info'), $this->pagehook, 'side');
     add_meta_box($this->pagehook . '_status_gpl', __('Basic / Common Features', WPSSO_TEXTDOM), array(&$this, 'show_metabox_status_gpl'), $this->pagehook, 'side');
     add_meta_box($this->pagehook . '_status_pro', __('Pro Version Features', WPSSO_TEXTDOM), array(&$this, 'show_metabox_status_pro'), $this->pagehook, 'side');
     add_meta_box($this->pagehook . '_help', __('Help and Support', WPSSO_TEXTDOM), array(&$this, 'show_metabox_help'), $this->pagehook, 'side');
 }