diff --git a/packages/block-library/src/archives/edit.js b/packages/block-library/src/archives/edit.js index 83b79b536eb872..0ec7ceb543d117 100644 --- a/packages/block-library/src/archives/edit.js +++ b/packages/block-library/src/archives/edit.js @@ -44,7 +44,6 @@ export default function ArchivesEdit( { attributes, setAttributes } ) { onChange={ ( nextAlign ) => { 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 2774569ab6531b..eec1f316c85653 100644 --- a/packages/block-library/src/archives/index.js +++ b/packages/block-library/src/archives/index.js @@ -25,7 +25,7 @@ export const settings = { getEditWrapperProps( attributes ) { const { align } = attributes; - if ( 'left' === align || 'right' === align || 'center' === align ) { + if ( [ 'left', 'center', 'right', 'wide', 'full' ].includes( align ) ) { return { 'data-align': align }; } }, diff --git a/packages/block-library/src/archives/index.php b/packages/block-library/src/archives/index.php index 9784284361922b..234037a2994ab2 100644 --- a/packages/block-library/src/archives/index.php +++ b/packages/block-library/src/archives/index.php @@ -16,7 +16,16 @@ */ function render_block_core_archives( $attributes ) { $show_post_count = ! empty( $attributes['showPostCounts'] ); - $class = "wp-block-archives align{$attributes['align']}"; + + $class = 'wp-block-archives'; + + if ( isset( $attributes['align'] ) ) { + $class .= " align{$attributes['align']}"; + } + + if ( isset( $attributes['className'] ) ) { + $class .= " {$attributes['className']}"; + } if ( ! empty( $attributes['displayAsDropdown'] ) ) { @@ -99,17 +108,19 @@ function register_block_core_archives() { 'core/archives', array( 'attributes' => array( - 'showPostCounts' => array( - 'type' => 'boolean', - 'default' => false, + 'align' => array( + 'type' => 'string', + ), + 'className' => array( + 'type' => 'string', ), 'displayAsDropdown' => array( 'type' => 'boolean', 'default' => false, ), - 'align' => array( - 'type' => 'string', - 'default' => 'none', + 'showPostCounts' => array( + 'type' => 'boolean', + 'default' => false, ), ), 'render_callback' => 'render_block_core_archives', diff --git a/packages/block-library/src/categories/edit.js b/packages/block-library/src/categories/edit.js index 49097d18b888d8..0bd2b18f3d3e5f 100644 --- a/packages/block-library/src/categories/edit.js +++ b/packages/block-library/src/categories/edit.js @@ -187,7 +187,6 @@ class CategoriesEdit extends Component { onChange={ ( nextAlign ) => { setAttributes( { align: nextAlign } ); } } - controls={ [ 'left', 'center', 'right', 'full' ] } />
diff --git a/packages/block-library/src/categories/index.js b/packages/block-library/src/categories/index.js index 399e5d95d7b2cc..fce7509a6be518 100644 --- a/packages/block-library/src/categories/index.js +++ b/packages/block-library/src/categories/index.js @@ -20,9 +20,8 @@ export const settings = { category: 'widgets', attributes: { - showPostCounts: { - type: 'boolean', - default: false, + align: { + type: 'string', }, displayAsDropdown: { type: 'boolean', @@ -32,8 +31,9 @@ export const settings = { type: 'boolean', default: false, }, - align: { - type: 'string', + showPostCounts: { + type: 'boolean', + default: false, }, }, @@ -43,7 +43,7 @@ export const settings = { getEditWrapperProps( attributes ) { const { align } = attributes; - if ( 'left' === align || 'right' === align || 'full' === align ) { + if ( [ 'left', 'center', 'right', 'wide', 'full' ].includes( align ) ) { return { 'data-align': align }; } }, diff --git a/packages/block-library/src/categories/index.php b/packages/block-library/src/categories/index.php index cf121ced0b769e..05aba5fccf2aca 100644 --- a/packages/block-library/src/categories/index.php +++ b/packages/block-library/src/categories/index.php @@ -16,11 +16,6 @@ function render_block_core_categories( $attributes ) { static $block_id = 0; $block_id++; - $align = 'center'; - if ( isset( $attributes['align'] ) && in_array( $attributes['align'], array( 'left', 'right', 'full' ), true ) ) { - $align = $attributes['align']; - } - $args = array( 'echo' => false, 'hierarchical' => ! empty( $attributes['showHierarchy'] ), @@ -46,10 +41,14 @@ function render_block_core_categories( $attributes ) { $type = 'list'; } - $class = "wp-block-categories wp-block-categories-{$type} align{$align}"; + $class = "wp-block-categories wp-block-categories-{$type}"; + + if ( isset( $attributes['align'] ) ) { + $class .= " align{$attributes['align']}"; + } if ( isset( $attributes['className'] ) ) { - $class .= ' ' . $attributes['className']; + $class .= " {$attributes['className']}"; } $block_content = sprintf( diff --git a/packages/block-library/src/latest-comments/index.php b/packages/block-library/src/latest-comments/index.php index dd310028ce145a..b40fa5e45eb85b 100644 --- a/packages/block-library/src/latest-comments/index.php +++ b/packages/block-library/src/latest-comments/index.php @@ -151,6 +151,9 @@ function gutenberg_render_block_core_latest_comments( $attributes = array() ) { 'core/latest-comments', array( 'attributes' => array( + 'align' => array( + 'type' => 'string', + ), 'className' => array( 'type' => 'string', ), @@ -172,10 +175,6 @@ function gutenberg_render_block_core_latest_comments( $attributes = array() ) { 'type' => 'boolean', 'default' => true, ), - 'align' => array( - 'type' => 'string', - 'enum' => array( 'center', 'left', 'right', 'wide', 'full', '' ), - ), ), 'render_callback' => 'gutenberg_render_block_core_latest_comments', ) diff --git a/packages/block-library/src/latest-posts/edit.js b/packages/block-library/src/latest-posts/edit.js index 580792b3e0d643..8c489af5ed7e20 100644 --- a/packages/block-library/src/latest-posts/edit.js +++ b/packages/block-library/src/latest-posts/edit.js @@ -125,7 +125,6 @@ class LatestPostsEdit extends Component { onChange={ ( nextAlign ) => { setAttributes( { align: nextAlign } ); } } - controls={ [ 'center', 'wide', 'full' ] } /> diff --git a/packages/block-library/src/latest-posts/index.js b/packages/block-library/src/latest-posts/index.js index 6fe9e161040411..10f1f4bb3cb403 100644 --- a/packages/block-library/src/latest-posts/index.js +++ b/packages/block-library/src/latest-posts/index.js @@ -27,7 +27,7 @@ export const settings = { getEditWrapperProps( attributes ) { const { align } = attributes; - if ( 'left' === align || 'right' === align || 'wide' === align || 'full' === align ) { + if ( [ 'left', 'center', 'right', 'wide', 'full' ].includes( align ) ) { return { 'data-align': align }; } }, diff --git a/packages/block-library/src/latest-posts/index.php b/packages/block-library/src/latest-posts/index.php index 070abafeb4c751..128df9685268c1 100644 --- a/packages/block-library/src/latest-posts/index.php +++ b/packages/block-library/src/latest-posts/index.php @@ -83,6 +83,9 @@ function register_block_core_latest_posts() { 'core/latest-posts', array( 'attributes' => array( + 'align' => array( + 'type' => 'string', + ), 'categories' => array( 'type' => 'string', ), @@ -105,9 +108,6 @@ function register_block_core_latest_posts() { 'type' => 'number', 'default' => 3, ), - 'align' => array( - 'type' => 'string', - ), 'order' => array( 'type' => 'string', 'default' => 'desc', diff --git a/test/integration/full-content/fixtures/core__archives.json b/test/integration/full-content/fixtures/core__archives.json index 0caf2ec732a3d1..7162be0dcddd3c 100644 --- a/test/integration/full-content/fixtures/core__archives.json +++ b/test/integration/full-content/fixtures/core__archives.json @@ -5,8 +5,7 @@ "isValid": true, "attributes": { "showPostCounts": false, - "displayAsDropdown": false, - "align": "none" + "displayAsDropdown": false }, "innerBlocks": [], "originalContent": "" diff --git a/test/integration/full-content/fixtures/core__archives__showPostCounts.json b/test/integration/full-content/fixtures/core__archives__showPostCounts.json index 76d086c472d07f..adf3c5324709db 100644 --- a/test/integration/full-content/fixtures/core__archives__showPostCounts.json +++ b/test/integration/full-content/fixtures/core__archives__showPostCounts.json @@ -5,8 +5,7 @@ "isValid": true, "attributes": { "showPostCounts": true, - "displayAsDropdown": false, - "align": "none" + "displayAsDropdown": false }, "innerBlocks": [], "originalContent": "" diff --git a/test/integration/full-content/server-registered.json b/test/integration/full-content/server-registered.json index ae3a5650908577..ce49d6a38a1329 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":{"showPostCounts":{"type":"boolean","default":false},"displayAsDropdown":{"type":"boolean","default":false},"align":{"type":"string","default":"none"}}},"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\/latest-comments":{"attributes":{"align":{"type":"string"},"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}}},"core\/archives":{"attributes":{"align":{"type":"string"},"className":{"type":"string"},"displayAsDropdown":{"type":"boolean","default":false},"showPostCounts":{"type":"boolean","default":false}}},"core\/latest-posts":{"attributes":{"align":{"type":"string"},"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}}}}