-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Compat: Social Links: Remove legacy renderers from packages #20098
Conversation
'type' => 'string', | ||
), | ||
), | ||
'render_callback' => 'gutenberg_render_core_social_link', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will need rebasing after #20085.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code-wise this is exactly what I expected to see 👍 A nice improvement that we can fully test next week after it is integrated with WordPress core.
lib/blocks.php
Outdated
* @see https://github.com/WordPress/gutenberg/pull/19887 | ||
*/ | ||
function gutenberg_register_legacy_social_link_blocks() { | ||
$sites = array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It probably could be:
$sites = array( | |
$services = array( |
but I see why it is called $sites
. It's your call what to land.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works — done.
@@ -85,6 +63,87 @@ function gutenberg_reregister_core_block_types() { | |||
} | |||
add_action( 'init', 'gutenberg_reregister_core_block_types' ); | |||
|
|||
/** | |||
* Complements the implementation of block type `core/social-icon`, whether it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like where you are going with this, but I think we decided to leave the old name:
* Complements the implementation of block type `core/social-icon`, whether it | |
* Complements the implementation of block type `core/social-link`, whether it |
😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm it works as expected. When I remove this code, I can't see Social Icons on the frontend with the legacy version saved in the post content. With this patch, everything works as before.
Hah, thanks for wrapping this one up for me! |
Description
As of #19887, Social Link is implemented as a single block type with multiple variations, whereas previously each supported service (e.g. WordPress, Twitter) was implemented as its own cloned block type:
Old format:
<!-- wp:social-link-wordpress {"url":"foo"} /-->
New format:
<!-- wp:social-link {"service":"wordpress","url":"foo"} /-->
However, Social Link is defined as a dynamic block. Thus, for backwards compatibility, #19887 preserved the server-side registration of all the "cloned" block types. However, this requirement only applies to the Gutenberg plugin, since Social Links haven't landed in core yet. Thus, this PR moves the server-side registration of cloned block types out of packages — specifically,
block-library
and intolib/blocks.php
.This will ensure that, the next time packages are published and pulled into WordPress core, no added work is needed to make sure that core installations do not register unneeded legacy block types.
How has this been tested?
core/social-link
but nocore/social-link-xyz
clones.Screenshots
Types of changes
Checklist: