WP_Block_Templates_Registry::unregister( string $template_name ): WP_Block_Template|WP_Error

In this article

Unregisters a template.

Parameters

$template_namestringrequired
Template name including namespace.

Return

WP_Block_Template|WP_Error The unregistered template on success, or WP_Error on failure.

Source

public function unregister( $template_name ) {
	if ( ! $this->is_registered( $template_name ) ) {
		_doing_it_wrong(
			__METHOD__,
			/* translators: %s: Template name. */
			sprintf( __( 'Template "%s" is not registered.' ), $template_name ),
			'6.7.0'
		);
		/* translators: %s: Template name. */
		return new WP_Error( 'template_not_registered', __( 'Template "%s" is not registered.' ) );
	}

	$unregistered_template = $this->registered_templates[ $template_name ];
	unset( $this->registered_templates[ $template_name ] );

	return $unregistered_template;
}

Changelog

VersionDescription
6.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.