tribe_register_rest_route( string $namespace, string $route, array $args = array(), bool $override = false )

Wrapper function for register_rest_route to allow for filtering any Tribe REST API endpoint.


Parameters #

$namespace

(string) (Required) The first URL segment after core prefix. Should be unique to your package/plugin.

$route

(string) (Required) The base URL for route you are adding.

$args

(array) (Optional) Either an array of options for the endpoint, or an array of arrays for multiple methods.

Default value: array()

$override

(bool) (Optional) If the route already exists, should we override it? True overrides, false merges (with newer overriding if duplicate keys exist).

Default value: false


Top ↑

Return #

(bool) True on success, false on error.


Top ↑

Source #

File: src/functions/utils.php

	function tribe_register_rest_route( $namespace, $route, $args = array(), $override = false ) {
		/**
		 * Allow plugins to customize REST API arguments and callbacks.
		 *
		 * @param array  $args      Either an array of options for the endpoint, or an array of arrays for
		 *                          multiple methods. Default empty array.
		 * @param string $namespace The first URL segment after core prefix. Should be unique to your package/plugin.
		 * @param string $route     The base URL for route you are adding.
		 * @param bool   $override  Optional. If the route already exists, should we override it? True overrides,
		 *                          false merges (with newer overriding if duplicate keys exist). Default false.
		 *
		 * @since 4.9.12
		 */
		$args = apply_filters( 'tribe_register_rest_route_args_' . $namespace . $route, $args, $namespace, $route, $override );

		/**
		 * Allow plugins to customize REST API arguments and callbacks.
		 *
		 * @param array  $args      Either an array of options for the endpoint, or an array of arrays for
		 *                          multiple methods. Default empty array.
		 * @param string $namespace The first URL segment after core prefix. Should be unique to your package/plugin.
		 * @param string $route     The base URL for route you are adding.
		 * @param bool   $override  Optional. If the route already exists, should we override it? True overrides,
		 *                          false merges (with newer overriding if duplicate keys exist). Default false.
		 *
		 * @since 4.9.12
		 */
		$args = apply_filters( 'tribe_register_rest_route_args', $args, $namespace, $route, $override );
		return register_rest_route( $namespace, $route, $args, $override );
	}

Top ↑

Changelog #

Changelog
Version Description
4.9.12 Introduced.