Yoast\WP\SEO\Editors\Framework\Site

Post_Site_Information::base_url_for_js()privateYoast 1.0

Returns a base URL for use in the JS, takes permalink structure into account.

Метод класса: Post_Site_Information{}

Хуков нет.

Возвращает

Строку.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->base_url_for_js(): string;

Код Post_Site_Information::base_url_for_js() Yoast 25.1

private function base_url_for_js(): string {
	global $pagenow;

	// The default base is the home_url.
	$base_url = \home_url( '/', null );

	if ( $pagenow === 'post-new.php' ) {
		return $base_url;
	}

	// If %postname% is the last tag, just strip it and use that as a base.
	if ( \preg_match( '#%postname%/?$#', $this->permalink ) === 1 ) {
		$base_url = \preg_replace( '#%postname%/?$#', '', $this->permalink );
	}

	// If %pagename% is the last tag, just strip it and use that as a base.
	if ( \preg_match( '#%pagename%/?$#', $this->permalink ) === 1 ) {
		$base_url = \preg_replace( '#%pagename%/?$#', '', $this->permalink );
	}

	return $base_url;
}