Пример #1
0
 public function load_meta_page($screen = false)
 {
     // all meta modules set this property, so use it to optimize code execution
     if (!empty(NgfbMeta::$head_meta_tags) || !isset($screen->id)) {
         return;
     }
     if ($this->p->debug->enabled) {
         $this->p->debug->mark();
         $this->p->debug->log('screen id: ' . $screen->id);
         $this->p->util->log_is_functions();
     }
     $lca = $this->p->cf['lca'];
     switch ($screen->id) {
         case 'upload':
         case strpos($screen->id, 'edit-') === 0 ? true : false:
             // posts list table
             return;
             break;
     }
     // make sure we have at least a post type and post status
     if (($obj = $this->p->util->get_post_object()) === false || empty($obj->post_type) || empty($obj->post_status)) {
         return;
     }
     $post_id = empty($obj->ID) ? 0 : $obj->ID;
     if ($obj->post_status !== 'auto-draft') {
         $post_type = get_post_type_object($obj->post_type);
         $add_metabox = empty($this->p->options['plugin_add_to_' . $post_type->name]) ? false : true;
         if (apply_filters($this->p->cf['lca'] . '_add_metabox_post', $add_metabox, $post_id, $post_type->name) === true) {
             // hook used by woocommerce module to load front-end libraries and start a session
             do_action($this->p->cf['lca'] . '_admin_post_header', $post_id, $post_type->name);
             // read_cache is false to generate notices etc.
             NgfbMeta::$head_meta_tags = $this->p->head->get_header_array($post_id, false);
             NgfbMeta::$head_meta_info = $this->p->head->extract_head_info(NgfbMeta::$head_meta_tags);
             if ($obj->post_status === 'publish') {
                 // check for missing open graph image and issue warning
                 if (empty(NgfbMeta::$head_meta_info['og:image'])) {
                     $this->p->notice->err($this->p->msgs->get('notice-missing-og-image'));
                 }
                 // check duplicates only when the post is available publicly and we have a valid permalink
                 if (!empty($this->p->options['plugin_check_head'])) {
                     $this->check_post_header($post_id, $obj);
                 }
             }
         }
     }
     $action_query = $lca . '-action';
     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], NgfbAdmin::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) {
                 default:
                     do_action($lca . '_load_meta_page_post_' . $action_name, $post_id, $obj);
                     break;
             }
         }
     }
 }
Пример #2
0
 public function load_meta_page($screen = false)
 {
     // all meta modules set this property, so use it to optimize code execution
     if (!empty(NgfbMeta::$head_meta_tags) || !isset($screen->id)) {
         return;
     }
     if ($this->p->debug->enabled) {
         $this->p->debug->mark();
         $this->p->debug->log('screen id: ' . $screen->id);
     }
     $lca = $this->p->cf['lca'];
     switch ($screen->id) {
         case 'edit-' . $this->tax_slug:
             break;
         default:
             return;
             break;
     }
     $add_metabox = empty($this->p->options['plugin_add_to_taxonomy']) ? false : true;
     if (apply_filters($this->p->cf['lca'] . '_add_metabox_taxonomy', $add_metabox, $this->term_id, $screen->id) === true) {
         do_action($this->p->cf['lca'] . '_admin_taxonomy_header', $this->term_id, $screen->id);
         // use_post is false since this isn't a post
         // read_cache is false to generate notices etc.
         NgfbMeta::$head_meta_tags = $this->p->head->get_header_array(false);
         NgfbMeta::$head_meta_info = $this->p->head->extract_head_info(NgfbMeta::$head_meta_tags);
         if (empty(NgfbMeta::$head_meta_info['og:image'])) {
             // check for missing open graph image and issue warning
             $this->p->notice->err($this->p->msgs->get('notice-missing-og-image'));
         }
     }
     $action_query = $lca . '-action';
     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], NgfbAdmin::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) {
                 default:
                     do_action($lca . '_load_meta_page_taxonomy_' . $action_name, $this->term_id);
                     break;
             }
         }
     }
 }