Skip to content

WordPress 7.0 Enhancement Opportunities #1

Open

Description

@AceMedia

WordPress 7.0 Enhancement Plan

WP 7.0 introduces Responsive Editing Mode (device-specific block visibility), expanded contentOnly mode, a new plugin list filter, and DataForms improvements — all relevant to a role-based block access plugin. All WP7 features gated for WP6 backwards compatibility.

Version detection

function ace_block_roles_is_wp7(): bool {
    return version_compare( get_bloginfo( 'version' ), '7.0', '>=' );
}

1. Responsive Editing Mode + Block Roles — complementary visibility

WP 7.0 introduces per-block device visibility (hide/show blocks on mobile/desktop/tablet) as a new block support. Block Roles controls who can see a block in the editor by role; Responsive Editing Mode controls where it appears by device. These are complementary but should not conflict.

Action:

  • Test that Block Roles' filtering logic does not accidentally strip the new device-visibility block support attributes when restricting blocks.
  • Consider a UI enhancement: display device-visibility status alongside role-availability status in the Block Roles admin grid so administrators have a unified view of "who can use this block and on what devices".

2. contentOnly mode awareness — pattern block restrictions

WP 7.0 expands contentOnly mode to apply more broadly to patterns containing inner blocks. Block Roles' restriction logic must handle this correctly: if a block is nested inside a contentOnly pattern and a user's role should have access to it, the block should still be accessible. If a role should NOT have access, the contentOnly lock should be preserved.

Action:

  • Audit the allowed_block_types_all filter logic to verify it correctly handles blocks nested in contentOnly patterns.
  • Test on WP7: create a synced pattern with inner blocks, apply a Block Roles restriction, and confirm restricted roles cannot access the block while permitted roles can edit it via the pattern.
  • Respect the new disableContentOnlyForUnsyncedPatterns setting: when this is set to true, our restriction logic should be re-evaluated for unsynced patterns.

3. New plugin list filter — show configuration status

WP 7.0 adds a plugins_list_status_text filter in get_views() for customising the plugin list status labels. Block Roles can use this to display a summary status in the plugins list (e.g. "Block Roles: 4 roles configured").

Action (WP7+):

if ( ace_block_roles_is_wp7() ) {
    add_filter( 'plugins_list_status_text', function( $text, $status ) {
        if ( 'active' === $status ) {
            $role_count = count( ace_block_roles_get_configured_roles() );
            return sprintf( __( 'Active — %d roles configured', 'ace-block-roles' ), $role_count );
        }
        return $text;
    }, 10, 2 );
}

4. Abilities API — register block role management abilities

Action (WP7+): Register with wp_register_ability():

  • ace-block-roles/get-role-blocks — return the list of blocks allowed for a given role
  • ace-block-roles/set-role-block-access — configure block access for a role (with manage_options capability check)
  • ace-block-roles/export-config — export current block roles configuration as JSON

These make Block Roles configuration accessible via AI tooling and the Command Palette.


5. DataForms for the block/role assignment UI

WP 7.0's @wordpress/dataviews DataForms and new list/details layouts provide a native way to manage tabular data — well-suited to the block × role assignment grid. Migrating to DataForms would:

  • Reduce custom React maintenance.
  • Provide built-in search, filtering, and sorting (especially useful for large block inventories).
  • Align the UI visually with the modernised WP7 admin.

Action: Evaluate migrating the settings grid to @wordpress/dataviews on WP7+. Keep existing AJAX-based grid on WP6.


6. JSON import/export — @wordpress/scripts build tooling

WP 7.0's refactored @wordpress/scripts builds from directories and reduces Webpack dependence. Consider migrating the build config to use the new directory-based build if upgrading @wordpress/scripts as part of a WP7 compatibility pass.


Backwards compatibility note

All items are additive or defensive audits. WP6 behaviour is unchanged. WP7-only registrations are wrapped in ace_block_roles_is_wp7() and function_exists() guards.

Activity

  1. AceMedia commented on May 15, 2026

    @AceMedia
    OwnerAuthor

    🤖 WordPress AI Plugin + MCP Adapter Integration

    Block access and role management are high-value targets for the MCP Adapter and the coming WordPress AI plugin Site Agent. Exposing block role configuration as queryable MCP resources and executable tools means an AI agent can audit, apply, and explain block restrictions via natural language — something that would otherwise require manual admin work across dozens of role/block combinations.


    Built-in AI plugin features that apply here

    AI Plugin Feature Integration Opportunity
    Abilities Explorer All ace-block-roles/* abilities surface in the Abilities Explorer for admins to test and understand without writing any code
    Review Notes Register a content reviewer that flags posts containing blocks the current user's role cannot edit — editor sees a contextual warning rather than discovering restrictions at publish time
    Coming: Site Agent Natural language block role management: "Restrict the Gallery block to Editor and above" — the Site Agent calls our registered abilities to apply the change
    Coming: Workflow Automation Automate role restriction changes on a schedule or in response to events (e.g., automatically restrict experimental blocks to Admins during a deployment window)

    Register block role abilities

    add_action( 'wp_abilities_api_init', function () {
        if ( ! function_exists( 'wp_register_ability' ) ) return;
    
        wp_register_ability( 'ace-block-roles/get-all-restrictions', [
            'label'       => __( 'Get All Block Role Restrictions', 'ace-block-roles' ),
            'capability'  => 'manage_options',
            'callback'    => 'ace_block_roles_get_all_restrictions',
            'output_schema' => [
                'type'  => 'object',
                'properties' => [
                    'restrictions' => [
                        'type'  => 'array',
                        'items' => [
                            'type'       => 'object',
                            'properties' => [
                                'block_name'  => [ 'type' => 'string' ],
                                'allowed_roles' => [ 'type' => 'array', 'items' => [ 'type' => 'string' ] ],
                                'post_types'  => [ 'type' => 'array', 'items' => [ 'type' => 'string' ] ],
                            ],
                        ],
                    ],
                ],
            ],
            'meta'        => [
                'mcp' => [
                    'public' => true,
                    'type'   => 'tool',
                ],
            ],
        ] );
    
        wp_register_ability( 'ace-block-roles/set-block-restriction', [
            'label'       => __( 'Set Block Role Restriction', 'ace-block-roles' ),
            'capability'  => 'manage_options',
            'callback'    => 'ace_block_roles_set_restriction',
            'input_schema' => [
                'type'       => 'object',
                'properties' => [
                    'block_name'    => [ 'type' => 'string', 'description' => 'Block name e.g. core/gallery' ],
                    'allowed_roles' => [ 'type' => 'array', 'items' => [ 'type' => 'string' ], 'description' => 'Roles that may use this block' ],
                    'post_types'    => [ 'type' => 'array', 'items' => [ 'type' => 'string' ], 'description' => 'Post types to apply restriction on (all if omitted)' ],
                ],
                'required' => [ 'block_name', 'allowed_roles' ],
            ],
            'meta'        => [
                'mcp' => [
                    'public' => true,
                    'type'   => 'tool',
                ],
            ],
        ] );
    
        wp_register_ability( 'ace-block-roles/remove-block-restriction', [
            'label'       => __( 'Remove Block Role Restriction', 'ace-block-roles' ),
            'capability'  => 'manage_options',
            'callback'    => 'ace_block_roles_remove_restriction',
            'input_schema' => [
                'type'       => 'object',
                'properties' => [ 'block_name' => [ 'type' => 'string' ] ],
                'required'   => [ 'block_name' ],
            ],
            'meta'        => [
                'mcp' => [
                    'public' => true,
                    'type'   => 'tool',
                ],
            ],
        ] );
    
        wp_register_ability( 'ace-block-roles/audit-restrictions', [
            'label'       => __( 'Audit Block Role Configuration', 'ace-block-roles' ),
            'capability'  => 'manage_options',
            'callback'    => 'ace_block_roles_audit',
            'output_schema' => [
                'type'       => 'object',
                'properties' => [
                    'issues'       => [ 'type' => 'array', 'items' => [ 'type' => 'string' ] ],
                    'warnings'     => [ 'type' => 'array', 'items' => [ 'type' => 'string' ] ],
                    'total_blocks' => [ 'type' => 'integer' ],
                    'restricted'   => [ 'type' => 'integer' ],
                    'unrestricted' => [ 'type' => 'integer' ],
                ],
            ],
            'meta'        => [
                'mcp' => [
                    'public' => true,
                    'type'   => 'tool',
                ],
            ],
        ] );
    
        wp_register_ability( 'ace-block-roles/get-blocks-for-role', [
            'label'       => __( 'Get Allowed Blocks for Role', 'ace-block-roles' ),
            'capability'  => 'edit_posts',
            'callback'    => 'ace_block_roles_get_for_role',
            'input_schema' => [
                'type'       => 'object',
                'properties' => [ 'role' => [ 'type' => 'string', 'description' => 'WordPress role slug' ] ],
                'required'   => [ 'role' ],
            ],
            'meta'        => [
                'mcp' => [
                    'public' => true,
                    'type'   => 'tool',
                ],
            ],
        ] );
    } );

    Review Notes: warn authors about restricted blocks in their content

    if ( class_exists( '\\AI_Plugin\\Features\\Abstract_Feature' ) ) {
        class Ace_Block_Roles_Review_Feature extends \AI_Plugin\Features\Abstract_Feature {
            public function get_name(): string { return 'ace-block-roles-review'; }
            public function get_label(): string { return __( 'Block Access Review Notes', 'ace-block-roles' ); }
            public function get_description(): string {
                return __( 'Flags blocks in post content that are restricted for the current user\'s role, preventing publish-time surprises.', 'ace-block-roles' );
            }
            protected function register(): void {
                add_filter( 'ai_plugin_review_notes_categories', function ( $cats ) {
                    $cats['block-roles'] = __( 'Block Access', 'ace-block-roles' );
                    return $cats;
                } );
                add_action( 'ai_plugin_review_notes_analyze', [ $this, 'flag_restricted_blocks' ], 10, 2 );
            }
        }
        ( new Ace_Block_Roles_Review_Feature() )->boot();
    }

    MCP Adapter — block permissions as agent resources

    Abilities with mcp.public = true are auto-exposed on the default MCP server at /wp-json/mcp/mcp-adapter-default-server, so the custom server below is optional and only needed when you want a dedicated plugin-specific MCP endpoint.

    add_action( 'wp_abilities_api_init', function () {
        if ( ! function_exists( 'wp_register_ability' ) ) return;
    
        wp_register_ability( 'ace-block-roles/all-restrictions-resource', [
            'label'       => __( 'All Block Role Restrictions', 'ace-block-roles' ),
            'description' => __( 'Complete map of block → allowed roles for the site', 'ace-block-roles' ),
            'capability'  => 'manage_options',
            'callback'    => 'ace_block_roles_get_all_restrictions',
            'meta'        => [
                'mcp' => [
                    'public' => true,
                    'type'   => 'resource',
                    'uri'    => 'ace-block-roles://restrictions/all',
                ],
            ],
        ] );
    
        wp_register_ability( 'ace-block-roles/blocks-for-role-resource', [
            'label'       => __( 'Blocks Allowed for Role', 'ace-block-roles' ),
            'description' => __( 'List of blocks a specific WordPress role is allowed to use', 'ace-block-roles' ),
            'capability'  => 'edit_posts',
            'callback'    => 'ace_block_roles_mcp_get_for_role',
            'input_schema' => [
                'type'       => 'object',
                'properties' => [ 'role' => [ 'type' => 'string' ] ],
                'required'   => [ 'role' ],
            ],
            'meta'        => [
                'mcp' => [
                    'public' => true,
                    'type'   => 'resource',
                    'uri'    => 'ace-block-roles://role/{role}/blocks',
                ],
            ],
        ] );
    
    } );
    
    add_action( 'mcp_adapter_init', function ( \WP\MCP\Core\McpAdapter $adapter ) {
        $adapter->create_server(
            'ace-block-roles',
            'mcp',
            'ace-block-roles',
            'Block Role Manager',
            'Query and manage role-based block access restrictions across the site',
            'v1.0.0',
            [ \WP\MCP\Transport\HttpTransport::class ],
            null,
            null,
            [
                'ace-block-roles/get-all-restrictions',
                'ace-block-roles/set-block-restriction',
                'ace-block-roles/remove-block-restriction',
                'ace-block-roles/audit-restrictions',
                'ace-block-roles/get-blocks-for-role',
            ],
            [
                'ace-block-roles/all-restrictions-resource',
                'ace-block-roles/blocks-for-role-resource',
            ],
            []
        );
    } );

    Site Agent scenarios

    • "Show me which blocks subscribers can and can't use"
    • "Restrict the Custom HTML block to Admins only"
    • "Audit our block restrictions — are there any obvious misconfiguration issues?"
    • "What blocks are currently unrestricted? Suggest which ones should require Editor access"
    • "Copy the block restriction profile from the 'author' role and apply it to our 'contributor' role"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions