apply_filters( ‘wp_get_abilities_item_include’, bool $include, WP_Ability $ability, array $args )

In this article

Filters whether an individual ability should be included in the result set.

Description

Fires after the declarative filters and the caller-scoped item_include_callback.
Plugins can use this to enforce universal inclusion rules regardless of what the caller passed in $args.

Parameters

$includebool
Whether to include the ability. Default true (after declarative filters pass).
$abilityWP_Ability
The ability instance being evaluated.
$argsarray
The full $args array passed to wp_get_abilities() .
More Arguments from wp_get_abilities( … $args )Arguments to filter the returned abilities. Default empty array (returns all).
  • category string
    Filter by category slug. Only abilities whose category exactly matches the given slug are included.
  • namespace string
    Filter by ability namespace prefix. Pass the namespace without a trailing slash, e.g. 'woocommerce' matches 'woocommerce/create-order'.
  • meta array
    Filter by meta key/value pairs. All conditions must match (AND logic). Supports nested arrays for structured meta, e.g. array( 'mcp' => array( 'public' => true ) ).
  • item_include_callback callable
    Optional. A callback invoked per ability after declarative filters. Receives a WP_Ability instance, returns bool.
    Return true to include, false to exclude.
  • result_callback callable
    Optional. A callback invoked once on the full matched array. Receives WP_Ability[], must return WP_Ability[].
    Use for sorting, slicing, or reshaping the result.

Source

$include = (bool) apply_filters( 'wp_get_abilities_item_include', $include, $ability, $args );

Changelog

VersionDescription
7.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.