Make WordPress Core


Ignore:
Timestamp:
08/18/2023 01:20:56 PM (22 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.