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
30 changes: 30 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Automatically normalize line endings.
* text=auto

# Files and directories to exclude from the generated archive (export-ignore).
# These will be omitted from GitHub/Packagist ZIP archives to keep packages small.

# Tests and test fixtures
/tests/ export-ignore

# PHP unit / static analysis configs.
/phpcs.xml.dist export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore

# Continuous Integration configs.
/.github/ export-ignore

# Node and build artifacts.
package.json export-ignore
package-lock.json export-ignore
/composer.lock export-ignore

# Don't include the dotfiles for distribution.
/.* export-ignore

# Mark docs as documentation for GitHub Linguist.
/docs/ linguist-documentation export-ignore
/CONTRIBUTING.md linguist-documentation export-ignore
/LICENSE.md linguist-documentation
/README.md linguist-documentation
Empty file removed .wordpress-org/.gitkeep
Empty file.
26 changes: 4 additions & 22 deletions abilities-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,9 @@
*/
define( 'WP_ABILITIES_API_DIR', plugin_dir_path( __FILE__ ) );

/**
* Version of the plugin.
*/
define( 'WP_ABILITIES_API_VERSION', '0.1.0' );

/**
* First the WP_Ability class that users can extend.
*/
require_once WP_ABILITIES_API_DIR . 'includes/abilities-api/class-wp-ability.php';

/**
* Then the WP_Abilities_Registry class that manages the abilities.
*/
require_once WP_ABILITIES_API_DIR . 'includes/abilities-api/class-wp-abilities-registry.php';

/**
* Then the public access functions that users can use to interact with the abilities.
*/
require_once WP_ABILITIES_API_DIR . 'includes/abilities-api.php';
require_once WP_ABILITIES_API_DIR . 'includes/bootstrap.php';

/**
* Initialize REST API controllers.
*/
require_once WP_ABILITIES_API_DIR . 'includes/rest-api/class-wp-rest-abilities-init.php';
if ( function_exists( 'add_action' ) ) {
add_action( 'rest_api_init', array( 'WP_REST_Abilities_Init', 'register_routes' ) );
}
37 changes: 24 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,44 @@
{
"name": "wordpress/abilities-api",
"description": "AI Abilities for WordPress",
"description": "AI Abilities for WordPress.",
"license": "GPL-2.0-or-later",
"type": "wordpress-plugin",
"version": "0.1.0",
"type": "library",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strongly disagree with this change. Nothing prevents anybody from using a wordpress-plugin as a library. But if anybody (including MCP Adapter or Experiments) tries to test this using Composer as a plugin dependency, they can't if it's a library.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"keywords": [
"ai",
"api",
"llm",
"abilities",
"abilities-api",
"wordpress"
],
"homepage": "https://github.com/WordPress/abilities-api/issues",
"authors": [
{
"name": "WordPress AI Team",
"homepage": "https://make.wordpress.org/ai/"
}
],
"homepage": "https://github.com/WordPress/abilities-api",
"support": {
"issues": "https://github.com/WordPress/abilities-api/issues"
"issues": "https://github.com/WordPress/abilities-api/issues",
"source": "https://github.com/WordPress/abilities-api"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"files": [
"includes/bootstrap.php"
]
},
"config": {
"sort-packages": true,
"platform": {
"php": "7.4"
},
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true,
"composer/installers": true
}
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved a few things around, so the order is similar to https://github.com/WordPress/php-ai-client/blob/trunk/composer.json. That made auditing easier for me.

"platform": {
"php": "7.4"
},
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true,
"repositories": [
{
"type": "composer",
Expand Down
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion includes/abilities-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Defines functions for managing abilities in WordPress.
*
* @package WordPress
* @subpackage Abilities API
* @subpackage Abilities_API
* @since 0.1.0
*
* phpcs:disable WordPress.NamingConventions.PrefixAllGlobals
Expand Down
37 changes: 37 additions & 0 deletions includes/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* Bootstraps the Abilities API classes and global functions.
*
* This file is autoloaded by Composer when the package is installed via the
* "files" autoload mechanism. It ensures the procedural functions defined in
* `includes/abilities-api.php` are available without requiring namespaces.
*
* @package WordPress
* @subpackage Abilities_API
* @since 0.1.0
*/

declare( strict_types = 1 );

// Version of the plugin.
if ( ! defined( 'WP_ABILITIES_API_VERSION' ) ) {
define( 'WP_ABILITIES_API_VERSION', '0.1.0' );
}

// Load core classes if they are not already defined (for non-Composer installs or direct includes).
if ( ! class_exists( 'WP_Ability' ) ) {
require_once __DIR__ . '/abilities-api/class-wp-ability.php';
}
if ( ! class_exists( 'WP_Abilities_Registry' ) ) {
require_once __DIR__ . '/abilities-api/class-wp-abilities-registry.php';
}

// Ensure procedural functions are available, too.
if ( ! function_exists( 'wp_register_ability' ) ) {
require_once __DIR__ . '/abilities-api.php';
}

// Load REST API init class for plugin bootstrap.
if ( ! class_exists( 'WP_REST_Abilities_Init' ) ) {
require_once __DIR__ . '/rest-api/class-wp-rest-abilities-init.php';
}
7 changes: 3 additions & 4 deletions includes/rest-api/class-wp-rest-abilities-init.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
/**
* REST API initialization for Abilities API.
*
* @package abilities-api
* @since 0.1.0
* @package WordPress
* @subpackage Abilities_API
* @since 0.1.0
*/

declare( strict_types = 1 );
Expand Down Expand Up @@ -31,5 +32,3 @@ public static function register_routes(): void {
$list_controller->register_routes();
}
}

add_action( 'rest_api_init', array( 'WP_REST_Abilities_Init', 'register_routes' ) );
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
/**
* REST API list controller for Abilities API.
*
* @package abilities-api
* @since 0.1.0
* @package WordPress
* @subpackage Abilities_API
* @since 0.1.0
*/

declare( strict_types = 1 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
/**
* REST API run controller for Abilities API.
*
* @package abilities-api
* @since 0.1.0
* @package WordPress
* @subpackage Abilities_API
* @since 0.1.0
*/

declare( strict_types = 1 );
Expand Down