Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion abilities-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions includes/abilities-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
*
Expand All @@ -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()
*
Expand All @@ -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()
*
Expand All @@ -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()
*
Expand Down
40 changes: 20 additions & 20 deletions includes/abilities-api/class-wp-abilities-category-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@
*
* @package WordPress
* @subpackage Abilities API
* @since n.e.x.t
* @since 0.3.0
*/

declare( strict_types = 1 );

/**
* 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;

/**
* Holds the registered categories.
*
* @since n.e.x.t
* @since 0.3.0
* @var \WP_Ability_Category[]
*/
private $registered_categories = array();
Expand All @@ -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()
*
Expand All @@ -66,7 +66,7 @@ public function register( string $slug, array $args ): ?WP_Ability_Category {
'<code>abilities_api_categories_init</code>',
'<code>' . esc_html( $slug ) . '</code>'
),
'n.e.x.t'
'0.3.0'
);
return null;
}
Expand All @@ -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;
}
Expand All @@ -85,15 +85,15 @@ 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;
}

/**
* 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<string,mixed> $args The arguments used to instantiate the category.
* @param string $slug The slug of the category.
Expand All @@ -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;
}
Expand All @@ -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()
*
Expand All @@ -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;
}
Expand All @@ -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()
*
Expand All @@ -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.
Expand All @@ -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()
*
Expand All @@ -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;
}
Expand All @@ -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.
*/
Expand All @@ -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.
*/
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion includes/abilities-api/class-wp-abilities-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
30 changes: 15 additions & 15 deletions includes/abilities-api/class-wp-ability-category.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
*
* @package WordPress
* @subpackage Abilities API
* @since n.e.x.t
* @since 0.3.0
*/

declare( strict_types = 1 );

/**
* 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
*/
Expand All @@ -23,31 +23,31 @@ final class WP_Ability_Category {
/**
* The unique slug for the category.
*
* @since n.e.x.t
* @since 0.3.0
* @var string
*/
protected $slug;

/**
* The human-readable category label.
*
* @since n.e.x.t
* @since 0.3.0
* @var string
*/
protected $label;

/**
* The detailed category description.
*
* @since n.e.x.t
* @since 0.3.0
* @var string
*/
protected $description;

/**
* The optional category metadata.
*
* @since n.e.x.t
* @since 0.3.0
* @var array<string,mixed>
*/
protected $meta = array();
Expand All @@ -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()
*
Expand Down Expand Up @@ -88,7 +88,7 @@ public function __construct( string $slug, array $args ) {
'<code>' . esc_html( $this->slug ) . '</code>',
'<code>' . esc_html( self::class ) . '</code>'
),
'n.e.x.t'
'0.3.0'
);
continue;
}
Expand All @@ -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<string,mixed> $args An associative array of arguments used to instantiate the class.
* @return array<string,mixed> The validated and prepared properties.
Expand Down Expand Up @@ -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.
*/
Expand All @@ -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.
*/
Expand All @@ -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.
*/
Expand All @@ -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<string,mixed> The metadata for the category.
*/
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
Loading