101 public $contexts = array(
'single',
'multiple',
'edit',
'export' );
115 public $icon =
'dashicons-admin-generic';
151 add_filter( sprintf(
'gravityview_template_%s_options', $this->name ), array( &$this,
'field_options' ), 10, 6 );
153 add_filter(
'gravityview/sortable/field_blocklist', array( $this,
'_filter_sortable_fields' ), 1 );
155 if( $this->entry_meta_key ) {
156 add_filter(
'gform_entry_meta', array( $this,
'add_entry_meta' ) );
157 add_filter(
'gravityview/common/sortable_fields', array( $this,
'add_sortable_field' ), 10, 2 );
160 if( $this->_custom_merge_tag ) {
161 add_filter(
'gform_custom_merge_tags', array( $this,
'_filter_gform_custom_merge_tags' ), 10, 4 );
162 add_filter(
'gform_replace_merge_tags', array( $this,
'_filter_gform_replace_merge_tags' ), 10, 7 );
165 if(
'meta' === $this->group ||
'' !== $this->default_search_label ) {
166 add_filter(
'gravityview_search_field_label', array( $this,
'set_default_search_label' ), 10, 3 );
173 if( empty( $this->label ) && ! empty( $this->_gf_field_class_name ) && class_exists( $this->_gf_field_class_name ) ) {
174 $this->label = ucfirst( GF_Fields::get( $this->name )->get_form_editor_field_title() );
180 gravityview()->log->critical( $exception->getMessage() );
193 $this->name => array(
194 'label' => $this->label,
196 'type' => $this->name,
197 'icon' => $this->icon,
198 'group' => $this->group,
210 public function get_icon() {
218 if ( empty( $this->_gf_field_class_name ) || ! class_exists( $this->_gf_field_class_name ) ) {
223 $gf_field = GF_Fields::get( $this->name );
227 return $gf_field->get_form_editor_field_icon();
244 $added_field = array(
245 'label' => $this->label,
246 'type' => $this->name
249 $fields[
"{$this->entry_meta_key}"] = $added_field;
269 if( $this->name ===
$field[
'field'] &&
'' ===
$label ) {
270 $label = esc_html( $this->default_search_label );
293 preg_match_all(
'/{' . preg_quote( $this->_custom_merge_tag ) .
':?(.*?)(?:\s)?}/ism', $text, $matches, PREG_SET_ORDER );
296 if ( empty( $matches ) ) {
323 foreach( $matches as $match ) {
325 $full_tag = $match[0];
328 $tag = str_replace( array(
'{',
'}'),
'', $full_tag );
331 if( isset(
$entry[ $tag ] ) ) {
335 if( is_callable( array( $this,
'get_content') ) ) {
339 $text = str_replace( $full_tag,
$value, $text );
343 unset(
$value, $tag, $full_tag );
368 return array_merge( $custom_merge_tags, $field_merge_tags );
388 'label' => $this->label,
389 'tag' =>
'{' . $this->_custom_merge_tag .
'}',
408 if( ! $this->is_sortable ) {
412 return $not_sortable;
426 if( ! isset( $entry_meta[
"{$this->entry_meta_key}"] ) ) {
429 'label' => $this->label,
430 'is_numeric' => $this->is_numeric,
431 'is_default_column' => $this->entry_meta_is_default_column,
434 if ( $this->entry_meta_update_callback && is_callable( $this->entry_meta_update_callback ) ) {
438 $entry_meta[
"{$this->entry_meta_key}"] = $added_meta;
441 gravityview()->log->error(
'Entry meta already set: {meta_key}', array(
'meta_key' => $this->entry_meta_key,
'data' => $entry_meta[
"{$this->entry_meta_key}"] ) );
449 'link_to_post' => array(
450 'type' =>
'checkbox',
451 'label' => __(
'Link to the post',
'gk-gravityview' ),
452 'desc' => __(
'Link to the post created by the entry.',
'gk-gravityview' ),
455 'group' =>
'display',
457 'link_to_term' => array(
458 'type' =>
'checkbox',
459 'label' => __(
'Link to the category or tag',
'gk-gravityview' ),
460 'desc' => __(
'Link to the current category or tag. "Link to single entry" must be unchecked.',
'gk-gravityview' ),
463 'group' =>
'display',
465 'dynamic_data' => array(
466 'type' =>
'checkbox',
467 'label' => __(
'Use the live post data',
'gk-gravityview' ),
468 'desc' => __(
'Instead of using the entry data, instead use the current post data.',
'gk-gravityview' ),
471 'group' =>
'display',
473 'date_display' => array(
475 'label' => __(
'Override Date Format',
'gk-gravityview' ),
476 'desc' => sprintf( __(
'Define how the date is displayed (using %sthe PHP date format%s)',
'gk-gravityview'),
'<a href="https://wordpress.org/support/article/formatting-date-and-time/" rel="external">',
'</a>' ),
481 'value' => apply_filters(
'gravityview_date_format', null ),
482 'class' =>
'code widefat',
484 'group' =>
'display',
486 'new_window' => array(
487 'type' =>
'checkbox',
488 'label' => __(
'Open link in a new tab or window?',
'gk-gravityview' ),
490 'group' =>
'display',
499 return apply_filters(
'gravityview_field_support_options', $options );
512 if( isset( $options[ $key ] ) ) {
513 $field_options[ $key ] = $options[ $key ];
516 return $field_options;
551 $this->_field_options = $field_options;
554 return $field_options;
576 if( empty( $connected_form ) ) {
580 if( empty( $connected_form ) ) {
581 gravityview()->log->error(
'Form not found for form ID "{form_id}"', array(
'form_id' => $connected_form ) );
585 $form = GFAPI::get_form( $connected_form );
588 gravityview()->log->error(
'Form not found for field ID of "{field_id}", when checking for a form with ID of "{form_id}"', array(
'field_id' => $this->_field_id,
'form_id' => $connected_form ) );
594 return ! empty(
$field->enableChoiceValue );
Modify field settings by extending this class.
__construct()
GravityView_Field constructor.
$is_numeric
boolean Is field content number-based?
add_entry_meta( $entry_meta)
Add the custom entry meta key to make it searchable and sortable.
_filter_gform_custom_merge_tags( $custom_merge_tags=array(), $form_id=0, $fields=array(), $element_id='')
Add custom merge tags to merge tag options.
replace_merge_tag( $matches=array(), $text='', $form=array(), $entry=array(), $url_encode=false, $esc_html=false)
Run GravityView filters when using GFCommon::replace_variables()
add_field_support( $key, &$field_options)
if(gravityview() ->plugin->is_GF_25()) $form
$group
standard, advanced, post, pricing, meta, gravityview, or add-ons
gravityview_get_field( $form, $field_id)
Returns the field details array of a specific form given the field id.
scale description p description
$is_sortable
boolean Can the field be sorted in search?
add_sortable_field( $fields)
Add the field to the Filter & Sort available fields.
custom_merge_tags( $form=array(), $fields=array())
Add custom Merge Tags to Merge Tag options, if custom Merge Tags exist.
gravityview_get_form_id( $view_id)
Get the connected form ID from a View ID.
is_choice_value_enabled()
Check whether the enableChoiceValue flag is set for a GF field.
$entry_meta_is_default_column
if(empty( $created_by)) $form_id
field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id)
Tap in here to modify field options.
gravityview()
The main GravityView wrapper function.
_filter_sortable_fields( $not_sortable)
Use field settings to modify whether a field is sortable.
set_default_search_label( $label='', $gf_field=null, $field=array())
Allow setting a default search label for search fields based on the field type.
if(false !==strpos( $value, '00:00')) $field_id
string $field_id ID of the field being displayed
_filter_gform_replace_merge_tags( $text, $form=array(), $entry=array(), $url_encode=false, $esc_html=false)
Match the merge tag in replacement text for the field.
static get_form( $form_id)
Returns the form object for a given Form ID.
$entry_meta_update_callback
static _POST( $name, $default=null)
Grab a value from the _POST superglobal or default.
as_array()
Returns the field as an array to be used in field pickers.