GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes | Private Member Functions
GravityView_View_Data Class Reference

If this file is called directly, abort. More...

Public Member Functions

 add_view ( $view_id, $atts=NULL)
 Add a view to the views array. More...
 
 get_fields ( $view_id)
 Get the visible fields for a View gravityview_get_directory_fields() Fetch the configured fields for a View GravityView_View_Data::filter_fields() Only show visible fields. More...
 
 get_id_from_atts ( $atts)
 Retrieves view ID from an array. More...
 
 get_view ( $view_id, $atts=NULL)
 
 get_views ()
 
 has_multiple_views ()
 
 maybe_get_view_id ( $passed_post=null)
 Figure out what the View ID is for a variable, if any. More...
 
 parse_post_content ( $content)
 Parse content to determine if there is a GV shortcode to allow for enqueing necessary files in the head. More...
 
 view_exists ( $view_id)
 Determines if a post, identified by the specified ID, exist within the WordPress database. More...
 

Static Public Member Functions

static get_default_arg ( $key, $with_details=false)
 Get a specific default setting. More...
 
static get_default_args ( $with_details=false, $group=NULL)
 Retrieve the default args for shortcode and theme function. More...
 
static getInstance ( $passed_post=NULL)
 
static is_valid_embed_id ( $post_id='', $view_id='', $empty_is_valid=false)
 Checks if the passed post id has the passed View id embedded. More...
 

Data Fields

 $views = array()
 

Static Public Attributes

static $instance = NULL
 

Private Member Functions

 __construct ( $passed_post=NULL)
 

Detailed Description

If this file is called directly, abort.

Definition at line 8 of file class-data.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $passed_post = NULL)
private
Parameters
null$passed_post

Definition at line 18 of file class-data.php.

References $view_id, and maybe_get_view_id().

Member Function Documentation

◆ add_view()

add_view (   $view_id,
  $atts = NULL 
)

Add a view to the views array.

Parameters
int | array$view_idView ID or array of View IDs
array | string$attsCombine other attributes (eg. from shortcode) with the view settings (optional)
See also
::append
Returns
array|false All views if $view_id is array, a view data array if $view_id is an int, false on errors.

Definition at line 201 of file class-data.php.

References $view_id, and GV\Mocks\GravityView_View_Data_add_view().

◆ get_default_arg()

static get_default_arg (   $key,
  $with_details = false 
)
static

Get a specific default setting.

Parameters
string$keyThe key of the setting array item
boolean$with_detailsInclude details
Returns
mixed|array If using $with_details, return array. Otherwise, mixed.

Definition at line 351 of file class-data.php.

References $args, and View_Settings\defaults().

◆ get_default_args()

static get_default_args (   $with_details = false,
  $group = NULL 
)
static

Retrieve the default args for shortcode and theme function.

Parameters
boolean$with_detailsTrue: Return array with full default settings information, including description, name, etc. False: Return an array with only key => value pairs.
string$groupOnly fetch
Returns
array $args Associative array of default settings for a View
Parameters
string$labelSetting label shown in admin
string$typeGravity Forms field type
string$groupThe field group the setting is associated with. Default: "default"
mixed$valueThe default value for the setting
string$tooltipTooltip displayed for the setting
boolean$show_in_shortcodeWhether to show the setting in the shortcode configuration modal
array$optionsArray of values to use when generating select, multiselect, radio, or checkboxes fields
boolean$full_widthTrue: Display the input and label together when rendering. False: Display label and input in separate columns when rendering.
See also
::defaults()

Definition at line 381 of file class-data.php.

◆ get_fields()

get_fields (   $view_id)

Get the visible fields for a View gravityview_get_directory_fields() Fetch the configured fields for a View GravityView_View_Data::filter_fields() Only show visible fields.

Parameters
int$view_idView ID
See also
::$fields
Returns
array|null Array of fields as passed by gravityview_get_directory_fields()

Definition at line 216 of file class-data.php.

References $view_id, and View\by_id().

◆ get_id_from_atts()

get_id_from_atts (   $atts)

Retrieves view ID from an array.

Parameters
array$atts
Returns
int|null A view ID cast to int, or null.

Definition at line 231 of file class-data.php.

References $settings, $view_id, and View_Settings\with_defaults().

Referenced by maybe_get_view_id().

◆ get_view()

get_view (   $view_id,
  $atts = NULL 
)
See also
::get()

Emulate this weird side-effect below...

Definition at line 149 of file class-data.php.

References $view_id, and View\by_id().

◆ get_views()

get_views ( )
See also
::all()

Definition at line 135 of file class-data.php.

◆ getInstance()

static getInstance (   $passed_post = NULL)
static

◆ has_multiple_views()

has_multiple_views ( )
See also
::count
Returns
boolean

Definition at line 37 of file class-data.php.

◆ is_valid_embed_id()

static is_valid_embed_id (   $post_id = '',
  $view_id = '',
  $empty_is_valid = false 
)
static

Checks if the passed post id has the passed View id embedded.

Returns

Since
1.6.1
Parameters
string$post_idPost ID where the View is embedded
string$view_idView ID
string$empty_is_validIf 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.

Definition at line 286 of file class-data.php.

References $post, $view_id, $views, View_Collection\from_post(), and gravityview_get_link().

Referenced by GravityView_Search_WP_Widget\update(), and GravityView_Recent_Entries_Widget\update().

◆ maybe_get_view_id()

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
WP_Post|WP_Post[]|array|string|int|null$passed_post See method description
See also
::from_post and ::parse
Returns
int|null|array ID of the View. If there are multiple views in the content, array of IDs parsed.

And as a side-effect... add each view to the global scope.

And as a side-effect... add each view to the global scope.

Definition at line 59 of file class-data.php.

References $post, $views, View\exists(), View_Collection\from_post(), get_id_from_atts(), and Shortcode\parse().

Referenced by __construct().

◆ parse_post_content()

parse_post_content (   $content)

Parse content to determine if there is a GV shortcode to allow for enqueing necessary files in the head.

gravityview_has_shortcode_r() Check whether shortcode exists (recursively) shortcode_parse_atts() Parse each GV shortcode gravityview_get_template_settings() Get the settings for the View ID

Parameters
string$content$post->post_content content
See also
::from_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

The original function outputs the ID even though it wasn't added by ::add_view() Wether this is a bug or not remains a mystery. But we need to emulate this behavior until better times.

Definition at line 252 of file class-data.php.

References $content.

◆ view_exists()

view_exists (   $view_id)

Determines if a post, identified by the specified ID, exist within the WordPress database.

See also
http://tommcfarlin.com/wordpress-post-exists-by-id/ Fastest check available
Parameters
int$view_idThe ID of the post to check
See also
::exists()
Returns
bool True if the post exists; otherwise, false.
Since
1.0.0

Definition at line 185 of file class-data.php.

References $view_id.

Field Documentation

◆ $instance

$instance = NULL
static

Definition at line 10 of file class-data.php.

Referenced by oEmbed\render_frontend(), and Legacy_Context\reset().

◆ $views

$views = array()

Definition at line 12 of file class-data.php.

Referenced by is_valid_embed_id(), and maybe_get_view_id().


The documentation for this class was generated from the following file: