Make WordPress Core


Ignore:
Timestamp:
12/13/2018 09:37:05 AM (5 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:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/tests/qunit/fixtures/wp-api-generated.js

    r43985 r44107  
    34093409                }
    34103410            ]
     3411        },
     3412        "/wp/v2/search": {
     3413            "namespace": "wp/v2",
     3414            "methods": [
     3415                "GET"
     3416            ],
     3417            "endpoints": [
     3418                {
     3419                    "methods": [
     3420                        "GET"
     3421                    ],
     3422                    "args": {
     3423                        "context": {
     3424                            "required": false,
     3425                            "default": "view",
     3426                            "enum": [
     3427                                "view",
     3428                                "embed"
     3429                            ],
     3430                            "description": "Scope under which the request is made; determines fields present in response.",
     3431                            "type": "string"
     3432                        },
     3433                        "page": {
     3434                            "required": false,
     3435                            "default": 1,
     3436                            "description": "Current page of the collection.",
     3437                            "type": "integer"
     3438                        },
     3439                        "per_page": {
     3440                            "required": false,
     3441                            "default": 10,
     3442                            "description": "Maximum number of items to be returned in result set.",
     3443                            "type": "integer"
     3444                        },
     3445                        "search": {
     3446                            "required": false,
     3447                            "description": "Limit results to those matching a string.",
     3448                            "type": "string"
     3449                        },
     3450                        "type": {
     3451                            "required": false,
     3452                            "default": "post",
     3453                            "enum": [
     3454                                "post"
     3455                            ],
     3456                            "description": "Limit results to items of an object type.",
     3457                            "type": "string"
     3458                        },
     3459                        "subtype": {
     3460                            "required": false,
     3461                            "default": "any",
     3462                            "description": "Limit results to items of one or more object subtypes.",
     3463                            "type": "array",
     3464                            "items": {
     3465                                "enum": [
     3466                                    "post",
     3467                                    "page",
     3468                                    "any"
     3469                                ],
     3470                                "type": "string"
     3471                            }
     3472                        }
     3473                    }
     3474                }
     3475            ],
     3476            "_links": {
     3477                "self": "http://example.org/index.php?rest_route=/wp/v2/search"
     3478            }
    34113479        },
    34123480        "/wp/v2/settings": {
Note: See TracChangeset for help on using the changeset viewer.