WP_REST_Templates_Controller::get_wp_templates_original_source_field()
Returns the source from where the template originally comes from.
Method of the class: WP_REST_Templates_Controller{}
No Hooks.
Return
String
. Original source of the template one of theme, plugin, site, or user.
Usage
$result = WP_REST_Templates_Controller::get_wp_templates_original_source_field( $template_object );
- $template_object(WP_Block_Template) (required)
- Template instance.
Changelog
Since 6.5.0 | Introduced. |
WP_REST_Templates_Controller::get_wp_templates_original_source_field() WP REST Templates Controller::get wp templates original source field code WP 6.7.1
private static function get_wp_templates_original_source_field( $template_object ) { if ( 'wp_template' === $template_object->type || 'wp_template_part' === $template_object->type ) { /* * Added by theme. * Template originally provided by a theme, but customized by a user. * Templates originally didn't have the 'origin' field so identify * older customized templates by checking for no origin and a 'theme' * or 'custom' source. */ if ( $template_object->has_theme_file && ( 'theme' === $template_object->origin || ( empty( $template_object->origin ) && in_array( $template_object->source, array( 'theme', 'custom', ), true ) ) ) ) { return 'theme'; } // Added by plugin. if ( 'plugin' === $template_object->origin ) { return 'plugin'; } /* * Added by site. * Template was created from scratch, but has no author. Author support * was only added to templates in WordPress 5.9. Fallback to showing the * site logo and title. */ if ( empty( $template_object->has_theme_file ) && 'custom' === $template_object->source && empty( $template_object->author ) ) { return 'site'; } } // Added by user. return 'user'; }