mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Editor: add Post Content attributes to block editor settings.
Adds a new block editor setting containing the Post Content block attributes, if they exist. Props audrasjb, spacedmonkey, jeremyfelt, mukesh27, flixos90, andrewserong. Fixes #58534. git-svn-id: https://develop.svn.wordpress.org/trunk@55955 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
<!-- wp:post-title {"level":1,"style":{"spacing":{"margin":{"bottom":"var:preset|spacing|40"}}}} /-->
|
||||
<!-- wp:post-content {"layout":{"type":"constrained"}} /-->
|
||||
@@ -27,12 +27,17 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
global $wp_rest_server;
|
||||
$wp_rest_server = new Spy_REST_Server();
|
||||
do_action( 'rest_api_init', $wp_rest_server );
|
||||
|
||||
global $post_ID;
|
||||
$post_ID = 1;
|
||||
}
|
||||
|
||||
public function tear_down() {
|
||||
/** @var WP_REST_Server $wp_rest_server */
|
||||
global $wp_rest_server;
|
||||
$wp_rest_server = null;
|
||||
global $post_ID;
|
||||
$post_ID = null;
|
||||
parent::tear_down();
|
||||
}
|
||||
|
||||
@@ -396,6 +401,59 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
$this->assertSame( 12345, $settings['maxUploadFileSize'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 58534
|
||||
*/
|
||||
public function test_wp_get_first_block() {
|
||||
$block_name = 'core/paragraph';
|
||||
$blocks = array(
|
||||
array(
|
||||
'blockName' => 'core/image',
|
||||
),
|
||||
array(
|
||||
'blockName' => $block_name,
|
||||
'attrs' => array(
|
||||
'content' => 'Hello World!',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'blockName' => 'core/heading',
|
||||
),
|
||||
array(
|
||||
'blockName' => $block_name,
|
||||
),
|
||||
);
|
||||
$blocks_with_no_paragraph = array(
|
||||
array(
|
||||
'blockName' => 'core/image',
|
||||
),
|
||||
array(
|
||||
'blockName' => 'core/heading',
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertSame( $blocks[1], wp_get_first_block( $blocks, $block_name ) );
|
||||
|
||||
$this->assertSame( array(), wp_get_first_block( $blocks_with_no_paragraph, $block_name ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 58534
|
||||
*/
|
||||
public function test_wp_get_post_content_block_attributes() {
|
||||
$attributes_with_layout = array(
|
||||
'layout' => array(
|
||||
'type' => 'constrained',
|
||||
),
|
||||
);
|
||||
// With no block theme, expect an empty array.
|
||||
$this->assertSame( array(), wp_get_post_content_block_attributes() );
|
||||
|
||||
switch_theme( 'block-theme' );
|
||||
|
||||
$this->assertSame( $attributes_with_layout, wp_get_post_content_block_attributes() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 53458
|
||||
*/
|
||||
@@ -456,6 +514,15 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
|
||||
$this->assertSameSets( array( 'rem' ), $settings['enableCustomUnits'] );
|
||||
// settings.spacing.customPadding
|
||||
$this->assertTrue( $settings['enableCustomSpacing'] );
|
||||
// settings.postContentAttributes
|
||||
$this->assertSameSets(
|
||||
array(
|
||||
'layout' => array(
|
||||
'type' => 'constrained',
|
||||
),
|
||||
),
|
||||
$settings['postContentAttributes']
|
||||
);
|
||||
|
||||
switch_theme( WP_DEFAULT_THEME );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user