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

API to define a default template for the template mode #32752

Closed
youknowriad opened this issue Jun 16, 2021 · 3 comments · Fixed by #32771
Closed

API to define a default template for the template mode #32752

youknowriad opened this issue Jun 16, 2021 · 3 comments · Fixed by #32771
Assignees
Labels
[Feature] Template Editing Mode Related to the template editor available in the Block Editor [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Status] In Progress Tracking issues with work in progress [Type] New API New API to be used by plugin developers or package users.

Comments

@youknowriad
Copy link
Contributor

WordPress 5.8 will introduce a template mode in the post editor https://make.wordpress.org/core/2021/06/14/introducing-the-template-editor-in-wordpress-5-8/

That mode allows users to create block templates and assign them to posts and pages. A default starting template is used to repopulate newly created templates.

Ideally, themes should be able to define the content of the initial template. Let's try to provide an API to do so. This API should be able to scale to FSE themes as well.

The simplest solution might be to add a settings to the block_editor_settings_all filter as this can be provided in php and made translatable easily.

An alternative would be a file in the theme (convention) but since we don't want to add block-templates to themes yet, it seems premature for this option.

cc @TimothyBJacobs @aristath

@youknowriad youknowriad added [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Feature] Full Site Editing [Type] New API New API to be used by plugin developers or package users. [Feature] Template Editing Mode Related to the template editor available in the Block Editor labels Jun 16, 2021
@aristath
Copy link
Member

aristath commented Jun 17, 2021

Using the block_editor_settings_all filter would make sense...
The 1st thought that came to mind was introduce a block-template-default.html file, but the filter sounds more versatile, and it can still be used with a file using something like

add_filter( 'block_editor_settings_all', function( $settings ) {
    $settings['block_template'] = file_get_contents( get_theme_file_path( 'block-template-default.html' ) );
    return $settings;
});

so using the filter does not exclude using a file... it makes sense to do something like that since it leaves the door open for other future implementations

@youknowriad
Copy link
Contributor Author

yes, that make sense maybe it should be named more something like default_block_template?

@aristath
Copy link
Member

maybe it should be named more something like default_block_template?

Yes, that would make sense. Or even default_block_template_content if we want to be more verbose/accurate 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Template Editing Mode Related to the template editor available in the Block Editor [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Status] In Progress Tracking issues with work in progress [Type] New API New API to be used by plugin developers or package users.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants