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

Block alignment - remove unnecessary class application for dynamic blocks. #24223

Merged
1 change: 1 addition & 0 deletions packages/block-editor/src/hooks/align.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export function addAttribute( settings ) {
...settings.attributes,
align: {
type: 'string',
enum: ALL_ALIGNMENTS,
},
};
}
Expand Down
10 changes: 0 additions & 10 deletions packages/block-library/src/archives/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@
"name": "core/archives",
"category": "widgets",
"attributes": {
"align": {
"type": "string",
"enum": [
"left",
"center",
"right",
"wide",
"full"
]
},
"className": {
"type": "string"
},
Expand Down
21 changes: 21 additions & 0 deletions packages/block-library/src/archives/deprecated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export default [
{
attributes: {
align: {
type: 'string',
enum: [ 'left', 'center', 'right', 'wide', 'full' ],
},
className: {
type: 'string',
},
displayAsDropdown: {
type: 'boolean',
default: false,
},
showPostCounts: {
type: 'boolean',
default: false,
},
},
},
];
2 changes: 2 additions & 0 deletions packages/block-library/src/archives/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { __ } from '@wordpress/i18n';
*/
import metadata from './block.json';
import edit from './edit';
import deprecated from './deprecated';

const { name } = metadata;

Expand All @@ -20,4 +21,5 @@ export const settings = {
icon,
example: {},
edit,
deprecated,
Addison-Stavlo marked this conversation as resolved.
Show resolved Hide resolved
};
4 changes: 0 additions & 4 deletions packages/block-library/src/archives/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ function render_block_core_archives( $attributes ) {

Addison-Stavlo marked this conversation as resolved.
Show resolved Hide resolved
$class = 'wp-block-archives';

if ( isset( $attributes['align'] ) ) {
$class .= " align{$attributes['align']}";
}

if ( isset( $attributes['className'] ) ) {
$class .= " {$attributes['className']}";
}
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/calendar/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ function render_block_core_calendar( $attributes ) {
}

$custom_class_name = empty( $attributes['className'] ) ? '' : ' ' . $attributes['className'];
$align_class_name = empty( $attributes['align'] ) ? '' : ' ' . "align{$attributes['align']}";

$output = sprintf(
'<div class="%1$s">%2$s</div>',
esc_attr( 'wp-block-calendar' . $custom_class_name . $align_class_name ),
esc_attr( 'wp-block-calendar' . $custom_class_name ),
get_calendar( true, false )
);

Expand Down
4 changes: 0 additions & 4 deletions packages/block-library/src/categories/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ function render_block_core_categories( $attributes ) {

$class = "wp-block-categories wp-block-categories-{$type}";

if ( isset( $attributes['align'] ) ) {
$class .= " align{$attributes['align']}";
}

if ( isset( $attributes['className'] ) ) {
$class .= " {$attributes['className']}";
}
Expand Down
3 changes: 0 additions & 3 deletions packages/block-library/src/latest-comments/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ function render_block_core_latest_comments( $attributes = array() ) {
if ( ! empty( $attributes['className'] ) ) {
$class .= ' ' . $attributes['className'];
}
if ( isset( $attributes['align'] ) ) {
$class .= " align{$attributes['align']}";
}
if ( $attributes['displayAvatar'] ) {
$class .= ' has-avatars';
}
Expand Down
3 changes: 0 additions & 3 deletions packages/block-library/src/latest-posts/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ function render_block_core_latest_posts( $attributes ) {
remove_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 );

$class = 'wp-block-latest-posts wp-block-latest-posts__list';
if ( isset( $attributes['align'] ) ) {
$class .= ' align' . $attributes['align'];
}

if ( isset( $attributes['postLayout'] ) && 'grid' === $attributes['postLayout'] ) {
$class .= ' is-grid';
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
array( 'wp-block-navigation' ),
isset( $attributes['className'] ) ? array( $attributes['className'] ) : array(),
( isset( $attributes['orientation'] ) && 'vertical' === $attributes['orientation'] ) ? array( 'is-vertical' ) : array(),
isset( $attributes['itemsJustification'] ) ? array( 'items-justified-' . $attributes['itemsJustification'] ) : array(),
isset( $attributes['align'] ) ? array( 'align' . $attributes['align'] ) : array()
isset( $attributes['itemsJustification'] ) ? array( 'items-justified-' . $attributes['itemsJustification'] ) : array()
);
$class_attribute = sprintf( ' class="%s"', esc_attr( implode( ' ', $classes ) ) );
$style_attribute = ( $colors['inline_styles'] || $font_sizes['inline_styles'] )
Expand Down
4 changes: 0 additions & 4 deletions packages/block-library/src/rss/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ function render_block_core_rss( $attributes ) {
}

$class = 'wp-block-rss';
if ( isset( $attributes['align'] ) ) {
$class .= ' align' . $attributes['align'];
}

if ( isset( $attributes['blockLayout'] ) && 'grid' === $attributes['blockLayout'] ) {
$class .= ' is-grid';
}
Expand Down
3 changes: 0 additions & 3 deletions packages/block-library/src/search/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ function render_block_core_search( $attributes ) {
if ( isset( $attributes['className'] ) ) {
$class .= ' ' . $attributes['className'];
}
if ( isset( $attributes['align'] ) ) {
$class .= ' align' . $attributes['align'];
}

return sprintf(
'<form class="%s" role="search" method="get" action="%s">%s</form>',
Expand Down
4 changes: 1 addition & 3 deletions packages/block-library/src/tag-cloud/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
* @return string Returns the tag cloud for selected taxonomy.
*/
function render_block_core_tag_cloud( $attributes ) {
$class = isset( $attributes['align'] ) ?
"wp-block-tag-cloud align{$attributes['align']}" :
'wp-block-tag-cloud';
$class = 'wp-block-tag-cloud';

if ( isset( $attributes['className'] ) ) {
$class .= ' ' . $attributes['className'];
Expand Down