|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @file class-gravityview-field-date-updated.php |
|
4
|
|
|
* @package GravityView |
|
5
|
|
|
* @subpackage includes\fields |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
class GravityView_Field_Date_Updated extends GravityView_Field_Date_Created { |
|
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
|
|
|
/** |
|
23
|
|
|
* GravityView_Field_Date_Updated constructor. |
|
24
|
|
|
*/ |
|
25
|
|
|
public function __construct() { |
|
26
|
|
|
|
|
27
|
|
|
$this->label = esc_html__( 'Date Updated', 'gravityview' ); |
|
28
|
|
|
$this->default_search_label = $this->label; |
|
29
|
|
|
$this->description = esc_html__( 'The date the entry was last updated.', 'gravityview' ); |
|
30
|
|
|
|
|
31
|
|
|
add_filter( 'gravityview_field_entry_value_' . $this->name . '_pre_link', array( $this, 'get_content' ), 10, 4 ); |
|
32
|
|
|
|
|
33
|
|
|
parent::__construct(); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Adds support for date_display setting for the field |
|
38
|
|
|
* |
|
39
|
|
|
* @param array $field_options |
|
40
|
|
|
* @param string $template_id |
|
41
|
|
|
* @param string $field_id |
|
42
|
|
|
* @param string $context |
|
43
|
|
|
* @param string $input_type |
|
44
|
|
|
* @param $form_id |
|
45
|
|
|
* |
|
46
|
|
|
* @return array |
|
47
|
|
|
*/ |
|
48
|
|
|
public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { |
|
49
|
|
|
|
|
50
|
|
|
if( 'edit' === $context ) { |
|
51
|
|
|
return $field_options; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
$this->add_field_support('date_display', $field_options ); |
|
55
|
|
|
|
|
56
|
|
|
return $field_options; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Filter the value of the field |
|
61
|
|
|
* |
|
62
|
|
|
* @since 2.8.2 |
|
63
|
|
|
* |
|
64
|
|
|
* @param string $output HTML value output |
|
65
|
|
|
* @param array $entry The GF entry array |
|
66
|
|
|
* @param array $field_settings Settings for the particular GV field |
|
67
|
|
|
* @param array $field Current field being displayed |
|
68
|
|
|
* |
|
69
|
|
|
* @return string values for this field based on the numeric values used by Gravity Forms |
|
70
|
|
|
*/ |
|
71
|
|
|
public function get_content( $output = '', $entry = array(), $field_settings = array(), $field = array() ) { |
|
72
|
|
|
|
|
73
|
|
|
/** Overridden by a template. */ |
|
74
|
|
|
if( \GV\Utils::get( $field, 'field_path' ) !== gravityview()->plugin->dir( 'templates/fields/field-html.php' ) ) { |
|
75
|
|
|
return $output; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
return GVCommon::format_date( $field['value'], 'format=' . \GV\Utils::get( $field_settings, 'date_display' ) ); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
new GravityView_Field_Date_Updated; |
|
83
|
|
|
|