Make WordPress Core

Changeset 56413


Ignore:
Timestamp:
08/18/2023 01:20:56 PM (10 months ago)
Author:
oandregal
Message:

Themes: add wp_get_theme_data_custom_templates function.

Adds a new public function, wp_get_theme_data_custom_templates that returns the customTemplates defined by the active theme from theme.json. It also substitutes the usage of private APIs by this new
API.

Props johnbillion, audrasjb.
Fixes #59137

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/block-template-utils.php

    r56385 r56413  
    412412    }
    413413
    414     $theme_data = WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_custom_templates();
     414    $theme_data = wp_get_theme_data_custom_templates();
    415415    if ( isset( $theme_data[ $template_item['slug'] ] ) ) {
    416416        $template_item['title']     = $theme_data[ $template_item['slug'] ]['title'];
  • trunk/src/wp-includes/global-styles-and-settings.php

    r56412 r56413  
    443443
    444444/**
     445 * Returns the metadata for the custom templates defined by the theme via theme.json.
     446 *
     447 * @since 6.4.0
     448 *
     449 * @return array Associative array of `$template_name => $template_data` pairs,
     450 *               with `$template_data` having "title" and "postTypes" fields.
     451 */
     452function wp_get_theme_data_custom_templates() {
     453    return WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_custom_templates();
     454}
     455
     456/**
    445457 * Returns the metadata for the template parts defined by the theme.
    446458 *
Note: See TracChangeset for help on using the changeset viewer.