WP_REST_Templates_Controller::get_wp_templates_author_text_field( WP_Block_Template $template_object ): string

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Returns a human readable text for the author of the template.

Parameters

$template_objectWP_Block_Templaterequired
Template instance.

Return

string Human readable text for the author.

Source

private static function get_wp_templates_author_text_field( $template_object ) {
	$original_source = self::get_wp_templates_original_source_field( $template_object );
	switch ( $original_source ) {
		case 'theme':
			$theme_name = wp_get_theme( $template_object->theme )->get( 'Name' );
			return empty( $theme_name ) ? $template_object->theme : $theme_name;
		case 'plugin':
			$plugins = get_plugins();
			$plugin  = $plugins[ plugin_basename( sanitize_text_field( $template_object->theme . '.php' ) ) ];
			return empty( $plugin['Name'] ) ? $template_object->theme : $plugin['Name'];
		case 'site':
			return get_bloginfo( 'name' );
		case 'user':
			$author = get_user_by( 'id', $template_object->author );
			if ( ! $author ) {
				return __( 'Unknown author' );
			}
			return $author->get( 'display_name' );
	}
}

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

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