Make WordPress Core

Changeset 44107

Timestamp:
12/13/2018 09:37:05 AM (6 years ago)
Author:
pento
Message:

REST API: Introduce controller for searching across post types.

Introduces a WP_REST_Search_Controller class which registers a /wp/v2/search endpoint. Search types are handled by extending WP_REST_Search_Handler. The default search type is WP_REST_Post_Search_Handler but can be filtered by plugins or a theme.

Merges [43739,43741] from the 5.0 branch to trunk.

Props danielbachhuber, flixos90, pento, rmccue, joehoyle.
Fixes #39965.

Location:
trunk
Files:
6 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/wp-includes/rest-api.php

    r43985 r44107  
    229229    // Comments.
    230230    $controller = new WP_REST_Comments_Controller;
     231
     232
     233
     234
     235
     236
     237
     238
     239
     240
     241
     242
     243
     244
    231245    $controller->register_routes();
    232246
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php

    r43739 r44107  
    7171
    7272                /* translators: %s: PHP class name */
    73                 _doing_it_wrong( __METHOD__, sprintf( __( 'REST search handlers must extend the %s class.' ), 'WP_REST_Search_Handler' ), '5.5.0' );
     73                _doing_it_wrong( __METHOD__, sprintf( __( 'REST search handlers must extend the %s class.' ), 'WP_REST_Search_Handler' ), '5..0' );
    7474                continue;
    7575            }
  • trunk/src/wp-settings.php

    r43985 r44107  
    235235require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-users-controller.php' );
    236236require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-comments-controller.php' );
     237
    237238require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-settings-controller.php' );
    238239require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-themes-controller.php' );
     
    242243require( ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-term-meta-fields.php' );
    243244require( ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-user-meta-fields.php' );
     245
     246
    244247
    245248$GLOBALS['wp_embed'] = new WP_Embed();
  • trunk/tests/phpunit/includes/bootstrap.php

    r43369 r44107  
    133133require dirname( __FILE__ ) . '/utils.php';
    134134require dirname( __FILE__ ) . '/spy-rest-server.php';
     135
    135136
    136137/**
  • trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php

    r43985 r44107  
    111111            '/wp/v2/comments',
    112112            '/wp/v2/comments/(?P<id>[\\d]+)',
     113
    113114            '/wp/v2/settings',
    114115            '/wp/v2/themes',
  • trunk/tests/qunit/fixtures/wp-api-generated.js

    r43985 r44107  
    34093409                }
    34103410            ]
     3411
     3412
     3413
     3414
     3415
     3416
     3417
     3418
     3419
     3420
     3421
     3422
     3423
     3424
     3425
     3426
     3427
     3428
     3429
     3430
     3431
     3432
     3433
     3434
     3435
     3436
     3437
     3438
     3439
     3440
     3441
     3442
     3443
     3444
     3445
     3446
     3447
     3448
     3449
     3450
     3451
     3452
     3453
     3454
     3455
     3456
     3457
     3458
     3459
     3460
     3461
     3462
     3463
     3464
     3465
     3466
     3467
     3468
     3469
     3470
     3471
     3472
     3473
     3474
     3475
     3476
     3477
     3478
    34113479        },
    34123480        "/wp/v2/settings": {
Note: See TracChangeset for help on using the changeset viewer.