Skip to content
This repository has been archived by the owner. It is now read-only.

Should php functions be pluggable through names? #114

Closed
aaronjorbin opened this issue Oct 14, 2021 · 3 comments
Closed

Should php functions be pluggable through names? #114

aaronjorbin opened this issue Oct 14, 2021 · 3 comments

Comments

@aaronjorbin
Copy link
Member

@aaronjorbin aaronjorbin commented Oct 14, 2021

Looking through functions.php, I see that the pattern is to use function_exists checks everywhere and thus encourage child themers to use the same function names to change functionality. This is a pattern for default themes that dates back to at least twentyten. In the years since the various APIs have matured and I think it might be good to question if this is the pattern that should still be encouraged?

As of now, functions.php and inc/block-patterns.php have a small number of functions and I think that makes it ripe to consider if this is the pattern that is still best. Would removing them and increasing the inline documentation to outline how to make adjustments be a better pattern? Is there another alternative that hasn't been done?

It's possible that additional hooks or extension points may need to be added to core, but I feel that the default themes have long been great drivers at making core better at providing themers with new APIs and thus the end-users of WordPress with better sites.

@kjellr
Copy link
Collaborator

@kjellr kjellr commented Oct 14, 2021

FWIW, we originally the theme didn't have these. Then a few folks seemed to support adding them in. And then more people asked that we take them out. 😅

Personally, I don't think the duplicate checks make much sense, and I'd be happy to get rid of them. In general I've never felt that re-using function names is a good practice. In most other contexts, you'll do some real damage!

(Also, I guess it's good that the theme is so lightweight that this minor discussion point is what folks keep being drawn to.)

@aaronjorbin
Copy link
Member Author

@aaronjorbin aaronjorbin commented Oct 14, 2021

I think clear documentation on how to extend things (and what should be extended) is safer than pluggable functions since as you point out, it's possible to do real damage.

If we want to go down this path, I might suggest that we come up with "recipes" for customization and have those documented and then referenced in line. For example, it's possible that someone's brand is to use a specific serif font and they would want to use that instead of Source Serif Pro. Making it clear how to do that and then above the twentytwentytwo_get_font_face_styles function, there could be a link to that recipe.

@kjellr
Copy link
Collaborator

@kjellr kjellr commented Jan 24, 2022

Now that we're nearing release, I'm going to close this issue. If anyone has further thoughts to share on this topic, feel free to open up a new issue on Trac.

@kjellr kjellr closed this Jan 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants