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

Decouple Post Blocks Experiment from Site Editor Experiment #27822

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/editor-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function gutenberg_get_common_block_editor_settings() {

$settings = array(
'__unstableEnableFullSiteEditingBlocks' => gutenberg_is_fse_theme(),
'__unstableEnablePostBlocks' => gutenberg_is_experiment_enabled( 'gutenberg-post-blocks' ),
'disableCustomColors' => get_theme_support( 'disable-custom-colors' ),
'disableCustomFontSizes' => get_theme_support( 'disable-custom-font-sizes' ),
'disableCustomGradients' => get_theme_support( 'disable-custom-gradients' ),
Expand Down Expand Up @@ -77,6 +78,7 @@ function gutenberg_get_common_block_editor_settings() {
*/
function gutenberg_extend_post_editor_settings( $settings ) {
$settings['__unstableEnableFullSiteEditingBlocks'] = gutenberg_is_fse_theme();
$settings['__unstableEnablePostBlocks'] = gutenberg_is_experiment_enabled( 'gutenberg-post-blocks' );
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add || gutenberg_is_fse_theme(). It doesn't make sense for me to have an FSE theme without these blocks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do add them if gutenberg_is_fse_theme... The only difference in the current status of this PR is template part, which is enabled only in FSE.

return $settings;
}
add_filter( 'block_editor_settings', 'gutenberg_extend_post_editor_settings' );
11 changes: 11 additions & 0 deletions lib/experiments-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ function gutenberg_initialize_experiments_settings() {
'gutenberg_display_experiment_section',
'gutenberg-experiments'
);
add_settings_field(
'gutenberg-post-blocks',
__( 'Post Blocks', 'gutenberg' ),
'gutenberg_display_experiment_field',
'gutenberg-experiments',
'gutenberg_experiments_section',
array(
'label' => __( 'Enable Post Blocks in block editor', 'gutenberg' ),
'id' => 'gutenberg-post-blocks',
)
);
add_settings_field(
'gutenberg-navigation',
__( 'Navigation', 'gutenberg' ),
Expand Down
54 changes: 27 additions & 27 deletions packages/block-library/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ export const registerCoreBlocks = (
* Function to register experimental core blocks depending on editor settings.
*
* @param {boolean} enableFSEBlocks Whether to enable the full site editing blocks.
* @param {boolean} enablePostBlocks Whether to enable the post blocks.
* @example
* ```js
* import { __experimentalRegisterExperimentalCoreBlocks } from '@wordpress/block-library';
Expand All @@ -200,38 +201,37 @@ export const registerCoreBlocks = (
*/
export const __experimentalRegisterExperimentalCoreBlocks =
process.env.GUTENBERG_PHASE === 2
? ( enableFSEBlocks ) => {
? ( enableFSEBlocks, enablePostBlocks ) => {
const postBlocks = [
siteLogo,
siteTagline,
siteTitle,
query,
queryLoop,
queryPagination,
postTitle,
postContent,
postAuthor,
postComment,
postCommentAuthor,
postCommentContent,
postCommentDate,
postComments,
postCommentsCount,
postCommentsForm,
postDate,
postExcerpt,
postFeaturedImage,
postHierarchicalTerms,
postTags,
];
[
navigation,
navigationLink,

// Register Full Site Editing Blocks.
...( enableFSEBlocks
? [
siteLogo,
siteTagline,
siteTitle,
templatePart,
query,
queryLoop,
queryPagination,
postTitle,
postContent,
postAuthor,
postComment,
postCommentAuthor,
postCommentContent,
postCommentDate,
postComments,
postCommentsCount,
postCommentsForm,
postDate,
postExcerpt,
postFeaturedImage,
postHierarchicalTerms,
postTags,
]
: [] ),
? [ templatePart, ...postBlocks ]
: ( enablePostBlocks && postBlocks ) || [] ),
].forEach( registerBlock );
}
: undefined;
7 changes: 6 additions & 1 deletion packages/edit-post/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,13 @@ export function initializeEditor(
);
registerCoreBlocks();
if ( process.env.GUTENBERG_PHASE === 2 ) {
const {
__unstableEnableFullSiteEditingBlocks,
__unstableEnablePostBlocks,
} = settings;
__experimentalRegisterExperimentalCoreBlocks(
settings.__unstableEnableFullSiteEditingBlocks
__unstableEnableFullSiteEditingBlocks,
__unstableEnablePostBlocks
);
}

Expand Down