GravityKit\GravityView\View\View
Source: src/View/View.php:41
Details
-
Kind:
class -
Namespace:
GravityKit\GravityView\View -
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. |
$styles | \GravityKit\GravityView\Settings\ViewStyles | The design-token registry adapter for this View. Provides token discovery, sanitisation, and CSS emission for the View's saved palette / typography / spacing / effects overrides. Backed by static methods; the property is a thin namespace handle so callers can write $view->styles->emit_css_declarations( ... ) (see also scoped_selector(), sticky_header_css(), and prefers_contrast_css() for the per-View emission helpers). |
$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. |
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() | Magic getter forwarded to the backing \WP_Post. |
get_post() | Return associated WP post |
get_validation_secret() | Calculates and returns the View's validation secret. |
get_validation_secret_by_id() | Calculates and returns a View's validation secret without hydrating the View. |
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: src/View/View.php:160
add_rewrite_endpoint()
public static function add_rewrite_endpoint()
Add extra rewrite endpoints.
Returns
void
Source: src/View/View.php:302
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: src/View/View.php:335
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: src/View/View.php:461
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: src/View/View.php:573
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:
2.0.112.0
Source: src/View/View.php:625
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: src/View/View.php:683
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: src/View/View.php:741
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: src/View/View.php:884
get_source()
public static function get_source( $field, $view )
Gets the source of the field.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$field | \GV\Field | The field. | |
$view | \GV\View | The view. |
Returns
\GV\GF_Form|\GV\Internal_Source
Since: 2.33
Source: src/View/View.php:908
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: src/View/View.php:940
get_entries()
public function get_entries( $request=null )
Retrieve the entries for the current view and request.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$request | \GV\Request | null | The request. |
Returns
\GV\Entry_Collection— The entries.
Source: src/View/View.php:1221
template_redirect()
public static function template_redirect()
Last chance to configure the output.
Used for CSV output, for example.
Returns
void
Source: src/View/View.php:1872
get_query_class()
public function get_query_class()
Return the query class for this View.
Returns
string— The class name.
Source: src/View/View.php:2004
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: 3.0.0
Source: src/View/View.php:2028
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: src/View/View.php:2073
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: src/View/View.php:2084
__get()
public function __get( $key )
Magic getter forwarded to the backing \WP_Post.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$key | string | The property name. |
Returns
mixed— The property value, or null if not set.
Source: src/View/View.php:2102
get_post()
public function get_post()
Return associated WP post
Returns
\WP_Post|null
Since: 2.13.2
Source: src/View/View.php:2117
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 | Whether to compute the secret for non-secure Views too. |
Returns
string|null— The View's secret.
Since: 2.21
Source: src/View/View.php:2186
get_validation_secret_by_id()
public static function get_validation_secret_by_id( int $view_id, bool $is_forced=false ): ?string
Calculates and returns a View's validation secret without hydrating the View.
Bulk callers (e.g. the block editor View picker) use this so listing thousands of Views does not pay full View hydration per row.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$view_id | int | The View ID. | |
$is_forced | bool | false | Whether to compute the secret for non-secure Views too. |
Returns
string|null— The View's secret.
Since: $ver$
Source: src/View/View.php:2203
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: src/View/View.php:2238
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:
2.212.22(Added$attsparameter.)
Source: src/View/View.php:2257