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: Template types to the patterns API. #3946

Conversation

jorgefilipecosta
Copy link
Member

Backports WordPress/gutenberg#45814 into the core.

Testing

I pasted the following sample pattern on lib/compat/wordpress-6.2/block-patterns.php.

register_block_pattern(
	'query/template-type-test',
	array(
		'title'      => __( 'Template type test', 'gutenberg' ),
		'templateTypes' => array( '404' ),
		'content'    => '<!-- wp:paragraph {"align":"center","fontSize":"x-large"} -->
						<p class="has-text-align-center has-x-large-font-size">404</p>
						<!-- /wp:paragraph -->',
	)
);

I opened the post editor and the developer tools and pasted wp.apiFetch( { path: '/wp/v2/block-patterns/patterns' } ).then( console.log ); on the browser console.
I verified that the API response for included query/template-type-test include 404 in the templateTypes.

@jorgefilipecosta jorgefilipecosta force-pushed the add/template-types-to-the-patterns-api branch 5 times, most recently from 5c8da31 to ca8fcae Compare January 30, 2023 23:27
@jorgefilipecosta jorgefilipecosta force-pushed the add/template-types-to-the-patterns-api branch from ca8fcae to 615a278 Compare January 30, 2023 23:32
@@ -318,6 +318,7 @@ function _register_theme_block_patterns() {
'blockTypes' => 'Block Types',
'postTypes' => 'Post Types',
'inserter' => 'Inserter',
'templateTypes' => 'Template Types',
Copy link
Member

@mukeshpanchal27 mukeshpanchal27 Jan 31, 2023

Choose a reason for hiding this comment

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

jorgefilipecosta and others added 2 commits January 31, 2023 15:10
…s-controller.php

Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
@jorgefilipecosta
Copy link
Member Author

Thank you for the feedback @mukeshpanchal27 it was applied. Committed at 620760e.

@mukeshpanchal27
Copy link
Member

mukeshpanchal27 commented Jan 31, 2023

Thanks @jorgefilipecosta I can't see my name in props

@jorgefilipecosta
Copy link
Member Author

Thanks @jorgefilipecosta I can't see my name in props

Hi @mukeshpanchal27, sorry for missing your name on the commit message I had an issue while formatting the message, but as referred in slack, your name was manually added to the props of the CPT on the system we use for props and should be accounted for in any stats. Thank you for the feedback!

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.

2 participants