GravityView_View_Data
Source: includes/class-data.php:8
Details
- Kind:
class - Namespace:
(global)
Methods
| Method | Description |
|---|---|
has_multiple_views() | |
maybe_get_view_id() | Figure out what the View ID is for a variable, if any. |
getInstance() | |
get_views() | |
get_view() | |
view_exists() | Determines if a post, identified by the specified ID, exist |
add_view() | Add a view to the views array |
get_fields() | Get the visible fields for a View |
get_id_from_atts() | Retrieves view ID from an array. |
parse_post_content() | Parse content to determine if there is a GV shortcode to allow for enqueing necessary files in the head. |
is_valid_embed_id() | Checks if the passed post id has the passed View id embedded. |
get_default_arg() | Get a specific default setting |
get_default_args() | Retrieve the default args for shortcode and theme function |
Method Reference
has_multiple_views()
public function has_multiple_views()
Returns
boolean
See Also
\GV\View_Collection::count
Source: includes/class-data.php:36
maybe_get_view_id()
public function maybe_get_view_id( $passed_post=null )
Figure out what the View ID is for a variable, if any.
Can be:
- WP_Post (Either a gravityview post type or not)
- Multi-dimensional array of WP_Post objects
- Array with view_id or id key(s) set
- String of content that may include GravityView shortcode
- Number representing the Post ID or View ID
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$passed_post | WP_Post | WP_Post[] | array | string | int | null | null | See method description |
Returns
int|null|array— ID of the View. If there are multiple views in the content, array of IDs parsed.
See Also
\GV\View_Collection::from_post and \GV\Shortcode::parse
Source: includes/class-data.php:58
getInstance()
public static function getInstance( $passed_post=null )
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$passed_post | null |
Returns
Source: includes/class-data.php:118
get_views()
function get_views()
See Also
Source: includes/class-data.php:131
get_view()
function get_view( $view_id, $atts=null )
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$view_id | |||
$atts | null |
See Also
Source: includes/class-data.php:153
view_exists()
function view_exists( $view_id )
Determines if a post, identified by the specified ID, exist
within the WordPress database.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$view_id | int | The ID of the post to check |
Returns
bool— True if the post exists; otherwise, false.
See Also
- http://tommcfarlin.com/wordpress-post-exists-by-id/ Fastest check available
\GV\View::exists()
Since: 1.0.0
Source: includes/class-data.php:189
add_view()
function add_view( $view_id, $atts=null )
Add a view to the views array
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$view_id | int | array | View ID or array of View IDs | |
$atts | array | string | null | Combine other attributes (eg. from shortcode) with the view settings (optional) |
Returns
array|false— All views if $view_id is array, a view data array if $view_id is an int, false on errors.
See Also
\GV\View_Collection::append
Source: includes/class-data.php:205
get_fields()
function get_fields( $view_id )
Get the visible fields for a View
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$view_id | int | View ID |
Returns
array|null— Array of fields as passed bygravityview_get_directory_fields()
See Also
\GV\View::$fields
Source: includes/class-data.php:221
get_id_from_atts()
function get_id_from_atts( $atts )
Retrieves view ID from an array.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$atts | array |
Returns
int|null— A view ID cast to int, or null.
Deprecated: Dead code, was probably superceded by GravityView_View_Data::parse_post_content
Source: includes/class-data.php:236
parse_post_content()
public function parse_post_content( $content )
Parse content to determine if there is a GV shortcode to allow for enqueing necessary files in the head.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$content | string | $post->post_content content |
Returns
int|null|array— If a single View is found, the ID of the View. If there are multiple views in the content, array of IDs parsed. If not found, NULL
See Also
\GV\View_Collection::from_content
Source: includes/class-data.php:257
is_valid_embed_id()
public static function is_valid_embed_id( $post_id='', $view_id='', $empty_is_valid=false )
Checks if the passed post id has the passed View id embedded.
Returns
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$post_id | string | '' | Post ID where the View is embedded |
$view_id | string | '' | View ID |
$empty_is_valid | string | false | If either $post_id or $view_id is empty consider valid. Default: false. |
Returns
bool| WP_Error — If valid, returns true. If invalid, returns WP_Error containing error message.
Since: 1.6.1
Source: includes/class-data.php:291
get_default_arg()
public static function get_default_arg( $key, $with_details=false )
Get a specific default setting
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$key | string | The key of the setting array item | |
$with_details | boolean | false | Include details |
Returns
mixed|array— If using $with_details, return array. Otherwise, mixed.
Source: includes/class-data.php:362
get_default_args()
public static function get_default_args( $with_details=false, $group=null )
Retrieve the default args for shortcode and theme function
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$with_details | boolean | false | True: Return array with full default settings information, including description, name, etc. False: Return an array with only key => value pairs. |
$group | string | null | The field group the setting is associated with. Default: "default" |
$label | string | Setting label shown in admin | |
$type | string | Gravity Forms field type | |
$value | mixed | The default value for the setting | |
$tooltip | string | Tooltip displayed for the setting | |
$show_in_shortcode | boolean | Whether to show the setting in the shortcode configuration modal | |
$options | array | Array of values to use when generating select, multiselect, radio, or checkboxes fields | |
$full_width | boolean | True: Display the input and label together when rendering. False: Display label and input in separate columns when rendering. |
Returns
array— $args Associative array of default settings for a View
See Also
Source: includes/class-data.php:392