本文整理汇总了PHP中WPSEO_Utils::home_url方法的典型用法代码示例。如果您正苦于以下问题:PHP WPSEO_Utils::home_url方法的具体用法?PHP WPSEO_Utils::home_url怎么用?PHP WPSEO_Utils::home_url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPSEO_Utils
的用法示例。
在下文中一共展示了WPSEO_Utils::home_url方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_home_url
/**
* Get Home URL
*
* This has been moved from the constructor because wp_rewrite is not available on plugins_loaded in multisite.
* It will now be requested on need and not on initialization.
*
* @return string
*/
protected function get_home_url()
{
if (!isset(self::$home_url)) {
self::$home_url = WPSEO_Utils::home_url();
}
return self::$home_url;
}
示例2: get_home_url
/**
* Get Home URL
*
* This has been moved from the constructor because wp_rewrite is not available on plugins_loaded in multisite.
* It will now be requested on need and not on initialization.
*
* @return string
*/
protected function get_home_url()
{
if (!isset($this->home_url)) {
$this->home_url = WPSEO_Utils::home_url();
}
return $this->home_url;
}
示例3: get_home_url
/**
* Retrieves the home URL
*
* @return string
*/
private function get_home_url()
{
/**
* Filter: 'wpseo_json_home_url' - Allows filtering of the home URL for Yoast SEO's JSON+LD output
*
* @api unsigned string
*/
return apply_filters('wpseo_json_home_url', WPSEO_Utils::home_url());
}
示例4: generate_canonical
/**
* This function normally outputs the canonical but is also used in other places to retrieve
* the canonical URL for the current page.
*
* @return void
*/
private function generate_canonical()
{
$canonical = false;
$canonical_override = false;
// Set decent canonicals for homepage, singulars and taxonomy pages.
if (is_singular()) {
$obj = get_queried_object();
$canonical = get_permalink($obj->ID);
$this->canonical_unpaged = $canonical;
$canonical_override = WPSEO_Meta::get_value('canonical');
// Fix paginated pages canonical, but only if the page is truly paginated.
if (get_query_var('page') > 1) {
$num_pages = substr_count($obj->post_content, '<!--nextpage-->') + 1;
if ($num_pages && get_query_var('page') <= $num_pages) {
if (!$GLOBALS['wp_rewrite']->using_permalinks()) {
$canonical = add_query_arg('page', get_query_var('page'), $canonical);
} else {
$canonical = user_trailingslashit(trailingslashit($canonical) . get_query_var('page'));
}
}
}
} else {
if (is_search()) {
$search_query = get_search_query();
// Regex catches case when /search/page/N without search term is itself mistaken for search term. R.
if (!empty($search_query) && !preg_match('|^page/\\d+$|', $search_query)) {
$canonical = get_search_link();
}
} elseif (is_front_page()) {
$canonical = WPSEO_Utils::home_url();
} elseif ($this->is_posts_page()) {
$posts_page_id = get_option('page_for_posts');
$canonical = WPSEO_Meta::get_value('canonical', $posts_page_id);
if (empty($canonical)) {
$canonical = get_permalink($posts_page_id);
}
} elseif (is_tax() || is_tag() || is_category()) {
$term = get_queried_object();
if (!empty($term) && !$this->is_multiple_terms_query()) {
$canonical_override = WPSEO_Taxonomy_Meta::get_term_meta($term, $term->taxonomy, 'canonical');
$term_link = get_term_link($term, $term->taxonomy);
if (!is_wp_error($term_link)) {
$canonical = $term_link;
}
}
} elseif (is_post_type_archive()) {
$post_type = get_query_var('post_type');
if (is_array($post_type)) {
$post_type = reset($post_type);
}
$canonical = get_post_type_archive_link($post_type);
} elseif (is_author()) {
$canonical = get_author_posts_url(get_query_var('author'), get_query_var('author_name'));
} elseif (is_archive()) {
if (is_date()) {
if (is_day()) {
$canonical = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day'));
} elseif (is_month()) {
$canonical = get_month_link(get_query_var('year'), get_query_var('monthnum'));
} elseif (is_year()) {
$canonical = get_year_link(get_query_var('year'));
}
}
}
$this->canonical_unpaged = $canonical;
if ($canonical && get_query_var('paged') > 1) {
global $wp_rewrite;
if (!$wp_rewrite->using_permalinks()) {
if (is_front_page()) {
$canonical = trailingslashit($canonical);
}
$canonical = add_query_arg('paged', get_query_var('paged'), $canonical);
} else {
if (is_front_page()) {
$canonical = WPSEO_Sitemaps_Router::get_base_url('');
}
$canonical = user_trailingslashit(trailingslashit($canonical) . trailingslashit($wp_rewrite->pagination_base) . get_query_var('paged'));
}
}
}
$this->canonical_no_override = $canonical;
if (is_string($canonical) && $canonical !== '') {
// Force canonical links to be absolute, relative is NOT an option.
if (WPSEO_Utils::is_url_relative($canonical) === true) {
$canonical = $this->base_url($canonical);
}
}
if (is_string($canonical_override) && $canonical_override !== '') {
$canonical = $canonical_override;
}
/**
* Filter: 'wpseo_canonical' - Allow filtering of the canonical URL put out by Yoast SEO
*
* @api string $canonical The canonical URL
//.........这里部分代码省略.........
示例5: add_home_crumb
/**
* Add Homepage crumb to the crumbs property
*/
private function add_home_crumb()
{
$this->add_predefined_crumb($this->options['breadcrumbs-home'], WPSEO_Utils::home_url(), true);
}