Returns the source from where the template originally comes from.
Parameters
$template_object
WP_Block_Templaterequired- Template instance.
Source
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 ( $template_object->has_theme_file && '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';
}
Changelog
Version | Description |
---|---|
6.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.