Make WordPress Core


Ignore:
Timestamp:
09/30/2025 03:49:18 PM (11 months ago)
Author:
johnbillion
Message:

REST API: Increase the specificity of capability checks for collections when the edit context is in use.

The edit access in now taken into account for each individual post, term, or user in the response.

Props andraganescu, desrosj, ehti, hurayraiit, iandunn, joehoyle, johnbillion, jorbin, mnelson4, noisysocks, peterwilsoncc, rmccue, timothyblynjacobs, vortfu, whyisjake, zieladam.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php

    r59970 r60814  
    366366                        $response = array();
    367367                        foreach ( $query_result as $term ) {
     368                                if ( 'edit' === $request['context'] && ! current_user_can( 'edit_term', $term->term_id ) ) {
     369                                        continue;
     370                                }
     371
    368372                                $data       = $this->prepare_item_for_response( $term, $request );
    369373                                $response[] = $this->prepare_response_for_collection( $data );
Note: See TracChangeset for help on using the changeset viewer.