Skip to main content

GravityKit\GravityView\Request\Request

The Request abstract class.

Knows more about the request than anyone else.

Since:

  • 2.0
  • 3.0.0 (Migrated to GravityKit\GravityView\Request namespace.)

Source: src/Request/Request.php:25

Details​

  • Kind: class
  • Namespace: GravityKit\GravityView\Request

Methods​

MethodDescription
__construct()Class constructor.
get_arguments()Returns the arguments this request carries.
is_renderable()Whether this request is something that is renderable.
is_admin()Check if WordPress is_admin(), and make sure not DOING_AJAX.
is_frontend()This is the frontend.
is_add_oembed_preview()Is this the Add Media / From URL preview request?
is_ajax()Is this an AJAX call in progress?
is_rest()Is this a REST request? Call after parse_request.
is_view()The current $post is a View, no?
is_entry()Checks whether this is a single entry request
is_edit_entry()Checks whether this an edit entry request.
is_search()Checks whether this an entry search request.
is_search_pristine()Whether this request is pristine for the given View: no search-bar argument, empty or

Method Reference​

__construct()​

public function __construct()

Class constructor.

Since: 2.0

Source: src/Request/Request.php:31

get_arguments()​

public function get_arguments(): array

Returns the arguments this request carries.

Defaults to the ambient HTTP request, read from the superglobal the configured search method names rather than the HTTP verb. Transports that transmit their own arguments (CLI, a mocked render) override this, and their answer is authoritative even when empty.

Returns​

  • array<string, — mixed> The arguments.

Since: 3.5.0

Source: src/Request/Request.php:44

is_renderable()​

public function is_renderable()

Whether this request is something that is renderable.

Returns​

  • bool — Yes or no.

Since: 2.5.2

Source: src/Request/Request.php:60

is_admin()​

public static function is_admin()

Check if WordPress is_admin(), and make sure not DOING_AJAX.

Returns​

  • boolean

Source: src/Request/Request.php:84

is_frontend()​

public static function is_frontend()

This is the frontend.

Returns​

  • boolean — True or false.

Source: src/Request/Request.php:96

is_add_oembed_preview()​

public static function is_add_oembed_preview()

Is this the Add Media / From URL preview request?

Will not work in WordPress 4.8+

Returns​

  • boolean

Source: src/Request/Request.php:107

is_ajax()​

public static function is_ajax()

Is this an AJAX call in progress?

Returns​

  • boolean

Source: src/Request/Request.php:117

is_rest()​

public static function is_rest()

Is this a REST request? Call after parse_request.

Returns​

  • boolean

Source: src/Request/Request.php:126

is_view()​

public function is_view( $return_view=true )

The current $post is a View, no?

Parameters​

NameTypeDefaultDescription
$return_viewbooltrueWhether to return a View object or boolean.

Returns​

  • \GV\View | bool — If the global $post is a View, returns the View or true, depending on $return_view. If not a View, returns false.

Since:

  • 2.0
  • 2.16 (Added $return_view parameter.)

Source: src/Request/Request.php:141

is_entry()​

public function is_entry( $form_id=0 )

Checks whether this is a single entry request

Parameters​

NameTypeDefaultDescription
$form_idint0The form ID, since slugs can be non-unique. Default: 0.

Returns​

  • \GV\GF_Entry | false — The entry requested or false.

Since: 2.0

Source: src/Request/Request.php:160

is_edit_entry()​

public function is_edit_entry( $form_id=0 )

Checks whether this an edit entry request.

Parameters​

NameTypeDefaultDescription
$form_idint0The form ID, since slugs can be non-unique. Default: 0.

Returns​

  • \GV\Entry | false — The entry requested or false.

Since: 2.0

Source: src/Request/Request.php:327

public function is_search( $view=null )

Checks whether this an entry search request.

Parameters​

NameTypeDefaultDescription
$view\GravityKit\GravityView\View\View | int | nullnullThe View (or its ID) to scope the answer to, if known.

Returns​

  • boolean — True if this is a search request.

Since: 2.0

Source: src/Request/Request.php:361

is_search_pristine()​

public function is_search_pristine( $view ): bool

Whether this request is pristine for the given View: no search-bar argument, empty or

not, applies to it, and no scope parameter names it.

Parameters​

NameTypeDefaultDescription
$view\GravityKit\GravityView\View\View | intThe View, or its ID.

Returns​

  • bool

Since: 3.5.0

Source: src/Request/Request.php:385