Completed
Branch master (44537d)
by
unknown
14:30 queued 10:03
created
core/db_models/fields/EE_Full_HTML_Field.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -13,56 +13,56 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Full_HTML_Field extends EE_Text_Field_Base
15 15
 {
16
-    /**
17
-     * @param string $table_column
18
-     * @param string $nicename
19
-     * @param bool   $nullable
20
-     * @param null   $default_value
21
-     */
22
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
23
-    {
24
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
25
-        $this->setSchemaType('object');
26
-    }
16
+	/**
17
+	 * @param string $table_column
18
+	 * @param string $nicename
19
+	 * @param bool   $nullable
20
+	 * @param null   $default_value
21
+	 */
22
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
23
+	{
24
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
25
+		$this->setSchemaType('object');
26
+	}
27 27
 
28 28
 
29
-    /**
30
-     * Does shortcodes and auto-paragraphs the content (unless schema is 'no_wpautop')
31
-     *
32
-     * @param mixed       $value_on_field_to_be_outputted
33
-     * @param string|null $schema
34
-     * @return string
35
-     */
36
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null)
37
-    {
38
-        if ($schema == 'form_input') {
39
-            return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema);
40
-        } elseif ($schema == 'no_wpautop') {
41
-            return do_shortcode(parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema));
42
-        } else {
43
-            return wpautop(do_shortcode(parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema)));
44
-        }
45
-    }
29
+	/**
30
+	 * Does shortcodes and auto-paragraphs the content (unless schema is 'no_wpautop')
31
+	 *
32
+	 * @param mixed       $value_on_field_to_be_outputted
33
+	 * @param string|null $schema
34
+	 * @return string
35
+	 */
36
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null)
37
+	{
38
+		if ($schema == 'form_input') {
39
+			return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema);
40
+		} elseif ($schema == 'no_wpautop') {
41
+			return do_shortcode(parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema));
42
+		} else {
43
+			return wpautop(do_shortcode(parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema)));
44
+		}
45
+	}
46 46
 
47 47
 
48
-    public function getSchemaProperties(): array
49
-    {
50
-        return [
51
-            'raw'      => [
52
-                'description' => sprintf(
53
-                    esc_html__('%s - the value in the database.', 'event_espresso'),
54
-                    $this->get_nicename()
55
-                ),
56
-                'type'        => 'string',
57
-            ],
58
-            'rendered' => [
59
-                'description' => sprintf(
60
-                    esc_html__('%s - transformed for display.', 'event_espresso'),
61
-                    $this->get_nicename()
62
-                ),
63
-                'type'        => 'string',
64
-                'readonly'    => true,
65
-            ],
66
-        ];
67
-    }
48
+	public function getSchemaProperties(): array
49
+	{
50
+		return [
51
+			'raw'      => [
52
+				'description' => sprintf(
53
+					esc_html__('%s - the value in the database.', 'event_espresso'),
54
+					$this->get_nicename()
55
+				),
56
+				'type'        => 'string',
57
+			],
58
+			'rendered' => [
59
+				'description' => sprintf(
60
+					esc_html__('%s - transformed for display.', 'event_espresso'),
61
+					$this->get_nicename()
62
+				),
63
+				'type'        => 'string',
64
+				'readonly'    => true,
65
+			],
66
+		];
67
+	}
68 68
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Infinite_Integer_Field.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -9,77 +9,77 @@
 block discarded – undo
9 9
  */
10 10
 class EE_Infinite_Integer_Field extends EE_Model_Field_Base
11 11
 {
12
-    /**
13
-     * @param string $table_column
14
-     * @param string $nicename
15
-     * @param bool   $nullable
16
-     * @param null   $default_value
17
-     */
18
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
19
-    {
20
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
21
-        $this->setSchemaType(['integer', 'null']);
22
-    }
12
+	/**
13
+	 * @param string $table_column
14
+	 * @param string $nicename
15
+	 * @param bool   $nullable
16
+	 * @param null   $default_value
17
+	 */
18
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
19
+	{
20
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
21
+		$this->setSchemaType(['integer', 'null']);
22
+	}
23 23
 
24 24
 
25
-    public function prepare_for_use_in_db($value_of_field_on_model_object)
26
-    {
27
-        if ($value_of_field_on_model_object === EE_INF) {
28
-            return EE_INF_IN_DB;
29
-        }
30
-        return (int) $value_of_field_on_model_object;
31
-    }
25
+	public function prepare_for_use_in_db($value_of_field_on_model_object)
26
+	{
27
+		if ($value_of_field_on_model_object === EE_INF) {
28
+			return EE_INF_IN_DB;
29
+		}
30
+		return (int) $value_of_field_on_model_object;
31
+	}
32 32
 
33 33
 
34
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
35
-    {
36
-        if (
37
-            $value_inputted_for_field_on_model_object === EE_INF_IN_DB ||
38
-            $value_inputted_for_field_on_model_object === EE_INF ||
39
-            $value_inputted_for_field_on_model_object === "EE_INF" ||
40
-            $value_inputted_for_field_on_model_object === ""
41
-        ) {
42
-            return EE_INF;
43
-        }
44
-        return (int) $value_inputted_for_field_on_model_object;
45
-    }
34
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
35
+	{
36
+		if (
37
+			$value_inputted_for_field_on_model_object === EE_INF_IN_DB ||
38
+			$value_inputted_for_field_on_model_object === EE_INF ||
39
+			$value_inputted_for_field_on_model_object === "EE_INF" ||
40
+			$value_inputted_for_field_on_model_object === ""
41
+		) {
42
+			return EE_INF;
43
+		}
44
+		return (int) $value_inputted_for_field_on_model_object;
45
+	}
46 46
 
47 47
 
48
-    public function prepare_for_set_from_db($value_inputted_for_field_on_model_object)
49
-    {
50
-        $intval = (int) $value_inputted_for_field_on_model_object;
51
-        if ($intval == EE_INF_IN_DB) {
52
-            return EE_INF;
53
-        }
54
-        return $intval;
55
-    }
48
+	public function prepare_for_set_from_db($value_inputted_for_field_on_model_object)
49
+	{
50
+		$intval = (int) $value_inputted_for_field_on_model_object;
51
+		if ($intval == EE_INF_IN_DB) {
52
+			return EE_INF;
53
+		}
54
+		return $intval;
55
+	}
56 56
 
57 57
 
58
-    /**
59
-     * For outputting this field's value. If you want to output it into an input or something,
60
-     * use $schema=='input', as it will replace EE_INF with ''. If you want a readable version, use $schema=='text'
61
-     * as it will replace EE_INF with i18n Infinite
62
-     *
63
-     * @param mixed       $value_on_field_to_be_outputted
64
-     * @param string|null $schema input, symbol, text; or any string you want to show if the value equals EE_INF
65
-     * @return string
66
-     */
67
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null)
68
-    {
69
-        if ($value_on_field_to_be_outputted === EE_INF) {
70
-            switch ($schema) {
71
-                case 'input':
72
-                case 'form_input':
73
-                    return '';
74
-                case 'symbol':
75
-                    return "∞";
76
-                case 'text':
77
-                case null:
78
-                    return esc_html__("Unlimited", "event_espresso");
79
-                default:
80
-                    return $schema;
81
-            }
82
-        }
83
-        return $value_on_field_to_be_outputted;
84
-    }
58
+	/**
59
+	 * For outputting this field's value. If you want to output it into an input or something,
60
+	 * use $schema=='input', as it will replace EE_INF with ''. If you want a readable version, use $schema=='text'
61
+	 * as it will replace EE_INF with i18n Infinite
62
+	 *
63
+	 * @param mixed       $value_on_field_to_be_outputted
64
+	 * @param string|null $schema input, symbol, text; or any string you want to show if the value equals EE_INF
65
+	 * @return string
66
+	 */
67
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null)
68
+	{
69
+		if ($value_on_field_to_be_outputted === EE_INF) {
70
+			switch ($schema) {
71
+				case 'input':
72
+				case 'form_input':
73
+					return '';
74
+				case 'symbol':
75
+					return "∞";
76
+				case 'text':
77
+				case null:
78
+					return esc_html__("Unlimited", "event_espresso");
79
+				default:
80
+					return $schema;
81
+			}
82
+		}
83
+		return $value_on_field_to_be_outputted;
84
+	}
85 85
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Enum_Text_Field.php 2 patches
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -10,121 +10,121 @@
 block discarded – undo
10 10
  */
11 11
 class EE_Enum_Text_Field extends EE_Text_Field_Base
12 12
 {
13
-    public array $_allowed_enum_values;
13
+	public array $_allowed_enum_values;
14 14
 
15 15
 
16
-    /**
17
-     * @param string  $table_column
18
-     * @param string  $nice_name
19
-     * @param boolean $nullable
20
-     * @param mixed   $default_value
21
-     * @param array   $allowed_enum_values keys are values to be used in the DB, values are how they should be displayed
22
-     */
23
-    public function __construct($table_column, $nice_name, $nullable, $default_value, $allowed_enum_values)
24
-    {
25
-        $this->_allowed_enum_values = (array) $allowed_enum_values;
26
-        parent::__construct($table_column, $nice_name, $nullable, $default_value);
27
-        $this->setSchemaType('object');
28
-    }
16
+	/**
17
+	 * @param string  $table_column
18
+	 * @param string  $nice_name
19
+	 * @param boolean $nullable
20
+	 * @param mixed   $default_value
21
+	 * @param array   $allowed_enum_values keys are values to be used in the DB, values are how they should be displayed
22
+	 */
23
+	public function __construct($table_column, $nice_name, $nullable, $default_value, $allowed_enum_values)
24
+	{
25
+		$this->_allowed_enum_values = (array) $allowed_enum_values;
26
+		parent::__construct($table_column, $nice_name, $nullable, $default_value);
27
+		$this->setSchemaType('object');
28
+	}
29 29
 
30 30
 
31
-    /**
32
-     * Returns the list of allowed enum options, but filterable.
33
-     * This is used internally
34
-     *
35
-     * @return array
36
-     */
37
-    protected function _allowed_enum_values()
38
-    {
39
-        return (array) apply_filters(
40
-            'FHEE__EE_Enum_Text_Field___allowed_enum_options',
41
-            $this->_allowed_enum_values,
42
-            $this
43
-        );
44
-    }
31
+	/**
32
+	 * Returns the list of allowed enum options, but filterable.
33
+	 * This is used internally
34
+	 *
35
+	 * @return array
36
+	 */
37
+	protected function _allowed_enum_values()
38
+	{
39
+		return (array) apply_filters(
40
+			'FHEE__EE_Enum_Text_Field___allowed_enum_options',
41
+			$this->_allowed_enum_values,
42
+			$this
43
+		);
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * When setting, just verify that the value being used matches what we've defined as allowable enum values.
49
-     * If not, throw an error (but if WP_DEBUG is false, just set the value to default).
50
-     *
51
-     * @param string $value_inputted_for_field_on_model_object
52
-     * @return string
53
-     */
54
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
55
-    {
56
-        if (
57
-            $value_inputted_for_field_on_model_object !== null
58
-            && ! array_key_exists($value_inputted_for_field_on_model_object, $this->_allowed_enum_values())
59
-        ) {
60
-            if (defined('WP_DEBUG') && WP_DEBUG) {
61
-                $msg  = sprintf(
62
-                    esc_html__('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
63
-                    $value_inputted_for_field_on_model_object,
64
-                    $this->_name
65
-                );
66
-                $msg2 = sprintf(
67
-                    esc_html__('Allowed values for "%1$s" are "%2$s". You provided: "%3$s"', 'event_espresso'),
68
-                    $this->_name,
69
-                    implode(', ', array_keys($this->_allowed_enum_values())),
70
-                    $value_inputted_for_field_on_model_object
71
-                );
72
-                EE_Error::add_error("$msg||$msg2", __FILE__, __FUNCTION__, __LINE__);
73
-            }
74
-            return $this->get_default_value();
75
-        }
76
-        return $value_inputted_for_field_on_model_object;
77
-    }
47
+	/**
48
+	 * When setting, just verify that the value being used matches what we've defined as allowable enum values.
49
+	 * If not, throw an error (but if WP_DEBUG is false, just set the value to default).
50
+	 *
51
+	 * @param string $value_inputted_for_field_on_model_object
52
+	 * @return string
53
+	 */
54
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
55
+	{
56
+		if (
57
+			$value_inputted_for_field_on_model_object !== null
58
+			&& ! array_key_exists($value_inputted_for_field_on_model_object, $this->_allowed_enum_values())
59
+		) {
60
+			if (defined('WP_DEBUG') && WP_DEBUG) {
61
+				$msg  = sprintf(
62
+					esc_html__('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
63
+					$value_inputted_for_field_on_model_object,
64
+					$this->_name
65
+				);
66
+				$msg2 = sprintf(
67
+					esc_html__('Allowed values for "%1$s" are "%2$s". You provided: "%3$s"', 'event_espresso'),
68
+					$this->_name,
69
+					implode(', ', array_keys($this->_allowed_enum_values())),
70
+					$value_inputted_for_field_on_model_object
71
+				);
72
+				EE_Error::add_error("$msg||$msg2", __FILE__, __FUNCTION__, __LINE__);
73
+			}
74
+			return $this->get_default_value();
75
+		}
76
+		return $value_inputted_for_field_on_model_object;
77
+	}
78 78
 
79 79
 
80
-    /**
81
-     * Gets the pretty version of the enum's value.
82
-     *
83
-     * @param int|string  $value_on_field_to_be_outputted
84
-     * @param string|null $schema
85
-     * @return    string
86
-     */
87
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null)
88
-    {
89
-        $options = $this->_allowed_enum_values();
90
-        return $options[ $value_on_field_to_be_outputted ] ?? $value_on_field_to_be_outputted;
91
-    }
80
+	/**
81
+	 * Gets the pretty version of the enum's value.
82
+	 *
83
+	 * @param int|string  $value_on_field_to_be_outputted
84
+	 * @param string|null $schema
85
+	 * @return    string
86
+	 */
87
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null)
88
+	{
89
+		$options = $this->_allowed_enum_values();
90
+		return $options[ $value_on_field_to_be_outputted ] ?? $value_on_field_to_be_outputted;
91
+	}
92 92
 
93 93
 
94
-    /**
95
-     * When retrieving something from the DB, don't enforce the enum's options. If it's in the DB, we just have to live
96
-     * with that. Note also: when we're saving to the DB again, we also don't enforce the enum options. It's ONLY
97
-     * when we're receiving USER input from prepare_for_set() that we enforce the enum options.
98
-     *
99
-     * @param mixed $value_in_db
100
-     * @return mixed
101
-     */
102
-    public function prepare_for_set_from_db($value_in_db)
103
-    {
104
-        return $value_in_db;
105
-    }
94
+	/**
95
+	 * When retrieving something from the DB, don't enforce the enum's options. If it's in the DB, we just have to live
96
+	 * with that. Note also: when we're saving to the DB again, we also don't enforce the enum options. It's ONLY
97
+	 * when we're receiving USER input from prepare_for_set() that we enforce the enum options.
98
+	 *
99
+	 * @param mixed $value_in_db
100
+	 * @return mixed
101
+	 */
102
+	public function prepare_for_set_from_db($value_in_db)
103
+	{
104
+		return $value_in_db;
105
+	}
106 106
 
107 107
 
108
-    public function getSchemaProperties(): array
109
-    {
110
-        return [
111
-            'raw'    => [
112
-                'description' => sprintf(
113
-                    esc_html__('%s - the value in the database.', 'event_espresso'),
114
-                    $this->get_nicename()
115
-                ),
116
-                'type'        => 'string',
117
-                'enum'        => array_keys($this->_allowed_enum_values),
118
-            ],
119
-            'pretty' => [
120
-                'description' => sprintf(
121
-                    esc_html__('%s - the value for display.', 'event_espresso'),
122
-                    $this->get_nicename()
123
-                ),
124
-                'type'        => 'string',
125
-                'enum'        => array_values($this->_allowed_enum_values),
126
-                'read_only'   => true,
127
-            ],
128
-        ];
129
-    }
108
+	public function getSchemaProperties(): array
109
+	{
110
+		return [
111
+			'raw'    => [
112
+				'description' => sprintf(
113
+					esc_html__('%s - the value in the database.', 'event_espresso'),
114
+					$this->get_nicename()
115
+				),
116
+				'type'        => 'string',
117
+				'enum'        => array_keys($this->_allowed_enum_values),
118
+			],
119
+			'pretty' => [
120
+				'description' => sprintf(
121
+					esc_html__('%s - the value for display.', 'event_espresso'),
122
+					$this->get_nicename()
123
+				),
124
+				'type'        => 'string',
125
+				'enum'        => array_values($this->_allowed_enum_values),
126
+				'read_only'   => true,
127
+			],
128
+		];
129
+	}
130 130
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
             && ! array_key_exists($value_inputted_for_field_on_model_object, $this->_allowed_enum_values())
59 59
         ) {
60 60
             if (defined('WP_DEBUG') && WP_DEBUG) {
61
-                $msg  = sprintf(
61
+                $msg = sprintf(
62 62
                     esc_html__('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
63 63
                     $value_inputted_for_field_on_model_object,
64 64
                     $this->_name
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null)
88 88
     {
89 89
         $options = $this->_allowed_enum_values();
90
-        return $options[ $value_on_field_to_be_outputted ] ?? $value_on_field_to_be_outputted;
90
+        return $options[$value_on_field_to_be_outputted] ?? $value_on_field_to_be_outputted;
91 91
     }
92 92
 
93 93
 
Please login to merge, or discard this patch.
core/db_models/fields/EE_Primary_Key_Field_Base.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -2,26 +2,26 @@
 block discarded – undo
2 2
 
3 3
 abstract class EE_Primary_Key_Field_Base extends EE_Field_With_Model_Name
4 4
 {
5
-    /**
6
-     * Overrides parent so it doesn't need to provide so many non-applicable fields
7
-     *
8
-     * @param string $table_column
9
-     * @param string $nicename
10
-     */
11
-    public function __construct($table_column, $nicename, $default)
12
-    {
13
-        parent::__construct($table_column, $nicename, false, $default, '');
14
-    }
5
+	/**
6
+	 * Overrides parent so it doesn't need to provide so many non-applicable fields
7
+	 *
8
+	 * @param string $table_column
9
+	 * @param string $nicename
10
+	 */
11
+	public function __construct($table_column, $nicename, $default)
12
+	{
13
+		parent::__construct($table_column, $nicename, false, $default, '');
14
+	}
15 15
 
16 16
 
17
-    /**
18
-     * @param string $table_alias
19
-     * @param string $name
20
-     * @param string $model_name
21
-     */
22
-    public function _construct_finalize(string $table_alias, string $name, string $model_name)
23
-    {
24
-        $this->_model_name_pointed_to = $model_name;
25
-        parent::_construct_finalize($table_alias, $name, $model_name);
26
-    }
17
+	/**
18
+	 * @param string $table_alias
19
+	 * @param string $name
20
+	 * @param string $model_name
21
+	 */
22
+	public function _construct_finalize(string $table_alias, string $name, string $model_name)
23
+	{
24
+		$this->_model_name_pointed_to = $model_name;
25
+		parent::_construct_finalize($table_alias, $name, $model_name);
26
+	}
27 27
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Datetime_Field.php 2 patches
Indentation   +760 added lines, -760 removed lines patch added patch discarded remove patch
@@ -17,764 +17,764 @@
 block discarded – undo
17 17
  */
18 18
 class EE_Datetime_Field extends EE_Model_Field_Base
19 19
 {
20
-    /**
21
-     * The pattern we're looking for is if only the characters 0-9 are found and there are only
22
-     * 10 or more numbers (because 9 numbers even with all 9's would be sometime in 2001 )
23
-     *
24
-     * @type string unix_timestamp_regex
25
-     */
26
-    const unix_timestamp_regex = '/[0-9]{10,}/';
27
-
28
-    /**
29
-     * @type string mysql_timestamp_format
30
-     */
31
-    const mysql_timestamp_format = 'Y-m-d H:i:s';
32
-
33
-    /**
34
-     * @type string mysql_date_format
35
-     */
36
-    const mysql_date_format = 'Y-m-d';
37
-
38
-    /**
39
-     * @type string mysql_time_format
40
-     */
41
-    const mysql_time_format = 'H:i:s';
42
-
43
-    /**
44
-     * Const for using in the default value. If the field's default is set to this,
45
-     * then we will return the time of calling `get_default_value()`, not
46
-     * just the current time at construction
47
-     */
48
-    const now = 'now';
49
-
50
-    /**
51
-     * The following properties hold the default formats for date and time.
52
-     * Defaults are set via the constructor and can be overridden on class instantiation.
53
-     * However they can also be overridden later by the set_format() method
54
-     * (and corresponding set_date_format, set_time_format methods);
55
-     */
56
-
57
-    protected string        $_date_format        = '';
58
-
59
-    protected string        $_time_format        = '';
60
-
61
-    protected string        $_pretty_date_format = '';
62
-
63
-    protected string        $_pretty_time_format = '';
64
-
65
-    protected ?DateTimeZone $_DateTimeZone       = null;
66
-
67
-    protected ?DateTimeZone $_UTC_DateTimeZone   = null;
68
-
69
-    protected ?DateTimeZone $_blog_DateTimeZone  = null;
70
-
71
-
72
-    /**
73
-     * This property holds how we want the output returned when getting a datetime string.  It is set for the
74
-     * set_date_time_output() method.  By default this is empty.  When empty, we are assuming that we want both date
75
-     * and time returned via getters.
76
-     *
77
-     * @var mixed (null|string)
78
-     */
79
-    protected $_date_time_output;
80
-
81
-
82
-    /**
83
-     * timezone string
84
-     * This gets set by the constructor and can be changed by the "set_timezone()" method so that we know what timezone
85
-     * incoming strings|timestamps are in.  This can also be used before a get to set what timezone you want strings
86
-     * coming out of the object to be in.  Default timezone is the current WP timezone option setting
87
-     */
88
-    protected ?string $_timezone_string = null;
89
-
90
-
91
-    /**
92
-     * This holds whatever UTC offset for the blog (we automatically convert timezone strings into their related
93
-     * offsets for comparison purposes).
94
-     *
95
-     * @var int
96
-     */
97
-    protected int $_blog_offset = 0;
98
-
99
-
100
-    /**
101
-     * @param string      $table_column
102
-     * @param string      $nice_name
103
-     * @param bool        $nullable
104
-     * @param string|null $default_value
105
-     * @param string|null $timezone_string
106
-     * @param string|null $date_format
107
-     * @param string|null $time_format
108
-     * @param string|null $pretty_date_format
109
-     * @param string|null $pretty_time_format
110
-     * @throws InvalidArgumentException
111
-     * @throws Exception
112
-     */
113
-    public function __construct(
114
-        string $table_column,
115
-        string $nice_name,
116
-        bool $nullable,
117
-        ?string $default_value,
118
-        ?string $timezone_string = '',
119
-        ?string $date_format = '',
120
-        ?string $time_format = '',
121
-        ?string $pretty_date_format = '',
122
-        ?string $pretty_time_format = ''
123
-    ) {
124
-        $this->set_date_format($date_format);
125
-        $this->set_time_format($time_format);
126
-        $this->set_date_format($pretty_date_format, true);
127
-        $this->set_time_format($pretty_time_format, true);
128
-
129
-        parent::__construct($table_column, $nice_name, $nullable, $default_value);
130
-        $this->set_timezone($timezone_string);
131
-        $this->setSchemaFormat('date-time');
132
-    }
133
-
134
-
135
-    /**
136
-     * @return DateTimeZone
137
-     * @throws Exception
138
-     */
139
-    public function get_UTC_DateTimeZone(): DateTimeZone
140
-    {
141
-        return $this->_UTC_DateTimeZone instanceof DateTimeZone
142
-            ? $this->_UTC_DateTimeZone
143
-            : $this->_create_timezone_object_from_timezone_string('UTC');
144
-    }
145
-
146
-
147
-    /**
148
-     * @return DateTimeZone
149
-     * @throws Exception
150
-     */
151
-    public function get_blog_DateTimeZone(): DateTimeZone
152
-    {
153
-        return $this->_blog_DateTimeZone instanceof DateTimeZone
154
-            ? $this->_blog_DateTimeZone
155
-            : $this->_create_timezone_object_from_timezone_string();
156
-    }
157
-
158
-
159
-    /**
160
-     * this prepares any incoming date data and make sure its converted to a utc unix timestamp
161
-     *
162
-     * @param string|int $value_inputted_for_field_on_model_object  could be a string formatted date time or int unix
163
-     *                                                              timestamp
164
-     * @return DateTime
165
-     * @throws Exception
166
-     */
167
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
168
-    {
169
-        return $this->_get_date_object($value_inputted_for_field_on_model_object);
170
-    }
171
-
172
-
173
-    /**
174
-     * This returns the format string to be used by getters depending on what the $_date_time_output property is set at.
175
-     * getters need to know whether we're just returning the date or the time or both.  By default we return both.
176
-     *
177
-     * @param bool $pretty If we're returning the pretty formats or standard format string.
178
-     * @return string    The final assembled format string.
179
-     */
180
-    protected function _get_date_time_output(bool $pretty = false): string
181
-    {
182
-        switch ($this->_date_time_output) {
183
-            case 'time':
184
-                return $pretty
185
-                    ? $this->_pretty_time_format
186
-                    : $this->_time_format;
187
-
188
-            case 'date':
189
-                return $pretty
190
-                    ? $this->_pretty_date_format
191
-                    : $this->_date_format;
192
-
193
-            default:
194
-                return $pretty
195
-                    ? trim($this->_pretty_date_format . ' ' . $this->_pretty_time_format)
196
-                    : trim($this->_date_format . ' ' . $this->_time_format);
197
-        }
198
-    }
199
-
200
-
201
-    /**
202
-     * This just sets the $_date_time_output property so we can flag how date and times are formatted before being
203
-     * returned (using the format properties)
204
-     *
205
-     * @param string|null $what acceptable values are 'time' or 'date'.
206
-     *                          Any other value will be set but will always result
207
-     *                          in both 'date' and 'time' being returned.
208
-     * @return void
209
-     */
210
-    public function set_date_time_output(?string $what = null)
211
-    {
212
-        $this->_date_time_output = $what;
213
-    }
214
-
215
-
216
-    /**
217
-     * See $_timezone property for description of what the timezone property is for.  This SETS the timezone internally
218
-     * for being able to reference what timezone we are running conversions on when converting TO the internal timezone
219
-     * (UTC Unix Timestamp) for the object OR when converting FROM the internal timezone (UTC Unix Timestamp).
220
-     * We also set some other properties in this method.
221
-     *
222
-     * @param string|null $timezone_string A valid timezone string as described by @link
223
-     *                                     http://www.php.net/manual/en/timezones.php
224
-     * @return void
225
-     * @throws InvalidArgumentException
226
-     * @throws InvalidDataTypeException
227
-     * @throws InvalidInterfaceException
228
-     * @throws Exception
229
-     */
230
-    public function set_timezone(?string $timezone_string = '')
231
-    {
232
-        if (empty($timezone_string) && $this->_timezone_string !== null) {
233
-            // leave the timezone AS-IS if we already have one and
234
-            // the function arg didn't provide one
235
-            return;
236
-        }
237
-        $timezone_string        = EEH_DTT_Helper::get_valid_timezone_string($timezone_string);
238
-        $this->_timezone_string = ! empty($timezone_string)
239
-            ? $timezone_string
240
-            : 'UTC';
241
-        $this->_DateTimeZone    = $this->_create_timezone_object_from_timezone_string($this->_timezone_string);
242
-    }
243
-
244
-
245
-    /**
246
-     * _create_timezone_object_from_timezone_name
247
-     *
248
-     * @access protected
249
-     * @param string|null $timezone_string
250
-     * @return DateTimeZone
251
-     * @throws InvalidArgumentException
252
-     * @throws InvalidDataTypeException
253
-     * @throws InvalidInterfaceException
254
-     * @throws Exception
255
-     */
256
-    protected function _create_timezone_object_from_timezone_string(?string $timezone_string = ''): DateTimeZone
257
-    {
258
-        return new DateTimeZone(EEH_DTT_Helper::get_valid_timezone_string($timezone_string));
259
-    }
260
-
261
-
262
-    /**
263
-     * This just returns whatever is set for the current timezone.
264
-     *
265
-     * @access public
266
-     * @return string timezone string
267
-     */
268
-    public function get_timezone(): ?string
269
-    {
270
-        return $this->_timezone_string;
271
-    }
272
-
273
-
274
-    /**
275
-     * set the $_date_format property
276
-     *
277
-     * @access public
278
-     * @param string $format a new date format (corresponding to formats accepted by PHP date() function)
279
-     * @param bool   $pretty Whether to set pretty format or not.
280
-     * @return void
281
-     */
282
-    public function set_date_format(string $format, bool $pretty = false)
283
-    {
284
-        if ($pretty) {
285
-            $this->_pretty_date_format = new DateFormat($format);
286
-        } else {
287
-            $this->_date_format = new DateFormat($format);
288
-        }
289
-    }
290
-
291
-
292
-    /**
293
-     * return the $_date_format property value.
294
-     *
295
-     * @param bool $pretty Whether to get pretty format or not.
296
-     * @return string
297
-     */
298
-    public function get_date_format(bool $pretty = false): string
299
-    {
300
-        return $pretty
301
-            ? $this->_pretty_date_format
302
-            : $this->_date_format;
303
-    }
304
-
305
-
306
-    /**
307
-     * set the $_time_format property
308
-     *
309
-     * @access public
310
-     * @param string $format a new time format (corresponding to formats accepted by PHP date() function)
311
-     * @param bool   $pretty Whether to set pretty format or not.
312
-     * @return void
313
-     */
314
-    public function set_time_format(string $format, bool $pretty = false)
315
-    {
316
-        if ($pretty) {
317
-            $this->_pretty_time_format = new TimeFormat($format);
318
-        } else {
319
-            $this->_time_format = new TimeFormat($format);
320
-        }
321
-    }
322
-
323
-
324
-    /**
325
-     * return the $_time_format property value.
326
-     *
327
-     * @param bool $pretty Whether to get pretty format or not.
328
-     * @return string
329
-     */
330
-    public function get_time_format(bool $pretty = false): string
331
-    {
332
-        return $pretty
333
-            ? $this->_pretty_time_format
334
-            : $this->_time_format;
335
-    }
336
-
337
-
338
-    /**
339
-     * set the $_pretty_date_format property
340
-     *
341
-     * @access public
342
-     * @param string|null $format a new pretty date format (corresponding to formats accepted by PHP date() function)
343
-     * @return void
344
-     */
345
-    public function set_pretty_date_format(?string $format)
346
-    {
347
-        $this->set_date_format($format, true);
348
-    }
349
-
350
-
351
-    /**
352
-     * set the $_pretty_time_format property
353
-     *
354
-     * @access public
355
-     * @param string|null $format a new pretty time format (corresponding to formats accepted by PHP date() function)
356
-     * @return void
357
-     */
358
-    public function set_pretty_time_format(?string $format)
359
-    {
360
-        $this->set_time_format($format, true);
361
-    }
362
-
363
-
364
-    /**
365
-     * Only sets the time portion of the datetime.
366
-     *
367
-     * @param string|DateTime $time_to_set_string like 8am OR a DateTime object.
368
-     * @param DateTime        $current            current DateTime object for the datetime field
369
-     * @return DateTime
370
-     */
371
-    public function prepare_for_set_with_new_time($time_to_set_string, DateTime $current): DateTime
372
-    {
373
-        // if $time_to_set_string is datetime object, then let's use it to set the parse array.
374
-        // Otherwise parse the string.
375
-        if ($time_to_set_string instanceof DateTime) {
376
-            $parsed = [
377
-                'hour'   => $time_to_set_string->format('H'),
378
-                'minute' => $time_to_set_string->format('i'),
379
-                'second' => $time_to_set_string->format('s'),
380
-            ];
381
-        } else {
382
-            // parse incoming string
383
-            $parsed = date_parse_from_format($this->_time_format, $time_to_set_string);
384
-        }
385
-        EEH_DTT_Helper::setTimezone($current, $this->_DateTimeZone);
386
-        return $current->setTime($parsed['hour'], $parsed['minute'], $parsed['second']);
387
-    }
388
-
389
-
390
-    /**
391
-     * Only sets the date portion of the datetime.
392
-     *
393
-     * @param string|DateTime $date_to_set_string like Friday, January 8th or a DateTime object.
394
-     * @param DateTime        $current            current DateTime object for the datetime field
395
-     * @return DateTime
396
-     */
397
-    public function prepare_for_set_with_new_date($date_to_set_string, DateTime $current): DateTime
398
-    {
399
-        // if $time_to_set_string is datetime object, then let's use it to set the parse array.
400
-        // Otherwise parse the string.
401
-        if ($date_to_set_string instanceof DateTime) {
402
-            $parsed = [
403
-                'year'  => $date_to_set_string->format('Y'),
404
-                'month' => $date_to_set_string->format('m'),
405
-                'day'   => $date_to_set_string->format('d'),
406
-            ];
407
-        } else {
408
-            // parse incoming string
409
-            $parsed = date_parse_from_format($this->_date_format, $date_to_set_string);
410
-        }
411
-        EEH_DTT_Helper::setTimezone($current, $this->_DateTimeZone);
412
-        return $current->setDate($parsed['year'], $parsed['month'], $parsed['day']);
413
-    }
414
-
415
-
416
-    /**
417
-     * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0 timezone).  When the
418
-     * datetime gets to this stage it should ALREADY be in UTC time
419
-     *
420
-     * @param DateTime $DateTime
421
-     * @return string formatted date time for given timezone
422
-     * @throws EE_Error
423
-     */
424
-    public function prepare_for_get($DateTime): string
425
-    {
426
-        return $this->_prepare_for_display($DateTime);
427
-    }
428
-
429
-
430
-    /**
431
-     * This differs from prepare_for_get in that it considers whether the internal $_timezone differs
432
-     * from the set wp timezone.  If so, then it returns the datetime string formatted via
433
-     * _pretty_date_format, and _pretty_time_format.  However, it also appends a timezone
434
-     * abbreviation to the date_string.
435
-     *
436
-     * @param mixed       $DateTime
437
-     * @param string|null $schema
438
-     * @return string
439
-     * @throws EE_Error
440
-     */
441
-    public function prepare_for_pretty_echoing($DateTime, ?string $schema = null): string
442
-    {
443
-        $schema = $schema ?: true;
444
-        return $this->_prepare_for_display($DateTime, $schema);
445
-    }
446
-
447
-
448
-    /**
449
-     * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0
450
-     * timezone).
451
-     *
452
-     * @param DateTime|null $DateTime
453
-     * @param bool|string   $schema
454
-     * @return string
455
-     * @throws EE_Error
456
-     * @throws Exception
457
-     */
458
-    protected function _prepare_for_display(?DateTime $DateTime, $schema = false): string
459
-    {
460
-        if (! $DateTime instanceof DateTime) {
461
-            if ($this->_nullable) {
462
-                return '';
463
-            }
464
-            if (WP_DEBUG) {
465
-                throw new EE_Error(
466
-                    sprintf(
467
-                        esc_html__(
468
-                            'EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.',
469
-                            'event_espresso'
470
-                        ),
471
-                        $this->_nicename
472
-                    )
473
-                );
474
-            }
475
-            $DateTime = new DbSafeDateTime(EE_Datetime_Field::now);
476
-            EE_Error::add_error(
477
-                sprintf(
478
-                    esc_html__(
479
-                        'EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.  When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.',
480
-                        'event_espresso'
481
-                    ),
482
-                    $this->_nicename
483
-                ),
484
-                __FILE__,
485
-                __FUNCTION__,
486
-                __LINE__
487
-            );
488
-        }
489
-        $format_string = $this->_get_date_time_output($schema);
490
-        EEH_DTT_Helper::setTimezone($DateTime, $this->_DateTimeZone);
491
-        if ($schema) {
492
-            $timezone_string = '';
493
-            if ($this->_display_timezone()) {
494
-                // must be explicit because schema could equal true.
495
-                if ($schema === 'no_html') {
496
-                    $timezone_string = ' (' . $DateTime->format('T') . ')';
497
-                } else {
498
-                    $timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format('T') . ')</span>';
499
-                }
500
-            }
501
-
502
-            return $DateTime->format($format_string) . $timezone_string;
503
-        }
504
-        return $DateTime->format($format_string);
505
-    }
506
-
507
-
508
-    /**
509
-     * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0
510
-     * timezone).
511
-     *
512
-     * @param mixed $datetime_value u
513
-     * @return string mysql timestamp in UTC
514
-     * @throws EE_Error
515
-     * @throws Exception
516
-     */
517
-    public function prepare_for_use_in_db($datetime_value): ?string
518
-    {
519
-        // we allow an empty value or DateTime object, but nothing else.
520
-        if (! empty($datetime_value) && ! $datetime_value instanceof DateTime) {
521
-            $datetime_value = $this->_get_date_object($datetime_value);
522
-            if (! $datetime_value instanceof DateTime) {
523
-                throw new EE_Error(
524
-                    sprintf(
525
-                        esc_html__(
526
-                            'The incoming value being prepared for setting in the database for the %1$s field must either be empty or a php DateTime object, instead of: %2$s %3$s',
527
-                            'event_espresso'
528
-                        ),
529
-                        $this->get_name(),
530
-                        '<br />',
531
-                        print_r($datetime_value, true)
532
-                    )
533
-                );
534
-            }
535
-        }
536
-
537
-        if ($datetime_value instanceof DateTime) {
538
-            if (! $datetime_value instanceof DbSafeDateTime) {
539
-                $datetime_value = DbSafeDateTime::createFromDateTime($datetime_value);
540
-            }
541
-            EEH_DTT_Helper::setTimezone($datetime_value, $this->get_UTC_DateTimeZone());
542
-            return $datetime_value->format(
543
-                EE_Datetime_Field::mysql_timestamp_format
544
-            );
545
-        }
546
-
547
-        // if $datetime_value is empty, and ! $this->_nullable, use current_time() but set the GMT flag to true
548
-        return ! $this->_nullable
549
-            ? current_time('mysql', true)
550
-            : null;
551
-    }
552
-
553
-
554
-    /**
555
-     * This prepares the datetime for internal usage as a PHP DateTime object OR null (if nullable is
556
-     * allowed)
557
-     *
558
-     * @param string $datetime_string mysql timestamp in UTC
559
-     * @return  bool|DbSafeDateTime|null
560
-     * @throws EE_Error
561
-     * @throws Exception
562
-     */
563
-    public function prepare_for_set_from_db($datetime_string)
564
-    {
565
-        // if $datetime_value is empty, and ! $this->_nullable, just use time()
566
-        if (empty($datetime_string) && $this->_nullable) {
567
-            return null;
568
-        }
569
-        // datetime strings from the db should ALWAYS be in UTC+0, so use UTC_DateTimeZone when creating
570
-        $DateTime = empty($datetime_string)
571
-            ? new DbSafeDateTime(EE_Datetime_Field::now, $this->get_UTC_DateTimeZone())
572
-            : DbSafeDateTime::createFromFormat(
573
-                EE_Datetime_Field::mysql_timestamp_format,
574
-                $datetime_string,
575
-                $this->get_UTC_DateTimeZone()
576
-            );
577
-
578
-        if (! $DateTime instanceof DbSafeDateTime) {
579
-            // if still no datetime object, then let's just use now
580
-            $DateTime = new DbSafeDateTime(EE_Datetime_Field::now, $this->get_UTC_DateTimeZone());
581
-        }
582
-        // THEN apply the field's set DateTimeZone
583
-        EEH_DTT_Helper::setTimezone($DateTime, $this->_DateTimeZone);
584
-        return $DateTime;
585
-    }
586
-
587
-
588
-    /**
589
-     * All this method does is determine if we're going to display the timezone string or not on any output.
590
-     * To determine this we check if the set timezone offset is different than the blog's set timezone offset.
591
-     * If so, then true.
592
-     *
593
-     * @return bool true for yes false for no
594
-     * @throws Exception
595
-     */
596
-    protected function _display_timezone(): bool
597
-    {
598
-        // first let's do a comparison of timezone strings.
599
-        // If they match then we can get out without any further calculations
600
-        $blog_string = get_option('timezone_string');
601
-        if ($blog_string === $this->_timezone_string) {
602
-            return false;
603
-        }
604
-        // now we need to calc the offset for the timezone string so we can compare with the blog offset.
605
-        $this_offset = $this->get_timezone_offset($this->_DateTimeZone);
606
-        $blog_offset = $this->get_timezone_offset($this->get_blog_DateTimeZone());
607
-        // now compare
608
-        return $blog_offset !== $this_offset;
609
-    }
610
-
611
-
612
-    /**
613
-     * This method returns a php DateTime object for setting on the EE_Base_Class model.
614
-     * EE passes around DateTime objects because they are MUCH easier to manipulate and deal
615
-     * with.
616
-     *
617
-     * @param int|string|DateTime $date_string            This should be the incoming date string.  It's assumed to be
618
-     *                                                    in the format that is set on the date_field (or DateTime
619
-     *                                                    object)!
620
-     * @return DateTime
621
-     * @throws Exception
622
-     * @throws Exception
623
-     */
624
-    protected function _get_date_object($date_string)
625
-    {
626
-        // first if this is an empty date_string and nullable is allowed, just return null.
627
-        if ($this->_nullable && empty($date_string)) {
628
-            return null;
629
-        }
630
-
631
-        // if incoming date
632
-        if ($date_string instanceof DateTime) {
633
-            EEH_DTT_Helper::setTimezone($date_string, $this->_DateTimeZone);
634
-            return $date_string;
635
-        }
636
-        // if empty date_string and made it here.
637
-        // Return a datetime object for now in the given timezone.
638
-        if (empty($date_string)) {
639
-            return new DbSafeDateTime(EE_Datetime_Field::now, $this->_DateTimeZone);
640
-        }
641
-        // if $date_string is matches something that looks like a Unix timestamp let's just use it.
642
-        if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $date_string)) {
643
-            try {
644
-                // This is operating under the assumption that the incoming Unix timestamp
645
-                // is an ACTUAL Unix timestamp and not the calculated one output by current_time('timestamp');
646
-                $DateTime = new DbSafeDateTime(EE_Datetime_Field::now, $this->_DateTimeZone);
647
-                $DateTime->setTimestamp($date_string);
648
-
649
-                return $DateTime;
650
-            } catch (Exception $e) {
651
-                // should be rare, but if things got fooled then let's just continue
652
-            }
653
-        }
654
-        // not a unix timestamp.  So we will use the set format on this object and set timezone to
655
-        // create the DateTime object.
656
-        $format = $this->_date_format . ' ' . $this->_time_format;
657
-        try {
658
-            $DateTime = DbSafeDateTime::createFromFormat($format, $date_string, $this->_DateTimeZone);
659
-            if (! $DateTime instanceof DbSafeDateTime) {
660
-                throw new EE_Error(
661
-                    sprintf(
662
-                        esc_html__(
663
-                            '"%1$s" does not represent a valid Date Time in the format "%2$s".',
664
-                            'event_espresso'
665
-                        ),
666
-                        $date_string,
667
-                        $format
668
-                    )
669
-                );
670
-            }
671
-        } catch (Exception $e) {
672
-            // if we made it here then likely then something went really wrong.
673
-            // Instead of throwing an exception, let's just return a DateTime object for now, in the set timezone.
674
-            $DateTime = new DbSafeDateTime(EE_Datetime_Field::now, $this->_DateTimeZone);
675
-        }
676
-
677
-        return $DateTime;
678
-    }
679
-
680
-
681
-    /**
682
-     * get_timezone_transitions
683
-     *
684
-     * @param DateTimeZone $DateTimeZone
685
-     * @param int|null     $time
686
-     * @param bool|null    $first_only
687
-     * @return array
688
-     */
689
-    public function get_timezone_transitions(
690
-        DateTimeZone $DateTimeZone,
691
-        ?int $time = null,
692
-        bool $first_only = true
693
-    ): array {
694
-        return EEH_DTT_Helper::get_timezone_transitions($DateTimeZone, $time, $first_only);
695
-    }
696
-
697
-
698
-    /**
699
-     * get_timezone_offset
700
-     *
701
-     * @param DateTimeZone    $DateTimeZone
702
-     * @param int|string|null $time
703
-     * @return mixed
704
-     * @throws DomainException
705
-     */
706
-    public function get_timezone_offset(DateTimeZone $DateTimeZone, $time = null)
707
-    {
708
-        return EEH_DTT_Helper::get_timezone_offset($DateTimeZone, $time);
709
-    }
710
-
711
-
712
-    /**
713
-     * This will take an incoming timezone string and return the abbreviation for that timezone
714
-     *
715
-     * @param string|null $timezone_string
716
-     * @return string           abbreviation
717
-     * @throws Exception
718
-     */
719
-    public function get_timezone_abbrev(?string $timezone_string = ''): string
720
-    {
721
-        $timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string);
722
-        $dateTime        = new DateTime(EE_Datetime_Field::now, new DateTimeZone($timezone_string));
723
-        return $dateTime->format('T');
724
-    }
725
-
726
-
727
-    /**
728
-     * Overrides the parent to allow for having a dynamic "now" value
729
-     *
730
-     * @return mixed
731
-     */
732
-    public function get_default_value()
733
-    {
734
-        if ($this->_default_value === EE_Datetime_Field::now) {
735
-            return time();
736
-        }
737
-        return parent::get_default_value();
738
-    }
739
-
740
-
741
-    /**
742
-     * Gets the default datetime object from the field's default time
743
-     *
744
-     * @return DbSafeDateTime|DateTime|null
745
-     * @throws InvalidArgumentException
746
-     * @throws InvalidDataTypeException
747
-     * @throws InvalidInterfaceException
748
-     * @throws Exception
749
-     * @since 4.9.66.p
750
-     */
751
-    public function getDefaultDateTimeObj()
752
-    {
753
-        $default_raw = $this->get_default_value();
754
-        if ($default_raw instanceof DateTime) {
755
-            return $default_raw;
756
-        }
757
-        if (is_null($default_raw)) {
758
-            return null;
759
-        }
760
-        $timezone_string = EEH_DTT_Helper::get_valid_timezone_string($this->get_timezone());
761
-        $timezone        = new DateTimeZone($timezone_string);
762
-
763
-        // can't pass unix timestamps directly to Datetime constructor
764
-        if (is_numeric($default_raw)) {
765
-            $datetime = new DbSafeDateTime();
766
-            $datetime->setTimestamp($default_raw);
767
-            return $datetime;
768
-        }
769
-        return new DbSafeDateTime($default_raw, $timezone);
770
-    }
771
-
772
-
773
-    public function getSchemaDescription(): string
774
-    {
775
-        return sprintf(
776
-            esc_html__('%s - the value for this field is in the timezone of the site.', 'event_espresso'),
777
-            $this->get_nicename()
778
-        );
779
-    }
20
+	/**
21
+	 * The pattern we're looking for is if only the characters 0-9 are found and there are only
22
+	 * 10 or more numbers (because 9 numbers even with all 9's would be sometime in 2001 )
23
+	 *
24
+	 * @type string unix_timestamp_regex
25
+	 */
26
+	const unix_timestamp_regex = '/[0-9]{10,}/';
27
+
28
+	/**
29
+	 * @type string mysql_timestamp_format
30
+	 */
31
+	const mysql_timestamp_format = 'Y-m-d H:i:s';
32
+
33
+	/**
34
+	 * @type string mysql_date_format
35
+	 */
36
+	const mysql_date_format = 'Y-m-d';
37
+
38
+	/**
39
+	 * @type string mysql_time_format
40
+	 */
41
+	const mysql_time_format = 'H:i:s';
42
+
43
+	/**
44
+	 * Const for using in the default value. If the field's default is set to this,
45
+	 * then we will return the time of calling `get_default_value()`, not
46
+	 * just the current time at construction
47
+	 */
48
+	const now = 'now';
49
+
50
+	/**
51
+	 * The following properties hold the default formats for date and time.
52
+	 * Defaults are set via the constructor and can be overridden on class instantiation.
53
+	 * However they can also be overridden later by the set_format() method
54
+	 * (and corresponding set_date_format, set_time_format methods);
55
+	 */
56
+
57
+	protected string        $_date_format        = '';
58
+
59
+	protected string        $_time_format        = '';
60
+
61
+	protected string        $_pretty_date_format = '';
62
+
63
+	protected string        $_pretty_time_format = '';
64
+
65
+	protected ?DateTimeZone $_DateTimeZone       = null;
66
+
67
+	protected ?DateTimeZone $_UTC_DateTimeZone   = null;
68
+
69
+	protected ?DateTimeZone $_blog_DateTimeZone  = null;
70
+
71
+
72
+	/**
73
+	 * This property holds how we want the output returned when getting a datetime string.  It is set for the
74
+	 * set_date_time_output() method.  By default this is empty.  When empty, we are assuming that we want both date
75
+	 * and time returned via getters.
76
+	 *
77
+	 * @var mixed (null|string)
78
+	 */
79
+	protected $_date_time_output;
80
+
81
+
82
+	/**
83
+	 * timezone string
84
+	 * This gets set by the constructor and can be changed by the "set_timezone()" method so that we know what timezone
85
+	 * incoming strings|timestamps are in.  This can also be used before a get to set what timezone you want strings
86
+	 * coming out of the object to be in.  Default timezone is the current WP timezone option setting
87
+	 */
88
+	protected ?string $_timezone_string = null;
89
+
90
+
91
+	/**
92
+	 * This holds whatever UTC offset for the blog (we automatically convert timezone strings into their related
93
+	 * offsets for comparison purposes).
94
+	 *
95
+	 * @var int
96
+	 */
97
+	protected int $_blog_offset = 0;
98
+
99
+
100
+	/**
101
+	 * @param string      $table_column
102
+	 * @param string      $nice_name
103
+	 * @param bool        $nullable
104
+	 * @param string|null $default_value
105
+	 * @param string|null $timezone_string
106
+	 * @param string|null $date_format
107
+	 * @param string|null $time_format
108
+	 * @param string|null $pretty_date_format
109
+	 * @param string|null $pretty_time_format
110
+	 * @throws InvalidArgumentException
111
+	 * @throws Exception
112
+	 */
113
+	public function __construct(
114
+		string $table_column,
115
+		string $nice_name,
116
+		bool $nullable,
117
+		?string $default_value,
118
+		?string $timezone_string = '',
119
+		?string $date_format = '',
120
+		?string $time_format = '',
121
+		?string $pretty_date_format = '',
122
+		?string $pretty_time_format = ''
123
+	) {
124
+		$this->set_date_format($date_format);
125
+		$this->set_time_format($time_format);
126
+		$this->set_date_format($pretty_date_format, true);
127
+		$this->set_time_format($pretty_time_format, true);
128
+
129
+		parent::__construct($table_column, $nice_name, $nullable, $default_value);
130
+		$this->set_timezone($timezone_string);
131
+		$this->setSchemaFormat('date-time');
132
+	}
133
+
134
+
135
+	/**
136
+	 * @return DateTimeZone
137
+	 * @throws Exception
138
+	 */
139
+	public function get_UTC_DateTimeZone(): DateTimeZone
140
+	{
141
+		return $this->_UTC_DateTimeZone instanceof DateTimeZone
142
+			? $this->_UTC_DateTimeZone
143
+			: $this->_create_timezone_object_from_timezone_string('UTC');
144
+	}
145
+
146
+
147
+	/**
148
+	 * @return DateTimeZone
149
+	 * @throws Exception
150
+	 */
151
+	public function get_blog_DateTimeZone(): DateTimeZone
152
+	{
153
+		return $this->_blog_DateTimeZone instanceof DateTimeZone
154
+			? $this->_blog_DateTimeZone
155
+			: $this->_create_timezone_object_from_timezone_string();
156
+	}
157
+
158
+
159
+	/**
160
+	 * this prepares any incoming date data and make sure its converted to a utc unix timestamp
161
+	 *
162
+	 * @param string|int $value_inputted_for_field_on_model_object  could be a string formatted date time or int unix
163
+	 *                                                              timestamp
164
+	 * @return DateTime
165
+	 * @throws Exception
166
+	 */
167
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
168
+	{
169
+		return $this->_get_date_object($value_inputted_for_field_on_model_object);
170
+	}
171
+
172
+
173
+	/**
174
+	 * This returns the format string to be used by getters depending on what the $_date_time_output property is set at.
175
+	 * getters need to know whether we're just returning the date or the time or both.  By default we return both.
176
+	 *
177
+	 * @param bool $pretty If we're returning the pretty formats or standard format string.
178
+	 * @return string    The final assembled format string.
179
+	 */
180
+	protected function _get_date_time_output(bool $pretty = false): string
181
+	{
182
+		switch ($this->_date_time_output) {
183
+			case 'time':
184
+				return $pretty
185
+					? $this->_pretty_time_format
186
+					: $this->_time_format;
187
+
188
+			case 'date':
189
+				return $pretty
190
+					? $this->_pretty_date_format
191
+					: $this->_date_format;
192
+
193
+			default:
194
+				return $pretty
195
+					? trim($this->_pretty_date_format . ' ' . $this->_pretty_time_format)
196
+					: trim($this->_date_format . ' ' . $this->_time_format);
197
+		}
198
+	}
199
+
200
+
201
+	/**
202
+	 * This just sets the $_date_time_output property so we can flag how date and times are formatted before being
203
+	 * returned (using the format properties)
204
+	 *
205
+	 * @param string|null $what acceptable values are 'time' or 'date'.
206
+	 *                          Any other value will be set but will always result
207
+	 *                          in both 'date' and 'time' being returned.
208
+	 * @return void
209
+	 */
210
+	public function set_date_time_output(?string $what = null)
211
+	{
212
+		$this->_date_time_output = $what;
213
+	}
214
+
215
+
216
+	/**
217
+	 * See $_timezone property for description of what the timezone property is for.  This SETS the timezone internally
218
+	 * for being able to reference what timezone we are running conversions on when converting TO the internal timezone
219
+	 * (UTC Unix Timestamp) for the object OR when converting FROM the internal timezone (UTC Unix Timestamp).
220
+	 * We also set some other properties in this method.
221
+	 *
222
+	 * @param string|null $timezone_string A valid timezone string as described by @link
223
+	 *                                     http://www.php.net/manual/en/timezones.php
224
+	 * @return void
225
+	 * @throws InvalidArgumentException
226
+	 * @throws InvalidDataTypeException
227
+	 * @throws InvalidInterfaceException
228
+	 * @throws Exception
229
+	 */
230
+	public function set_timezone(?string $timezone_string = '')
231
+	{
232
+		if (empty($timezone_string) && $this->_timezone_string !== null) {
233
+			// leave the timezone AS-IS if we already have one and
234
+			// the function arg didn't provide one
235
+			return;
236
+		}
237
+		$timezone_string        = EEH_DTT_Helper::get_valid_timezone_string($timezone_string);
238
+		$this->_timezone_string = ! empty($timezone_string)
239
+			? $timezone_string
240
+			: 'UTC';
241
+		$this->_DateTimeZone    = $this->_create_timezone_object_from_timezone_string($this->_timezone_string);
242
+	}
243
+
244
+
245
+	/**
246
+	 * _create_timezone_object_from_timezone_name
247
+	 *
248
+	 * @access protected
249
+	 * @param string|null $timezone_string
250
+	 * @return DateTimeZone
251
+	 * @throws InvalidArgumentException
252
+	 * @throws InvalidDataTypeException
253
+	 * @throws InvalidInterfaceException
254
+	 * @throws Exception
255
+	 */
256
+	protected function _create_timezone_object_from_timezone_string(?string $timezone_string = ''): DateTimeZone
257
+	{
258
+		return new DateTimeZone(EEH_DTT_Helper::get_valid_timezone_string($timezone_string));
259
+	}
260
+
261
+
262
+	/**
263
+	 * This just returns whatever is set for the current timezone.
264
+	 *
265
+	 * @access public
266
+	 * @return string timezone string
267
+	 */
268
+	public function get_timezone(): ?string
269
+	{
270
+		return $this->_timezone_string;
271
+	}
272
+
273
+
274
+	/**
275
+	 * set the $_date_format property
276
+	 *
277
+	 * @access public
278
+	 * @param string $format a new date format (corresponding to formats accepted by PHP date() function)
279
+	 * @param bool   $pretty Whether to set pretty format or not.
280
+	 * @return void
281
+	 */
282
+	public function set_date_format(string $format, bool $pretty = false)
283
+	{
284
+		if ($pretty) {
285
+			$this->_pretty_date_format = new DateFormat($format);
286
+		} else {
287
+			$this->_date_format = new DateFormat($format);
288
+		}
289
+	}
290
+
291
+
292
+	/**
293
+	 * return the $_date_format property value.
294
+	 *
295
+	 * @param bool $pretty Whether to get pretty format or not.
296
+	 * @return string
297
+	 */
298
+	public function get_date_format(bool $pretty = false): string
299
+	{
300
+		return $pretty
301
+			? $this->_pretty_date_format
302
+			: $this->_date_format;
303
+	}
304
+
305
+
306
+	/**
307
+	 * set the $_time_format property
308
+	 *
309
+	 * @access public
310
+	 * @param string $format a new time format (corresponding to formats accepted by PHP date() function)
311
+	 * @param bool   $pretty Whether to set pretty format or not.
312
+	 * @return void
313
+	 */
314
+	public function set_time_format(string $format, bool $pretty = false)
315
+	{
316
+		if ($pretty) {
317
+			$this->_pretty_time_format = new TimeFormat($format);
318
+		} else {
319
+			$this->_time_format = new TimeFormat($format);
320
+		}
321
+	}
322
+
323
+
324
+	/**
325
+	 * return the $_time_format property value.
326
+	 *
327
+	 * @param bool $pretty Whether to get pretty format or not.
328
+	 * @return string
329
+	 */
330
+	public function get_time_format(bool $pretty = false): string
331
+	{
332
+		return $pretty
333
+			? $this->_pretty_time_format
334
+			: $this->_time_format;
335
+	}
336
+
337
+
338
+	/**
339
+	 * set the $_pretty_date_format property
340
+	 *
341
+	 * @access public
342
+	 * @param string|null $format a new pretty date format (corresponding to formats accepted by PHP date() function)
343
+	 * @return void
344
+	 */
345
+	public function set_pretty_date_format(?string $format)
346
+	{
347
+		$this->set_date_format($format, true);
348
+	}
349
+
350
+
351
+	/**
352
+	 * set the $_pretty_time_format property
353
+	 *
354
+	 * @access public
355
+	 * @param string|null $format a new pretty time format (corresponding to formats accepted by PHP date() function)
356
+	 * @return void
357
+	 */
358
+	public function set_pretty_time_format(?string $format)
359
+	{
360
+		$this->set_time_format($format, true);
361
+	}
362
+
363
+
364
+	/**
365
+	 * Only sets the time portion of the datetime.
366
+	 *
367
+	 * @param string|DateTime $time_to_set_string like 8am OR a DateTime object.
368
+	 * @param DateTime        $current            current DateTime object for the datetime field
369
+	 * @return DateTime
370
+	 */
371
+	public function prepare_for_set_with_new_time($time_to_set_string, DateTime $current): DateTime
372
+	{
373
+		// if $time_to_set_string is datetime object, then let's use it to set the parse array.
374
+		// Otherwise parse the string.
375
+		if ($time_to_set_string instanceof DateTime) {
376
+			$parsed = [
377
+				'hour'   => $time_to_set_string->format('H'),
378
+				'minute' => $time_to_set_string->format('i'),
379
+				'second' => $time_to_set_string->format('s'),
380
+			];
381
+		} else {
382
+			// parse incoming string
383
+			$parsed = date_parse_from_format($this->_time_format, $time_to_set_string);
384
+		}
385
+		EEH_DTT_Helper::setTimezone($current, $this->_DateTimeZone);
386
+		return $current->setTime($parsed['hour'], $parsed['minute'], $parsed['second']);
387
+	}
388
+
389
+
390
+	/**
391
+	 * Only sets the date portion of the datetime.
392
+	 *
393
+	 * @param string|DateTime $date_to_set_string like Friday, January 8th or a DateTime object.
394
+	 * @param DateTime        $current            current DateTime object for the datetime field
395
+	 * @return DateTime
396
+	 */
397
+	public function prepare_for_set_with_new_date($date_to_set_string, DateTime $current): DateTime
398
+	{
399
+		// if $time_to_set_string is datetime object, then let's use it to set the parse array.
400
+		// Otherwise parse the string.
401
+		if ($date_to_set_string instanceof DateTime) {
402
+			$parsed = [
403
+				'year'  => $date_to_set_string->format('Y'),
404
+				'month' => $date_to_set_string->format('m'),
405
+				'day'   => $date_to_set_string->format('d'),
406
+			];
407
+		} else {
408
+			// parse incoming string
409
+			$parsed = date_parse_from_format($this->_date_format, $date_to_set_string);
410
+		}
411
+		EEH_DTT_Helper::setTimezone($current, $this->_DateTimeZone);
412
+		return $current->setDate($parsed['year'], $parsed['month'], $parsed['day']);
413
+	}
414
+
415
+
416
+	/**
417
+	 * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0 timezone).  When the
418
+	 * datetime gets to this stage it should ALREADY be in UTC time
419
+	 *
420
+	 * @param DateTime $DateTime
421
+	 * @return string formatted date time for given timezone
422
+	 * @throws EE_Error
423
+	 */
424
+	public function prepare_for_get($DateTime): string
425
+	{
426
+		return $this->_prepare_for_display($DateTime);
427
+	}
428
+
429
+
430
+	/**
431
+	 * This differs from prepare_for_get in that it considers whether the internal $_timezone differs
432
+	 * from the set wp timezone.  If so, then it returns the datetime string formatted via
433
+	 * _pretty_date_format, and _pretty_time_format.  However, it also appends a timezone
434
+	 * abbreviation to the date_string.
435
+	 *
436
+	 * @param mixed       $DateTime
437
+	 * @param string|null $schema
438
+	 * @return string
439
+	 * @throws EE_Error
440
+	 */
441
+	public function prepare_for_pretty_echoing($DateTime, ?string $schema = null): string
442
+	{
443
+		$schema = $schema ?: true;
444
+		return $this->_prepare_for_display($DateTime, $schema);
445
+	}
446
+
447
+
448
+	/**
449
+	 * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0
450
+	 * timezone).
451
+	 *
452
+	 * @param DateTime|null $DateTime
453
+	 * @param bool|string   $schema
454
+	 * @return string
455
+	 * @throws EE_Error
456
+	 * @throws Exception
457
+	 */
458
+	protected function _prepare_for_display(?DateTime $DateTime, $schema = false): string
459
+	{
460
+		if (! $DateTime instanceof DateTime) {
461
+			if ($this->_nullable) {
462
+				return '';
463
+			}
464
+			if (WP_DEBUG) {
465
+				throw new EE_Error(
466
+					sprintf(
467
+						esc_html__(
468
+							'EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.',
469
+							'event_espresso'
470
+						),
471
+						$this->_nicename
472
+					)
473
+				);
474
+			}
475
+			$DateTime = new DbSafeDateTime(EE_Datetime_Field::now);
476
+			EE_Error::add_error(
477
+				sprintf(
478
+					esc_html__(
479
+						'EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.  When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.',
480
+						'event_espresso'
481
+					),
482
+					$this->_nicename
483
+				),
484
+				__FILE__,
485
+				__FUNCTION__,
486
+				__LINE__
487
+			);
488
+		}
489
+		$format_string = $this->_get_date_time_output($schema);
490
+		EEH_DTT_Helper::setTimezone($DateTime, $this->_DateTimeZone);
491
+		if ($schema) {
492
+			$timezone_string = '';
493
+			if ($this->_display_timezone()) {
494
+				// must be explicit because schema could equal true.
495
+				if ($schema === 'no_html') {
496
+					$timezone_string = ' (' . $DateTime->format('T') . ')';
497
+				} else {
498
+					$timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format('T') . ')</span>';
499
+				}
500
+			}
501
+
502
+			return $DateTime->format($format_string) . $timezone_string;
503
+		}
504
+		return $DateTime->format($format_string);
505
+	}
506
+
507
+
508
+	/**
509
+	 * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0
510
+	 * timezone).
511
+	 *
512
+	 * @param mixed $datetime_value u
513
+	 * @return string mysql timestamp in UTC
514
+	 * @throws EE_Error
515
+	 * @throws Exception
516
+	 */
517
+	public function prepare_for_use_in_db($datetime_value): ?string
518
+	{
519
+		// we allow an empty value or DateTime object, but nothing else.
520
+		if (! empty($datetime_value) && ! $datetime_value instanceof DateTime) {
521
+			$datetime_value = $this->_get_date_object($datetime_value);
522
+			if (! $datetime_value instanceof DateTime) {
523
+				throw new EE_Error(
524
+					sprintf(
525
+						esc_html__(
526
+							'The incoming value being prepared for setting in the database for the %1$s field must either be empty or a php DateTime object, instead of: %2$s %3$s',
527
+							'event_espresso'
528
+						),
529
+						$this->get_name(),
530
+						'<br />',
531
+						print_r($datetime_value, true)
532
+					)
533
+				);
534
+			}
535
+		}
536
+
537
+		if ($datetime_value instanceof DateTime) {
538
+			if (! $datetime_value instanceof DbSafeDateTime) {
539
+				$datetime_value = DbSafeDateTime::createFromDateTime($datetime_value);
540
+			}
541
+			EEH_DTT_Helper::setTimezone($datetime_value, $this->get_UTC_DateTimeZone());
542
+			return $datetime_value->format(
543
+				EE_Datetime_Field::mysql_timestamp_format
544
+			);
545
+		}
546
+
547
+		// if $datetime_value is empty, and ! $this->_nullable, use current_time() but set the GMT flag to true
548
+		return ! $this->_nullable
549
+			? current_time('mysql', true)
550
+			: null;
551
+	}
552
+
553
+
554
+	/**
555
+	 * This prepares the datetime for internal usage as a PHP DateTime object OR null (if nullable is
556
+	 * allowed)
557
+	 *
558
+	 * @param string $datetime_string mysql timestamp in UTC
559
+	 * @return  bool|DbSafeDateTime|null
560
+	 * @throws EE_Error
561
+	 * @throws Exception
562
+	 */
563
+	public function prepare_for_set_from_db($datetime_string)
564
+	{
565
+		// if $datetime_value is empty, and ! $this->_nullable, just use time()
566
+		if (empty($datetime_string) && $this->_nullable) {
567
+			return null;
568
+		}
569
+		// datetime strings from the db should ALWAYS be in UTC+0, so use UTC_DateTimeZone when creating
570
+		$DateTime = empty($datetime_string)
571
+			? new DbSafeDateTime(EE_Datetime_Field::now, $this->get_UTC_DateTimeZone())
572
+			: DbSafeDateTime::createFromFormat(
573
+				EE_Datetime_Field::mysql_timestamp_format,
574
+				$datetime_string,
575
+				$this->get_UTC_DateTimeZone()
576
+			);
577
+
578
+		if (! $DateTime instanceof DbSafeDateTime) {
579
+			// if still no datetime object, then let's just use now
580
+			$DateTime = new DbSafeDateTime(EE_Datetime_Field::now, $this->get_UTC_DateTimeZone());
581
+		}
582
+		// THEN apply the field's set DateTimeZone
583
+		EEH_DTT_Helper::setTimezone($DateTime, $this->_DateTimeZone);
584
+		return $DateTime;
585
+	}
586
+
587
+
588
+	/**
589
+	 * All this method does is determine if we're going to display the timezone string or not on any output.
590
+	 * To determine this we check if the set timezone offset is different than the blog's set timezone offset.
591
+	 * If so, then true.
592
+	 *
593
+	 * @return bool true for yes false for no
594
+	 * @throws Exception
595
+	 */
596
+	protected function _display_timezone(): bool
597
+	{
598
+		// first let's do a comparison of timezone strings.
599
+		// If they match then we can get out without any further calculations
600
+		$blog_string = get_option('timezone_string');
601
+		if ($blog_string === $this->_timezone_string) {
602
+			return false;
603
+		}
604
+		// now we need to calc the offset for the timezone string so we can compare with the blog offset.
605
+		$this_offset = $this->get_timezone_offset($this->_DateTimeZone);
606
+		$blog_offset = $this->get_timezone_offset($this->get_blog_DateTimeZone());
607
+		// now compare
608
+		return $blog_offset !== $this_offset;
609
+	}
610
+
611
+
612
+	/**
613
+	 * This method returns a php DateTime object for setting on the EE_Base_Class model.
614
+	 * EE passes around DateTime objects because they are MUCH easier to manipulate and deal
615
+	 * with.
616
+	 *
617
+	 * @param int|string|DateTime $date_string            This should be the incoming date string.  It's assumed to be
618
+	 *                                                    in the format that is set on the date_field (or DateTime
619
+	 *                                                    object)!
620
+	 * @return DateTime
621
+	 * @throws Exception
622
+	 * @throws Exception
623
+	 */
624
+	protected function _get_date_object($date_string)
625
+	{
626
+		// first if this is an empty date_string and nullable is allowed, just return null.
627
+		if ($this->_nullable && empty($date_string)) {
628
+			return null;
629
+		}
630
+
631
+		// if incoming date
632
+		if ($date_string instanceof DateTime) {
633
+			EEH_DTT_Helper::setTimezone($date_string, $this->_DateTimeZone);
634
+			return $date_string;
635
+		}
636
+		// if empty date_string and made it here.
637
+		// Return a datetime object for now in the given timezone.
638
+		if (empty($date_string)) {
639
+			return new DbSafeDateTime(EE_Datetime_Field::now, $this->_DateTimeZone);
640
+		}
641
+		// if $date_string is matches something that looks like a Unix timestamp let's just use it.
642
+		if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $date_string)) {
643
+			try {
644
+				// This is operating under the assumption that the incoming Unix timestamp
645
+				// is an ACTUAL Unix timestamp and not the calculated one output by current_time('timestamp');
646
+				$DateTime = new DbSafeDateTime(EE_Datetime_Field::now, $this->_DateTimeZone);
647
+				$DateTime->setTimestamp($date_string);
648
+
649
+				return $DateTime;
650
+			} catch (Exception $e) {
651
+				// should be rare, but if things got fooled then let's just continue
652
+			}
653
+		}
654
+		// not a unix timestamp.  So we will use the set format on this object and set timezone to
655
+		// create the DateTime object.
656
+		$format = $this->_date_format . ' ' . $this->_time_format;
657
+		try {
658
+			$DateTime = DbSafeDateTime::createFromFormat($format, $date_string, $this->_DateTimeZone);
659
+			if (! $DateTime instanceof DbSafeDateTime) {
660
+				throw new EE_Error(
661
+					sprintf(
662
+						esc_html__(
663
+							'"%1$s" does not represent a valid Date Time in the format "%2$s".',
664
+							'event_espresso'
665
+						),
666
+						$date_string,
667
+						$format
668
+					)
669
+				);
670
+			}
671
+		} catch (Exception $e) {
672
+			// if we made it here then likely then something went really wrong.
673
+			// Instead of throwing an exception, let's just return a DateTime object for now, in the set timezone.
674
+			$DateTime = new DbSafeDateTime(EE_Datetime_Field::now, $this->_DateTimeZone);
675
+		}
676
+
677
+		return $DateTime;
678
+	}
679
+
680
+
681
+	/**
682
+	 * get_timezone_transitions
683
+	 *
684
+	 * @param DateTimeZone $DateTimeZone
685
+	 * @param int|null     $time
686
+	 * @param bool|null    $first_only
687
+	 * @return array
688
+	 */
689
+	public function get_timezone_transitions(
690
+		DateTimeZone $DateTimeZone,
691
+		?int $time = null,
692
+		bool $first_only = true
693
+	): array {
694
+		return EEH_DTT_Helper::get_timezone_transitions($DateTimeZone, $time, $first_only);
695
+	}
696
+
697
+
698
+	/**
699
+	 * get_timezone_offset
700
+	 *
701
+	 * @param DateTimeZone    $DateTimeZone
702
+	 * @param int|string|null $time
703
+	 * @return mixed
704
+	 * @throws DomainException
705
+	 */
706
+	public function get_timezone_offset(DateTimeZone $DateTimeZone, $time = null)
707
+	{
708
+		return EEH_DTT_Helper::get_timezone_offset($DateTimeZone, $time);
709
+	}
710
+
711
+
712
+	/**
713
+	 * This will take an incoming timezone string and return the abbreviation for that timezone
714
+	 *
715
+	 * @param string|null $timezone_string
716
+	 * @return string           abbreviation
717
+	 * @throws Exception
718
+	 */
719
+	public function get_timezone_abbrev(?string $timezone_string = ''): string
720
+	{
721
+		$timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string);
722
+		$dateTime        = new DateTime(EE_Datetime_Field::now, new DateTimeZone($timezone_string));
723
+		return $dateTime->format('T');
724
+	}
725
+
726
+
727
+	/**
728
+	 * Overrides the parent to allow for having a dynamic "now" value
729
+	 *
730
+	 * @return mixed
731
+	 */
732
+	public function get_default_value()
733
+	{
734
+		if ($this->_default_value === EE_Datetime_Field::now) {
735
+			return time();
736
+		}
737
+		return parent::get_default_value();
738
+	}
739
+
740
+
741
+	/**
742
+	 * Gets the default datetime object from the field's default time
743
+	 *
744
+	 * @return DbSafeDateTime|DateTime|null
745
+	 * @throws InvalidArgumentException
746
+	 * @throws InvalidDataTypeException
747
+	 * @throws InvalidInterfaceException
748
+	 * @throws Exception
749
+	 * @since 4.9.66.p
750
+	 */
751
+	public function getDefaultDateTimeObj()
752
+	{
753
+		$default_raw = $this->get_default_value();
754
+		if ($default_raw instanceof DateTime) {
755
+			return $default_raw;
756
+		}
757
+		if (is_null($default_raw)) {
758
+			return null;
759
+		}
760
+		$timezone_string = EEH_DTT_Helper::get_valid_timezone_string($this->get_timezone());
761
+		$timezone        = new DateTimeZone($timezone_string);
762
+
763
+		// can't pass unix timestamps directly to Datetime constructor
764
+		if (is_numeric($default_raw)) {
765
+			$datetime = new DbSafeDateTime();
766
+			$datetime->setTimestamp($default_raw);
767
+			return $datetime;
768
+		}
769
+		return new DbSafeDateTime($default_raw, $timezone);
770
+	}
771
+
772
+
773
+	public function getSchemaDescription(): string
774
+	{
775
+		return sprintf(
776
+			esc_html__('%s - the value for this field is in the timezone of the site.', 'event_espresso'),
777
+			$this->get_nicename()
778
+		);
779
+	}
780 780
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 
193 193
             default:
194 194
                 return $pretty
195
-                    ? trim($this->_pretty_date_format . ' ' . $this->_pretty_time_format)
196
-                    : trim($this->_date_format . ' ' . $this->_time_format);
195
+                    ? trim($this->_pretty_date_format.' '.$this->_pretty_time_format)
196
+                    : trim($this->_date_format.' '.$this->_time_format);
197 197
         }
198 198
     }
199 199
 
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
      */
458 458
     protected function _prepare_for_display(?DateTime $DateTime, $schema = false): string
459 459
     {
460
-        if (! $DateTime instanceof DateTime) {
460
+        if ( ! $DateTime instanceof DateTime) {
461 461
             if ($this->_nullable) {
462 462
                 return '';
463 463
             }
@@ -493,13 +493,13 @@  discard block
 block discarded – undo
493 493
             if ($this->_display_timezone()) {
494 494
                 // must be explicit because schema could equal true.
495 495
                 if ($schema === 'no_html') {
496
-                    $timezone_string = ' (' . $DateTime->format('T') . ')';
496
+                    $timezone_string = ' ('.$DateTime->format('T').')';
497 497
                 } else {
498
-                    $timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format('T') . ')</span>';
498
+                    $timezone_string = ' <span class="ee_dtt_timezone_string">('.$DateTime->format('T').')</span>';
499 499
                 }
500 500
             }
501 501
 
502
-            return $DateTime->format($format_string) . $timezone_string;
502
+            return $DateTime->format($format_string).$timezone_string;
503 503
         }
504 504
         return $DateTime->format($format_string);
505 505
     }
@@ -517,9 +517,9 @@  discard block
 block discarded – undo
517 517
     public function prepare_for_use_in_db($datetime_value): ?string
518 518
     {
519 519
         // we allow an empty value or DateTime object, but nothing else.
520
-        if (! empty($datetime_value) && ! $datetime_value instanceof DateTime) {
520
+        if ( ! empty($datetime_value) && ! $datetime_value instanceof DateTime) {
521 521
             $datetime_value = $this->_get_date_object($datetime_value);
522
-            if (! $datetime_value instanceof DateTime) {
522
+            if ( ! $datetime_value instanceof DateTime) {
523 523
                 throw new EE_Error(
524 524
                     sprintf(
525 525
                         esc_html__(
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
         }
536 536
 
537 537
         if ($datetime_value instanceof DateTime) {
538
-            if (! $datetime_value instanceof DbSafeDateTime) {
538
+            if ( ! $datetime_value instanceof DbSafeDateTime) {
539 539
                 $datetime_value = DbSafeDateTime::createFromDateTime($datetime_value);
540 540
             }
541 541
             EEH_DTT_Helper::setTimezone($datetime_value, $this->get_UTC_DateTimeZone());
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
                 $this->get_UTC_DateTimeZone()
576 576
             );
577 577
 
578
-        if (! $DateTime instanceof DbSafeDateTime) {
578
+        if ( ! $DateTime instanceof DbSafeDateTime) {
579 579
             // if still no datetime object, then let's just use now
580 580
             $DateTime = new DbSafeDateTime(EE_Datetime_Field::now, $this->get_UTC_DateTimeZone());
581 581
         }
@@ -653,10 +653,10 @@  discard block
 block discarded – undo
653 653
         }
654 654
         // not a unix timestamp.  So we will use the set format on this object and set timezone to
655 655
         // create the DateTime object.
656
-        $format = $this->_date_format . ' ' . $this->_time_format;
656
+        $format = $this->_date_format.' '.$this->_time_format;
657 657
         try {
658 658
             $DateTime = DbSafeDateTime::createFromFormat($format, $date_string, $this->_DateTimeZone);
659
-            if (! $DateTime instanceof DbSafeDateTime) {
659
+            if ( ! $DateTime instanceof DbSafeDateTime) {
660 660
                 throw new EE_Error(
661 661
                     sprintf(
662 662
                         esc_html__(
Please login to merge, or discard this patch.
core/db_models/fields/EE_Email_Field.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -14,40 +14,40 @@
 block discarded – undo
14 14
  */
15 15
 class EE_Email_Field extends EE_Text_Field_Base
16 16
 {
17
-    /**
18
-     * @param string $table_column
19
-     * @param string $nice_name
20
-     * @param bool   $nullable
21
-     * @param null   $default_value
22
-     * @throws InvalidArgumentException
23
-     */
24
-    public function __construct($table_column, $nice_name, $nullable, $default_value = null)
25
-    {
26
-        parent::__construct($table_column, $nice_name, $nullable, $default_value);
27
-        $this->setSchemaFormat('email');
28
-    }
17
+	/**
18
+	 * @param string $table_column
19
+	 * @param string $nice_name
20
+	 * @param bool   $nullable
21
+	 * @param null   $default_value
22
+	 * @throws InvalidArgumentException
23
+	 */
24
+	public function __construct($table_column, $nice_name, $nullable, $default_value = null)
25
+	{
26
+		parent::__construct($table_column, $nice_name, $nullable, $default_value);
27
+		$this->setSchemaFormat('email');
28
+	}
29 29
 
30 30
 
31
-    /**
32
-     * In form inputs, we should have called htmlentities and addslashes() on form inputs,
33
-     * so we need to undo that on setting of these fields
34
-     *
35
-     * @param string $email_address
36
-     * @return string
37
-     * @throws InvalidArgumentException
38
-     * @throws InvalidInterfaceException
39
-     * @throws InvalidDataTypeException
40
-     */
41
-    public function prepare_for_set($email_address)
42
-    {
43
-        if (empty($email_address)) {
44
-            return '';
45
-        }
46
-        try {
47
-            $email_address_obj = EmailAddressFactory::create($email_address);
48
-            return $email_address_obj instanceof EmailAddress ? $email_address_obj->get() : '';
49
-        } catch (EmailValidationException $e) {
50
-            return '';
51
-        }
52
-    }
31
+	/**
32
+	 * In form inputs, we should have called htmlentities and addslashes() on form inputs,
33
+	 * so we need to undo that on setting of these fields
34
+	 *
35
+	 * @param string $email_address
36
+	 * @return string
37
+	 * @throws InvalidArgumentException
38
+	 * @throws InvalidInterfaceException
39
+	 * @throws InvalidDataTypeException
40
+	 */
41
+	public function prepare_for_set($email_address)
42
+	{
43
+		if (empty($email_address)) {
44
+			return '';
45
+		}
46
+		try {
47
+			$email_address_obj = EmailAddressFactory::create($email_address);
48
+			return $email_address_obj instanceof EmailAddress ? $email_address_obj->get() : '';
49
+		} catch (EmailValidationException $e) {
50
+			return '';
51
+		}
52
+	}
53 53
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Enum_Integer_Field.php 2 patches
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -9,111 +9,111 @@
 block discarded – undo
9 9
  */
10 10
 class EE_Enum_Integer_Field extends EE_Integer_Field
11 11
 {
12
-    /**
13
-     * @var array $_allowed_enum_values
14
-     */
15
-    public $_allowed_enum_values;
12
+	/**
13
+	 * @var array $_allowed_enum_values
14
+	 */
15
+	public $_allowed_enum_values;
16 16
 
17 17
 
18
-    /**
19
-     * @param string  $table_column
20
-     * @param string  $nicename
21
-     * @param boolean $nullable
22
-     * @param int     $default_value
23
-     * @param array   $allowed_enum_values keys are values to be used in the DB, values are how they should be displayed
24
-     */
25
-    public function __construct($table_column, $nicename, $nullable, $default_value, $allowed_enum_values)
26
-    {
27
-        $this->_allowed_enum_values = $allowed_enum_values;
28
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
29
-        $this->setSchemaType('object');
30
-    }
18
+	/**
19
+	 * @param string  $table_column
20
+	 * @param string  $nicename
21
+	 * @param boolean $nullable
22
+	 * @param int     $default_value
23
+	 * @param array   $allowed_enum_values keys are values to be used in the DB, values are how they should be displayed
24
+	 */
25
+	public function __construct($table_column, $nicename, $nullable, $default_value, $allowed_enum_values)
26
+	{
27
+		$this->_allowed_enum_values = $allowed_enum_values;
28
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
29
+		$this->setSchemaType('object');
30
+	}
31 31
 
32 32
 
33
-    /**
34
-     * Returns the list of allowed enum options, but filterable.
35
-     * This is used internally
36
-     *
37
-     * @return array
38
-     */
39
-    protected function _allowed_enum_values()
40
-    {
41
-        return (array) apply_filters(
42
-            'FHEE__EE_Enum_Integer_Field___allowed_enum_options',
43
-            $this->_allowed_enum_values,
44
-            $this
45
-        );
46
-    }
33
+	/**
34
+	 * Returns the list of allowed enum options, but filterable.
35
+	 * This is used internally
36
+	 *
37
+	 * @return array
38
+	 */
39
+	protected function _allowed_enum_values()
40
+	{
41
+		return (array) apply_filters(
42
+			'FHEE__EE_Enum_Integer_Field___allowed_enum_options',
43
+			$this->_allowed_enum_values,
44
+			$this
45
+		);
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * When setting, just verify that the value being used matches what we've defined as allowable enum values.
51
-     * If not, throw an error (but if WP_DEBUG is false, just set the value to default)
52
-     *
53
-     * @param int $value_inputted_for_field_on_model_object
54
-     * @return int
55
-     */
56
-    public function prepare_for_set($value_inputted_for_field_on_model_object)
57
-    {
58
-        $allowed_enum_values = $this->_allowed_enum_values();
59
-        if (
60
-            $value_inputted_for_field_on_model_object !== null
61
-            && ! array_key_exists($value_inputted_for_field_on_model_object, $allowed_enum_values)
62
-        ) {
63
-            if (defined('WP_DEBUG') && WP_DEBUG) {
64
-                $msg  = sprintf(
65
-                    esc_html__('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
66
-                    $value_inputted_for_field_on_model_object,
67
-                    $this->_name
68
-                );
69
-                $msg2 = sprintf(
70
-                    esc_html__('Allowed values for "%1$s" are "%2$s". You provided "%3$s"', 'event_espresso'),
71
-                    $this->_name,
72
-                    implode(', ', array_keys($allowed_enum_values)),
73
-                    $value_inputted_for_field_on_model_object
74
-                );
75
-                EE_Error::add_error("{$msg}||{$msg2}", __FILE__, __FUNCTION__, __LINE__);
76
-            }
77
-            return $this->get_default_value();
78
-        }
79
-        return (int) $value_inputted_for_field_on_model_object;
80
-    }
49
+	/**
50
+	 * When setting, just verify that the value being used matches what we've defined as allowable enum values.
51
+	 * If not, throw an error (but if WP_DEBUG is false, just set the value to default)
52
+	 *
53
+	 * @param int $value_inputted_for_field_on_model_object
54
+	 * @return int
55
+	 */
56
+	public function prepare_for_set($value_inputted_for_field_on_model_object)
57
+	{
58
+		$allowed_enum_values = $this->_allowed_enum_values();
59
+		if (
60
+			$value_inputted_for_field_on_model_object !== null
61
+			&& ! array_key_exists($value_inputted_for_field_on_model_object, $allowed_enum_values)
62
+		) {
63
+			if (defined('WP_DEBUG') && WP_DEBUG) {
64
+				$msg  = sprintf(
65
+					esc_html__('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
66
+					$value_inputted_for_field_on_model_object,
67
+					$this->_name
68
+				);
69
+				$msg2 = sprintf(
70
+					esc_html__('Allowed values for "%1$s" are "%2$s". You provided "%3$s"', 'event_espresso'),
71
+					$this->_name,
72
+					implode(', ', array_keys($allowed_enum_values)),
73
+					$value_inputted_for_field_on_model_object
74
+				);
75
+				EE_Error::add_error("{$msg}||{$msg2}", __FILE__, __FUNCTION__, __LINE__);
76
+			}
77
+			return $this->get_default_value();
78
+		}
79
+		return (int) $value_inputted_for_field_on_model_object;
80
+	}
81 81
 
82 82
 
83
-    /**
84
-     * Gets the pretty version of the enum's value.
85
-     *
86
-     * @param int | string $value_on_field_to_be_outputted
87
-     * @param string|null  $schema
88
-     * @return string
89
-     */
90
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null)
91
-    {
92
-        $options = $this->_allowed_enum_values();
93
-        return $options[ $value_on_field_to_be_outputted ] ?? $value_on_field_to_be_outputted;
94
-    }
83
+	/**
84
+	 * Gets the pretty version of the enum's value.
85
+	 *
86
+	 * @param int | string $value_on_field_to_be_outputted
87
+	 * @param string|null  $schema
88
+	 * @return string
89
+	 */
90
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null)
91
+	{
92
+		$options = $this->_allowed_enum_values();
93
+		return $options[ $value_on_field_to_be_outputted ] ?? $value_on_field_to_be_outputted;
94
+	}
95 95
 
96 96
 
97
-    public function getSchemaProperties(): array
98
-    {
99
-        return [
100
-            'raw'    => [
101
-                'description' => sprintf(
102
-                    esc_html__('%s - the value in the database.', 'event_espresso'),
103
-                    $this->get_nicename()
104
-                ),
105
-                'enum'        => array_keys($this->_allowed_enum_values()),
106
-                'type'        => 'integer',
107
-            ],
108
-            'pretty' => [
109
-                'description' => sprintf(
110
-                    esc_html__('%s - the value for display.', 'event_espresso'),
111
-                    $this->get_nicename()
112
-                ),
113
-                'enum'        => array_values($this->_allowed_enum_values()),
114
-                'type'        => 'string',
115
-                'read_only'   => true,
116
-            ],
117
-        ];
118
-    }
97
+	public function getSchemaProperties(): array
98
+	{
99
+		return [
100
+			'raw'    => [
101
+				'description' => sprintf(
102
+					esc_html__('%s - the value in the database.', 'event_espresso'),
103
+					$this->get_nicename()
104
+				),
105
+				'enum'        => array_keys($this->_allowed_enum_values()),
106
+				'type'        => 'integer',
107
+			],
108
+			'pretty' => [
109
+				'description' => sprintf(
110
+					esc_html__('%s - the value for display.', 'event_espresso'),
111
+					$this->get_nicename()
112
+				),
113
+				'enum'        => array_values($this->_allowed_enum_values()),
114
+				'type'        => 'string',
115
+				'read_only'   => true,
116
+			],
117
+		];
118
+	}
119 119
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             && ! array_key_exists($value_inputted_for_field_on_model_object, $allowed_enum_values)
62 62
         ) {
63 63
             if (defined('WP_DEBUG') && WP_DEBUG) {
64
-                $msg  = sprintf(
64
+                $msg = sprintf(
65 65
                     esc_html__('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
66 66
                     $value_inputted_for_field_on_model_object,
67 67
                     $this->_name
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null)
91 91
     {
92 92
         $options = $this->_allowed_enum_values();
93
-        return $options[ $value_on_field_to_be_outputted ] ?? $value_on_field_to_be_outputted;
93
+        return $options[$value_on_field_to_be_outputted] ?? $value_on_field_to_be_outputted;
94 94
     }
95 95
 
96 96
 
Please login to merge, or discard this patch.
core/db_models/fields/EE_Post_Content_Field.php 2 patches
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -6,133 +6,133 @@
 block discarded – undo
6 6
  */
7 7
 class EE_Post_Content_Field extends EE_Text_Field_Base
8 8
 {
9
-    /**
10
-     * @param string $table_column
11
-     * @param string $nicename
12
-     * @param bool   $nullable
13
-     * @param null   $default_value
14
-     */
15
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
16
-    {
17
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
18
-        $this->setSchemaType('object');
19
-    }
9
+	/**
10
+	 * @param string $table_column
11
+	 * @param string $nicename
12
+	 * @param bool   $nullable
13
+	 * @param null   $default_value
14
+	 */
15
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
16
+	{
17
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
18
+		$this->setSchemaType('object');
19
+	}
20 20
 
21 21
 
22
-    /**
23
-     * removes all tags which a WP Post wouldn't allow in its content normally
24
-     *
25
-     * @param string $value
26
-     * @return string
27
-     */
28
-    public function prepare_for_set($value)
29
-    {
30
-        if (! current_user_can('unfiltered_html')) {
31
-            $value = wp_kses("$value", wp_kses_allowed_html('post'));
32
-        }
33
-        return parent::prepare_for_set($value);
34
-    }
22
+	/**
23
+	 * removes all tags which a WP Post wouldn't allow in its content normally
24
+	 *
25
+	 * @param string $value
26
+	 * @return string
27
+	 */
28
+	public function prepare_for_set($value)
29
+	{
30
+		if (! current_user_can('unfiltered_html')) {
31
+			$value = wp_kses("$value", wp_kses_allowed_html('post'));
32
+		}
33
+		return parent::prepare_for_set($value);
34
+	}
35 35
 
36 36
 
37
-    /**
38
-     * Runs the content through `the_content`, or if prepares the content for placing in a form input
39
-     *
40
-     * @param string      $value_on_field_to_be_outputted
41
-     * @param string|null $schema possible values: 'form_input' or null (if null, will run through 'the_content')
42
-     * @return string
43
-     * @throws EE_Error when WP_DEBUG is on and recursive calling is detected
44
-     */
45
-    public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null)
46
-    {
47
-        switch ($schema) {
48
-            case 'form_input':
49
-                return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema);
50
-            case 'the_content':
51
-                if (doing_filter('the_content')) {
52
-                    if (defined('WP_DEBUG') && WP_DEBUG) {
53
-                        throw new EE_Error(
54
-                            sprintf(
55
-                                esc_html__(
56
-                                    'You have recursively called "%1$s" with %2$s set to %3$s which uses "%2$s" filter. You should use it with %2$s "%3$s" instead here.',
57
-                                    'event_espresso'
58
-                                ),
59
-                                'EE_Post_Content_Field::prepare_for_pretty_echoing',
60
-                                '$schema',
61
-                                'the_content',
62
-                                'the_content_wp_core_only'
63
-                            )
64
-                        );
65
-                    } else {
66
-                        return $this->prepare_for_pretty_echoing(
67
-                            $value_on_field_to_be_outputted,
68
-                            'the_content_wp_core_only'
69
-                        );
70
-                    }
71
-                }
72
-                return apply_filters(
73
-                    'the_content',
74
-                    parent::prepare_for_pretty_echoing(
75
-                        $value_on_field_to_be_outputted,
76
-                        $schema
77
-                    )
78
-                );
79
-            case 'the_content_wp_core_only':
80
-            default:
81
-                self::_setup_the_content_wp_core_only_filters();
82
-                $return_value = apply_filters(
83
-                    'the_content_wp_core_only',
84
-                    parent::prepare_for_pretty_echoing(
85
-                        $value_on_field_to_be_outputted,
86
-                        $schema
87
-                    )
88
-                );
89
-                // ya know what? adding these filters is super fast. Let's just
90
-                // avoid needing to maintain global state and set this up as-needed
91
-                remove_all_filters('the_content_wp_core_only');
92
-                do_action('AHEE__EE_Post_Content_Field__prepare_for_pretty_echoing__the_content_wp_core_only__done');
93
-                return $return_value;
94
-        }
95
-    }
37
+	/**
38
+	 * Runs the content through `the_content`, or if prepares the content for placing in a form input
39
+	 *
40
+	 * @param string      $value_on_field_to_be_outputted
41
+	 * @param string|null $schema possible values: 'form_input' or null (if null, will run through 'the_content')
42
+	 * @return string
43
+	 * @throws EE_Error when WP_DEBUG is on and recursive calling is detected
44
+	 */
45
+	public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, ?string $schema = null)
46
+	{
47
+		switch ($schema) {
48
+			case 'form_input':
49
+				return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema);
50
+			case 'the_content':
51
+				if (doing_filter('the_content')) {
52
+					if (defined('WP_DEBUG') && WP_DEBUG) {
53
+						throw new EE_Error(
54
+							sprintf(
55
+								esc_html__(
56
+									'You have recursively called "%1$s" with %2$s set to %3$s which uses "%2$s" filter. You should use it with %2$s "%3$s" instead here.',
57
+									'event_espresso'
58
+								),
59
+								'EE_Post_Content_Field::prepare_for_pretty_echoing',
60
+								'$schema',
61
+								'the_content',
62
+								'the_content_wp_core_only'
63
+							)
64
+						);
65
+					} else {
66
+						return $this->prepare_for_pretty_echoing(
67
+							$value_on_field_to_be_outputted,
68
+							'the_content_wp_core_only'
69
+						);
70
+					}
71
+				}
72
+				return apply_filters(
73
+					'the_content',
74
+					parent::prepare_for_pretty_echoing(
75
+						$value_on_field_to_be_outputted,
76
+						$schema
77
+					)
78
+				);
79
+			case 'the_content_wp_core_only':
80
+			default:
81
+				self::_setup_the_content_wp_core_only_filters();
82
+				$return_value = apply_filters(
83
+					'the_content_wp_core_only',
84
+					parent::prepare_for_pretty_echoing(
85
+						$value_on_field_to_be_outputted,
86
+						$schema
87
+					)
88
+				);
89
+				// ya know what? adding these filters is super fast. Let's just
90
+				// avoid needing to maintain global state and set this up as-needed
91
+				remove_all_filters('the_content_wp_core_only');
92
+				do_action('AHEE__EE_Post_Content_Field__prepare_for_pretty_echoing__the_content_wp_core_only__done');
93
+				return $return_value;
94
+		}
95
+	}
96 96
 
97 97
 
98
-    /**
99
-     * Verifies we've setup the standard WP core filters on  'the_content_wp_core_only' filter
100
-     */
101
-    protected static function _setup_the_content_wp_core_only_filters()
102
-    {
103
-        add_filter('the_content_wp_core_only', [$GLOBALS['wp_embed'], 'run_shortcode'], 8);
104
-        add_filter('the_content_wp_core_only', [$GLOBALS['wp_embed'], 'autoembed'], 8);
105
-        add_filter('the_content_wp_core_only', 'wptexturize', 10);
106
-        add_filter('the_content_wp_core_only', 'wpautop', 10);
107
-        add_filter('the_content_wp_core_only', 'shortcode_unautop', 10);
108
-        add_filter('the_content_wp_core_only', 'prepend_attachment', 10);
109
-        if (function_exists('wp_filter_content_tags')) {
110
-            add_filter('the_content_wp_core_only', 'wp_filter_content_tags', 10);
111
-        } elseif (function_exists('wp_make_content_images_responsive')) {
112
-            add_filter('the_content_wp_core_only', 'wp_make_content_images_responsive', 10);
113
-        }
114
-        add_filter('the_content_wp_core_only', 'do_shortcode', 11);
115
-        add_filter('the_content_wp_core_only', 'convert_smilies', 20);
116
-    }
98
+	/**
99
+	 * Verifies we've setup the standard WP core filters on  'the_content_wp_core_only' filter
100
+	 */
101
+	protected static function _setup_the_content_wp_core_only_filters()
102
+	{
103
+		add_filter('the_content_wp_core_only', [$GLOBALS['wp_embed'], 'run_shortcode'], 8);
104
+		add_filter('the_content_wp_core_only', [$GLOBALS['wp_embed'], 'autoembed'], 8);
105
+		add_filter('the_content_wp_core_only', 'wptexturize', 10);
106
+		add_filter('the_content_wp_core_only', 'wpautop', 10);
107
+		add_filter('the_content_wp_core_only', 'shortcode_unautop', 10);
108
+		add_filter('the_content_wp_core_only', 'prepend_attachment', 10);
109
+		if (function_exists('wp_filter_content_tags')) {
110
+			add_filter('the_content_wp_core_only', 'wp_filter_content_tags', 10);
111
+		} elseif (function_exists('wp_make_content_images_responsive')) {
112
+			add_filter('the_content_wp_core_only', 'wp_make_content_images_responsive', 10);
113
+		}
114
+		add_filter('the_content_wp_core_only', 'do_shortcode', 11);
115
+		add_filter('the_content_wp_core_only', 'convert_smilies', 20);
116
+	}
117 117
 
118 118
 
119
-    public function getSchemaProperties(): array
120
-    {
121
-        return [
122
-            'raw'      => [
123
-                'description' => sprintf(
124
-                    esc_html__('%s - the content as it exists in the database.', 'event_espresso'),
125
-                    $this->get_nicename()
126
-                ),
127
-                'type'        => 'string',
128
-            ],
129
-            'rendered' => [
130
-                'description' => sprintf(
131
-                    esc_html__('%s - the content rendered for display.', 'event_espresso'),
132
-                    $this->get_nicename()
133
-                ),
134
-                'type'        => 'string',
135
-            ],
136
-        ];
137
-    }
119
+	public function getSchemaProperties(): array
120
+	{
121
+		return [
122
+			'raw'      => [
123
+				'description' => sprintf(
124
+					esc_html__('%s - the content as it exists in the database.', 'event_espresso'),
125
+					$this->get_nicename()
126
+				),
127
+				'type'        => 'string',
128
+			],
129
+			'rendered' => [
130
+				'description' => sprintf(
131
+					esc_html__('%s - the content rendered for display.', 'event_espresso'),
132
+					$this->get_nicename()
133
+				),
134
+				'type'        => 'string',
135
+			],
136
+		];
137
+	}
138 138
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
      */
28 28
     public function prepare_for_set($value)
29 29
     {
30
-        if (! current_user_can('unfiltered_html')) {
30
+        if ( ! current_user_can('unfiltered_html')) {
31 31
             $value = wp_kses("$value", wp_kses_allowed_html('post'));
32 32
         }
33 33
         return parent::prepare_for_set($value);
Please login to merge, or discard this patch.
core/db_models/EEM_Form_Section.model.php 1 patch
Indentation   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -20,244 +20,244 @@
 block discarded – undo
20 20
  */
21 21
 class EEM_Form_Section extends EEM_Base
22 22
 {
23
-    public const APPLIES_TO_ALL         = 'all';
23
+	public const APPLIES_TO_ALL         = 'all';
24 24
 
25
-    public const APPLIES_TO_PRIMARY     = 'primary';
25
+	public const APPLIES_TO_PRIMARY     = 'primary';
26 26
 
27
-    public const APPLIES_TO_PURCHASER   = 'purchaser';
27
+	public const APPLIES_TO_PURCHASER   = 'purchaser';
28 28
 
29
-    public const APPLIES_TO_REGISTRANTS = 'registrants';
29
+	public const APPLIES_TO_REGISTRANTS = 'registrants';
30 30
 
31
-    /**
32
-     * @var EEM_Form_Section
33
-     */
34
-    protected static $_instance;
31
+	/**
32
+	 * @var EEM_Form_Section
33
+	 */
34
+	protected static $_instance;
35 35
 
36
-    /**
37
-     * @var RequestInterface
38
-     */
39
-    private $request;
36
+	/**
37
+	 * @var RequestInterface
38
+	 */
39
+	private $request;
40 40
 
41
-    /**
42
-     * @var array
43
-     */
44
-    private $valid_applies_to_options;
41
+	/**
42
+	 * @var array
43
+	 */
44
+	private $valid_applies_to_options;
45 45
 
46 46
 
47
-    /**
48
-     * EEM_Form_Section constructor.
49
-     *
50
-     * @param FormStatus  $form_status
51
-     * @param string|null $timezone
52
-     * @throws EE_Error
53
-     */
54
-    protected function __construct(FormStatus $form_status, ?string $timezone = '')
55
-    {
56
-        $this->valid_applies_to_options = apply_filters(
57
-            'FHEE__EEM_Form_Section__valid_applies_to_options',
58
-            [
59
-                EEM_Form_Section::APPLIES_TO_ALL         => esc_html__('All Registrants', 'event_espresso'),
60
-                EEM_Form_Section::APPLIES_TO_PRIMARY     => esc_html__('Primary Registrant Only', 'event_espresso'),
61
-                EEM_Form_Section::APPLIES_TO_PURCHASER   => esc_html__('Purchasing Agent', 'event_espresso'),
62
-                EEM_Form_Section::APPLIES_TO_REGISTRANTS => esc_html__('Additional Registrants', 'event_espresso'),
63
-            ]
64
-        );
47
+	/**
48
+	 * EEM_Form_Section constructor.
49
+	 *
50
+	 * @param FormStatus  $form_status
51
+	 * @param string|null $timezone
52
+	 * @throws EE_Error
53
+	 */
54
+	protected function __construct(FormStatus $form_status, ?string $timezone = '')
55
+	{
56
+		$this->valid_applies_to_options = apply_filters(
57
+			'FHEE__EEM_Form_Section__valid_applies_to_options',
58
+			[
59
+				EEM_Form_Section::APPLIES_TO_ALL         => esc_html__('All Registrants', 'event_espresso'),
60
+				EEM_Form_Section::APPLIES_TO_PRIMARY     => esc_html__('Primary Registrant Only', 'event_espresso'),
61
+				EEM_Form_Section::APPLIES_TO_PURCHASER   => esc_html__('Purchasing Agent', 'event_espresso'),
62
+				EEM_Form_Section::APPLIES_TO_REGISTRANTS => esc_html__('Additional Registrants', 'event_espresso'),
63
+			]
64
+		);
65 65
 
66
-        $this->singular_item = esc_html__('Form Section', 'event_espresso');
67
-        $this->plural_item   = esc_html__('Form Sections', 'event_espresso');
66
+		$this->singular_item = esc_html__('Form Section', 'event_espresso');
67
+		$this->plural_item   = esc_html__('Form Sections', 'event_espresso');
68 68
 
69
-        $this->_tables          = [
70
-            'Form_Section' => new EE_Primary_Table('esp_form_section', 'FSC_UUID'),
71
-        ];
72
-        $this->_fields          = [
73
-            'Form_Section' => [
74
-                'FSC_UUID'       => new EE_Primary_Key_String_Field(
75
-                    'FSC_UUID',
76
-                    esc_html__('Form Section UUID (universally unique identifier)', 'event_espresso')
77
-                ),
78
-                'FSC_appliesTo'  => new EE_Enum_Text_Field(
79
-                    'FSC_appliesTo',
80
-                    esc_html(
81
-                        sprintf(
82
-                        /* translators: 1 class name */
83
-                            __(
84
-                                'Form user type that this form section should be presented to. Values correspond to the %s constants.',
85
-                                'event_espresso'
86
-                            ),
87
-                            'EEM_Form_Section::APPLIES_TO_*'
88
-                        )
89
-                    ),
90
-                    false,
91
-                    EEM_Form_Section::APPLIES_TO_ALL,
92
-                    $this->valid_applies_to_options
93
-                ),
94
-                'FSC_attributes' => new EE_JSON_Field(
95
-                    'FSC_attributes',
96
-                    esc_html__(
97
-                        'JSON string of HTML attributes, such as class, to be applied to this form section\'s container.',
98
-                        'event_espresso'
99
-                    ),
100
-                    false,
101
-                    '{}'
102
-                ),
103
-                'FSC_belongsTo'  => new EE_Plain_Text_Field(
104
-                    'FSC_belongsTo',
105
-                    esc_html__('UUID of parent form section that this one belongs to.', 'event_espresso'),
106
-                    false,
107
-                    ''
108
-                ),
109
-                'FSC_label'      => new EE_JSON_Field(
110
-                    'FSC_label',
111
-                    esc_html__(
112
-                        'JSON string of properties pertaining to a form section\'s label.',
113
-                        'event_espresso'
114
-                    ),
115
-                    false,
116
-                    '{}'
117
-                ),
118
-                'FSC_order'      => new EE_Integer_Field(
119
-                    'FSC_order',
120
-                    esc_html__('Order in which form section appears in a form.', 'event_espresso'),
121
-                    false,
122
-                    0
123
-                ),
124
-                'FSC_status'     => new EE_Enum_Text_Field(
125
-                    'FSC_status',
126
-                    esc_html(
127
-                        sprintf(
128
-                        /* translators: 1 class name */
129
-                            __(
130
-                                'Whether form section is active, archived, shared, trashed, or used as a default on new forms. Values correspond to the %1$s class constants.',
131
-                                'event_espresso'
132
-                            ),
133
-                            'EventEspresso\core\services\form\meta\FormStatus'
134
-                        )
135
-                    ),
136
-                    false,
137
-                    FormStatus::ACTIVE,
138
-                    $form_status->validStatusOptions()
139
-                ),
140
-                'FSC_wpUser'     => new EE_WP_User_Field(
141
-                    'FSC_wpUser',
142
-                    esc_html__('ID of the WP User that created this form section.', 'event_espresso'),
143
-                    false
144
-                ),
145
-            ],
146
-        ];
147
-        $this->_model_relations = [
148
-            'Form_Element'    => new EE_Has_Many_Relation(),
149
-            'Form_Submission' => new EE_Has_Many_Relation(),
150
-            'WP_User'         => new EE_Belongs_To_Relation(),
151
-        ];
152
-        // this model is generally available for reading
153
-        $restrictions                              = [];
154
-        $restrictions[ EEM_Base::caps_read ]       = new EE_Restriction_Generator_Public();
155
-        $restrictions[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to');
156
-        $restrictions[ EEM_Base::caps_edit ]       = new EE_Restriction_Generator_Reg_Form('FSC_applies_to');
157
-        $restrictions[ EEM_Base::caps_delete ]     = new EE_Restriction_Generator_Reg_Form('FSC_applies_to');
158
-        $this->_cap_restriction_generators         = $restrictions;
159
-        parent::__construct($timezone);
160
-        $this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
161
-    }
69
+		$this->_tables          = [
70
+			'Form_Section' => new EE_Primary_Table('esp_form_section', 'FSC_UUID'),
71
+		];
72
+		$this->_fields          = [
73
+			'Form_Section' => [
74
+				'FSC_UUID'       => new EE_Primary_Key_String_Field(
75
+					'FSC_UUID',
76
+					esc_html__('Form Section UUID (universally unique identifier)', 'event_espresso')
77
+				),
78
+				'FSC_appliesTo'  => new EE_Enum_Text_Field(
79
+					'FSC_appliesTo',
80
+					esc_html(
81
+						sprintf(
82
+						/* translators: 1 class name */
83
+							__(
84
+								'Form user type that this form section should be presented to. Values correspond to the %s constants.',
85
+								'event_espresso'
86
+							),
87
+							'EEM_Form_Section::APPLIES_TO_*'
88
+						)
89
+					),
90
+					false,
91
+					EEM_Form_Section::APPLIES_TO_ALL,
92
+					$this->valid_applies_to_options
93
+				),
94
+				'FSC_attributes' => new EE_JSON_Field(
95
+					'FSC_attributes',
96
+					esc_html__(
97
+						'JSON string of HTML attributes, such as class, to be applied to this form section\'s container.',
98
+						'event_espresso'
99
+					),
100
+					false,
101
+					'{}'
102
+				),
103
+				'FSC_belongsTo'  => new EE_Plain_Text_Field(
104
+					'FSC_belongsTo',
105
+					esc_html__('UUID of parent form section that this one belongs to.', 'event_espresso'),
106
+					false,
107
+					''
108
+				),
109
+				'FSC_label'      => new EE_JSON_Field(
110
+					'FSC_label',
111
+					esc_html__(
112
+						'JSON string of properties pertaining to a form section\'s label.',
113
+						'event_espresso'
114
+					),
115
+					false,
116
+					'{}'
117
+				),
118
+				'FSC_order'      => new EE_Integer_Field(
119
+					'FSC_order',
120
+					esc_html__('Order in which form section appears in a form.', 'event_espresso'),
121
+					false,
122
+					0
123
+				),
124
+				'FSC_status'     => new EE_Enum_Text_Field(
125
+					'FSC_status',
126
+					esc_html(
127
+						sprintf(
128
+						/* translators: 1 class name */
129
+							__(
130
+								'Whether form section is active, archived, shared, trashed, or used as a default on new forms. Values correspond to the %1$s class constants.',
131
+								'event_espresso'
132
+							),
133
+							'EventEspresso\core\services\form\meta\FormStatus'
134
+						)
135
+					),
136
+					false,
137
+					FormStatus::ACTIVE,
138
+					$form_status->validStatusOptions()
139
+				),
140
+				'FSC_wpUser'     => new EE_WP_User_Field(
141
+					'FSC_wpUser',
142
+					esc_html__('ID of the WP User that created this form section.', 'event_espresso'),
143
+					false
144
+				),
145
+			],
146
+		];
147
+		$this->_model_relations = [
148
+			'Form_Element'    => new EE_Has_Many_Relation(),
149
+			'Form_Submission' => new EE_Has_Many_Relation(),
150
+			'WP_User'         => new EE_Belongs_To_Relation(),
151
+		];
152
+		// this model is generally available for reading
153
+		$restrictions                              = [];
154
+		$restrictions[ EEM_Base::caps_read ]       = new EE_Restriction_Generator_Public();
155
+		$restrictions[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to');
156
+		$restrictions[ EEM_Base::caps_edit ]       = new EE_Restriction_Generator_Reg_Form('FSC_applies_to');
157
+		$restrictions[ EEM_Base::caps_delete ]     = new EE_Restriction_Generator_Reg_Form('FSC_applies_to');
158
+		$this->_cap_restriction_generators         = $restrictions;
159
+		parent::__construct($timezone);
160
+		$this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
161
+	}
162 162
 
163 163
 
164
-    /**
165
-     * @param array $query_params
166
-     * @return array
167
-     */
168
-    private function addDefaultWhereConditions(array $query_params): array
169
-    {
170
-        // might need to add a way to identify GQL requests for admin domains
171
-        $admin_request                            = $this->request->isAdmin() || $this->request->isAdminAjax();
172
-        $query_params['default_where_conditions'] = $admin_request
173
-            ? EEM_Base::default_where_conditions_none
174
-            : EEM_Base::default_where_conditions_all;
175
-        return $query_params;
176
-    }
164
+	/**
165
+	 * @param array $query_params
166
+	 * @return array
167
+	 */
168
+	private function addDefaultWhereConditions(array $query_params): array
169
+	{
170
+		// might need to add a way to identify GQL requests for admin domains
171
+		$admin_request                            = $this->request->isAdmin() || $this->request->isAdminAjax();
172
+		$query_params['default_where_conditions'] = $admin_request
173
+			? EEM_Base::default_where_conditions_none
174
+			: EEM_Base::default_where_conditions_all;
175
+		return $query_params;
176
+	}
177 177
 
178 178
 
179
-    /**
180
-     * form sections should always be sorted in ascending order via the FSC_order field
181
-     *
182
-     * @param array $query_params
183
-     * @return array
184
-     */
185
-    private function addOrderByQueryParams(array $query_params): array
186
-    {
187
-        $query_params['order_by'] = ['FSC_order' => 'ASC'];
188
-        return $query_params;
189
-    }
179
+	/**
180
+	 * form sections should always be sorted in ascending order via the FSC_order field
181
+	 *
182
+	 * @param array $query_params
183
+	 * @return array
184
+	 */
185
+	private function addOrderByQueryParams(array $query_params): array
186
+	{
187
+		$query_params['order_by'] = ['FSC_order' => 'ASC'];
188
+		return $query_params;
189
+	}
190 190
 
191 191
 
192
-    /**
193
-     * returns an array of Form Sections that should be added by default to new Events
194
-     *
195
-     * @return EE_Form_Section[]
196
-     * @throws EE_Error
197
-     */
198
-    public function getDefaultFormSections(): array
199
-    {
200
-        return $this->getFormSections(['FSC_status' => FormStatus::DEFAULT]);
201
-    }
192
+	/**
193
+	 * returns an array of Form Sections that should be added by default to new Events
194
+	 *
195
+	 * @return EE_Form_Section[]
196
+	 * @throws EE_Error
197
+	 */
198
+	public function getDefaultFormSections(): array
199
+	{
200
+		return $this->getFormSections(['FSC_status' => FormStatus::DEFAULT]);
201
+	}
202 202
 
203 203
 
204
-    /**
205
-     * returns an array of Form Sections for the specified parent Form Section
206
-     *
207
-     * @param string $FSC_UUID
208
-     * @return EE_Form_Section[]
209
-     * @throws EE_Error
210
-     */
211
-    public function getChildFormSections(string $FSC_UUID): array
212
-    {
213
-        return $this->getFormSections(['FSC_belongsTo' => $FSC_UUID]);
214
-    }
204
+	/**
205
+	 * returns an array of Form Sections for the specified parent Form Section
206
+	 *
207
+	 * @param string $FSC_UUID
208
+	 * @return EE_Form_Section[]
209
+	 * @throws EE_Error
210
+	 */
211
+	public function getChildFormSections(string $FSC_UUID): array
212
+	{
213
+		return $this->getFormSections(['FSC_belongsTo' => $FSC_UUID]);
214
+	}
215 215
 
216 216
 
217
-    /**
218
-     * @return EE_Form_Section[]
219
-     * @throws EE_Error
220
-     */
221
-    public function getFormSections(array $where_params): array
222
-    {
223
-        $query_params = $this->addDefaultWhereConditions([$where_params]);
224
-        $query_params = $this->addOrderByQueryParams($query_params);
225
-        return $this->get_all($query_params);
226
-    }
217
+	/**
218
+	 * @return EE_Form_Section[]
219
+	 * @throws EE_Error
220
+	 */
221
+	public function getFormSections(array $where_params): array
222
+	{
223
+		$query_params = $this->addDefaultWhereConditions([$where_params]);
224
+		$query_params = $this->addOrderByQueryParams($query_params);
225
+		return $this->get_all($query_params);
226
+	}
227 227
 
228 228
 
229
-    /**
230
-     * returns an array of Form Sections for the specified Event
231
-     *
232
-     * @param EE_Event $event
233
-     * @return EE_Form_Section[]
234
-     * @throws EE_Error
235
-     * @throws ReflectionException
236
-     */
237
-    public function getFormSectionsForEvent(EE_Event $event): array
238
-    {
239
-        $FSC_UUID = $event->registrationFormUuid();
240
-        return ! empty($FSC_UUID)
241
-            ? $this->getFormSections(
242
-                [
243
-                    'OR' => [
244
-                        'FSC_UUID'      => $FSC_UUID, // top level form
245
-                        'FSC_belongsTo' => $FSC_UUID, // child form sections
246
-                    ],
247
-                ]
248
-            )
249
-            : [];
250
-    }
229
+	/**
230
+	 * returns an array of Form Sections for the specified Event
231
+	 *
232
+	 * @param EE_Event $event
233
+	 * @return EE_Form_Section[]
234
+	 * @throws EE_Error
235
+	 * @throws ReflectionException
236
+	 */
237
+	public function getFormSectionsForEvent(EE_Event $event): array
238
+	{
239
+		$FSC_UUID = $event->registrationFormUuid();
240
+		return ! empty($FSC_UUID)
241
+			? $this->getFormSections(
242
+				[
243
+					'OR' => [
244
+						'FSC_UUID'      => $FSC_UUID, // top level form
245
+						'FSC_belongsTo' => $FSC_UUID, // child form sections
246
+					],
247
+				]
248
+			)
249
+			: [];
250
+	}
251 251
 
252 252
 
253
-    /**
254
-     * @param bool $constants_only
255
-     * @return array
256
-     */
257
-    public function validAppliesToOptions(bool $constants_only = false): array
258
-    {
259
-        return $constants_only
260
-            ? array_keys($this->valid_applies_to_options)
261
-            : $this->valid_applies_to_options;
262
-    }
253
+	/**
254
+	 * @param bool $constants_only
255
+	 * @return array
256
+	 */
257
+	public function validAppliesToOptions(bool $constants_only = false): array
258
+	{
259
+		return $constants_only
260
+			? array_keys($this->valid_applies_to_options)
261
+			: $this->valid_applies_to_options;
262
+	}
263 263
 }
Please login to merge, or discard this patch.