diff --git a/packages/block-library/src/archives/edit.js b/packages/block-library/src/archives/edit.js index b59f4dd04d930f..a529b00151c301 100644 --- a/packages/block-library/src/archives/edit.js +++ b/packages/block-library/src/archives/edit.js @@ -1,26 +1,20 @@ /** * WordPress dependencies */ -import { Fragment } from '@wordpress/element'; import { + Disabled, PanelBody, ToggleControl, - Disabled, } from '@wordpress/components'; -import { __ } from '@wordpress/i18n'; - -/** - * Internal dependencies - */ import { InspectorControls, - BlockAlignmentToolbar, - BlockControls, ServerSideRender, } from '@wordpress/editor'; +import { Fragment } from '@wordpress/element'; +import { __ } from '@wordpress/i18n'; export default function ArchivesEdit( { attributes, setAttributes } ) { - const { align, showPostCounts, displayAsDropdown } = attributes; + const { displayAsDropdown, showPostCounts } = attributes; return ( @@ -38,15 +32,6 @@ export default function ArchivesEdit( { attributes, setAttributes } ) { /> - - { - setAttributes( { align: nextAlign } ); - } } - controls={ [ 'left', 'center', 'right' ] } - /> - diff --git a/packages/block-library/src/archives/index.js b/packages/block-library/src/archives/index.js index 8dfca64a8823cd..8b34f786c4c484 100644 --- a/packages/block-library/src/archives/index.js +++ b/packages/block-library/src/archives/index.js @@ -21,16 +21,10 @@ export const settings = { category: 'widgets', supports: { + align: true, html: false, }, - getEditWrapperProps( attributes ) { - const { align } = attributes; - if ( [ 'left', 'center', 'right' ].includes( align ) ) { - return { 'data-align': align }; - } - }, - edit, save() { diff --git a/packages/block-library/src/archives/index.php b/packages/block-library/src/archives/index.php index 3d7b5b42f4ae43..7e557fec126c7f 100644 --- a/packages/block-library/src/archives/index.php +++ b/packages/block-library/src/archives/index.php @@ -126,6 +126,7 @@ function register_block_core_archives() { 'attributes' => array( 'align' => array( 'type' => 'string', + 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ), ), 'className' => array( 'type' => 'string', diff --git a/packages/block-library/src/latest-posts/index.js b/packages/block-library/src/latest-posts/index.js index e1dd91ea70af86..5d5d860aced529 100644 --- a/packages/block-library/src/latest-posts/index.js +++ b/packages/block-library/src/latest-posts/index.js @@ -23,16 +23,10 @@ export const settings = { keywords: [ __( 'recent posts' ) ], supports: { + align: true, html: false, }, - getEditWrapperProps( attributes ) { - const { align } = attributes; - if ( [ 'left', 'center', 'right', 'wide', 'full' ].includes( align ) ) { - return { 'data-align': align }; - } - }, - edit, save() { diff --git a/packages/block-library/src/latest-posts/index.php b/packages/block-library/src/latest-posts/index.php index 18a43e51828e56..f96f707e535759 100644 --- a/packages/block-library/src/latest-posts/index.php +++ b/packages/block-library/src/latest-posts/index.php @@ -54,7 +54,7 @@ function render_block_core_latest_posts( $attributes ) { $class = 'wp-block-latest-posts'; if ( isset( $attributes['align'] ) ) { - $class .= ' align' . $attributes['align']; + $class .= " align{$attributes['align']}"; } if ( isset( $attributes['postLayout'] ) && 'grid' === $attributes['postLayout'] ) { @@ -62,7 +62,7 @@ function render_block_core_latest_posts( $attributes ) { } if ( isset( $attributes['columns'] ) && 'grid' === $attributes['postLayout'] ) { - $class .= ' columns-' . $attributes['columns']; + $class .= " columns-{$attributes['columns']}"; } if ( isset( $attributes['displayPostDate'] ) && $attributes['displayPostDate'] ) { @@ -70,7 +70,7 @@ function render_block_core_latest_posts( $attributes ) { } if ( isset( $attributes['className'] ) ) { - $class .= ' ' . $attributes['className']; + $class .= " {$attributes['className']}"; } $block_content = sprintf( @@ -90,31 +90,24 @@ function register_block_core_latest_posts() { 'core/latest-posts', array( 'attributes' => array( + 'align' => array( + 'type' => 'string', + 'enum' => array( 'left', 'center', 'right', 'wide', 'full' ), + ), 'categories' => array( 'type' => 'string', ), 'className' => array( 'type' => 'string', ), - 'postsToShow' => array( + 'columns' => array( 'type' => 'number', - 'default' => 5, + 'default' => 3, ), 'displayPostDate' => array( 'type' => 'boolean', 'default' => false, ), - 'postLayout' => array( - 'type' => 'string', - 'default' => 'list', - ), - 'columns' => array( - 'type' => 'number', - 'default' => 3, - ), - 'align' => array( - 'type' => 'string', - ), 'order' => array( 'type' => 'string', 'default' => 'desc', @@ -123,6 +116,14 @@ function register_block_core_latest_posts() { 'type' => 'string', 'default' => 'date', ), + 'postLayout' => array( + 'type' => 'string', + 'default' => 'list', + ), + 'postsToShow' => array( + 'type' => 'number', + 'default' => 5, + ), ), 'render_callback' => 'render_block_core_latest_posts', ) diff --git a/test/integration/full-content/server-registered.json b/test/integration/full-content/server-registered.json index 65eb48d6d53f28..b6587d70f18620 100644 --- a/test/integration/full-content/server-registered.json +++ b/test/integration/full-content/server-registered.json @@ -1 +1 @@ -{"core\/block":{"attributes":{"ref":{"type":"number"}}},"core\/latest-comments":{"attributes":{"className":{"type":"string"},"commentsToShow":{"type":"number","default":5,"minimum":1,"maximum":100},"displayAvatar":{"type":"boolean","default":true},"displayDate":{"type":"boolean","default":true},"displayExcerpt":{"type":"boolean","default":true},"align":{"type":"string","enum":["center","left","right","wide","full",""]}}},"core\/archives":{"attributes":{"align":{"type":"string"},"className":{"type":"string"},"displayAsDropdown":{"type":"boolean","default":false},"showPostCounts":{"type":"boolean","default":false}}},"core\/latest-posts":{"attributes":{"categories":{"type":"string"},"className":{"type":"string"},"postsToShow":{"type":"number","default":5},"displayPostDate":{"type":"boolean","default":false},"postLayout":{"type":"string","default":"list"},"columns":{"type":"number","default":3},"align":{"type":"string"},"order":{"type":"string","default":"desc"},"orderBy":{"type":"string","default":"date"}}}} \ No newline at end of file +{"core\/block":{"attributes":{"ref":{"type":"number"}}},"core\/archives":{"attributes":{"align":{"type":"string","enum":["left","center","right","wide","full"]},"className":{"type":"string"},"displayAsDropdown":{"type":"boolean","default":false},"showPostCounts":{"type":"boolean","default":false}}},"core\/latest-comments":{"attributes":{"className":{"type":"string"},"commentsToShow":{"type":"number","default":5,"minimum":1,"maximum":100},"displayAvatar":{"type":"boolean","default":true},"displayDate":{"type":"boolean","default":true},"displayExcerpt":{"type":"boolean","default":true},"align":{"type":"string","enum":["center","left","right","wide","full",""]}}},"core\/latest-posts":{"attributes":{"align":{"type":"string","enum":["left","center","right","wide","full"]},"categories":{"type":"string"},"className":{"type":"string"},"columns":{"type":"number","default":3},"displayPostDate":{"type":"boolean","default":false},"order":{"type":"string","default":"desc"},"orderBy":{"type":"string","default":"date"},"postLayout":{"type":"string","default":"list"},"postsToShow":{"type":"number","default":5}}}} \ No newline at end of file