Yoast\WP\SEO\Helpers
Crawl_Cleanup_Helper::singular_url
Returns the proper URL for singular pages.
Метод класса: Crawl_Cleanup_Helper{}
Хуков нет.
Возвращает
Строку. The proper URL.
Использование
$Crawl_Cleanup_Helper = new Crawl_Cleanup_Helper(); $Crawl_Cleanup_Helper->singular_url();
Код Crawl_Cleanup_Helper::singular_url() Crawl Cleanup Helper::singular url Yoast 27.3
public function singular_url() {
global $post;
$proper_url = \get_permalink( $post->ID );
$page = \get_query_var( 'page' );
if ( $page && $page !== 1 ) {
$the_post = \get_post( $post->ID );
$page_count = \substr_count( $the_post->post_content, '<!--nextpage-->' );
$proper_url = \user_trailingslashit( \trailingslashit( $proper_url ) . $page );
if ( $page > ( $page_count + 1 ) ) {
$proper_url = \user_trailingslashit( \trailingslashit( $proper_url ) . ( $page_count + 1 ) );
}
}
// Fix reply to comment links, whoever decided this should be a GET variable?
// phpcs:ignore WordPress.Security -- We know this is scary.
if ( isset( $_SERVER['REQUEST_URI'] ) && \preg_match( '`(\?replytocom=[^&]+)`', \sanitize_text_field( $_SERVER['REQUEST_URI'] ), $matches ) ) {
$proper_url .= \str_replace( '?replytocom=', '#comment-', $matches[0] );
}
unset( $matches );
return $proper_url;
}