本文整理汇总了PHP中SucomUtil::is_term_page方法的典型用法代码示例。如果您正苦于以下问题:PHP SucomUtil::is_term_page方法的具体用法?PHP SucomUtil::is_term_page怎么用?PHP SucomUtil::is_term_page使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SucomUtil
的用法示例。
在下文中一共展示了SucomUtil::is_term_page方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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_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()) {
//.........这里部分代码省略.........
示例3: add_plugin_image_sizes
public function add_plugin_image_sizes($id = false, $sizes = array(), $filter = true, $mod = false)
{
/*
* Allow various plugin extensions to provide their image names, labels, etc.
* The first dimension array key is the option name prefix by default.
* You can also include the width, height, crop, crop_x, and crop_y values.
*
* Array (
* [rp_img] => Array (
* [name] => richpin
* [label] => Rich Pin Image Dimensions
* )
* [og_img] => Array (
* [name] => opengraph
* [label] => Open Graph Image Dimensions
* )
* )
*/
if ($filter === true) {
$sizes = apply_filters($this->p->cf['lca'] . '_plugin_image_sizes', $sizes, $id, $mod);
}
$meta_opts = array();
if ($mod === false) {
if (SucomUtil::is_post_page(false)) {
$mod = 'post';
} elseif (SucomUtil::is_term_page()) {
$mod = 'taxonomy';
} elseif (SucomUtil::is_author_page()) {
$mod = 'user';
} elseif ($this->p->debug->enabled) {
$this->p->debug->log('module type could not be determined');
}
}
if (is_object($id)) {
$obj = $id;
// could be WP_Object or post/term/user object
$id = false;
if ($mod === 'post') {
$id = empty($obj->ID) || empty($obj->post_type) ? $this->get_post_object(false, 'id') : $obj->ID;
} elseif ($mod === 'taxonomy') {
$id = empty($obj->term_id) ? $this->get_term_object('id') : $obj->term_id;
} elseif ($mod === 'user') {
$id = empty($obj->ID) ? $this->get_author_object('id') : $obj->ID;
}
} elseif (empty($id)) {
if ($mod === 'post') {
$id = $this->get_post_object(false, 'id');
} elseif ($mod === 'taxonomy') {
$id = $this->get_term_object('id');
} elseif ($mod === 'user') {
$id = $this->get_author_object('id');
}
}
if (empty($mod)) {
if ($this->p->debug->enabled) {
$this->p->debug->log('no module defined');
}
} elseif (empty($id)) {
if ($this->p->debug->enabled) {
$this->p->debug->log('no object id defined');
}
} else {
$meta_opts = $this->get_mod_options($mod, $id);
}
foreach ($sizes as $opt_prefix => $size_info) {
if (!is_array($size_info)) {
$save_name = empty($size_info) ? $opt_prefix : $size_info;
$size_info = array('name' => $save_name, 'label' => $save_name);
} elseif (!empty($size_info['prefix'])) {
// allow for alternate option prefix
$opt_prefix = $size_info['prefix'];
}
foreach (array('width', 'height', 'crop', 'crop_x', 'crop_y') as $key) {
if (isset($size_info[$key])) {
// prefer existing info from filters
continue;
} elseif (isset($meta_opts[$opt_prefix . '_' . $key])) {
// use post meta if available
$size_info[$key] = $meta_opts[$opt_prefix . '_' . $key];
} elseif (isset($this->p->options[$opt_prefix . '_' . $key])) {
// current plugin settings
$size_info[$key] = $this->p->options[$opt_prefix . '_' . $key];
} else {
if (!isset($def_opts)) {
// only read once if necessary
$def_opts = $this->p->opt->get_defaults();
}
$size_info[$key] = $def_opts[$opt_prefix . '_' . $key];
// fallback to default value
}
if ($key === 'crop') {
// make sure crop is true or false
$size_info[$key] = empty($size_info[$key]) ? false : true;
}
}
if ($size_info['width'] > 0 && $size_info['height'] > 0) {
// preserve compatibility with older wordpress versions, use true or false when possible
if ($size_info['crop'] === true && ($size_info['crop_x'] !== 'center' || $size_info['crop_y'] !== 'center')) {
global $wp_version;
if (!version_compare($wp_version, 3.9, '<')) {
//.........这里部分代码省略.........
示例4: 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);
}