-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Backport: Add filter for duotone to account for gutenberg_restore_image_outer_container in classic themes #6607
Conversation
…ge_outer_container in classic themes
Trac Ticket MissingThis pull request is missing a link to a Trac ticket. For a contribution to be considered, there must be a corresponding ticket in Trac. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. More information about contributing to WordPress on GitHub can be found in the Core Handbook. |
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
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.
Hmm, this changeset doesn't match the one from WordPress/gutenberg#59764, which adds a new restore_image_outer_container
function to the duotone class. Is that intentional?
I also see in testing that this is removing the outer wrapper on aligned images, instead of moving the duotone classname to it (which is what happens in the plugin after WordPress/gutenberg#59764)
@tellthemachines I have the correct backport at #6719 |
@tellthemachines you're right I had done this wrongly. I have updated the PR with the correct approach (I hope!) I had incorrectly read the original PR and thought it was removing the |
@@ -57,3 +57,7 @@ | |||
|
|||
// Migrate the old experimental duotone support flag. | |||
add_filter( 'block_type_metadata_settings', array( 'WP_Duotone', 'migrate_experimental_duotone_support_flag' ), 10, 2 ); | |||
|
|||
// Restore duotone classes to the image wrapper div. | |||
add_filter( 'render_block_core/image', array( 'WP_Duotone', 'restore_image_outer_container' ), 11, 2 ); |
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.
add_filter( 'render_block_core/image', array( 'WP_Duotone', 'restore_image_outer_container' ), 11, 2 ); | |
add_filter( 'render_block_core/image', array( 'WP_Duotone', 'restore_image_outer_container' ), 10, 1 ); |
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 think we might have to keep the higher priority because the filter isn't working on your other PR @ajlende, but it's working on this one.
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 forgot that this was weird in the PR. Things have to be loaded in a very specific order. WordPress/gutenberg#59764 (comment)
When this gets backported to core, the same should happen with the core version of the functions. Although, it looks like the imports will have to be reordered during the core backport (WordPress/wordpress-develop@9a616a5/src/wp-settings.php#L371).
In my opinion, with the way WordPress code is written with side effects in many files, the way that we mostly centralize imports, the size of the codebase, and the number of contributors, it makes more sense for use to just preserve the order of imports when backporting things to not have to worry so much about priority levels. It seems better to me to maintain that order than force extenders to use extra high priorities to override core behavior.
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.
@tellthemachines I don't have permissions to push to this branch, but I updated the import order to match Gutenberg in #6719 and that seems to work for me.
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.
Cool we can go with that one then!
* Fixes the issue with our generated class name not being added to the block's outer container | ||
* in classic themes. | ||
* | ||
* @since 6.5.0 |
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.
* @since 6.5.0 | |
* @since 6.6.0 |
return $tags->get_updated_html(); | ||
} | ||
|
||
|
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.
|
||
// Restore duotone classes to the image wrapper div. | ||
add_filter( 'render_block_core/image', array( 'WP_Duotone', 'restore_image_outer_container' ), 11, 2 ); | ||
|
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.
Closing this one in favour of #6719. |
* @since 6.5.0 | ||
* | ||
* @param string $block_content Rendered block content. | ||
* @return string Filtered block content. |
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.
@tellthemachines @return string Filtered block content.
space should be removed.
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.
Backport for WordPress/gutenberg#59764
Trac ticket: https://core.trac.wordpress.org/ticket/61271
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.