WordPress.org

Make WordPress Core

Changeset 51882


Ignore:
Timestamp:
10/02/2021 09:43:26 PM (2 months ago)
Author:
TimothyBlynJacobs
Message:

REST API: Sort widget types by their id.

Fixes #53303.
Props spacedmonkey.

Location:
trunk
Files:
2 edited

Legend:

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

    r51786 r51882  
    238238        }
    239239
     240        ksort( $widgets );
     241
    240242        return $widgets;
    241243    }
  • trunk/tests/phpunit/tests/rest-api/rest-widget-types-controller.php

    r51657 r51882  
    127127
    128128    /**
     129     * @ticket 53303
     130     */
     131    public function test_get_items_ordering() {
     132        wp_set_current_user( self::$admin_id );
     133        $request  = new WP_REST_Request( 'GET', '/wp/v2/widget-types' );
     134        $response = rest_get_server()->dispatch( $request );
     135        $data     = $response->get_data();
     136        $this->assertGreaterThan( 1, count( $data ) );
     137        $ids    = wp_list_pluck( $data, 'id' );
     138        $sorted = $ids;
     139        sort( $sorted );
     140
     141        $this->assertSame( $sorted, $ids );
     142    }
     143
     144    /**
    129145     * @ticket 53305
    130146     */
Note: See TracChangeset for help on using the changeset viewer.