public function get_all_images($num = 0, $size_name = 'thumbnail', $post_id, $check_dupes = true, $meta_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, 'meta_pre' => $meta_pre));
     }
     $og_ret = array();
     $force_regen = false;
     // check for an attachment page
     // is_attachment() only works on the front-end, so check the post_type as well
     if (!empty($post_id)) {
         if ((is_attachment($post_id) || get_post_type($post_id) === 'attachment') && wp_attachment_is_image($post_id)) {
             $og_image = array();
             $num_remains = $this->p->media->num_remains($og_ret, $num);
             $og_image = $this->p->media->get_attachment_image($num_remains, $size_name, $post_id, $check_dupes);
             // if an attachment is not an image, then use the default image instead
             if (empty($og_image)) {
                 $num_remains = $this->p->media->num_remains($og_ret, $num);
                 $og_ret = array_merge($og_ret, $this->p->media->get_default_image($num_remains, $size_name));
             } else {
                 $og_ret = array_merge($og_ret, $og_image);
             }
             return $og_ret;
         }
     }
     if ($this->p->util->force_default_image()) {
         $num_remains = $this->p->media->num_remains($og_ret, $num);
         $og_ret = array_merge($og_ret, $this->p->media->get_default_image($num_remains, $size_name));
         return $og_ret;
         // stop here and return the image array
     }
     $num_remains = $this->p->media->num_remains($og_ret, $num);
     if (SucomUtil::is_term_page()) {
         $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, $meta_pre));
         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->mods['util']['taxonomy']->get_term_images($num_remains, $size_name, $term_id, $check_dupes, $force_regen, $meta_pre));
         }
     } elseif (SucomUtil::is_author_page()) {
         $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, $meta_pre));
     } else {
         // check for custom meta, featured, or attached image(s)
         // allow for empty post_id in order to execute featured/attached image filters for modules
         $og_ret = array_merge($og_ret, $this->p->media->get_post_images($num_remains, $size_name, $post_id, $check_dupes, $meta_pre));
         // check for ngg shortcodes and query vars
         if ($this->p->is_avail['media']['ngg'] === true && !empty($this->p->mods['media']['ngg']) && !$this->p->util->is_maxed($og_ret, $num)) {
             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));
         }
     }
     $this->p->util->slice_max($og_ret, $num);
     return $og_ret;
 }
Exemplo n.º 2
0
 public function get_header_array($use_post = false, $read_cache = true, &$meta_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_read_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 (is_singular() || $use_post !== false) {
         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, Twitter Card
      *
      * The Twitter Card meta tags are added by the 
      * NgfbHeadTwittercard class using an 'ngfb_og' filter hook.
      */
     $meta_og = $this->p->og->get_array($meta_og, $use_post, $obj);
     /**
      * Name / SEO meta tags
      */
     $meta_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') {
             $meta_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'])) {
         $meta_name['canonical'] = $sharing_url;
     }
     if (!empty($this->p->options['add_meta_name_description'])) {
         $meta_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'])) {
             $meta_name['p:domain_verify'] = $this->p->options['rp_dom_verify'];
         }
     }
     $meta_name = apply_filters($lca . '_meta_name', $meta_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
      */
     $meta_schema = $this->p->schema->get_meta_array($use_post, $obj, $meta_og);
     /**
      * Combine and return all meta tags
      */
     $comment = $this->p->cf['lca'] . ' meta tags';
     $header_array = array_merge($this->get_single_tag('meta', 'name', 'generator', $short_aop . ' ' . $this->p->cf['plugin'][$lca]['version'] . ($this->p->check->aop() ? 'L' : ($this->p->is_avail['aop'] ? 'U' : 'G')) . ($this->p->is_avail['util']['um'] ? ' +' : ' -') . 'UM', '', $use_post), $this->get_tag_array('link', 'rel', $link_rel, $use_post), $this->get_tag_array('meta', 'property', $meta_og, $use_post), $this->get_tag_array('meta', 'itemprop', $meta_schema, $use_post), $this->get_tag_array('meta', 'name', $meta_name, $use_post), SucomUtil::a2aa($this->p->schema->get_json_array($post_id, $author_id, $this->p->cf['lca'] . '-schema')));
     /**
      * 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;
 }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
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;
 }
Exemplo n.º 5
0
 public function get_description($textlen = 156, $trailing = '...', $use_post = false, $use_cache = true, $add_hashtags = true, $encode = true, $md_idx = 'og_desc', $src_id = '')
 {
     if ($this->p->debug->enabled) {
         $this->p->debug->mark('render description');
         // start timer
         $this->p->debug->args(array('textlen' => $textlen, 'trailing' => $trailing, 'use_post' => $use_post, 'use_cache' => $use_cache, 'add_hashtags' => $add_hashtags, 'encode' => $encode, 'md_idx' => $md_idx, 'src_id' => $src_id));
     }
     $desc = false;
     $hashtags = '';
     $post_id = 0;
     $page = '';
     if (is_singular() || $use_post !== false) {
         if (($obj = $this->p->util->get_post_object($use_post)) === false) {
             if ($this->p->debug->enabled) {
                 $this->p->debug->log('exiting early: invalid object type');
             }
             return $desc;
         }
         $post_id = empty($obj->ID) || empty($obj->post_type) ? 0 : $obj->ID;
     }
     // skip if no metadata index / key name
     if (!empty($md_idx)) {
         if (is_singular() || $use_post !== false) {
             if (!empty($post_id)) {
                 $desc = $this->p->util->get_mod_options('post', $post_id, array($md_idx, 'og_desc'));
             }
         } elseif (SucomUtil::is_term_page()) {
             $term = $this->p->util->get_term_object();
             if (!empty($term->term_id)) {
                 $desc = $this->p->util->get_mod_options('taxonomy', $term->term_id, $md_idx);
             }
         } elseif (SucomUtil::is_author_page()) {
             $author = $this->p->util->get_author_object();
             if (!empty($author->ID)) {
                 $desc = $this->p->util->get_mod_options('user', $author->ID, $md_idx);
             }
         }
         if ($this->p->debug->enabled) {
             if (empty($desc)) {
                 $this->p->debug->log('no custom description found');
             } else {
                 $this->p->debug->log('custom description = "' . $desc . '"');
             }
         }
     }
     // get seed if no custom meta description
     if (empty($desc)) {
         $desc = apply_filters($this->p->cf['lca'] . '_description_seed', '', $use_post, $add_hashtags, $md_idx, $src_id);
         if (!empty($desc)) {
             if ($this->p->debug->enabled) {
                 $this->p->debug->log('description seed = "' . $desc . '"');
             }
         }
     }
     // remove and save trailing hashtags
     if (preg_match('/^(.*)(( *#[a-z][a-z0-9\\-]+)+)$/U', $desc, $match)) {
         $desc = $match[1];
         $hashtags = trim($match[2]);
     } elseif (is_singular() || $use_post !== false) {
         if (!empty($add_hashtags) && !empty($this->p->options['og_desc_hashtags'])) {
             $hashtags = $this->get_hashtags($post_id, $add_hashtags);
         }
     }
     if ($this->p->debug->enabled) {
         $this->p->debug->log('hashtags found = "' . $hashtags . '"');
     }
     // if there's no custom description, and no pre-seed,
     // then go ahead and generate the description value
     if (empty($desc)) {
         // $obj and $post_id are defined above, with the same test, so we should be good
         if (is_singular() || $use_post !== false) {
             // use the excerpt, if we have one
             if (has_excerpt($post_id)) {
                 $desc = $obj->post_excerpt;
                 if (!empty($this->p->options['plugin_filter_excerpt'])) {
                     $filter_removed = apply_filters($this->p->cf['lca'] . '_pre_filter_remove', false, 'get_the_excerpt');
                     if ($this->p->debug->enabled) {
                         $this->p->debug->log('calling apply_filters(\'get_the_excerpt\')');
                     }
                     $desc = apply_filters('get_the_excerpt', $desc);
                     if ($filter_removed) {
                         $filter_added = apply_filters($this->p->cf['lca'] . '_post_filter_add', false, 'get_the_excerpt');
                     }
                 }
             } elseif ($this->p->debug->enabled) {
                 $this->p->debug->log('no post_excerpt for post_id ' . $post_id);
             }
             // if there's no excerpt, then fallback to the content
             if (empty($desc)) {
                 $desc = $this->get_content($post_id, $use_post, $use_cache, $md_idx, $src_id);
             }
             // ignore everything before the first paragraph if true
             if ($this->p->options['plugin_p_strip']) {
                 if ($this->p->debug->enabled) {
                     $this->p->debug->log('removing all text before the first paragraph');
                 }
                 $desc = preg_replace('/^.*?<p>/i', '', $desc);
                 // question mark makes regex un-greedy
             }
         } elseif (SucomUtil::is_term_page()) {
             if (is_tag()) {
                 $desc = tag_description();
                 if (empty($desc)) {
                     $desc = sprintf('Tagged with %s', single_tag_title('', false));
                 }
             } elseif (is_category()) {
                 $desc = category_description();
                 if (empty($desc)) {
                     $desc = sprintf('%s Category', single_cat_title('', false));
                 }
             } else {
                 // other taxonomies
                 $term = $this->p->util->get_term_object();
                 if (!empty($term->description)) {
                     $desc = $term->description;
                 } elseif (!empty($term->name)) {
                     $desc = $term->name . ' Archives';
                 }
             }
         } elseif (SucomUtil::is_author_page()) {
             $author = $this->p->util->get_author_object();
             if (!empty($author->description)) {
                 $desc = $author->description;
             } elseif (!empty($author->display_name)) {
                 $desc = sprintf('Authored by %s', $author->display_name);
             }
         } elseif (is_day()) {
             $desc = sprintf('Daily Archives for %s', get_the_date());
         } elseif (is_month()) {
             $desc = sprintf('Monthly Archives for %s', get_the_date('F Y'));
         } elseif (is_year()) {
             $desc = sprintf('Yearly Archives for %s', get_the_date('Y'));
         }
     }
     // if there's still no description, then fallback to a generic version
     if (empty($desc)) {
         if (is_admin() && !empty($obj->post_status) && $obj->post_status == 'auto-draft') {
             if ($this->p->debug->enabled) {
                 $this->p->debug->log('post_status is auto-draft - using empty description');
             }
         } else {
             // pass options array to allow fallback if locale option does not exist
             $key = SucomUtil::get_locale_key('og_site_description', $this->p->options, $post_id);
             if (!empty($this->p->options[$key])) {
                 if ($this->p->debug->enabled) {
                     $this->p->debug->log('description is empty - custom site description (' . $key . ')');
                 }
                 $desc = $this->p->options[$key];
             } else {
                 if ($this->p->debug->enabled) {
                     $this->p->debug->log('description is empty - using blog description');
                 }
                 $desc = get_bloginfo('description', 'display');
             }
         }
     }
     if ($this->p->debug->enabled) {
         $this->p->debug->log('description strlen before html cleanup ' . strlen($desc));
     }
     $desc = $this->p->util->cleanup_html_tags($desc, true, $this->p->options['plugin_use_img_alt']);
     $desc = apply_filters($this->p->cf['lca'] . '_description_pre_limit', $desc);
     if ($textlen > 0) {
         if (!empty($add_hashtags) && !empty($hashtags)) {
             $textlen = $textlen - strlen($hashtags) - 1;
         }
         if ($this->p->debug->enabled) {
             $this->p->debug->log('description strlen before limit length ' . strlen($desc) . ' (limiting to ' . $textlen . ' chars)');
         }
         $desc = $this->p->util->limit_text_length($desc, $textlen, $trailing, false);
         // don't run cleanup_html_tags()
     } elseif ($this->p->debug->enabled) {
         $this->p->debug->log('description limit text length skipped');
     }
     if (!empty($add_hashtags) && !empty($hashtags)) {
         $desc .= ' ' . $hashtags;
     }
     if ($encode === true) {
         $desc = wp_encode_emoji(htmlentities($desc, ENT_QUOTES, get_bloginfo('charset'), false));
     }
     // double_encode = false
     if ($this->p->debug->enabled) {
         $this->p->debug->mark('render description');
     }
     // stop timer
     return apply_filters($this->p->cf['lca'] . '_description', $desc, $use_post, $add_hashtags, $md_idx, $src_id);
 }
Exemplo n.º 6
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);
 }