From b7cd03a907fa11df3afe41f12696896d72b1cb54 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Tue, 14 Oct 2025 15:25:55 +0200 Subject: [PATCH 1/2] Update version to 0.3.0 in preparation to Composer package release --- abilities-api.php | 2 +- includes/abilities-api.php | 8 ++-- .../class-wp-abilities-category-registry.php | 40 +++++++++---------- .../class-wp-abilities-registry.php | 2 +- .../class-wp-ability-category.php | 30 +++++++------- includes/abilities-api/class-wp-ability.php | 12 +++--- includes/bootstrap.php | 2 +- 7 files changed, 48 insertions(+), 48 deletions(-) diff --git a/abilities-api.php b/abilities-api.php index d1de7330..ac0ed5ed 100644 --- a/abilities-api.php +++ b/abilities-api.php @@ -12,7 +12,7 @@ * Plugin URI: https://github.com/WordPress/abilities-api * Description: Provides a framework for registering and executing AI abilities in WordPress. * Requires at least: 6.8 - * Version: 0.2.0 + * Version: 0.3.0 * Requires PHP: 7.2 * Author: WordPress.org Contributors * Author URI: https://github.com/WordPress/abilities-api/graphs/contributors diff --git a/includes/abilities-api.php b/includes/abilities-api.php index 6e8c283f..6672b0c6 100644 --- a/includes/abilities-api.php +++ b/includes/abilities-api.php @@ -107,7 +107,7 @@ function wp_get_abilities(): array { /** * Registers a new ability category. * - * @since n.e.x.t + * @since 0.3.0 * * @see WP_Abilities_Category_Registry::register() * @@ -131,7 +131,7 @@ function wp_register_ability_category( string $slug, array $args ): ?WP_Ability_ /** * Unregisters an ability category. * - * @since n.e.x.t + * @since 0.3.0 * * @see WP_Abilities_Category_Registry::unregister() * @@ -145,7 +145,7 @@ function wp_unregister_ability_category( string $slug ): ?WP_Ability_Category { /** * Retrieves a registered ability category. * - * @since n.e.x.t + * @since 0.3.0 * * @see WP_Abilities_Category_Registry::get_registered() * @@ -159,7 +159,7 @@ function wp_get_ability_category( string $slug ): ?WP_Ability_Category { /** * Retrieves all registered ability categories. * - * @since n.e.x.t + * @since 0.3.0 * * @see WP_Abilities_Category_Registry::get_all_registered() * diff --git a/includes/abilities-api/class-wp-abilities-category-registry.php b/includes/abilities-api/class-wp-abilities-category-registry.php index 09fc07b8..045a1df6 100644 --- a/includes/abilities-api/class-wp-abilities-category-registry.php +++ b/includes/abilities-api/class-wp-abilities-category-registry.php @@ -6,7 +6,7 @@ * * @package WordPress * @subpackage Abilities API - * @since n.e.x.t + * @since 0.3.0 */ declare( strict_types = 1 ); @@ -14,14 +14,14 @@ /** * Manages the registration and lookup of ability categories. * - * @since n.e.x.t + * @since 0.3.0 * @access private */ final class WP_Abilities_Category_Registry { /** * The singleton instance of the registry. * - * @since n.e.x.t + * @since 0.3.0 * @var ?self */ private static $instance = null; @@ -29,7 +29,7 @@ final class WP_Abilities_Category_Registry { /** * Holds the registered categories. * - * @since n.e.x.t + * @since 0.3.0 * @var \WP_Ability_Category[] */ private $registered_categories = array(); @@ -39,7 +39,7 @@ final class WP_Abilities_Category_Registry { * * Do not use this method directly. Instead, use the `wp_register_ability_category()` function. * - * @since n.e.x.t + * @since 0.3.0 * * @see wp_register_ability_category() * @@ -66,7 +66,7 @@ public function register( string $slug, array $args ): ?WP_Ability_Category { 'abilities_api_categories_init', '' . esc_html( $slug ) . '' ), - 'n.e.x.t' + '0.3.0' ); return null; } @@ -76,7 +76,7 @@ public function register( string $slug, array $args ): ?WP_Ability_Category { __METHOD__, /* translators: %s: Category slug. */ esc_html( sprintf( __( 'Category "%s" is already registered.' ), $slug ) ), - 'n.e.x.t' + '0.3.0' ); return null; } @@ -85,7 +85,7 @@ public function register( string $slug, array $args ): ?WP_Ability_Category { _doing_it_wrong( __METHOD__, esc_html__( 'Category slug must contain only lowercase alphanumeric characters and dashes.' ), - 'n.e.x.t' + '0.3.0' ); return null; } @@ -93,7 +93,7 @@ public function register( string $slug, array $args ): ?WP_Ability_Category { /** * Filters the category arguments before they are validated and used to instantiate the category. * - * @since n.e.x.t + * @since 0.3.0 * * @param array $args The arguments used to instantiate the category. * @param string $slug The slug of the category. @@ -107,7 +107,7 @@ public function register( string $slug, array $args ): ?WP_Ability_Category { _doing_it_wrong( __METHOD__, esc_html( $e->getMessage() ), - 'n.e.x.t' + '0.3.0' ); return null; } @@ -121,7 +121,7 @@ public function register( string $slug, array $args ): ?WP_Ability_Category { * * Do not use this method directly. Instead, use the `wp_unregister_ability_category()` function. * - * @since n.e.x.t + * @since 0.3.0 * * @see wp_unregister_ability_category() * @@ -134,7 +134,7 @@ public function unregister( string $slug ): ?WP_Ability_Category { __METHOD__, /* translators: %s: Ability category slug. */ sprintf( esc_html__( 'Ability category "%s" not found.' ), esc_attr( $slug ) ), - 'n.e.x.t' + '0.3.0' ); return null; } @@ -150,7 +150,7 @@ public function unregister( string $slug ): ?WP_Ability_Category { * * Do not use this method directly. Instead, use the `wp_get_ability_categories()` function. * - * @since n.e.x.t + * @since 0.3.0 * * @see wp_get_ability_categories() * @@ -163,7 +163,7 @@ public function get_all_registered(): array { /** * Checks if a category is registered. * - * @since n.e.x.t + * @since 0.3.0 * * @param string $slug The slug of the category. * @return bool True if the category is registered, false otherwise. @@ -177,7 +177,7 @@ public function is_registered( string $slug ): bool { * * Do not use this method directly. Instead, use the `wp_get_ability_category()` function. * - * @since n.e.x.t + * @since 0.3.0 * * @see wp_get_ability_category() * @@ -190,7 +190,7 @@ public function get_registered( string $slug ): ?WP_Ability_Category { __METHOD__, /* translators: %s: Ability category slug. */ sprintf( esc_html__( 'Ability category "%s" not found.' ), esc_attr( $slug ) ), - 'n.e.x.t' + '0.3.0' ); return null; } @@ -202,7 +202,7 @@ public function get_registered( string $slug ): ?WP_Ability_Category { * * The instance will be created if it does not exist yet. * - * @since n.e.x.t + * @since 0.3.0 * * @return \WP_Abilities_Category_Registry The main registry instance. */ @@ -215,7 +215,7 @@ public static function get_instance(): self { * * Categories should be registered on this action to ensure they're available when needed. * - * @since n.e.x.t + * @since 0.3.0 * * @param \WP_Abilities_Category_Registry $instance Categories registry object. */ @@ -228,7 +228,7 @@ public static function get_instance(): self { /** * Wakeup magic method. * - * @since n.e.x.t + * @since 0.3.0 * @throws \LogicException If the registry is unserialized. This is a security hardening measure to prevent unserialization of the registry. */ public function __wakeup(): void { @@ -238,7 +238,7 @@ public function __wakeup(): void { /** * Serialization magic method. * - * @since n.e.x.t + * @since 0.3.0 * @throws \LogicException If the registry is serialized. This is a security hardening measure to prevent serialization of the registry. */ public function __sleep(): array { diff --git a/includes/abilities-api/class-wp-abilities-registry.php b/includes/abilities-api/class-wp-abilities-registry.php index 8a10a15d..d5f36999 100644 --- a/includes/abilities-api/class-wp-abilities-registry.php +++ b/includes/abilities-api/class-wp-abilities-registry.php @@ -111,7 +111,7 @@ public function register( string $name, array $args ): ?WP_Ability { esc_attr( $args['category'] ), esc_attr( $name ) ), - 'n.e.x.t' + '0.3.0' ); return null; } diff --git a/includes/abilities-api/class-wp-ability-category.php b/includes/abilities-api/class-wp-ability-category.php index 722a1949..734b436f 100644 --- a/includes/abilities-api/class-wp-ability-category.php +++ b/includes/abilities-api/class-wp-ability-category.php @@ -6,7 +6,7 @@ * * @package WordPress * @subpackage Abilities API - * @since n.e.x.t + * @since 0.3.0 */ declare( strict_types = 1 ); @@ -14,7 +14,7 @@ /** * Encapsulates the properties and methods related to a specific ability category. * - * @since n.e.x.t + * @since 0.3.0 * * @see WP_Abilities_Category_Registry */ @@ -23,7 +23,7 @@ final class WP_Ability_Category { /** * The unique slug for the category. * - * @since n.e.x.t + * @since 0.3.0 * @var string */ protected $slug; @@ -31,7 +31,7 @@ final class WP_Ability_Category { /** * The human-readable category label. * - * @since n.e.x.t + * @since 0.3.0 * @var string */ protected $label; @@ -39,7 +39,7 @@ final class WP_Ability_Category { /** * The detailed category description. * - * @since n.e.x.t + * @since 0.3.0 * @var string */ protected $description; @@ -47,7 +47,7 @@ final class WP_Ability_Category { /** * The optional category metadata. * - * @since n.e.x.t + * @since 0.3.0 * @var array */ protected $meta = array(); @@ -59,7 +59,7 @@ final class WP_Ability_Category { * * @access private * - * @since n.e.x.t + * @since 0.3.0 * * @see wp_register_ability_category() * @@ -88,7 +88,7 @@ public function __construct( string $slug, array $args ) { '' . esc_html( $this->slug ) . '', '' . esc_html( self::class ) . '' ), - 'n.e.x.t' + '0.3.0' ); continue; } @@ -100,7 +100,7 @@ public function __construct( string $slug, array $args ) { /** * Prepares and validates the properties used to instantiate the category. * - * @since n.e.x.t + * @since 0.3.0 * * @param array $args An associative array of arguments used to instantiate the class. * @return array The validated and prepared properties. @@ -140,7 +140,7 @@ protected function prepare_properties( array $args ): array { /** * Retrieves the slug of the category. * - * @since n.e.x.t + * @since 0.3.0 * * @return string The category slug. */ @@ -151,7 +151,7 @@ public function get_slug(): string { /** * Retrieves the human-readable label for the category. * - * @since n.e.x.t + * @since 0.3.0 * * @return string The human-readable category label. */ @@ -162,7 +162,7 @@ public function get_label(): string { /** * Retrieves the detailed description for the category. * - * @since n.e.x.t + * @since 0.3.0 * * @return string The detailed description for the category. */ @@ -173,7 +173,7 @@ public function get_description(): string { /** * Retrieves the metadata for the category. * - * @since n.e.x.t + * @since 0.3.0 * * @return array The metadata for the category. */ @@ -184,7 +184,7 @@ public function get_meta(): array { /** * Wakeup magic method. * - * @since n.e.x.t + * @since 0.3.0 * @throws \LogicException If the category is unserialized. This is a security hardening measure to prevent unserialization of the category. */ public function __wakeup(): void { @@ -194,7 +194,7 @@ public function __wakeup(): void { /** * Serialization magic method. * - * @since n.e.x.t + * @since 0.3.0 * @throws \LogicException If the category is serialized. This is a security hardening measure to prevent serialization of the category. */ public function __sleep(): array { diff --git a/includes/abilities-api/class-wp-ability.php b/includes/abilities-api/class-wp-ability.php index cce2e04e..e31ce5ba 100644 --- a/includes/abilities-api/class-wp-ability.php +++ b/includes/abilities-api/class-wp-ability.php @@ -23,7 +23,7 @@ class WP_Ability { /** * The default value for the `show_in_rest` meta. * - * @since n.e.x.t + * @since 0.3.0 * @var bool */ protected const DEFAULT_SHOW_IN_REST = false; @@ -32,7 +32,7 @@ class WP_Ability { * The default ability annotations. * They are not guaranteed to provide a faithful description of ability behavior. * - * @since n.e.x.t + * @since 0.3.0 * @var array */ protected static $default_annotations = array( @@ -120,7 +120,7 @@ class WP_Ability { /** * The ability category (required). * - * @since n.e.x.t + * @since 0.3.0 * @var string */ protected $category; @@ -345,7 +345,7 @@ public function get_meta(): array { /** * Retrieves the category for the ability. * - * @since n.e.x.t + * @since 0.3.0 * * @return string The category for the ability. */ @@ -356,7 +356,7 @@ public function get_category(): string { /** * Retrieves a specific metadata item for the ability. * - * @since n.e.x.t + * @since 0.3.0 * * @param string $key The metadata key to retrieve. * @param mixed $default_value Optional. The default value to return if the metadata item is not found. Default `null`. @@ -410,7 +410,7 @@ protected function validate_input( $input = null ) { /** * Invokes a callable, ensuring the input is passed through only if the input schema is defined. * - * @since n.e.x.t + * @since 0.3.0 * * @param callable $callback The callable to invoke. * @param mixed $input Optional. The input data for the ability. Default `null`. diff --git a/includes/bootstrap.php b/includes/bootstrap.php index 4838495a..ae23de56 100644 --- a/includes/bootstrap.php +++ b/includes/bootstrap.php @@ -19,7 +19,7 @@ // Version of the plugin. if ( ! defined( 'WP_ABILITIES_API_VERSION' ) ) { - define( 'WP_ABILITIES_API_VERSION', '0.2.0' ); + define( 'WP_ABILITIES_API_VERSION', '0.3.0' ); } // Load core classes if they are not already defined (for non-Composer installs or direct includes). From 5bb3a3e845a717e191f9f2eb97e7797219849f4b Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Tue, 14 Oct 2025 16:16:32 +0200 Subject: [PATCH 2/2] Fix styling issues raised on WP Core CI --- tests/unit/abilities-api/wpAbility.php | 14 +++++++------- tests/unit/abilities-api/wpRegisterAbility.php | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/unit/abilities-api/wpAbility.php b/tests/unit/abilities-api/wpAbility.php index b60a056d..17c16e7b 100644 --- a/tests/unit/abilities-api/wpAbility.php +++ b/tests/unit/abilities-api/wpAbility.php @@ -62,7 +62,7 @@ function () { } /** - * Tear down after each test. + * Tear down after each test. */ public function tear_down(): void { // Clean up registered categories. @@ -74,7 +74,7 @@ public function tear_down(): void { parent::tear_down(); } - /* + /* * Tests that getting non-existing metadata item returns default value. */ public function test_meta_get_non_existing_item_returns_default() { @@ -111,7 +111,7 @@ public function test_get_merged_annotations_from_meta() { array( 'instructions' => '', 'idempotent' => false, - ), + ) ), $ability->get_meta_item( 'annotations' ) ); @@ -196,7 +196,7 @@ public function test_meta_show_in_rest_defaults_to_false() { * Tests that `show_in_rest` metadata can be set to true. */ public function test_meta_show_in_rest_can_be_set_to_true() { - $args = array_merge( + $args = array_merge( self::$test_ability_properties, array( 'meta' => array( @@ -216,7 +216,7 @@ public function test_meta_show_in_rest_can_be_set_to_true() { * Tests that `show_in_rest` can be set to false. */ public function test_show_in_rest_can_be_set_to_false() { - $args = array_merge( + $args = array_merge( self::$test_ability_properties, array( 'meta' => array( @@ -407,7 +407,7 @@ public function my_instance_execute_callback( string $input ): int { */ public function data_execute_callback() { return array( - 'function name string' => array( + 'function name string' => array( 'strlen', ), 'closure' => array( @@ -432,7 +432,7 @@ static function ( string $input ): int { * * @dataProvider data_execute_callback */ - public function test_execute_with_different_callbacks( $execute_callback) { + public function test_execute_with_different_callbacks( $execute_callback ) { $args = array_merge( self::$test_ability_properties, array( diff --git a/tests/unit/abilities-api/wpRegisterAbility.php b/tests/unit/abilities-api/wpRegisterAbility.php index 1fa0aaa0..04a39a21 100644 --- a/tests/unit/abilities-api/wpRegisterAbility.php +++ b/tests/unit/abilities-api/wpRegisterAbility.php @@ -156,14 +156,14 @@ public function test_register_valid_ability(): void { $result = wp_register_ability( self::$test_ability_name, self::$test_ability_args ); - $expected_annotations = array_merge( + $expected_annotations = array_merge( self::$test_ability_args['meta']['annotations'], array( 'instructions' => '', 'idempotent' => false, - ), + ) ); - $expected_meta = array_merge( + $expected_meta = array_merge( self::$test_ability_args['meta'], array( 'annotations' => $expected_annotations,