Skip to content

Commit bbda8b6

Browse files
committed
Abilities: Support ability deprecation
1 parent a3c672d commit bbda8b6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/wp-includes/abilities-api/class-wp-ability.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ protected function prepare_properties( array $args ): array {
325325
$args['meta'] ?? array(),
326326
array(
327327
'annotations' => static::$default_annotations,
328+
'deprecated' => false,
328329
'show_in_rest' => self::DEFAULT_SHOW_IN_REST,
329330
)
330331
);
@@ -553,6 +554,13 @@ protected function do_execute( $input = null ) {
553554
);
554555
}
555556

557+
// Trigger deprecation notice if the ability is deprecated.
558+
if ( $this->get_meta_item( 'deprecated', false ) === true ) {
559+
$version = $this->get_meta_item( 'deprecated_version', '' );
560+
$replacement = $this->get_meta_item( 'deprecated_replacement', '' );
561+
_deprecated_ability( $this->name, $version, $replacement );
562+
}
563+
556564
return $this->invoke_callback( $this->execute_callback, $input );
557565
}
558566

0 commit comments

Comments
 (0)