GV\View
Source: future/includes/class-gv-view.php:30
Details
-
Kind:
class -
Namespace:
GV -
Implements:
ArrayAccess
Properties
| Property | Type | Description |
|---|---|---|
$settings | \GV\View_Settings | The settings. |
$widgets | \GV\Widget_Collection | The widgets attached here. |
$form | \GV\GF_Form | \GV\Form | The backing form for this view. Contains the form that is sourced for entries in this view. |
$fields | \GV\Field_Collection | The 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
| Method | Description |
|---|---|
__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
| Name | Type | Default | Description |
|---|---|---|---|
$content | string | Should 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
| Name | Type | Default | Description |
|---|---|---|---|
$context | string[] | null | The 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\Request | null | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$post | \WP_Post | GravityView CPT to get joins for |
Returns
- \GV\Join[] — Array of \GV\Join instances
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
| Name | Type | Default | Description |
|---|---|---|---|
$post_id | int | ID of the View |
Returns
- \GV\GF_Form[] — Array of \GV\GF_Form instances
Since:
Source: future/includes/class-gv-view.php:585
get_unions()
public static function get_unions( $post )
Get unions associated with a view
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$post | \WP_Post | GravityView CPT to get unions for |
Returns
- \GV\Field[][] — Array of unions (see self::$unions)
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
| Name | Type | Default | Description |
|---|---|---|---|
$post | \WP_Post | The \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
| Name | Type | Default | Description |
|---|---|---|---|
$post_id | int | string | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$field | Field | The field. | |
$view | View | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$view | int | \WP_Post | null | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$view_id | int | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$view_id | int | null | null | If 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
| Name | Type | Default | Description |
|---|---|---|---|
$view_id | int | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$view_id | int | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$view_id | int | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$view_id | int | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$request | null |
Returns
- \GV\Entry_Collection — The entries.
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
| Name | Type | Default | Description |
|---|---|---|---|
$caps | array The output capabilities. | ||
$cap | string The cap that is being checked. | ||
$user_id | int The User ID. | ||
$args | array 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
| Name | Type | Default | Description |
|---|---|---|---|
$counter | int | 1 | An 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
| Name | Type | Default | Description |
|---|---|---|---|
$is_forced | bool | false |
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
| Name | Type | Default | Description |
|---|---|---|---|
$secret | string | The 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
| Name | Type | Default | Description |
|---|---|---|---|
$atts | array | [] | Additional attributes for the shortcode. |
Returns
string
Since:
Source: future/includes/class-gv-view.php:2122