Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wp_get_theme_data_custom_templates #5031

Closed
wants to merge 4 commits into from
Closed

Add wp_get_theme_data_custom_templates #5031

wants to merge 4 commits into from

Conversation

oandregal
Copy link
Member

@oandregal oandregal commented Aug 18, 2023

Part of WordPress/gutenberg#45171
Trac ticket: https://core.trac.wordpress.org/ticket/59137

What

This PR adds a new public function wp_get_theme_data_custom_templates to offer access to metadata stored under customTemplates in theme.json.

Why

There is a no public function to get access to that data, so consumers need to resort to private APIs. This follows the steps of wp_get_global_settings, wp_theme_has_theme_json, wp_get_theme_directory_pattern_slugs, and wp_get_theme_data_template_parts.

How

It creates a new function that uses the private calls and substitutes all the instances of the old one in the codebase.

How to test

TBD.

Commit 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

Copy link
Member

@johnbillion johnbillion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is missing a return statement and its @return tag is incorrect. Can you check and correct those please?

@oandregal
Copy link
Member Author

This function is missing a return statement and its @return tag is incorrect. Can you check and correct those please?

Thanks, @johnbillion for catching the issue. Both things addressed.

@audrasjb
Copy link
Contributor

Ah correct.
The change looks good to me, but we usually add a line break on long docblock sentences to avoid having too much characters on the same line

@oandregal
Copy link
Member Author

The change looks good to me, but we usually add a line break on long docblock sentences to avoid having too much characters on the same line

Added the line break as well.

@oandregal
Copy link
Member Author

Looking for how we do @return in other functions, I've noticed this #5033

@oandregal
Copy link
Member Author

@johnbillion when you have the time, can you clear up the blocker so I can commit this?

@oandregal
Copy link
Member Author

@oandregal oandregal closed this Aug 18, 2023
@oandregal oandregal deleted the add/public-method-for-custom-templates branch August 18, 2023 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants