WPSEO_Post_Metabox_Formatter::base_url_for_js()privateYoast 1.0

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

{} Это метод класса: WPSEO_Post_Metabox_Formatter{}

Хуков нет.

Возвращает

Строку.

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

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

Код WPSEO_Post_Metabox_Formatter::base_url_for_js() Yoast 19.6.1

private function base_url_for_js() {
	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;
}