Yoast\WP\SEO\Builders
Indexable_Link_Builder::get_permalink() protected Yoast 1.0
Returns a cleaned permalink for a given link.
{} Это метод класса: Indexable_Link_Builder{}
Хуков нет.
Возвращает
Строку. The cleaned permalink.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_permalink( $link, $home_url );
- $link(строка) (обязательный)
- The raw URL.
- $home_url(массив) (обязательный)
- The home URL, as parsed by wp_parse_url.
Код Indexable_Link_Builder::get_permalink() Indexable Link Builder::get permalink Yoast 15.6.2
protected function get_permalink( $link, $home_url ) {
// Get rid of the #anchor.
$url_split = \explode( '#', $link );
$link = $url_split[0];
// Get rid of URL ?query=string.
$url_split = \explode( '?', $link );
$link = $url_split[0];
// Set the correct URL scheme.
$link = \set_url_scheme( $link, $home_url['scheme'] );
// Add 'www.' if it is absent and should be there.
if ( \strpos( $home_url['host'], 'www.' ) === 0 && \strpos( $link, '://www.' ) === false ) {
$link = \str_replace( '://', '://www.', $link );
}
// Strip 'www.' if it is present and shouldn't be.
if ( \strpos( $home_url['host'], 'www.' ) !== 0 ) {
$link = \str_replace( '://www.', '://', $link );
}
return $link;
}