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

Quote v2: bootstrap flag in experiments page #39703

Merged
merged 1 commit into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 7 additions & 3 deletions lib/compat/experimental/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,16 @@ function ( $response ) {
add_action( 'rest_api_init', 'gutenberg_rest_comment_set_children_as_embeddable' );

/**
* Sets a global JS variable used to trigger the availability of the experimental list block.
* Sets a global JS variable used to trigger the availability of the experimental blocks.
*/
function gutenberg_enable_experimental_list_block() {
function gutenberg_enable_experimental_blocks() {
if ( get_option( 'gutenberg-experiments' ) && array_key_exists( 'gutenberg-list-v2', get_option( 'gutenberg-experiments' ) ) ) {
wp_add_inline_script( 'wp-block-library', 'window.__experimentalEnableListBlockV2 = true', 'before' );
}

if ( get_option( 'gutenberg-experiments' ) && array_key_exists( 'gutenberg-quote-v2', get_option( 'gutenberg-experiments' ) ) ) {
wp_add_inline_script( 'wp-block-library', 'window.__experimentalEnableQuoteBlockV2 = true', 'before' );
}
}

add_action( 'admin_init', 'gutenberg_enable_experimental_list_block' );
add_action( 'admin_init', 'gutenberg_enable_experimental_blocks' );
11 changes: 11 additions & 0 deletions lib/experiments-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ function gutenberg_initialize_experiments_settings() {
'id' => 'gutenberg-list-v2',
)
);
add_settings_field(
'gutenberg-quote-v2',
__( 'Quote block v2', 'gutenberg' ),
'gutenberg_display_experiment_field',
'gutenberg-experiments',
'gutenberg_experiments_section',
array(
'label' => __( 'Test a new quote block that allows nested blocks (Warning: The new block is not ready. You may experience content loss, avoid using it on production sites)', 'gutenberg' ),
'id' => 'gutenberg-quote-v2',
)
);
register_setting(
'gutenberg-experiments',
'gutenberg-experiments'
Expand Down
7 changes: 6 additions & 1 deletion packages/block-library/src/quote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import edit from './edit';
import metadata from './block.json';
import save from './save';
import transforms from './transforms';
import settingsV2 from './v2';

const { name } = metadata;

export { metadata, name };

export const settings = {
export const settingsV1 = {
icon,
example: {
attributes: {
Expand Down Expand Up @@ -51,3 +52,7 @@ export const settings = {
},
deprecated,
};

export const settings = window?.__experimentalEnableQuoteBlockV2
? settingsV2
: settingsV1;
5 changes: 5 additions & 0 deletions packages/block-library/src/quote/v2/edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function Edit() {
return <div>Quote block v2</div>;
}

export default Edit;
18 changes: 18 additions & 0 deletions packages/block-library/src/quote/v2/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* WordPress dependencies
*/
import { quote as icon } from '@wordpress/icons';

/**
* Internal dependencies
*/
import edit from './edit';
import save from './save';

const settings = {
icon,
edit,
save,
};

export default settings;
5 changes: 5 additions & 0 deletions packages/block-library/src/quote/v2/save.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function Save() {
return <div>Quote block v2</div>;
}

export default Save;