本文整理汇总了PHP中SucomUtil::is_author_page方法的典型用法代码示例。如果您正苦于以下问题:PHP SucomUtil::is_author_page方法的具体用法?PHP SucomUtil::is_author_page怎么用?PHP SucomUtil::is_author_page使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SucomUtil
的用法示例。
在下文中一共展示了SucomUtil::is_author_page方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_all_images
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;
}
示例2: get_header_array
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
*/
//.........这里部分代码省略.........
示例3: get_array
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 {
//.........这里部分代码省略.........
示例4: force_default_media
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;
}
示例5: get_description
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()) {
//.........这里部分代码省略.........
示例6: get_mod_obj
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);
}