本文整理汇总了PHP中WPSEO_Frontend类的典型用法代码示例。如果您正苦于以下问题:PHP WPSEO_Frontend类的具体用法?PHP WPSEO_Frontend怎么用?PHP WPSEO_Frontend使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WPSEO_Frontend类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: webdados_fb_open_graph
//.........这里部分代码省略.........
$fb_url = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day'));
} else {
if (is_month()) {
$fb_title = esc_attr(strip_tags(stripslashes(single_month_title(' ', false) . ' ' . __('Archives'))));
$fb_url = get_month_link(get_query_var('year'), get_query_var('monthnum'));
} else {
if (is_year()) {
$fb_title = esc_attr(strip_tags(stripslashes(get_query_var('year') . ' ' . __('Archives'))));
$fb_url = get_year_link(get_query_var('year'));
}
}
}
} else {
if (is_front_page()) {
$fb_url = get_option('home') . (intval($fb_url_add_trailing) == 1 ? '/' : '');
$fb_type = trim($fb_type_homepage == '' ? 'website' : $fb_type_homepage);
} else {
//Others... Defaults already set up there
}
}
}
}
}
}
}
}
//If no description let's just add the title
if (trim($fb_desc) == '') {
$fb_desc = $fb_title;
}
//YOAST?
if ($fb_show_wpseoyoast == 1) {
if (defined('WPSEO_VERSION')) {
$wpseo = WPSEO_Frontend::get_instance();
//App ID - From our plugin
//Admin ID - From our plugin
//Locale - From our plugin
//Sitename - From our plugin
//Title - From WPSEO
$fb_title = strip_tags($wpseo->title(false));
//Title - SubHeading plugin
if ($fb_show_subheading == 1) {
if (webdados_fb_open_graph_subheadingactive()) {
$fb_title .= ' - ' . get_the_subheading();
}
}
//URL - From WPSEO
$fb_url = $wpseo->canonical(false);
//Description - From WPSEO or our plugin
$fb_desc_temp = $wpseo->metadesc(false);
$fb_desc = strip_tags(trim($fb_desc_temp) != '' ? trim($fb_desc_temp) : $fb_desc);
//Image - From our plugin
}
}
//WooCommerce - Additional product images?
if (intval($fb_image_show) == 1 && class_exists('woocommerce') && $fb_wc_useproductgallery == 1 && is_product()) {
global $post;
$product = new WC_Product($post->ID);
if ($attachment_ids = $product->get_gallery_attachment_ids()) {
foreach ($attachment_ids as $attachment_id) {
if ($image_link = wp_get_attachment_url($attachment_id)) {
if (trim($image_link) != '') {
$fb_image_additional[] = trim($image_link);
}
}
}
示例2: disable_seo_on_escaped_fragment
public function disable_seo_on_escaped_fragment()
{
if (!array_key_exists('_escaped_fragment_', $_GET) || !ecwid_page_has_productbrowser()) {
return;
}
global $wpseo_front;
// Canonical
if (empty($wpseo_front)) {
$wpseo_front = WPSEO_Frontend::get_instance();
}
remove_action('wpseo_head', array($wpseo_front, 'canonical'), 20);
// Description
remove_action('wpseo_head', array($wpseo_front, 'metadesc'), 10);
}
示例3: listing_og_description
public static function listing_og_description($listing_id)
{
if (self::is_wp_seo_enabled()) {
$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();
}
global $post;
$prev_post = $post;
$post = get_post($listing_id);
$desc = $wpseo_front->metadesc(false);
$post = $prev_post;
return $desc;
}
$listing = WPBDP_Listing::get($listing_id);
return $listing->get_field_value('excerpt');
}
示例4: filter__title
/**
* Generate title
*
* @see get_title_from_options()
* @scope front
* @since 1.1.1
*
* @param string $text
*
* @return string
*/
public static function filter__title($text)
{
$text = WPGlobus_Core::text_filter($text, WPGlobus::Config()->language);
$wpseo_f = WPSEO_Frontend::get_instance();
if (empty($text)) {
global $post;
$text = $post->post_title . ' ' . $wpseo_f->get_title_from_options('wpseo_titles');
}
return $text;
}
示例5: wpseo_init
public function wpseo_init()
{
global $polylang;
if (!defined('WPSEO_VERSION') || PLL_ADMIN) {
return;
}
// reloads options once the language has been defined to enable translations
// useful only when the language is set from content
if (did_action('wp_loaded')) {
if (version_compare(WPSEO_VERSION, '1.7.2', '<')) {
global $wpseo_front;
} else {
$wpseo_front = WPSEO_Frontend::get_instance();
}
$options = version_compare(WPSEO_VERSION, '1.5', '<') ? get_wpseo_options_arr() : WPSEO_Options::get_option_names();
foreach ($options as $opt) {
$wpseo_front->options = array_merge($wpseo_front->options, (array) get_option($opt));
}
}
// one sitemap per language when using multiple domains or subdomains
// because WPSEO does not accept several domains or subdomains in one sitemap
if ($polylang->options['force_lang'] > 1) {
add_filter('wpseo_enable_xml_sitemap_transient_caching', '__return_false');
// disable cache! otherwise WPSEO keeps only one domain
add_filter('home_url', array(&$this, 'wpseo_home_url'), 10, 2);
// fix home_url
add_filter('wpseo_posts_join', array(&$this, 'wpseo_posts_join'), 10, 2);
add_filter('wpseo_posts_where', array(&$this, 'wpseo_posts_where'), 10, 2);
add_filter('wpseo_typecount_join', array(&$this, 'wpseo_posts_join'), 10, 2);
add_filter('wpseo_typecount_where', array(&$this, 'wpseo_posts_where'), 10, 2);
} else {
add_filter('get_terms_args', array(&$this, 'wpseo_remove_terms_filter'));
}
add_filter('pll_home_url_white_list', create_function('$arr', "return array_merge(\$arr, array(array('file' => 'wordpress-seo')));"));
add_action('wpseo_opengraph', array(&$this, 'wpseo_ogp'), 2);
}
示例6: fallback_title
/**
* Returns the Twitter title for any page
*
* @return string
*/
private function fallback_title()
{
return WPSEO_Frontend::get_instance()->title('');
}
示例7: test_twitter_url
/**
* @covers WPSEO_Twitter::url
*/
public function test_twitter_url()
{
// create and go to post
$post_id = $this->factory->post->create();
$this->go_to(get_permalink($post_id));
$expected = $this->metatag('url', esc_url(WPSEO_Frontend::get_instance()->canonical(false)));
self::$class_instance->url();
$this->expectOutput($expected);
}
示例8: description
public function description()
{
$desc = wpseo_get_value('opengraph-description');
if (!$desc) {
$desc = WPSEO_Frontend::metadesc(false);
}
if ($desc && $desc != '') {
echo "<meta property='og:description' content='" . esc_attr($desc) . "'/>\n";
}
}
示例9: wpto_remove_yoast_information
public function wpto_remove_yoast_information()
{
if (!empty($this->wpto_options['remove_yoast_information'])) {
if (defined('WPSEO_VERSION')) {
$instance = WPSEO_Frontend::get_instance();
remove_action('wpseo_head', array($instance, 'debug_marker'), 2);
remove_action('wp_head', array($instance, 'head'), 1);
add_action('wp_head', 'custom_yoast_head', 1);
function custom_yoast_head()
{
global $wp_query;
$old_wp_query = null;
if (!$wp_query->is_main_query()) {
$old_wp_query = $wp_query;
wp_reset_query();
}
do_action('wpseo_head');
if (!empty($old_wp_query)) {
$GLOBALS['wp_query'] = $old_wp_query;
unset($old_wp_query);
}
return;
}
}
}
}
示例10: wpseo_admin_bar_menu
/**
* Adds an SEO admin bar menu with several options. If the current user is an admin he can also go straight to several settings menu's from here.
*/
function wpseo_admin_bar_menu()
{
// If the current user can't write posts, this is all of no use, so let's not output an admin menu
if (!current_user_can('edit_posts')) {
return;
}
global $wp_admin_bar, $post;
$url = WPSEO_Frontend::get_instance()->canonical(false);
$focuskw = '';
$score = '';
$seo_url = get_admin_url(null, 'admin.php?page=wpseo_dashboard');
if ((is_singular() || is_admin() && in_array($GLOBALS['pagenow'], array('post.php', 'post-new.php'), true)) && isset($post) && is_object($post) && apply_filters('wpseo_use_page_analysis', true) === true) {
$focuskw = WPSEO_Meta::get_value('focuskw', $post->ID);
$perc_score = WPSEO_Meta::get_value('linkdex', $post->ID);
$calc_score = WPSEO_Utils::calc($perc_score, '/', 10, true);
$txtscore = WPSEO_Utils::translate_score($calc_score);
$title = WPSEO_Utils::translate_score($calc_score, false);
$score = '<div title="' . esc_attr($title) . '" class="' . esc_attr('wpseo-score-icon ' . $txtscore . ' ' . $perc_score) . '"></div>';
$seo_url = get_edit_post_link($post->ID);
if ($txtscore !== 'na') {
$seo_url .= '#wpseo_linkdex';
}
}
$wp_admin_bar->add_menu(array('id' => 'wpseo-menu', 'title' => __('SEO', 'wordpress-seo') . $score, 'href' => $seo_url));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-kwresearch', 'title' => __('Keyword Research', 'wordpress-seo'), '#'));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-kwresearch', 'id' => 'wpseo-adwordsexternal', 'title' => __('AdWords External', 'wordpress-seo'), 'href' => 'http://adwords.google.com/keywordplanner', 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-kwresearch', 'id' => 'wpseo-googleinsights', 'title' => __('Google Insights', 'wordpress-seo'), 'href' => 'http://www.google.com/insights/search/#q=' . urlencode($focuskw) . '&cmpt=q', 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-kwresearch', 'id' => 'wpseo-wordtracker', 'title' => __('SEO Book', 'wordpress-seo'), 'href' => 'http://tools.seobook.com/keyword-tools/seobook/?keyword=' . urlencode($focuskw), 'meta' => array('target' => '_blank')));
if (!is_admin()) {
$wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-analysis', 'title' => __('Analyze this page', 'wordpress-seo'), '#'));
if (is_string($url)) {
// @todo [JRF => whomever] check if this url shouldn't be encoded either with urlencode or with esc_url or something
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-inlinks-ose', 'title' => __('Check Inlinks (OSE)', 'wordpress-seo'), 'href' => '//moz.com/researchtools/ose/links?site=' . urlencode($url), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-kwdensity', 'title' => __('Check Keyword Density', 'wordpress-seo'), 'href' => '//www.zippy.co.uk/keyworddensity/index.php?url=' . urlencode($url) . '&keyword=' . urlencode($focuskw), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-cache', 'title' => __('Check Google Cache', 'wordpress-seo'), 'href' => '//webcache.googleusercontent.com/search?strip=1&q=cache:' . urlencode($url), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-header', 'title' => __('Check Headers', 'wordpress-seo'), 'href' => '//quixapp.com/headers/?r=' . urlencode($url), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-richsnippets', 'title' => __('Check Rich Snippets', 'wordpress-seo'), 'href' => '//www.google.com/webmasters/tools/richsnippets?q=' . urlencode($url), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-facebookdebug', 'title' => __('Facebook Debugger', 'wordpress-seo'), 'href' => '//developers.facebook.com/tools/debug/og/object?q=' . urlencode($url), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-pinterestvalidator', 'title' => __('Pinterest Rich Pins Validator', 'wordpress-seo'), 'href' => '//developers.pinterest.com/rich_pins/validator/?link=' . urlencode($url), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-htmlvalidation', 'title' => __('HTML Validator', 'wordpress-seo'), 'href' => '//validator.w3.org/check?uri=' . urlencode($url), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-cssvalidation', 'title' => __('CSS Validator', 'wordpress-seo'), 'href' => '//jigsaw.w3.org/css-validator/validator?uri=' . urlencode($url), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-pagespeed', 'title' => __('Google Page Speed Test', 'wordpress-seo'), 'href' => '//developers.google.com/speed/pagespeed/insights/?url=' . urlencode($url), 'meta' => array('target' => '_blank')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-analysis', 'id' => 'wpseo-modernie', 'title' => __('Modern IE Site Scan', 'wordpress-seo'), 'href' => '//www.modern.ie/en-us/report#' . urlencode($url), 'meta' => array('target' => '_blank')));
}
}
$admin_menu = false;
if (is_multisite()) {
$options = get_site_option('wpseo_ms');
if ($options['access'] === 'superadmin' && is_super_admin()) {
$admin_menu = true;
} elseif (current_user_can('manage_options')) {
$admin_menu = true;
}
} elseif (current_user_can('manage_options')) {
$admin_menu = true;
}
// @todo: add links to bulk title and bulk description edit pages
if ($admin_menu) {
$wp_admin_bar->add_menu(array('parent' => 'wpseo-menu', 'id' => 'wpseo-settings', 'title' => __('SEO Settings', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_titles')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-titles', 'title' => __('Titles & Metas', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_titles')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-social', 'title' => __('Social', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_social')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-xml', 'title' => __('XML Sitemaps', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_xml')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-permalinks', 'title' => __('Permalinks', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_permalinks')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-internal-links', 'title' => __('Internal Links', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_internal-links')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-rss', 'title' => __('RSS', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_rss')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-import', 'title' => esc_html__('Import & Export', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_import')));
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo_bulk-editor', 'title' => __('Bulk Editor', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_bulk-editor')));
// Check where to add the edit files page
if (WPSEO_Utils::allow_system_file_edit() === true) {
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-files', 'title' => __('Edit Files', 'wordpress-seo'), 'href' => network_admin_url('admin.php?page=wpseo_files')));
// will auto-use admin_url if not in multi-site
}
$wp_admin_bar->add_menu(array('parent' => 'wpseo-settings', 'id' => 'wpseo-licenses', 'title' => __('Extensions', 'wordpress-seo'), 'href' => admin_url('admin.php?page=wpseo_licenses')));
}
}
示例11: foreach
foreach ($post_categories_array as $cats) {
$cat = get_category($cats);
if ($post_sections == '') {
$post_sections .= $cat->name;
} else {
$post_sections .= ', ' . $cat->name;
}
}
?>
<meta itemprop="name headline" content="<?php
the_title();
?>
" />
<?php
if (class_exists('WPSEO_Frontend')) {
$wp_seo_object = WPSEO_Frontend::get_instance();
$post_description = htmlentities($wp_seo_object->metadesc(false));
echo '<meta itemprop="description" content="' . $post_description . '" />';
}
?>
<meta itemprop="datePublished" content="<?php
echo $post_date_iso;
?>
" />
<span class="date published"><?php
echo $post_date_iso;
?>
</span>
<meta itemprop="dateModified" content="<?php
echo $post_modified_date_iso;
?>
示例12: wp_head
/**
@brief Use the correct canonical link.
**/
public function wp_head()
{
// Only override the canonical if we're looking at a single post.
$override = false;
$override |= is_single();
$override |= is_page();
if (!$override) {
return;
}
global $post;
global $blog_id;
// Find the parent, if any.
$broadcast_data = $this->get_post_broadcast_data($blog_id, $post->ID);
$linked_parent = $broadcast_data->get_linked_parent();
if ($linked_parent === false) {
return;
}
// Post has a parent. Get the parent's permalink.
switch_to_blog($linked_parent['blog_id']);
$url = get_permalink($linked_parent['post_id']);
restore_current_blog();
echo sprintf('<link rel="canonical" href="%s" />', $url);
echo "\n";
// Prevent Wordpress from outputting its own canonical.
remove_action('wp_head', 'rel_canonical');
// Remove Canonical Link Added By Yoast WordPress SEO Plugin
if (class_exists('\\WPSEO_Frontend')) {
$this->add_filter('wpseo_canonical', 'wp_head_remove_wordpress_seo_canonical');
$wpseo_frontend = \WPSEO_Frontend::get_instance();
remove_action('wpseo_head', array($wpseo_frontend, 'canonical'), 20);
}
}
示例13: ampforwp_update_metadata
function ampforwp_update_metadata($metadata, $post)
{
global $redux_builder_amp;
$structured_data_logo = $redux_builder_amp['amp-structured-data-logo']['url'];
if ($structured_data_logo) {
$structured_data_logo = $structured_data_logo;
} else {
$structured_data_logo = $redux_builder_amp['opt-media']['url'];
}
$metadata['publisher']['logo'] = array('@type' => 'ImageObject', 'url' => $structured_data_logo, 'height' => 36, 'width' => 190);
//code for adding 'description' meta from Yoast SEO
include_once ABSPATH . 'wp-admin/includes/plugin.php';
if (is_plugin_active('wordpress-seo/wp-seo.php')) {
$front = WPSEO_Frontend::get_instance();
$desc = $front->metadesc(false);
if ($desc) {
$metadata['description'] = $desc;
}
}
//End of code for adding 'description' meta from Yoast SEO
return $metadata;
}
示例14: test_twitter_description_metadesc
/**
* @covers WPSEO_Twitter::description
*/
public function test_twitter_description_metadesc()
{
// create and go to post
$post_id = $this->factory->post->create();
// test wpseo meta
WPSEO_Meta::set_value('metadesc', 'Meta description', $post_id);
$this->go_to(get_permalink($post_id));
$expected = $this->metatag('description', WPSEO_Frontend::get_instance()->metadesc(false));
self::$class_instance->description();
$this->expectOutput($expected);
}
示例15: test_og_title
/**
* @covers WPSEO_OpenGraph::og_title
*/
public function test_og_title()
{
// create and go to post
$post_id = $this->factory->post->create();
$this->go_to(get_permalink($post_id));
$expected_title = WPSEO_Frontend::get_instance()->title('');
$expected_html = '<meta property="og:title" content="' . $expected_title . '" />' . "\n";
$this->assertTrue(self::$class_instance->og_title());
$this->expectOutput($expected_html);
$this->assertEquals(self::$class_instance->og_title(false), $expected_title);
}