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 .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ jobs:
strategy:
matrix:
php: ['8.4', '8.3', '8.2', '8.1', '8.0', '7.4']
wp: [latest, trunk, '6.7']
wp: [latest, trunk ]
coverage: [false]
include:
- php: '8.4'
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Join the `#core-ai` channel [on WordPress Slack](http://wordpress.slack.com) ([s

## Coding standards

In general, all code must follow the [WordPress Coding Standards and best practices](https://developer.wordpress.org/coding-standards/). All code in the Performance Lab plugin must follow these requirements:
In general, all code must follow the [WordPress Coding Standards and best practices](https://developer.wordpress.org/coding-standards/). All code in the Abilities API plugin must follow these requirements:

- **WordPress**: As of Performance Lab v0.0.1, released {@todo}, the plugin's minimum WordPress version requirement is 6.7.
- **PHP**: The minimum required version right now is 7.4. This is subject to change and will be brought in sync with the WordPress core minimum PHP version requirement closer to release.
- **WordPress**: The plugin's minimum WordPress version requirement is 6.8.
- **PHP**: The minimum required version of the code slated for WordPress Core includes is PHP7.2, but the tooling and development environment requires PHP 7.4 or higher.

We include [several tools](#useful-commands) to help ensure your code meets contribution

Expand Down
8 changes: 4 additions & 4 deletions abilities-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
* Plugin Name: Abilities API
* Plugin URI: https://github.com/WordPress/abilities-api
* Description: Provides a framework for registering and executing AI abilities in WordPress.
* Requires at least: 6.7
* Version: 0.0.1
* Requires PHP: 7.4
* Requires at least: 6.8
* Version: 0.1.0
* Requires PHP: 7.2
* Author: WordPress.org Contributors
* Author URI: https://github.com/WordPress/abilities-api/graphs/contributors
* License: GPLv2 or later
Expand All @@ -29,7 +29,7 @@
/**
* Version of the plugin.
*/
define( 'WP_ABILITIES_API_VERSION', '0.0.1' );
define( 'WP_ABILITIES_API_VERSION', '0.1.0' );

/**
* First the WP_Ability class that users can extend.
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "AI Abilities for WordPress",
"license": "GPL-2.0-or-later",
"type": "wordpress-plugin",
"version": "0.1.0",
"keywords": [
"ai",
"llm",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function register_routes(): void {
array(
'args' => array(
'name' => array(
'description' => __( 'Unique identifier for the ability.', 'abilities-api' ),
'description' => __( 'Unique identifier for the ability.' ),
'type' => 'string',
'pattern' => '^[a-zA-Z0-9\-\/]+$',
),
Expand Down Expand Up @@ -152,7 +152,7 @@ public function get_item( $request ) {
if ( ! $ability ) {
return new \WP_Error(
'rest_ability_not_found',
__( 'Ability not found.', 'abilities-api' ),
__( 'Ability not found.' ),
array( 'status' => 404 )
);
}
Expand Down Expand Up @@ -233,37 +233,37 @@ public function get_item_schema(): array {
'type' => 'object',
'properties' => array(
'name' => array(
'description' => __( 'Unique identifier for the ability.', 'abilities-api' ),
'description' => __( 'Unique identifier for the ability.' ),
'type' => 'string',
'context' => array( 'view', 'edit', 'embed' ),
'readonly' => true,
),
'label' => array(
'description' => __( 'Display label for the ability.', 'abilities-api' ),
'description' => __( 'Display label for the ability.' ),
'type' => 'string',
'context' => array( 'view', 'edit', 'embed' ),
'readonly' => true,
),
'description' => array(
'description' => __( 'Description of the ability.', 'abilities-api' ),
'description' => __( 'Description of the ability.' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'input_schema' => array(
'description' => __( 'JSON Schema for the ability input.', 'abilities-api' ),
'description' => __( 'JSON Schema for the ability input.' ),
'type' => 'object',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'output_schema' => array(
'description' => __( 'JSON Schema for the ability output.', 'abilities-api' ),
'description' => __( 'JSON Schema for the ability output.' ),
'type' => 'object',
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'meta' => array(
'description' => __( 'Meta information about the ability.', 'abilities-api' ),
'description' => __( 'Meta information about the ability.' ),
'type' => 'object',
'context' => array( 'view', 'edit' ),
'readonly' => true,
Expand All @@ -286,15 +286,15 @@ public function get_collection_params(): array {
return array(
'context' => $this->get_context_param( array( 'default' => 'view' ) ),
'page' => array(
'description' => __( 'Current page of the collection.', 'abilities-api' ),
'description' => __( 'Current page of the collection.' ),
'type' => 'integer',
'default' => 1,
'sanitize_callback' => 'absint',
'validate_callback' => 'rest_validate_request_arg',
'minimum' => 1,
),
'per_page' => array(
'description' => __( 'Maximum number of items to be returned in result set.', 'abilities-api' ),
'description' => __( 'Maximum number of items to be returned in result set.' ),
'type' => 'integer',
'default' => self::DEFAULT_PER_PAGE,
'minimum' => 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function register_routes(): void {
array(
'args' => array(
'name' => array(
'description' => __( 'Unique identifier for the ability.', 'abilities-api' ),
'description' => __( 'Unique identifier for the ability.' ),
'type' => 'string',
'pattern' => '^[a-zA-Z0-9\-\/]+$',
),
Expand Down Expand Up @@ -84,7 +84,7 @@ public function run_ability_with_method_check( $request ) {
if ( ! $ability ) {
return new \WP_Error(
'rest_ability_not_found',
__( 'Ability not found.', 'abilities-api' ),
__( 'Ability not found.' ),
array( 'status' => 404 )
);
}
Expand All @@ -97,15 +97,15 @@ public function run_ability_with_method_check( $request ) {
if ( 'resource' === $type && 'GET' !== $method ) {
return new \WP_Error(
'rest_invalid_method',
__( 'Resource abilities require GET method.', 'abilities-api' ),
__( 'Resource abilities require GET method.' ),
array( 'status' => 405 )
);
}

if ( 'tool' === $type && 'POST' !== $method ) {
return new \WP_Error(
'rest_invalid_method',
__( 'Tool abilities require POST method.', 'abilities-api' ),
__( 'Tool abilities require POST method.' ),
array( 'status' => 405 )
);
}
Expand All @@ -127,7 +127,7 @@ public function run_ability( $request ) {
if ( ! $ability ) {
return new \WP_Error(
'rest_ability_not_found',
__( 'Ability not found.', 'abilities-api' ),
__( 'Ability not found.' ),
array( 'status' => 404 )
);
}
Expand Down Expand Up @@ -156,7 +156,7 @@ public function run_ability( $request ) {
if ( is_null( $result ) ) {
return new \WP_Error(
'rest_ability_execution_failed',
__( 'Ability execution failed. Please check permissions and input parameters.', 'abilities-api' ),
__( 'Ability execution failed. Please check permissions and input parameters.' ),
array( 'status' => 500 )
);
}
Expand All @@ -183,7 +183,7 @@ public function run_ability_permissions_check( $request ) {
if ( ! $ability ) {
return new \WP_Error(
'rest_ability_not_found',
__( 'Ability not found.', 'abilities-api' ),
__( 'Ability not found.' ),
array( 'status' => 404 )
);
}
Expand All @@ -193,7 +193,7 @@ public function run_ability_permissions_check( $request ) {
if ( ! $ability->has_permission( $input ) ) {
return new \WP_Error(
'rest_cannot_execute',
__( 'Sorry, you are not allowed to execute this ability.', 'abilities-api' ),
__( 'Sorry, you are not allowed to execute this ability.' ),
array( 'status' => rest_authorization_required_code() )
);
}
Expand Down Expand Up @@ -223,7 +223,7 @@ private function validate_input( $ability, $input ) {
'rest_invalid_param',
sprintf(
/* translators: %s: error message */
__( 'Invalid input parameters: %s', 'abilities-api' ),
__( 'Invalid input parameters: %s' ),
$validation_result->get_error_message()
),
array( 'status' => 400 )
Expand Down Expand Up @@ -255,7 +255,7 @@ private function validate_output( $ability, $output ) {
'rest_invalid_response',
sprintf(
/* translators: %s: error message */
__( 'Invalid response from ability: %s', 'abilities-api' ),
__( 'Invalid response from ability: %s' ),
$validation_result->get_error_message()
),
array( 'status' => 500 )
Expand Down Expand Up @@ -299,7 +299,7 @@ private function get_input_from_request( $request ) {
public function get_run_args(): array {
return array(
'input' => array(
'description' => __( 'Input parameters for the ability execution.', 'abilities-api' ),
'description' => __( 'Input parameters for the ability execution.' ),
'type' => 'object',
'default' => array(),
),
Expand All @@ -320,7 +320,7 @@ public function get_run_schema(): array {
'type' => 'object',
'properties' => array(
'result' => array(
'description' => __( 'The result of the ability execution.', 'abilities-api' ),
'description' => __( 'The result of the ability execution.' ),
'type' => 'mixed',
'context' => array( 'view' ),
'readonly' => true,
Expand Down
16 changes: 7 additions & 9 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
Tests for PHP version compatibility.
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards#Recomended-additional-rulesets
-->
<config name="testVersion" value="7.4-" />
<config name="testVersion" value="7.2-" />

<!--
Tests for WordPress version compatibility.
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties
-->
<config name="minimum_wp_version" value="6.7" />
<config name="minimum_wp_version" value="6.8" />

<!--
Load WordPress VIP Go standards
Expand All @@ -59,9 +59,8 @@
<exclude name="WordPressVIPMinimum.JS" />
</rule>
<rule ref="WordPress-Extra">
<!-- @todo: Determine a strategy on namespacing/merging into core. -->
<exclude name="WordPress.WP.I18n.MissingArgDomain" />
<exclude name="WordPress.NamingConventions.PrefixAllGlobals" />
<exclude name="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound" />
<!-- Needed to typehint, see: https://github.com/WordPress/WordPress-Coding-Standards/issues/403 -->
<exclude name="Generic.Commenting.DocComment.MissingShort" />
</rule>
Expand Down Expand Up @@ -196,21 +195,20 @@
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array">
<!-- @todo: Should we use a namespace or prefix ? -->
<element value="abilities_api" />
<element value="abilities_api_" /><!-- Hook prefix -->
<element value="WP_Ability" />
<element value="WP_Abilities" />
<element value="WP_ABILITIES_API" />
<element value="WP_REST_Abilities" />
<element value="WP_ABILITIES_API" /> <!-- Constant -->
</property>
</properties>
</rule>

<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<!-- Value: replace the text domain(s) used. -->
<element value="abilities-api" />
<!-- If flagged, remove the text-domain entirely. -->
<element value="" />
</property>
</properties>
</rule>
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ parameters:
# Configuration
level: 8
phpVersion:
min: 70400
min: 70200
max: 80300
bootstrapFiles:
- abilities-api.php
Expand Down