You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhance WP_Ability validation for execute_callback
This commit updates the WP_Ability class to validate the execute_callback only when the ability_class parameter is not overridden during instantiation.
$this->assertNotSame( $filtered_ability->get_label(), $unfiltered_ability->get_label(), 'The filter incorrectly modified the args for an ability it should not have.' );
652
676
}
653
677
}
678
+
679
+
/**
680
+
* Test custom ability class that extends WP_Ability.
681
+
*
682
+
* This class overrides do_execute() and check_permissions() directly,
683
+
* allowing registration without execute_callback or permission_callback.
684
+
*/
685
+
class Tests_Custom_Ability_Class extends WP_Ability {
686
+
687
+
/**
688
+
* Custom execute implementation that multiplies instead of adds.
689
+
*
690
+
* @param mixed $input The input data.
691
+
* @return int The result of multiplying a and b.
692
+
*/
693
+
protectedfunctiondo_execute( $input = null ) {
694
+
return$input['a'] * $input['b'];
695
+
}
696
+
697
+
/**
698
+
* Custom permission check that always returns true.
0 commit comments