File tree Expand file tree Collapse file tree 2 files changed +4
-2
lines changed
src/wp-includes/abilities-api
tests/phpunit/tests/abilities-api Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -284,7 +284,8 @@ protected function prepare_properties( array $args ): array {
284284 );
285285 }
286286
287- if ( empty ( $ args ['permission_callback ' ] ) || ! is_callable ( $ args ['permission_callback ' ] ) ) {
287+ // If we are not overriding `ability_class` parameter during instantiation, then we need to validate the permission_callback.
288+ if ( get_class ( $ this ) === self ::class && ( empty ( $ args ['permission_callback ' ] ) || ! is_callable ( $ args ['permission_callback ' ] ) ) ) {
288289 throw new InvalidArgumentException (
289290 __ ( 'The ability properties must provide a valid `permission_callback` function. ' )
290291 );
Original file line number Diff line number Diff line change @@ -268,8 +268,9 @@ public function test_register_incorrect_execute_callback_type() {
268268 * @covers WP_Ability::prepare_properties
269269 */
270270 public function test_register_with_custom_ability_class_without_execute_callback () {
271- // Remove execute_callback since the custom class provides its own implementation.
271+ // Remove execute_callback and permission_callback since the custom class provides its own implementation.
272272 unset( self ::$ test_ability_args ['execute_callback ' ] );
273+ unset( self ::$ test_ability_args ['permission_callback ' ] );
273274
274275 self ::$ test_ability_args ['ability_class ' ] = 'Tests_Custom_Ability_Class ' ;
275276
You can’t perform that action at this time.
0 commit comments