GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
class-gravityview-field-date-updated.php
Go to the documentation of this file.
1 <?php
2 /**
3  * @file class-gravityview-field-date-updated.php
4  * @package GravityView
5  * @subpackage includes\fields
6  */
7 
9 
10  var $name = 'date_updated';
11 
12  var $is_searchable = true;
13 
14  var $_custom_merge_tag = 'date_updated';
15 
16  var $search_operators = array( 'less_than', 'greater_than', 'is', 'isnot' );
17 
18  var $group = 'meta';
19 
20  var $contexts = array( 'single', 'multiple', 'export' );
21 
22  var $icon = 'dashicons-calendar-alt';
23 
24  /**
25  * GravityView_Field_Date_Updated constructor.
26  */
27  public function __construct() {
28 
29  parent::__construct();
30 
31  $this->label = esc_html__( 'Date Updated', 'gk-gravityview' );
32  $this->default_search_label = $this->label;
33  $this->description = esc_html__( 'The date the entry was last updated.', 'gk-gravityview' );
34 
35  add_filter( 'gravityview_field_entry_value_' . $this->name . '_pre_link', array( $this, 'get_content' ), 10, 4 );
36  }
37 
38  /**
39  * Adds support for date_display setting for the field
40  *
41  * @param array $field_options
42  * @param string $template_id
43  * @param string $field_id
44  * @param string $context
45  * @param string $input_type
46  * @param $form_id
47  *
48  * @return array
49  */
50  public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) {
51 
52  if( 'edit' === $context ) {
53  return $field_options;
54  }
55 
56  $this->add_field_support('date_display', $field_options );
57 
58  return $field_options;
59  }
60 
61  /**
62  * Filter the value of the field
63  *
64  * @since 2.8.2
65  *
66  * @param string $output HTML value output
67  * @param array $entry The GF entry array
68  * @param array $field_settings Settings for the particular GV field
69  * @param array $field Current field being displayed
70  *
71  * @return string values for this field based on the numeric values used by Gravity Forms
72  */
73  public function get_content( $output = '', $entry = array(), $field_settings = array(), $field = array() ) {
74 
75  /** Overridden by a template. */
76  if( \GV\Utils::get( $field, 'field_path' ) !== gravityview()->plugin->dir( 'templates/fields/field-html.php' ) ) {
77  return $output;
78  }
79 
80  return GVCommon::format_date( $field['value'], 'format=' . \GV\Utils::get( $field_settings, 'date_display' ) );
81  }
82 }
83 
__construct()
GravityView_Field_Date_Updated constructor.
$field_settings['content']
Definition: custom.php:27
add_field_support( $key, &$field_options)
get_content( $output='', $entry=array(), $field_settings=array(), $field=array())
Filter the value of the field.
scale description p description
field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id)
Adds support for date_display setting for the field.
static format_date( $date_string='', $args=array())
Allow formatting date and time based on GravityView standards.
if(empty( $created_by)) $form_id
gravityview()
The main GravityView wrapper function.
$entry
Definition: notes.php:27
if(false !==strpos( $value, '00:00')) $field_id
string $field_id ID of the field being displayed
Definition: time.php:22