@@ -33,7 +33,7 @@ class WP_Ability {
3333 * They are not guaranteed to provide a faithful description of ability behavior.
3434 *
3535 * @since 6.9.0
36- * @var array<string, ( bool|null) >
36+ * @var array<string, bool|null>
3737 */
3838 protected static $ default_annotations = array (
3939 // If true, the ability does not modify its environment.
@@ -150,7 +150,16 @@ class WP_Ability {
150150 * @type array<string, mixed> $meta {
151151 * Optional. Additional metadata for the ability.
152152 *
153- * @type array<string, null|bool> $annotations Optional. Annotation metadata for the ability.
153+ * @type array<string, bool|null> $annotations {
154+ * Optional. Semantic annotations describing the ability's behavioral characteristics.
155+ * These annotations are hints for tooling and documentation.
156+ *
157+ * @type bool|null $readonly Optional. If true, the ability does not modify its environment.
158+ * @type bool|null $destructive Optional. If true, the ability may perform destructive updates to its environment.
159+ * If false, the ability performs only additive updates.
160+ * @type bool|null $idempotent Optional. If true, calling the ability repeatedly with the same arguments
161+ * will have no additional effect on its environment.
162+ * }
154163 * @type bool $show_in_rest Optional. Whether to expose this ability in the REST API. Default false.
155164 * }
156165 * }
@@ -205,7 +214,16 @@ public function __construct( string $name, array $args ) {
205214 * @type array<string, mixed> $meta {
206215 * Optional. Additional metadata for the ability.
207216 *
208- * @type array<string, null|bool> $annotations Optional. Annotation metadata for the ability.
217+ * @type array<string, bool|null> $annotations {
218+ * Optional. Semantic annotations describing the ability's behavioral characteristics.
219+ * These annotations are hints for tooling and documentation.
220+ *
221+ * @type bool|null $readonly Optional. If true, the ability does not modify its environment.
222+ * @type bool|null $destructive Optional. If true, the ability may perform destructive updates to its environment.
223+ * If false, the ability performs only additive updates.
224+ * @type bool|null $idempotent Optional. If true, calling the ability repeatedly with the same arguments
225+ * will have no additional effect on its environment.
226+ * }
209227 * @type bool $show_in_rest Optional. Whether to expose this ability in the REST API. Default false.
210228 * }
211229 * }
@@ -224,7 +242,16 @@ public function __construct( string $name, array $args ) {
224242 * @type array<string, mixed> $meta {
225243 * Additional metadata for the ability.
226244 *
227- * @type array<string, null|bool> $annotations Optional. Annotation metadata for the ability.
245+ * @type array<string, bool|null> $annotations {
246+ * Semantic annotations describing the ability's behavioral characteristics.
247+ * These annotations are hints for tooling and documentation.
248+ *
249+ * @type bool|null $readonly If true, the ability does not modify its environment.
250+ * @type bool|null $destructive If true, the ability may perform destructive updates to its environment.
251+ * If false, the ability performs only additive updates.
252+ * @type bool|null $idempotent If true, calling the ability repeatedly with the same arguments
253+ * will have no additional effect on its environment.
254+ * }
228255 * @type bool $show_in_rest Whether to expose this ability in the REST API. Default false.
229256 * }
230257 * }
@@ -498,6 +525,14 @@ protected function invoke_callback( callable $callback, $input = null ) {
498525 * @return bool|WP_Error Whether the ability has the necessary permission.
499526 */
500527 public function check_permissions ( $ input = null ) {
528+ if ( ! is_callable ( $ this ->permission_callback ) ) {
529+ return new WP_Error (
530+ 'ability_invalid_permission_callback ' ,
531+ /* translators: %s ability name. */
532+ sprintf ( __ ( 'Ability "%s" does not have a valid permission callback. ' ), esc_html ( $ this ->name ) )
533+ );
534+ }
535+
501536 return $ this ->invoke_callback ( $ this ->permission_callback , $ input );
502537 }
503538
0 commit comments