-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 widget: Set container classname dynamically depending on block #26375
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Size Change: 0 B Total Size: 1.38 MB ℹ️ View Unchanged
|
draganescu
approved these changes
Oct 28, 2020
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 tested this PR and it works. @noisysocks I left one optional comment that could save us one line of code, but maybe it's clearer to leave it like you did it for clarity.
3b18131
to
8c5d4a5
Compare
I rebased this. |
8c5d4a5
to
ea1f886
Compare
7 tasks
noisysocks
added a commit
that referenced
this pull request
Feb 22, 2021
…26375) * Block widget: Set container classname dynamically depending on block * add widgets snapshot update Co-authored-by: Vagabond User <vagabond@guest.guest>
noisysocks
added a commit
that referenced
this pull request
Feb 22, 2021
…26375) * Block widget: Set container classname dynamically depending on block * add widgets snapshot update Co-authored-by: Vagabond User <vagabond@guest.guest>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Backwards Compatibility
Issues or PRs that impact backwards compatability
[Feature] Widgets Screen
The block-based screen that replaced widgets.php.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #25822.
Updates
WP_Widget_Block
to dynamically set the classname used in the block widget's container HTML. This way, if a block widget contains a block that has an equivalent legacy widget, we can display that legacy widget's class name.This lessens the likelihood that a theme's CSS styles need to be updated to work correctly with a block widget.
A new
widget_block_dynamic_classname
filter has also been added. This lets third parties do something similar for their blocks and complements the existingwidgets_to_exclude_from_legacy_widget_block
filter.An example
To illustrate, this is how the Archives widget renders in a sidebar today:
And this is how the Archives block renders in a sidebar today:
With this change, the Archives block renders like so:
Note the addition of the
widget_archive
classname.To test
widget_search
appears in the markup surrounding the Search block