本文整理汇总了PHP中get_wpseo_options函数的典型用法代码示例。如果您正苦于以下问题:PHP get_wpseo_options函数的具体用法?PHP get_wpseo_options怎么用?PHP get_wpseo_options使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_wpseo_options函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Class constructor.
*/
public function __construct()
{
$this->options = get_wpseo_options();
global $fb_ver;
if (isset($fb_ver) || class_exists('Facebook_Loader')) {
add_filter('fb_meta_tags', array($this, 'facebook_filter'), 10, 1);
} else {
add_filter('language_attributes', array($this, 'add_opengraph_namespace'));
add_action('wpseo_opengraph', array($this, 'locale'), 1);
add_action('wpseo_opengraph', array($this, 'type'), 5);
add_action('wpseo_opengraph', array($this, 'og_title'), 10);
add_action('wpseo_opengraph', array($this, 'site_owner'), 20);
add_action('wpseo_opengraph', array($this, 'description'), 11);
add_action('wpseo_opengraph', array($this, 'url'), 12);
add_action('wpseo_opengraph', array($this, 'site_name'), 13);
add_action('wpseo_opengraph', array($this, 'website_facebook'), 14);
add_action('wpseo_opengraph', array($this, 'article_author_facebook'), 15);
add_action('wpseo_opengraph', array($this, 'tags'), 16);
add_action('wpseo_opengraph', array($this, 'category'), 17);
add_action('wpseo_opengraph', array($this, 'publish_date'), 19);
add_action('wpseo_opengraph', array($this, 'image'), 30);
}
remove_action('wp_head', 'jetpack_og_tags');
add_action('wpseo_head', array($this, 'opengraph'), 30);
}
示例2: __construct
public function __construct()
{
$options = get_wpseo_options();
add_action('wpseo_tab_header', array(&$this, 'tab_header'), 60);
add_action('wpseo_tab_content', array(&$this, 'tab_content'));
add_filter('wpseo_save_metaboxes', array(&$this, 'save_meta_boxes'), 10, 1);
}
示例3: query_vars
/**
* Update the query vars with the redirect var when stripcategorybase is active
*
* @param $query_vars
* @return array
*/
function query_vars($query_vars)
{
$options = get_wpseo_options();
if (isset($options['stripcategorybase']) && $options['stripcategorybase']) {
$query_vars[] = 'wpseo_category_redirect';
}
return $query_vars;
}
示例4: __construct
public function __construct()
{
$this->options = get_wpseo_options();
add_action('wpseo_head', array(&$this, 'opengraph'));
if (isset($this->options['opengraph']) && $this->options['opengraph']) {
add_filter('language_attributes', array(&$this, 'add_opengraph_namespace'));
}
}
示例5: WPSEO_Widgets
function WPSEO_Widgets()
{
$options = get_wpseo_options();
if (isset($options['replacemetawidget']) && $options['replacemetawidget'] == "on") {
add_action('plugins_loaded', array(&$this, 'load_widgets'), 10);
add_action('widgets_init', array(&$this, 'widgets_init'), 99);
}
}
示例6: __construct
function __construct()
{
if (!defined('ENT_XML1')) {
define("ENT_XML1", 16);
}
add_action('init', array($this, 'init'), 1);
add_action('template_redirect', array($this, 'redirect'));
add_filter('redirect_canonical', array($this, 'canonical'));
add_action('wpseo_hit_sitemap_index', array($this, 'hit_sitemap_index'));
// default stylesheet
$this->stylesheet = '<?xml-stylesheet type="text/xsl" href="' . home_url('main-sitemap.xsl') . '"?>';
$this->options = get_wpseo_options();
}
示例7: add_to_index
/**
* Adds active languages sitemap links to sitemap_index.xml
* @param type $str
*/
function add_to_index($str)
{
global $sitepress, $sitepress_settings, $wpdb;
$options = get_wpseo_options();
$default_language = $sitepress->get_default_language();
$current_language = $sitepress->get_current_language();
foreach ($sitepress->get_active_languages() as $lang_code => $array) {
if (isset($sitepress_settings['language_domains'][$lang_code])) {
$home_url = $sitepress_settings['language_domains'][$lang_code];
} else {
$home_url = home_url();
}
foreach (get_post_types(array('public' => true)) as $post_type) {
$sitepress->switch_lang($lang_code);
$count = get_posts(array('post_type' => $post_type, 'post_status' => 'publish', 'suppress_filters' => 0));
$sitepress->switch_lang($current_language);
if (count($count) > 0 && $sitepress->is_translated_post_type($post_type)) {
if (!isset($options['post_types-' . $post_type . '-not_in_sitemap']) && $lang_code !== $default_language) {
$filename = $post_type . '-' . $lang_code . '-sitemap.xml';
$date = $this->get_last_mod_date($post_type, $lang_code);
$str .= '<sitemap>' . "\n";
$str .= '<loc>' . $home_url . '/' . $filename . '</loc>' . "\n";
$str .= '<lastmod>' . $date . '</lastmod>' . "\n";
$str .= '</sitemap>' . "\n";
}
}
}
foreach (get_taxonomies(array('public' => true)) as $tax) {
$sitepress->switch_lang($lang_code);
$count = get_terms($tax, array('suppress_filters' => 0));
$sitepress->switch_lang($current_language);
if (count($count) > 0 && $sitepress->is_translated_taxonomy($tax)) {
if (!isset($options['taxonomies-' . $tax . '-not_in_sitemap']) && $lang_code !== $default_language) {
$filename = $tax . '-' . $lang_code . '-sitemap.xml';
$date = $this->get_last_mod_date('post', $lang_code);
$str .= '<sitemap>' . "\n";
$str .= '<loc>' . $home_url . '/' . $filename . '</loc>' . "\n";
$str .= '<lastmod>' . $date . '</lastmod>' . "\n";
$str .= '</sitemap>' . "\n";
}
}
}
}
return $str;
}
示例8: status_transition
/**
* Hooked into transition_post_status. Will initiate search engine pings
* if the post is being published, is a post type that a sitemap is built for
* and is a post that is included in sitemaps.
*/
function status_transition($new_status, $old_status, $post)
{
if ($new_status != 'publish') {
return;
}
wp_cache_delete('lastpostmodified:gmt:' . $post->post_type, 'timeinfo');
// #17455
$options = get_wpseo_options();
if (isset($options['post_types-' . $post->post_type . '-not_in_sitemap']) && $options['post_types-' . $post->post_type . '-not_in_sitemap']) {
return;
}
if (WP_CACHE) {
wp_schedule_single_event(time(), 'wpseo_hit_sitemap_index');
}
// Allow the pinging to happen slightly after the hit sitemap index so the sitemap is fully regenerated when the ping happens.
if (wpseo_get_value('sitemap-include', $post->ID) != 'never') {
wp_schedule_single_event(time() + 60, 'wpseo_ping_search_engines');
}
}
示例9: modify_breadcrumb_element
/**
* This function modifies the output for a single breadcrumb.
*
* The default output is not modified, instead a completely new output is generated.
* If the default link output contains a rel attribute with the value 'v:url' (which is added by WordPress SEO for every but the last link), URL and text are output.
* Otherwise it is the current page for which only the text is printed out.
*
* In this method the Schema.org markup for a single breadcrumb is added, and the link counter (class variable) is increased by 1 (for each link).
*
* @param string $link_output the default output created by the WordPress SEO plugin
* @param array $link an array containing data for the breadcrumb link (with fields 'url' and 'text')
* @return string the output for a single breadcrumb link
*/
public function modify_breadcrumb_element($link_output, $link)
{
$output = '';
if (isset($link['url']) && substr_count($link_output, 'rel="v:url"') > 0) {
$output .= '<a href="' . esc_attr($link['url']) . '"><span itemprop="itemListElement">' . $link['text'] . '</span></a>';
} else {
$opt = array();
if (class_exists('WPSEO_Options')) {
$opt = WPSEO_Options::get_all();
} else {
$opt = get_wpseo_options();
}
if (isset($opt['breadcrumbs-boldlast']) && $opt['breadcrumbs-boldlast']) {
$output .= '<strong class="breadcrumb_last" itemprop="itemListElement">' . $link['text'] . '</strong>';
} else {
$output .= '<span class="breadcrumb_last" itemprop="itemListElement">' . $link['text'] . '</span>';
}
}
$this->breadcrumb_link_counter++;
return $output;
}
开发者ID:felixarntz,项目名称:schema-breadcrumbs-for-wordpress-seo,代码行数:34,代码来源:class.schema_breadcrumbs.php
示例10: term_additions_form
function term_additions_form($term, $taxonomy)
{
$tax_meta = get_option('wpseo_taxonomy_meta');
$options = get_wpseo_options();
if (isset($tax_meta[$taxonomy][$term->term_id])) {
$tax_meta = $tax_meta[$taxonomy][$term->term_id];
}
echo '<h3>Yoast WordPress SEO Settings</h3>';
echo '<table class="form-table">';
$this->form_row('wpseo_title', 'SEO Title', 'The SEO title is used on the archive page for this term.', $tax_meta);
$this->form_row('wpseo_desc', 'SEO Description', 'The SEO description is used for the meta description on the archive page for this term.', $tax_meta);
if (isset($options['usemetakeywords']) && $options['usemetakeywords']) {
$this->form_row('wpseo_metakey', 'Meta Keywords', 'Meta keywords used on the archive page for this term.', $tax_meta);
}
$this->form_row('wpseo_canonical', 'Canonical', 'The canonical link is shown on the archive page for this term.', $tax_meta);
$this->form_row('wpseo_bctitle', 'Breadcrumbs Title', 'The Breadcrumbs title is used in the breadcrumbs where this ' . $taxonomy . ' appears.', $tax_meta);
$this->form_row('wpseo_noindex', 'Noindex this ' . $taxonomy, '', $tax_meta, 'checkbox');
$this->form_row('wpseo_nofollow', 'Nofollow this ' . $taxonomy, '', $tax_meta, 'checkbox');
$this->form_row('wpseo_sitemap_include', 'Include in sitemap?', '', $tax_meta, 'select', array("-" => __("Auto detect"), "always" => __("Always include"), "never" => __("Never include")));
echo '</table>';
}
示例11: twitter
/**
* Outputs the Twitter Card code on singular pages.
*
* @return false Only shows on singular pages, false on non-singular pages.
*/
public function twitter()
{
if (!is_singular()) {
return false;
}
wp_reset_query();
$this->type();
$this->site_twitter();
$this->site_domain();
$this->author_twitter();
// No need to show these when OpenGraph is also showing, as it'd be the same contents and Twitter
// would fallback to OpenGraph anyway.
$this->image();
$options = get_wpseo_options();
if (!isset($options['opengraph']) || !$options['opengraph']) {
$this->twitter_description();
$this->twitter_title();
$this->twitter_url();
}
do_action('wpseo_twitter');
}
示例12: calculate_results
/**
* Calculate the page analysis results for post.
*
* @param object $post Post to calculate the results for.
* @return array
*/
function calculate_results($post)
{
$options = get_wpseo_options();
if (!class_exists('DOMDocument')) {
$result = new WP_Error('no-domdocument', sprintf(__("Your hosting environment does not support PHP's %sDocument Object Model%s.", 'wordpress-seo'), '<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.", 'wordpress-seo'));
return $result;
}
if (!wpseo_get_value('focuskw', $post->ID)) {
$result = new WP_Error('no-focuskw', sprintf(__('No focus keyword was set for this %s. If you do not set a focus keyword, no score can be calculated.', 'wordpress-seo'), $post->post_type));
wpseo_set_value('linkdex', 0, $post->ID);
return $result;
}
$results = array();
$job = array();
$sampleurl = get_sample_permalink($post);
$job["pageUrl"] = preg_replace('/%(post|page)name%/', $sampleurl[1], $sampleurl[0]);
$job["pageSlug"] = urldecode($post->post_name);
$job["keyword"] = trim(wpseo_get_value('focuskw'));
$job["keyword_folded"] = $this->strip_separators_and_fold($job["keyword"]);
$job["post_id"] = $post->ID;
$dom = new domDocument();
$dom->strictErrorChecking = false;
$dom->preserveWhiteSpace = false;
@$dom->loadHTML($post->post_content);
$xpath = new DOMXPath($dom);
$statistics = new Yoast_TextStatistics();
// Check if this focus keyword has been used already.
$this->check_double_focus_keyword($job, $results);
// Keyword
$this->score_keyword($job['keyword'], $results);
// Title
if (wpseo_get_value('title')) {
$job['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%%';
}
$job['title'] = wpseo_replace_vars($title_template, (array) $post);
}
$this->score_title($job, $results, $statistics);
// Meta description
$description = '';
if (wpseo_get_value('metadesc')) {
$description = wpseo_get_value('metadesc');
} else {
if (isset($options['metadesc-' . $post->post_type]) && !empty($options['metadesc-' . $post->post_type])) {
$description = wpseo_replace_vars($options['metadesc-' . $post->post_type], (array) $post);
}
}
$meta_length = apply_filters('wpseo_metadesc_length', 156, $post);
$this->score_description($job, $results, $description, $statistics, $meta_length);
unset($description);
// Body
$body = $this->get_body($post);
$firstp = $this->get_first_paragraph($post);
$this->score_body($job, $results, $body, $firstp, $statistics);
unset($body);
unset($firstp);
// URL
$this->score_url($job, $results, $statistics);
// Headings
$headings = $this->get_headings($post->post_content);
$this->score_headings($job, $results, $headings);
unset($headings);
// Images
$imgs = array();
$imgs['count'] = substr_count($post->post_content, '<img');
$imgs = $this->get_images_alt_text($post, $imgs);
$this->score_images_alt_text($job, $results, $imgs);
unset($imgs);
// Anchors
$anchors = $this->get_anchor_texts($xpath);
$count = $this->get_anchor_count($xpath);
$this->score_anchor_texts($job, $results, $anchors, $count);
unset($anchors, $count, $dom);
$results = apply_filters('wpseo_linkdex_results', $results, $job, $post);
$this->aasort($results, 'val');
$overall = 0;
$overall_max = 0;
foreach ($results as $result) {
$overall += $result['val'];
$overall_max += 9;
}
if ($overall < 1) {
$overall = 1;
}
$score = round($overall / $overall_max * 100);
wpseo_set_value('linkdex', absint($score), $post->ID);
return $results;
}
示例13: __construct
/**
* Class constructor
*
* Adds and removes a lot of filters.
*/
function __construct()
{
$this->options = get_wpseo_options();
add_action('wp_head', array($this, 'head'), 1);
// The head function here calls action wpseo_head, to which we hook all our functionality
add_action('wpseo_head', array($this, 'debug_marker'), 2);
add_action('wpseo_head', array($this, 'robots'), 6);
add_action('wpseo_head', array($this, 'metadesc'), 10);
add_action('wpseo_head', array($this, 'metakeywords'), 11);
add_action('wpseo_head', array($this, 'canonical'), 20);
add_action('wpseo_head', array($this, 'adjacent_rel_links'), 21);
add_action('wpseo_head', array($this, 'author'), 22);
add_action('wpseo_head', array($this, 'publisher'), 23);
add_action('wpseo_head', array($this, 'webmaster_tools_authentication'), 90);
// Remove actions that we will handle through our wpseo_head call, and probably change the output of
remove_action('wp_head', 'rel_canonical');
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'start_post_rel_link');
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
add_filter('wp_title', array($this, 'title'), 15, 3);
add_filter('thematic_doctitle', array($this, 'title'), 15);
add_action('wp', array($this, 'page_redirect'), 99, 1);
add_action('template_redirect', array($this, 'noindex_feed'));
add_filter('loginout', array($this, 'nofollow_link'));
add_filter('register', array($this, 'nofollow_link'));
if (isset($this->options['hide-rsdlink']) && $this->options['hide-rsdlink']) {
remove_action('wp_head', 'rsd_link');
}
if (isset($this->options['hide-wlwmanifest']) && $this->options['hide-wlwmanifest']) {
remove_action('wp_head', 'wlwmanifest_link');
}
if (isset($this->options['hide-shortlink']) && $this->options['hide-shortlink']) {
remove_action('wp_head', 'wp_shortlink_wp_head');
remove_action('template_redirect', 'wp_shortlink_header');
}
if (isset($this->options['hide-feedlinks']) && $this->options['hide-feedlinks']) {
// @todo: add option to display just normal feed and hide comment feed.
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'feed_links_extra', 3);
}
if (isset($this->options['disable-date']) && $this->options['disable-date'] || isset($this->options['disable-author']) && $this->options['disable-author'] || isset($this->options['disable-post_formats']) && $this->options['disable-post_formats']) {
add_action('wp', array($this, 'archive_redirect'));
}
if (isset($this->options['redirectattachment']) && $this->options['redirectattachment']) {
add_action('template_redirect', array($this, 'attachment_redirect'), 1);
}
if (isset($this->options['trailingslash']) && $this->options['trailingslash']) {
add_filter('user_trailingslashit', array($this, 'add_trailingslash'), 10, 2);
}
if (isset($this->options['cleanpermalinks']) && $this->options['cleanpermalinks']) {
add_action('template_redirect', array($this, 'clean_permalink'), 1);
}
if (isset($this->options['cleanreplytocom']) && $this->options['cleanreplytocom']) {
add_filter('comment_reply_link', array($this, 'remove_reply_to_com'));
}
add_filter('the_content_feed', array($this, 'embed_rssfooter'));
add_filter('the_excerpt_rss', array($this, 'embed_rssfooter_excerpt'));
if (isset($this->options['forcerewritetitle']) && $this->options['forcerewritetitle']) {
add_action('get_header', array($this, 'force_rewrite_output_buffer'));
add_action('wp_footer', array($this, 'flush_cache'));
}
if (isset($this->options['title_test']) && $this->options['title_test']) {
add_filter('wpseo_title', array($this, 'title_test_helper'));
}
if (isset($_GET['replytocom'])) {
remove_action('wp_head', 'wp_no_robots');
add_action('template_redirect', array($this, 'replytocom_redirect'), 1);
}
}
示例14: header
<?php
/**
* @package Admin
*/
if (!defined('WPSEO_VERSION')) {
header('HTTP/1.0 403 Forbidden');
die;
}
global $wpseo_admin_pages;
$options = get_wpseo_options();
?>
<div class="wrap">
<?php
if (isset($_GET['updated']) && $_GET['updated'] == 'true' || isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true') {
$msg = __('Settings updated', 'wordpress-seo');
echo '<div id="message" style="width:94%;" class="message updated"><p><strong>' . $msg . '.</strong></p></div>';
}
?>
<a href="http://yoast.com/">
<div id="top yoast-icon" style="background: url('<?php
echo WPSEO_URL;
?>
images/wordpress-SEO-32x32.png') no-repeat;"
class="icon32"><br/></div>
</a>
<h2 id="wpseo-title"><?php
_e("Yoast WordPress SEO: Titles & Metas", 'wordpress-seo');
?>
</h2>
示例15: 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)
{
$options = get_wpseo_options();
if (isset($options['taxonomies-' . $taxonomy->name . '-not_in_sitemap']) && $options['taxonomies-' . $taxonomy->name . '-not_in_sitemap'] || 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 = 25;
$n = (int) get_query_var('sitemap_n');
$offset = $n > 1 ? ($n - 1) * $this->max_entries : 0;
$total = $offset + $this->max_entries;
$terms = get_terms($taxonomy->name, array('hide_empty' => true));
$terms = array_splice($terms, $offset, $steps);
foreach ($terms as $c) {
$url = array();
if (wpseo_get_term_meta($c, $c->taxonomy, 'noindex') && !in_array(wpseo_get_term_meta($c, $c->taxonomy, 'sitemap_include'), array('always', '-'))) {
continue;
}
if (wpseo_get_term_meta($c, $c->taxonomy, 'sitemap_include') == 'never') {
continue;
}
$url['loc'] = wpseo_get_term_meta($c, $c->taxonomy, 'canonical');
if (!$url['loc']) {
$url['loc'] = get_term_link($c, $c->taxonomy);
if (isset($options['trailingslash']) && $options['trailingslash']) {
$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("SELECT MAX(p.post_modified_gmt) AS lastmod\n\t\t\t\t\tFROM\t{$wpdb->posts} AS p\n\t\t\t\t\tINNER JOIN {$wpdb->term_relationships} AS term_rel\n\t\t\t\t\tON\t\tterm_rel.object_id = p.ID\n\t\t\t\t\tINNER JOIN {$wpdb->term_taxonomy} AS term_tax\n\t\t\t\t\tON\t\tterm_tax.term_taxonomy_id = term_rel.term_taxonomy_id\n\t\t\t\t\tAND\t\tterm_tax.taxonomy = %s\n\t\t\t\t\tAND\t\tterm_tax.term_id = %d\n\t\t\t\t\tWHERE\tp.post_status IN ('publish','inherit')\n\t\t\t\t\tAND\t\tp.post_password = ''", $c->taxonomy, $c->term_id);
$url['mod'] = $wpdb->get_var($sql);
$url['chf'] = 'weekly';
$output .= $this->sitemap_url($url);
}
if (empty($output)) {
$this->bad_sitemap = true;
return;
}
$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";
$this->sitemap .= $output . '</urlset>';
}