-
Notifications
You must be signed in to change notification settings - Fork 239
Dynamic action priorities #1232
Description
PR #1228 implemented new filter vp_action_priority_{$scope}, see diff, but there has also been some discussion about other options. Specifically, @pavelevap noted that special WPLANG handling is not evident from the actions.yml file and can be missed:
option:
actions:
create: Created option '%VPID%'
edit:
message: Edited option '%VPID%'
priority: 12
delete: Deleted option '%VPID%'That is true although it could be said for many other things in hooks.php. Still, we discussed with @JanVoracek what we could do about that. Some option would be something like this:
option:
actions:
create:
message: Created option '%VPID%'
priority: 10
priority(option_name==WPLANG): 20But it's not really accurate: in this case, the rule is more complex and would need to be something like:
option:
actions:
create:
message: Created option '%VPID%'
priority: 10
priority(option_name=='WPLANG' && option_value==''): 20We're now basically embedding code into YAML which didn't look like a good idea.
Another idea was to call a function, similarly to what's possible in schema.yml:
option:
actions:
create:
message: Created option '%VPID%'
priority: 10
priority_WPLANG: @getWplangPriorityBut that probably wouldn't work as determining priority doesn't seem to be deterministic here.
So it seems that the vp_action_priority_{$scope} filter as per #1228 is a reasonable solution for now, maybe combined with some comment in the YAML file (although, again, hooks.php is full of stuff to be aware of).
🏁 PR #1228