Skip to content
WordPress Core

Client-Side Abilities API Powers WordPress 7.0

WordPress 7.0 debuts the Client-Side Abilities API, enabling dynamic browser-based interactions and plugin automation with JavaScript.

WordPress 7.0 introduces the Client-Side Abilities API, a significant enhancement to the Abilities API first rolled out in version 6.9. This addition enables plugins and developers to harness client-side capabilities like navigating the WordPress dashboard or inserting blocks directly from JavaScript. By providing a unified JavaScript interface, this API is set to change how developers build interactive experiences and integrate browser-based tools.

Key Takeaways

  • The Client-Side Abilities API extends the functionality of the server-side Abilities API introduced in WordPress 6.9.
  • It includes two packages: @wordpress/abilities for state management and @wordpress/core-abilities for WordPress integration.
  • Developers can register client-side abilities, define input/output schemas, and implement permission callbacks for granular control.
  • This API improves compatibility with browser agents, extensions, and tools like WebMCP.

What Is the Client-Side Abilities API?

The Client-Side Abilities API builds on the foundational work of the Abilities API, introduced in WordPress 6.9. While the original API focused on server-side interaction, the new JavaScript counterpart empowers developers to implement abilities directly within the browser. This capability is particularly useful for plugins requiring dynamic client-side behavior, such as navigating, inserting blocks, or interacting with browser extensions like WebMCP.

The API is divided into two packages:

  • @wordpress/abilities: A standalone state management package with no dependency on WordPress servers. This makes it versatile for both WordPress and non-WordPress projects.
  • @wordpress/core-abilities: A WordPress-specific layer that fetches server-registered abilities via REST API endpoints and integrates them with the state management package.

How Developers Can Use the API

To get started with the Client-Side Abilities API, developers must enqueue the relevant script modules within their plugins. Depending on whether the plugin interacts with server-registered abilities or only client-side ones, the approach will differ.

Enqueueing Script Modules

For plugins requiring server-registered abilities:

add_action( 'admin_enqueue_scripts', 'my_plugin_enqueue_abilities' );
function my_plugin_enqueue_abilities() {
    wp_enqueue_script_module( '@wordpress/core-abilities' );
}

This method automatically loads both @wordpress/core-abilities and @wordpress/abilities, fetching and registering server-side abilities.

For plugins needing only client-side abilities:

add_action( 'admin_enqueue_scripts', 'my_plugin_enqueue_abilities' );
function my_plugin_enqueue_abilities( $hook_suffix ) {
    if ( 'my-plugin-page' !== $hook_suffix ) {
        return;
    }
    wp_enqueue_script_module( '@wordpress/abilities' );
}

Registering Abilities

Abilities must be organized into categories before being registered. Developers can define categories and abilities using dynamic imports or standard JavaScript imports.

import { registerAbilityCategory, registerAbility } from '@wordpress/abilities';

registerAbilityCategory( 'my-plugin-actions', {
    label: 'My Plugin Actions',
    description: 'Actions provided by My Plugin',
});

registerAbility({
    name: 'my-plugin/navigate-to-settings',
    label: 'Navigate to Settings',
    description: 'Navigates to the plugin settings page',
    category: 'my-plugin-actions',
    callback: async () => {
        window.location.href = '/wp-admin/options-general.php?page=my-plugin';
        return { success: true };
    },
});

Advanced Features of the API

One standout feature of the Client-Side Abilities API is its support for input and output validation using JSON Schema (draft-04). Developers can define schemas to ensure robust data validation during ability execution. Additionally, permission callbacks allow fine-grained control over who can execute specific abilities based on user roles or capabilities.

For example:

registerAbility({
    name: 'my-plugin/admin-action',
    label: 'Admin Action',
    description: 'An action only available to administrators',
    category: 'my-plugin-actions',
    permissionCallback: () => currentUserCan( 'manage_options' ),
    callback: async () => {
        return { success: true };
    },
});

If a user fails the permission check, the API throws an error with the code ability_permission_denied, ensuring secure execution.

What This Means for WordPress Users

The introduction of the Client-Side Abilities API in WordPress 7.0 marks a significant step forward in empowering developers to create richer, browser-based interactions. For plugin authors, this API simplifies the process of integrating advanced client-side functionality without relying on heavy server-side dependencies. Agencies and freelancers working on custom solutions can now more easily implement features like dynamic navigation workflows or complex input validation directly in the browser.

For site owners, this opens the door to more responsive and interactive plugin experiences. Tools relying on AI agents or browser extensions will benefit from the standardized interface, ensuring compatibility and reducing friction during integration.

We expect the Client-Side Abilities API to play a pivotal role in enhancing automation and interactivity across the WordPress ecosystem.

Frequently Asked Questions

What is the difference between @wordpress/abilities and @wordpress/core-abilities?

@wordpress/abilities is a standalone state management package usable in any project, while @wordpress/core-abilities integrates with the WordPress server to fetch and manage server-registered abilities.

Do abilities require categories?

Yes, every ability must belong to a category. Categories help organize abilities and are registered before abilities themselves.

Can I use the Abilities API outside of WordPress?

The @wordpress/abilities package can be used in non-WordPress projects, making it versatile for broader applications.

Related News