wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



rest_allowed_cors_methods › Filtr WordPress Hooks

Od7.2.0
Przestarzałyn/a
› apply_filters( 'rest_allowed_cors_methods', $allow_methods, $request instanceof WP_REST_Request ? $request : null )
Parametry: (2)
  • () allow_methods The list of HTTP methods to allow.
    Wymagane: Tak
  • () request The request in context, if available.
    Wymagane: Tak
Zdefiniowane na:
Codex:

Filters the list of HTTP methods advertised to REST API CORS requests.

The allowed methods are passed to the browser to specify which methods may be used in a cross-origin request to the REST API. The list is a fixed default and is not derived from the registered routes, so a site serving routes that accept other methods can advertise them here. If the response already set its own `Access-Control-Allow-Methods` header naming valid methods, `$allow_methods` is those methods instead of the default list. Entries that are not valid method tokens are dropped, and an empty list omits the header. A value that is neither an array nor a string is ignored.




Źródło

$filtered_methods = apply_filters( 'rest_allowed_cors_methods', $allow_methods, $request instanceof WP_REST_Request ? $request : null );