Yoast\WP\SEO\Models
Indexable::sanitize_permalink
Sanitizes the permalink.
Метод класса: Indexable{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->sanitize_permalink();
Код Indexable::sanitize_permalink() Indexable::sanitize permalink Yoast 28.2
protected function sanitize_permalink() {
if ( $this->permalink === 'unindexed' ) {
return;
}
$permalink_structure = \get_option( 'permalink_structure' );
$permalink_parts = \wp_parse_url( $this->permalink );
if ( ! isset( $permalink_parts['path'] ) ) {
$permalink_parts['path'] = '/';
}
if ( \substr( $permalink_structure, -1, 1 ) === '/' && \strpos( \substr( $permalink_parts['path'], -5 ), '.' ) === false ) {
$permalink_parts['path'] = \trailingslashit( $permalink_parts['path'] );
}
$permalink = '';
if ( isset( $permalink_parts['scheme'] ) ) {
$permalink .= $permalink_parts['scheme'] . '://';
}
if ( isset( $permalink_parts['host'] ) ) {
$permalink .= $permalink_parts['host'];
}
if ( isset( $permalink_parts['port'] ) ) {
$permalink .= ':' . $permalink_parts['port'];
}
if ( isset( $permalink_parts['path'] ) ) {
$permalink .= $permalink_parts['path'];
}
if ( isset( $permalink_parts['query'] ) ) {
$permalink .= '?' . $permalink_parts['query'];
}
// We never set the fragment as the fragment is intended to be client-only.
$this->permalink = $permalink;
}