Skip to main content

GV\View

Source: future/includes/class-gv-view.php:30

Details

  • Kind: class

  • Namespace: GV

  • Implements: ArrayAccess

Properties

PropertyTypeDescription
$settings\GV\View_SettingsThe settings.
$widgets\GV\Widget_CollectionThe widgets attached here.
$form\GV\GF_Form | \GV\FormThe backing form for this view. Contains the form that is sourced for entries in this view.
$fields\GV\Field_CollectionThe fields for this view. Contains all the fields that are attached to this view.
$joins\GV\Join[]The joins for all sources in this view.
$unions\GV\Field[][]The unions for all sources in this view. An array of fields grouped by form_id keyed by main field_id: array( $form_id => array( $field_id => $field, $field_id => $field, ) )

Methods

MethodDescription
__construct()The constructor.
add_rewrite_endpoint()Add extra rewrite endpoints.
content()A renderer filter for the View post type content.
can_render()Checks whether this view can be accessed or not.
get_joins()Get joins associated with a view
get_joined_forms()Get joined forms associated with a view
get_unions()Get unions associated with a view
from_post()Construct a \GV\View instance from a \WP_Post.
by_id()Construct a \GV\View instance from a post ID.
get_source()Gets the source of the field.
exists()Determines if a view exists to begin with.
push_rendering()Starts tracking that a View is being rendered.
pop_rendering()Stops tracking that a View is being rendered
is_rendering()Checks if a View is currently being rendered (embedded View detection).
get_current_rendering()Returns the currently rendering View ID (the most recent one).
get_rendering_stack()Returns all currently rendering View IDs.
is_primary_view()Checks if View is the primary (first) rendering View.
is_embedded_view()Checks if View is embedded (not the first in stack).
get_parent_view()Returns the parent View of an embedded View.
get_rendering_depth()Returns the rendering depth of a View (how many levels deep it's nested).
get_entries()Retrieve the entries for the current view and request.
template_redirect()Last chance to configure the output.
get_query_class()Return the query class for this View.
restrict()Restrict View access to specific capabilities.
set_anchor_id()Sets the anchor ID of a View, without the prefix.
get_anchor_id()Returns the anchor ID to be used in the View container HTML id attribute.
get_post()Return associated WP post
get_validation_secret()Calculates and returns the View's validation secret.
validate_secret()Returns whether the provided secret validates for this View.
get_shortcode()Returns the shortcode for this View.

Method Reference

__construct()

public function __construct()

The constructor.

Source: future/includes/class-gv-view.php:134

add_rewrite_endpoint()

public static function add_rewrite_endpoint()

Add extra rewrite endpoints.

Returns

  • void

Source: future/includes/class-gv-view.php:275

content()

public static function content( $content )

A renderer filter for the View post type content.

Parameters

NameTypeDefaultDescription
$contentstringShould be empty, as we don't store anything there.

Returns

  • string — $content The view content as output by the renderers.

Source: future/includes/class-gv-view.php:308

can_render()

public function can_render( $context=null, $request=null )

Checks whether this view can be accessed or not.

Parameters

NameTypeDefaultDescription
$contextstring[]nullThe context we're asking for access from. Can any and as many of one of: edit An edit context. single A single context. cpt The custom post type single page accessed. shortcode Embedded as a shortcode. oembed Embedded as an oEmbed. rest A REST call.
$request\GV\RequestnullThe request

Returns

  • bool | \WP_Error — An error if this View shouldn't be rendered here.

Source: future/includes/class-gv-view.php:425

get_joins()

public static function get_joins( $post )

Get joins associated with a view

Parameters

NameTypeDefaultDescription
$post\WP_PostGravityView CPT to get joins for

Returns

Since: 2.0.11

Source: future/includes/class-gv-view.php:536

get_joined_forms()

public static function get_joined_forms( $post_id )

Get joined forms associated with a view

In no particular order.

Parameters

NameTypeDefaultDescription
$post_idintID of the View

Returns

Since:

Source: future/includes/class-gv-view.php:585

get_unions()

public static function get_unions( $post )

Get unions associated with a view

Parameters

NameTypeDefaultDescription
$post\WP_PostGravityView CPT to get unions for

Returns

Since: 2.2.2

Source: future/includes/class-gv-view.php:639

from_post()

public static function from_post( $post )

Construct a \GV\View instance from a \WP_Post.

Parameters

NameTypeDefaultDescription
$post\WP_PostThe \WP_Post instance to wrap.

Returns

  • \GV\View | null — An instance around this \WP_Post if valid, null otherwise.

Since: 2.0

Source: future/includes/class-gv-view.php:694

by_id()

public static function by_id( $post_id )

Construct a \GV\View instance from a post ID.

Parameters

NameTypeDefaultDescription
$post_idint | stringThe post ID.

Returns

  • \GV\View | null — An instance around this \WP_Post or null if not found.

Since: 2.0

Source: future/includes/class-gv-view.php:837

get_source()

public static function get_source( $field, $view )

Gets the source of the field.

Parameters

NameTypeDefaultDescription
$fieldFieldThe field.
$viewViewThe view.

Returns

  • GF_Form | Internal_Source

Since: 2.33

Source: future/includes/class-gv-view.php:854

exists()

public static function exists( $view )

Determines if a view exists to begin with.

Parameters

NameTypeDefaultDescription
$viewint | \WP_Post | nullThe WordPress post ID, a \WP_Post object or null for global $post;

Returns

  • bool — Whether the post exists or not.

Since: 2.0

Source: future/includes/class-gv-view.php:886

push_rendering()

public static function push_rendering( $view_id )

Starts tracking that a View is being rendered.

Parameters

NameTypeDefaultDescription
$view_idintThe View ID being rendered.

Since: 2.46.2

Source: future/includes/class-gv-view.php:899

pop_rendering()

public static function pop_rendering()

Stops tracking that a View is being rendered

Returns

  • int | null — The View ID that was being rendered, or null if stack was empty.

Since: 2.46.2

Source: future/includes/class-gv-view.php:912

is_rendering()

public static function is_rendering( $view_id=null )

Checks if a View is currently being rendered (embedded View detection).

Parameters

NameTypeDefaultDescription
$view_idint | nullnullIf provided, check if this specific View is being rendered. If null, check if any view is being rendered.

Returns

  • bool — True if the View (or any View) is being rendered.

Since: 2.46.2

Source: future/includes/class-gv-view.php:927

get_current_rendering()

public static function get_current_rendering()

Returns the currently rendering View ID (the most recent one).

Returns

  • int | null — The View ID currently being rendered, or null if none.

Since: 2.46.2

Source: future/includes/class-gv-view.php:944

get_rendering_stack()

public static function get_rendering_stack()

Returns all currently rendering View IDs.

Returns

  • array — Array of View IDs in rendering order (oldest to newest).

Since: 2.46.2

Source: future/includes/class-gv-view.php:961

is_primary_view()

public static function is_primary_view( $view_id )

Checks if View is the primary (first) rendering View.

Parameters

NameTypeDefaultDescription
$view_idintThe View ID to check

Returns

  • bool — True if the View is the primary rendering View.

Since: 2.46.2

Source: future/includes/class-gv-view.php:976

is_embedded_view()

public static function is_embedded_view( $view_id )

Checks if View is embedded (not the first in stack).

Parameters

NameTypeDefaultDescription
$view_idintThe View ID to check

Returns

  • bool — True if the View is embedded within another View.

Since: 2.46.2

Source: future/includes/class-gv-view.php:991

get_parent_view()

public static function get_parent_view( $view_id )

Returns the parent View of an embedded View.

Parameters

NameTypeDefaultDescription
$view_idintThe View ID to get parent for.

Returns

  • int | null — The parent View ID, or null if not embedded or no parent.

Since: 2.46.2

Source: future/includes/class-gv-view.php:1006

get_rendering_depth()

public static function get_rendering_depth( $view_id )

Returns the rendering depth of a View (how many levels deep it's nested).

Parameters

NameTypeDefaultDescription
$view_idintThe View ID to check

Returns

  • int | false — The depth (0 for primary, 1+ for nested), or false if not rendering.

Since: 2.46.2

Source: future/includes/class-gv-view.php:1027

get_entries()

public function get_entries( $request=null )

Retrieve the entries for the current view and request.

Parameters

NameTypeDefaultDescription
$requestnull

Returns

Source: future/includes/class-gv-view.php:1156

template_redirect()

public static function template_redirect()

Last chance to configure the output.

Used for CSV output, for example.

Returns

  • void

Source: future/includes/class-gv-view.php:1774

get_query_class()

public function get_query_class()

Return the query class for this View.

Returns

  • string — The class name.

Source: future/includes/class-gv-view.php:1905

restrict()

public static function restrict( $caps, $cap, $user_id, $args )

Restrict View access to specific capabilities.

Hooked into map_meta_cap WordPress filter.

Parameters

NameTypeDefaultDescription
$capsarray The output capabilities.
$capstring The cap that is being checked.
$user_idint The User ID.
$argsarray Additional arguments to the capability.

Returns

  • array — The resulting capabilities.

Since: develop

Source: future/includes/class-gv-view.php:1929

set_anchor_id()

public function set_anchor_id( $counter=1 )

Sets the anchor ID of a View, without the prefix.

Parameters

NameTypeDefaultDescription
$counterint1An incremental counter reflecting how many times this View has been rendered.

Returns

  • void

Since: 2.15

Source: future/includes/class-gv-view.php:1974

get_anchor_id()

public function get_anchor_id()

Returns the anchor ID to be used in the View container HTML id attribute.

Returns

  • string — Unsanitized anchor ID.

Since: 2.15

Source: future/includes/class-gv-view.php:1985

get_post()

public function get_post()

Return associated WP post

Returns

  • \WP_Post | null

Since: 2.13.2

Source: future/includes/class-gv-view.php:2011

get_validation_secret()

final public function get_validation_secret( bool $is_forced=false ): ?string

Calculates and returns the View's validation secret.

Parameters

NameTypeDefaultDescription
$is_forcedboolfalse

Returns

  • string | null — The View's secret.

Since: 2.21

Source: future/includes/class-gv-view.php:2078

validate_secret()

final public function validate_secret( string $secret ): bool

Returns whether the provided secret validates for this View.

Parameters

NameTypeDefaultDescription
$secretstringThe provided secret.

Returns

  • bool

Since: 2.21

Source: future/includes/class-gv-view.php:2103

get_shortcode()

final public function get_shortcode( array $atts=[] ): string

Returns the shortcode for this View.

Parameters

NameTypeDefaultDescription
$attsarray[]Additional attributes for the shortcode.

Returns

  • string

Since:

Source: future/includes/class-gv-view.php:2122