Yes, these are different hooks with different parameters, but these are triggered by the same function[0].
When the function is called, all of these hooks are triggered. To identify what the user was doing (post creation on the first time? post updated? is the status being updated?), unless you have many conditions (potentially nested ifs), it's a cumbersome job.
For example, a user wants a workflow every time the post is sent to the Trash. When a post is sent to the Trash, three things happen:
- A hook is triggered because it's sent to the Trash.
- The updated status one is also triggered (Published -> Trash).
- The Updated post one is also triggered, because yes, this is an update.
Yes, these are different hooks, but these do come from the same function. We tested two other plugins similar to ours and found minimal automation capabilities; we speculate this is because of the reasons I just exposed.
If you check out the source code for wp_insert_post(), you'll find many do_action(). When clicking the "Add Post" button, the post is created at that moment (so it can reserve the permalink, etc.); by the time you save the post for the first time, in reality, it's being updated, not saved for the first time as one would believe.
This is just a single example, but these software design decisions make it not that straightforward to create an automation plugin. By the way, that function calls many others inside, functions that trigger hooks by themselves; therefore, you'll have many workflows trigger attempts many times per second, just by saving the post.
When the function is called, all of these hooks are triggered. To identify what the user was doing (post creation on the first time? post updated? is the status being updated?), unless you have many conditions (potentially nested ifs), it's a cumbersome job.
For example, a user wants a workflow every time the post is sent to the Trash. When a post is sent to the Trash, three things happen:
- A hook is triggered because it's sent to the Trash.
- The updated status one is also triggered (Published -> Trash).
- The Updated post one is also triggered, because yes, this is an update.
Yes, these are different hooks, but these do come from the same function. We tested two other plugins similar to ours and found minimal automation capabilities; we speculate this is because of the reasons I just exposed.
If you check out the source code for wp_insert_post(), you'll find many do_action(). When clicking the "Add Post" button, the post is created at that moment (so it can reserve the permalink, etc.); by the time you save the post for the first time, in reality, it's being updated, not saved for the first time as one would believe.
This is just a single example, but these software design decisions make it not that straightforward to create an automation plugin. By the way, that function calls many others inside, functions that trigger hooks by themselves; therefore, you'll have many workflows trigger attempts many times per second, just by saving the post.
EDIT: Clarity.
--
[0]: https://developer.wordpress.org/reference/functions/wp_inser...