Completed
Branch fix-dummy-related-question-qst... (e5efcf)
by
unknown
07:49 queued 03:45
created
core/services/assets/BlockAssetManager.php 2 patches
Indentation   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -22,249 +22,249 @@
 block discarded – undo
22 22
 abstract class BlockAssetManager extends AssetManager implements BlockAssetManagerInterface
23 23
 {
24 24
 
25
-    /**
26
-     * @var string $editor_script_handle
27
-     */
28
-    private $editor_script_handle;
29
-
30
-    /**
31
-     * @var string $editor_style_handle
32
-     */
33
-    private $editor_style_handle;
34
-
35
-    /**
36
-     * @var string $script_handle
37
-     */
38
-    private $script_handle;
39
-
40
-    /**
41
-     * @var string $style_handle
42
-     */
43
-    private $style_handle;
44
-
45
-
46
-    /**
47
-     * @return string
48
-     */
49
-    public function getEditorScriptHandle()
50
-    {
51
-        return $this->editor_script_handle;
52
-    }
53
-
54
-
55
-    /**
56
-     * @param string $editor_script_handle
57
-     */
58
-    public function setEditorScriptHandle($editor_script_handle)
59
-    {
60
-        if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
61
-            $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle;
62
-        }
63
-        $this->editor_script_handle = $editor_script_handle;
64
-    }
65
-
66
-
67
-    /**
68
-     * @return string
69
-     */
70
-    public function getEditorStyleHandle()
71
-    {
72
-        return $this->editor_style_handle;
73
-    }
74
-
75
-
76
-    /**
77
-     * @param string $editor_style_handle
78
-     */
79
-    public function setEditorStyleHandle($editor_style_handle)
80
-    {
81
-        if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
82
-            $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle;
83
-        }
84
-        $this->editor_style_handle = $editor_style_handle;
85
-    }
86
-
87
-
88
-    /**
89
-     * @return string
90
-     */
91
-    public function getScriptHandle()
92
-    {
93
-        return $this->script_handle;
94
-    }
95
-
96
-
97
-    /**
98
-     * @param string $script_handle
99
-     */
100
-    public function setScriptHandle($script_handle)
101
-    {
102
-        if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
103
-            $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle;
104
-        }
105
-        $this->script_handle = $script_handle;
106
-    }
107
-
108
-
109
-    /**
110
-     * @return string
111
-     */
112
-    public function getStyleHandle()
113
-    {
114
-        return $this->style_handle;
115
-    }
116
-
117
-
118
-    /**
119
-     * @param string $style_handle
120
-     */
121
-    public function setStyleHandle($style_handle)
122
-    {
123
-        if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
124
-            $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle;
125
-        }
126
-        $this->style_handle = $style_handle;
127
-    }
128
-
129
-    /**
130
-     * @since 4.9.71.p
131
-     * @throws InvalidDataTypeException
132
-     * @throws InvalidEntityException
133
-     * @throws DuplicateCollectionIdentifierException
134
-     */
135
-    public function addAssets()
136
-    {
137
-        $this->addEditorScript($this->getEditorScriptHandle());
138
-        $this->addEditorStyle($this->getEditorStyleHandle());
139
-        $this->addScript($this->getScriptHandle());
140
-        $this->addStyle($this->getStyleHandle());
141
-    }
142
-
143
-
144
-    /**
145
-     * @param       $handle
146
-     * @param array $dependencies
147
-     * @since 4.9.71.p
148
-     * @return JavascriptAsset
149
-     * @throws InvalidDataTypeException
150
-     * @throws InvalidEntityException
151
-     * @throws DuplicateCollectionIdentifierException
152
-     */
153
-    public function addEditorScript($handle, array $dependencies = array())
154
-    {
155
-        if ($this->assets->hasJavascriptAsset($handle)){
156
-            return $this->assets->getJavascriptAsset($handle);
157
-        }
158
-        return $this->addJs($handle, $dependencies)->setRequiresTranslation();
159
-    }
160
-
161
-
162
-    /**
163
-     * @param        $handle
164
-     * @param array  $dependencies
165
-     * @since 4.9.71.p
166
-     * @return StylesheetAsset
167
-     * @throws InvalidDataTypeException
168
-     * @throws InvalidEntityException
169
-     * @throws DuplicateCollectionIdentifierException
170
-     */
171
-    public function addEditorStyle($handle, array $dependencies = array())
172
-    {
173
-        if ($this->assets->hasStylesheetAsset($handle)) {
174
-            return $this->assets->getStylesheetAsset($handle);
175
-        }
176
-        return $this->addCss($handle, $dependencies);
177
-    }
178
-
179
-
180
-    /**
181
-     * @param       $handle
182
-     * @param array $dependencies
183
-     * @since 4.9.71.p
184
-     * @return JavascriptAsset
185
-     * @throws InvalidDataTypeException
186
-     * @throws InvalidEntityException
187
-     * @throws DuplicateCollectionIdentifierException
188
-     */
189
-    public function addScript($handle, array $dependencies = array())
190
-    {
191
-        if ($this->assets->hasJavascriptAsset($handle)) {
192
-            return $this->assets->getJavascriptAsset($handle);
193
-        }
194
-        return $this->addJs($handle, $dependencies)->setRequiresTranslation();
195
-    }
196
-
197
-
198
-    /**
199
-     * @param        $handle
200
-     * @param array  $dependencies
201
-     * @since 4.9.71.p
202
-     * @return StylesheetAsset
203
-     * @throws InvalidDataTypeException
204
-     * @throws InvalidEntityException
205
-     * @throws DuplicateCollectionIdentifierException
206
-     */
207
-    public function addStyle($handle, array $dependencies = array())
208
-    {
209
-        if ($this->assets->hasStylesheetAsset($handle)) {
210
-            return $this->assets->getStylesheetAsset($handle);
211
-        }
212
-        return $this->addCss($handle, $dependencies);
213
-    }
214
-
215
-
216
-    /**
217
-     * @return JavascriptAsset|null
218
-     */
219
-    public function getEditorScript()
220
-    {
221
-        return $this->assets->getJavascriptAsset($this->editor_script_handle);
222
-    }
223
-
224
-
225
-    /**
226
-     * @return StylesheetAsset|null
227
-     */
228
-    public function getEditorStyle()
229
-    {
230
-        return $this->assets->getStylesheetAsset($this->editor_style_handle);
231
-    }
232
-
233
-
234
-    /**
235
-     * @return JavascriptAsset|null
236
-     */
237
-    public function getScript()
238
-    {
239
-        return $this->assets->getJavascriptAsset($this->script_handle);
240
-    }
241
-
242
-
243
-    /**
244
-     * @return StylesheetAsset|null
245
-     */
246
-    public function getStyle()
247
-    {
248
-        return $this->assets->getStylesheetAsset($this->style_handle);
249
-    }
250
-
251
-
252
-    /**
253
-     * @return  void
254
-     */
255
-    public function enqueueAssets()
256
-    {
257
-        $assets = array(
258
-            $this->getEditorScript(),
259
-            $this->getEditorStyle(),
260
-            $this->getScript(),
261
-            $this->getStyle(),
262
-        );
263
-        foreach ($assets as $asset) {
264
-            if ($asset instanceof BrowserAsset && $asset->isRegistered()) {
265
-                $asset->enqueueAsset();
266
-            }
267
-        }
268
-    }
25
+	/**
26
+	 * @var string $editor_script_handle
27
+	 */
28
+	private $editor_script_handle;
29
+
30
+	/**
31
+	 * @var string $editor_style_handle
32
+	 */
33
+	private $editor_style_handle;
34
+
35
+	/**
36
+	 * @var string $script_handle
37
+	 */
38
+	private $script_handle;
39
+
40
+	/**
41
+	 * @var string $style_handle
42
+	 */
43
+	private $style_handle;
44
+
45
+
46
+	/**
47
+	 * @return string
48
+	 */
49
+	public function getEditorScriptHandle()
50
+	{
51
+		return $this->editor_script_handle;
52
+	}
53
+
54
+
55
+	/**
56
+	 * @param string $editor_script_handle
57
+	 */
58
+	public function setEditorScriptHandle($editor_script_handle)
59
+	{
60
+		if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
61
+			$editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle;
62
+		}
63
+		$this->editor_script_handle = $editor_script_handle;
64
+	}
65
+
66
+
67
+	/**
68
+	 * @return string
69
+	 */
70
+	public function getEditorStyleHandle()
71
+	{
72
+		return $this->editor_style_handle;
73
+	}
74
+
75
+
76
+	/**
77
+	 * @param string $editor_style_handle
78
+	 */
79
+	public function setEditorStyleHandle($editor_style_handle)
80
+	{
81
+		if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
82
+			$editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle;
83
+		}
84
+		$this->editor_style_handle = $editor_style_handle;
85
+	}
86
+
87
+
88
+	/**
89
+	 * @return string
90
+	 */
91
+	public function getScriptHandle()
92
+	{
93
+		return $this->script_handle;
94
+	}
95
+
96
+
97
+	/**
98
+	 * @param string $script_handle
99
+	 */
100
+	public function setScriptHandle($script_handle)
101
+	{
102
+		if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
103
+			$script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle;
104
+		}
105
+		$this->script_handle = $script_handle;
106
+	}
107
+
108
+
109
+	/**
110
+	 * @return string
111
+	 */
112
+	public function getStyleHandle()
113
+	{
114
+		return $this->style_handle;
115
+	}
116
+
117
+
118
+	/**
119
+	 * @param string $style_handle
120
+	 */
121
+	public function setStyleHandle($style_handle)
122
+	{
123
+		if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
124
+			$style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle;
125
+		}
126
+		$this->style_handle = $style_handle;
127
+	}
128
+
129
+	/**
130
+	 * @since 4.9.71.p
131
+	 * @throws InvalidDataTypeException
132
+	 * @throws InvalidEntityException
133
+	 * @throws DuplicateCollectionIdentifierException
134
+	 */
135
+	public function addAssets()
136
+	{
137
+		$this->addEditorScript($this->getEditorScriptHandle());
138
+		$this->addEditorStyle($this->getEditorStyleHandle());
139
+		$this->addScript($this->getScriptHandle());
140
+		$this->addStyle($this->getStyleHandle());
141
+	}
142
+
143
+
144
+	/**
145
+	 * @param       $handle
146
+	 * @param array $dependencies
147
+	 * @since 4.9.71.p
148
+	 * @return JavascriptAsset
149
+	 * @throws InvalidDataTypeException
150
+	 * @throws InvalidEntityException
151
+	 * @throws DuplicateCollectionIdentifierException
152
+	 */
153
+	public function addEditorScript($handle, array $dependencies = array())
154
+	{
155
+		if ($this->assets->hasJavascriptAsset($handle)){
156
+			return $this->assets->getJavascriptAsset($handle);
157
+		}
158
+		return $this->addJs($handle, $dependencies)->setRequiresTranslation();
159
+	}
160
+
161
+
162
+	/**
163
+	 * @param        $handle
164
+	 * @param array  $dependencies
165
+	 * @since 4.9.71.p
166
+	 * @return StylesheetAsset
167
+	 * @throws InvalidDataTypeException
168
+	 * @throws InvalidEntityException
169
+	 * @throws DuplicateCollectionIdentifierException
170
+	 */
171
+	public function addEditorStyle($handle, array $dependencies = array())
172
+	{
173
+		if ($this->assets->hasStylesheetAsset($handle)) {
174
+			return $this->assets->getStylesheetAsset($handle);
175
+		}
176
+		return $this->addCss($handle, $dependencies);
177
+	}
178
+
179
+
180
+	/**
181
+	 * @param       $handle
182
+	 * @param array $dependencies
183
+	 * @since 4.9.71.p
184
+	 * @return JavascriptAsset
185
+	 * @throws InvalidDataTypeException
186
+	 * @throws InvalidEntityException
187
+	 * @throws DuplicateCollectionIdentifierException
188
+	 */
189
+	public function addScript($handle, array $dependencies = array())
190
+	{
191
+		if ($this->assets->hasJavascriptAsset($handle)) {
192
+			return $this->assets->getJavascriptAsset($handle);
193
+		}
194
+		return $this->addJs($handle, $dependencies)->setRequiresTranslation();
195
+	}
196
+
197
+
198
+	/**
199
+	 * @param        $handle
200
+	 * @param array  $dependencies
201
+	 * @since 4.9.71.p
202
+	 * @return StylesheetAsset
203
+	 * @throws InvalidDataTypeException
204
+	 * @throws InvalidEntityException
205
+	 * @throws DuplicateCollectionIdentifierException
206
+	 */
207
+	public function addStyle($handle, array $dependencies = array())
208
+	{
209
+		if ($this->assets->hasStylesheetAsset($handle)) {
210
+			return $this->assets->getStylesheetAsset($handle);
211
+		}
212
+		return $this->addCss($handle, $dependencies);
213
+	}
214
+
215
+
216
+	/**
217
+	 * @return JavascriptAsset|null
218
+	 */
219
+	public function getEditorScript()
220
+	{
221
+		return $this->assets->getJavascriptAsset($this->editor_script_handle);
222
+	}
223
+
224
+
225
+	/**
226
+	 * @return StylesheetAsset|null
227
+	 */
228
+	public function getEditorStyle()
229
+	{
230
+		return $this->assets->getStylesheetAsset($this->editor_style_handle);
231
+	}
232
+
233
+
234
+	/**
235
+	 * @return JavascriptAsset|null
236
+	 */
237
+	public function getScript()
238
+	{
239
+		return $this->assets->getJavascriptAsset($this->script_handle);
240
+	}
241
+
242
+
243
+	/**
244
+	 * @return StylesheetAsset|null
245
+	 */
246
+	public function getStyle()
247
+	{
248
+		return $this->assets->getStylesheetAsset($this->style_handle);
249
+	}
250
+
251
+
252
+	/**
253
+	 * @return  void
254
+	 */
255
+	public function enqueueAssets()
256
+	{
257
+		$assets = array(
258
+			$this->getEditorScript(),
259
+			$this->getEditorStyle(),
260
+			$this->getScript(),
261
+			$this->getStyle(),
262
+		);
263
+		foreach ($assets as $asset) {
264
+			if ($asset instanceof BrowserAsset && $asset->isRegistered()) {
265
+				$asset->enqueueAsset();
266
+			}
267
+		}
268
+	}
269 269
 
270 270
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function setEditorScriptHandle($editor_script_handle)
59 59
     {
60
-        if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
61
-            $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle;
60
+        if (strpos($editor_script_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
61
+            $editor_script_handle = BlockInterface::NAME_SPACE.'-'.$editor_script_handle;
62 62
         }
63 63
         $this->editor_script_handle = $editor_script_handle;
64 64
     }
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function setEditorStyleHandle($editor_style_handle)
80 80
     {
81
-        if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
82
-            $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle;
81
+        if (strpos($editor_style_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
82
+            $editor_style_handle = BlockInterface::NAME_SPACE.'-'.$editor_style_handle;
83 83
         }
84 84
         $this->editor_style_handle = $editor_style_handle;
85 85
     }
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
      */
100 100
     public function setScriptHandle($script_handle)
101 101
     {
102
-        if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
103
-            $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle;
102
+        if (strpos($script_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
103
+            $script_handle = BlockInterface::NAME_SPACE.'-'.$script_handle;
104 104
         }
105 105
         $this->script_handle = $script_handle;
106 106
     }
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public function setStyleHandle($style_handle)
122 122
     {
123
-        if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) {
124
-            $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle;
123
+        if (strpos($style_handle, BlockInterface::NAME_SPACE.'-') !== 0) {
124
+            $style_handle = BlockInterface::NAME_SPACE.'-'.$style_handle;
125 125
         }
126 126
         $this->style_handle = $style_handle;
127 127
     }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
      */
153 153
     public function addEditorScript($handle, array $dependencies = array())
154 154
     {
155
-        if ($this->assets->hasJavascriptAsset($handle)){
155
+        if ($this->assets->hasJavascriptAsset($handle)) {
156 156
             return $this->assets->getJavascriptAsset($handle);
157 157
         }
158 158
         return $this->addJs($handle, $dependencies)->setRequiresTranslation();
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_State_Select_Input.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     {
37 37
         if (isset($input_settings['value_field_name'])) {
38 38
             $this->valueFieldName = $input_settings['value_field_name'];
39
-            if (! EEM_State::instance()->has_field((string) $this->valueFieldName())) {
39
+            if ( ! EEM_State::instance()->has_field((string) $this->valueFieldName())) {
40 40
                 throw new InvalidArgumentException(
41 41
                     sprintf(
42 42
                         esc_html__('An invalid state field "%1$s" was specified for the state input\'s option values.', 'event_espresso'),
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
             $this
54 54
         );
55 55
         $input_settings['html_class'] = isset($input_settings['html_class'])
56
-            ? $input_settings['html_class'] . ' ee-state-select-js'
56
+            ? $input_settings['html_class'].' ee-state-select-js'
57 57
             : 'ee-state-select-js';
58 58
         parent::__construct($state_options, $input_settings);
59 59
     }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     public function get_state_answer_options($state_options = null)
84 84
     {
85 85
         // if passed something that is NOT an array
86
-        if (! is_array($state_options) || empty($state_options)) {
86
+        if ( ! is_array($state_options) || empty($state_options)) {
87 87
             // get possibly cached list of states
88 88
             $states = EEM_State::instance()->get_all_active_states();
89 89
         }
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
             $states = $state_options;
92 92
             $state_options = array();
93 93
         }
94
-        if (! empty($states)) {
94
+        if ( ! empty($states)) {
95 95
             // set the default
96 96
             $state_options[''][''] = '';
97 97
             foreach ($states as $state) {
98 98
                 if ($state instanceof EE_State) {
99
-                    $state_options[ $state->country()->name() ][ $state->get($this->valueFieldName()) ] = $state->name();
99
+                    $state_options[$state->country()->name()][$state->get($this->valueFieldName())] = $state->name();
100 100
                 }
101 101
             }
102 102
         }
Please login to merge, or discard this patch.
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -12,94 +12,94 @@
 block discarded – undo
12 12
  */
13 13
 class EE_State_Select_Input extends EE_Select_Input
14 14
 {
15
-    /**
16
-     * @var string the name of the EE_State field to use for option values in the HTML form input.
17
-     */
18
-    protected $valueFieldName;
15
+	/**
16
+	 * @var string the name of the EE_State field to use for option values in the HTML form input.
17
+	 */
18
+	protected $valueFieldName;
19 19
 
20
-    /**
21
-     * @param EE_State[]|array|null $state_options. If a flat array of string is provided,
22
-     * $input_settings['value_field_name'] is ignored. If an array of states is passed, that field will be used for
23
-     * the keys (which will become the option values). If null or empty is passed, all active states will be used,
24
-     * and $input_settings['value_field_name'] will again be used.     *
25
-     * @param array $input_settings same as parent, but also {
26
-     *   @type string $value_field_name the name of the field to use
27
-     *   for the HTML option values, ie, `STA_ID`, `STA_abbrev`, or `STA_name`.
28
-     * }
29
-     * @throws EE_Error
30
-     * @throws InvalidArgumentException
31
-     * @throws InvalidDataTypeException
32
-     * @throws InvalidInterfaceException
33
-     * @throws ReflectionException
34
-     */
35
-    public function __construct($state_options, $input_settings = array())
36
-    {
37
-        if (isset($input_settings['value_field_name'])) {
38
-            $this->valueFieldName = $input_settings['value_field_name'];
39
-            if (! EEM_State::instance()->has_field((string) $this->valueFieldName())) {
40
-                throw new InvalidArgumentException(
41
-                    sprintf(
42
-                        esc_html__('An invalid state field "%1$s" was specified for the state input\'s option values.', 'event_espresso'),
43
-                        $this->valueFieldName()
44
-                    )
45
-                );
46
-            }
47
-        } else {
48
-            $this->valueFieldName = 'STA_ID';
49
-        }
50
-        $state_options = apply_filters(
51
-            'FHEE__EE_State_Select_Input____construct__state_options',
52
-            $this->get_state_answer_options($state_options),
53
-            $this
54
-        );
55
-        $input_settings['html_class'] = isset($input_settings['html_class'])
56
-            ? $input_settings['html_class'] . ' ee-state-select-js'
57
-            : 'ee-state-select-js';
58
-        parent::__construct($state_options, $input_settings);
59
-    }
20
+	/**
21
+	 * @param EE_State[]|array|null $state_options. If a flat array of string is provided,
22
+	 * $input_settings['value_field_name'] is ignored. If an array of states is passed, that field will be used for
23
+	 * the keys (which will become the option values). If null or empty is passed, all active states will be used,
24
+	 * and $input_settings['value_field_name'] will again be used.     *
25
+	 * @param array $input_settings same as parent, but also {
26
+	 *   @type string $value_field_name the name of the field to use
27
+	 *   for the HTML option values, ie, `STA_ID`, `STA_abbrev`, or `STA_name`.
28
+	 * }
29
+	 * @throws EE_Error
30
+	 * @throws InvalidArgumentException
31
+	 * @throws InvalidDataTypeException
32
+	 * @throws InvalidInterfaceException
33
+	 * @throws ReflectionException
34
+	 */
35
+	public function __construct($state_options, $input_settings = array())
36
+	{
37
+		if (isset($input_settings['value_field_name'])) {
38
+			$this->valueFieldName = $input_settings['value_field_name'];
39
+			if (! EEM_State::instance()->has_field((string) $this->valueFieldName())) {
40
+				throw new InvalidArgumentException(
41
+					sprintf(
42
+						esc_html__('An invalid state field "%1$s" was specified for the state input\'s option values.', 'event_espresso'),
43
+						$this->valueFieldName()
44
+					)
45
+				);
46
+			}
47
+		} else {
48
+			$this->valueFieldName = 'STA_ID';
49
+		}
50
+		$state_options = apply_filters(
51
+			'FHEE__EE_State_Select_Input____construct__state_options',
52
+			$this->get_state_answer_options($state_options),
53
+			$this
54
+		);
55
+		$input_settings['html_class'] = isset($input_settings['html_class'])
56
+			? $input_settings['html_class'] . ' ee-state-select-js'
57
+			: 'ee-state-select-js';
58
+		parent::__construct($state_options, $input_settings);
59
+	}
60 60
 
61
-    /**
62
-     * Returns the name of the state field used for the HTML option values.
63
-     * @since 4.10.0.p
64
-     * @return string
65
-     */
66
-    public function valueFieldName()
67
-    {
68
-        return $this->valueFieldName;
69
-    }
61
+	/**
62
+	 * Returns the name of the state field used for the HTML option values.
63
+	 * @since 4.10.0.p
64
+	 * @return string
65
+	 */
66
+	public function valueFieldName()
67
+	{
68
+		return $this->valueFieldName;
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     * get_state_answer_options
74
-     *
75
-     * @param array $state_options
76
-     * @return array
77
-     * @throws EE_Error
78
-     * @throws InvalidArgumentException
79
-     * @throws ReflectionException
80
-     * @throws InvalidDataTypeException
81
-     * @throws InvalidInterfaceException
82
-     */
83
-    public function get_state_answer_options($state_options = null)
84
-    {
85
-        // if passed something that is NOT an array
86
-        if (! is_array($state_options) || empty($state_options)) {
87
-            // get possibly cached list of states
88
-            $states = EEM_State::instance()->get_all_active_states();
89
-        }
90
-        if (is_array($state_options) && reset($state_options) instanceof EE_State) {
91
-            $states = $state_options;
92
-            $state_options = array();
93
-        }
94
-        if (! empty($states)) {
95
-            // set the default
96
-            $state_options[''][''] = '';
97
-            foreach ($states as $state) {
98
-                if ($state instanceof EE_State) {
99
-                    $state_options[ $state->country()->name() ][ $state->get($this->valueFieldName()) ] = $state->name();
100
-                }
101
-            }
102
-        }
103
-        return $state_options;
104
-    }
72
+	/**
73
+	 * get_state_answer_options
74
+	 *
75
+	 * @param array $state_options
76
+	 * @return array
77
+	 * @throws EE_Error
78
+	 * @throws InvalidArgumentException
79
+	 * @throws ReflectionException
80
+	 * @throws InvalidDataTypeException
81
+	 * @throws InvalidInterfaceException
82
+	 */
83
+	public function get_state_answer_options($state_options = null)
84
+	{
85
+		// if passed something that is NOT an array
86
+		if (! is_array($state_options) || empty($state_options)) {
87
+			// get possibly cached list of states
88
+			$states = EEM_State::instance()->get_all_active_states();
89
+		}
90
+		if (is_array($state_options) && reset($state_options) instanceof EE_State) {
91
+			$states = $state_options;
92
+			$state_options = array();
93
+		}
94
+		if (! empty($states)) {
95
+			// set the default
96
+			$state_options[''][''] = '';
97
+			foreach ($states as $state) {
98
+				if ($state instanceof EE_State) {
99
+					$state_options[ $state->country()->name() ][ $state->get($this->valueFieldName()) ] = $state->name();
100
+				}
101
+			}
102
+		}
103
+		return $state_options;
104
+	}
105 105
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Datetime.model.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                 ),
122 122
             ),
123 123
         );
124
-        $this->_model_relations        = array(
124
+        $this->_model_relations = array(
125 125
             'Ticket'  => new EE_HABTM_Relation('Datetime_Ticket'),
126 126
             'Event'   => new EE_Belongs_To_Relation(),
127 127
             'Checkin' => new EE_Has_Many_Relation(),
@@ -131,16 +131,16 @@  discard block
 block discarded – undo
131 131
         $this->model_chain_to_password = $path_to_event_model;
132 132
         $this->_model_chain_to_wp_user = $path_to_event_model;
133 133
         // this model is generally available for reading
134
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ]       = new EE_Restriction_Generator_Event_Related_Public(
134
+        $this->_cap_restriction_generators[EEM_Base::caps_read]       = new EE_Restriction_Generator_Event_Related_Public(
135 135
             $path_to_event_model
136 136
         );
137
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected(
137
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected(
138 138
             $path_to_event_model
139 139
         );
140
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]       = new EE_Restriction_Generator_Event_Related_Protected(
140
+        $this->_cap_restriction_generators[EEM_Base::caps_edit]       = new EE_Restriction_Generator_Event_Related_Protected(
141 141
             $path_to_event_model
142 142
         );
143
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]     = new EE_Restriction_Generator_Event_Related_Protected(
143
+        $this->_cap_restriction_generators[EEM_Base::caps_delete]     = new EE_Restriction_Generator_Event_Related_Protected(
144 144
             $path_to_event_model,
145 145
             EEM_Base::caps_edit
146 146
         );
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
      */
247 247
     private function validateStartAndEndTimeForBlankDate($start_time, $end_time)
248 248
     {
249
-        if (! is_array($start_time)) {
249
+        if ( ! is_array($start_time)) {
250 250
             throw new InvalidDataTypeException('start_time', $start_time, 'array');
251 251
         }
252
-        if (! is_array($end_time)) {
252
+        if ( ! is_array($end_time)) {
253 253
             throw new InvalidDataTypeException('end_time', $end_time, 'array');
254 254
         }
255 255
         if (count($start_time) !== 2) {
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
      */
284 284
     public function get_all_event_dates($EVT_ID = 0)
285 285
     {
286
-        if (! $EVT_ID) { // on add_new_event event_id gets set to 0
286
+        if ( ! $EVT_ID) { // on add_new_event event_id gets set to 0
287 287
             return $this->create_new_blank_datetime();
288 288
         }
289 289
         $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID);
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
                 'order_by'                 => array('DTT_order' => 'ASC'),
330 330
                 'default_where_conditions' => 'none',
331 331
             );
332
-        if (! $include_expired) {
332
+        if ( ! $include_expired) {
333 333
             $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
334 334
         }
335 335
         if ($include_deleted) {
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
             ),
449 449
             'default_where_conditions' => EEM_Base::default_where_conditions_this_only
450 450
         );
451
-        if (! $include_expired) {
451
+        if ( ! $include_expired) {
452 452
             $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
453 453
         }
454 454
         if ($include_deleted) {
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
         $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
487 487
         $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
488 488
         $query_params = array(array('Ticket.TKT_ID' => $TKT_ID), 'order_by' => array('DTT_EVT_start' => 'asc'));
489
-        if (! $include_expired) {
489
+        if ( ! $include_expired) {
490 490
             $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
491 491
         }
492 492
         if ($include_deleted) {
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
         $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
527 527
         $where_params = array('Ticket.TKT_ID' => $TKT_ID);
528 528
         $query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC'));
529
-        if (! $include_expired) {
529
+        if ( ! $include_expired) {
530 530
             $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
531 531
         }
532 532
         if ($include_deleted) {
@@ -649,10 +649,10 @@  discard block
 block discarded – undo
649 649
             $this->get_timezone(),
650 650
             'DTT_EVT_start'
651 651
         );
652
-        $columns_to_select        = array(
653
-            'dtt_year'      => array('YEAR(' . $query_interval . ')', '%s'),
654
-            'dtt_month'     => array('MONTHNAME(' . $query_interval . ')', '%s'),
655
-            'dtt_month_num' => array('MONTH(' . $query_interval . ')', '%s'),
652
+        $columns_to_select = array(
653
+            'dtt_year'      => array('YEAR('.$query_interval.')', '%s'),
654
+            'dtt_month'     => array('MONTHNAME('.$query_interval.')', '%s'),
655
+            'dtt_month_num' => array('MONTH('.$query_interval.')', '%s'),
656 656
         );
657 657
         return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
658 658
     }
@@ -731,17 +731,17 @@  discard block
 block discarded – undo
731 731
                 array('DTT_EVT_end' => array('<', time()))
732 732
             ),
733 733
         );
734
-        if (! empty($stati_to_include)) {
734
+        if ( ! empty($stati_to_include)) {
735 735
             foreach (array_keys($status_query_args) as $status) {
736
-                if (! in_array($status, $stati_to_include, true)) {
737
-                    unset($status_query_args[ $status ]);
736
+                if ( ! in_array($status, $stati_to_include, true)) {
737
+                    unset($status_query_args[$status]);
738 738
                 }
739 739
             }
740 740
         }
741 741
         // loop through and query counts for each stati.
742 742
         $status_query_results = array();
743 743
         foreach ($status_query_args as $status => $status_where_conditions) {
744
-            $status_query_results[ $status ] = EEM_Datetime::count(
744
+            $status_query_results[$status] = EEM_Datetime::count(
745 745
                 array($status_where_conditions),
746 746
                 'DTT_ID',
747 747
                 true
@@ -762,6 +762,6 @@  discard block
 block discarded – undo
762 762
     public function get_datetime_count_for_status($status = EE_Datetime::active, array $query_params = array())
763 763
     {
764 764
         $count = $this->get_datetime_counts_by_status(array($status), $query_params);
765
-        return ! empty($count[ $status ]) ? $count[ $status ] : 0;
765
+        return ! empty($count[$status]) ? $count[$status] : 0;
766 766
     }
767 767
 }
Please login to merge, or discard this patch.
Indentation   +751 added lines, -751 removed lines patch added patch discarded remove patch
@@ -12,755 +12,755 @@
 block discarded – undo
12 12
  */
13 13
 class EEM_Datetime extends EEM_Soft_Delete_Base
14 14
 {
15
-    /**
16
-     * @var EEM_Datetime $_instance
17
-     */
18
-    protected static $_instance;
19
-
20
-
21
-    /**
22
-     * private constructor to prevent direct creation
23
-     *
24
-     * @param string $timezone A string representing the timezone we want to set for returned Date Time Strings
25
-     *                         (and any incoming timezone data that gets saved).
26
-     *                         Note this just sends the timezone info to the date time model field objects.
27
-     *                         Default is NULL
28
-     *                         (and will be assumed using the set timezone in the 'timezone_string' wp option)
29
-     * @throws EE_Error
30
-     * @throws InvalidArgumentException
31
-     * @throws InvalidArgumentException
32
-     */
33
-    protected function __construct($timezone)
34
-    {
35
-        $this->singular_item           = esc_html__('Datetime', 'event_espresso');
36
-        $this->plural_item             = esc_html__('Datetimes', 'event_espresso');
37
-        $this->_tables                 = array(
38
-            'Datetime' => new EE_Primary_Table('esp_datetime', 'DTT_ID'),
39
-        );
40
-        $this->_fields                 = array(
41
-            'Datetime' => array(
42
-                'DTT_ID'          => new EE_Primary_Key_Int_Field(
43
-                    'DTT_ID',
44
-                    esc_html__('Datetime ID', 'event_espresso')
45
-                ),
46
-                'EVT_ID'          => new EE_Foreign_Key_Int_Field(
47
-                    'EVT_ID',
48
-                    esc_html__('Event ID', 'event_espresso'),
49
-                    false,
50
-                    0,
51
-                    'Event'
52
-                ),
53
-                'DTT_name'        => new EE_Plain_Text_Field(
54
-                    'DTT_name',
55
-                    esc_html__('Datetime Name', 'event_espresso'),
56
-                    false,
57
-                    ''
58
-                ),
59
-                'DTT_description' => new EE_Post_Content_Field(
60
-                    'DTT_description',
61
-                    esc_html__('Description for Datetime', 'event_espresso'),
62
-                    false,
63
-                    ''
64
-                ),
65
-                'DTT_EVT_start'   => new EE_Datetime_Field(
66
-                    'DTT_EVT_start',
67
-                    esc_html__('Start time/date of Event', 'event_espresso'),
68
-                    false,
69
-                    EE_Datetime_Field::now,
70
-                    $timezone
71
-                ),
72
-                'DTT_EVT_end'     => new EE_Datetime_Field(
73
-                    'DTT_EVT_end',
74
-                    esc_html__('End time/date of Event', 'event_espresso'),
75
-                    false,
76
-                    EE_Datetime_Field::now,
77
-                    $timezone
78
-                ),
79
-                'DTT_reg_limit'   => new EE_Infinite_Integer_Field(
80
-                    'DTT_reg_limit',
81
-                    esc_html__('Registration Limit for this time', 'event_espresso'),
82
-                    true,
83
-                    EE_INF
84
-                ),
85
-                'DTT_sold'        => new EE_Integer_Field(
86
-                    'DTT_sold',
87
-                    esc_html__('How many sales for this Datetime that have occurred', 'event_espresso'),
88
-                    true,
89
-                    0
90
-                ),
91
-                'DTT_reserved'    => new EE_Integer_Field(
92
-                    'DTT_reserved',
93
-                    esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso'),
94
-                    false,
95
-                    0
96
-                ),
97
-                'DTT_is_primary'  => new EE_Boolean_Field(
98
-                    'DTT_is_primary',
99
-                    esc_html__('Flag indicating datetime is primary one for event', 'event_espresso'),
100
-                    false,
101
-                    false
102
-                ),
103
-                'DTT_order'       => new EE_Integer_Field(
104
-                    'DTT_order',
105
-                    esc_html__('The order in which the Datetime is displayed', 'event_espresso'),
106
-                    false,
107
-                    0
108
-                ),
109
-                'DTT_parent'      => new EE_Integer_Field(
110
-                    'DTT_parent',
111
-                    esc_html__('Indicates what DTT_ID is the parent of this DTT_ID', 'event_espresso'),
112
-                    true,
113
-                    0
114
-                ),
115
-                'DTT_deleted'     => new EE_Trashed_Flag_Field(
116
-                    'DTT_deleted',
117
-                    esc_html__('Flag indicating datetime is archived', 'event_espresso'),
118
-                    false,
119
-                    false
120
-                ),
121
-            ),
122
-        );
123
-        $this->_model_relations        = array(
124
-            'Ticket'  => new EE_HABTM_Relation('Datetime_Ticket'),
125
-            'Event'   => new EE_Belongs_To_Relation(),
126
-            'Checkin' => new EE_Has_Many_Relation(),
127
-            'Datetime_Ticket' => new EE_Has_Many_Relation(),
128
-        );
129
-        $path_to_event_model = 'Event';
130
-        $this->model_chain_to_password = $path_to_event_model;
131
-        $this->_model_chain_to_wp_user = $path_to_event_model;
132
-        // this model is generally available for reading
133
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ]       = new EE_Restriction_Generator_Event_Related_Public(
134
-            $path_to_event_model
135
-        );
136
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected(
137
-            $path_to_event_model
138
-        );
139
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ]       = new EE_Restriction_Generator_Event_Related_Protected(
140
-            $path_to_event_model
141
-        );
142
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ]     = new EE_Restriction_Generator_Event_Related_Protected(
143
-            $path_to_event_model,
144
-            EEM_Base::caps_edit
145
-        );
146
-        parent::__construct($timezone);
147
-    }
148
-
149
-
150
-    /**
151
-     * create new blank datetime
152
-     *
153
-     * @access public
154
-     * @return EE_Datetime[] array on success, FALSE on fail
155
-     * @throws EE_Error
156
-     * @throws InvalidArgumentException
157
-     * @throws InvalidDataTypeException
158
-     * @throws ReflectionException
159
-     * @throws InvalidInterfaceException
160
-     */
161
-    public function create_new_blank_datetime()
162
-    {
163
-        // makes sure timezone is always set.
164
-        $timezone_string = $this->get_timezone();
165
-        /**
166
-         * Filters the initial start date for the new datetime.
167
-         * Any time included in this value will be overridden later so use additional filters to modify the time.
168
-         *
169
-         * @param int $start_date Unixtimestamp representing now + 30 days in seconds.
170
-         * @return int unixtimestamp
171
-         */
172
-        $start_date = apply_filters(
173
-            'FHEE__EEM_Datetime__create_new_blank_datetime__start_date',
174
-            $this->current_time_for_query('DTT_EVT_start', true) + MONTH_IN_SECONDS
175
-        );
176
-        /**
177
-         * Filters the initial end date for the new datetime.
178
-         * Any time included in this value will be overridden later so use additional filters to modify the time.
179
-         *
180
-         * @param int $end_data Unixtimestamp representing now + 30 days in seconds.
181
-         * @return int unixtimestamp
182
-         */
183
-        $end_date = apply_filters(
184
-            'FHEE__EEM_Datetime__create_new_blank_datetime__end_date',
185
-            $this->current_time_for_query('DTT_EVT_end', true) + MONTH_IN_SECONDS
186
-        );
187
-        $blank_datetime = EE_Datetime::new_instance(
188
-            array(
189
-                'DTT_EVT_start' => $start_date,
190
-                'DTT_EVT_end'   => $end_date,
191
-                'DTT_order'     => 1,
192
-                'DTT_reg_limit' => EE_INF,
193
-            ),
194
-            $timezone_string
195
-        );
196
-        /**
197
-         * Filters the initial start time and format for the new EE_Datetime instance.
198
-         *
199
-         * @param array $start_time An array having size 2.  First element is the time, second element is the time
200
-         *                          format.
201
-         * @return array
202
-         */
203
-        $start_time = apply_filters(
204
-            'FHEE__EEM_Datetime__create_new_blank_datetime__start_time',
205
-            ['8am', 'ga']
206
-        );
207
-        /**
208
-         * Filters the initial end time and format for the new EE_Datetime instance.
209
-         *
210
-         * @param array $end_time An array having size 2.  First element is the time, second element is the time
211
-         *                        format
212
-         * @return array
213
-         */
214
-        $end_time = apply_filters(
215
-            'FHEE__EEM_Datetime__create_new_blank_datetime__end_time',
216
-            ['5pm', 'ga']
217
-        );
218
-        $this->validateStartAndEndTimeForBlankDate($start_time, $end_time);
219
-        $blank_datetime->set_start_time(
220
-            $this->convert_datetime_for_query(
221
-                'DTT_EVT_start',
222
-                $start_time[0],
223
-                $start_time[1],
224
-                $timezone_string
225
-            )
226
-        );
227
-        $blank_datetime->set_end_time(
228
-            $this->convert_datetime_for_query(
229
-                'DTT_EVT_end',
230
-                $end_time[0],
231
-                $end_time[1],
232
-                $timezone_string
233
-            )
234
-        );
235
-        return array($blank_datetime);
236
-    }
237
-
238
-
239
-    /**
240
-     * Validates whether the start_time and end_time are in the expected format.
241
-     * @param array $start_time
242
-     * @param array $end_time
243
-     * @throws InvalidArgumentException
244
-     * @throws InvalidDataTypeException
245
-     */
246
-    private function validateStartAndEndTimeForBlankDate($start_time, $end_time)
247
-    {
248
-        if (! is_array($start_time)) {
249
-            throw new InvalidDataTypeException('start_time', $start_time, 'array');
250
-        }
251
-        if (! is_array($end_time)) {
252
-            throw new InvalidDataTypeException('end_time', $end_time, 'array');
253
-        }
254
-        if (count($start_time) !== 2) {
255
-            throw new InvalidArgumentException(
256
-                sprintf(
257
-                    'The variable %1$s is expected to be an array with two elements.  The first item in the '
258
-                    . 'array should be a valid time string, the second item in the array should be a valid time format',
259
-                    '$start_time'
260
-                )
261
-            );
262
-        }
263
-        if (count($end_time) !== 2) {
264
-            throw new InvalidArgumentException(
265
-                sprintf(
266
-                    'The variable %1$s is expected to be an array with two elements.  The first item in the '
267
-                    . 'array should be a valid time string, the second item in the array should be a valid time format',
268
-                    '$end_time'
269
-                )
270
-            );
271
-        }
272
-    }
273
-
274
-
275
-    /**
276
-     * get event start date from db
277
-     *
278
-     * @access public
279
-     * @param  int $EVT_ID
280
-     * @return EE_Datetime[] array on success, FALSE on fail
281
-     * @throws EE_Error
282
-     */
283
-    public function get_all_event_dates($EVT_ID = 0)
284
-    {
285
-        if (! $EVT_ID) { // on add_new_event event_id gets set to 0
286
-            return $this->create_new_blank_datetime();
287
-        }
288
-        $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID);
289
-        if (empty($results)) {
290
-            return $this->create_new_blank_datetime();
291
-        }
292
-        return $results;
293
-    }
294
-
295
-
296
-    /**
297
-     * get all datetimes attached to an event ordered by the DTT_order field
298
-     *
299
-     * @public
300
-     * @param  int    $EVT_ID     event id
301
-     * @param boolean $include_expired
302
-     * @param boolean $include_deleted
303
-     * @param  int    $limit      If included then limit the count of results by
304
-     *                            the given number
305
-     * @return EE_Datetime[]
306
-     * @throws EE_Error
307
-     */
308
-    public function get_datetimes_for_event_ordered_by_DTT_order(
309
-        $EVT_ID,
310
-        $include_expired = true,
311
-        $include_deleted = true,
312
-        $limit = null
313
-    ) {
314
-        // sanitize EVT_ID
315
-        $EVT_ID         = absint($EVT_ID);
316
-        $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
317
-        $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
318
-        $where_params = array('Event.EVT_ID' => $EVT_ID);
319
-        $query_params = ! empty($limit)
320
-            ? array(
321
-                $where_params,
322
-                'limit'                    => $limit,
323
-                'order_by'                 => array('DTT_order' => 'ASC'),
324
-                'default_where_conditions' => 'none',
325
-            )
326
-            : array(
327
-                $where_params,
328
-                'order_by'                 => array('DTT_order' => 'ASC'),
329
-                'default_where_conditions' => 'none',
330
-            );
331
-        if (! $include_expired) {
332
-            $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
333
-        }
334
-        if ($include_deleted) {
335
-            $query_params[0]['DTT_deleted'] = array('IN', array(true, false));
336
-        }
337
-        /** @var EE_Datetime[] $result */
338
-        $result = $this->get_all($query_params);
339
-        $this->assume_values_already_prepared_by_model_object($old_assumption);
340
-        return $result;
341
-    }
342
-
343
-
344
-    /**
345
-     * Gets the datetimes for the event (with the given limit), and orders them by "importance".
346
-     * By importance, we mean that the primary datetimes are most important (DEPRECATED FOR NOW),
347
-     * and then the earlier datetimes are the most important.
348
-     * Maybe we'll want this to take into account datetimes that haven't already passed, but we don't yet.
349
-     *
350
-     * @param int $EVT_ID
351
-     * @param int $limit
352
-     * @return EE_Datetime[]|EE_Base_Class[]
353
-     * @throws EE_Error
354
-     */
355
-    public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = null)
356
-    {
357
-        return $this->get_all(
358
-            array(
359
-                array('Event.EVT_ID' => $EVT_ID),
360
-                'limit'                    => $limit,
361
-                'order_by'                 => array('DTT_EVT_start' => 'ASC'),
362
-                'default_where_conditions' => 'none',
363
-            )
364
-        );
365
-    }
366
-
367
-
368
-    /**
369
-     * @param int     $EVT_ID
370
-     * @param boolean $include_expired
371
-     * @param boolean $include_deleted
372
-     * @return EE_Datetime
373
-     * @throws EE_Error
374
-     */
375
-    public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false)
376
-    {
377
-        $results = $this->get_datetimes_for_event_ordered_by_start_time(
378
-            $EVT_ID,
379
-            $include_expired,
380
-            $include_deleted,
381
-            1
382
-        );
383
-        if ($results) {
384
-            return array_shift($results);
385
-        }
386
-        return null;
387
-    }
388
-
389
-
390
-    /**
391
-     * Gets the 'primary' datetime for an event.
392
-     *
393
-     * @param int  $EVT_ID
394
-     * @param bool $try_to_exclude_expired
395
-     * @param bool $try_to_exclude_deleted
396
-     * @return \EE_Datetime
397
-     * @throws EE_Error
398
-     */
399
-    public function get_primary_datetime_for_event(
400
-        $EVT_ID,
401
-        $try_to_exclude_expired = true,
402
-        $try_to_exclude_deleted = true
403
-    ) {
404
-        if ($try_to_exclude_expired) {
405
-            $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false);
406
-            if ($non_expired) {
407
-                return $non_expired;
408
-            }
409
-        }
410
-        if ($try_to_exclude_deleted) {
411
-            $expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true);
412
-            if ($expired_even) {
413
-                return $expired_even;
414
-            }
415
-        }
416
-        return $this->get_oldest_datetime_for_event($EVT_ID, true, true);
417
-    }
418
-
419
-
420
-    /**
421
-     * Gets ALL the datetimes for an event (including trashed ones, for now), ordered
422
-     * only by start date
423
-     *
424
-     * @param int     $EVT_ID
425
-     * @param boolean $include_expired
426
-     * @param boolean $include_deleted
427
-     * @param int     $limit
428
-     * @return EE_Datetime[]
429
-     * @throws EE_Error
430
-     */
431
-    public function get_datetimes_for_event_ordered_by_start_time(
432
-        $EVT_ID,
433
-        $include_expired = true,
434
-        $include_deleted = true,
435
-        $limit = null
436
-    ) {
437
-        // sanitize EVT_ID
438
-        $EVT_ID         = absint($EVT_ID);
439
-        $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
440
-        $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
441
-        $query_params = array(
442
-            array(
443
-                'Event.EVT_ID' => $EVT_ID
444
-            ),
445
-            'order_by' => array(
446
-                'DTT_EVT_start' => 'asc'
447
-            ),
448
-            'default_where_conditions' => EEM_Base::default_where_conditions_this_only
449
-        );
450
-        if (! $include_expired) {
451
-            $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
452
-        }
453
-        if ($include_deleted) {
454
-            $query_params[0]['DTT_deleted'] = array('IN', array(true, false));
455
-        }
456
-        if ($limit) {
457
-            $query_params['limit'] = $limit;
458
-        }
459
-        /** @var EE_Datetime[] $result */
460
-        $result = $this->get_all($query_params);
461
-        $this->assume_values_already_prepared_by_model_object($old_assumption);
462
-        return $result;
463
-    }
464
-
465
-
466
-    /**
467
-     * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered
468
-     * only by start date
469
-     *
470
-     * @param int     $TKT_ID
471
-     * @param boolean $include_expired
472
-     * @param boolean $include_deleted
473
-     * @param int     $limit
474
-     * @return EE_Datetime[]
475
-     * @throws EE_Error
476
-     */
477
-    public function get_datetimes_for_ticket_ordered_by_start_time(
478
-        $TKT_ID,
479
-        $include_expired = true,
480
-        $include_deleted = true,
481
-        $limit = null
482
-    ) {
483
-        // sanitize TKT_ID
484
-        $TKT_ID         = absint($TKT_ID);
485
-        $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
486
-        $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
487
-        $query_params = array(array('Ticket.TKT_ID' => $TKT_ID), 'order_by' => array('DTT_EVT_start' => 'asc'));
488
-        if (! $include_expired) {
489
-            $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
490
-        }
491
-        if ($include_deleted) {
492
-            $query_params[0]['DTT_deleted'] = array('IN', array(true, false));
493
-        }
494
-        if ($limit) {
495
-            $query_params['limit'] = $limit;
496
-        }
497
-        /** @var EE_Datetime[] $result */
498
-        $result = $this->get_all($query_params);
499
-        $this->assume_values_already_prepared_by_model_object($old_assumption);
500
-        return $result;
501
-    }
502
-
503
-
504
-    /**
505
-     * Gets all the datetimes for a ticket (including trashed ones, for now), ordered by the DTT_order for the
506
-     * datetimes.
507
-     *
508
-     * @param  int      $TKT_ID          ID of ticket to retrieve the datetimes for
509
-     * @param  boolean  $include_expired whether to include expired datetimes or not
510
-     * @param  boolean  $include_deleted whether to include trashed datetimes or not.
511
-     * @param  int|null $limit           if null, no limit, if int then limit results by
512
-     *                                   that number
513
-     * @return EE_Datetime[]
514
-     * @throws EE_Error
515
-     */
516
-    public function get_datetimes_for_ticket_ordered_by_DTT_order(
517
-        $TKT_ID,
518
-        $include_expired = true,
519
-        $include_deleted = true,
520
-        $limit = null
521
-    ) {
522
-        // sanitize id.
523
-        $TKT_ID         = absint($TKT_ID);
524
-        $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
525
-        $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
526
-        $where_params = array('Ticket.TKT_ID' => $TKT_ID);
527
-        $query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC'));
528
-        if (! $include_expired) {
529
-            $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
530
-        }
531
-        if ($include_deleted) {
532
-            $query_params[0]['DTT_deleted'] = array('IN', array(true, false));
533
-        }
534
-        if ($limit) {
535
-            $query_params['limit'] = $limit;
536
-        }
537
-        /** @var EE_Datetime[] $result */
538
-        $result = $this->get_all($query_params);
539
-        $this->assume_values_already_prepared_by_model_object($old_assumption);
540
-        return $result;
541
-    }
542
-
543
-
544
-    /**
545
-     * Gets the most important datetime for a particular event (ie, the primary event usually. But if for some WACK
546
-     * reason it doesn't exist, we consider the earliest event the most important)
547
-     *
548
-     * @param int $EVT_ID
549
-     * @return EE_Datetime
550
-     * @throws EE_Error
551
-     */
552
-    public function get_most_important_datetime_for_event($EVT_ID)
553
-    {
554
-        $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1);
555
-        if ($results) {
556
-            return array_shift($results);
557
-        }
558
-        return null;
559
-    }
560
-
561
-
562
-    /**
563
-     * This returns a wpdb->results        Array of all DTT month and years matching the incoming query params and
564
-     * grouped by month and year.
565
-     *
566
-     * @param  array  $where_params      @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions
567
-     * @param  string $evt_active_status A string representing the evt active status to filter the months by.
568
-     *                                   Can be:
569
-     *                                   - '' = no filter
570
-     *                                   - upcoming = Published events with at least one upcoming datetime.
571
-     *                                   - expired = Events with all datetimes expired.
572
-     *                                   - active = Events that are published and have at least one datetime that
573
-     *                                   starts before now and ends after now.
574
-     *                                   - inactive = Events that are either not published.
575
-     * @return stdClass[]
576
-     * @throws EE_Error
577
-     * @throws InvalidArgumentException
578
-     * @throws InvalidArgumentException
579
-     */
580
-    public function get_dtt_months_and_years($where_params, $evt_active_status = '')
581
-    {
582
-        $current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start');
583
-        $current_time_for_DTT_EVT_end   = $this->current_time_for_query('DTT_EVT_end');
584
-        switch ($evt_active_status) {
585
-            case 'upcoming':
586
-                $where_params['Event.status'] = 'publish';
587
-                // if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
588
-                if (isset($where_params['DTT_EVT_start'])) {
589
-                    $where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start'];
590
-                }
591
-                $where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start);
592
-                break;
593
-            case 'expired':
594
-                if (isset($where_params['Event.status'])) {
595
-                    unset($where_params['Event.status']);
596
-                }
597
-                // get events to exclude
598
-                $exclude_query[0] = array_merge(
599
-                    $where_params,
600
-                    array('DTT_EVT_end' => array('>', $current_time_for_DTT_EVT_end))
601
-                );
602
-                // first get all events that have datetimes where its not expired.
603
-                $event_ids = $this->_get_all_wpdb_results(
604
-                    $exclude_query,
605
-                    OBJECT_K,
606
-                    'Datetime.EVT_ID'
607
-                );
608
-                $event_ids = array_keys($event_ids);
609
-                if (isset($where_params['DTT_EVT_end'])) {
610
-                    $where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end'];
611
-                }
612
-                $where_params['DTT_EVT_end']  = array('<', $current_time_for_DTT_EVT_end);
613
-                $where_params['Event.EVT_ID'] = array('NOT IN', $event_ids);
614
-                break;
615
-            case 'active':
616
-                $where_params['Event.status'] = 'publish';
617
-                if (isset($where_params['DTT_EVT_start'])) {
618
-                    $where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start'];
619
-                }
620
-                if (isset($where_params['Datetime.DTT_EVT_end'])) {
621
-                    $where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end'];
622
-                }
623
-                $where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start);
624
-                $where_params['DTT_EVT_end']   = array('>', $current_time_for_DTT_EVT_end);
625
-                break;
626
-            case 'inactive':
627
-                if (isset($where_params['Event.status'])) {
628
-                    unset($where_params['Event.status']);
629
-                }
630
-                if (isset($where_params['OR'])) {
631
-                    $where_params['AND']['OR'] = $where_params['OR'];
632
-                }
633
-                if (isset($where_params['DTT_EVT_end'])) {
634
-                    $where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end'];
635
-                    unset($where_params['DTT_EVT_end']);
636
-                }
637
-                if (isset($where_params['DTT_EVT_start'])) {
638
-                    $where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start'];
639
-                    unset($where_params['DTT_EVT_start']);
640
-                }
641
-                $where_params['AND']['Event.status'] = array('!=', 'publish');
642
-                break;
643
-        }
644
-        $query_params[0]          = $where_params;
645
-        $query_params['group_by'] = array('dtt_year', 'dtt_month');
646
-        $query_params['order_by'] = array('DTT_EVT_start' => 'DESC');
647
-        $query_interval           = EEH_DTT_Helper::get_sql_query_interval_for_offset(
648
-            $this->get_timezone(),
649
-            'DTT_EVT_start'
650
-        );
651
-        $columns_to_select        = array(
652
-            'dtt_year'      => array('YEAR(' . $query_interval . ')', '%s'),
653
-            'dtt_month'     => array('MONTHNAME(' . $query_interval . ')', '%s'),
654
-            'dtt_month_num' => array('MONTH(' . $query_interval . ')', '%s'),
655
-        );
656
-        return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
657
-    }
658
-
659
-
660
-    /**
661
-     * Updates the DTT_sold attribute on each datetime (based on the registrations
662
-     * for the tickets for each datetime)
663
-     *
664
-     * @param EE_Base_Class[]|EE_Datetime[] $datetimes
665
-     * @throws EE_Error
666
-     */
667
-    public function update_sold($datetimes)
668
-    {
669
-        EE_Error::doing_it_wrong(
670
-            __FUNCTION__,
671
-            esc_html__(
672
-                'Please use \EEM_Ticket::update_tickets_sold() instead which will in turn correctly update both the Ticket AND Datetime counts.',
673
-                'event_espresso'
674
-            ),
675
-            '4.9.32.rc.005'
676
-        );
677
-        foreach ($datetimes as $datetime) {
678
-            $datetime->update_sold();
679
-        }
680
-    }
681
-
682
-
683
-    /**
684
-     *    Gets the total number of tickets available at a particular datetime
685
-     *    (does NOT take into account the datetime's spaces available)
686
-     *
687
-     * @param int   $DTT_ID
688
-     * @param array $query_params
689
-     * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF,  IF there are NO
690
-     *             tickets attached to datetime then FALSE is returned.
691
-     */
692
-    public function sum_tickets_currently_available_at_datetime($DTT_ID, array $query_params = array())
693
-    {
694
-        $datetime = $this->get_one_by_ID($DTT_ID);
695
-        if ($datetime instanceof EE_Datetime) {
696
-            return $datetime->tickets_remaining($query_params);
697
-        }
698
-        return 0;
699
-    }
700
-
701
-
702
-    /**
703
-     * This returns an array of counts of datetimes in the database for each Datetime status that can be queried.
704
-     *
705
-     * @param  array $stati_to_include If included you can restrict the statuses we return counts for by including the
706
-     *                                 stati you want counts for as values in the array.  An empty array returns counts
707
-     *                                 for all valid stati.
708
-     * @param  array $query_params     If included can be used to refine the conditions for returning the count (i.e.
709
-     *                                 only for Datetimes connected to a specific event, or specific ticket.
710
-     * @return array  The value returned is an array indexed by Datetime Status and the values are the counts.  The
711
-     * @throws EE_Error
712
-     *                                 stati used as index keys are: EE_Datetime::active EE_Datetime::upcoming
713
-     *                                 EE_Datetime::expired
714
-     */
715
-    public function get_datetime_counts_by_status(array $stati_to_include = array(), array $query_params = array())
716
-    {
717
-        // only accept where conditions for this query.
718
-        $_where            = isset($query_params[0]) ? $query_params[0] : array();
719
-        $status_query_args = array(
720
-            EE_Datetime::active   => array_merge(
721
-                $_where,
722
-                array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time()))
723
-            ),
724
-            EE_Datetime::upcoming => array_merge(
725
-                $_where,
726
-                array('DTT_EVT_start' => array('>', time()))
727
-            ),
728
-            EE_Datetime::expired  => array_merge(
729
-                $_where,
730
-                array('DTT_EVT_end' => array('<', time()))
731
-            ),
732
-        );
733
-        if (! empty($stati_to_include)) {
734
-            foreach (array_keys($status_query_args) as $status) {
735
-                if (! in_array($status, $stati_to_include, true)) {
736
-                    unset($status_query_args[ $status ]);
737
-                }
738
-            }
739
-        }
740
-        // loop through and query counts for each stati.
741
-        $status_query_results = array();
742
-        foreach ($status_query_args as $status => $status_where_conditions) {
743
-            $status_query_results[ $status ] = EEM_Datetime::count(
744
-                array($status_where_conditions),
745
-                'DTT_ID',
746
-                true
747
-            );
748
-        }
749
-        return $status_query_results;
750
-    }
751
-
752
-
753
-    /**
754
-     * Returns the specific count for a given Datetime status matching any given query_params.
755
-     *
756
-     * @param string $status Valid string representation for Datetime status requested. (Defaults to Active).
757
-     * @param array  $query_params
758
-     * @return int
759
-     * @throws EE_Error
760
-     */
761
-    public function get_datetime_count_for_status($status = EE_Datetime::active, array $query_params = array())
762
-    {
763
-        $count = $this->get_datetime_counts_by_status(array($status), $query_params);
764
-        return ! empty($count[ $status ]) ? $count[ $status ] : 0;
765
-    }
15
+	/**
16
+	 * @var EEM_Datetime $_instance
17
+	 */
18
+	protected static $_instance;
19
+
20
+
21
+	/**
22
+	 * private constructor to prevent direct creation
23
+	 *
24
+	 * @param string $timezone A string representing the timezone we want to set for returned Date Time Strings
25
+	 *                         (and any incoming timezone data that gets saved).
26
+	 *                         Note this just sends the timezone info to the date time model field objects.
27
+	 *                         Default is NULL
28
+	 *                         (and will be assumed using the set timezone in the 'timezone_string' wp option)
29
+	 * @throws EE_Error
30
+	 * @throws InvalidArgumentException
31
+	 * @throws InvalidArgumentException
32
+	 */
33
+	protected function __construct($timezone)
34
+	{
35
+		$this->singular_item           = esc_html__('Datetime', 'event_espresso');
36
+		$this->plural_item             = esc_html__('Datetimes', 'event_espresso');
37
+		$this->_tables                 = array(
38
+			'Datetime' => new EE_Primary_Table('esp_datetime', 'DTT_ID'),
39
+		);
40
+		$this->_fields                 = array(
41
+			'Datetime' => array(
42
+				'DTT_ID'          => new EE_Primary_Key_Int_Field(
43
+					'DTT_ID',
44
+					esc_html__('Datetime ID', 'event_espresso')
45
+				),
46
+				'EVT_ID'          => new EE_Foreign_Key_Int_Field(
47
+					'EVT_ID',
48
+					esc_html__('Event ID', 'event_espresso'),
49
+					false,
50
+					0,
51
+					'Event'
52
+				),
53
+				'DTT_name'        => new EE_Plain_Text_Field(
54
+					'DTT_name',
55
+					esc_html__('Datetime Name', 'event_espresso'),
56
+					false,
57
+					''
58
+				),
59
+				'DTT_description' => new EE_Post_Content_Field(
60
+					'DTT_description',
61
+					esc_html__('Description for Datetime', 'event_espresso'),
62
+					false,
63
+					''
64
+				),
65
+				'DTT_EVT_start'   => new EE_Datetime_Field(
66
+					'DTT_EVT_start',
67
+					esc_html__('Start time/date of Event', 'event_espresso'),
68
+					false,
69
+					EE_Datetime_Field::now,
70
+					$timezone
71
+				),
72
+				'DTT_EVT_end'     => new EE_Datetime_Field(
73
+					'DTT_EVT_end',
74
+					esc_html__('End time/date of Event', 'event_espresso'),
75
+					false,
76
+					EE_Datetime_Field::now,
77
+					$timezone
78
+				),
79
+				'DTT_reg_limit'   => new EE_Infinite_Integer_Field(
80
+					'DTT_reg_limit',
81
+					esc_html__('Registration Limit for this time', 'event_espresso'),
82
+					true,
83
+					EE_INF
84
+				),
85
+				'DTT_sold'        => new EE_Integer_Field(
86
+					'DTT_sold',
87
+					esc_html__('How many sales for this Datetime that have occurred', 'event_espresso'),
88
+					true,
89
+					0
90
+				),
91
+				'DTT_reserved'    => new EE_Integer_Field(
92
+					'DTT_reserved',
93
+					esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso'),
94
+					false,
95
+					0
96
+				),
97
+				'DTT_is_primary'  => new EE_Boolean_Field(
98
+					'DTT_is_primary',
99
+					esc_html__('Flag indicating datetime is primary one for event', 'event_espresso'),
100
+					false,
101
+					false
102
+				),
103
+				'DTT_order'       => new EE_Integer_Field(
104
+					'DTT_order',
105
+					esc_html__('The order in which the Datetime is displayed', 'event_espresso'),
106
+					false,
107
+					0
108
+				),
109
+				'DTT_parent'      => new EE_Integer_Field(
110
+					'DTT_parent',
111
+					esc_html__('Indicates what DTT_ID is the parent of this DTT_ID', 'event_espresso'),
112
+					true,
113
+					0
114
+				),
115
+				'DTT_deleted'     => new EE_Trashed_Flag_Field(
116
+					'DTT_deleted',
117
+					esc_html__('Flag indicating datetime is archived', 'event_espresso'),
118
+					false,
119
+					false
120
+				),
121
+			),
122
+		);
123
+		$this->_model_relations        = array(
124
+			'Ticket'  => new EE_HABTM_Relation('Datetime_Ticket'),
125
+			'Event'   => new EE_Belongs_To_Relation(),
126
+			'Checkin' => new EE_Has_Many_Relation(),
127
+			'Datetime_Ticket' => new EE_Has_Many_Relation(),
128
+		);
129
+		$path_to_event_model = 'Event';
130
+		$this->model_chain_to_password = $path_to_event_model;
131
+		$this->_model_chain_to_wp_user = $path_to_event_model;
132
+		// this model is generally available for reading
133
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ]       = new EE_Restriction_Generator_Event_Related_Public(
134
+			$path_to_event_model
135
+		);
136
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected(
137
+			$path_to_event_model
138
+		);
139
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ]       = new EE_Restriction_Generator_Event_Related_Protected(
140
+			$path_to_event_model
141
+		);
142
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ]     = new EE_Restriction_Generator_Event_Related_Protected(
143
+			$path_to_event_model,
144
+			EEM_Base::caps_edit
145
+		);
146
+		parent::__construct($timezone);
147
+	}
148
+
149
+
150
+	/**
151
+	 * create new blank datetime
152
+	 *
153
+	 * @access public
154
+	 * @return EE_Datetime[] array on success, FALSE on fail
155
+	 * @throws EE_Error
156
+	 * @throws InvalidArgumentException
157
+	 * @throws InvalidDataTypeException
158
+	 * @throws ReflectionException
159
+	 * @throws InvalidInterfaceException
160
+	 */
161
+	public function create_new_blank_datetime()
162
+	{
163
+		// makes sure timezone is always set.
164
+		$timezone_string = $this->get_timezone();
165
+		/**
166
+		 * Filters the initial start date for the new datetime.
167
+		 * Any time included in this value will be overridden later so use additional filters to modify the time.
168
+		 *
169
+		 * @param int $start_date Unixtimestamp representing now + 30 days in seconds.
170
+		 * @return int unixtimestamp
171
+		 */
172
+		$start_date = apply_filters(
173
+			'FHEE__EEM_Datetime__create_new_blank_datetime__start_date',
174
+			$this->current_time_for_query('DTT_EVT_start', true) + MONTH_IN_SECONDS
175
+		);
176
+		/**
177
+		 * Filters the initial end date for the new datetime.
178
+		 * Any time included in this value will be overridden later so use additional filters to modify the time.
179
+		 *
180
+		 * @param int $end_data Unixtimestamp representing now + 30 days in seconds.
181
+		 * @return int unixtimestamp
182
+		 */
183
+		$end_date = apply_filters(
184
+			'FHEE__EEM_Datetime__create_new_blank_datetime__end_date',
185
+			$this->current_time_for_query('DTT_EVT_end', true) + MONTH_IN_SECONDS
186
+		);
187
+		$blank_datetime = EE_Datetime::new_instance(
188
+			array(
189
+				'DTT_EVT_start' => $start_date,
190
+				'DTT_EVT_end'   => $end_date,
191
+				'DTT_order'     => 1,
192
+				'DTT_reg_limit' => EE_INF,
193
+			),
194
+			$timezone_string
195
+		);
196
+		/**
197
+		 * Filters the initial start time and format for the new EE_Datetime instance.
198
+		 *
199
+		 * @param array $start_time An array having size 2.  First element is the time, second element is the time
200
+		 *                          format.
201
+		 * @return array
202
+		 */
203
+		$start_time = apply_filters(
204
+			'FHEE__EEM_Datetime__create_new_blank_datetime__start_time',
205
+			['8am', 'ga']
206
+		);
207
+		/**
208
+		 * Filters the initial end time and format for the new EE_Datetime instance.
209
+		 *
210
+		 * @param array $end_time An array having size 2.  First element is the time, second element is the time
211
+		 *                        format
212
+		 * @return array
213
+		 */
214
+		$end_time = apply_filters(
215
+			'FHEE__EEM_Datetime__create_new_blank_datetime__end_time',
216
+			['5pm', 'ga']
217
+		);
218
+		$this->validateStartAndEndTimeForBlankDate($start_time, $end_time);
219
+		$blank_datetime->set_start_time(
220
+			$this->convert_datetime_for_query(
221
+				'DTT_EVT_start',
222
+				$start_time[0],
223
+				$start_time[1],
224
+				$timezone_string
225
+			)
226
+		);
227
+		$blank_datetime->set_end_time(
228
+			$this->convert_datetime_for_query(
229
+				'DTT_EVT_end',
230
+				$end_time[0],
231
+				$end_time[1],
232
+				$timezone_string
233
+			)
234
+		);
235
+		return array($blank_datetime);
236
+	}
237
+
238
+
239
+	/**
240
+	 * Validates whether the start_time and end_time are in the expected format.
241
+	 * @param array $start_time
242
+	 * @param array $end_time
243
+	 * @throws InvalidArgumentException
244
+	 * @throws InvalidDataTypeException
245
+	 */
246
+	private function validateStartAndEndTimeForBlankDate($start_time, $end_time)
247
+	{
248
+		if (! is_array($start_time)) {
249
+			throw new InvalidDataTypeException('start_time', $start_time, 'array');
250
+		}
251
+		if (! is_array($end_time)) {
252
+			throw new InvalidDataTypeException('end_time', $end_time, 'array');
253
+		}
254
+		if (count($start_time) !== 2) {
255
+			throw new InvalidArgumentException(
256
+				sprintf(
257
+					'The variable %1$s is expected to be an array with two elements.  The first item in the '
258
+					. 'array should be a valid time string, the second item in the array should be a valid time format',
259
+					'$start_time'
260
+				)
261
+			);
262
+		}
263
+		if (count($end_time) !== 2) {
264
+			throw new InvalidArgumentException(
265
+				sprintf(
266
+					'The variable %1$s is expected to be an array with two elements.  The first item in the '
267
+					. 'array should be a valid time string, the second item in the array should be a valid time format',
268
+					'$end_time'
269
+				)
270
+			);
271
+		}
272
+	}
273
+
274
+
275
+	/**
276
+	 * get event start date from db
277
+	 *
278
+	 * @access public
279
+	 * @param  int $EVT_ID
280
+	 * @return EE_Datetime[] array on success, FALSE on fail
281
+	 * @throws EE_Error
282
+	 */
283
+	public function get_all_event_dates($EVT_ID = 0)
284
+	{
285
+		if (! $EVT_ID) { // on add_new_event event_id gets set to 0
286
+			return $this->create_new_blank_datetime();
287
+		}
288
+		$results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID);
289
+		if (empty($results)) {
290
+			return $this->create_new_blank_datetime();
291
+		}
292
+		return $results;
293
+	}
294
+
295
+
296
+	/**
297
+	 * get all datetimes attached to an event ordered by the DTT_order field
298
+	 *
299
+	 * @public
300
+	 * @param  int    $EVT_ID     event id
301
+	 * @param boolean $include_expired
302
+	 * @param boolean $include_deleted
303
+	 * @param  int    $limit      If included then limit the count of results by
304
+	 *                            the given number
305
+	 * @return EE_Datetime[]
306
+	 * @throws EE_Error
307
+	 */
308
+	public function get_datetimes_for_event_ordered_by_DTT_order(
309
+		$EVT_ID,
310
+		$include_expired = true,
311
+		$include_deleted = true,
312
+		$limit = null
313
+	) {
314
+		// sanitize EVT_ID
315
+		$EVT_ID         = absint($EVT_ID);
316
+		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
317
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
318
+		$where_params = array('Event.EVT_ID' => $EVT_ID);
319
+		$query_params = ! empty($limit)
320
+			? array(
321
+				$where_params,
322
+				'limit'                    => $limit,
323
+				'order_by'                 => array('DTT_order' => 'ASC'),
324
+				'default_where_conditions' => 'none',
325
+			)
326
+			: array(
327
+				$where_params,
328
+				'order_by'                 => array('DTT_order' => 'ASC'),
329
+				'default_where_conditions' => 'none',
330
+			);
331
+		if (! $include_expired) {
332
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
333
+		}
334
+		if ($include_deleted) {
335
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
336
+		}
337
+		/** @var EE_Datetime[] $result */
338
+		$result = $this->get_all($query_params);
339
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
340
+		return $result;
341
+	}
342
+
343
+
344
+	/**
345
+	 * Gets the datetimes for the event (with the given limit), and orders them by "importance".
346
+	 * By importance, we mean that the primary datetimes are most important (DEPRECATED FOR NOW),
347
+	 * and then the earlier datetimes are the most important.
348
+	 * Maybe we'll want this to take into account datetimes that haven't already passed, but we don't yet.
349
+	 *
350
+	 * @param int $EVT_ID
351
+	 * @param int $limit
352
+	 * @return EE_Datetime[]|EE_Base_Class[]
353
+	 * @throws EE_Error
354
+	 */
355
+	public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = null)
356
+	{
357
+		return $this->get_all(
358
+			array(
359
+				array('Event.EVT_ID' => $EVT_ID),
360
+				'limit'                    => $limit,
361
+				'order_by'                 => array('DTT_EVT_start' => 'ASC'),
362
+				'default_where_conditions' => 'none',
363
+			)
364
+		);
365
+	}
366
+
367
+
368
+	/**
369
+	 * @param int     $EVT_ID
370
+	 * @param boolean $include_expired
371
+	 * @param boolean $include_deleted
372
+	 * @return EE_Datetime
373
+	 * @throws EE_Error
374
+	 */
375
+	public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false)
376
+	{
377
+		$results = $this->get_datetimes_for_event_ordered_by_start_time(
378
+			$EVT_ID,
379
+			$include_expired,
380
+			$include_deleted,
381
+			1
382
+		);
383
+		if ($results) {
384
+			return array_shift($results);
385
+		}
386
+		return null;
387
+	}
388
+
389
+
390
+	/**
391
+	 * Gets the 'primary' datetime for an event.
392
+	 *
393
+	 * @param int  $EVT_ID
394
+	 * @param bool $try_to_exclude_expired
395
+	 * @param bool $try_to_exclude_deleted
396
+	 * @return \EE_Datetime
397
+	 * @throws EE_Error
398
+	 */
399
+	public function get_primary_datetime_for_event(
400
+		$EVT_ID,
401
+		$try_to_exclude_expired = true,
402
+		$try_to_exclude_deleted = true
403
+	) {
404
+		if ($try_to_exclude_expired) {
405
+			$non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false);
406
+			if ($non_expired) {
407
+				return $non_expired;
408
+			}
409
+		}
410
+		if ($try_to_exclude_deleted) {
411
+			$expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true);
412
+			if ($expired_even) {
413
+				return $expired_even;
414
+			}
415
+		}
416
+		return $this->get_oldest_datetime_for_event($EVT_ID, true, true);
417
+	}
418
+
419
+
420
+	/**
421
+	 * Gets ALL the datetimes for an event (including trashed ones, for now), ordered
422
+	 * only by start date
423
+	 *
424
+	 * @param int     $EVT_ID
425
+	 * @param boolean $include_expired
426
+	 * @param boolean $include_deleted
427
+	 * @param int     $limit
428
+	 * @return EE_Datetime[]
429
+	 * @throws EE_Error
430
+	 */
431
+	public function get_datetimes_for_event_ordered_by_start_time(
432
+		$EVT_ID,
433
+		$include_expired = true,
434
+		$include_deleted = true,
435
+		$limit = null
436
+	) {
437
+		// sanitize EVT_ID
438
+		$EVT_ID         = absint($EVT_ID);
439
+		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
440
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
441
+		$query_params = array(
442
+			array(
443
+				'Event.EVT_ID' => $EVT_ID
444
+			),
445
+			'order_by' => array(
446
+				'DTT_EVT_start' => 'asc'
447
+			),
448
+			'default_where_conditions' => EEM_Base::default_where_conditions_this_only
449
+		);
450
+		if (! $include_expired) {
451
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
452
+		}
453
+		if ($include_deleted) {
454
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
455
+		}
456
+		if ($limit) {
457
+			$query_params['limit'] = $limit;
458
+		}
459
+		/** @var EE_Datetime[] $result */
460
+		$result = $this->get_all($query_params);
461
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
462
+		return $result;
463
+	}
464
+
465
+
466
+	/**
467
+	 * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered
468
+	 * only by start date
469
+	 *
470
+	 * @param int     $TKT_ID
471
+	 * @param boolean $include_expired
472
+	 * @param boolean $include_deleted
473
+	 * @param int     $limit
474
+	 * @return EE_Datetime[]
475
+	 * @throws EE_Error
476
+	 */
477
+	public function get_datetimes_for_ticket_ordered_by_start_time(
478
+		$TKT_ID,
479
+		$include_expired = true,
480
+		$include_deleted = true,
481
+		$limit = null
482
+	) {
483
+		// sanitize TKT_ID
484
+		$TKT_ID         = absint($TKT_ID);
485
+		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
486
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
487
+		$query_params = array(array('Ticket.TKT_ID' => $TKT_ID), 'order_by' => array('DTT_EVT_start' => 'asc'));
488
+		if (! $include_expired) {
489
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
490
+		}
491
+		if ($include_deleted) {
492
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
493
+		}
494
+		if ($limit) {
495
+			$query_params['limit'] = $limit;
496
+		}
497
+		/** @var EE_Datetime[] $result */
498
+		$result = $this->get_all($query_params);
499
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
500
+		return $result;
501
+	}
502
+
503
+
504
+	/**
505
+	 * Gets all the datetimes for a ticket (including trashed ones, for now), ordered by the DTT_order for the
506
+	 * datetimes.
507
+	 *
508
+	 * @param  int      $TKT_ID          ID of ticket to retrieve the datetimes for
509
+	 * @param  boolean  $include_expired whether to include expired datetimes or not
510
+	 * @param  boolean  $include_deleted whether to include trashed datetimes or not.
511
+	 * @param  int|null $limit           if null, no limit, if int then limit results by
512
+	 *                                   that number
513
+	 * @return EE_Datetime[]
514
+	 * @throws EE_Error
515
+	 */
516
+	public function get_datetimes_for_ticket_ordered_by_DTT_order(
517
+		$TKT_ID,
518
+		$include_expired = true,
519
+		$include_deleted = true,
520
+		$limit = null
521
+	) {
522
+		// sanitize id.
523
+		$TKT_ID         = absint($TKT_ID);
524
+		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
525
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
526
+		$where_params = array('Ticket.TKT_ID' => $TKT_ID);
527
+		$query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC'));
528
+		if (! $include_expired) {
529
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', true));
530
+		}
531
+		if ($include_deleted) {
532
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
533
+		}
534
+		if ($limit) {
535
+			$query_params['limit'] = $limit;
536
+		}
537
+		/** @var EE_Datetime[] $result */
538
+		$result = $this->get_all($query_params);
539
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
540
+		return $result;
541
+	}
542
+
543
+
544
+	/**
545
+	 * Gets the most important datetime for a particular event (ie, the primary event usually. But if for some WACK
546
+	 * reason it doesn't exist, we consider the earliest event the most important)
547
+	 *
548
+	 * @param int $EVT_ID
549
+	 * @return EE_Datetime
550
+	 * @throws EE_Error
551
+	 */
552
+	public function get_most_important_datetime_for_event($EVT_ID)
553
+	{
554
+		$results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1);
555
+		if ($results) {
556
+			return array_shift($results);
557
+		}
558
+		return null;
559
+	}
560
+
561
+
562
+	/**
563
+	 * This returns a wpdb->results        Array of all DTT month and years matching the incoming query params and
564
+	 * grouped by month and year.
565
+	 *
566
+	 * @param  array  $where_params      @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions
567
+	 * @param  string $evt_active_status A string representing the evt active status to filter the months by.
568
+	 *                                   Can be:
569
+	 *                                   - '' = no filter
570
+	 *                                   - upcoming = Published events with at least one upcoming datetime.
571
+	 *                                   - expired = Events with all datetimes expired.
572
+	 *                                   - active = Events that are published and have at least one datetime that
573
+	 *                                   starts before now and ends after now.
574
+	 *                                   - inactive = Events that are either not published.
575
+	 * @return stdClass[]
576
+	 * @throws EE_Error
577
+	 * @throws InvalidArgumentException
578
+	 * @throws InvalidArgumentException
579
+	 */
580
+	public function get_dtt_months_and_years($where_params, $evt_active_status = '')
581
+	{
582
+		$current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start');
583
+		$current_time_for_DTT_EVT_end   = $this->current_time_for_query('DTT_EVT_end');
584
+		switch ($evt_active_status) {
585
+			case 'upcoming':
586
+				$where_params['Event.status'] = 'publish';
587
+				// if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
588
+				if (isset($where_params['DTT_EVT_start'])) {
589
+					$where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start'];
590
+				}
591
+				$where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start);
592
+				break;
593
+			case 'expired':
594
+				if (isset($where_params['Event.status'])) {
595
+					unset($where_params['Event.status']);
596
+				}
597
+				// get events to exclude
598
+				$exclude_query[0] = array_merge(
599
+					$where_params,
600
+					array('DTT_EVT_end' => array('>', $current_time_for_DTT_EVT_end))
601
+				);
602
+				// first get all events that have datetimes where its not expired.
603
+				$event_ids = $this->_get_all_wpdb_results(
604
+					$exclude_query,
605
+					OBJECT_K,
606
+					'Datetime.EVT_ID'
607
+				);
608
+				$event_ids = array_keys($event_ids);
609
+				if (isset($where_params['DTT_EVT_end'])) {
610
+					$where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end'];
611
+				}
612
+				$where_params['DTT_EVT_end']  = array('<', $current_time_for_DTT_EVT_end);
613
+				$where_params['Event.EVT_ID'] = array('NOT IN', $event_ids);
614
+				break;
615
+			case 'active':
616
+				$where_params['Event.status'] = 'publish';
617
+				if (isset($where_params['DTT_EVT_start'])) {
618
+					$where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start'];
619
+				}
620
+				if (isset($where_params['Datetime.DTT_EVT_end'])) {
621
+					$where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end'];
622
+				}
623
+				$where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start);
624
+				$where_params['DTT_EVT_end']   = array('>', $current_time_for_DTT_EVT_end);
625
+				break;
626
+			case 'inactive':
627
+				if (isset($where_params['Event.status'])) {
628
+					unset($where_params['Event.status']);
629
+				}
630
+				if (isset($where_params['OR'])) {
631
+					$where_params['AND']['OR'] = $where_params['OR'];
632
+				}
633
+				if (isset($where_params['DTT_EVT_end'])) {
634
+					$where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end'];
635
+					unset($where_params['DTT_EVT_end']);
636
+				}
637
+				if (isset($where_params['DTT_EVT_start'])) {
638
+					$where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start'];
639
+					unset($where_params['DTT_EVT_start']);
640
+				}
641
+				$where_params['AND']['Event.status'] = array('!=', 'publish');
642
+				break;
643
+		}
644
+		$query_params[0]          = $where_params;
645
+		$query_params['group_by'] = array('dtt_year', 'dtt_month');
646
+		$query_params['order_by'] = array('DTT_EVT_start' => 'DESC');
647
+		$query_interval           = EEH_DTT_Helper::get_sql_query_interval_for_offset(
648
+			$this->get_timezone(),
649
+			'DTT_EVT_start'
650
+		);
651
+		$columns_to_select        = array(
652
+			'dtt_year'      => array('YEAR(' . $query_interval . ')', '%s'),
653
+			'dtt_month'     => array('MONTHNAME(' . $query_interval . ')', '%s'),
654
+			'dtt_month_num' => array('MONTH(' . $query_interval . ')', '%s'),
655
+		);
656
+		return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
657
+	}
658
+
659
+
660
+	/**
661
+	 * Updates the DTT_sold attribute on each datetime (based on the registrations
662
+	 * for the tickets for each datetime)
663
+	 *
664
+	 * @param EE_Base_Class[]|EE_Datetime[] $datetimes
665
+	 * @throws EE_Error
666
+	 */
667
+	public function update_sold($datetimes)
668
+	{
669
+		EE_Error::doing_it_wrong(
670
+			__FUNCTION__,
671
+			esc_html__(
672
+				'Please use \EEM_Ticket::update_tickets_sold() instead which will in turn correctly update both the Ticket AND Datetime counts.',
673
+				'event_espresso'
674
+			),
675
+			'4.9.32.rc.005'
676
+		);
677
+		foreach ($datetimes as $datetime) {
678
+			$datetime->update_sold();
679
+		}
680
+	}
681
+
682
+
683
+	/**
684
+	 *    Gets the total number of tickets available at a particular datetime
685
+	 *    (does NOT take into account the datetime's spaces available)
686
+	 *
687
+	 * @param int   $DTT_ID
688
+	 * @param array $query_params
689
+	 * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF,  IF there are NO
690
+	 *             tickets attached to datetime then FALSE is returned.
691
+	 */
692
+	public function sum_tickets_currently_available_at_datetime($DTT_ID, array $query_params = array())
693
+	{
694
+		$datetime = $this->get_one_by_ID($DTT_ID);
695
+		if ($datetime instanceof EE_Datetime) {
696
+			return $datetime->tickets_remaining($query_params);
697
+		}
698
+		return 0;
699
+	}
700
+
701
+
702
+	/**
703
+	 * This returns an array of counts of datetimes in the database for each Datetime status that can be queried.
704
+	 *
705
+	 * @param  array $stati_to_include If included you can restrict the statuses we return counts for by including the
706
+	 *                                 stati you want counts for as values in the array.  An empty array returns counts
707
+	 *                                 for all valid stati.
708
+	 * @param  array $query_params     If included can be used to refine the conditions for returning the count (i.e.
709
+	 *                                 only for Datetimes connected to a specific event, or specific ticket.
710
+	 * @return array  The value returned is an array indexed by Datetime Status and the values are the counts.  The
711
+	 * @throws EE_Error
712
+	 *                                 stati used as index keys are: EE_Datetime::active EE_Datetime::upcoming
713
+	 *                                 EE_Datetime::expired
714
+	 */
715
+	public function get_datetime_counts_by_status(array $stati_to_include = array(), array $query_params = array())
716
+	{
717
+		// only accept where conditions for this query.
718
+		$_where            = isset($query_params[0]) ? $query_params[0] : array();
719
+		$status_query_args = array(
720
+			EE_Datetime::active   => array_merge(
721
+				$_where,
722
+				array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time()))
723
+			),
724
+			EE_Datetime::upcoming => array_merge(
725
+				$_where,
726
+				array('DTT_EVT_start' => array('>', time()))
727
+			),
728
+			EE_Datetime::expired  => array_merge(
729
+				$_where,
730
+				array('DTT_EVT_end' => array('<', time()))
731
+			),
732
+		);
733
+		if (! empty($stati_to_include)) {
734
+			foreach (array_keys($status_query_args) as $status) {
735
+				if (! in_array($status, $stati_to_include, true)) {
736
+					unset($status_query_args[ $status ]);
737
+				}
738
+			}
739
+		}
740
+		// loop through and query counts for each stati.
741
+		$status_query_results = array();
742
+		foreach ($status_query_args as $status => $status_where_conditions) {
743
+			$status_query_results[ $status ] = EEM_Datetime::count(
744
+				array($status_where_conditions),
745
+				'DTT_ID',
746
+				true
747
+			);
748
+		}
749
+		return $status_query_results;
750
+	}
751
+
752
+
753
+	/**
754
+	 * Returns the specific count for a given Datetime status matching any given query_params.
755
+	 *
756
+	 * @param string $status Valid string representation for Datetime status requested. (Defaults to Active).
757
+	 * @param array  $query_params
758
+	 * @return int
759
+	 * @throws EE_Error
760
+	 */
761
+	public function get_datetime_count_for_status($status = EE_Datetime::active, array $query_params = array())
762
+	{
763
+		$count = $this->get_datetime_counts_by_status(array($status), $query_params);
764
+		return ! empty($count[ $status ]) ? $count[ $status ] : 0;
765
+	}
766 766
 }
Please login to merge, or discard this patch.
admin_pages/transactions/Transactions_Admin_Page_Init.core.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,15 +22,15 @@
 block discarded – undo
22 22
     {
23 23
 
24 24
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
25
-        if (! defined('TXN_PG_SLUG')) {
25
+        if ( ! defined('TXN_PG_SLUG')) {
26 26
             define('TXN_PG_SLUG', 'espresso_transactions');
27 27
             define('TXN_PG_NAME', ucwords(str_replace('_', '', TXN_PG_SLUG)));
28
-            define('TXN_ADMIN', EE_ADMIN_PAGES . 'transactions/');
29
-            define('TXN_ADMIN_URL', admin_url('admin.php?page=' . TXN_PG_SLUG));
30
-            define('TXN_ASSETS_PATH', TXN_ADMIN . 'assets/');
31
-            define('TXN_ASSETS_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/assets/'));
32
-            define('TXN_TEMPLATE_PATH', TXN_ADMIN . 'templates/');
33
-            define('TXN_TEMPLATE_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/templates/'));
28
+            define('TXN_ADMIN', EE_ADMIN_PAGES.'transactions/');
29
+            define('TXN_ADMIN_URL', admin_url('admin.php?page='.TXN_PG_SLUG));
30
+            define('TXN_ASSETS_PATH', TXN_ADMIN.'assets/');
31
+            define('TXN_ASSETS_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL.'transactions/assets/'));
32
+            define('TXN_TEMPLATE_PATH', TXN_ADMIN.'templates/');
33
+            define('TXN_TEMPLATE_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL.'transactions/templates/'));
34 34
         }
35 35
         parent::__construct();
36 36
     }
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -11,58 +11,58 @@
 block discarded – undo
11 11
  */
12 12
 class Transactions_Admin_Page_Init extends EE_Admin_Page_Init
13 13
 {
14
-    /**
15
-     * @Constructor
16
-     * @access public
17
-     * @return Transactions_Admin_Page_Init
18
-     */
19
-    public function __construct()
20
-    {
14
+	/**
15
+	 * @Constructor
16
+	 * @access public
17
+	 * @return Transactions_Admin_Page_Init
18
+	 */
19
+	public function __construct()
20
+	{
21 21
 
22
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
23
-        if (! defined('TXN_PG_SLUG')) {
24
-            define('TXN_PG_SLUG', 'espresso_transactions');
25
-            define('TXN_PG_NAME', ucwords(str_replace('_', '', TXN_PG_SLUG)));
26
-            define('TXN_ADMIN', EE_ADMIN_PAGES . 'transactions/');
27
-            define('TXN_ADMIN_URL', admin_url('admin.php?page=' . TXN_PG_SLUG));
28
-            define('TXN_ASSETS_PATH', TXN_ADMIN . 'assets/');
29
-            define('TXN_ASSETS_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/assets/'));
30
-            define('TXN_TEMPLATE_PATH', TXN_ADMIN . 'templates/');
31
-            define('TXN_TEMPLATE_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/templates/'));
32
-        }
33
-        parent::__construct();
34
-    }
22
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
23
+		if (! defined('TXN_PG_SLUG')) {
24
+			define('TXN_PG_SLUG', 'espresso_transactions');
25
+			define('TXN_PG_NAME', ucwords(str_replace('_', '', TXN_PG_SLUG)));
26
+			define('TXN_ADMIN', EE_ADMIN_PAGES . 'transactions/');
27
+			define('TXN_ADMIN_URL', admin_url('admin.php?page=' . TXN_PG_SLUG));
28
+			define('TXN_ASSETS_PATH', TXN_ADMIN . 'assets/');
29
+			define('TXN_ASSETS_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/assets/'));
30
+			define('TXN_TEMPLATE_PATH', TXN_ADMIN . 'templates/');
31
+			define('TXN_TEMPLATE_URL', str_replace('\\', '/', EE_ADMIN_PAGES_URL . 'transactions/templates/'));
32
+		}
33
+		parent::__construct();
34
+	}
35 35
 
36 36
 
37
-    /**
38
-     *    _set_init_properties
39
-     *
40
-     * @return void
41
-     */
42
-    protected function _set_init_properties()
43
-    {
44
-        $this->label = esc_html__('Transactions Overview', 'event_espresso');
45
-    }
37
+	/**
38
+	 *    _set_init_properties
39
+	 *
40
+	 * @return void
41
+	 */
42
+	protected function _set_init_properties()
43
+	{
44
+		$this->label = esc_html__('Transactions Overview', 'event_espresso');
45
+	}
46 46
 
47 47
 
48
-    /**
49
-     *    _set_menu_map
50
-     *
51
-     * @return void
52
-     */
53
-    protected function _set_menu_map()
54
-    {
55
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
56
-            array(
57
-                'menu_group'      => 'main',
58
-                'menu_order'      => 50,
59
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
60
-                'parent_slug'     => 'espresso_events',
61
-                'menu_slug'       => TXN_PG_SLUG,
62
-                'menu_label'      => esc_html__('Transactions', 'event_espresso'),
63
-                'capability'      => 'ee_read_transactions',
64
-                'admin_init_page' => $this,
65
-            )
66
-        );
67
-    }
48
+	/**
49
+	 *    _set_menu_map
50
+	 *
51
+	 * @return void
52
+	 */
53
+	protected function _set_menu_map()
54
+	{
55
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
56
+			array(
57
+				'menu_group'      => 'main',
58
+				'menu_order'      => 50,
59
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
60
+				'parent_slug'     => 'espresso_events',
61
+				'menu_slug'       => TXN_PG_SLUG,
62
+				'menu_label'      => esc_html__('Transactions', 'event_espresso'),
63
+				'capability'      => 'ee_read_transactions',
64
+				'admin_init_page' => $this,
65
+			)
66
+		);
67
+	}
68 68
 }
Please login to merge, or discard this patch.
admin_pages/venues/Venues_Admin_Page_Init.core.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@
 block discarded – undo
21 21
     {
22 22
         // define some event categories related constants
23 23
         define('EE_VENUES_PG_SLUG', 'espresso_venues');
24
-        define('EE_VENUES_ADMIN_URL', admin_url('admin.php?page=' . EE_VENUES_PG_SLUG));
25
-        define('EE_VENUES_ASSETS_URL', EE_ADMIN_PAGES_URL . 'venues/assets/');
26
-        define('EE_VENUES_TEMPLATE_PATH', EE_ADMIN_PAGES . 'venues/templates/');
24
+        define('EE_VENUES_ADMIN_URL', admin_url('admin.php?page='.EE_VENUES_PG_SLUG));
25
+        define('EE_VENUES_ASSETS_URL', EE_ADMIN_PAGES_URL.'venues/assets/');
26
+        define('EE_VENUES_TEMPLATE_PATH', EE_ADMIN_PAGES.'venues/templates/');
27 27
 
28 28
         parent::__construct();
29
-        $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
29
+        $this->_folder_path = EE_ADMIN_PAGES.$this->_folder_name.'/';
30 30
     }
31 31
 
32 32
     protected function _set_init_properties()
Please login to merge, or discard this patch.
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -15,39 +15,39 @@
 block discarded – undo
15 15
  */
16 16
 class Venues_Admin_Page_Init extends EE_Admin_Page_CPT_Init
17 17
 {
18
-    public function __construct()
19
-    {
20
-        // define some event categories related constants
21
-        define('EE_VENUES_PG_SLUG', 'espresso_venues');
22
-        define('EE_VENUES_ADMIN_URL', admin_url('admin.php?page=' . EE_VENUES_PG_SLUG));
23
-        define('EE_VENUES_ASSETS_URL', EE_ADMIN_PAGES_URL . 'venues/assets/');
24
-        define('EE_VENUES_TEMPLATE_PATH', EE_ADMIN_PAGES . 'venues/templates/');
18
+	public function __construct()
19
+	{
20
+		// define some event categories related constants
21
+		define('EE_VENUES_PG_SLUG', 'espresso_venues');
22
+		define('EE_VENUES_ADMIN_URL', admin_url('admin.php?page=' . EE_VENUES_PG_SLUG));
23
+		define('EE_VENUES_ASSETS_URL', EE_ADMIN_PAGES_URL . 'venues/assets/');
24
+		define('EE_VENUES_TEMPLATE_PATH', EE_ADMIN_PAGES . 'venues/templates/');
25 25
 
26
-        parent::__construct();
27
-        $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
28
-    }
26
+		parent::__construct();
27
+		$this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
28
+	}
29 29
 
30
-    protected function _set_init_properties()
31
-    {
32
-        $this->label = esc_html__('Event Venues', 'event_espresso');
33
-        $this->menu_label = esc_html__('Venues', 'event_espresso');
34
-        $this->menu_slug = EE_VENUES_PG_SLUG;
35
-    }
30
+	protected function _set_init_properties()
31
+	{
32
+		$this->label = esc_html__('Event Venues', 'event_espresso');
33
+		$this->menu_label = esc_html__('Venues', 'event_espresso');
34
+		$this->menu_slug = EE_VENUES_PG_SLUG;
35
+	}
36 36
 
37 37
 
38
-    protected function _set_menu_map()
39
-    {
40
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
41
-            array(
42
-                'menu_group'      => 'management',
43
-                'menu_order'      => 40,
44
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
45
-                'parent_slug'     => 'espresso_events',
46
-                'menu_slug'       => EE_VENUES_PG_SLUG,
47
-                'menu_label'      => esc_html__('Venues', 'event_espresso'),
48
-                'capability'      => 'ee_read_venues',
49
-                'admin_init_page' => $this,
50
-            )
51
-        );
52
-    }
38
+	protected function _set_menu_map()
39
+	{
40
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
41
+			array(
42
+				'menu_group'      => 'management',
43
+				'menu_order'      => 40,
44
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
45
+				'parent_slug'     => 'espresso_events',
46
+				'menu_slug'       => EE_VENUES_PG_SLUG,
47
+				'menu_label'      => esc_html__('Venues', 'event_espresso'),
48
+				'capability'      => 'ee_read_venues',
49
+				'admin_init_page' => $this,
50
+			)
51
+		);
52
+	}
53 53
 }
Please login to merge, or discard this patch.
admin_pages/messages/Messages_Admin_Page_Init.core.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,15 +24,15 @@
 block discarded – undo
24 24
 
25 25
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
26 26
 
27
-        if (! defined('EE_MSG_PG_SLUG')) {
27
+        if ( ! defined('EE_MSG_PG_SLUG')) {
28 28
             define('EE_MSG_PG_SLUG', 'espresso_messages');
29 29
             define('EE_MSG_PG_NAME', ucwords(str_replace('_', '', EE_MSG_PG_SLUG)));
30
-            define('EE_MSG_ADMIN', EE_ADMIN_PAGES . 'messages/');
31
-            define('EE_MSG_ADMIN_URL', admin_url('admin.php?page=' . EE_MSG_PG_SLUG));
32
-            define('EE_MSG_ASSETS_PATH', EE_MSG_ADMIN . 'assets/');
33
-            define('EE_MSG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'messages/assets/');
34
-            define('EE_MSG_TEMPLATE_PATH', EE_MSG_ADMIN . 'templates/');
35
-            define('EE_MSG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'messages/templates/');
30
+            define('EE_MSG_ADMIN', EE_ADMIN_PAGES.'messages/');
31
+            define('EE_MSG_ADMIN_URL', admin_url('admin.php?page='.EE_MSG_PG_SLUG));
32
+            define('EE_MSG_ASSETS_PATH', EE_MSG_ADMIN.'assets/');
33
+            define('EE_MSG_ASSETS_URL', EE_ADMIN_PAGES_URL.'messages/assets/');
34
+            define('EE_MSG_TEMPLATE_PATH', EE_MSG_ADMIN.'templates/');
35
+            define('EE_MSG_TEMPLATE_URL', EE_ADMIN_PAGES_URL.'messages/templates/');
36 36
         }
37 37
 
38 38
         parent::__construct();
Please login to merge, or discard this patch.
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -13,52 +13,52 @@
 block discarded – undo
13 13
  */
14 14
 class Messages_Admin_Page_Init extends EE_Admin_Page_Init
15 15
 {
16
-    /**
17
-     *constructor
18
-     *
19
-     * @Constructor
20
-     * @access public
21
-     * @return void
22
-     */
23
-    public function __construct()
24
-    {
16
+	/**
17
+	 *constructor
18
+	 *
19
+	 * @Constructor
20
+	 * @access public
21
+	 * @return void
22
+	 */
23
+	public function __construct()
24
+	{
25 25
 
26
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
26
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
27 27
 
28
-        if (! defined('EE_MSG_PG_SLUG')) {
29
-            define('EE_MSG_PG_SLUG', 'espresso_messages');
30
-            define('EE_MSG_PG_NAME', ucwords(str_replace('_', '', EE_MSG_PG_SLUG)));
31
-            define('EE_MSG_ADMIN', EE_ADMIN_PAGES . 'messages/');
32
-            define('EE_MSG_ADMIN_URL', admin_url('admin.php?page=' . EE_MSG_PG_SLUG));
33
-            define('EE_MSG_ASSETS_PATH', EE_MSG_ADMIN . 'assets/');
34
-            define('EE_MSG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'messages/assets/');
35
-            define('EE_MSG_TEMPLATE_PATH', EE_MSG_ADMIN . 'templates/');
36
-            define('EE_MSG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'messages/templates/');
37
-        }
28
+		if (! defined('EE_MSG_PG_SLUG')) {
29
+			define('EE_MSG_PG_SLUG', 'espresso_messages');
30
+			define('EE_MSG_PG_NAME', ucwords(str_replace('_', '', EE_MSG_PG_SLUG)));
31
+			define('EE_MSG_ADMIN', EE_ADMIN_PAGES . 'messages/');
32
+			define('EE_MSG_ADMIN_URL', admin_url('admin.php?page=' . EE_MSG_PG_SLUG));
33
+			define('EE_MSG_ASSETS_PATH', EE_MSG_ADMIN . 'assets/');
34
+			define('EE_MSG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'messages/assets/');
35
+			define('EE_MSG_TEMPLATE_PATH', EE_MSG_ADMIN . 'templates/');
36
+			define('EE_MSG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'messages/templates/');
37
+		}
38 38
 
39
-        parent::__construct();
40
-    }
39
+		parent::__construct();
40
+	}
41 41
 
42 42
 
43
-    protected function _set_init_properties()
44
-    {
45
-        $this->label = esc_html__('Messages System', 'event_espresso');
46
-    }
43
+	protected function _set_init_properties()
44
+	{
45
+		$this->label = esc_html__('Messages System', 'event_espresso');
46
+	}
47 47
 
48 48
 
49
-    protected function _set_menu_map()
50
-    {
51
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
52
-            array(
53
-                'menu_group'      => 'management',
54
-                'menu_order'      => 10,
55
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
56
-                'parent_slug'     => 'espresso_events',
57
-                'menu_slug'       => EE_MSG_PG_SLUG,
58
-                'menu_label'      => esc_html__('Messages', 'event_espresso'),
59
-                'capability'      => 'ee_read_global_messages',
60
-                'admin_init_page' => $this,
61
-            )
62
-        );
63
-    }
49
+	protected function _set_menu_map()
50
+	{
51
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
52
+			array(
53
+				'menu_group'      => 'management',
54
+				'menu_order'      => 10,
55
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
56
+				'parent_slug'     => 'espresso_events',
57
+				'menu_slug'       => EE_MSG_PG_SLUG,
58
+				'menu_label'      => esc_html__('Messages', 'event_espresso'),
59
+				'capability'      => 'ee_read_global_messages',
60
+				'admin_init_page' => $this,
61
+			)
62
+		);
63
+	}
64 64
 }
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page_Init.core.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -23,15 +23,15 @@
 block discarded – undo
23 23
     public function __construct()
24 24
     {
25 25
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
26
-        if (! defined('REG_PG_SLUG')) {
26
+        if ( ! defined('REG_PG_SLUG')) {
27 27
             define('REG_PG_SLUG', 'espresso_registrations');
28 28
             define('REG_PG_NAME', ucwords(str_replace('_', '', REG_PG_SLUG)));
29
-            define('REG_ADMIN', EE_ADMIN_PAGES . 'registrations/');
30
-            define('REG_ADMIN_URL', admin_url('admin.php?page=' . REG_PG_SLUG));
31
-            define('REG_ASSETS_PATH', REG_ADMIN . 'assets/');
32
-            define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registrations/assets/');
33
-            define('REG_TEMPLATE_PATH', REG_ADMIN . 'templates/');
34
-            define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registrations/templates/');
29
+            define('REG_ADMIN', EE_ADMIN_PAGES.'registrations/');
30
+            define('REG_ADMIN_URL', admin_url('admin.php?page='.REG_PG_SLUG));
31
+            define('REG_ASSETS_PATH', REG_ADMIN.'assets/');
32
+            define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL.'registrations/assets/');
33
+            define('REG_TEMPLATE_PATH', REG_ADMIN.'templates/');
34
+            define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL.'registrations/templates/');
35 35
         }
36 36
 
37 37
         parent::__construct();
Please login to merge, or discard this patch.
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -11,50 +11,50 @@
 block discarded – undo
11 11
  */
12 12
 class Registrations_Admin_Page_Init extends EE_Admin_Page_CPT_Init
13 13
 {
14
-    /**
15
-     *        constructor
16
-     *
17
-     * @Constructor
18
-     * @access public
19
-     * @return void
20
-     */
21
-    public function __construct()
22
-    {
23
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
24
-        if (! defined('REG_PG_SLUG')) {
25
-            define('REG_PG_SLUG', 'espresso_registrations');
26
-            define('REG_PG_NAME', ucwords(str_replace('_', '', REG_PG_SLUG)));
27
-            define('REG_ADMIN', EE_ADMIN_PAGES . 'registrations/');
28
-            define('REG_ADMIN_URL', admin_url('admin.php?page=' . REG_PG_SLUG));
29
-            define('REG_ASSETS_PATH', REG_ADMIN . 'assets/');
30
-            define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registrations/assets/');
31
-            define('REG_TEMPLATE_PATH', REG_ADMIN . 'templates/');
32
-            define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registrations/templates/');
33
-        }
14
+	/**
15
+	 *        constructor
16
+	 *
17
+	 * @Constructor
18
+	 * @access public
19
+	 * @return void
20
+	 */
21
+	public function __construct()
22
+	{
23
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
24
+		if (! defined('REG_PG_SLUG')) {
25
+			define('REG_PG_SLUG', 'espresso_registrations');
26
+			define('REG_PG_NAME', ucwords(str_replace('_', '', REG_PG_SLUG)));
27
+			define('REG_ADMIN', EE_ADMIN_PAGES . 'registrations/');
28
+			define('REG_ADMIN_URL', admin_url('admin.php?page=' . REG_PG_SLUG));
29
+			define('REG_ASSETS_PATH', REG_ADMIN . 'assets/');
30
+			define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registrations/assets/');
31
+			define('REG_TEMPLATE_PATH', REG_ADMIN . 'templates/');
32
+			define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registrations/templates/');
33
+		}
34 34
 
35
-        parent::__construct();
36
-    }
35
+		parent::__construct();
36
+	}
37 37
 
38 38
 
39
-    protected function _set_init_properties()
40
-    {
41
-        $this->label = esc_html__('Registrations Overview', 'event_espresso');
42
-    }
39
+	protected function _set_init_properties()
40
+	{
41
+		$this->label = esc_html__('Registrations Overview', 'event_espresso');
42
+	}
43 43
 
44 44
 
45
-    protected function _set_menu_map()
46
-    {
47
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
48
-            array(
49
-                'menu_group'      => 'main',
50
-                'menu_order'      => 40,
51
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
52
-                'parent_slug'     => 'espresso_events',
53
-                'menu_slug'       => REG_PG_SLUG,
54
-                'menu_label'      => esc_html__('Registrations', 'event_espresso'),
55
-                'capability'      => 'ee_read_registrations',
56
-                'admin_init_page' => $this,
57
-            )
58
-        );
59
-    }
45
+	protected function _set_menu_map()
46
+	{
47
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
48
+			array(
49
+				'menu_group'      => 'main',
50
+				'menu_order'      => 40,
51
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
52
+				'parent_slug'     => 'espresso_events',
53
+				'menu_slug'       => REG_PG_SLUG,
54
+				'menu_label'      => esc_html__('Registrations', 'event_espresso'),
55
+				'capability'      => 'ee_read_registrations',
56
+				'admin_init_page' => $this,
57
+			)
58
+		);
59
+	}
60 60
 }
Please login to merge, or discard this patch.
payment_methods/Paypal_Express/EE_PMT_Paypal_Express.pm.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,18 +20,18 @@
 block discarded – undo
20 20
      */
21 21
     public function __construct($pm_instance = null)
22 22
     {
23
-        require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php');
23
+        require_once($this->file_folder().'EEG_Paypal_Express.gateway.php');
24 24
         $this->_gateway = new EEG_Paypal_Express();
25 25
 
26 26
         $this->_pretty_name = esc_html__('PayPal Express', 'event_espresso');
27
-        $this->_template_path = $this->file_folder() . 'templates/';
27
+        $this->_template_path = $this->file_folder().'templates/';
28 28
         $this->_default_description = esc_html__(
29 29
             // @codingStandardsIgnoreStart
30 30
             'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.',
31 31
             // @codingStandardsIgnoreEnd
32 32
             'event_espresso'
33 33
         );
34
-        $this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png';
34
+        $this->_default_button_url = $this->file_url().'lib/paypal-express-checkout-logo-gold-160.png';
35 35
 
36 36
         parent::__construct($pm_instance);
37 37
     }
Please login to merge, or discard this patch.
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -14,89 +14,89 @@
 block discarded – undo
14 14
  */
15 15
 class EE_PMT_Paypal_Express extends EE_PMT_Base
16 16
 {
17
-    /**
18
-     * EE_PMT_Paypal_Express constructor.
19
-     */
20
-    public function __construct($pm_instance = null)
21
-    {
22
-        require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php');
23
-        $this->_gateway = new EEG_Paypal_Express();
17
+	/**
18
+	 * EE_PMT_Paypal_Express constructor.
19
+	 */
20
+	public function __construct($pm_instance = null)
21
+	{
22
+		require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php');
23
+		$this->_gateway = new EEG_Paypal_Express();
24 24
 
25
-        $this->_pretty_name = esc_html__('PayPal Express', 'event_espresso');
26
-        $this->_template_path = $this->file_folder() . 'templates/';
27
-        $this->_default_description = esc_html__(
28
-            // @codingStandardsIgnoreStart
29
-            'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.',
30
-            // @codingStandardsIgnoreEnd
31
-            'event_espresso'
32
-        );
33
-        $this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png';
25
+		$this->_pretty_name = esc_html__('PayPal Express', 'event_espresso');
26
+		$this->_template_path = $this->file_folder() . 'templates/';
27
+		$this->_default_description = esc_html__(
28
+			// @codingStandardsIgnoreStart
29
+			'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.',
30
+			// @codingStandardsIgnoreEnd
31
+			'event_espresso'
32
+		);
33
+		$this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png';
34 34
 
35
-        parent::__construct($pm_instance);
36
-    }
35
+		parent::__construct($pm_instance);
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * Adds the help tab.
41
-     *
42
-     * @see EE_PMT_Base::help_tabs_config()
43
-     * @return array
44
-     */
45
-    public function help_tabs_config()
46
-    {
47
-        return array(
48
-            $this->get_help_tab_name() => array(
49
-                'title'    => esc_html__('PayPal Express Settings', 'event_espresso'),
50
-                'filename' => 'payment_methods_overview_paypal_express'
51
-            )
52
-        );
53
-    }
39
+	/**
40
+	 * Adds the help tab.
41
+	 *
42
+	 * @see EE_PMT_Base::help_tabs_config()
43
+	 * @return array
44
+	 */
45
+	public function help_tabs_config()
46
+	{
47
+		return array(
48
+			$this->get_help_tab_name() => array(
49
+				'title'    => esc_html__('PayPal Express Settings', 'event_espresso'),
50
+				'filename' => 'payment_methods_overview_paypal_express'
51
+			)
52
+		);
53
+	}
54 54
 
55 55
 
56
-    /**
57
-     * Gets the form for all the settings related to this payment method type.
58
-     *
59
-     * @return EE_Payment_Method_Form
60
-     */
61
-    public function generate_new_settings_form()
62
-    {
63
-        return new SettingsForm(array(), $this->get_help_tab_link());
64
-    }
56
+	/**
57
+	 * Gets the form for all the settings related to this payment method type.
58
+	 *
59
+	 * @return EE_Payment_Method_Form
60
+	 */
61
+	public function generate_new_settings_form()
62
+	{
63
+		return new SettingsForm(array(), $this->get_help_tab_link());
64
+	}
65 65
 
66 66
 
67
-    /**
68
-     * Creates a billing form for this payment method type.
69
-     *
70
-     * @param \EE_Transaction $transaction
71
-     * @return \EE_Billing_Info_Form
72
-     */
73
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
74
-    {
75
-        if ($this->_pm_instance->debug_mode()) {
76
-            $form = new EE_Billing_Info_Form(
77
-                $this->_pm_instance,
78
-                array(
79
-                    'name' => 'paypal_express_Info_Form',
80
-                    'subsections' => array(
81
-                        'paypal_express_debug_info' => new EE_Form_Section_Proper(
82
-                            array(
83
-                                'layout_strategy' => new EE_Template_Layout(
84
-                                    array(
85
-                                        'layout_template_file' => $this->_template_path
86
-                                                                    . 'paypal_express_debug_info.template.php',
87
-                                        'template_args'        => array(
88
-                                            'debug_mode' => $this->_pm_instance->debug_mode()
89
-                                        )
90
-                                    )
91
-                                )
92
-                            )
93
-                        )
94
-                    )
95
-                )
96
-            );
97
-            return $form;
98
-        }
67
+	/**
68
+	 * Creates a billing form for this payment method type.
69
+	 *
70
+	 * @param \EE_Transaction $transaction
71
+	 * @return \EE_Billing_Info_Form
72
+	 */
73
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
74
+	{
75
+		if ($this->_pm_instance->debug_mode()) {
76
+			$form = new EE_Billing_Info_Form(
77
+				$this->_pm_instance,
78
+				array(
79
+					'name' => 'paypal_express_Info_Form',
80
+					'subsections' => array(
81
+						'paypal_express_debug_info' => new EE_Form_Section_Proper(
82
+							array(
83
+								'layout_strategy' => new EE_Template_Layout(
84
+									array(
85
+										'layout_template_file' => $this->_template_path
86
+																	. 'paypal_express_debug_info.template.php',
87
+										'template_args'        => array(
88
+											'debug_mode' => $this->_pm_instance->debug_mode()
89
+										)
90
+									)
91
+								)
92
+							)
93
+						)
94
+					)
95
+				)
96
+			);
97
+			return $form;
98
+		}
99 99
 
100
-        return false;
101
-    }
100
+		return false;
101
+	}
102 102
 }
Please login to merge, or discard this patch.
core/services/bootstrap/BootstrapRequestResponseObjects.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
     {
91 91
         espresso_load_required(
92 92
             'EE_Request',
93
-            EE_CORE . 'request_stack/EE_Request.core.php'
93
+            EE_CORE.'request_stack/EE_Request.core.php'
94 94
         );
95 95
         $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
96 96
         $this->legacy_request->setRequest($this->request);
Please login to merge, or discard this patch.
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -28,84 +28,84 @@
 block discarded – undo
28 28
  */
29 29
 class BootstrapRequestResponseObjects
30 30
 {
31
-    /**
32
-     * @type LegacyRequestInterface $legacy_request
33
-     */
34
-    protected $legacy_request;
31
+	/**
32
+	 * @type LegacyRequestInterface $legacy_request
33
+	 */
34
+	protected $legacy_request;
35 35
 
36
-    /**
37
-     * @type LoaderInterface $loader
38
-     */
39
-    protected $loader;
36
+	/**
37
+	 * @type LoaderInterface $loader
38
+	 */
39
+	protected $loader;
40 40
 
41
-    /**
42
-     * @var RequestInterface $request
43
-     */
44
-    protected $request;
41
+	/**
42
+	 * @var RequestInterface $request
43
+	 */
44
+	protected $request;
45 45
 
46
-    /**
47
-     * @var ResponseInterface $response
48
-     */
49
-    protected $response;
46
+	/**
47
+	 * @var ResponseInterface $response
48
+	 */
49
+	protected $response;
50 50
 
51 51
 
52
-    /**
53
-     * BootstrapRequestResponseObjects constructor.
54
-     *
55
-     * @param LoaderInterface $loader
56
-     */
57
-    public function __construct(LoaderInterface $loader)
58
-    {
59
-        $this->loader = $loader;
60
-    }
52
+	/**
53
+	 * BootstrapRequestResponseObjects constructor.
54
+	 *
55
+	 * @param LoaderInterface $loader
56
+	 */
57
+	public function __construct(LoaderInterface $loader)
58
+	{
59
+		$this->loader = $loader;
60
+	}
61 61
 
62 62
 
63
-    /**
64
-     * @return void
65
-     */
66
-    public function buildRequestResponse()
67
-    {
68
-        $request_params = new RequestParams(new RequestSanitizer());
69
-        $server_params = new ServerParams(new ServerSanitizer());
70
-        // load our Request and Response objects
71
-        $this->request = new Request($request_params, $server_params);
72
-        $this->response = new Response();
73
-        $this->loader->share(RequestParams::class, $request_params);
74
-        $this->loader->share(ServerParams::class, $server_params);
75
-    }
63
+	/**
64
+	 * @return void
65
+	 */
66
+	public function buildRequestResponse()
67
+	{
68
+		$request_params = new RequestParams(new RequestSanitizer());
69
+		$server_params = new ServerParams(new ServerSanitizer());
70
+		// load our Request and Response objects
71
+		$this->request = new Request($request_params, $server_params);
72
+		$this->response = new Response();
73
+		$this->loader->share(RequestParams::class, $request_params);
74
+		$this->loader->share(ServerParams::class, $server_params);
75
+	}
76 76
 
77 77
 
78
-    /**
79
-     * @return void
80
-     * @throws InvalidArgumentException
81
-     */
82
-    public function shareRequestResponse()
83
-    {
84
-        $this->loader->share('EventEspresso\core\services\request\Request', $this->request);
85
-        $this->loader->share('EventEspresso\core\services\request\Response', $this->response);
86
-        EE_Dependency_Map::instance()->setRequest($this->request);
87
-        EE_Dependency_Map::instance()->setResponse($this->response);
88
-    }
78
+	/**
79
+	 * @return void
80
+	 * @throws InvalidArgumentException
81
+	 */
82
+	public function shareRequestResponse()
83
+	{
84
+		$this->loader->share('EventEspresso\core\services\request\Request', $this->request);
85
+		$this->loader->share('EventEspresso\core\services\request\Response', $this->response);
86
+		EE_Dependency_Map::instance()->setRequest($this->request);
87
+		EE_Dependency_Map::instance()->setResponse($this->response);
88
+	}
89 89
 
90 90
 
91
-    /**
92
-     * @return void
93
-     * @throws InvalidArgumentException
94
-     * @throws EE_Error
95
-     */
96
-    public function setupLegacyRequest()
97
-    {
98
-        espresso_load_required(
99
-            'EE_Request',
100
-            EE_CORE . 'request_stack/EE_Request.core.php'
101
-        );
102
-        $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
103
-        $this->legacy_request->setRequest($this->request);
104
-        $this->legacy_request->admin = $this->request->isAdmin();
105
-        $this->legacy_request->ajax = $this->request->isAjax();
106
-        $this->legacy_request->front_ajax = $this->request->isFrontAjax();
107
-        EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request);
108
-        $this->loader->share('EE_Request', $this->legacy_request);
109
-        $this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request);
110
-    }
91
+	/**
92
+	 * @return void
93
+	 * @throws InvalidArgumentException
94
+	 * @throws EE_Error
95
+	 */
96
+	public function setupLegacyRequest()
97
+	{
98
+		espresso_load_required(
99
+			'EE_Request',
100
+			EE_CORE . 'request_stack/EE_Request.core.php'
101
+		);
102
+		$this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
103
+		$this->legacy_request->setRequest($this->request);
104
+		$this->legacy_request->admin = $this->request->isAdmin();
105
+		$this->legacy_request->ajax = $this->request->isAjax();
106
+		$this->legacy_request->front_ajax = $this->request->isFrontAjax();
107
+		EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request);
108
+		$this->loader->share('EE_Request', $this->legacy_request);
109
+		$this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request);
110
+	}
111 111
 }
Please login to merge, or discard this patch.