Skip to main content

GravityView_View_Data

Source: includes/class-data.php:8

Details

  • Kind: class
  • Namespace: (global)

Methods

MethodDescription
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

NameTypeDefaultDescription
$passed_postWP_Post | WP_Post[] | array | string | int | nullnullSee 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

NameTypeDefaultDescription
$passed_postnull

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

NameTypeDefaultDescription
$view_id
$attsnull

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

NameTypeDefaultDescription
$view_idintThe ID of the post to check

Returns

  • bool — True if the post exists; otherwise, false.

See Also

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

NameTypeDefaultDescription
$view_idint | arrayView ID or array of View IDs
$attsarray | stringnullCombine 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

NameTypeDefaultDescription
$view_idintView ID

Returns

  • array | null — Array of fields as passed by gravityview_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

NameTypeDefaultDescription
$attsarray

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

NameTypeDefaultDescription
$contentstring$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

NameTypeDefaultDescription
$post_idstring''Post ID where the View is embedded
$view_idstring''View ID
$empty_is_validstringfalseIf 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

NameTypeDefaultDescription
$keystringThe key of the setting array item
$with_detailsbooleanfalseInclude 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

NameTypeDefaultDescription
$with_detailsbooleanfalseTrue: Return array with full default settings information, including description, name, etc. False: Return an array with only key => value pairs.
$groupstringnullThe field group the setting is associated with. Default: "default"
$labelstringSetting label shown in admin
$typestringGravity Forms field type
$valuemixedThe default value for the setting
$tooltipstringTooltip displayed for the setting
$show_in_shortcodebooleanWhether to show the setting in the shortcode configuration modal
$optionsarrayArray of values to use when generating select, multiselect, radio, or checkboxes fields
$full_widthbooleanTrue: 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