本文整理汇总了PHP中wpseo_replace_vars函数的典型用法代码示例。如果您正苦于以下问题:PHP wpseo_replace_vars函数的具体用法?PHP wpseo_replace_vars怎么用?PHP wpseo_replace_vars使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpseo_replace_vars函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_title_separator
public function get_title_separator($separator)
{
if (class_exists('WPSEO_Option_Titles')) {
$separator = wpseo_replace_vars('%%sep%%', array());
}
return $separator;
}
开发者ID:johnmanlove,项目名称:Galveston_Island,代码行数:7,代码来源:class-ecwid-integration-wpseo.php
示例2: item_to_response
/**
* Convert the given term into a analyzable object.
*
* @param mixed $item The term for which to build the analyzer data.
*
* @return array
*/
protected function item_to_response($item)
{
$focus_keyword = $this->get_focus_keyword($item);
$title = str_replace(' %%page%% ', ' ', $this->get_title($item));
$meta = $this->get_meta_description($item);
$description = $item->description;
/**
* Filter the term description for recalculation.
*
* @param string $description Content of the term. Modify to reflect front-end content.
* @oaram WP_Term $item The term the description comes from.
*/
$description = apply_filters('wpseo_term_description_for_recalculation', $description, $item);
return array('term_id' => $item->term_id, 'taxonomy' => $item->taxonomy, 'text' => $description, 'keyword' => $focus_keyword, 'url' => urldecode($item->slug), 'pageTitle' => apply_filters('wpseo_title', wpseo_replace_vars($title, $item, array('page'))), 'meta' => apply_filters('wpseo_metadesc', wpseo_replace_vars($meta, $item)), 'keyword_usage' => array($focus_keyword => WPSEO_Taxonomy_Meta::get_keyword_usage($focus_keyword, $item->term_id, $item->taxonomy)));
}
开发者ID:Didox,项目名称:beminfinito,代码行数:22,代码来源:class-recalculate-terms.php
示例3: item_to_response
/**
* Map the posts to a response array
*
* @param WP_Post $item The post for which to build the analyzer data.
*
* @return array
*/
protected function item_to_response($item)
{
$focus_keyword = WPSEO_Meta::get_value('focuskw', $item->ID);
$content = $item->post_content;
/**
* Filter the post content for use in the SEO score recalculation.
*
* @param string $content Content of the post. Modify to reflect front-end content.
* @param WP_Post $item The Post object the content comes from.
*/
$content = apply_filters('wpseo_post_content_for_recalculation', $content, $item);
// Apply shortcodes.
$content = do_shortcode($content);
return array('post_id' => $item->ID, 'text' => $content, 'keyword' => $focus_keyword, 'url' => urldecode($item->post_name), 'pageTitle' => apply_filters('wpseo_title', wpseo_replace_vars($this->get_title($item->ID, $item->post_type), $item)), 'meta' => apply_filters('wpseo_metadesc', wpseo_replace_vars($this->get_meta_description($item->ID, $item->post_type), $item)), 'keyword_usage' => array($focus_keyword => WPSEO_Meta::keyword_usage($focus_keyword, $item->ID)));
}
开发者ID:Didox,项目名称:beminfinito,代码行数:22,代码来源:class-recalculate-posts.php
示例4: google_plus_title
/**
* Output the Google+ specific title
*/
public function google_plus_title()
{
if (is_singular()) {
$title = WPSEO_Meta::get_value('google-plus-title');
/**
* Filter: 'wpseo_googleplus_title' - Allow developers to change the Google+ specific title
*
* @api string $title The title string
*/
$title = trim(apply_filters('wpseo_googleplus_title', $title));
if (is_string($title) && $title !== '') {
$title = wpseo_replace_vars($title, get_post());
echo '<meta itemprop="name" content="', esc_attr($title), '">', "\n";
}
}
}
开发者ID:HealthStaffTraining,项目名称:healthstafftraining,代码行数:19,代码来源:class-googleplus.php
示例5: test_wpseo_replace_vars
/**
* @covers wpseo_replace_vars
*/
public function test_wpseo_replace_vars()
{
// create author
$user_id = $this->factory->user->create(array('user_login' => 'User_Login', 'display_name' => 'User_Nicename'));
// create post
$post_id = $this->factory->post->create(array('post_title' => 'Post_Title', 'post_content' => 'Post_Content', 'post_excerpt' => 'Post_Excerpt', 'post_author' => $user_id, 'post_date' => date('Y-m-d H:i:s', strtotime('2000-01-01 2:30:00'))));
// get post
$post = get_post($post_id);
$input = '%%title%% %%excerpt%% %%date%% %%name%%';
$expected = 'Post_Title Post_Excerpt ' . mysql2date(get_option('date_format'), $post->post_date, true) . ' User_Nicename';
$output = wpseo_replace_vars($input, (array) $post);
$this->assertEquals($expected, $output);
/*
TODO
- Test all Basic Variables
- Test all Advanced Variables
*/
}
开发者ID:centre-for-effective-altruism,项目名称:wordpress-seo,代码行数:21,代码来源:test-wpseo-functions.php
示例6: get_replace_vars
/**
* Prepares the replace vars for localization.
*
* @return array replace vars
*/
private function get_replace_vars()
{
$post = $this->get_metabox_post();
$cached_replacement_vars = array();
$vars_to_cache = array('date', 'id', 'sitename', 'sitedesc', 'sep', 'page', 'currenttime', 'currentdate', 'currentday', 'currentmonth', 'currentyear');
foreach ($vars_to_cache as $var) {
$cached_replacement_vars[$var] = wpseo_replace_vars('%%' . $var . '%%', $post);
}
return $cached_replacement_vars;
}
开发者ID:domalexxx,项目名称:nashvancouver,代码行数:15,代码来源:class-metabox.php
示例7: metadesc
/**
* Outputs the meta description element or returns the description text.
*
* @param bool $echo Whether or not to echo the description.
* @return string
*/
function metadesc($echo = true)
{
if (get_query_var('paged') && get_query_var('paged') > 1) {
return;
}
global $post, $wp_query;
$options = get_wpseo_options();
$metadesc = '';
if (is_singular()) {
$metadesc = wpseo_get_value('metadesc');
if ($metadesc == '' || !$metadesc) {
if (isset($options['metadesc-' . $post->post_type]) && $options['metadesc-' . $post->post_type] != '') {
$metadesc = wpseo_replace_vars($options['metadesc-' . $post->post_type], (array) $post);
}
}
} else {
if (is_search()) {
$metadesc = '';
} else {
if ($this->is_home_posts_page() && isset($options['metadesc-home'])) {
$metadesc = wpseo_replace_vars($options['metadesc-home'], array());
} else {
if ($this->is_posts_page()) {
$metadesc = wpseo_get_value('metadesc', get_option('page_for_posts'));
if (($metadesc == '' || !$metadesc) && isset($options['metadesc-' . $post->post_type])) {
$page = get_post(get_option('page_for_posts'));
$metadesc = wpseo_replace_vars($options['metadesc-' . $post->post_type], (array) $page);
}
} else {
if ($this->is_home_static_page()) {
global $post;
$metadesc = wpseo_get_value('metadesc');
if (($metadesc == '' || !$metadesc) && isset($options['metadesc-' . $post->post_type])) {
$metadesc = wpseo_replace_vars($options['metadesc-' . $post->post_type], (array) $post);
}
} else {
if (is_category() || is_tag() || is_tax()) {
$term = $wp_query->get_queried_object();
$metadesc = wpseo_get_term_meta($term, $term->taxonomy, 'desc');
if (!$metadesc && isset($options['metadesc-' . $term->taxonomy])) {
$metadesc = wpseo_replace_vars($options['metadesc-' . $term->taxonomy], (array) $term);
}
} else {
if (is_author()) {
$author_id = get_query_var('author');
$metadesc = get_the_author_meta('wpseo_metadesc', $author_id);
if (!$metadesc && isset($options['metadesc-author'])) {
$metadesc = wpseo_replace_vars($options['metadesc-author'], (array) $wp_query->get_queried_object());
}
} else {
if (function_exists('is_post_type_archive') && is_post_type_archive()) {
$post_type = get_post_type();
if (isset($options['metadesc-ptarchive-' . $post_type]) && '' != $options['metadesc-ptarchive-' . $post_type]) {
$metadesc = $options['metadesc-ptarchive-' . $post_type];
}
}
}
}
}
}
}
}
}
$metadesc = apply_filters('wpseo_metadesc', trim($metadesc));
if ($echo) {
if (!empty($metadesc)) {
echo '<meta name="description" content="' . esc_attr(strip_tags(stripslashes($metadesc))) . '"/>' . "\n";
} else {
if (current_user_can('manage_options') && is_singular()) {
echo '<!-- ' . __('Admin only notice: this page doesn\'t show a meta description because it doesn\'t have one, either write it for this page specifically or go into the SEO -> Titles menu and set up a template.', 'wordpress-seo') . ' -->' . "\n";
}
}
} else {
return $metadesc;
}
}
开发者ID:robjcordes,项目名称:nexnewwp,代码行数:82,代码来源:class-frontend.php
示例8: 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()) {
$ogdesc = $this->options['og_frontpage_desc'] !== '' ? $this->options['og_frontpage_desc'] : $this->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 = $this->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 = trim(strip_tags(term_description()));
}
// Strip shortcodes if any
$ogdesc = strip_shortcodes($ogdesc);
/**
* Filter: 'wpseo_opengraph_desc' - Allow changing the OpenGraph description
*
* @api string $ogdesc The description string.
*/
$ogdesc = apply_filters('wpseo_opengraph_desc', $ogdesc);
if (is_string($ogdesc) && $ogdesc !== '') {
if ($echo !== false) {
$this->og_tag('og:description', $ogdesc);
}
}
return $ogdesc;
}
开发者ID:phuluang,项目名称:rosewellmusic,代码行数:44,代码来源:class-opengraph.php
示例9: 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));
}
开发者ID:shellygraham,项目名称:livestock-framing,代码行数:93,代码来源:class-frontend.php
示例10: wpseo_ajax_replace_vars
/**
* Used in the editor to replace vars for the snippet preview
*/
function wpseo_ajax_replace_vars()
{
check_ajax_referer('wpseo-replace-vars');
$post = get_post($_POST['post_id']);
$omit = array('excerpt', 'excerpt_only', 'title');
echo wpseo_replace_vars(stripslashes($_POST['string']), $post, $omit);
die;
}
开发者ID:UPMediaDesign,项目名称:vidaestudiantilip,代码行数:11,代码来源:ajax.php
示例11: get_single_sitemap_line
/**
* Get a single sitemap line to output in the xml sitemap
*
* @param $val
* @param $key
* @param $xtra
*
* @return null|string
*/
private function get_single_sitemap_line($val, $key, $xtra)
{
$val = $this->clean_string($val);
if (in_array($key, array('description', 'category', 'tag', 'title'))) {
$val = ent2ncr(esc_html($val));
}
if (!empty($val)) {
return "\t\t\t<video:" . $key . $xtra . '>' . wpseo_replace_vars($val, array()) . '</video:' . $key . ">\n";
}
return null;
}
开发者ID:bitrecruiter,项目名称:wordpress-stackable,代码行数:20,代码来源:video-seo.php
示例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;
}
}
开发者ID:Nedick,项目名称:stzagora-website,代码行数:51,代码来源:business-directory-plugin.php
示例13: page_title
/**
* Retrieve the page title.
*
* @param int $post_id Post to retrieve the title for.
*
* @return string
*/
private function page_title($post_id)
{
$fixed_title = WPSEO_Meta::get_value('title', $post_id);
if ($fixed_title !== '') {
return $fixed_title;
}
$post = get_post($post_id);
$options = WPSEO_Options::get_option('wpseo_titles');
if (is_object($post) && (isset($options['title-' . $post->post_type]) && $options['title-' . $post->post_type] !== '')) {
$title_template = $options['title-' . $post->post_type];
$title_template = str_replace(' %%page%% ', ' ', $title_template);
return wpseo_replace_vars($title_template, $post);
}
return wpseo_replace_vars('%%title%%', $post);
}
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:22,代码来源:class-meta-columns.php
示例14: ctfw_event_calendar_head_title
function ctfw_event_calendar_head_title($title, $sep, $seplocation)
{
global $post;
$new_title = $title;
// Theme supports this?
$support = get_theme_support('ctfw-event-calendar-head-title');
if (!empty($support)) {
// Arguments from theme support or default
$args = isset($support[0]) ? $support[0] : array();
$args = wp_parse_args($args, array('page_template' => 'events-calendar.php'));
// Only on event calendar page template
if (is_page_template(CTFW_THEME_PAGE_TPL_DIR . '/' . $args['page_template'])) {
$parts = array();
// Get month
if (!empty($_GET['month'])) {
/* translators: this is the PHP date format used for <title> on event calendar months */
$parts[] = date_i18n(_x('F Y', 'event calendar', 'church-theme-framework'), strtotime($_GET['month']));
}
// Get category
if (!empty($_GET['category'])) {
// Get term from slug
$category = get_term_by('slug', $_GET['category'], 'ctc_event_category');
// Get name
if (!empty($category->name)) {
$parts[] = wptexturize($category->name);
}
}
// Combine parts
if ($parts) {
// Is Yoast SEO plugin active?
$wpseo_separator = '';
if (function_exists('wpseo_replace_vars')) {
$wpseo_separator = trim(wpseo_replace_vars('%%sep%%', array()));
if (!empty($wpseo_separator)) {
$wpseo_separator = ' ' . $wpseo_separator . ' ';
}
}
// Get separator
if ($wpseo_separator) {
// use Yoast SEO plugin's separator if available
$separator = $wpseo_separator;
} else {
// otherwise fall back to ' | ' WordPress default
/* translators: separator for <title> content */
$separator = _x(' | ', 'head title', 'church-theme-framework');
}
// Combine month and category into suffix
$month_category = $separator . implode($separator, $parts);
// separator at left
$month_category_right = implode($separator, $parts) . $separator;
// separator at right
// Post title was found in <title>
// Insert month and category after that (e.g. Monthly Calendar - Month - Category - Site Title)
$post_title = isset($post->post_title) ? wptexturize($post->post_title) : '';
$post_title_esc = preg_quote($post_title);
if (!empty($post_title) && preg_match('/' . $post_title_esc . preg_quote($separator) . '/', $title)) {
$new_title = preg_replace('/(' . $post_title_esc . ')/', '$1' . $month_category, $title);
} else {
$site_title = get_bloginfo('name', 'display');
// wptexturize applied
$site_title_esc = preg_quote($site_title);
if (!empty($site_title)) {
// Is site title found at end of title?
// Insert month and category before that (e.g. Custom Title - Month - Category - Site Name)
if (preg_match('/' . $site_title_esc . '$/', $title)) {
$new_title = preg_replace('/(' . $site_title_esc . ')$/', $month_category_right . '$1', $title);
} else {
$new_title .= $month_category;
}
}
}
}
}
}
return $new_title;
}
开发者ID:pemiu01,项目名称:church-theme-framework,代码行数:76,代码来源:head.php
示例15: test_get_title_from_options
/**
* @covers WPSEO_Frontend::get_title_from_options
*/
public function test_get_title_from_options()
{
// should return an empty string
$this->assertEmpty(self::$class_instance->get_title_from_options('__not-existing-index'));
// create and go to post
$post_id = $this->factory->post->create();
$this->go_to(get_permalink($post_id));
$var_source = (array) get_queried_object();
$expected_title = wpseo_replace_vars('%%title%% %%sep%% %%sitename%%', $var_source);
$this->assertEquals($expected_title, self::$class_instance->get_title_from_options('__not-existing-index', $var_source));
// test with an option that exists
$index = 'title-post';
$expected_title = wpseo_replace_vars(self::$class_instance->options[$index], $var_source);
$this->assertEquals($expected_title, self::$class_instance->get_title_from_options($index, $var_source));
}
开发者ID:michalvittek,项目名称:wordpress-seo,代码行数:18,代码来源:test-class-wpseo-frontend.php
示例16: output
function output($post)
{
global $wpseo_metabox;
$options = get_wpseo_options();
if (is_int($post)) {
$post = get_post($post);
}
if (!$post) {
return;
}
if (!class_exists('DOMDocument')) {
$output = '<div class="wpseo_msg"><p><strong>' . __('Error') . ':</strong> ' . sprintf(__("your hosting environment does not support PHP's %sDocument Object Model%s."), '<a href="http://php.net/manual/en/book.dom.php">', '</a>') . ' ' . __("To enjoy all the benefits of the page analysis feature, you'll need to (get your host to) install it.") . '</p></div>';
return $output;
}
if (!wpseo_get_value('focuskw')) {
$output = '<div class="wpseo_msg"><p><strong>' . __('Error') . ':</strong> ' . __("you have not specified a focus keyword, you'll have to enter one, then save or update this post, before this report works.") . '</p></div>';
return $output;
}
$output = '<div class="wpseo_msg"><p><strong>' . __('Note') . ':</strong> ' . __('to update this page analysis, save as draft or update and check this tab again') . '.</p></div>';
$results = '';
$job = array();
$sampleurl = get_sample_permalink($post->ID);
$job["pageUrl"] = str_replace('%postname%', $sampleurl[1], $sampleurl[0]);
$job["pageSlug"] = urldecode($post->post_name);
$job["keyword"] = wpseo_get_value('focuskw');
$job["keyword_folded"] = $this->strip_separators_and_fold($job["keyword"]);
$dom = new domDocument();
$dom->strictErrorChecking = false;
$dom->preserveWhiteSpace = false;
@$dom->loadHTML($post->post_content);
$xpath = new DOMXPath($dom);
$statistics = new TextStatistics();
// Keyword
$this->ScoreKeyword($job, $results);
// Title
if (wpseo_get_value('title')) {
$title = wpseo_get_value('title');
} else {
if (isset($options['title-' . $post->post_type]) && $options['title-' . $post->post_type] != '') {
$title_template = $options['title-' . $post->post_type];
} else {
$title_template = '%%title%% - %%sitename%%';
}
$title = wpseo_replace_vars($title_template, (array) $post);
}
$this->ScoreTitle($job, $results, $title, $statistics);
unset($title);
// Meta description
$description = '';
if (wpseo_get_value('metadesc')) {
$description = wpseo_get_value('metadesc');
} else {
if (isset($options['metadesc-' . $post->post_type]) && $options['metadesc-' . $post->post_type] != '') {
$description = wpseo_replace_vars($options['metadesc-' . $post->post_type], (array) $post);
}
}
$this->ScoreDescription($job, $results, $description, $wpseo_metabox->wpseo_meta_length, $statistics);
unset($description);
// Body
$body = $this->GetBody($post);
$firstp = $this->GetFirstParagraph($post);
$this->ScoreBody($job, $results, $body, $firstp, $statistics);
unset($body);
unset($firstp);
// URL
$this->ScoreUrl($job, $results, $statistics);
// Headings
$headings = $this->GetHeadings($post->post_content);
$this->ScoreHeadings($job, $results, $headings);
unset($headings);
// Images
$alts = $this->GetImagesAltText($post->post_content);
$imgs = $this->GetImageCount($dom, $xpath);
$this->ScoreImagesAltText($job, $results, $alts, $imgs);
unset($alts);
unset($imgs);
// Anchors
$anchors = $this->GetAnchorTexts($dom, $xpath);
$count = $this->GetAnchorCount($dom, $xpath);
$this->ScoreAnchorTexts($job, $results, $anchors, $count);
unset($anchors);
unset($count);
unset($dom);
asort($results);
$output .= '<table class="wpseoanalysis">';
foreach ($results as $result) {
$scoreval = substr($result, 0, 1);
switch ($scoreval) {
case 1:
case 2:
case 3:
$score = 'poor';
break;
case 4:
case 5:
case 6:
$score = 'ok';
break;
case 7:
case 8:
//.........这里部分代码省略.........
开发者ID:Joshuwar,项目名称:Masterson,代码行数:101,代码来源:linkdex.php
示例17: get_keywords
/**
* Getting the keywords
*
* @param WP_Post $post The post object with the values.
*
* @return string
*/
private function get_keywords($post)
{
$keywords = WPSEO_Meta::get_value('metakeywords', $post->ID);
$option_meta_key = 'metakey-' . $post->post_type;
if ($keywords === '' && (is_object($post) && (isset($this->options[$option_meta_key]) && $this->options[$option_meta_key] !== ''))) {
$keywords = wpseo_replace_vars($this->options[$option_meta_key], $post);
}
return $keywords;
}
开发者ID:Friends-School-Atlanta,项目名称:Deployable-WordPress,代码行数:16,代码来源:class-frontend.php
示例18: page_title
function page_title($postid)
{
$fixed_title = wpseo_get_value('title', $postid);
if ($fixed_title) {
return $fixed_title;
} else {
$post = get_post($postid);
$options = get_wpseo_options();
if (isset($options['title-' . $post->post_type]) && !empty($options['title-' . $post->post_type])) {
return wpseo_replace_vars($options['title-' . $post->post_type], (array) $post);
} else {
return wpseo_replace_vars('%%title%%', (array) $post);
}
}
}
开发者ID:kitfrench,项目名称:Futurestep,代码行数:15,代码来源:class-metabox.php
示例19: wpseo_ajax_replace_vars
/**
* Used in the editor to replace vars for the snippet preview
*/
function wpseo_ajax_replace_vars()
{
global $post;
check_ajax_referer('wpseo-replace-vars');
$post = get_post(intval(WPSEO_Utils::filter_input(INPUT_POST, 'post_id')));
$omit = array('excerpt', 'excerpt_only', 'title');
echo wpseo_replace_vars(stripslashes(WPSEO_Utils::filter_input(INPUT_POST, 'string')), $post, $omit);
die;
}
开发者ID:BennyHudson,项目名称:foundations,代码行数:12,代码来源:ajax.php
示例20: 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 = '';
$frontend = WPSEO_Frontend::get_instance();
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 = $frontend->metadesc(false);
}
}
$is_posts_page = $frontend->is_posts_page();
if (is_singular() || $is_posts_page) {
$post_id = $is_posts_page ? get_option('page_for_posts') : get_the_ID();
$post = get_post($post_id);
$ogdesc = WPSEO_Meta::get_value('opengraph-description', $post_id);
// Replace Yoast SEO Variables.
$ogdesc = wpseo_replace_vars($ogdesc, $post);
// Use metadesc if $ogdesc is empty.
if ($ogdesc === '') {
$ogdesc = $frontend->metadesc(false);
}
// Tag 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_Taxonomy_Meta::get_meta_without_term('opengraph-description');
if ($ogdesc === '') {
$ogdesc = $frontend->metadesc(false);
}
if ($ogdesc === '') {
$ogdesc = trim(strip_tags(term_description()));
}
if ($ogdesc === '') {
$ogdesc = WPSEO_Taxonomy_Meta::get_meta_without_term('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;
}
开发者ID:yoast,项目名称:wordpress-seo,代码行数:61,代码来源:class-opengraph.php
注:本文中的wpseo_replace_vars函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论