Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks

Video::get_current_post_url │ private │ WC 1.0

Get the current post permalink with security validation.

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

Хуков нет.

Возвращает

string. Post permalink or empty string if invalid.

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

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

Код Video::get_current_post_url() WC 11.2.2

private function get_current_post_url(): string {
	global $post;

	if ( ! $post instanceof \WP_Post ) {
		return '';
	}

	$permalink = get_permalink( $post->ID );
	if ( empty( $permalink ) ) {
		return '';
	}

	// Validate URL type and format (following audio block pattern).
	if ( strpos( $permalink, 'https://' ) !== 0 && strpos( $permalink, 'http://' ) !== 0 ) {
		// Reject non-HTTP protocols for security.
		return '';
	}

	// For all HTTP(S) URLs, validate with wp_http_validate_url.
	if ( ! wp_http_validate_url( $permalink ) ) {
		return '';
	}

	return $permalink;
}