-
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
Update getContext() usage examples with namespace argument #63411
Update getContext() usage examples with namespace argument #63411
Conversation
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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.
Thanks for adding these docs! :)
What you have written at the moment is not how the API is working however.
The namespace
you pass to the getContext
function needs to be the namespace of an interactive region (data-wp-interactive
).
So in this case you would want to use getContext("myPlugin")
And the getContext
function always gets the entire context object. There is no helper function to only get part of a context.
Hi @fabiankaegy, Thank you for your feedback. I have updated the documentation to reflect the correct usage of the getContext function with the namespace of an interactive region (data-wp-interactive). Can you please review it once more to ensure everything is accurate? |
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.
Left one minor suggestion :) Otherwise this looks great 👍
Thanks for updating it :)
Co-authored-by: Fabian Kägy <mail@fabian-kaegy.de>
…tivity API Documentation (WordPress#63411) Co-authored-by: dhananjaykuber <dhananjaykuber@git.wordpress.org> Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org> Co-authored-by: juanmaguitar <juanmaguitar@git.wordpress.org>
Fixes #63366
What?
This PR updates the documentation for the getContext() function to separate usage examples with and without namespace arguments. It provides clear, distinct examples and explanations for each case.
Why?
This PR addresses the need for clearer documentation on how to use the getContext() function both with and without the optional namespace argument. It helps developers understand the different use cases and how to retrieve specific parts of the context, improving the overall usability and clarity of the documentation.
How?
Adding a section for using getContext(namespace) with a namespace argument.