Make WordPress Core


Ignore:
Timestamp:
09/30/2025 05:06:42 PM (9 months ago)
Author:
desrosj
Message:

Grouped backports for the 4.7 branch.

  • REST API: Increase the specificity of capability checks for collections when the edit context is in use.
  • Menus: Prevent HTML in menu item titles from being rendered unexpectedly.

Merges [60814], [60815], [60816] to the 4.7 branch.

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

Location:
branches/4.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/tests/phpunit/tests/rest-api/rest-users-controller.php

    r40426 r60839  
    819819        $request->set_param( 'context', 'edit' );
    820820        $response = $this->server->dispatch( $request );
    821         $this->assertErrorResponse( 'rest_user_cannot_view', $response, 401 );
     821        $this->assertErrorResponse( 'rest_forbidden_context', $response, 401 );
    822822    }
    823823
     
    23962396    }
    23972397
     2398    /**
     2399     * Callback for map_meta_cap filter to disallow edit_user capability
     2400     *
     2401     * @param array  $caps Required capabilities.
     2402     * @param string $cap  Capability being checked.
     2403     * @return array Modified capabilities.
     2404     */
     2405    public function disallow_edit_user_cap( $caps, $cap ) {
     2406        if ( 'edit_user' === $cap ) {
     2407            return array( 'do_not_allow' );
     2408        }
     2409
     2410        return $caps;
     2411    }
     2412
     2413    /**
     2414     * Callback for map_meta_cap filter to allow edit_user capability
     2415     *
     2416     * @param array  $caps Required capabilities.
     2417     * @param string $cap  Capability being checked.
     2418     * @return array Modified capabilities.
     2419     */
     2420    public function allow_edit_user_cap( $caps, $cap ) {
     2421        if ( 'edit_user' === $cap ) {
     2422            return array();
     2423        }
     2424
     2425        return $caps;
     2426    }
     2427
    23982428    protected function allow_user_to_manage_multisite() {
    23992429        wp_set_current_user( self::$user );
Note: See TracChangeset for help on using the changeset viewer.