Skip to content

Enhance doc regarding the doAction / applyFilters#40840

Closed
timotheemoulin wants to merge 1 commit intoWordPress:trunkfrom
timotheemoulin:patch-1
Closed

Enhance doc regarding the doAction / applyFilters#40840
timotheemoulin wants to merge 1 commit intoWordPress:trunkfrom
timotheemoulin:patch-1

Conversation

@timotheemoulin
Copy link

What?

Enhance the documentation with missing (IMO important) info on the hook names.
There is no documentation about the hookName, we need to know what kind of names are allowed.
For example, slashes (/) are not permitted in the hookName in the JS implementation, which is not a problem when registering PHP actions and filters (any string will do).

Why?

The main issue is that registering an action/filter with a "wrong" name will not trigger any notice, thus not giving any indication on the source of the error, so improving the doc is a must have.

There is no documentation about the hookName, we need to know what kind of names are allowed.
For example, slashes are not permitted in the hookName in the JS implementation, which is not a problem when registering PHP actions and filters (any string will do).

The main issue is that registering an action/filter with a "wrong" name will not trigger any notice, thus not giving any indication on the source of the error.
@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label May 5, 2022
@github-actions
Copy link

github-actions bot commented May 5, 2022

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @timotheemoulin! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@skorasaurus skorasaurus added [Type] Developer Documentation Documentation for developers Developer Experience Ideas about improving block and theme developer experience labels May 5, 2022
#### Parameters

- `hookName` unique name of the hook. It may contains only alphanumeric characters and dashes `[a-zA-z\-\_]`. Slashes are not permitted.
- `namespace` namespace used by your application. Needed only when adding or removing an action or a filter.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

namespace is required, so I would change "Needed only..." to "Used..."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The namespace can only contain numbers, letters, dashes, periods, underscores and slashes." ... should take the vendor/plugin/function. (from inline docs)


#### Parameters

- `hookName` unique name of the hook. It may contains only alphanumeric characters and dashes `[a-zA-z\-\_]`. Slashes are not permitted.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hook name from doc block: Should be a non empty string containing only numbers, letters, dashes, periods and underscores. Also, the hook name cannot begin with __.

@Mamaduka
Copy link
Member

Mamaduka commented Aug 4, 2025

This looks to be still relevant. The patch needs to be refreshed and feedback addressed.

Marking as "stale" for now.

@github-actions
Copy link

github-actions bot commented Aug 4, 2025

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: timotheemoulin <timotheemoulin@git.wordpress.org>
Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka Mamaduka added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Aug 4, 2025
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Developer Experience Ideas about improving block and theme developer experience First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Status] In Progress Tracking issues with work in progress [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. [Type] Developer Documentation Documentation for developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants