Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Sep 9, 2025

This is an AI-generated experiment.

It's mostly to start the conversation using another source of input.


This PR implements comprehensive filtering functionality for the WordPress Abilities API to address the challenge of managing large numbers of registered abilities from core and plugins.

What's New

Core Filtering System

  • New WP_Abilities_Query class: Provides a WordPress-style query interface for filtering abilities
  • Enhanced wp_get_abilities() function: Now accepts optional query parameters while maintaining full backward compatibility
  • REST API filtering: All filtering options are available via REST API query parameters

Filtering Options Available

Namespace filtering: Filter abilities by plugin/namespace prefix

$abilities = wp_get_abilities( array( 'namespace' => 'my-plugin' ) );

Text search: Search abilities by label or description (case-insensitive)

$abilities = wp_get_abilities( array( 'search' => 'math' ) );

Schema presence filtering: Filter by input/output schema availability

$abilities = wp_get_abilities( array( 'has_input_schema' => true ) );

Meta query filtering: WordPress-style meta queries with multiple operators

$abilities = wp_get_abilities( array(
    'meta_query' => array(
        array(
            'key'   => 'category',
            'value' => 'ai',
        ),
    ),
) );

Combined filtering: All filters can be used together

$abilities = wp_get_abilities( array(
    'namespace'        => 'my-plugin',
    'search'           => 'process',
    'has_input_schema' => true,
) );

REST API Integration

The REST API now supports all filtering options via query parameters:

GET /wp-json/wp/v2/abilities?namespace=my-plugin&search=math&has_input_schema=true

Backward Compatibility

The changes are fully backward compatible:

  • wp_get_abilities() without parameters continues to return all abilities
  • Existing REST API endpoints work unchanged
  • No breaking changes to existing functionality

Implementation Details

  • Performance-conscious: Filtering is done in-memory after loading abilities
  • Type-safe: Full PHPDoc annotations and strict typing
  • Standards-compliant: Passes WordPress coding standards
  • Well-tested: Comprehensive test coverage included
  • Documented: Complete documentation with examples

This implementation follows WordPress conventions (similar to WP_Query, WP_User_Query) and provides the scalability needed for managing abilities in environments with many registered items.

Fixes #38.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI assigned Copilot and gziolo Sep 9, 2025
Copy link
Author

Copilot AI commented Sep 9, 2025

@gziolo 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

@Copilot Copilot AI changed the title [WIP] Proposal: Add a convienient way to filter the list of all registered abilities Add filtering capabilities to WordPress Abilities API Sep 9, 2025
@Copilot Copilot AI requested a review from gziolo September 9, 2025 07:23
Copilot finished work on behalf of gziolo September 9, 2025 07:23
@gziolo gziolo added [Type] Enhancement New feature or request [Status] In Progress Assigned work scheduled labels Sep 9, 2025
@gziolo gziolo changed the title Add filtering capabilities to WordPress Abilities API Experiment: Add filtering capabilities to WordPress Abilities API Sep 9, 2025
@gziolo gziolo changed the title Experiment: Add filtering capabilities to WordPress Abilities API 🤖 Experiment: Add filtering capabilities to WordPress Abilities API Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] In Progress Assigned work scheduled [Type] Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: Add a convienient way to filter the list of all registered abilities
2 participants