|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @file class-gravityview-field-workflow_current_status_timestamp.php |
|
4
|
|
|
* @since develop |
|
5
|
|
|
* @package GravityView |
|
6
|
|
|
* @subpackage includes\fields |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
class GravityView_Field_Workflow_Current_Status_Timestamp extends GravityView_Field { |
|
10
|
|
|
|
|
11
|
|
|
var $name = 'workflow_current_status_timestamp'; |
|
12
|
|
|
|
|
13
|
|
|
var $group = 'meta'; |
|
14
|
|
|
|
|
15
|
|
|
var $contexts = array( 'multiple', 'single' ); |
|
16
|
|
|
|
|
17
|
|
|
var $entry_meta_key = 'workflow_current_status_timestamp'; |
|
18
|
|
|
|
|
19
|
|
|
var $is_numeric = true; |
|
20
|
|
|
|
|
21
|
|
|
public function __construct() { |
|
22
|
|
|
$this->label = esc_html__( 'Workflow Current Status Timestamp', 'gravityview' ); |
|
23
|
|
|
$this->add_hooks(); |
|
24
|
|
|
parent::__construct(); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
function add_hooks() { |
|
|
|
|
|
|
28
|
|
|
add_filter( 'gravityview_field_entry_value_workflow_current_status_timestamp', array( $this, 'modify_entry_value_workflow_current_status_timestamp' ), 10, 4 ); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Convert a timestamp into a nice format. |
|
33
|
|
|
* |
|
34
|
|
|
* @param string $output HTML value output |
|
35
|
|
|
* @param array $entry The GF entry array |
|
36
|
|
|
* @param array $field_settings Settings for the particular GV field, |
|
37
|
|
|
* @param array $field Current field being displayed |
|
38
|
|
|
* |
|
39
|
|
|
* @since 1.17 |
|
40
|
|
|
* |
|
41
|
|
|
* @return string If Gravity Flow not found, or entry not processed yet, returns initial value. Otherwise, returns name of workflow step. |
|
42
|
|
|
*/ |
|
43
|
|
|
function modify_entry_value_workflow_current_status_timestamp( $output, $entry, $field_settings, $field ) { |
|
|
|
|
|
|
44
|
|
|
$timestamp = gform_get_meta( $entry['id'], 'workflow_current_status_timestamp' ); |
|
45
|
|
|
|
|
46
|
|
|
if ( ! $timestamp ) { |
|
47
|
|
|
return $timestamp; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
return GVCommon::format_date( date( 'Y-m-d H:i:s', $timestamp ), 'format=' . \GV\Utils::get( $field_settings, 'date_display' ) ); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { |
|
54
|
|
|
if ( $context == 'edit' ) { |
|
55
|
|
|
return $field_options; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
$this->add_field_support( 'date_display', $field_options ); |
|
59
|
|
|
|
|
60
|
|
|
return $field_options; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
new GravityView_Field_Workflow_Current_Status_Timestamp; |
|
65
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.