WPSEO_Post_Type_Sitemap_Provider::get_url
Produce array of URL parts for given post object.
Метод класса: WPSEO_Post_Type_Sitemap_Provider{}
Хуки из метода
Возвращает
Массив|true|false.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_url( $post );
- $post(объект) (обязательный)
- Post object to get URL parts for.
Код WPSEO_Post_Type_Sitemap_Provider::get_url() WPSEO Post Type Sitemap Provider::get url Yoast 27.8
protected function get_url( $post ) {
$url = [];
/**
* Filter the URL Yoast SEO uses in the XML sitemap.
*
* Note that only absolute local URLs are allowed as the check after this removes external URLs.
*
* @param string $url URL to use in the XML sitemap
* @param object $post Post object for the URL.
*/
$url['loc'] = apply_filters( 'wpseo_xml_sitemap_post_url', get_permalink( $post ), $post );
$link_type = YoastSEO()->helpers->url->get_link_type(
wp_parse_url( $url['loc'] ),
$this->get_parsed_home_url(),
);
/*
* Do not include external URLs.
*
* {@link https://wordpress.org/plugins/page-links-to/} can rewrite permalinks to external URLs.
*/
if ( $link_type === SEO_Links::TYPE_EXTERNAL ) {
return false;
}
$modified = max( $post->post_modified_gmt, $post->post_date_gmt );
if ( $modified !== '0000-00-00 00:00:00' ) {
$url['mod'] = $modified;
}
$url['chf'] = 'daily'; // Deprecated, kept for backwards data compat. R.
$canonical = WPSEO_Meta::get_value( 'canonical', $post->ID );
if ( $canonical !== '' && $canonical !== $url['loc'] ) {
/*
* Let's assume that if a canonical is set for this page and it's different from
* the URL of this post, that page is either already in the XML sitemap OR is on
* an external site, either way, we shouldn't include it here.
*/
return false;
}
unset( $canonical );
$url['pri'] = 1; // Deprecated, kept for backwards data compat. R.
if ( $this->include_images ) {
$url['images'] = $this->get_image_parser()->get_images( $post );
}
return $url;
}