This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Add wide and full alignment support for legacy template block #5433
Merged
Merged
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
fe21f86
add align wide and full support for legacy template block
gigitux 7a755d8
fix PHP warning
gigitux bb19d24
add a comment on get_markup_with_classes_by_attributes
gigitux 6166306
rename function
gigitux 012741e
add align wide and full support for legacy template block
gigitux 987445e
fix PHP warning
gigitux 187bb61
add a comment on get_markup_with_classes_by_attributes
gigitux b4cf934
rename function
gigitux 2aeca80
Merge branch 'add/5229-add-align-support-legacy-template' of github.c…
gigitux f4689e6
fix regex
gigitux e291dc3
update regex
gigitux 891edf7
update regex
gigitux 6ed25c3
fix code styling
gigitux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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.
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.
Looking at the
BlockTypesController::add_data_attributes
, I notice the ways we target the element there and in this method are different:BlockTypesController::add_data_attributes
, we target only the openning<div>
. This may not work forLegacyTemplate
with themes that use<section>
as the wrapper tag.<div>
) that contain theclass
attribute.IMO, we need to use the same mechanism to target wrapper elements in both places. I'm tagging @mikejolley here for more insights because he originally created
BlockTypesController::add_data_attributes
.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.
Ok, it makes sense!
I agree with you. This regex is not great :D
Let's wait for @mikejolley feedback!
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.
In the case of
add_data_attributes
we know we're dealing with adiv
element because thats how the block markup is saved to the post. If the opening element is unknown, your regex is probably better, but I wonder if you can still target only the opening element rather than the first class found which could be deeper? I am not going to pretend to be regex expert, because I am not :DThere 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 can be a good idea, but I'm pretty sure that the regex will be hard to write and read. I'm not a fan of complex regex, but if you think that it makes sense to work on it, I can do 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.
It might not be desirable to add that class deeper in case it breaks other parts of the layout 👍🏻
Are there any alternatives considered for this additional class inserted by regex? Would it be a disaster to wrap in another div with the class, or does that not work here?
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 works without problem, but I don't know if we can wrap a block in another div. If we can follow this path, I think that it is the best solution.
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 wrapping inside another element can make it harder (and confusing) for themes developers to style the page because the opening element now is not the first element in the
wrapper-start.php
but the alignmentdiv
.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.
With f4689e6, I implemented a series of regexes.
First of all, I pick the first tag HTML, after that:
Let me know what do you think :D