Skip to content
Draft
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: 0 additions & 2 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
/node_modules
/resources/frontend/css/*.map
/tests
/vendor/autoload.php
/vendor/composer
/vendor/convertkit/convertkit-wordpress-libraries/.git
/vendor/convertkit/convertkit-wordpress-libraries/.github
/vendor/convertkit/convertkit-wordpress-libraries/tests
Expand Down
15 changes: 14 additions & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,22 @@ jobs:
tools: cs2pr

# Installs wp-browser, Codeception, PHP CodeSniffer and anything else needed to run tests.
# --ignore-platform-req=php is required as wordpress/mcp-adapter otherwise won't install
# on PHP 7.2 and 7.3, resulting in composer errors.
- name: Run Composer
working-directory: ${{ env.PLUGIN_DIR }}
run: composer update
run: |
if [[ "${{ matrix.php-versions }}" == "7.2" || "${{ matrix.php-versions }}" == "7.3" ]]; then
composer update --ignore-platform-req=php
else
composer update
fi

# Remove the wordpress/mcp-adapter package. We don't need it for coding standards, and composer
# commands will fail if it's installed and using PHP 7.2 or 7.3.
- name: Remove wordpress/mcp-adapter
working-directory: ${{ env.PLUGIN_DIR }}
run: composer remove wordpress/mcp-adapter --no-update

- name: Build PHP Autoloader
working-directory: ${{ env.PLUGIN_DIR }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ jobs:
"resources/frontend/css/frontend.css"
"resources/frontend/js/dist/frontend.min.asset.php"
"resources/frontend/js/dist/frontend.min.js"
"vendor/autoload.php"
"vendor/convertkit/convertkit-wordpress-libraries/src/class-convertkit-api-traits.php"
"vendor/convertkit/convertkit-wordpress-libraries/src/class-convertkit-api-v4.php"
"vendor/convertkit/convertkit-wordpress-libraries/src/class-convertkit-log.php"
"vendor/convertkit/convertkit-wordpress-libraries/src/class-convertkit-resource-v4.php"
"vendor/convertkit/convertkit-wordpress-libraries/src/class-convertkit-review-request.php"
"vendor/wordpress/mcp-adapter/mcp-adapter.php"
)

for file in "${files[@]}"; do
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests-backward-compat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,13 @@ jobs:
"resources/frontend/css/frontend.css"
"resources/frontend/js/dist/frontend.min.asset.php"
"resources/frontend/js/dist/frontend.min.js"
"vendor/autoload.php"
"vendor/convertkit/convertkit-wordpress-libraries/src/class-convertkit-api-traits.php"
"vendor/convertkit/convertkit-wordpress-libraries/src/class-convertkit-api-v4.php"
"vendor/convertkit/convertkit-wordpress-libraries/src/class-convertkit-log.php"
"vendor/convertkit/convertkit-wordpress-libraries/src/class-convertkit-resource-v4.php"
"vendor/convertkit/convertkit-wordpress-libraries/src/class-convertkit-review-request.php"
"vendor/wordpress/mcp-adapter/mcp-adapter.php"
)

for file in "${files[@]}"; do
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,14 @@ jobs:
working-directory: ${{ env.PLUGIN_DIR }}
run: composer update

# Install the WordPress MCP Adapter, which requires PHP 7.4+. We don't
# include it in composer.json because the Plugin must support PHP 7.1+,
# and Composer cannot conditionally require packages by PHP version.
# All test matrix entries run on PHP 7.4+, so this is always safe here.
- name: Install MCP Adapter
working-directory: ${{ env.PLUGIN_DIR }}
run: composer require wordpress/mcp-adapter:^0.5.0

# Build the frontend CSS and JS assets
- name: Run npm
working-directory: ${{ env.PLUGIN_DIR }}
Expand All @@ -350,11 +358,13 @@ jobs:
"resources/frontend/css/frontend.css"
"resources/frontend/js/dist/frontend.min.asset.php"
"resources/frontend/js/dist/frontend.min.js"
"vendor/autoload.php"
"vendor/convertkit/convertkit-wordpress-libraries/src/class-convertkit-api-traits.php"
"vendor/convertkit/convertkit-wordpress-libraries/src/class-convertkit-api-v4.php"
"vendor/convertkit/convertkit-wordpress-libraries/src/class-convertkit-log.php"
"vendor/convertkit/convertkit-wordpress-libraries/src/class-convertkit-resource-v4.php"
"vendor/convertkit/convertkit-wordpress-libraries/src/class-convertkit-review-request.php"
"vendor/wordpress/mcp-adapter/mcp-adapter.php"
)

for file in "${files[@]}"; do
Expand Down
2 changes: 0 additions & 2 deletions .scripts/create-plugin-zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ zip -r convertkit.zip . \
-x ".wordpress-org/*" \
-x "log/*" \
-x "tests/*" \
-x "vendor/composer/*" \
-x "vendor/convertkit/convertkit-wordpress-libraries/.github" \
-x "vendor/convertkit/convertkit-wordpress-libraries/tests/*" \
-x "vendor/convertkit/convertkit-wordpress-libraries/composer.json" \
-x "vendor/autoload.php" \
-x "*.distignore" \
-x "*.env.*" \
-x ".gitignore" \
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"type": "project",
"license": "GPLv3",
"require": {
"convertkit/convertkit-wordpress-libraries": "2.1.6"
"convertkit/convertkit-wordpress-libraries": "2.1.6",
"wordpress/mcp-adapter": "^0.5.0"
},
"require-dev": {
"php-webdriver/webdriver": "^1.0",
Expand Down
13 changes: 7 additions & 6 deletions includes/class-wp-convertkit.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,13 @@ private function initialize_global() {
$this->classes['broadcasts_importer'] = new ConvertKit_Broadcasts_Importer();
$this->classes['elementor'] = new ConvertKit_Elementor();
$this->classes['gutenberg'] = new ConvertKit_Gutenberg();
$this->classes['media_library'] = new ConvertKit_Media_Library();
$this->classes['output_restrict_content'] = new ConvertKit_Output_Restrict_Content();
$this->classes['review_request'] = new ConvertKit_Review_Request( 'Kit', 'convertkit', CONVERTKIT_PLUGIN_PATH );
$this->classes['preview_output'] = new ConvertKit_Preview_Output();
$this->classes['setup'] = new ConvertKit_Setup();
$this->classes['shortcodes'] = new ConvertKit_Shortcodes();
$this->classes['mcp'] = new ConvertKit_MCP();
$this->classes['media_library'] = new ConvertKit_Media_Library();
$this->classes['output_restrict_content'] = new ConvertKit_Output_Restrict_Content();
$this->classes['review_request'] = new ConvertKit_Review_Request( 'Kit', 'convertkit', CONVERTKIT_PLUGIN_PATH );
$this->classes['preview_output'] = new ConvertKit_Preview_Output();
$this->classes['setup'] = new ConvertKit_Setup();
$this->classes['shortcodes'] = new ConvertKit_Shortcodes();

/**
* Initialize integration classes for the frontend web site.
Expand Down
24 changes: 24 additions & 0 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,30 @@ function convertkit_get_form_importers() {

}

/**
* Helper method to get registered abilities.
*
* @since 3.4.0
*
* @return array Abilities.
*/
function convertkit_get_abilities() {

$abilities = array();

/**
* Registers abilities for the Kit Plugin.
*
* @since 3.4.0
*
* @param array $abilities Abilities.
*/
$abilities = apply_filters( 'convertkit_abilities', $abilities );

return $abilities;

}

/**
* Helper method to return the Plugin Settings Link
*
Expand Down
168 changes: 168 additions & 0 deletions includes/mcp/class-convertkit-mcp-ability.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
<?php
/**
* Kit MCP Ability base class.
*
* @package ConvertKit
* @author ConvertKit
*/

/**
* Abstract base for all Kit Plugin abilities exposed via the WordPress Abilities
* API and MCP Adapter.
*
* @package ConvertKit
* @author ConvertKit
*/
abstract class ConvertKit_MCP_Ability {

/**
* Sets whether the ability is readonly.
*
* @since 3.4.0
*
* @var bool
*/
private $readonly = false;

/**
* Sets whether the ability is destructive.
*
* @since 3.4.0
*
* @var bool
*/
private $destructive = false;

/**
* Sets whether the ability is idempotent.
*
* @since 3.4.0
*
* @var bool
*/
private $idempotent = false;

/**
* Returns the ability name, prefixed with `kit/` (e.g. `kit/form-insert`).
*
* @since 3.4.0
*
* @return string
*/
abstract public function get_name();

/**
* Returns the arguments array passed to wp_register_ability().
*
* @since 3.4.0
*
* @return array
*/
public function get_ability_args() {

return array(
'label' => $this->get_label(),
'description' => $this->get_description(),
'category' => $this->get_category(),
'input_schema' => $this->get_input_schema(),
'output_schema' => $this->get_output_schema(),
'permission_callback' => array( $this, 'permission_callback' ),
'execute_callback' => array( $this, 'execute_callback' ),
'meta' => array(
'annotations' => $this->get_annotations(),
),
);

}

/**
* Returns the ability's human-readable label.
*
* @since 3.4.0
*
* @return string
*/
abstract public function get_label();

/**
* Returns the ability's human-readable description.
*
* @since 3.4.0
*
* @return string
*/
abstract public function get_description();

/**
* Returns the ability's category.
*
* @since 3.4.0
*
* @return string
*/
public function get_category() {

return 'kit';

}

/**
* Returns the ability's input JSON Schema.
*
* @since 3.4.0
*
* @return array
*/
abstract public function get_input_schema();

/**
* Returns the ability's output JSON Schema.
*
* @since 3.4.0
*
* @return array
*/
abstract public function get_output_schema();

/**
* Returns the MCP annotations for this ability.
*
* Defaults to a non-readonly, non-destructive, non-idempotent action.
* Subclasses override the returned array to set the appropriate hints.
*
* @since 3.4.0
*
* @return array
*/
public function get_annotations() {

return array(
'title' => $this->get_label(),
'readonly' => $this->readonly,
'destructive' => $this->destructive,
'idempotent' => $this->idempotent,
);

}

/**
* Permission callback for this ability.
*
* @since 3.4.0
*
* @param array $input Ability input.
* @return bool|WP_Error
*/
abstract public function permission_callback( $input );

/**
* Execute callback for this ability.
*
* @since 3.4.0
*
* @param array $input Ability input.
* @return array|WP_Error
*/
abstract public function execute_callback( $input );

}
Loading
Loading