Ejemplo n.º 1
0
 protected function add_actions()
 {
     if (is_admin()) {
         /**
          * Hook a minimum number of admin actions to maximize performance.
          * The post or post_ID arguments are always present when we're
          * editing a post and/or page.
          */
         if (SucomUtil::is_post_page()) {
             add_action('add_meta_boxes', array(&$this, 'add_metaboxes'));
             add_action('admin_head', array(&$this, 'set_head_meta_tags'));
             add_action('save_post', array(&$this, 'save_options'), NGFB_META_SAVE_PRIORITY);
             add_action('save_post', array(&$this, 'clear_cache'), NGFB_META_CACHE_PRIORITY);
             add_action('edit_attachment', array(&$this, 'save_options'), NGFB_META_SAVE_PRIORITY);
             add_action('edit_attachment', array(&$this, 'clear_cache'), NGFB_META_CACHE_PRIORITY);
         } else {
             // only check registered front-end post types (to avoid menu items, product variations, etc.)
             $post_types = $this->p->util->get_post_types('frontend', 'names');
             if (is_array($post_types)) {
                 foreach ($post_types as $ptn) {
                     add_filter('manage_' . $ptn . '_posts_columns', array($this, 'add_column_headings'), 10, 1);
                     add_action('manage_' . $ptn . '_posts_custom_column', array($this, 'show_post_column_content'), 10, 2);
                 }
             }
             $this->p->util->add_plugin_filters($this, array('og_image_post_column_content' => 3, 'og_desc_post_column_content' => 3));
         }
     }
 }
Ejemplo n.º 2
0
 protected function add_actions()
 {
     if (is_admin()) {
         /**
          * Hook a minimum number of admin actions to maximize performance.
          * The post or post_ID arguments are always present when we're
          * editing a post and/or page.
          */
         if (SucomUtil::is_post_page()) {
             add_action('add_meta_boxes', array(&$this, 'add_metaboxes'));
             // load_meta_page() priorities: 100 post, 200 user, 300 taxonomy
             add_action('current_screen', array(&$this, 'load_meta_page'), 100, 1);
             add_action('save_post', array(&$this, 'save_options'), NGFB_META_SAVE_PRIORITY);
             add_action('save_post', array(&$this, 'clear_cache'), NGFB_META_CACHE_PRIORITY);
             add_action('edit_attachment', array(&$this, 'save_options'), NGFB_META_SAVE_PRIORITY);
             add_action('edit_attachment', array(&$this, 'clear_cache'), NGFB_META_CACHE_PRIORITY);
             if (!empty($this->p->options['plugin_shortlink'])) {
                 add_action('get_shortlink', array(&$this, 'get_shortlink'), 9000, 4);
             }
         } elseif (!empty($this->p->options['plugin_columns_post'])) {
             $ptns = $this->p->util->get_post_types('names');
             if (is_array($ptns)) {
                 foreach ($ptns as $ptn) {
                     add_filter('manage_' . $ptn . '_posts_columns', array($this, 'add_column_headings'), 10, 1);
                     add_action('manage_' . $ptn . '_posts_custom_column', array($this, 'show_post_column_content'), 10, 2);
                 }
             }
             $this->p->util->add_plugin_filters($this, array('og_image_post_column_content' => 4, 'og_desc_post_column_content' => 4));
         }
     }
 }
Ejemplo n.º 3
0
 public function get_head_item_type($use_post = false, $obj = false)
 {
     if (!is_object($obj)) {
         $obj = $this->p->util->get_post_object($use_post);
     }
     $post_id = empty($obj->ID) || empty($obj->post_type) || !SucomUtil::is_post_page($use_post) ? 0 : $obj->ID;
     $schema_types = apply_filters($this->p->cf['lca'] . '_schema_post_types', $this->p->cf['head']['schema_type']);
     $item_type = $schema_types['website'];
     // default value for non-singular webpages
     if (is_singular()) {
         if (!empty($obj->post_type) && !empty($this->p->options['schema_type_for_' . $obj->post_type])) {
             $type_name = $this->p->options['schema_type_for_' . $obj->post_type];
             if (isset($schema_types[$type_name])) {
                 $item_type = $schema_types[$type_name];
             } else {
                 $item_type = $schema_types['webpage'];
             }
         } else {
             $item_type = $schema_types['webpage'];
         }
     } elseif ($this->p->util->force_default_author() && !empty($this->p->options['og_def_author_id'])) {
         $item_type = $schema_types['webpage'];
     }
     return apply_filters($this->p->cf['lca'] . '_schema_item_type', $item_type, $post_id, $obj);
 }
Ejemplo n.º 4
0
        public function get_rows_social_preview(&$form, &$head_info)
        {
            $rows = array();
            $prev_width = 600;
            $prev_height = 315;
            $div_style = 'width:' . $prev_width . 'px; height:' . $prev_height . 'px;';
            $have_sizes = !empty($head_info['og:image:width']) && $head_info['og:image:width'] > 0 && !empty($head_info['og:image:height']) && $head_info['og:image:height'] > 0 ? true : false;
            $is_sufficient = $have_sizes === true && $head_info['og:image:width'] >= $prev_width && $head_info['og:image:height'] >= $prev_height ? true : false;
            foreach (array('og:image:secure_url', 'og:image') as $img_url) {
                if (!empty($head_info[$img_url])) {
                    if ($have_sizes === true) {
                        $image_preview_html = '<div class="preview_img" style="' . $div_style . ' 
						background-size:' . ($is_sufficient === true ? 'cover' : $head_info['og:image:width'] . ' ' . $head_info['og:image:height']) . '; 
						background-image:url(' . $head_info[$img_url] . ');" />' . ($is_sufficient === true ? '' : '<p>' . sprintf(_x('Image Dimensions Smaller<br/>than Suggested Minimum<br/>of %s', 'preview image error', 'nextgen-facebook'), $prev_width . 'x' . $prev_height . 'px') . '</p>') . '</div>';
                    } else {
                        $image_preview_html = '<div class="preview_img" style="' . $div_style . ' 
						background-image:url(' . $head_info[$img_url] . ');" /><p>' . _x('Image Dimensions Unknown<br/>or Not Available', 'preview image error', 'nextgen-facebook') . '</p></div>';
                    }
                    break;
                    // stop after first image
                }
            }
            if (empty($image_preview_html)) {
                $image_preview_html = '<div class="preview_img" style="' . $div_style . '"><p>' . _x('No Open Graph Image Found', 'preview image error', 'nextgen-facebook') . '</p></div>';
            }
            $long_url = $this->p->util->get_sharing_url($head_info['post_id']);
            $short_url = apply_filters($this->p->cf['lca'] . '_shorten_url', $long_url, $this->p->options['plugin_shortener']);
            if ($long_url === $short_url && SucomUtil::is_post_page()) {
                $short_url = wp_get_shortlink();
            }
            $rows[] = $this->p->util->get_th(_x('Sharing URL', 'option label', 'nextgen-facebook'), 'medium') . '<td>' . $form->get_copy_input($long_url) . '</td>';
            $rows[] = $this->p->util->get_th(_x('Short URL', 'option label', 'nextgen-facebook'), 'medium') . '<td>' . $form->get_copy_input($short_url) . '</td>';
            $rows[] = $this->p->util->get_th(_x('Open Graph Example', 'option label', 'nextgen-facebook'), 'medium') . '<td rowspan="2" style="background-color:#e9eaed;border:1px dotted #e0e0e0;">
			<div class="preview_box" style="width:' . ($prev_width + 40) . 'px;">
				<div class="preview_box" style="width:' . $prev_width . 'px;">
					' . $image_preview_html . '
					<div class="preview_txt">
						<div class="preview_title">' . (empty($head_info['og:title']) ? 'No Title' : $head_info['og:title']) . '</div>
						<div class="preview_desc">' . (empty($head_info['og:description']) ? 'No Description' : $head_info['og:description']) . '</div>
						<div class="preview_by">' . ($_SERVER['SERVER_NAME'] . (empty($head_info['author']) ? '' : ' | By ' . $head_info['author'])) . '</div>
					</div>
				</div>
			</div></td>';
            $rows[] = '<th class="medium textinfo">' . $this->p->msgs->get('info-meta-social-preview') . '</th>';
            return $rows;
        }
Ejemplo n.º 5
0
 public function get_all_images($num = 0, $size_name = 'thumbnail', $post_id, $check_dupes = true, $md_pre = 'og')
 {
     if ($this->p->debug->enabled) {
         $this->p->debug->args(array('num' => $num, 'size_name' => $size_name, 'post_id' => $post_id, 'check_dupes' => $check_dupes, 'md_pre' => $md_pre));
     }
     $og_ret = array();
     $force_regen = false;
     $num_remains = $this->p->media->num_remains($og_ret, $num);
     // if requesting images for a specific post_id
     if (SucomUtil::is_post_page($post_id)) {
         // is_attachment() only works on the front-end, so check the post_type as well
         if ((is_attachment($post_id) || get_post_type($post_id) === 'attachment') && wp_attachment_is_image($post_id)) {
             $og_image = $this->p->media->get_attachment_image($num_remains, $size_name, $post_id, $check_dupes);
             // exiting early
             if (empty($og_image)) {
                 return array_merge($og_ret, $this->p->media->get_default_image($num_remains, $size_name, $check_dupes, $force_regen));
             } else {
                 return array_merge($og_ret, $og_image);
             }
         }
         // check for custom meta, featured, or attached image(s)
         // allow for empty post_id in order to execute featured/attached image filters for modules
         if (!$this->p->util->is_maxed($og_ret, $num)) {
             $og_ret = array_merge($og_ret, $this->p->media->get_post_images($num_remains, $size_name, $post_id, $check_dupes, $md_pre));
         }
         // check for ngg shortcodes and query vars
         if (!$this->p->util->is_maxed($og_ret, $num) && $this->p->is_avail['media']['ngg'] && !empty($this->p->mods['media']['ngg'])) {
             if ($this->p->debug->enabled) {
                 $this->p->debug->log('checking for ngg shortcodes and query vars');
             }
             // ngg pre-v2 used query arguments
             $ngg_query_og_ret = array();
             $num_remains = $this->p->media->num_remains($og_ret, $num);
             if (version_compare($this->p->mods['media']['ngg']->ngg_version, '2.0.0', '<')) {
                 $ngg_query_og_ret = $this->p->mods['media']['ngg']->get_query_images($num_remains, $size_name, $check_dupes);
             }
             // if we found images in the query, skip content shortcodes
             if (count($ngg_query_og_ret) > 0) {
                 if ($this->p->debug->enabled) {
                     $this->p->debug->log(count($ngg_query_og_ret) . ' image(s) returned - skipping additional shortcode images');
                 }
                 $og_ret = array_merge($og_ret, $ngg_query_og_ret);
                 // if no query images were found, continue with ngg shortcodes in content
             } elseif (!$this->p->util->is_maxed($og_ret, $num)) {
                 $num_remains = $this->p->media->num_remains($og_ret, $num);
                 $og_ret = array_merge($og_ret, $this->p->mods['media']['ngg']->get_shortcode_images($num_remains, $size_name, $check_dupes));
             }
         }
         // end of check for ngg shortcodes and query vars
         // if we haven't reached the limit of images yet, keep going and check the content text
         if (!$this->p->util->is_maxed($og_ret, $num)) {
             $num_remains = $this->p->media->num_remains($og_ret, $num);
             $og_ret = array_merge($og_ret, $this->p->media->get_content_images($num_remains, $size_name, $post_id, $check_dupes));
         }
     } else {
         // check for priority media before using the default image
         if (SucomUtil::is_term_page()) {
             if ($this->p->debug->enabled) {
                 $this->p->debug->log('is_term_page() = true');
             }
             $term_id = $this->p->util->get_term_object('id');
             $og_ret = array_merge($og_ret, $this->p->mods['util']['taxonomy']->get_og_image($num_remains, $size_name, $term_id, $check_dupes, $force_regen, $md_pre));
             if (!$this->p->util->is_maxed($og_ret, $num)) {
                 $og_ret = array_merge($og_ret, $this->p->mods['util']['taxonomy']->get_term_images($num_remains, $size_name, $term_id, $check_dupes, $force_regen, $md_pre));
             }
         } elseif (SucomUtil::is_author_page()) {
             if ($this->p->debug->enabled) {
                 $this->p->debug->log('is_author_page() = true');
             }
             $author_id = $this->p->util->get_author_object('id');
             $og_ret = array_merge($og_ret, $this->p->mods['util']['user']->get_og_image($num_remains, $size_name, $author_id, $check_dupes, $force_regen, $md_pre));
         }
         if (count($og_ret) < 1 && $this->p->util->force_default_image()) {
             return array_merge($og_ret, $this->p->media->get_default_image($num_remains, $size_name, $check_dupes, $force_regen));
         }
         $num_remains = $this->p->media->num_remains($og_ret, $num);
     }
     $this->p->util->slice_max($og_ret, $num);
     return $og_ret;
 }
Ejemplo n.º 6
0
 public function get_header_array($use_post = false, $read_cache = true, &$mt_og = array())
 {
     $lca = $this->p->cf['lca'];
     $short_aop = $this->p->cf['plugin'][$lca]['short'] . ($this->p->is_avail['aop'] ? ' Pro' : '');
     $obj = $this->p->util->get_post_object($use_post);
     $post_id = empty($obj->ID) || empty($obj->post_type) || !is_singular() && $use_post === false ? 0 : $obj->ID;
     $sharing_url = $this->p->util->get_sharing_url($use_post);
     $author_id = false;
     if ($this->p->debug->enabled) {
         $this->p->debug->log('use_post: ' . ($use_post === false ? 'false' : ($use_post === true ? 'true' : $use_post)));
         $this->p->debug->log('post_id: ' . $post_id);
         $this->p->debug->log('obj post_type: ' . (empty($obj->post_type) ? '' : $obj->post_type));
         $this->p->debug->log('sharing url: ' . $sharing_url);
     }
     $header_array = array();
     if ($this->p->is_avail['cache']['transient']) {
         $cache_salt = __METHOD__ . '(' . apply_filters($lca . '_head_cache_salt', 'lang:' . SucomUtil::get_locale() . '_post:' . $post_id . '_url:' . $sharing_url, $use_post) . ')';
         $cache_id = $lca . '_' . md5($cache_salt);
         $cache_type = 'object cache';
         if ($this->p->debug->enabled) {
             $this->p->debug->log($cache_type . ': transient salt ' . $cache_salt);
         }
         if (apply_filters($lca . '_header_get_cache', $read_cache)) {
             $header_array = get_transient($cache_id);
             if ($header_array !== false) {
                 if ($this->p->debug->enabled) {
                     $this->p->debug->log($cache_type . ': header array retrieved from transient ' . $cache_id);
                 }
                 return $header_array;
             }
         }
     }
     /*
      * Define an author_id, if one is available
      */
     if (SucomUtil::is_post_page($use_post)) {
         if (!empty($obj->post_author)) {
             $author_id = $obj->post_author;
         } elseif (!empty($this->p->options['seo_def_author_id'])) {
             $author_id = $this->p->options['seo_def_author_id'];
         }
     } elseif (SucomUtil::is_author_page()) {
         $author_id = $this->p->util->get_author_object('id');
     } elseif ($this->p->util->force_default_author($use_post, 'seo')) {
         $author_id = $this->p->options['seo_def_author_id'];
     }
     if ($this->p->debug->enabled && $author_id !== false) {
         $this->p->debug->log('author_id: ' . $author_id);
     }
     /*
      * Open Graph
      */
     $mt_og = $this->p->og->get_array($use_post, $obj, $mt_og);
     /*
      * Twitter Cards
      */
     $mt_tc = $this->p->tc->get_array($use_post, $obj, $mt_og);
     /*
      * Name / SEO meta tags
      */
     $mt_name = array();
     if (!empty($this->p->options['add_meta_name_author'])) {
         if (isset($this->p->options['seo_author_name']) && $this->p->options['seo_author_name'] !== 'none') {
             $mt_name['author'] = $this->p->mods['util']['user']->get_author_name($author_id, $this->p->options['seo_author_name']);
         }
     }
     if (!empty($this->p->options['add_meta_name_canonical'])) {
         $mt_name['canonical'] = $sharing_url;
     }
     if (!empty($this->p->options['add_meta_name_description'])) {
         $mt_name['description'] = $this->p->webpage->get_description($this->p->options['seo_desc_len'], '...', $use_post, true, false, true, 'seo_desc');
     }
     // add_hashtags = false
     if (!empty($this->p->options['add_meta_name_p:domain_verify'])) {
         if (!empty($this->p->options['rp_dom_verify'])) {
             $mt_name['p:domain_verify'] = $this->p->options['rp_dom_verify'];
         }
     }
     $mt_name = apply_filters($lca . '_meta_name', $mt_name, $use_post, $obj);
     /*
      * Link relation tags
      */
     $link_rel = array();
     if (!empty($this->p->options['add_link_rel_author'])) {
         if (!empty($author_id)) {
             $link_rel['author'] = $this->p->mods['util']['user']->get_author_website_url($author_id, $this->p->options['seo_author_field']);
         }
     }
     if (!empty($this->p->options['add_link_rel_publisher'])) {
         if (!empty($this->p->options['seo_publisher_url'])) {
             $link_rel['publisher'] = $this->p->options['seo_publisher_url'];
         }
     }
     $link_rel = apply_filters($lca . '_link_rel', $link_rel, $use_post, $obj);
     /*
      * Schema meta tags
      */
     $mt_schema = $this->p->schema->get_meta_array($use_post, $obj, $mt_og);
     /*
      * Combine and return all meta tags
      */
     $header_array = array_merge($this->get_single_mt('meta', 'name', 'generator', $short_aop . ' ' . $this->p->cf['plugin'][$lca]['version'] . ($this->p->check->aop($this->p->cf['lca'], true, $this->p->is_avail['aop']) ? 'L' : ($this->p->is_avail['aop'] ? 'U' : 'G')) . ($this->p->is_avail['util']['um'] ? ' +' : ' -') . 'UM', '', $use_post), $this->get_mt_array('link', 'rel', $link_rel, $use_post), $this->get_mt_array('meta', 'property', $mt_og, $use_post), $this->get_mt_array('meta', 'name', $mt_tc, $use_post), $this->get_mt_array('meta', 'itemprop', $mt_schema, $use_post), $this->get_mt_array('meta', 'name', $mt_name, $use_post), $this->p->schema->get_noscript_array($use_post, $obj, $mt_og, $post_id, $author_id), $this->p->schema->get_json_array($use_post, $obj, $mt_og, $post_id, $author_id));
     /*
      * Save the header array to the WordPress transient cache
      */
     if (apply_filters($lca . '_header_set_cache', $this->p->is_avail['cache']['transient'])) {
         set_transient($cache_id, $header_array, $this->p->options['plugin_object_cache_exp']);
         if ($this->p->debug->enabled) {
             $this->p->debug->log($cache_type . ': header array saved to transient ' . $cache_id . ' (' . $this->p->options['plugin_object_cache_exp'] . ' seconds)');
         }
     }
     return $header_array;
 }
Ejemplo n.º 7
0
 public function get_array($use_post = false, $obj = false, &$og = array())
 {
     if ($this->p->debug->enabled) {
         $this->p->debug->mark();
     }
     if (!is_object($obj)) {
         $obj = $this->p->util->get_post_object($use_post);
     }
     $post_id = empty($obj->ID) || empty($obj->post_type) || !is_singular() && $use_post === false ? 0 : $obj->ID;
     $og_max = $this->p->util->get_max_nums($post_id, 'post');
     // post_id 0 returns the plugin settings
     $tc = SucomUtil::preg_grep_keys('/^twitter:/', $og);
     // read any pre-defined twitter card values
     $tc = apply_filters($this->p->cf['lca'] . '_tc_seed', $tc, $use_post, $obj);
     // the twitter:domain is used in place of the 'view on web' text
     if (!isset($tc['twitter:domain']) && !empty($og['og:url'])) {
         $tc['twitter:domain'] = preg_replace('/^.*\\/\\/([^\\/]+).*$/', '$1', $og['og:url']);
     }
     if (!isset($tc['twitter:site']) && !empty($this->p->options['tc_site'])) {
         $tc['twitter:site'] = $this->p->options['tc_site'];
     }
     if (!isset($tc['twitter:title'])) {
         $tc['twitter:title'] = $this->p->webpage->get_title(70, '...', $use_post, true, false, true, 'og_title');
     }
     if (!isset($tc['twitter:description'])) {
         $tc['twitter:description'] = $this->p->webpage->get_description($this->p->options['tc_desc_len'], '...', $use_post, true, true, true, 'tc_desc');
     }
     if (!isset($tc['twitter:creator'])) {
         if (SucomUtil::is_post_page($use_post)) {
             if (!empty($obj->post_author)) {
                 $tc['twitter:creator'] = get_the_author_meta($this->p->options['plugin_cm_twitter_name'], $obj->post_author);
             } elseif (!empty($this->p->options['og_def_author_id'])) {
                 $tc['twitter:creator'] = get_the_author_meta($this->p->options['plugin_cm_twitter_name'], $this->p->options['og_def_author_id']);
             }
         } elseif (SucomUtil::is_author_page()) {
             $author_id = $this->p->util->get_author_object('id');
             $tc['twitter:creator'] = get_the_author_meta($this->p->options['plugin_cm_twitter_name'], $author_id);
         } elseif ($this->p->util->force_default_author($use_post)) {
             $tc['twitter:creator'] = get_the_author_meta($this->p->options['plugin_cm_twitter_name'], $this->p->options['og_def_author_id']);
         }
     }
     /*
      * Player Card
      */
     // player card relies on existing og meta tags - a valid post_id is not required
     if (!isset($tc['twitter:card'])) {
         if ($this->p->debug->enabled) {
             $this->p->debug->log('player card: checking for videos');
         }
         if (isset($og['og:video']) && count($og['og:video']) > 0) {
             foreach ($og['og:video'] as $video) {
                 if (!empty($video['og:video:embed_url'])) {
                     $tc['twitter:card'] = 'player';
                     $tc['twitter:player'] = $video['og:video:embed_url'];
                     if (!empty($video['og:image'])) {
                         $tc['twitter:image'] = $video['og:image'];
                     }
                     if (!empty($video['og:video:width'])) {
                         $tc['twitter:player:width'] = $video['og:video:width'];
                     }
                     if (!empty($video['og:video:height'])) {
                         $tc['twitter:player:height'] = $video['og:video:height'];
                     }
                     break;
                     // only list the first video
                 }
             }
         }
     }
     /*
      * All Image Cards
      */
     if (empty($og_max['og_img_max'])) {
         if ($this->p->debug->enabled) {
             $this->p->debug->log('images disabled: maximum images = 0');
         }
     } else {
         /*
          * Default Image for Indexes
          */
         if (!isset($tc['twitter:card']) && !$use_post) {
             if ($this->p->util->force_default_image()) {
                 if ($this->p->debug->enabled) {
                     $this->p->debug->log('large image card: checking for default image');
                 }
                 $og_image = $this->p->media->get_default_image(1, $this->p->cf['lca'] . '-tc-lrgimg');
                 if (count($og_image) > 0) {
                     $image = reset($og_image);
                     $tc['twitter:card'] = 'summary_large_image';
                     $tc['twitter:image'] = $image['og:image'];
                 }
                 $post_id = 0;
                 // skip additional image checks
             }
         }
         if (empty($post_id)) {
             if ($this->p->debug->enabled) {
                 $this->p->debug->log('no post_id: image related cards skipped');
             }
         } else {
             // post meta image
             if (!isset($tc['twitter:card'])) {
                 if ($this->p->debug->enabled) {
                     $this->p->debug->log('large image card: checking for post image (meta, featured, attached)');
                 }
                 $og_image = $this->p->media->get_post_images(1, $this->p->cf['lca'] . '-tc-lrgimg', $post_id, false);
                 if (count($og_image) > 0) {
                     $image = reset($og_image);
                     $tc['twitter:card'] = 'summary_large_image';
                     $tc['twitter:image'] = $image['og:image'];
                 }
             }
             // singlepic shortcode image
             if (!isset($tc['twitter:card']) && $this->p->is_avail['media']['ngg'] === true) {
                 if (!empty($this->p->mods['media']['ngg'])) {
                     if ($this->p->debug->enabled) {
                         $this->p->debug->log('large image card: checking for singlepic image');
                     }
                     $og_image = $this->p->mods['media']['ngg']->get_singlepic_images(1, $this->p->cf['lca'] . '-tc-lrgimg', false);
                     if (count($og_image) > 0) {
                         $image = reset($og_image);
                         $tc['twitter:card'] = 'summary_large_image';
                         $tc['twitter:image'] = $image['og:image'];
                     }
                 } elseif ($this->p->debug->enabled) {
                     $this->p->debug->log('large image card: singlepic check skipped - NGG module not available');
                 }
             }
         }
     }
     /*
      * Summary Card (default)
      */
     if (!isset($tc['twitter:card'])) {
         $tc['twitter:card'] = 'summary';
         if (!empty($og_max['og_img_max'])) {
             if ($this->p->debug->enabled) {
                 $this->p->debug->log('summary card: checking for content image');
             }
             $og_image = $this->p->og->get_all_images(1, $this->p->cf['lca'] . '-tc-summary', $post_id, false);
             if (count($og_image) > 0) {
                 $image = reset($og_image);
                 $tc['twitter:image'] = $image['og:image'];
             }
         }
     }
     return apply_filters($this->p->cf['lca'] . '_tc', $tc, $use_post, $obj);
 }
Ejemplo n.º 8
0
 public function force_default_media($use_post = false, $opt_pre = 'og', $media = 'img')
 {
     $ret = null;
     // save some time
     if (empty($this->p->options[$opt_pre . '_def_' . $media . '_id']) && empty($this->p->options[$opt_pre . '_def_' . $media . '_url'])) {
         $ret = false;
     } else {
         // check for singular pages first
         if ($ret === null && SucomUtil::is_post_page($use_post)) {
             $ret = false;
         }
         if ($ret === null && !empty($this->p->options[$opt_pre . '_def_' . $media . '_on_index'])) {
             if (is_home() || is_archive() && !is_admin() && !SucomUtil::is_author_page()) {
                 $ret = true;
             }
         }
         if ($ret === null && !empty($this->p->options[$opt_pre . '_def_' . $media . '_on_author'])) {
             if (SucomUtil::is_author_page()) {
                 $ret = true;
             }
         }
         if ($ret === null && !empty($this->p->options[$opt_pre . '_def_' . $media . '_on_search'])) {
             if (is_search()) {
                 $ret = true;
             }
         }
         if ($ret === null) {
             $ret = false;
         }
     }
     $ret = apply_filters($this->p->cf['lca'] . '_force_default_' . $media, $ret);
     if ($ret === true && $this->p->debug->enabled) {
         $this->p->debug->log('default ' . $media . ' is forced');
     }
     return $ret;
 }
Ejemplo n.º 9
0
 public function get_mod_obj($id, $mod = 'post')
 {
     $obj = false;
     if (empty($id) || empty($mod)) {
         if (!empty($id)) {
             $mod = 'post';
         } elseif (SucomUtil::is_post_page(false)) {
             $mod = 'post';
         } elseif (SucomUtil::is_term_page()) {
             $mod = 'taxonomy';
         } elseif (SucomUtil::is_author_page()) {
             $mod = 'user';
         }
     }
     if (isset($this->p->mods['util'][$mod])) {
         $obj =& $this->p->mods['util'][$mod];
         if (empty($id)) {
             switch ($mod) {
                 case 'post':
                     $id = $this->get_post_object(false, 'id');
                     break;
                 case 'taxonomy':
                     $id = $this->get_term_object('id');
                     break;
                 case 'author':
                     $id = $this->get_author_object('id');
                     break;
             }
         }
     }
     return array($id, $obj);
 }