Skip to content
Docs
Get RestroPress

Filter

rpress_api_output_format

Updated
On this page

Filters the output format of an API response.

Runs in RPRESS_API::get_output_format(). The value is the 'format' query variable of the request, or 'json' when it is absent. The built-in formats are 'json' and 'xml'; any other value is passed to the rpress_api_output_{$format} action so extensions can render it.

Parameters#

ParameterTypeDescription
$formatstringRequested output format, 'json' by default.

Return value#

string. The format to use for the response.

Example#

function my_api_output_format( $format ) {
	return in_array( $format, array( 'json', 'xml', 'csv' ), true ) ? $format : 'json';
}
add_filter( 'rpress_api_output_format', 'my_api_output_format', 10, 1 );

Source#

Applied in:

  • includes/api/class-rpress-api.php (line 1434), in RPRESS_API::get_output_format()
  • includes/class-rpress-api.php (line 385), in RPRESS_API::get_output_format()

See also#

Was this page helpful?