本文整理汇总了PHP中WPSEO_Taxonomy_Meta::get_term_meta方法的典型用法代码示例。如果您正苦于以下问题:PHP WPSEO_Taxonomy_Meta::get_term_meta方法的具体用法?PHP WPSEO_Taxonomy_Meta::get_term_meta怎么用?PHP WPSEO_Taxonomy_Meta::get_term_meta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPSEO_Taxonomy_Meta
的用法示例。
在下文中一共展示了WPSEO_Taxonomy_Meta::get_term_meta方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpseo_metadesc
function wpseo_metadesc($metadesc)
{
if (empty($metadesc)) {
$tax_metadesc = WPSEO_Taxonomy_Meta::get_term_meta($this->term, $this->term->taxonomy, 'desc');
if (!empty($tax_metadesc)) {
return $tax_metadesc;
}
}
return $metadesc;
}
示例2: term_seo_form
/**
* Show the SEO inputs for term.
*
* @param object $term Term to show the edit boxes for.
*/
function term_seo_form($term)
{
global $wpseo_taxonomy;
$tax_meta = WPSEO_Taxonomy_Meta::get_term_meta((int) $term->term_id, $term->taxonomy);
echo '<h2>' . __('Local SEO Settings', 'yoast-local-seo') . '</h2>';
echo '<table class="form-table wpseo-local-taxonomy-form">';
echo '<tr class="form-field">';
echo '<th scope="row">';
echo '<label class="textinput" for="show_route_label">' . __('Custom marker', 'yoast-local-seo') . ':</label>';
echo '</th>';
echo '<td>';
echo '<img src="' . (isset($tax_meta['wpseo_local_custom_marker']) ? wp_get_attachment_url($tax_meta['wpseo_local_custom_marker']) : '') . '" id="custom_marker" />';
echo '<button class="set_custom_images button">' . __('Set custom marker image', 'yoast-local-seo') . '</button>';
echo '<p class="description">' . __('A custom marker can be set per category. If no marker is set here, the global marker will be used.', 'yoast-local-seo') . '</p>';
if (isset($tax_meta['wpseo_local_custom_marker']) && '' != $tax_meta['wpseo_local_custom_marker']) {
echo '<br /><button id="remove_marker">' . __('Remove marker', 'yoast-local-seo') . '</button>';
}
echo '<input type="hidden" id="hidden_custom_marker" name="wpseo_local_custom_marker" value="' . (isset($tax_meta['wpseo_local_custom_marker']) && $tax_meta['wpseo_local_custom_marker'] !== '' ? $tax_meta['wpseo_local_custom_marker'] : '') . '">';
//$wpseo_taxonomy->form_row( 'wpseo_local_custom_marker', '', '', $tax_meta, 'upload' );
echo '</td>';
echo '</tr>';
echo '</table>';
}
示例3: get_sitemap_links
/**
* Get set of sitemap link data.
*
* @param string $type Sitemap type.
* @param int $max_entries Entries per sitemap.
* @param int $current_page Current page of the sitemap.
*
* @return array
*/
public function get_sitemap_links($type, $max_entries, $current_page)
{
global $wpdb;
$links = array();
$taxonomy = get_taxonomy($type);
if ($taxonomy === false || !$this->is_valid_taxonomy($taxonomy->name) || !$taxonomy->public) {
return $links;
}
$options = $this->get_options();
$steps = $max_entries;
$offset = $current_page > 1 ? ($current_page - 1) * $max_entries : 0;
/** This filter is documented in inc/sitemaps/class-taxonomy-sitemap-provider.php */
$hide_empty = apply_filters('wpseo_sitemap_exclude_empty_terms', true, $taxonomy);
$terms = get_terms($taxonomy->name, array('hide_empty' => $hide_empty));
$terms = array_splice($terms, $offset, $steps);
if (empty($terms)) {
$terms = array();
}
// Grab last modified date.
$sql = "\n\t\t\tSELECT MAX(p.post_modified_gmt) AS lastmod\n\t\t\tFROM\t{$wpdb->posts} AS p\n\t\t\tINNER JOIN {$wpdb->term_relationships} AS term_rel\n\t\t\t\tON\t\tterm_rel.object_id = p.ID\n\t\t\tINNER JOIN {$wpdb->term_taxonomy} AS term_tax\n\t\t\t\tON\t\tterm_tax.term_taxonomy_id = term_rel.term_taxonomy_id\n\t\t\t\tAND\t\tterm_tax.taxonomy = %s\n\t\t\t\tAND\t\tterm_tax.term_id = %d\n\t\t\tWHERE\tp.post_status IN ('publish','inherit')\n\t\t\t\tAND\t\tp.post_password = ''\n\t\t";
foreach ($terms as $term) {
$url = array();
$tax_noindex = WPSEO_Taxonomy_Meta::get_term_meta($term, $term->taxonomy, 'noindex');
$tax_sitemap_inc = WPSEO_Taxonomy_Meta::get_term_meta($term, $term->taxonomy, 'sitemap_include');
if ($tax_noindex === 'noindex' && $tax_sitemap_inc !== 'always') {
continue;
}
if ($tax_sitemap_inc === 'never') {
continue;
}
$url['loc'] = WPSEO_Taxonomy_Meta::get_term_meta($term, $term->taxonomy, 'canonical');
if (!is_string($url['loc']) || $url['loc'] === '') {
$url['loc'] = get_term_link($term, $term->taxonomy);
if ($options['trailingslash'] === true) {
$url['loc'] = trailingslashit($url['loc']);
}
}
$url['mod'] = $wpdb->get_var($wpdb->prepare($sql, $term->taxonomy, $term->term_id));
$url['images'] = $this->get_image_parser()->get_term_images($term);
// Deprecated, kept for backwards data compat. R.
$url['chf'] = 'daily';
$url['pri'] = 1;
/** This filter is documented at inc/sitemaps/class-post-type-sitemap-provider.php */
$url = apply_filters('wpseo_sitemap_entry', $url, 'term', $term);
if (!empty($url)) {
$links[] = $url;
}
}
return $links;
}
示例4: build_tax_map
/**
* Build a sub-sitemap for a specific taxonomy -- example.com/tax-sitemap.xml
*
* @param string $taxonomy Registered taxonomy's slug
*/
function build_tax_map($taxonomy)
{
if (isset($this->options['taxonomies-' . $taxonomy->name . '-not_in_sitemap']) && $this->options['taxonomies-' . $taxonomy->name . '-not_in_sitemap'] === true || in_array($taxonomy, array('link_category', 'nav_menu', 'post_format')) || apply_filters('wpseo_sitemap_exclude_taxonomy', false, $taxonomy->name)) {
$this->bad_sitemap = true;
return;
}
global $wpdb;
$output = '';
$steps = $this->max_entries;
$n = (int) $this->n;
$offset = $n > 1 ? ($n - 1) * $this->max_entries : 0;
/**
* Filter: 'wpseo_sitemap_exclude_empty_terms' - Allow people to include empty terms in sitemap
*
* @api bool $hide_empty Whether or not to hide empty terms, defaults to true.
*
* @param object $taxonomy The taxonomy we're getting terms for.
*/
$hide_empty = apply_filters('wpseo_sitemap_exclude_empty_terms', true, $taxonomy);
$terms = get_terms($taxonomy->name, array('hide_empty' => $hide_empty));
$terms = array_splice($terms, $offset, $steps);
if (is_array($terms) && $terms !== array()) {
foreach ($terms as $c) {
$url = array();
$tax_noindex = WPSEO_Taxonomy_Meta::get_term_meta($c, $c->taxonomy, 'noindex');
$tax_sitemap_inc = WPSEO_Taxonomy_Meta::get_term_meta($c, $c->taxonomy, 'sitemap_include');
if (is_string($tax_noindex) && $tax_noindex === 'noindex' && (!is_string($tax_sitemap_inc) || $tax_sitemap_inc !== 'always')) {
continue;
}
if ($tax_sitemap_inc === 'never') {
continue;
}
$url['loc'] = WPSEO_Taxonomy_Meta::get_term_meta($c, $c->taxonomy, 'canonical');
if (!is_string($url['loc']) || $url['loc'] === '') {
$url['loc'] = get_term_link($c, $c->taxonomy);
if ($this->options['trailingslash'] === true) {
$url['loc'] = trailingslashit($url['loc']);
}
}
if ($c->count > 10) {
$url['pri'] = 0.6;
} else {
if ($c->count > 3) {
$url['pri'] = 0.4;
} else {
$url['pri'] = 0.2;
}
}
// Grab last modified date
$sql = $wpdb->prepare("\n\t\t\t\t\t\tSELECT MAX(p.post_modified_gmt) AS lastmod\n\t\t\t\t\t\tFROM\t{$wpdb->posts} AS p\n\t\t\t\t\t\tINNER JOIN {$wpdb->term_relationships} AS term_rel\n\t\t\t\t\t\t\tON\t\tterm_rel.object_id = p.ID\n\t\t\t\t\t\tINNER JOIN {$wpdb->term_taxonomy} AS term_tax\n\t\t\t\t\t\t\tON\t\tterm_tax.term_taxonomy_id = term_rel.term_taxonomy_id\n\t\t\t\t\t\t\tAND\t\tterm_tax.taxonomy = %s\n\t\t\t\t\t\t\tAND\t\tterm_tax.term_id = %d\n\t\t\t\t\t\tWHERE\tp.post_status IN ('publish','inherit')\n\t\t\t\t\t\t\tAND\t\tp.post_password = ''", $c->taxonomy, $c->term_id);
$url['mod'] = $wpdb->get_var($sql);
$url['chf'] = $this->filter_frequency($c->taxonomy . '_term', 'weekly', $url['loc']);
// Use this filter to adjust the entry before it gets added to the sitemap
$url = apply_filters('wpseo_sitemap_entry', $url, 'term', $c);
if (is_array($url) && $url !== array()) {
$output .= $this->sitemap_url($url);
}
}
}
$this->sitemap = '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ';
$this->sitemap .= 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" ';
$this->sitemap .= 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
// Only add $ouput != empty
if (!empty($output)) {
$this->sitemap .= $output;
}
$this->sitemap .= '</urlset>';
}
示例5: generate_metadesc
/**
* Generates the meta description text.
*/
private function generate_metadesc()
{
global $post, $wp_query;
$metadesc = '';
$metadesc_override = false;
$post_type = '';
$template = '';
if (is_object($post) && (isset($post->post_type) && $post->post_type !== '')) {
$post_type = $post->post_type;
}
if (is_singular()) {
if ($metadesc === '' && $post_type !== '' && isset($this->options['metadesc-' . $post_type])) {
$template = $this->options['metadesc-' . $post_type];
$term = $post;
}
$metadesc_override = WPSEO_Meta::get_value('metadesc');
} else {
if (is_search()) {
$metadesc = '';
} elseif ($this->is_home_posts_page()) {
$template = $this->options['metadesc-home-wpseo'];
$term = array();
if (empty($template)) {
$template = get_bloginfo('description');
}
} elseif ($this->is_posts_page()) {
$metadesc = WPSEO_Meta::get_value('metadesc', get_option('page_for_posts'));
if ($metadesc === '' && $post_type !== '' && isset($this->options['metadesc-' . $post_type])) {
$page = get_post(get_option('page_for_posts'));
$template = $this->options['metadesc-' . $post_type];
$term = $page;
}
} elseif ($this->is_home_static_page()) {
$metadesc = WPSEO_Meta::get_value('metadesc');
if ($metadesc === '' && $post_type !== '' && isset($this->options['metadesc-' . $post_type])) {
$template = $this->options['metadesc-' . $post_type];
}
} elseif (is_category() || is_tag() || is_tax()) {
$term = $wp_query->get_queried_object();
$metadesc_override = WPSEO_Taxonomy_Meta::get_term_meta($term, $term->taxonomy, 'desc');
if (is_object($term) && isset($term->taxonomy, $this->options['metadesc-tax-' . $term->taxonomy])) {
$template = $this->options['metadesc-tax-' . $term->taxonomy];
}
} elseif (is_author()) {
$author_id = get_query_var('author');
$metadesc = get_the_author_meta('wpseo_metadesc', $author_id);
if ((!is_string($metadesc) || $metadesc === '') && '' !== $this->options['metadesc-author-wpseo']) {
$template = $this->options['metadesc-author-wpseo'];
}
} elseif (is_post_type_archive()) {
$post_type = get_query_var('post_type');
if (is_array($post_type)) {
$post_type = reset($post_type);
}
if (isset($this->options['metadesc-ptarchive-' . $post_type])) {
$template = $this->options['metadesc-ptarchive-' . $post_type];
}
} elseif (is_archive()) {
$template = $this->options['metadesc-archive-wpseo'];
}
// If we're on a paginated page, and the template doesn't change for paginated pages, bail.
if ((!is_string($metadesc) || $metadesc === '') && get_query_var('paged') && get_query_var('paged') > 1 && $template !== '') {
if (strpos($template, '%%page') === false) {
$metadesc = '';
}
}
}
$post_data = $post;
if (is_string($metadesc_override) && '' !== $metadesc_override) {
$metadesc = $metadesc_override;
if (isset($term)) {
$post_data = $term;
}
} else {
if ((!is_string($metadesc) || '' === $metadesc) && '' !== $template) {
if (!isset($term)) {
$term = $wp_query->get_queried_object();
}
$metadesc = $template;
$post_data = $term;
}
}
$metadesc = wpseo_replace_vars($metadesc, $post_data);
/**
* Filter: 'wpseo_metadesc' - Allow changing the WP SEO meta description sentence.
*
* @api string $metadesc The description sentence.
*/
$this->metadesc = apply_filters('wpseo_metadesc', trim($metadesc));
}
示例6: update_term
/**
* Update the taxonomy meta data on save.
*
* @param int $term_id ID of the term to save data for
* @param int $tt_id The taxonomy_term_id for the term.
* @param string $taxonomy The taxonomy the term belongs to.
*/
function update_term($term_id, $tt_id, $taxonomy)
{
$tax_meta = get_option('wpseo_taxonomy_meta');
/* Create post array with only our values */
$new_meta_data = array();
foreach (WPSEO_Taxonomy_Meta::$defaults_per_term as $key => $default) {
if (isset($_POST[$key])) {
$new_meta_data[$key] = $_POST[$key];
}
}
/* Validate the post values */
$old = WPSEO_Taxonomy_Meta::get_term_meta($term_id, $taxonomy);
$clean = WPSEO_Taxonomy_Meta::validate_term_meta_data($new_meta_data, $old);
/* Add/remove the result to/from the original option value */
if ($clean !== array()) {
$tax_meta[$taxonomy][$term_id] = $clean;
} else {
unset($tax_meta[$taxonomy][$term_id]);
if (isset($tax_meta[$taxonomy]) && $tax_meta[$taxonomy] === array()) {
unset($tax_meta[$taxonomy]);
}
}
// Prevent complete array validation
$tax_meta['wpseo_already_validated'] = true;
update_option('wpseo_taxonomy_meta', $tax_meta);
}
示例7: update_video_term_meta
/**
* Check and, if applicable, update video details for a term description
*
* @since 1.3
*
* @param object $term The term to check the description and possibly update the video details for.
* @param boolean $echo Whether or not to echo the performed actions.
*
* @return mixed $vid The video array that was just stored, or "none" if nothing was stored
* or false if not applicable.
*/
public function update_video_term_meta($term, $echo = false)
{
$options = array_merge(WPSEO_Options::get_all(), get_option('wpseo_video'));
if (!is_array($options['videositemap_taxonomies']) || $options['videositemap_taxonomies'] === array()) {
return false;
}
if (!in_array($term->taxonomy, $options['videositemap_taxonomies'])) {
return false;
}
$tax_meta = get_option('wpseo_taxonomy_meta');
$old_vid = array();
if (!isset($_POST['force'])) {
if (isset($tax_meta[$term->taxonomy]['_video'][$term->term_id])) {
$old_vid = $tax_meta[$term->taxonomy]['_video'][$term->term_id];
}
}
$vid = array();
$title = WPSEO_Taxonomy_Meta::get_term_meta($term->term_id, $term->taxonomy, 'wpseo_title');
if (empty($title) && isset($options['title-' . $term->taxonomy]) && $options['title-' . $term->taxonomy] !== '') {
$title = wpseo_replace_vars($options['title-' . $term->taxonomy], (array) $term);
}
if (empty($title)) {
$title = $term->name;
}
$vid['title'] = htmlspecialchars($title);
$vid['description'] = WPSEO_Taxonomy_Meta::get_term_meta($term->term_id, $term->taxonomy, 'wpseo_metadesc');
if (!$vid['description']) {
$vid['description'] = esc_attr(preg_replace('`\\s+`', ' ', wp_html_excerpt($this->strip_shortcodes(get_term_field('description', $term->term_id, $term->taxonomy)), 300)));
}
$vid['publication_date'] = date('Y-m-d\\TH:i:s+00:00');
// concatenate genesis intro text and term description to index the videos for both
$genesis_term_meta = get_option('genesis-term-meta');
$content = '';
if (isset($genesis_term_meta[$term->term_id]['intro_text']) && $genesis_term_meta[$term->term_id]['intro_text']) {
$content .= $genesis_term_meta[$term->term_id]['intro_text'];
}
$content .= "\n" . $term->description;
$content = stripslashes($content);
$vid = $this->index_content($content, $vid, $old_vid, null);
if ($vid != 'none') {
$tax_meta[$term->taxonomy]['_video'][$term->term_id] = $vid;
// Don't bother with the complete tax meta validation
$tax_meta['wpseo_already_validated'] = true;
update_option('wpseo_taxonomy_meta', $tax_meta);
if ($echo) {
$link = get_term_link($term);
if (!is_wp_error($link)) {
echo 'Updated <a href="' . esc_url($link) . '">' . esc_html($vid['title']) . '</a> - ' . esc_html($vid['type']) . '<br/>';
}
}
}
return $vid;
}
示例8: getTitle
public function getTitle()
{
if ($this->title_is_loaded === false) {
$this->title_is_loaded = true;
if ($this->post_loaded || $this->category_loaded) {
$this->loadTheQuery();
ob_start();
$object = $GLOBALS['wp_query']->get_queried_object();
if (function_exists('get_plugin_data') !== true) {
require_once $this->wordpress_location . '/wp-admin/includes/plugin.php';
}
if (file_exists($this->wordpress_location . '/wp-content/plugins/wordpress-seo/wp-seo.php') === true) {
$arDataWpSeo = get_plugin_data($this->wordpress_location . '/wp-content/plugins/wordpress-seo/wp-seo.php');
if (isset($arDataWpSeo['Version']) === true) {
$isRecentWpSeoVersion = version_compare($arDataWpSeo['Version'], '1.5.0', '>=');
if ($isRecentWpSeoVersion === false) {
if ($this->post_loaded) {
if (function_exists('wpseo_get_value')) {
$titleSeo = wpseo_get_value('title', $object->ID);
}
} elseif ($this->category_loaded) {
if (function_exists('wpseo_get_term_meta')) {
$titleSeo = wpseo_get_term_meta($object, $object->taxonomy, 'title');
}
}
} else {
if ($this->post_loaded) {
if (method_exists('\\WPSEO_Meta', 'get_value')) {
$titleSeo = \WPSEO_Meta::get_value('title', $object->ID);
}
} elseif ($this->category_loaded) {
if (method_exists('\\WPSEO_Taxonomy_Meta', 'get_term_meta')) {
$titleSeo = \WPSEO_Taxonomy_Meta::get_term_meta($object, $object->taxonomy, 'title');
}
}
}
}
}
if (isset($titleSeo) === true) {
echo $titleSeo;
} else {
the_title();
}
$this->title = ob_get_clean();
}
}
return $this->title;
}
示例9: get_link_info_for_term
/**
* Retrieve link url and text based on term object
*
* @param object $term Term object
*
* @return array $link Array of link text and url
*/
private function get_link_info_for_term($term)
{
$link = array();
$bctitle = WPSEO_Taxonomy_Meta::get_term_meta($term, $term->taxonomy, 'bctitle');
if (!is_string($bctitle) || $bctitle === '') {
$bctitle = $term->name;
}
$link['url'] = get_term_link($term);
$link['text'] = $bctitle;
return $link;
}
示例10: __construct
/**
* @param stdClass $term The current term.
*/
public function __construct($term)
{
$this->tax_meta = WPSEO_Taxonomy_Meta::get_term_meta((int) $term->term_id, $term->taxonomy);
}
示例11: get_focus_keyword
/**
* Returns the focus keyword if this is set, otherwise it will give the term name.
*
* @param stdClass|WP_Term $term The current term.
*
* @return string
*/
private function get_focus_keyword($term)
{
if ($focus_keyword = WPSEO_Taxonomy_Meta::get_term_meta('focuskw', $term->term_id, $term->taxonomy)) {
return $focus_keyword;
}
return $term->name;
}
示例12: _meta_keywords
public function _meta_keywords()
{
$wpseo_front = null;
if (isset($GLOBALS['wpseo_front'])) {
$wpseo_front = $GLOBALS['wpseo_front'];
} elseif (class_exists('WPSEO_Frontend') && method_exists('WPSEO_Frontend', 'get_instance')) {
$wpseo_front = WPSEO_Frontend::get_instance();
}
$current_action = $this->controller->get_current_action();
switch ($current_action) {
case 'showlisting':
global $post;
$listing_id = get_query_var('listing') ? wpbdp_get_post_by_slug(get_query_var('listing'))->ID : wpbdp_getv($_GET, 'id', get_query_var('id'));
$prev_post = $post;
$post = get_post($listing_id);
if (is_object($wpseo_front)) {
$wpseo_front->metadesc();
$wpseo_front->metakeywords();
}
$post = $prev_post;
break;
case 'browsecategory':
case 'browsetag':
if ($current_action == 'browsetag') {
$term = get_term_by('slug', get_query_var('tag'), WPBDP_TAGS_TAX);
} else {
$term = get_term_by('slug', get_query_var('category'), WPBDP_CATEGORY_TAX);
if (!$term && get_query_var('category_id')) {
$term = get_term_by('id', get_query_var('category_id'), WPBDP_CATEGORY_TAX);
}
}
if ($term) {
$metadesc = method_exists('WPSEO_Taxonomy_Meta', 'get_term_meta') ? WPSEO_Taxonomy_Meta::get_term_meta($term, $term->taxonomy, 'desc') : wpseo_get_term_meta($term, $term->taxonomy, 'desc');
if (!$metadesc && is_object($wpseo_front) && isset($wpseo_front->options['metadesc-tax-' . $term->taxonomy])) {
$metadesc = wpseo_replace_vars($wpseo_front->options['metadesc-tax-' . $term->taxonomy], (array) $term);
}
if ($metadesc) {
echo '<meta name="description" content="' . esc_attr(strip_tags(stripslashes($metadesc))) . '"/>' . "\n";
}
}
break;
case 'main':
if (is_object($wpseo_front)) {
$wpseo_front->metadesc();
$wpseo_front->metakeywords();
}
break;
default:
break;
}
}
示例13: wpseo_local_get_custom_marker
/**
* Get the custom marker from categories or general Local SEO settings.
*
* @param $post_id Int the post id
* @param $taxonomy String The taxonomy name from the location category
*/
function wpseo_local_get_custom_marker($post_id = null, $taxonomy = '')
{
$custom_marker = '';
if (!empty($post_id) && !empty($taxonomy)) {
$terms = wp_get_object_terms($post_id, $taxonomy, array('fields' => 'ids'));
$terms = apply_filters('wpseo_local_custom_marker_order', $terms);
if (!empty($terms)) {
foreach ($terms as $term_id) {
$tax_meta = WPSEO_Taxonomy_Meta::get_term_meta((int) $term_id, $taxonomy);
if (isset($tax_meta['wpseo_local_custom_marker']) && !empty($tax_meta['wpseo_local_custom_marker'])) {
$custom_marker = wp_get_attachment_url($tax_meta['wpseo_local_custom_marker']);
}
break;
}
}
} else {
$options = get_option('wpseo_local');
if (isset($options['custom_marker']) && intval($options['custom_marker'])) {
$custom_marker = wp_get_attachment_url($options['custom_marker']);
}
}
return $custom_marker;
}
示例14: description
/**
* Output the OpenGraph description, specific OG description first, if not, grab the meta description.
*
* @param bool $echo Whether to echo or return the description
*
* @return string $ogdesc
*/
public function description($echo = true)
{
$ogdesc = '';
if (is_front_page()) {
if (isset($this->options['og_frontpage_desc']) && $this->options['og_frontpage_desc'] !== '') {
$ogdesc = wpseo_replace_vars($this->options['og_frontpage_desc'], null);
} else {
$ogdesc = WPSEO_Frontend::get_instance()->metadesc(false);
}
}
if (is_singular()) {
$ogdesc = WPSEO_Meta::get_value('opengraph-description');
// Replace WP SEO Variables
$ogdesc = wpseo_replace_vars($ogdesc, get_post());
// Use metadesc if $ogdesc is empty
if ($ogdesc === '') {
$ogdesc = WPSEO_Frontend::get_instance()->metadesc(false);
}
// og:description is still blank so grab it from get_the_excerpt()
if (!is_string($ogdesc) || is_string($ogdesc) && $ogdesc === '') {
$ogdesc = str_replace('[…]', '…', strip_tags(get_the_excerpt()));
}
}
if (is_category() || is_tag() || is_tax()) {
$ogdesc = WPSEO_Frontend::get_instance()->metadesc(false);
if ('' == $ogdesc) {
$ogdesc = trim(strip_tags(term_description()));
}
if ('' == $ogdesc) {
$term = $GLOBALS['wp_query']->get_queried_object();
$ogdesc = WPSEO_Taxonomy_Meta::get_term_meta($term, $term->taxonomy, 'desc');
}
}
// Strip shortcodes if any
$ogdesc = strip_shortcodes($ogdesc);
/**
* Filter: 'wpseo_opengraph_desc' - Allow changing the OpenGraph description
*
* @api string $ogdesc The description string.
*/
$ogdesc = trim(apply_filters('wpseo_opengraph_desc', $ogdesc));
if (is_string($ogdesc) && $ogdesc !== '') {
if ($echo !== false) {
$this->og_tag('og:description', $ogdesc);
}
}
return $ogdesc;
}
示例15: get_focus_keyword_usage
/**
* Counting the number of given keyword used for other term than given term_id
*
* @return array
*/
private function get_focus_keyword_usage()
{
$focuskw = WPSEO_Taxonomy_Meta::get_term_meta($this->term, $this->term->taxonomy, 'focuskw');
return WPSEO_Taxonomy_Meta::get_keyword_usage($focuskw, $this->term->term_id, $this->term->taxonomy);
}