Skip to main content

GravityView_Template

Class used to register a new template to be shown in GravityView presets

Source: includes/class-gravityview-template.php:6

Details

  • Kind: class
  • Namespace: (global)

Properties

PropertyTypeDescription
$template_idstringtemplate unique id
$settingsarrayArray shape:<ul><li><code>$slug</code> (string): template slug (frontend)</li><li><code>$css_source</code> (string): url path to CSS file, to be enqueued (frontend)</li><li><code>$type</code> (string): 'custom' or 'preset' (admin)</li><li><code>$label</code> (string): template nicename (admin)</li><li><code>$description</code> (string): short about text (admin)</li><li><code>$logo</code> (string): template icon (admin)</li><li><code>$icon</code> (string): template icon (admin)</li><li><code>$preview</code> (string): template image for previewing (admin)</li><li><code>$buy_source</code> (string): url source for buying this template</li><li><code>$preset_form</code> (string): path to Gravity Form form XML file</li></ul>
$field_optionsarrayform fields extra options
$active_areasarraydefine the active areas

Methods

MethodDescription
register_template()Register the template to display in the admin
assign_active_areas()Assign active areas (for admin configuration)
assign_field_options()Assign template specific field options
assign_form_xml()Set the Gravity Forms import form information by using the preset_form field defined in the template.
assign_fields_xml()Set the Gravity Forms import form by using the preset_fields field defined in the template.
assign_view_slug()Assign the template slug when loading the presentation template (frontend)
register_styles()If the template has a CSS file defined in the css_source setting, register it

Method Reference

register_template()

public function register_template( $templates )

Register the template to display in the admin

Parameters

NameTypeDefaultDescription
$templatesmixed

Returns

  • array — Array of templates available for GV

Source: includes/class-gravityview-template.php:123

assign_active_areas()

public function assign_active_areas( $areas, $template='', $context='directory' )

Assign active areas (for admin configuration)

Parameters

NameTypeDefaultDescription
$areasarray
$templatestring''(default: '')
$context'directory'

Returns

  • array — Array of active areas

Source: includes/class-gravityview-template.php:140

assign_field_options()

public function assign_field_options( $field_options, $template_id, $field_id=null, $context='directory', $input_type='' )

Assign template specific field options

Parameters

NameTypeDefaultDescription
$field_options
$template_id
$field_idstringnullkey for the field
$contextstring | array'directory'Context for the field; directory or single for example.
$input_type''
$optionsarrayarray((default: array())
$templatestring''(default: '')

Returns

  • array — Array of field options

Source: includes/class-gravityview-template.php:167

assign_form_xml()

public function assign_form_xml( $xml='', $template='' )

Set the Gravity Forms import form information by using the preset_form field defined in the template.

Parameters

NameTypeDefaultDescription
$xml''
$template''

Returns

  • string — Path to XML file

See Also

Source: includes/class-gravityview-template.php:196

assign_fields_xml()

public function assign_fields_xml( $xml='', $template='' )

Set the Gravity Forms import form by using the preset_fields field defined in the template.

Parameters

NameTypeDefaultDescription
$xml''
$template''

Returns

  • string — Path to XML file

See Also

Source: includes/class-gravityview-template.php:210

assign_view_slug()

public function assign_view_slug( $default, $context )

Assign the template slug when loading the presentation template (frontend)

Parameters

NameTypeDefaultDescription
$defaultmixed
$context

Returns

  • string

Source: includes/class-gravityview-template.php:228

register_styles()

public function register_styles()

If the template has a CSS file defined in the css_source setting, register it

It will be registered using gravityview_style_{template_id} format

Returns

  • void

Source: includes/class-gravityview-template.php:247