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

Rename button block attributes from url and text to href and content #62612

Closed
Closed
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
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Prompt visitors to take action with a button-style link. ([Source](https://githu
- **Category:** design
- **Parent:** core/buttons
- **Supports:** anchor, color (background, gradients, text), interactivity (clientNavigation), shadow (), spacing (padding), splitting, typography (fontSize, lineHeight), ~~alignWide~~, ~~align~~, ~~reusable~~
- **Attributes:** backgroundColor, gradient, linkTarget, placeholder, rel, tagName, text, textAlign, textColor, title, type, url, width
- **Attributes:** backgroundColor, content, gradient, href, linkTarget, placeholder, rel, tagName, textAlign, textColor, title, type, width

## Buttons

Expand Down
2 changes: 1 addition & 1 deletion lib/compat/wordpress-6.5/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function gutenberg_process_block_bindings( $block_content, $parsed_block, $block
'core/paragraph' => array( 'content' ),
'core/heading' => array( 'content' ),
'core/image' => array( 'id', 'url', 'title', 'alt' ),
'core/button' => array( 'url', 'text', 'linkTarget', 'rel' ),
'core/button' => array( 'href', 'content', 'linkTarget', 'rel' ),
);

// If the block doesn't have the bindings property or isn't one of the supported block types, return.
Expand Down
2 changes: 1 addition & 1 deletion lib/compat/wordpress-6.6/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function gutenberg_replace_pattern_override_default_binding( $parsed_block ) {
'core/paragraph' => array( 'content' ),
'core/heading' => array( 'content' ),
'core/image' => array( 'id', 'url', 'title', 'alt' ),
'core/button' => array( 'url', 'text', 'linkTarget', 'rel' ),
'core/button' => array( 'href', 'content', 'linkTarget', 'rel' ),
);

$bindings = $parsed_block['attrs']['metadata']['bindings'] ?? array();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const BLOCK_BINDINGS_ALLOWED_BLOCKS = {
'core/paragraph': [ 'content' ],
'core/heading': [ 'content' ],
'core/image': [ 'id', 'url', 'title', 'alt' ],
'core/button': [ 'url', 'text', 'linkTarget', 'rel' ],
'core/button': [ 'href', 'content', 'linkTarget', 'rel' ],
};

const DEFAULT_ATTRIBUTE = '__default';
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/button/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"textAlign": {
"type": "string"
},
"url": {
"href": {
"type": "string",
"source": "attribute",
"selector": "a",
Expand All @@ -35,7 +35,7 @@
"attribute": "title",
"__experimentalRole": "content"
},
"text": {
"content": {
"type": "rich-text",
"source": "rich-text",
"selector": "a,button",
Expand Down
Loading
Loading