Skip to content
Open
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
5 changes: 4 additions & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,12 @@ jobs:
tools: cs2pr

# Installs wp-browser, Codeception, PHP CodeSniffer and anything else needed to run tests.
# jq is used to remove the wordpress/mcp-adapter package from composer.json, as it requires PHP 7.4+.
- name: Run Composer
working-directory: ${{ env.PLUGIN_DIR }}
run: composer update
run: |
jq 'del(.require."wordpress/mcp-adapter")' composer.json > composer.json.tmp && mv composer.json.tmp composer.json
composer update

# Installs WordPress scripts for CSS and JS Coding Standards.
- name: Run npm install
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: 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
2 changes: 1 addition & 1 deletion admin/section/class-convertkit-admin-section-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ abstract class ConvertKit_Admin_Section_Base {
*
* @since 1.9.6
*
* @var false|ConvertKit_Settings|ConvertKit_ContactForm7_Settings|ConvertKit_Wishlist_Settings|ConvertKit_Settings_Restrict_Content|ConvertKit_Settings_Broadcasts|ConvertKit_Forminator_Settings
* @var false|ConvertKit_Settings|ConvertKit_ContactForm7_Settings|ConvertKit_Wishlist_Settings|ConvertKit_Settings_Restrict_Content|ConvertKit_Settings_Broadcasts|ConvertKit_Forminator_Settings|ConvertKit_Settings_MCP
*/
public $settings;

Expand Down
4 changes: 2 additions & 2 deletions admin/section/class-convertkit-admin-section-broadcasts.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public function __construct() {
$this->settings_key = $this->settings::SETTINGS_NAME;

// Define the programmatic name, Title and Tab Text.
$this->name = 'broadcasts';
$this->title = __( 'Broadcasts', 'convertkit' );
$this->name = $this->settings->get_name();
$this->title = $this->settings->get_title();
$this->tab_text = __( 'Broadcasts', 'convertkit' );

// Identify that this is beta functionality.
Expand Down
4 changes: 2 additions & 2 deletions admin/section/class-convertkit-admin-section-general.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public function __construct() {
$this->settings_key = $this->settings::SETTINGS_NAME;

// Define the programmatic name, Title and Tab Text.
$this->name = 'general';
$this->title = __( 'General Settings', 'convertkit' );
$this->name = $this->settings->get_name();
$this->title = $this->settings->get_title();
$this->tab_text = __( 'General', 'convertkit' );

// Define settings sections.
Expand Down
176 changes: 176 additions & 0 deletions admin/section/class-convertkit-admin-section-mcp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
<?php
/**
* ConvertKit Settings MCP Settings class.
*
* @package ConvertKit
* @author ConvertKit
*/

/**
* Registers MCP Settings that can be edited at Settings > Kit > MCP.
*
* @package ConvertKit
* @author ConvertKit
*/
class ConvertKit_Admin_Section_MCP extends ConvertKit_Admin_Section_Base {

/**
* Constructor.
*
* @since 3.4.0
*/
public function __construct() {

// Define the class that reads/writes settings.
$this->settings = new ConvertKit_Settings_MCP();

// Define the settings key.
$this->settings_key = $this->settings::SETTINGS_NAME;

// Define the programmatic name, Title and Tab Text.
$this->name = 'mcp';
$this->title = __( 'MCP', 'convertkit' );
$this->tab_text = __( 'MCP', 'convertkit' );

// Identify that this is beta functionality.
$this->is_beta = true;

// Define settings sections.
$this->settings_sections = array(
'general' => array(
'title' => $this->title,
'callback' => array( $this, 'print_section_info' ),
'wrap' => true,
),
);

// Register and maybe output notices for this settings screen, and the Intercom messenger.
if ( $this->on_settings_screen( $this->name ) ) {
add_action( 'convertkit_settings_base_render_before', array( $this, 'maybe_output_notices' ) );
}

// Enqueue scripts and CSS.
add_action( 'convertkit_admin_settings_enqueue_scripts', array( $this, 'enqueue_scripts' ) );

parent::__construct();

}

/**
* Enqueues scripts for the Settings > MCP screen.
*
* @since 3.4.0
*
* @param string $section Settings section / tab (general|tools|restrict-content|broadcasts|mcp).
*/
public function enqueue_scripts( $section ) {

// Bail if we're not on the MCP section.
if ( $section !== $this->name ) {
return;
}

// Enqueue JS.
wp_enqueue_script( 'convertkit-admin-settings-conditional-display', CONVERTKIT_PLUGIN_URL . 'resources/backend/js/settings-conditional-display.js', array( 'jquery' ), CONVERTKIT_PLUGIN_VERSION, true );

}

/**
* Registers settings fields for this section.
*
* @since 3.4.0
*/
public function register_fields() {

// Enable.
add_settings_field(
'enabled',
__( 'Enable MCP Server', 'convertkit' ),
array( $this, 'enabled_callback' ),
$this->settings_key,
$this->name,
array(
'name' => 'enabled',
'label_for' => 'enabled',
'label' => __( 'When enabled, allows AI clients to connect to the Kit Plugin using MCP.', 'convertkit' ),
'description' => sprintf(
'%s<br /><code>%s</code>',
__( 'Go to your AI tool to add a custom connector by pasting this URL to connect to this plugin:', 'convertkit' ),
get_site_url() . '/wp-json/kit/mcp/v1'
),
)
);

}

/**
* Prints help info for this section
*
* @since 3.4.0
*/
public function print_section_info() {

?>
<span class="convertkit-beta-label"><?php esc_html_e( 'Beta', 'convertkit' ); ?></span>
<p class="description"><?php esc_html_e( 'Defines whether AI clients can connect to the Kit Plugin using MCP.', 'convertkit' ); ?></p>
<?php

}


/**
* Returns the URL for the ConvertKit documentation for this setting section.
*
* @since 3.4.0
*
* @return string Documentation URL.
*/
public function documentation_url() {

return '#';

}

/**
* Renders the input for the Enable setting.
*
* @since 3.4.0
*
* @param array $args Setting field arguments (name,description).
*/
public function enabled_callback( $args ) {

// Output field.
$this->output_checkbox_field(
$args['name'],
'on',
$this->settings->enabled(),
$args['label'],
$args['description'],
array( 'convertkit-conditional-display' )
);

}

}

// Bootstrap.
add_filter(
'convertkit_admin_settings_register_sections',
function ( $sections ) {

// Don't register the MCP section if the Abilities API is not available (WordPress < 6.9).
if ( ! function_exists( 'wp_register_ability' ) ) {
return $sections;
}

// Don't register the MCP section if PHP 7.4+ is not installed.
if ( version_compare( PHP_VERSION, '7.4', '<' ) ) {
return $sections;
}

$sections['mcp'] = new ConvertKit_Admin_Section_MCP();
return $sections;

}
);
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
16 changes: 16 additions & 0 deletions includes/blocks/class-convertkit-block-broadcasts.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public function __construct() {
// Register this as a Gutenberg block in the ConvertKit Plugin.
add_filter( 'convertkit_blocks', array( $this, 'register' ) );

// Register this block's MCP abilities.
add_filter( 'convertkit_abilities', array( $this, 'register_abilities' ) );

// Enqueue scripts and styles for this Gutenberg Block in the editor and frontend views.
add_action( 'convertkit_gutenberg_enqueue_scripts_editor_and_frontend', array( $this, 'enqueue_scripts' ) );
add_action( 'convertkit_gutenberg_enqueue_styles_editor_and_frontend', array( $this, 'enqueue_styles' ) );
Expand Down Expand Up @@ -171,6 +174,19 @@ public function get_title() {

}

/**
* Returns this block's plural title.
*
* @since 3.4.0
*
* @return string
*/
public function get_title_plural() {

return __( 'Kit Broadcasts', 'convertkit' );

}

/**
* Returns this block's icon.
*
Expand Down
16 changes: 16 additions & 0 deletions includes/blocks/class-convertkit-block-form-trigger.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public function __construct() {
// Register this as a Gutenberg block in the ConvertKit Plugin.
add_filter( 'convertkit_blocks', array( $this, 'register' ) );

// Register this block's MCP abilities.
add_filter( 'convertkit_abilities', array( $this, 'register_abilities' ) );

// Enqueue scripts and styles for this Gutenberg Block in the editor and frontend views.
add_action( 'convertkit_gutenberg_enqueue_styles_editor_and_frontend', array( $this, 'enqueue_styles' ) );

Expand Down Expand Up @@ -73,6 +76,19 @@ public function get_title() {

}

/**
* Returns this block's plural title.
*
* @since 3.4.0
*
* @return string
*/
public function get_title_plural() {

return __( 'Kit Form Triggers', 'convertkit' );

}

/**
* Returns this block's icon.
*
Expand Down
16 changes: 16 additions & 0 deletions includes/blocks/class-convertkit-block-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public function __construct() {
// Register this as a Gutenberg block in the ConvertKit Plugin.
add_filter( 'convertkit_blocks', array( $this, 'register' ) );

// Register this block's MCP abilities.
add_filter( 'convertkit_abilities', array( $this, 'register_abilities' ) );

// Enqueue scripts for this Gutenberg Block in the editor view.
add_action( 'convertkit_gutenberg_enqueue_scripts', array( $this, 'enqueue_scripts_editor' ) );

Expand Down Expand Up @@ -101,6 +104,19 @@ public function get_title() {

}

/**
* Returns this block's plural title.
*
* @since 3.4.0
*
* @return string
*/
public function get_title_plural() {

return __( 'Kit Forms', 'convertkit' );

}

/**
* Returns this block's icon.
*
Expand Down
16 changes: 16 additions & 0 deletions includes/blocks/class-convertkit-block-product.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public function __construct() {
// Register this as a Gutenberg block in the ConvertKit Plugin.
add_filter( 'convertkit_blocks', array( $this, 'register' ) );

// Register this block's MCP abilities.
add_filter( 'convertkit_abilities', array( $this, 'register_abilities' ) );

// Enqueue scripts and styles for this Gutenberg Block in the editor and frontend views.
add_action( 'convertkit_gutenberg_enqueue_scripts_editor_and_frontend', array( $this, 'enqueue_scripts' ) );
add_action( 'convertkit_gutenberg_enqueue_styles_editor_and_frontend', array( $this, 'enqueue_styles' ) );
Expand Down Expand Up @@ -95,6 +98,19 @@ public function get_title() {

}

/**
* Returns this block's plural title.
*
* @since 3.4.0
*
* @return string
*/
public function get_title_plural() {

return __( 'Kit Products', 'convertkit' );

}

/**
* Returns this block's icon.
*
Expand Down
Loading
Loading