-
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 Library: Try to standardize PHP function names used #20085
Conversation
8a778a7
to
3ffd816
Compare
3ffd816
to
d37df94
Compare
@aduth – if you would be able to land all those changes, we might also consider simplifying the logic in webpack that modifies names of the functions to a simple string replace |
Related: #20039 , #18589 (comment) For functions already present as of WordPress 5.3.x, is it even possible to change the names without breaking some backward-compatibility commitment? |
What is the standard we're trying to encourage here? I think the inconsistencies we've seen thus far can be explained at least in part by not having a clear idea / documentation for what we want. My comment at #18589 (comment), while somewhat rambling, was an exploration of this. I see some of the same patterns here. To clarify, is the idea something like always using Case in point:
Technically, if you follow the convention of the render prefix, this could just as well be:
|
Why aren't we using PHP namespaces? |
@ZebulanStanphill My understanding is it's an unsettled question in core standards, since the feature only became available as of the recent-ish minimum PHP version bump to 5.6. It's not something I think we can hope to address as part of the immediate goals here, though it would be worth being mindful of some future interoperability. https://make.wordpress.org/core/2019/03/26/coding-standards-updates-for-php-5-6/
|
I have no idea. That's why I divided the list of updated blocks to post and pre 5.3.0 release.
I followed the patterns that exist already in the codebase. I think they were born naturally. I'm not aware of any written recommendation.
Yes,
|
Trying to think about what might be the most flagrant violations for blocks we have known control over (the ones you consider as 5.4 and beyond, blocks pending for 5.4). These ones should incorporate
These to follow the convention of
To clarify, you have made most of these corrections already. Just highlighting the specifics about what I think can be considered as incorrect about them. |
As far as I know, we can not change the names of functions part of WordPress core. |
It is possible, but the old names should be deprecated. True, it's not "ideal" to deprecate functions just for that reason, but on the other hand having consistent, easy to understand and follow naming scheme would be really nice. Always using |
My recommendation on this specific point would be:
I don't think we ought to substitute "core", and I think we should continue to prefix these with |
This reverts commit b04d061820c613ed2954257fb0cfe4376acb254b.
d37df94
to
b57011e
Compare
While we might have the option to rename existing functions as part of a deprecation, that option will remain open to us in the next release as well (WordPress 5.5.0), so I don't think it's the most pressing concern here. Instead, I've rebased the branch to update only those blocks pending to be new additions as part of WordPress 5.4.0, to try to conform to a more standardized naming convention. My expectation is that this is:
Per the original comment, this is only expected to impact:
|
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.
The PR tested well for, I tried the three changed blocks without any error on the editor and front end 👍
Thanks, @aduth for helping with this PR. It makes sense to proceed as you explained 💯 |
I retained commit history for the original approach, in case it is needed for future reference: 7b608da |
Description
This PR tries to standardize all functions names used in PHP files created for core blocks. I don't know how much it is still possible to do, but we should double-check and update at least all those blocks that are new to WordPress 5.4.
Updated blocks
Pre 5.4
Needs to be confirmed:
5.4 and beyond
It's safe to update:
Testing
I ensured that all listed blocks can be inserted in the post content and they render on the frontend.