0

I'm trying to customize the Gallery block using the new Gutenberk Block API thing.

Long story short, I need to add a filter to do the customization.

So what is the purpose of the namespace argument when calling the addFilter function? I am failing to find an explanation for the purpose of this argument.

Edit: Essentially, I am trying to do what is shown in this post/question. Still, the question remains, what is the purpose of the namespace argument, and its role in the scope of the project?

Ref: Validation error: Extending Gutenberg gallery block

Also, if you're going to downvote, can you explain why?

2

So what is the purpose of the namespace argument when calling the addFilter function? I am failing to find an explanation for the purpose of this argument.

The core ticket for adding Javascript actions and filters is #21170

It spans many years and contains a lot of discussions about e.g. namespacing.

See e.g. this comment by @azaozz:

Also thinking the namespaces/identifiers should be required as that would make removing anonymous functions easy. As far as I see the most common use of this would be with anonymous functions

and then it gets implemented e.g. here by @adamsilverstein and then with more iterations.

Here's another description by Igor Benić:

That difference is the namespace which you also add when adding actions and filters (or removing them). This is done in case you have same function names under different components (or Apps). With using namespaces you can easily distinguish to which component or app it belongs so you don’t accidentaly remove the wrong function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.