[wp-trac] [WordPress Trac] #64407: Abilities API: when using `ability_class`, the `execute_callback` should not be mandatory
WordPress Trac
noreply at wordpress.org
Wed Dec 17 15:27:44 UTC 2025
#64407: Abilities API: when using `ability_class`, the `execute_callback` should
not be mandatory
--------------------------------------+------------------------------
Reporter: artpi | Owner: artpi
Type: defect (bug) | Status: closed
Priority: normal | Milestone: Awaiting Review
Component: AI | Version:
Severity: minor | Resolution: fixed
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+------------------------------
Changes (by jorgefilipecosta):
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"61390" 61390]:
{{{
#!CommitTicketReference repository="" revision="61390"
Abilities API: Enhance WP_Ability validation for execute_callback and
permission_callback.
Abilities API allows for extending WP_Ability by providing ability_class
during the ability registration. This is meant to unlock complex abilities
holding some sort of state or logic that requires multiple helper methods.
In all of those scenarios you would ovewrite execute or do_execute method.
However, because the check for execute_callback is in constructor, then in
order to register an ability with ability_class overwrite, you have to
BOTH: provide do_execute and provide a dummy execute_callback. The same
need happens for permission_callback.
This commit fixes the issue execute_callback and permission_callback are
now optional when a class is provided.
Props artpi, swissspidy, jorgefilipecosta, mindctrl.
Fixes #64407.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64407#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list