26 'field' => _x(
'Field',
'Denotes the name under which certain field settings are grouped',
'gk-gravityview' ),
27 'display' => _x(
'Display',
'Denotes the name under which certain field settings are grouped',
'gk-gravityview' ),
28 'label' => _x(
'Label',
'Denotes the name under which certain field settings are grouped',
'gk-gravityview' ),
29 'visibility' => _x(
'Visibility',
'Denotes the name under which certain field settings are grouped',
'gk-gravityview' ),
30 'advanced' => _x(
'Advanced',
'Denotes the name under which certain field settings are grouped',
'gk-gravityview' ),
31 'default' => _x(
'Default',
'Denotes the name under which certain field settings are grouped',
'gk-gravityview' ),
52 $field_options = array();
54 $is_table_layout = preg_match(
'/table/ism', $template_id );
56 if(
'field' === $field_type ) {
59 $field_options = array(
60 'show_label' => array(
62 'label' => __(
'Show Label',
'gk-gravityview' ),
63 'value' => ! empty ( $is_table_layout ),
67 'custom_label' => array(
69 'label' => __(
'Custom Label:',
'gk-gravityview' ),
74 'requires' =>
'show_label',
77 'custom_class' => array(
79 'label' => __(
'Custom CSS Class:',
'gk-gravityview' ),
80 'desc' => __(
'This class will be added to the field container',
'gk-gravityview' ),
83 'tooltip' =>
'gv_css_merge_tags',
84 'class' =>
'widefat code',
86 'group' =>
'advanced',
88 'only_loggedin' => array(
90 'label' => __(
'Make visible only to logged-in users?',
'gk-gravityview' ),
93 'group' =>
'visibility',
95 'only_loggedin_cap' => array(
97 'label' => __(
'Make visible for:',
'gk-gravityview' ),
98 'options' => self::get_cap_choices( $template_id,
$field_id, $context, $input_type ),
102 'requires' =>
'only_loggedin',
103 'group' =>
'visibility',
108 if( $is_table_layout &&
'directory' === $context ) {
109 $field_options[
'width'] = array(
111 'label' => __(
'Percent Width',
'gk-gravityview'),
112 'desc' => __(
'Leave blank for column width to be based on the field content.',
'gk-gravityview'),
113 'class' =>
'code widefat',
116 'group' =>
'display',
123 foreach ( $field_options as $key => $field_option ) {
124 $field_options[ $key ][
'label'] = trim( $field_option[
'label'],
':' );
136 $field_options = apply_filters(
"gravityview_template_{$field_type}_options", $field_options, $template_id,
$field_id, $context, $input_type,
$form_id );
147 $field_options = apply_filters(
"gravityview_template_{$input_type}_options", $field_options, $template_id,
$field_id, $context, $input_type,
$form_id );
149 if (
'directory' === $context && isset( $field_options[
'show_as_link'] ) && ! isset( $field_options[
'new_window'] ) ) {
150 $field_options[
'new_window'] = array(
151 'type' =>
'checkbox',
152 'label' => __(
'Open link in a new tab or window?',
'gk-gravityview' ),
154 'context' =>
'directory',
155 'requires' =>
'show_as_link',
157 'group' =>
'display',
163 $option_groups = array();
165 foreach ( $field_options as $key => $field_option ) {
171 $field_option[
'priority'] = 100;
178 $option_groups[ $_group ][ $key ] = $field_option;
181 foreach ( $option_groups as & $option_group ) {
182 uasort( $option_group, array( __CLASS__,
'_sort_by_priority' ) );
185 $field_options = array();
186 foreach ( self::get_field_groups() as $group_key => $group_name ) {
187 $field_options[ $group_key ] =
\GV\Utils::get( $option_groups, $group_key, array() );
191 uasort( $field_options, array( __CLASS__,
'_sort_by_priority' ) );
194 return $field_options;
213 if ( $a_priority === $b_priority ) {
217 return ( $a_priority < $b_priority ) ? - 1 : 1;
233 $select_cap_choices = array(
234 'read' => __(
'Any Logged-In User',
'gk-gravityview' ),
235 'publish_posts' => __(
'Author Or Higher',
'gk-gravityview' ),
236 'gravityforms_view_entries' => __(
'Can View Gravity Forms Entries',
'gk-gravityview' ),
237 'delete_others_posts' => __(
'Editor Or Higher',
'gk-gravityview' ),
238 'gravityforms_edit_entries' => __(
'Can Edit Gravity Forms Entries',
'gk-gravityview' ),
239 'manage_options' => __(
'Administrator',
'gk-gravityview' ),
242 if( is_multisite() ) {
243 $select_cap_choices[
'manage_network'] = __(
'Multisite Super Admin',
'gk-gravityview' );
256 $select_cap_choices = apply_filters(
'gravityview_field_visibility_caps', $select_cap_choices, $template_id,
$field_id, $context, $input_type );
258 return $select_cap_choices;
281 public static function render_field_options(
$form_id, $field_type, $template_id,
$field_id, $field_label, $area, $input_type = NULL, $uniqid =
'', $current =
'', $context =
'single', $item = array() ) {
282 if( empty( $uniqid ) ) {
284 $uniqid = uniqid(
'',
false);
287 $grouped = (
'field' === $field_type );
290 $option_groups = self::get_default_field_options( $field_type, $template_id,
$field_id, $context, $input_type,
$form_id, $grouped );
293 $option_groups = array( $option_groups );
296 $option_groups = array_filter( $option_groups );
299 $name_prefix = $field_type .
's' .
'['. $area .
']['. $uniqid .
']';
302 $hidden_fields =
'<input type="hidden" class="field-key" name="'. $name_prefix .
'[id]" value="'. esc_attr(
$field_id ) .
'">';
303 $hidden_fields .=
'<input type="hidden" class="field-label" name="'. $name_prefix .
'[label]" value="'. esc_attr( $field_label ) .
'">';
307 $hidden_fields .=
'<input type="hidden" class="field-form-id" name="'. $name_prefix .
'[form_id]" value="'. esc_attr(
$form_id ) .
'">';
309 $form_title =
$form[
'title'];
313 if ( empty( $option_groups ) ) {
314 return $hidden_fields .
'<!-- No Options -->';
317 $settings_title = esc_attr( sprintf( __(
'%s Settings',
'gk-gravityview' ) , strip_tags( html_entity_decode( $field_label ) ) ) );
327 $input_type_label = $input_type;
331 foreach ( $option_groups as $group_key => $option_group ) {
333 if ( empty( $option_group ) ) {
338 $group_name = rgar( self::get_field_groups(), $group_key,
'' );
339 $field_settings .=
'<fieldset class="item-settings-group item-settings-group-' . esc_attr( $group_key ) .
'">';
343 foreach ( $option_group as $key => $option ) {
345 $value = isset( $current[ $key ] ) ? $current[ $key ] : null;
347 $field_output = self::render_field_option( $name_prefix .
'[' . $key .
']', $option,
$value );
350 if ( empty( $field_output ) ) {
355 if ( ! empty( $option[
'requires'] ) ) {
356 $show_if .= sprintf(
' data-requires="%s"', $option[
'requires'] );
359 if ( ! empty( $option[
'requires_not'] ) ) {
360 $show_if .= sprintf(
' data-requires-not="%s"', $option[
'requires_not'] );
363 switch ( $option[
'type'] ) {
366 $field_settings .=
'<div class="gv-setting-container gv-setting-container-' . esc_attr( $key ) .
' screen-reader-text">' . $field_output .
'</div>';
369 $field_settings .=
'<div class="gv-setting-container gv-setting-container-' . esc_attr( $key ) .
'" ' . $show_if .
'>' . $field_output .
'</div>';
381 if(
'field' === $field_type ) {
382 $subtitle = ! empty( $item[
'subtitle'] ) ?
'<div class="subtitle">' . $item[
'subtitle'] .
'</div>' :
'';
385 <div class="gv-field-details--container"> 386 <label class="gv-field-details--toggle">' . esc_html__(
'Field Details',
'gk-gravityview' ) .
' <i class="dashicons dashicons-arrow-right"></i></label> 387 <section class="gv-field-details gv-field-details--closed">';
391 <div class="gv-field-detail gv-field-detail--field"> 392 <span class="gv-field-detail--label">' . esc_html__(
'Field ID',
'gk-gravityview' ) .
'</span><span class="gv-field-detail--value">#{{field_id}}</span> 397 <div class="gv-field-detail gv-field-detail--type"> 398 <span class="gv-field-detail--label">' . esc_html_x(
'Type',
'The type of field being configured (eg: "Single Line Text")',
'gk-gravityview' ) .
'</span><span class="gv-field-detail--value">{{input_type_label}}</span> 403 <div class="gv-field-detail gv-field-detail--form"> 404 <span class="gv-field-detail--label">' . esc_html__(
'Form',
'gk-gravityview' ) .
'</span><span class="gv-field-detail--value">{{form_title}} (#{{form_id}})</span> 412 $subtitle = ! empty( $item[
'subtitle'] ) ?
'<div class="subtitle">' . $item[
'subtitle'] .
'</div>' :
'';
413 $widget_details_content =
\GV\Utils::get( $item,
'description',
'' );
416 $item_details =
'<div class="gv-field-details--container">' . wpautop( trim( $widget_details_content ) ) .
'</div>';
420 <div
class=
"gv-dialog-options" title=
"{{settings_title}}">
430 $replacements = array(
442 foreach ( $replacements as $replacement ) {
443 if ( is_null( ${$replacement} ) ) {
447 if ( $replacement ===
'form_id' && strpos(
$form_id,
'preset_' ) !==
false ) {
449 $output = str_replace(
'#{{' . $replacement .
'}}', esc_html__(
'Form Preset',
$output,
'gk-gravityview' ),
$output );
454 $output = str_replace(
'{{' . $replacement .
'}}', ${$replacement},
$output );
479 if( !empty( $option[
'default'] ) && empty( $option[
'value'] ) ) {
480 $option[
'value'] = $option[
'default'];
481 _deprecated_function(
'GravityView_FieldType::get_field_defaults',
'1.1.7',
'[value] instead of [default] when defining the setting '.
$name .
' details' );
485 if( isset( $option[
'type'] ) ) {
487 $type_class = self::load_type_class( $option );
489 if( class_exists( $type_class ) ) {
492 $render_type =
new $type_class(
$name, $option, $curr_value );
496 $render_type->render_option();
506 $output = apply_filters(
"gravityview/option/output/{$option['type']}" ,
$output, $option );
533 if ( ! $setting =
$settings->get( $key ) ) {
541 if( isset( $setting[
'name'] ) && empty( $setting[
'label'] ) ) {
542 $setting[
'label'] = $setting[
'name'];
543 _deprecated_function(
'GravityView_FieldType::get_field_defaults',
'1.1.7',
'[label] instead of [name] when defining the setting '. $key .
' details' );
547 $setting[
'id'] = esc_attr( sprintf( $id, $key ) );
548 $setting[
'tooltip'] =
'gv_' . $key;
554 $setting[
'type'] = empty( $setting[
'type'] ) ?
'text' : $setting[
'type'];
557 if( !isset( $setting[
'merge_tags'] ) ) {
558 if( $setting[
'type'] ===
'text' ) {
559 $setting[
'merge_tags'] =
true;
561 $setting[
'merge_tags'] =
false;
568 $type_class = self::load_type_class( $setting );
569 if( class_exists( $type_class ) ) {
571 $render_type =
new $type_class(
$name, $setting, $curr_value );
573 $render_type->render_setting( $override_input );
575 $output = str_replace(
'gv-merge-tag-support',
'merge-tag-support',
$output );
579 if( !empty( $setting[
'show_in_template'] ) ) {
580 if( !is_array( $setting[
'show_in_template'] ) ) {
581 $setting[
'show_in_template'] = array( $setting[
'show_in_template'] );
583 $show_if =
' data-show-if="'. implode(
' ', $setting[
'show_in_template'] ).
'"';
588 if( ! empty( $setting[
'requires'] ) ) {
589 $show_if .= sprintf(
' data-requires="%s"', $setting[
'requires'] );
592 if( ! empty( $setting[
'requires_not'] ) ) {
593 $show_if .= sprintf(
' data-requires-not="%s"', $setting[
'requires_not'] );
597 echo
'<tr style="vertical-align: top;" '. $show_if .
'>' .
$output .
'</tr>';
609 if( empty(
$field[
'type'] ) ) {
618 $type_class = apply_filters(
"gravityview/setting/class/{$field['type']}",
'GravityView_FieldType_' .
$field[
'type'],
$field );
620 if( class_exists( $type_class ) ) {
629 $class_file = apply_filters(
"gravityview/setting/class_file/{$field['type']}",
GRAVITYVIEW_DIR .
"includes/admin/field-types/type_{$field['type']}.php",
$field );
631 if( $class_file && file_exists( $class_file ) ) {
632 require_once( $class_file );
651 _deprecated_function( __METHOD__,
'1.2',
'GravityView_FieldType_checkbox::render_input' );
653 $output =
'<input name="'. esc_attr(
$name ) .
'" type="hidden" value="0">';
654 $output .=
'<input name="'. esc_attr(
$name ) .
'" id="'. esc_attr( $id ) .
'" type="checkbox" value="1" '. checked( $current,
'1',
false ) .
' >';
671 _deprecated_function( __METHOD__,
'1.2',
'GravityView_FieldType_text::render_input' );
674 $is_list = ( preg_match(
'/_list-/ism',
$name ));
677 $is_single = ( preg_match(
'/single_/ism',
$name ));
678 $show = ( $is_single || $is_list );
682 if( $show && $add_merge_tags !==
false || $add_merge_tags ===
'force' ) {
683 $class =
'gv-merge-tag-support mt-position-right mt-hide_all_fields ';
687 $type = !empty(
$args[
'type'] ) ?
$args[
'type'] :
'text';
689 return '<input name="'. esc_attr(
$name ) .
'" id="'. esc_attr( $id ) .
'" type="'.esc_attr($type).
'" value="'. esc_attr( $current ) .
'" class="'.esc_attr(
$class ).
'">';
703 _deprecated_function( __METHOD__,
'1.2',
'GravityView_FieldType_textarea::render_input' );
706 $is_list = ( preg_match(
'/_list-/ism',
$name ));
709 $is_single = ( preg_match(
'/single_/ism',
$name ));
710 $show = ( $is_single || $is_list );
714 if( $show && $add_merge_tags !==
false || $add_merge_tags ===
'force' ) {
715 $class =
'gv-merge-tag-support mt-position-right mt-hide_all_fields ';
718 $class .= !empty(
$args[
'class'] ) ?
'widefat '.$args[
'class'] :
'widefat';
720 return '<textarea name="'. esc_attr(
$name ) .
'" id="'. esc_attr( $id ) .
'" class="'.esc_attr(
$class ).
'">'. esc_textarea( $current ) .
'</textarea>';
734 _deprecated_function( __METHOD__,
'1.2',
'GravityView_FieldType_select::render_input' );
738 $output .=
'<option value="'. esc_attr(
$value ) .
'" '. selected(
$value, $current,
false ) .
'>'. esc_html(
$label ) .
'</option>';
const GRAVITYVIEW_DIR
"GRAVITYVIEW_DIR" "./" The absolute path to the plugin directory, with trailing slash ...
static _sort_by_priority( $a, $b)
Sort field settings by the priority key.
static render_field_options( $form_id, $field_type, $template_id, $field_id, $field_label, $area, $input_type=NULL, $uniqid='', $current='', $context='single', $item=array())
Render Field Options html (shown through a dialog box)
static load_type_class( $field=NULL)
Given a field type calculates the php class.
static with_defaults( $detailed=false)
Retrieve an instance of the settings with default values.
static render_checkbox_option( $name='', $id='', $current='')
if(! isset( $gravityview)||empty( $gravityview->template)) $template
The entry loop for the list output.
static get( $field_name)
Alias for get_instance()
static render_setting_row( $key='', $current_settings=array(), $override_input=null, $name='template_settings[%s]', $id='gravityview_se_%s')
Output a table row for view settings.
$field_settings['content']
static get_default_field_options( $field_type, $template_id, $field_id, $context, $input_type, $form_id, $grouped=false)
Get the default options for a standard field.
if(gravityview() ->plugin->is_GF_25()) $form
static get_field_groups()
Get available field groups.
static render_textarea_option( $name='', $id='', $current='', $add_merge_tags=NULL, $args=array())
static get_form_or_form_template( $form_id=0)
Returns form object for existing form or a form template.
static render_field_option( $name='', $option=array(), $curr_value=null)
Handle rendering a field option form element.
if(empty( $created_by)) $form_id
static render_text_option( $name='', $id='', $current='', $add_merge_tags=NULL, $args=array())
static get( $array, $key, $default=null)
Grab a value from an array or an object or default.
static get_cap_choices( $template_id='', $field_id='', $context='', $input_type='')
Get capabilities options for GravityView.
if(false !==strpos( $value, '00:00')) $field_id
string $field_id ID of the field being displayed
static render_select_option( $name='', $id='', $choices=array(), $current='')
Render the HTML for a select box to be used on the field & widgets options.