10up / ElasticPress

A fast and flexible search and query engine for WordPress.
https://elasticpress.io
GNU General Public License v2.0
1.24k stars 312 forks source link

Add $context to get_capability() #3866

Closed felipeelia closed 5 months ago

felipeelia commented 5 months ago

Description of the Change

Users wanting to manage synonyms-related capabilities, for example, can use the following snippet and add the manage_elasticpress_synonyms capability to their chosen role:

add_filter(
    'ep_capability',
    function ( $cacapability, $context ) {
        return ( 'synonyms' === $context ) ?
            'manage_elasticpress_synonyms' :
            $cacapability;
    },
    10,
    2
);

Closes #3787

How to test the Change

Changelog Entry

Added - Context parameter to the get_capability() function

Credits

Props @felipeelia @selim13

Checklist: