WP_Block_Templates_Registry::unregister
Unregisters a template.
Method of the class: WP_Block_Templates_Registry{}
No Hooks.
Returns
WP_Block_Template|WP_Error. The unregistered template on success, or WP_Error on failure.
Usage
$WP_Block_Templates_Registry = new WP_Block_Templates_Registry(); $WP_Block_Templates_Registry->unregister( $template_name );
- $template_name(string) (required)
- Template name including namespace.
Changelog
| Since 6.7.0 | Introduced. |
WP_Block_Templates_Registry::unregister() WP Block Templates Registry::unregister code WP 7.0
public function unregister( $template_name ) {
if ( ! $this->is_registered( $template_name ) ) {
/* translators: %s: Template name. */
$error_message = sprintf( __( 'Template "%s" is not registered.' ), $template_name );
_doing_it_wrong( __METHOD__, $error_message, '6.7.0' );
return new WP_Error( 'template_not_registered', $error_message );
}
$unregistered_template = $this->registered_templates[ $template_name ];
unset( $this->registered_templates[ $template_name ] );
return $unregistered_template;
}