Last active
July 11, 2023 23:51
-
-
Save kalamalahala/81c9181df5e7c6d05bee3e24e83be1ad to your computer and use it in GitHub Desktop.
Format changed by parameter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function get_sub_item( $request ) { | |
$url = $request->get_url_params(); | |
$view_id = intval( $url['id'] ); | |
$entry_id = intval( $url['s_id'] ); | |
$format = \GV\Utils::get( $url, 'format', 'json' ); | |
if (isset($_GET['gv_response_format'])) { | |
$format = $_GET['gv_response_format']; | |
} | |
$view = \GV\View::by_id( $view_id ); | |
$entry = \GV\GF_Entry::by_id( $entry_id ); | |
if ( $format === 'html' ) { | |
$renderer = new \GV\Entry_Renderer(); | |
return $renderer->render( $entry, $view, new Request( $request ) ); | |
} | |
return $this->prepare_entry_for_response( $view, $entry, $request, 'single' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://thejohnson.group/wp-json/gravityview/v1/views/22221/entries/55287?gv_response_format=html
Setting format via GET Parameter