Skip to content

Commit

Permalink
Add: Author text and original source to wp_template_part. (#56567)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta authored Nov 27, 2023
1 parent 7381549 commit 1b30918
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/compat/wordpress-6.5/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ function gutenberg_register_global_styles_revisions_endpoints() {
add_action( 'rest_api_init', 'gutenberg_register_global_styles_revisions_endpoints' );

/**
* Registers additional fields for wp_template rest api.
* Registers additional fields for wp_template and wp_template_part rest api.
*
* @access private
* @internal
*
* @param array $template_object Template object.
* @return string Original source of the template one of theme, plugin, site, or user.
* @return string Original source of the template one of theme, plugin, site, or user.
*/
function _gutenberg_get_wp_templates_original_source_field( $template_object ) {
if ( 'wp_template' === $template_object['type'] || 'wp_template_part' === $template_object['type'] ) {
Expand Down Expand Up @@ -70,13 +70,13 @@ function _gutenberg_get_wp_templates_original_source_field( $template_object ) {
}

/**
* Registers additional fields for wp_template rest api.
* Registers additional fields for wp_template and wp_template_part rest api.
*
* @access private
* @internal
*
* @param array $template_object Template object.
* @return string Human readable text for the author.
* @return string Human readable text for the author.
*/
function _gutenberg_get_wp_templates_author_text_field( $template_object ) {
$original_source = _gutenberg_get_wp_templates_original_source_field( $template_object );
Expand All @@ -96,14 +96,14 @@ function _gutenberg_get_wp_templates_author_text_field( $template_object ) {
}

/**
* Registers additional fields for wp_template rest api.
* Registers additional fields for wp_template and wp_template_part rest api.
*
* @access private
* @internal
*/
function _gutenberg_register_wp_templates_additional_fields() {
register_rest_field(
'wp_template',
array( 'wp_template', 'wp_template_part' ),
'author_text',
array(
'get_callback' => '_gutenberg_get_wp_templates_author_text_field',
Expand All @@ -118,7 +118,7 @@ function _gutenberg_register_wp_templates_additional_fields() {
);

register_rest_field(
'wp_template',
array( 'wp_template', 'wp_template_part' ),
'original_source',
array(
'get_callback' => '_gutenberg_get_wp_templates_original_source_field',
Expand Down

0 comments on commit 1b30918

Please sign in to comment.