-
Notifications
You must be signed in to change notification settings - Fork 106
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
Determining the correct hook #2702
Comments
Lesson Development Checklist
|
@jonathanbossenger from what I got from this issue, this section is here to teach the learner when to use a filter or an action? |
Understand the purpose of an action vs a filter: (Maybe we can talk a bit about the CQRS approach)
When to use an action:
When to use filter:
If you see other scenarios feel free to add them |
Hi @CrochetFeve0251, apologies if this wasn't clear. The objective of this lesson would be how to determine which hook or filter to use, in order to achieve a specific goal. So, for example, if I want to enqueue admin-only scripts, which hook do I use? If I want to process a form submission, which hook should I use? The general process would be:
The beginner developer lessons on Hooks, Actions and Filters does already cover the basic purpose of the two, but you certainly can expand on that based on what you've shared here already. Then after that, you can include the process of how to decide which one to use, when developing plugins. |
I see this lesson also had the wrong name for some reason, so I've updated it. It also didn't have prerequisite lessons or objectives set, so I've added those as well. |
@CrochetFeve0251 I'm checking in to see if you're still happy to continue with scripting the next lesson in this module? |
@jonathanbossenger I started to work on it but I didn't push yet the script |
Thank you, no pressure from my side, just wanted to make sure the process is still enjoyable. 🙂 |
When I think about which hook is best at an advanced level, I also consider (1) what data is made available in the hook's parameters and (2) the execution order of the hook. (eg. filtering a post's data before it is inserted into the database rather than acting on it after creation to then update it is generally more efficient) These are the two main reasons I often cannot use a particular hook: it either doesn't provide crucial data needed for my custom functionality or it executes too early or late in the execution flow. Additionally, a nifty trick is you can certainly use a filter hook as an action hook if it meets the necessary criteria. You simply perform your logic and then pass back the filtered value with no modifications to it. Maybe these are also good concepts to consider for this lession. |
Logging that a PR for the script has been created. I will review this week. |
@jonathanbossenger I'm unable to access the video for review. |
@MichelleBlanchette apologies, this should be public now. |
Tutorial/Lessons Review ChecklistPlease tick all items you've confirmed:
I really enjoyed this lesson. The description and purpose of each mentioned hook was spot on and clearly communicated. I was particularly impressed by the explanation of the |
00:00 Introduction |
Details
Prerequisites
It is assumed that the learner has already completed the following lessons:
Learning Objectives
Related Resources and Other Notes
Automation Code
//lesson
The text was updated successfully, but these errors were encountered: