Completed
Branch BUG/update-unit-tests (7b5400)
by
unknown
07:51 queued 05:38
created
core/libraries/iframe_display/Iframe.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     public function __construct($title, $content)
84 84
     {
85 85
         global $wp_version;
86
-        if (! defined('EE_IFRAME_DIR_URL')) {
86
+        if ( ! defined('EE_IFRAME_DIR_URL')) {
87 87
             define('EE_IFRAME_DIR_URL', plugin_dir_url(__FILE__));
88 88
         }
89 89
         $this->setContent($content);
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
                 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css',
94 94
                 array(
95 95
                     'site_theme'       => get_stylesheet_directory_uri()
96
-                                          . '/style.css?ver=' . EVENT_ESPRESSO_VERSION,
97
-                    'dashicons'        => includes_url('css/dashicons.min.css?ver=' . $wp_version),
96
+                                          . '/style.css?ver='.EVENT_ESPRESSO_VERSION,
97
+                    'dashicons'        => includes_url('css/dashicons.min.css?ver='.$wp_version),
98 98
                     'espresso_default' => EE_GLOBAL_ASSETS_URL
99
-                                          . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
99
+                                          . 'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION,
100 100
                 ),
101 101
                 $this
102 102
             )
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
             apply_filters(
106 106
                 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js',
107 107
                 array(
108
-                    'jquery'        => includes_url('js/jquery/jquery.js?ver=' . $wp_version),
108
+                    'jquery'        => includes_url('js/jquery/jquery.js?ver='.$wp_version),
109 109
                     'espresso_core' => EE_GLOBAL_ASSETS_URL
110
-                                       . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION,
110
+                                       . 'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION,
111 111
                 ),
112 112
                 $this
113 113
             )
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
             );
182 182
         }
183 183
         foreach ($stylesheets as $handle => $stylesheet) {
184
-            $this->css[ $handle ] = $stylesheet;
184
+            $this->css[$handle] = $stylesheet;
185 185
         }
186 186
     }
187 187
 
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
         }
204 204
         foreach ($scripts as $handle => $script) {
205 205
             if ($add_to_header) {
206
-                $this->header_js[ $handle ] = $script;
206
+                $this->header_js[$handle] = $script;
207 207
             } else {
208
-                $this->footer_js[ $handle ] = $script;
208
+                $this->footer_js[$handle] = $script;
209 209
             }
210 210
         }
211 211
     }
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
         }
229 229
         foreach ($script_attributes as $handle => $script_attribute) {
230 230
             if ($add_to_header) {
231
-                $this->header_js_attributes[ $handle ] = $script_attribute;
231
+                $this->header_js_attributes[$handle] = $script_attribute;
232 232
             } else {
233
-                $this->footer_js_attributes[ $handle ] = $script_attribute;
233
+                $this->footer_js_attributes[$handle] = $script_attribute;
234 234
             }
235 235
         }
236 236
     }
@@ -253,14 +253,14 @@  discard block
 block discarded – undo
253 253
         }
254 254
         foreach ($vars as $handle => $var) {
255 255
             if ($var_name === 'eei18n') {
256
-                EE_Registry::$i18n_js_strings[ $handle ] = $var;
256
+                EE_Registry::$i18n_js_strings[$handle] = $var;
257 257
             } elseif ($var_name === 'eeCAL' && $handle === 'espresso_calendar') {
258
-                $this->localized_vars[ $var_name ] = $var;
258
+                $this->localized_vars[$var_name] = $var;
259 259
             } else {
260
-                if (! isset($this->localized_vars[ $var_name ])) {
261
-                    $this->localized_vars[ $var_name ] = array();
260
+                if ( ! isset($this->localized_vars[$var_name])) {
261
+                    $this->localized_vars[$var_name] = array();
262 262
                 }
263
-                $this->localized_vars[ $var_name ][ $handle ] = $var;
263
+                $this->localized_vars[$var_name][$handle] = $var;
264 264
             }
265 265
         }
266 266
     }
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
     public function getTemplate()
291 291
     {
292 292
         return EEH_Template::display_template(
293
-            __DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php',
293
+            __DIR__.DIRECTORY_SEPARATOR.'iframe_wrapper.template.php',
294 294
             array(
295 295
                 'title'                => apply_filters(
296 296
                     'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title',
@@ -334,11 +334,11 @@  discard block
 block discarded – undo
334 334
                 ),
335 335
                 'eei18n'               => apply_filters(
336 336
                     'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings',
337
-                    EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(),
337
+                    EE_Registry::localize_i18n_js_strings().$this->localizeJsonVars(),
338 338
                     $this
339 339
                 ),
340 340
                 'notices'              => EEH_Template::display_template(
341
-                    EE_TEMPLATES . 'espresso-ajax-notices.template.php',
341
+                    EE_TEMPLATES.'espresso-ajax-notices.template.php',
342 342
                     array(),
343 343
                     true
344 344
                 ),
@@ -358,9 +358,9 @@  discard block
 block discarded – undo
358 358
     {
359 359
         $JSON = '';
360 360
         foreach ($this->localized_vars as $var_name => $vars) {
361
-            $this->localized_vars[ $var_name ] = $this->encodeJsonVars($vars);
361
+            $this->localized_vars[$var_name] = $this->encodeJsonVars($vars);
362 362
             $JSON .= "/* <![CDATA[ */ var {$var_name} = ";
363
-            $JSON .= wp_json_encode($this->localized_vars[ $var_name ]);
363
+            $JSON .= wp_json_encode($this->localized_vars[$var_name]);
364 364
             $JSON .= '; /* ]]> */';
365 365
         }
366 366
         return $JSON;
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
         if (is_array($var)) {
377 377
             $localized_vars = array();
378 378
             foreach ((array) $var as $key => $value) {
379
-                $localized_vars[ $key ] = $this->encodeJsonVars($value);
379
+                $localized_vars[$key] = $this->encodeJsonVars($value);
380 380
             }
381 381
             return $localized_vars;
382 382
         }
Please login to merge, or discard this patch.
Indentation   +334 added lines, -334 removed lines patch added patch discarded remove patch
@@ -17,373 +17,373 @@
 block discarded – undo
17 17
  */
18 18
 class Iframe
19 19
 {
20
-    /*
20
+	/*
21 21
     * HTML for notices and ajax gif
22 22
     * @var string $title
23 23
     */
24
-    protected $title = '';
24
+	protected $title = '';
25 25
 
26
-    /*
26
+	/*
27 27
     * HTML for the content being displayed
28 28
     * @var string $content
29 29
     */
30
-    protected $content = '';
30
+	protected $content = '';
31 31
 
32
-    /*
32
+	/*
33 33
     * whether or not to call wp_head() and wp_footer()
34 34
     * @var boolean $enqueue_wp_assets
35 35
     */
36
-    protected $enqueue_wp_assets = false;
36
+	protected $enqueue_wp_assets = false;
37 37
 
38
-    /*
38
+	/*
39 39
     * an array of CSS URLs
40 40
     * @var array $css
41 41
     */
42
-    protected $css = array();
42
+	protected $css = array();
43 43
 
44
-    /*
44
+	/*
45 45
     * an array of JS URLs to be set in the HTML header.
46 46
     * @var array $header_js
47 47
     */
48
-    protected $header_js = array();
48
+	protected $header_js = array();
49 49
 
50
-    /*
50
+	/*
51 51
     * an array of additional attributes to be added to <script> tags for header JS
52 52
     * @var array $footer_js
53 53
     */
54
-    protected $header_js_attributes = array();
54
+	protected $header_js_attributes = array();
55 55
 
56
-    /*
56
+	/*
57 57
     * an array of JS URLs to be displayed before the HTML </body> tag
58 58
     * @var array $footer_js
59 59
     */
60
-    protected $footer_js = array();
60
+	protected $footer_js = array();
61 61
 
62
-    /*
62
+	/*
63 63
     * an array of additional attributes to be added to <script> tags for footer JS
64 64
     * @var array $footer_js_attributes
65 65
     */
66
-    protected $footer_js_attributes = array();
66
+	protected $footer_js_attributes = array();
67 67
 
68
-    /*
68
+	/*
69 69
     * an array of JSON vars to be set in the HTML header.
70 70
     * @var array $localized_vars
71 71
     */
72
-    protected $localized_vars = array();
73
-
74
-
75
-    /**
76
-     * Iframe constructor
77
-     *
78
-     * @param string $title
79
-     * @param string $content
80
-     * @throws DomainException
81
-     */
82
-    public function __construct($title, $content)
83
-    {
84
-        global $wp_version;
85
-        if (! defined('EE_IFRAME_DIR_URL')) {
86
-            define('EE_IFRAME_DIR_URL', plugin_dir_url(__FILE__));
87
-        }
88
-        $this->setContent($content);
89
-        $this->setTitle($title);
90
-        $this->addStylesheets(
91
-            apply_filters(
92
-                'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css',
93
-                array(
94
-                    'site_theme'       => get_stylesheet_directory_uri()
95
-                                          . '/style.css?ver=' . EVENT_ESPRESSO_VERSION,
96
-                    'dashicons'        => includes_url('css/dashicons.min.css?ver=' . $wp_version),
97
-                    'espresso_default' => EE_GLOBAL_ASSETS_URL
98
-                                          . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
99
-                ),
100
-                $this
101
-            )
102
-        );
103
-        $this->addScripts(
104
-            apply_filters(
105
-                'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js',
106
-                array(
107
-                    'jquery'        => includes_url('js/jquery/jquery.js?ver=' . $wp_version),
108
-                    'espresso_core' => EE_GLOBAL_ASSETS_URL
109
-                                       . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION,
110
-                ),
111
-                $this
112
-            )
113
-        );
114
-        if (
115
-            apply_filters(
116
-                'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__load_default_theme_stylesheet',
117
-                false
118
-            )
119
-        ) {
120
-            $this->addStylesheets(
121
-                apply_filters(
122
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_theme_stylesheet',
123
-                    array('default_theme_stylesheet' => get_stylesheet_uri()),
124
-                    $this
125
-                )
126
-            );
127
-        }
128
-    }
129
-
130
-
131
-    /**
132
-     * @param string $title
133
-     * @throws DomainException
134
-     */
135
-    public function setTitle($title)
136
-    {
137
-        if (empty($title)) {
138
-            throw new DomainException(
139
-                esc_html__('You must provide a page title in order to create an iframe.', 'event_espresso')
140
-            );
141
-        }
142
-        $this->title = $title;
143
-    }
144
-
145
-
146
-    /**
147
-     * @param string $content
148
-     * @throws DomainException
149
-     */
150
-    public function setContent($content)
151
-    {
152
-        if (empty($content)) {
153
-            throw new DomainException(
154
-                esc_html__('You must provide content in order to create an iframe.', 'event_espresso')
155
-            );
156
-        }
157
-        $this->content = $content;
158
-    }
159
-
160
-
161
-    /**
162
-     * @param boolean $enqueue_wp_assets
163
-     */
164
-    public function setEnqueueWpAssets($enqueue_wp_assets)
165
-    {
166
-        $this->enqueue_wp_assets = filter_var($enqueue_wp_assets, FILTER_VALIDATE_BOOLEAN);
167
-    }
168
-
169
-
170
-    /**
171
-     * @param array $stylesheets
172
-     * @throws DomainException
173
-     */
174
-    public function addStylesheets(array $stylesheets)
175
-    {
176
-        if (empty($stylesheets)) {
177
-            throw new DomainException(
178
-                esc_html__(
179
-                    'A non-empty array of URLs, is required to add a CSS stylesheet to an iframe.',
180
-                    'event_espresso'
181
-                )
182
-            );
183
-        }
184
-        foreach ($stylesheets as $handle => $stylesheet) {
185
-            $this->css[ $handle ] = $stylesheet;
186
-        }
187
-    }
188
-
189
-
190
-    /**
191
-     * @param array $scripts
192
-     * @param bool  $add_to_header
193
-     * @throws DomainException
194
-     */
195
-    public function addScripts(array $scripts, $add_to_header = false)
196
-    {
197
-        if (empty($scripts)) {
198
-            throw new DomainException(
199
-                esc_html__(
200
-                    'A non-empty array of URLs, is required to add Javascript to an iframe.',
201
-                    'event_espresso'
202
-                )
203
-            );
204
-        }
205
-        foreach ($scripts as $handle => $script) {
206
-            if ($add_to_header) {
207
-                $this->header_js[ $handle ] = $script;
208
-            } else {
209
-                $this->footer_js[ $handle ] = $script;
210
-            }
211
-        }
212
-    }
213
-
214
-
215
-    /**
216
-     * @param array $script_attributes
217
-     * @param bool  $add_to_header
218
-     * @throws DomainException
219
-     */
220
-    public function addScriptAttributes(array $script_attributes, $add_to_header = false)
221
-    {
222
-        if (empty($script_attributes)) {
223
-            throw new DomainException(
224
-                esc_html__(
225
-                    'A non-empty array of strings, is required to add attributes to iframe Javascript.',
226
-                    'event_espresso'
227
-                )
228
-            );
229
-        }
230
-        foreach ($script_attributes as $handle => $script_attribute) {
231
-            if ($add_to_header) {
232
-                $this->header_js_attributes[ $handle ] = $script_attribute;
233
-            } else {
234
-                $this->footer_js_attributes[ $handle ] = $script_attribute;
235
-            }
236
-        }
237
-    }
238
-
239
-
240
-    /**
241
-     * @param array  $vars
242
-     * @param string $var_name
243
-     * @throws DomainException
244
-     */
245
-    public function addLocalizedVars(array $vars, $var_name = 'eei18n')
246
-    {
247
-        if (empty($vars)) {
248
-            throw new DomainException(
249
-                esc_html__(
250
-                    'A non-empty array of vars, is required to add localized Javascript vars to an iframe.',
251
-                    'event_espresso'
252
-                )
253
-            );
254
-        }
255
-        foreach ($vars as $handle => $var) {
256
-            if ($var_name === 'eei18n') {
257
-                EE_Registry::$i18n_js_strings[ $handle ] = $var;
258
-            } elseif ($var_name === 'eeCAL' && $handle === 'espresso_calendar') {
259
-                $this->localized_vars[ $var_name ] = $var;
260
-            } else {
261
-                if (! isset($this->localized_vars[ $var_name ])) {
262
-                    $this->localized_vars[ $var_name ] = array();
263
-                }
264
-                $this->localized_vars[ $var_name ][ $handle ] = $var;
265
-            }
266
-        }
267
-    }
268
-
269
-
270
-    /**
271
-     * @param string $utm_content
272
-     * @throws DomainException
273
-     */
274
-    public function display($utm_content = '')
275
-    {
276
-        $this->content .= EEH_Template::powered_by_event_espresso(
277
-            '',
278
-            '',
279
-            ! empty($utm_content) ? array('utm_content' => $utm_content) : array()
280
-        );
281
-        EE_System::do_not_cache();
282
-        echo $this->getTemplate(); // already escaped
283
-        exit;
284
-    }
285
-
286
-
287
-    /**
288
-     * @return string
289
-     * @throws DomainException
290
-     */
291
-    public function getTemplate()
292
-    {
293
-        return EEH_Template::display_template(
294
-            __DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php',
295
-            array(
296
-                'title'                => apply_filters(
297
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title',
298
-                    $this->title,
299
-                    $this
300
-                ),
301
-                'content'              => apply_filters(
302
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__content',
303
-                    $this->content,
304
-                    $this
305
-                ),
306
-                'enqueue_wp_assets'    => apply_filters(
307
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__enqueue_wp_assets',
308
-                    $this->enqueue_wp_assets,
309
-                    $this
310
-                ),
311
-                'css'                  => (array) apply_filters(
312
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__css_urls',
313
-                    $this->css,
314
-                    $this
315
-                ),
316
-                'header_js'            => (array) apply_filters(
317
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_urls',
318
-                    $this->header_js,
319
-                    $this
320
-                ),
321
-                'header_js_attributes' => (array) apply_filters(
322
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_attributes',
323
-                    $this->header_js_attributes,
324
-                    $this
325
-                ),
326
-                'footer_js'            => (array) apply_filters(
327
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_urls',
328
-                    $this->footer_js,
329
-                    $this
330
-                ),
331
-                'footer_js_attributes' => (array) apply_filters(
332
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_attributes',
333
-                    $this->footer_js_attributes,
334
-                    $this
335
-                ),
336
-                'eei18n'               => apply_filters(
337
-                    'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings',
338
-                    EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(),
339
-                    $this
340
-                ),
341
-                'notices'              => EEH_Template::display_template(
342
-                    EE_TEMPLATES . 'espresso-ajax-notices.template.php',
343
-                    array(),
344
-                    true
345
-                ),
346
-            ),
347
-            true,
348
-            true
349
-        );
350
-    }
351
-
352
-
353
-    /**
354
-     * localizeJsonVars
355
-     *
356
-     * @return string
357
-     */
358
-    public function localizeJsonVars()
359
-    {
360
-        $JSON = '';
361
-        foreach ($this->localized_vars as $var_name => $vars) {
362
-            $this->localized_vars[ $var_name ] = $this->encodeJsonVars($vars);
363
-            $JSON .= "/* <![CDATA[ */ var {$var_name} = ";
364
-            $JSON .= wp_json_encode($this->localized_vars[ $var_name ]);
365
-            $JSON .= '; /* ]]> */';
366
-        }
367
-        return $JSON;
368
-    }
369
-
370
-
371
-    /**
372
-     * @param bool|int|float|string|array $var
373
-     * @return array|string|null
374
-     */
375
-    public function encodeJsonVars($var)
376
-    {
377
-        if (is_array($var)) {
378
-            $localized_vars = array();
379
-            foreach ((array) $var as $key => $value) {
380
-                $localized_vars[ $key ] = $this->encodeJsonVars($value);
381
-            }
382
-            return $localized_vars;
383
-        }
384
-        if (is_scalar($var)) {
385
-            return html_entity_decode((string) $var, ENT_QUOTES, 'UTF-8');
386
-        }
387
-        return null;
388
-    }
72
+	protected $localized_vars = array();
73
+
74
+
75
+	/**
76
+	 * Iframe constructor
77
+	 *
78
+	 * @param string $title
79
+	 * @param string $content
80
+	 * @throws DomainException
81
+	 */
82
+	public function __construct($title, $content)
83
+	{
84
+		global $wp_version;
85
+		if (! defined('EE_IFRAME_DIR_URL')) {
86
+			define('EE_IFRAME_DIR_URL', plugin_dir_url(__FILE__));
87
+		}
88
+		$this->setContent($content);
89
+		$this->setTitle($title);
90
+		$this->addStylesheets(
91
+			apply_filters(
92
+				'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css',
93
+				array(
94
+					'site_theme'       => get_stylesheet_directory_uri()
95
+										  . '/style.css?ver=' . EVENT_ESPRESSO_VERSION,
96
+					'dashicons'        => includes_url('css/dashicons.min.css?ver=' . $wp_version),
97
+					'espresso_default' => EE_GLOBAL_ASSETS_URL
98
+										  . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
99
+				),
100
+				$this
101
+			)
102
+		);
103
+		$this->addScripts(
104
+			apply_filters(
105
+				'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js',
106
+				array(
107
+					'jquery'        => includes_url('js/jquery/jquery.js?ver=' . $wp_version),
108
+					'espresso_core' => EE_GLOBAL_ASSETS_URL
109
+									   . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION,
110
+				),
111
+				$this
112
+			)
113
+		);
114
+		if (
115
+			apply_filters(
116
+				'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__load_default_theme_stylesheet',
117
+				false
118
+			)
119
+		) {
120
+			$this->addStylesheets(
121
+				apply_filters(
122
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_theme_stylesheet',
123
+					array('default_theme_stylesheet' => get_stylesheet_uri()),
124
+					$this
125
+				)
126
+			);
127
+		}
128
+	}
129
+
130
+
131
+	/**
132
+	 * @param string $title
133
+	 * @throws DomainException
134
+	 */
135
+	public function setTitle($title)
136
+	{
137
+		if (empty($title)) {
138
+			throw new DomainException(
139
+				esc_html__('You must provide a page title in order to create an iframe.', 'event_espresso')
140
+			);
141
+		}
142
+		$this->title = $title;
143
+	}
144
+
145
+
146
+	/**
147
+	 * @param string $content
148
+	 * @throws DomainException
149
+	 */
150
+	public function setContent($content)
151
+	{
152
+		if (empty($content)) {
153
+			throw new DomainException(
154
+				esc_html__('You must provide content in order to create an iframe.', 'event_espresso')
155
+			);
156
+		}
157
+		$this->content = $content;
158
+	}
159
+
160
+
161
+	/**
162
+	 * @param boolean $enqueue_wp_assets
163
+	 */
164
+	public function setEnqueueWpAssets($enqueue_wp_assets)
165
+	{
166
+		$this->enqueue_wp_assets = filter_var($enqueue_wp_assets, FILTER_VALIDATE_BOOLEAN);
167
+	}
168
+
169
+
170
+	/**
171
+	 * @param array $stylesheets
172
+	 * @throws DomainException
173
+	 */
174
+	public function addStylesheets(array $stylesheets)
175
+	{
176
+		if (empty($stylesheets)) {
177
+			throw new DomainException(
178
+				esc_html__(
179
+					'A non-empty array of URLs, is required to add a CSS stylesheet to an iframe.',
180
+					'event_espresso'
181
+				)
182
+			);
183
+		}
184
+		foreach ($stylesheets as $handle => $stylesheet) {
185
+			$this->css[ $handle ] = $stylesheet;
186
+		}
187
+	}
188
+
189
+
190
+	/**
191
+	 * @param array $scripts
192
+	 * @param bool  $add_to_header
193
+	 * @throws DomainException
194
+	 */
195
+	public function addScripts(array $scripts, $add_to_header = false)
196
+	{
197
+		if (empty($scripts)) {
198
+			throw new DomainException(
199
+				esc_html__(
200
+					'A non-empty array of URLs, is required to add Javascript to an iframe.',
201
+					'event_espresso'
202
+				)
203
+			);
204
+		}
205
+		foreach ($scripts as $handle => $script) {
206
+			if ($add_to_header) {
207
+				$this->header_js[ $handle ] = $script;
208
+			} else {
209
+				$this->footer_js[ $handle ] = $script;
210
+			}
211
+		}
212
+	}
213
+
214
+
215
+	/**
216
+	 * @param array $script_attributes
217
+	 * @param bool  $add_to_header
218
+	 * @throws DomainException
219
+	 */
220
+	public function addScriptAttributes(array $script_attributes, $add_to_header = false)
221
+	{
222
+		if (empty($script_attributes)) {
223
+			throw new DomainException(
224
+				esc_html__(
225
+					'A non-empty array of strings, is required to add attributes to iframe Javascript.',
226
+					'event_espresso'
227
+				)
228
+			);
229
+		}
230
+		foreach ($script_attributes as $handle => $script_attribute) {
231
+			if ($add_to_header) {
232
+				$this->header_js_attributes[ $handle ] = $script_attribute;
233
+			} else {
234
+				$this->footer_js_attributes[ $handle ] = $script_attribute;
235
+			}
236
+		}
237
+	}
238
+
239
+
240
+	/**
241
+	 * @param array  $vars
242
+	 * @param string $var_name
243
+	 * @throws DomainException
244
+	 */
245
+	public function addLocalizedVars(array $vars, $var_name = 'eei18n')
246
+	{
247
+		if (empty($vars)) {
248
+			throw new DomainException(
249
+				esc_html__(
250
+					'A non-empty array of vars, is required to add localized Javascript vars to an iframe.',
251
+					'event_espresso'
252
+				)
253
+			);
254
+		}
255
+		foreach ($vars as $handle => $var) {
256
+			if ($var_name === 'eei18n') {
257
+				EE_Registry::$i18n_js_strings[ $handle ] = $var;
258
+			} elseif ($var_name === 'eeCAL' && $handle === 'espresso_calendar') {
259
+				$this->localized_vars[ $var_name ] = $var;
260
+			} else {
261
+				if (! isset($this->localized_vars[ $var_name ])) {
262
+					$this->localized_vars[ $var_name ] = array();
263
+				}
264
+				$this->localized_vars[ $var_name ][ $handle ] = $var;
265
+			}
266
+		}
267
+	}
268
+
269
+
270
+	/**
271
+	 * @param string $utm_content
272
+	 * @throws DomainException
273
+	 */
274
+	public function display($utm_content = '')
275
+	{
276
+		$this->content .= EEH_Template::powered_by_event_espresso(
277
+			'',
278
+			'',
279
+			! empty($utm_content) ? array('utm_content' => $utm_content) : array()
280
+		);
281
+		EE_System::do_not_cache();
282
+		echo $this->getTemplate(); // already escaped
283
+		exit;
284
+	}
285
+
286
+
287
+	/**
288
+	 * @return string
289
+	 * @throws DomainException
290
+	 */
291
+	public function getTemplate()
292
+	{
293
+		return EEH_Template::display_template(
294
+			__DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php',
295
+			array(
296
+				'title'                => apply_filters(
297
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title',
298
+					$this->title,
299
+					$this
300
+				),
301
+				'content'              => apply_filters(
302
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__content',
303
+					$this->content,
304
+					$this
305
+				),
306
+				'enqueue_wp_assets'    => apply_filters(
307
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__enqueue_wp_assets',
308
+					$this->enqueue_wp_assets,
309
+					$this
310
+				),
311
+				'css'                  => (array) apply_filters(
312
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__css_urls',
313
+					$this->css,
314
+					$this
315
+				),
316
+				'header_js'            => (array) apply_filters(
317
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_urls',
318
+					$this->header_js,
319
+					$this
320
+				),
321
+				'header_js_attributes' => (array) apply_filters(
322
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_attributes',
323
+					$this->header_js_attributes,
324
+					$this
325
+				),
326
+				'footer_js'            => (array) apply_filters(
327
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_urls',
328
+					$this->footer_js,
329
+					$this
330
+				),
331
+				'footer_js_attributes' => (array) apply_filters(
332
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_attributes',
333
+					$this->footer_js_attributes,
334
+					$this
335
+				),
336
+				'eei18n'               => apply_filters(
337
+					'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings',
338
+					EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(),
339
+					$this
340
+				),
341
+				'notices'              => EEH_Template::display_template(
342
+					EE_TEMPLATES . 'espresso-ajax-notices.template.php',
343
+					array(),
344
+					true
345
+				),
346
+			),
347
+			true,
348
+			true
349
+		);
350
+	}
351
+
352
+
353
+	/**
354
+	 * localizeJsonVars
355
+	 *
356
+	 * @return string
357
+	 */
358
+	public function localizeJsonVars()
359
+	{
360
+		$JSON = '';
361
+		foreach ($this->localized_vars as $var_name => $vars) {
362
+			$this->localized_vars[ $var_name ] = $this->encodeJsonVars($vars);
363
+			$JSON .= "/* <![CDATA[ */ var {$var_name} = ";
364
+			$JSON .= wp_json_encode($this->localized_vars[ $var_name ]);
365
+			$JSON .= '; /* ]]> */';
366
+		}
367
+		return $JSON;
368
+	}
369
+
370
+
371
+	/**
372
+	 * @param bool|int|float|string|array $var
373
+	 * @return array|string|null
374
+	 */
375
+	public function encodeJsonVars($var)
376
+	{
377
+		if (is_array($var)) {
378
+			$localized_vars = array();
379
+			foreach ((array) $var as $key => $value) {
380
+				$localized_vars[ $key ] = $this->encodeJsonVars($value);
381
+			}
382
+			return $localized_vars;
383
+		}
384
+		if (is_scalar($var)) {
385
+			return html_entity_decode((string) $var, ENT_QUOTES, 'UTF-8');
386
+		}
387
+		return null;
388
+	}
389 389
 }
Please login to merge, or discard this patch.
modules/events_archive/EventsArchiveIframe.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
             apply_filters(
48 48
                 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
49 49
                 [
50
-                    'espresso_default' => is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
51
-                        ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION
52
-                        : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
50
+                    'espresso_default' => is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css')
51
+                        ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION
52
+                        : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION,
53 53
                 ],
54 54
                 $this
55 55
             )
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
                             EE_Registry::instance()->CFG->map_settings->google_map_api_key
66 66
                         )
67 67
                     ),
68
-                    'ee_gmap'  => EE_HELPERS_ASSETS . 'ee_gmap.js?ver=1.0',
68
+                    'ee_gmap'  => EE_HELPERS_ASSETS.'ee_gmap.js?ver=1.0',
69 69
                 ],
70 70
                 $this
71 71
             )
Please login to merge, or discard this patch.
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -21,58 +21,58 @@
 block discarded – undo
21 21
  */
22 22
 class EventsArchiveIframe extends Iframe
23 23
 {
24
-    /**
25
-     * EventsArchiveIframe constructor.
26
-     *
27
-     * @param EED_Events_Archive $EED_Events_Archive
28
-     * @throws EE_Error
29
-     * @throws ReflectionException
30
-     */
31
-    public function __construct($EED_Events_Archive)
32
-    {
33
-        /** @var CurrentPage $current_page */
34
-        $current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class);
35
-        $current_page->setEspressoPage(true);
36
-        add_filter('FHEE__EED_Events_Archive__event_list_iframe', '__return_true');
37
-        $EED_Events_Archive->event_list();
38
-        /** @var EspressoEvents $event_list */
39
-        $event_list = EE_Registry::instance()->create('EventEspresso\core\domain\entities\shortcodes\EspressoEvents');
40
-        parent::__construct(
41
-            esc_html__('Event List', 'event_espresso'),
42
-            $event_list->processShortcode()
43
-        );
44
-        $this->addStylesheets(
45
-            apply_filters(
46
-                'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
47
-                [
48
-                    'espresso_default' => is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
49
-                        ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION
50
-                        : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
51
-                ],
52
-                $this
53
-            )
54
-        );
55
-        $this->addScripts(
56
-            apply_filters(
57
-                'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
58
-                [
59
-                    'gmap_api' => sprintf(
60
-                        'https://maps.googleapis.com/maps/api/js?key=%s',
61
-                        apply_filters(
62
-                            'FHEE__EEH_Maps__espresso_google_maps_js__api_key',
63
-                            EE_Registry::instance()->CFG->map_settings->google_map_api_key
64
-                        )
65
-                    ),
66
-                    'ee_gmap'  => EE_HELPERS_ASSETS . 'ee_gmap.js?ver=1.0',
67
-                ],
68
-                $this
69
-            )
70
-        );
71
-        $this->addLocalizedVars(
72
-            [
73
-                'ee_gmap' => EEH_Maps::$gmap_vars,
74
-            ],
75
-            'ee_gmap_vars'
76
-        );
77
-    }
24
+	/**
25
+	 * EventsArchiveIframe constructor.
26
+	 *
27
+	 * @param EED_Events_Archive $EED_Events_Archive
28
+	 * @throws EE_Error
29
+	 * @throws ReflectionException
30
+	 */
31
+	public function __construct($EED_Events_Archive)
32
+	{
33
+		/** @var CurrentPage $current_page */
34
+		$current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class);
35
+		$current_page->setEspressoPage(true);
36
+		add_filter('FHEE__EED_Events_Archive__event_list_iframe', '__return_true');
37
+		$EED_Events_Archive->event_list();
38
+		/** @var EspressoEvents $event_list */
39
+		$event_list = EE_Registry::instance()->create('EventEspresso\core\domain\entities\shortcodes\EspressoEvents');
40
+		parent::__construct(
41
+			esc_html__('Event List', 'event_espresso'),
42
+			$event_list->processShortcode()
43
+		);
44
+		$this->addStylesheets(
45
+			apply_filters(
46
+				'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
47
+				[
48
+					'espresso_default' => is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
49
+						? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION
50
+						: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION,
51
+				],
52
+				$this
53
+			)
54
+		);
55
+		$this->addScripts(
56
+			apply_filters(
57
+				'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
58
+				[
59
+					'gmap_api' => sprintf(
60
+						'https://maps.googleapis.com/maps/api/js?key=%s',
61
+						apply_filters(
62
+							'FHEE__EEH_Maps__espresso_google_maps_js__api_key',
63
+							EE_Registry::instance()->CFG->map_settings->google_map_api_key
64
+						)
65
+					),
66
+					'ee_gmap'  => EE_HELPERS_ASSETS . 'ee_gmap.js?ver=1.0',
67
+				],
68
+				$this
69
+			)
70
+		);
71
+		$this->addLocalizedVars(
72
+			[
73
+				'ee_gmap' => EEH_Maps::$gmap_vars,
74
+			],
75
+			'ee_gmap_vars'
76
+		);
77
+	}
78 78
 }
Please login to merge, or discard this patch.
modules/ticket_selector/TicketSelectorSimple.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,6 +72,6 @@
 block discarded – undo
72 72
         }
73 73
         $this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription();
74 74
         $this->template_args['template_path']      =
75
-            TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php';
75
+            TICKET_SELECTOR_TEMPLATES_PATH.'simple_ticket_selector.template.php';
76 76
     }
77 77
 }
Please login to merge, or discard this patch.
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -19,59 +19,59 @@
 block discarded – undo
19 19
  */
20 20
 class TicketSelectorSimple extends TicketSelector
21 21
 {
22
-    /**
23
-     * @var EE_Ticket $ticket
24
-     */
25
-    protected $ticket;
22
+	/**
23
+	 * @var EE_Ticket $ticket
24
+	 */
25
+	protected $ticket;
26 26
 
27 27
 
28
-    /**
29
-     * TicketSelectorSimple constructor.
30
-     *
31
-     * @param EE_Event  $event
32
-     * @param EE_Ticket $ticket
33
-     * @param int       $max_attendees
34
-     * @param array     $template_args
35
-     * @throws EE_Error
36
-     */
37
-    public function __construct(EE_Event $event, EE_Ticket $ticket, $max_attendees, array $template_args)
38
-    {
39
-        $this->ticket = $ticket;
40
-        parent::__construct(
41
-            $event,
42
-            [$this->ticket],
43
-            $max_attendees,
44
-            $template_args
45
-        );
46
-    }
28
+	/**
29
+	 * TicketSelectorSimple constructor.
30
+	 *
31
+	 * @param EE_Event  $event
32
+	 * @param EE_Ticket $ticket
33
+	 * @param int       $max_attendees
34
+	 * @param array     $template_args
35
+	 * @throws EE_Error
36
+	 */
37
+	public function __construct(EE_Event $event, EE_Ticket $ticket, $max_attendees, array $template_args)
38
+	{
39
+		$this->ticket = $ticket;
40
+		parent::__construct(
41
+			$event,
42
+			[$this->ticket],
43
+			$max_attendees,
44
+			$template_args
45
+		);
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * sets any and all template args that are required for this Ticket Selector
51
-     *
52
-     * @return void
53
-     * @throws UnexpectedEntityException
54
-     * @throws EE_Error
55
-     */
56
-    protected function addTemplateArgs()
57
-    {
58
-        $this->ticket_rows = 1;
59
-        unset($this->template_args['tickets']);
60
-        $this->template_args['ticket'] = $this->ticket;
61
-        $ticket_selector_row           = new TicketSelectorRowSimple(
62
-            $this->ticket,
63
-            $this->max_attendees,
64
-            $this->template_args['date_format'],
65
-            $this->template_args['event_status']
66
-        );
67
-        $this->template_args['TKT_ID'] = $this->ticket->ID();
68
-        $ticket_selector_row->setupTicketStatusDisplay();
69
-        $this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay();
70
-        if (empty($this->template_args['ticket_status_display'])) {
71
-            add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
72
-        }
73
-        $this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription();
74
-        $this->template_args['template_path']      =
75
-            TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php';
76
-    }
49
+	/**
50
+	 * sets any and all template args that are required for this Ticket Selector
51
+	 *
52
+	 * @return void
53
+	 * @throws UnexpectedEntityException
54
+	 * @throws EE_Error
55
+	 */
56
+	protected function addTemplateArgs()
57
+	{
58
+		$this->ticket_rows = 1;
59
+		unset($this->template_args['tickets']);
60
+		$this->template_args['ticket'] = $this->ticket;
61
+		$ticket_selector_row           = new TicketSelectorRowSimple(
62
+			$this->ticket,
63
+			$this->max_attendees,
64
+			$this->template_args['date_format'],
65
+			$this->template_args['event_status']
66
+		);
67
+		$this->template_args['TKT_ID'] = $this->ticket->ID();
68
+		$ticket_selector_row->setupTicketStatusDisplay();
69
+		$this->template_args['ticket_status_display'] = $ticket_selector_row->getTicketStatusDisplay();
70
+		if (empty($this->template_args['ticket_status_display'])) {
71
+			add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
72
+		}
73
+		$this->template_args['ticket_description'] = $ticket_selector_row->getTicketDescription();
74
+		$this->template_args['template_path']      =
75
+			TICKET_SELECTOR_TEMPLATES_PATH . 'simple_ticket_selector.template.php';
76
+	}
77 77
 }
Please login to merge, or discard this patch.
modules/feeds/EED_Feeds.module.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         $request = self::getRequest();
84 84
         if ($request->requestParamIsSet('post_type')) {
85 85
             // define path to templates
86
-            define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
86
+            define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/');
87 87
             // what kinda post_type are we dealing with ?
88 88
             switch ($request->getRequestParam('post_type')) {
89 89
                 case 'espresso_events':
@@ -155,14 +155,14 @@  discard block
 block discarded – undo
155 155
      */
156 156
     public static function the_event_feed($content)
157 157
     {
158
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) {
158
+        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH.'espresso_events_feed.template.php')) {
159 159
             global $post;
160 160
             $template_args = array(
161 161
                 'EVT_ID'            => $post->ID,
162 162
                 'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
163 163
             );
164 164
             $content = EEH_Template::display_template(
165
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php',
165
+                RSS_FEEDS_TEMPLATES_PATH.'espresso_events_feed.template.php',
166 166
                 $template_args,
167 167
                 true
168 168
             );
@@ -196,14 +196,14 @@  discard block
 block discarded – undo
196 196
      */
197 197
     public static function the_venue_feed($content)
198 198
     {
199
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) {
199
+        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH.'espresso_venues_feed.template.php')) {
200 200
             global $post;
201 201
             $template_args = array(
202 202
                 'VNU_ID'            => $post->ID,
203 203
                 'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
204 204
             );
205 205
             $content = EEH_Template::display_template(
206
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php',
206
+                RSS_FEEDS_TEMPLATES_PATH.'espresso_venues_feed.template.php',
207 207
                 $template_args,
208 208
                 true
209 209
             );
Please login to merge, or discard this patch.
Indentation   +214 added lines, -214 removed lines patch added patch discarded remove patch
@@ -11,218 +11,218 @@
 block discarded – undo
11 11
  */
12 12
 class EED_Feeds extends EED_Module
13 13
 {
14
-    /**
15
-     * @return EED_Feeds
16
-     */
17
-    public static function instance()
18
-    {
19
-        return parent::get_instance(__CLASS__);
20
-    }
21
-
22
-
23
-    /**
24
-     *    set_hooks - for hooking into EE Core, other modules, etc
25
-     *
26
-     * @access    public
27
-     * @return    void
28
-     */
29
-    public static function set_hooks()
30
-    {
31
-        add_action('parse_request', array('EED_Feeds', 'parse_request'), 10);
32
-        add_filter('default_feed', array('EED_Feeds', 'default_feed'), 10, 1);
33
-        add_filter('comment_feed_join', array('EED_Feeds', 'comment_feed_join'), 10, 2);
34
-        add_filter('comment_feed_where', array('EED_Feeds', 'comment_feed_where'), 10, 2);
35
-    }
36
-
37
-    /**
38
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
39
-     *
40
-     * @access    public
41
-     * @return    void
42
-     */
43
-    public static function set_hooks_admin()
44
-    {
45
-    }
46
-
47
-
48
-    /**
49
-     *    run - initial module setup
50
-     *
51
-     * @access    public
52
-     * @return    void
53
-     */
54
-    public function run($WP)
55
-    {
56
-    }
57
-
58
-
59
-    /**
60
-     *    default_feed
61
-     *
62
-     * @access    public
63
-     * @param    type    rss2, atom, rss, rdf, rssjs
64
-     * @return    string
65
-     */
66
-    public static function default_feed($type = 'rss2')
67
-    {
68
-        // rss2, atom, rss, rdf, rssjs
69
-        $type = 'rss2';
70
-        return $type;
71
-    }
72
-
73
-
74
-    /**
75
-     *    parse_request
76
-     *
77
-     * @access    public
78
-     * @return    void
79
-     */
80
-    public static function parse_request()
81
-    {
82
-        $request = self::getRequest();
83
-        if ($request->requestParamIsSet('post_type')) {
84
-            // define path to templates
85
-            define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
86
-            // what kinda post_type are we dealing with ?
87
-            switch ($request->getRequestParam('post_type')) {
88
-                case 'espresso_events':
89
-                    // for rss2, atom, rss, rdf
90
-                    add_filter('the_excerpt_rss', array('EED_Feeds', 'the_event_feed'), 10, 1);
91
-                    add_filter('the_content_feed', array('EED_Feeds', 'the_event_feed'), 10, 1);
92
-                    // for json ( also uses the above filter )
93
-                    add_filter('rssjs_feed_item', array('EED_Feeds', 'the_event_rssjs_feed'), 10, 1);
94
-                    break;
95
-                case 'espresso_venues':
96
-                    // for rss2, atom, rss, rdf
97
-                    add_filter('the_excerpt_rss', array('EED_Feeds', 'the_venue_feed'), 10, 1);
98
-                    add_filter('the_content_feed', array('EED_Feeds', 'the_venue_feed'), 10, 1);
99
-                    // for json ( also uses the above filter )
100
-                    add_filter('rssjs_feed_item', array('EED_Feeds', 'the_venue_rssjs_feed'), 10, 1);
101
-                    break;
102
-            }
103
-        }
104
-    }
105
-
106
-
107
-    /**
108
-     *    comment_feed_join - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
109
-     *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
110
-     *    so this little snippet of SQL taps into the comment feed query and removes comments for the
111
-     *    espresso_attendees post_type
112
-     *
113
-     * @access    public
114
-     * @param    string $SQL the JOIN clause for the comment feed query
115
-     * @return    void
116
-     */
117
-    public static function comment_feed_join($SQL)
118
-    {
119
-        global $wpdb;
120
-        // check for wp_posts table in JOIN clause
121
-        if (strpos($SQL, $wpdb->posts) !== false) {
122
-            add_filter('EED_Feeds__comment_feed_where__espresso_attendees', '__return_true');
123
-        }
124
-        return $SQL;
125
-    }
126
-
127
-
128
-    /**
129
-     *    comment_feed_where - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
130
-     *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
131
-     *    so this little snippet of SQL taps into the comment feed query and removes comments for the
132
-     *    espresso_attendees post_type
133
-     *
134
-     * @access    public
135
-     * @param    string $SQL the WHERE clause for the comment feed query
136
-     * @return    void
137
-     */
138
-    public static function comment_feed_where($SQL)
139
-    {
140
-        global $wp_query, $wpdb;
141
-        if ($wp_query->is_comment_feed && apply_filters('EED_Feeds__comment_feed_where__espresso_attendees', false)) {
142
-            $SQL .= " AND $wpdb->posts.post_type != 'espresso_attendees'";
143
-        }
144
-        return $SQL;
145
-    }
146
-
147
-
148
-    /**
149
-     *    the_event_feed
150
-     *
151
-     * @access    public
152
-     * @param    string $content
153
-     * @return    void
154
-     */
155
-    public static function the_event_feed($content)
156
-    {
157
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) {
158
-            global $post;
159
-            $template_args = array(
160
-                'EVT_ID'            => $post->ID,
161
-                'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
162
-            );
163
-            $content = EEH_Template::display_template(
164
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php',
165
-                $template_args,
166
-                true
167
-            );
168
-        }
169
-        return $content;
170
-    }
171
-
172
-
173
-    /**
174
-     *    the_event_rssjs_feed
175
-     *
176
-     * @access    public
177
-     * @param    object $item
178
-     * @return    void
179
-     */
180
-    public static function the_event_rssjs_feed($item)
181
-    {
182
-        if (is_feed() && isset($item->description)) {
183
-            $item->description = EED_Feeds::the_event_feed($item->description);
184
-        }
185
-        return $item;
186
-    }
187
-
188
-
189
-    /**
190
-     *    the_venue_feed
191
-     *
192
-     * @access    public
193
-     * @param    string $content
194
-     * @return    void
195
-     */
196
-    public static function the_venue_feed($content)
197
-    {
198
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) {
199
-            global $post;
200
-            $template_args = array(
201
-                'VNU_ID'            => $post->ID,
202
-                'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
203
-            );
204
-            $content = EEH_Template::display_template(
205
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php',
206
-                $template_args,
207
-                true
208
-            );
209
-        }
210
-        return $content;
211
-    }
212
-
213
-
214
-    /**
215
-     *    the_venue_rssjs_feed
216
-     *
217
-     * @access    public
218
-     * @param    object $item
219
-     * @return    void
220
-     */
221
-    public static function the_venue_rssjs_feed($item)
222
-    {
223
-        if (is_feed() && isset($item->description)) {
224
-            $item->description = EED_Feeds::the_venue_feed($item->description);
225
-        }
226
-        return $item;
227
-    }
14
+	/**
15
+	 * @return EED_Feeds
16
+	 */
17
+	public static function instance()
18
+	{
19
+		return parent::get_instance(__CLASS__);
20
+	}
21
+
22
+
23
+	/**
24
+	 *    set_hooks - for hooking into EE Core, other modules, etc
25
+	 *
26
+	 * @access    public
27
+	 * @return    void
28
+	 */
29
+	public static function set_hooks()
30
+	{
31
+		add_action('parse_request', array('EED_Feeds', 'parse_request'), 10);
32
+		add_filter('default_feed', array('EED_Feeds', 'default_feed'), 10, 1);
33
+		add_filter('comment_feed_join', array('EED_Feeds', 'comment_feed_join'), 10, 2);
34
+		add_filter('comment_feed_where', array('EED_Feeds', 'comment_feed_where'), 10, 2);
35
+	}
36
+
37
+	/**
38
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
39
+	 *
40
+	 * @access    public
41
+	 * @return    void
42
+	 */
43
+	public static function set_hooks_admin()
44
+	{
45
+	}
46
+
47
+
48
+	/**
49
+	 *    run - initial module setup
50
+	 *
51
+	 * @access    public
52
+	 * @return    void
53
+	 */
54
+	public function run($WP)
55
+	{
56
+	}
57
+
58
+
59
+	/**
60
+	 *    default_feed
61
+	 *
62
+	 * @access    public
63
+	 * @param    type    rss2, atom, rss, rdf, rssjs
64
+	 * @return    string
65
+	 */
66
+	public static function default_feed($type = 'rss2')
67
+	{
68
+		// rss2, atom, rss, rdf, rssjs
69
+		$type = 'rss2';
70
+		return $type;
71
+	}
72
+
73
+
74
+	/**
75
+	 *    parse_request
76
+	 *
77
+	 * @access    public
78
+	 * @return    void
79
+	 */
80
+	public static function parse_request()
81
+	{
82
+		$request = self::getRequest();
83
+		if ($request->requestParamIsSet('post_type')) {
84
+			// define path to templates
85
+			define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
86
+			// what kinda post_type are we dealing with ?
87
+			switch ($request->getRequestParam('post_type')) {
88
+				case 'espresso_events':
89
+					// for rss2, atom, rss, rdf
90
+					add_filter('the_excerpt_rss', array('EED_Feeds', 'the_event_feed'), 10, 1);
91
+					add_filter('the_content_feed', array('EED_Feeds', 'the_event_feed'), 10, 1);
92
+					// for json ( also uses the above filter )
93
+					add_filter('rssjs_feed_item', array('EED_Feeds', 'the_event_rssjs_feed'), 10, 1);
94
+					break;
95
+				case 'espresso_venues':
96
+					// for rss2, atom, rss, rdf
97
+					add_filter('the_excerpt_rss', array('EED_Feeds', 'the_venue_feed'), 10, 1);
98
+					add_filter('the_content_feed', array('EED_Feeds', 'the_venue_feed'), 10, 1);
99
+					// for json ( also uses the above filter )
100
+					add_filter('rssjs_feed_item', array('EED_Feeds', 'the_venue_rssjs_feed'), 10, 1);
101
+					break;
102
+			}
103
+		}
104
+	}
105
+
106
+
107
+	/**
108
+	 *    comment_feed_join - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
109
+	 *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
110
+	 *    so this little snippet of SQL taps into the comment feed query and removes comments for the
111
+	 *    espresso_attendees post_type
112
+	 *
113
+	 * @access    public
114
+	 * @param    string $SQL the JOIN clause for the comment feed query
115
+	 * @return    void
116
+	 */
117
+	public static function comment_feed_join($SQL)
118
+	{
119
+		global $wpdb;
120
+		// check for wp_posts table in JOIN clause
121
+		if (strpos($SQL, $wpdb->posts) !== false) {
122
+			add_filter('EED_Feeds__comment_feed_where__espresso_attendees', '__return_true');
123
+		}
124
+		return $SQL;
125
+	}
126
+
127
+
128
+	/**
129
+	 *    comment_feed_where - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
130
+	 *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
131
+	 *    so this little snippet of SQL taps into the comment feed query and removes comments for the
132
+	 *    espresso_attendees post_type
133
+	 *
134
+	 * @access    public
135
+	 * @param    string $SQL the WHERE clause for the comment feed query
136
+	 * @return    void
137
+	 */
138
+	public static function comment_feed_where($SQL)
139
+	{
140
+		global $wp_query, $wpdb;
141
+		if ($wp_query->is_comment_feed && apply_filters('EED_Feeds__comment_feed_where__espresso_attendees', false)) {
142
+			$SQL .= " AND $wpdb->posts.post_type != 'espresso_attendees'";
143
+		}
144
+		return $SQL;
145
+	}
146
+
147
+
148
+	/**
149
+	 *    the_event_feed
150
+	 *
151
+	 * @access    public
152
+	 * @param    string $content
153
+	 * @return    void
154
+	 */
155
+	public static function the_event_feed($content)
156
+	{
157
+		if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) {
158
+			global $post;
159
+			$template_args = array(
160
+				'EVT_ID'            => $post->ID,
161
+				'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
162
+			);
163
+			$content = EEH_Template::display_template(
164
+				RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php',
165
+				$template_args,
166
+				true
167
+			);
168
+		}
169
+		return $content;
170
+	}
171
+
172
+
173
+	/**
174
+	 *    the_event_rssjs_feed
175
+	 *
176
+	 * @access    public
177
+	 * @param    object $item
178
+	 * @return    void
179
+	 */
180
+	public static function the_event_rssjs_feed($item)
181
+	{
182
+		if (is_feed() && isset($item->description)) {
183
+			$item->description = EED_Feeds::the_event_feed($item->description);
184
+		}
185
+		return $item;
186
+	}
187
+
188
+
189
+	/**
190
+	 *    the_venue_feed
191
+	 *
192
+	 * @access    public
193
+	 * @param    string $content
194
+	 * @return    void
195
+	 */
196
+	public static function the_venue_feed($content)
197
+	{
198
+		if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) {
199
+			global $post;
200
+			$template_args = array(
201
+				'VNU_ID'            => $post->ID,
202
+				'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
203
+			);
204
+			$content = EEH_Template::display_template(
205
+				RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php',
206
+				$template_args,
207
+				true
208
+			);
209
+		}
210
+		return $content;
211
+	}
212
+
213
+
214
+	/**
215
+	 *    the_venue_rssjs_feed
216
+	 *
217
+	 * @access    public
218
+	 * @param    object $item
219
+	 * @return    void
220
+	 */
221
+	public static function the_venue_rssjs_feed($item)
222
+	{
223
+		if (is_feed() && isset($item->description)) {
224
+			$item->description = EED_Feeds::the_venue_feed($item->description);
225
+		}
226
+		return $item;
227
+	}
228 228
 }
Please login to merge, or discard this patch.
modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
      */
229 229
     public function set_submit_button_text($submit_button_text = '')
230 230
     {
231
-        if (! empty($submit_button_text)) {
231
+        if ( ! empty($submit_button_text)) {
232 232
             $this->_submit_button_text = $submit_button_text;
233 233
         } elseif ($this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
234 234
             if ($this->checkout->revisit) {
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
     public function reg_form_name()
389 389
     {
390 390
         if (empty($this->_reg_form_name)) {
391
-            $this->set_reg_form_name('ee-spco-' . $this->slug() . '-reg-step-form');
391
+            $this->set_reg_form_name('ee-spco-'.$this->slug().'-reg-step-form');
392 392
         }
393 393
         return $this->_reg_form_name;
394 394
     }
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
     public function reg_step_url($action = '')
413 413
     {
414 414
         $query_args = ['step' => $this->slug()];
415
-        if (! empty($action)) {
415
+        if ( ! empty($action)) {
416 416
             $query_args['action'] = $action;
417 417
         }
418 418
         // final step has no display
@@ -442,12 +442,12 @@  discard block
 block discarded – undo
442 442
             return new EE_Form_Section_Proper(
443 443
                 [
444 444
                     'layout_strategy' => new EE_Div_Per_Section_Layout(),
445
-                    'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
445
+                    'html_id'         => 'ee-'.$this->slug().'-hidden-inputs',
446 446
                     'subsections'     => [
447 447
                         'next_step' => new EE_Fixed_Hidden_Input(
448 448
                             [
449 449
                                 'html_name' => 'next_step',
450
-                                'html_id'   => 'spco-' . $this->slug() . '-next-step',
450
+                                'html_id'   => 'spco-'.$this->slug().'-next-step',
451 451
                                 'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
452 452
                                     ? $this->checkout->next_step->slug()
453 453
                                     : '',
@@ -461,12 +461,12 @@  discard block
 block discarded – undo
461 461
         return new EE_Form_Section_Proper(
462 462
             [
463 463
                 'layout_strategy' => new EE_Div_Per_Section_Layout(),
464
-                'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
464
+                'html_id'         => 'ee-'.$this->slug().'-hidden-inputs',
465 465
                 'subsections'     => [
466 466
                     'action'         => new EE_Fixed_Hidden_Input(
467 467
                         [
468 468
                             'html_name' => 'action',
469
-                            'html_id'   => 'spco-' . $this->slug() . '-action',
469
+                            'html_id'   => 'spco-'.$this->slug().'-action',
470 470
                             'default'   => apply_filters(
471 471
                                 'FHEE__EE_SPCO_Reg_Step__reg_step_hidden_inputs__default_form_action',
472 472
                                 empty($this->checkout->reg_url_link)
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
                     'next_step'      => new EE_Fixed_Hidden_Input(
480 480
                         [
481 481
                             'html_name' => 'next_step',
482
-                            'html_id'   => 'spco-' . $this->slug() . '-next-step',
482
+                            'html_id'   => 'spco-'.$this->slug().'-next-step',
483 483
                             'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
484 484
                                 ? $this->checkout->next_step->slug()
485 485
                                 : '',
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
      */
514 514
     public function generate_reg_form_for_actions($actions = [])
515 515
     {
516
-        $actions                           = array_merge(
516
+        $actions = array_merge(
517 517
             [
518 518
                 'generate_reg_form',
519 519
                 'display_spco_reg_step',
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
      */
557 557
     public function reg_step_submit_button()
558 558
     {
559
-        if (! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
559
+        if ( ! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
560 560
             return '';
561 561
         }
562 562
         ob_start();
@@ -570,18 +570,18 @@  discard block
 block discarded – undo
570 570
         // generate submit button
571 571
         $submit_btn = new EE_Submit_Input(
572 572
             [
573
-                'html_name'             => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
574
-                'html_id'               => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
573
+                'html_name'             => 'spco-go-to-step-'.$this->checkout->next_step->slug(),
574
+                'html_id'               => 'spco-go-to-step-'.$this->checkout->next_step->slug(),
575 575
                 'html_class'            => 'spco-next-step-btn',
576
-                'other_html_attributes' => ' rel="' . $this->slug() . '"',
576
+                'other_html_attributes' => ' rel="'.$this->slug().'"',
577 577
                 'default'               => $this->submit_button_text(),
578 578
             ]
579 579
         );
580 580
         $submit_btn->set_button_css_attributes(true, 'large');
581 581
         $submit_btn_html = $submit_btn->get_html_for_input();
582
-        $html            .= EEH_HTML::div(
582
+        $html .= EEH_HTML::div(
583 583
             apply_filters('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', $submit_btn_html, $this),
584
-            'spco-' . $this->slug() . '-whats-next-buttons-dv',
584
+            'spco-'.$this->slug().'-whats-next-buttons-dv',
585 585
             'spco-whats-next-buttons'
586 586
         );
587 587
         return $html;
Please login to merge, or discard this patch.
Indentation   +644 added lines, -644 removed lines patch added patch discarded remove patch
@@ -13,648 +13,648 @@
 block discarded – undo
13 13
  */
14 14
 abstract class EE_SPCO_Reg_Step
15 15
 {
16
-    /**
17
-     *    $_completed - TRUE if this step has fully completed it's duties
18
-     *
19
-     * @access protected
20
-     * @type bool $_completed
21
-     */
22
-    protected $_completed = false;
23
-
24
-    /**
25
-     *    $_is_current_step - TRUE if this is the current step
26
-     *
27
-     * @access protected
28
-     * @type bool $_is_current_step
29
-     */
30
-    protected $_is_current_step = false;
31
-
32
-    /**
33
-     *    $_order - when the reg step should be run relative to other steps
34
-     *
35
-     * @access protected
36
-     * @type int $_template
37
-     */
38
-    protected $_order = 0;
39
-
40
-    /**
41
-     *    $_slug - URL param for this step
42
-     *
43
-     * @access protected
44
-     * @type string $_slug
45
-     */
46
-    protected $_slug;
47
-
48
-    /**
49
-     *    $_name - Step Name - translatable string
50
-     *
51
-     * @access protected
52
-     * @type string $_slug
53
-     */
54
-    protected $_name;
55
-
56
-    /**
57
-     *    $_submit_button_text - translatable string that appears on this step's submit button
58
-     *
59
-     * @access protected
60
-     * @type string $_slug
61
-     */
62
-    protected $_submit_button_text;
63
-
64
-    /**
65
-     *    $_template - template name
66
-     *
67
-     * @access protected
68
-     * @type string $_template
69
-     */
70
-    protected $_template;
71
-
72
-    /**
73
-     *    $_reg_form_name - the form input name and id attribute
74
-     *
75
-     * @access protected
76
-     * @var string $_reg_form_name
77
-     */
78
-    protected $_reg_form_name;
79
-
80
-    /**
81
-     *    $_success_message - text to display upon successful form submission
82
-     *
83
-     * @access private
84
-     * @var string $_success_message
85
-     */
86
-    protected $_success_message;
87
-
88
-    /**
89
-     *    $_instructions - a brief description of how to complete the reg step.
90
-     *    Usually displayed in conjunction with the previous step's success message.
91
-     *
92
-     * @access private
93
-     * @var string $_instructions
94
-     */
95
-    protected $_instructions;
96
-
97
-    /**
98
-     *    $_valid_data - the normalized and validated data for this step
99
-     *
100
-     * @access public
101
-     * @var array $_valid_data
102
-     */
103
-    protected $_valid_data = [];
104
-
105
-    /**
106
-     *    $reg_form - the registration form for this step
107
-     *
108
-     * @access public
109
-     * @var EE_Form_Section_Proper $reg_form
110
-     */
111
-    public $reg_form;
112
-
113
-    /**
114
-     *    $checkout - EE_Checkout object for handling the properties of the current checkout process
115
-     *
116
-     * @access public
117
-     * @var EE_Checkout $checkout
118
-     */
119
-    public $checkout;
120
-
121
-    /**
122
-     * @var RequestInterface $request
123
-     */
124
-    protected $request;
125
-
126
-
127
-    /**
128
-     * @return void
129
-     */
130
-    abstract public function translate_js_strings();
131
-
132
-
133
-    /**
134
-     * @return void
135
-     */
136
-    abstract public function enqueue_styles_and_scripts();
137
-
138
-
139
-    /**
140
-     * @return boolean
141
-     */
142
-    abstract public function initialize_reg_step();
143
-
144
-
145
-    /**
146
-     * @return string
147
-     */
148
-    abstract public function generate_reg_form();
149
-
150
-
151
-    /**
152
-     * @return boolean
153
-     */
154
-    abstract public function process_reg_step();
155
-
156
-
157
-    /**
158
-     * @return boolean
159
-     */
160
-    abstract public function update_reg_step();
161
-
162
-
163
-    /**
164
-     * @return boolean
165
-     */
166
-    public function completed()
167
-    {
168
-        return $this->_completed;
169
-    }
170
-
171
-
172
-    /**
173
-     * set_completed - toggles $_completed to TRUE
174
-     */
175
-    public function set_completed()
176
-    {
177
-        // DEBUG LOG
178
-        // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
179
-        $this->_completed = apply_filters('FHEE__EE_SPCO_Reg_Step__set_completed___completed', true, $this);
180
-    }
181
-
182
-
183
-    /**
184
-     * set_completed - toggles $_completed to FALSE
185
-     */
186
-    public function set_not_completed()
187
-    {
188
-        $this->_completed = false;
189
-    }
190
-
191
-
192
-    /**
193
-     * @return string
194
-     */
195
-    public function name()
196
-    {
197
-        return $this->_name;
198
-    }
199
-
200
-
201
-    /**
202
-     * @return string
203
-     */
204
-    public function slug()
205
-    {
206
-        return $this->_slug;
207
-    }
208
-
209
-
210
-    /**
211
-     * submit_button_text
212
-     * the text that appears on the reg step form submit button
213
-     *
214
-     * @return string
215
-     */
216
-    public function submit_button_text()
217
-    {
218
-        return $this->_submit_button_text;
219
-    }
220
-
221
-
222
-    /**
223
-     * set_submit_button_text
224
-     * sets the text that appears on the reg step form submit button
225
-     *
226
-     * @param string $submit_button_text
227
-     */
228
-    public function set_submit_button_text($submit_button_text = '')
229
-    {
230
-        if (! empty($submit_button_text)) {
231
-            $this->_submit_button_text = $submit_button_text;
232
-        } elseif ($this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
233
-            if ($this->checkout->revisit) {
234
-                $this->_submit_button_text = sprintf(
235
-                    esc_html__('Update %s', 'event_espresso'),
236
-                    $this->checkout->current_step->name()
237
-                );
238
-            } else {
239
-                $this->_submit_button_text = sprintf(
240
-                    esc_html__('Proceed to %s', 'event_espresso'),
241
-                    $this->checkout->next_step->name()
242
-                );
243
-            }
244
-        }
245
-        // filters the submit button text
246
-        $this->_submit_button_text = apply_filters(
247
-            'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
248
-            $this->_submit_button_text,
249
-            $this->checkout
250
-        );
251
-    }
252
-
253
-
254
-    /**
255
-     * @param boolean $is_current_step
256
-     */
257
-    public function set_is_current_step($is_current_step)
258
-    {
259
-        $this->_is_current_step = $is_current_step;
260
-    }
261
-
262
-
263
-    /**
264
-     * @return boolean
265
-     */
266
-    public function is_current_step()
267
-    {
268
-        return $this->_is_current_step;
269
-    }
270
-
271
-
272
-    /**
273
-     * @return boolean
274
-     */
275
-    public function is_final_step()
276
-    {
277
-        return $this instanceof EE_SPCO_Reg_Step_Finalize_Registration;
278
-    }
279
-
280
-
281
-    /**
282
-     * @param int $order
283
-     */
284
-    public function set_order($order)
285
-    {
286
-        $this->_order = $order;
287
-    }
288
-
289
-
290
-    /**
291
-     * @return int
292
-     */
293
-    public function order()
294
-    {
295
-        return $this->_order;
296
-    }
297
-
298
-
299
-    /**
300
-     * @return string
301
-     */
302
-    public function template()
303
-    {
304
-        return $this->_template;
305
-    }
306
-
307
-
308
-    /**
309
-     * @return string
310
-     */
311
-    public function success_message()
312
-    {
313
-        return $this->_success_message;
314
-    }
315
-
316
-
317
-    /**
318
-     * _set_success_message
319
-     *
320
-     * @param string $success_message
321
-     */
322
-    protected function _set_success_message($success_message)
323
-    {
324
-        $this->_success_message = $success_message;
325
-    }
326
-
327
-
328
-    /**
329
-     * _reset_success_message
330
-     *
331
-     * @return void
332
-     */
333
-    protected function _reset_success_message()
334
-    {
335
-        $this->_success_message = '';
336
-    }
337
-
338
-
339
-    /**
340
-     * @return string
341
-     */
342
-    public function _instructions()
343
-    {
344
-        return $this->_instructions;
345
-    }
346
-
347
-
348
-    /**
349
-     * @param string $instructions
350
-     */
351
-    public function set_instructions($instructions)
352
-    {
353
-        $this->_instructions = apply_filters(
354
-            'FHEE__EE_SPCO_Reg_Step__set_instructions__instructions',
355
-            $instructions,
356
-            $this
357
-        );
358
-    }
359
-
360
-
361
-    /**
362
-     * @param array $valid_data
363
-     */
364
-    public function set_valid_data($valid_data)
365
-    {
366
-        $this->_valid_data = $valid_data;
367
-    }
368
-
369
-
370
-    /**
371
-     * @return array
372
-     * @throws EE_Error
373
-     * @throws EE_Error
374
-     */
375
-    public function valid_data()
376
-    {
377
-        if (empty($this->_valid_data)) {
378
-            $this->_valid_data = $this->reg_form->valid_data();
379
-        }
380
-        return $this->_valid_data;
381
-    }
382
-
383
-
384
-    /**
385
-     * @return string
386
-     */
387
-    public function reg_form_name()
388
-    {
389
-        if (empty($this->_reg_form_name)) {
390
-            $this->set_reg_form_name('ee-spco-' . $this->slug() . '-reg-step-form');
391
-        }
392
-        return $this->_reg_form_name;
393
-    }
394
-
395
-
396
-    /**
397
-     * @param string $reg_form_name
398
-     */
399
-    protected function set_reg_form_name($reg_form_name)
400
-    {
401
-        $this->_reg_form_name = $reg_form_name;
402
-    }
403
-
404
-
405
-    /**
406
-     * reg_step_url
407
-     *
408
-     * @param string $action
409
-     * @return string
410
-     */
411
-    public function reg_step_url($action = '')
412
-    {
413
-        $query_args = ['step' => $this->slug()];
414
-        if (! empty($action)) {
415
-            $query_args['action'] = $action;
416
-        }
417
-        // final step has no display
418
-        if ($this instanceof EE_SPCO_Reg_Step_Finalize_Registration && $action === 'display_spco_reg_step') {
419
-            $query_args['action'] = 'process_reg_step';
420
-        }
421
-        if ($this->checkout->revisit) {
422
-            $query_args['revisit'] = true;
423
-        }
424
-        if ($this->checkout->reg_url_link) {
425
-            $query_args['e_reg_url_link'] = $this->checkout->reg_url_link;
426
-        }
427
-        return add_query_arg($query_args, $this->checkout->reg_page_base_url);
428
-    }
429
-
430
-
431
-    /**
432
-     * creates the default hidden inputs section
433
-     *
434
-     * @return EE_Form_Section_Proper
435
-     * @throws EE_Error
436
-     */
437
-    public function reg_step_hidden_inputs()
438
-    {
439
-        // hidden inputs for admin registrations
440
-        if ($this->checkout->admin_request) {
441
-            return new EE_Form_Section_Proper(
442
-                [
443
-                    'layout_strategy' => new EE_Div_Per_Section_Layout(),
444
-                    'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
445
-                    'subsections'     => [
446
-                        'next_step' => new EE_Fixed_Hidden_Input(
447
-                            [
448
-                                'html_name' => 'next_step',
449
-                                'html_id'   => 'spco-' . $this->slug() . '-next-step',
450
-                                'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
451
-                                    ? $this->checkout->next_step->slug()
452
-                                    : '',
453
-                            ]
454
-                        ),
455
-                    ],
456
-                ]
457
-            );
458
-        }
459
-        // hidden inputs for frontend registrations
460
-        return new EE_Form_Section_Proper(
461
-            [
462
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
463
-                'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
464
-                'subsections'     => [
465
-                    'action'         => new EE_Fixed_Hidden_Input(
466
-                        [
467
-                            'html_name' => 'action',
468
-                            'html_id'   => 'spco-' . $this->slug() . '-action',
469
-                            'default'   => apply_filters(
470
-                                'FHEE__EE_SPCO_Reg_Step__reg_step_hidden_inputs__default_form_action',
471
-                                empty($this->checkout->reg_url_link)
472
-                                    ? 'process_reg_step'
473
-                                    : 'update_reg_step',
474
-                                $this
475
-                            ),
476
-                        ]
477
-                    ),
478
-                    'next_step'      => new EE_Fixed_Hidden_Input(
479
-                        [
480
-                            'html_name' => 'next_step',
481
-                            'html_id'   => 'spco-' . $this->slug() . '-next-step',
482
-                            'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
483
-                                ? $this->checkout->next_step->slug()
484
-                                : '',
485
-                        ]
486
-                    ),
487
-                    'e_reg_url_link' => new EE_Fixed_Hidden_Input(
488
-                        [
489
-                            'html_name' => 'e_reg_url_link',
490
-                            'html_id'   => 'spco-reg_url_link',
491
-                            'default'   => $this->checkout->reg_url_link,
492
-                        ]
493
-                    ),
494
-                    'revisit'        => new EE_Fixed_Hidden_Input(
495
-                        [
496
-                            'html_name' => 'revisit',
497
-                            'html_id'   => 'spco-revisit',
498
-                            'default'   => $this->checkout->revisit,
499
-                        ]
500
-                    ),
501
-                ],
502
-            ]
503
-        );
504
-    }
505
-
506
-
507
-    /**
508
-     * generate_reg_form_for_actions
509
-     *
510
-     * @param array $actions
511
-     * @return void
512
-     */
513
-    public function generate_reg_form_for_actions($actions = [])
514
-    {
515
-        $actions                           = array_merge(
516
-            [
517
-                'generate_reg_form',
518
-                'display_spco_reg_step',
519
-                'process_reg_step',
520
-                'update_reg_step',
521
-            ],
522
-            $actions
523
-        );
524
-        $this->checkout->generate_reg_form = in_array($this->checkout->action, $actions, true);
525
-    }
526
-
527
-
528
-    /**
529
-     * @return string
530
-     * @throws EE_Error
531
-     */
532
-    public function display_reg_form()
533
-    {
534
-        $html = '';
535
-        if ($this->reg_form instanceof EE_Form_Section_Proper) {
536
-            do_action('AHEE__EE_SPCO_Reg_Step__display_reg_form__reg_form', $this->reg_form, $this);
537
-            $html .= ! $this->checkout->admin_request ? $this->reg_form->form_open($this->reg_step_url()) : '';
538
-            if ($this->request->isAjax()) {
539
-                $this->reg_form->localize_validation_rules();
540
-                $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
541
-            }
542
-            $html .= $this->reg_form->get_html();
543
-            $html .= ! $this->checkout->admin_request ? $this->reg_step_submit_button() : '';
544
-            $html .= ! $this->checkout->admin_request ? $this->reg_form->form_close() : '';
545
-        }
546
-        return $html;
547
-    }
548
-
549
-
550
-    /**
551
-     * div_class - returns nothing for current step, but a css class of "hidden" for others
552
-     *
553
-     * @return string
554
-     * @throws EE_Error
555
-     */
556
-    public function reg_step_submit_button()
557
-    {
558
-        if (! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
559
-            return '';
560
-        }
561
-        ob_start();
562
-        do_action(
563
-            'AHEE__before_spco_whats_next_buttons',
564
-            $this->slug(),
565
-            $this->checkout->next_step->slug(),
566
-            $this->checkout
567
-        );
568
-        $html = ob_get_clean();
569
-        // generate submit button
570
-        $submit_btn = new EE_Submit_Input(
571
-            [
572
-                'html_name'             => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
573
-                'html_id'               => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
574
-                'html_class'            => 'spco-next-step-btn',
575
-                'other_html_attributes' => ' rel="' . $this->slug() . '"',
576
-                'default'               => $this->submit_button_text(),
577
-            ]
578
-        );
579
-        $submit_btn->set_button_css_attributes(true, 'large');
580
-        $submit_btn_html = $submit_btn->get_html_for_input();
581
-        $html            .= EEH_HTML::div(
582
-            apply_filters('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', $submit_btn_html, $this),
583
-            'spco-' . $this->slug() . '-whats-next-buttons-dv',
584
-            'spco-whats-next-buttons'
585
-        );
586
-        return $html;
587
-    }
588
-
589
-
590
-    /**
591
-     * div_class - returns nothing for current step, but a css class of "hidden" for others
592
-     *
593
-     * @return string
594
-     */
595
-    public function div_class()
596
-    {
597
-        return $this->is_current_step() ? '' : ' hidden';
598
-    }
599
-
600
-
601
-    /**
602
-     * div_class - returns  a css class of "hidden" for current step, but nothing for others
603
-     *
604
-     * @return string
605
-     */
606
-    public function edit_lnk_url()
607
-    {
608
-        return add_query_arg(['step' => $this->slug()], $this->checkout->reg_page_base_url);
609
-    }
610
-
611
-
612
-    /**
613
-     * div_class - returns  a css class of "hidden" for current step, but nothing for others
614
-     *
615
-     * @return string
616
-     */
617
-    public function edit_link_class()
618
-    {
619
-        return $this->is_current_step() ? ' hidden' : '';
620
-    }
621
-
622
-
623
-    /**
624
-     * update_checkout with changes that have been made to the cart
625
-     *
626
-     * @return void
627
-     * @throws EE_Error
628
-     * @throws ReflectionException
629
-     */
630
-    public function update_checkout()
631
-    {
632
-        // grab the cart grand total and reset TXN total
633
-        $this->checkout->transaction->set_total($this->checkout->cart->get_cart_grand_total());
634
-        $this->checkout->stash_transaction_and_checkout();
635
-    }
636
-
637
-
638
-    /**
639
-     *    __sleep
640
-     * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon
641
-     * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the
642
-     * reg form, because if needed, it will be regenerated anyways
643
-     *
644
-     * @return array
645
-     */
646
-    public function __sleep()
647
-    {
648
-        // remove the reg form and the checkout
649
-        return array_diff(array_keys(get_object_vars($this)), ['reg_form', 'checkout']);
650
-    }
651
-
652
-
653
-    /**
654
-     * @param RequestInterface $request
655
-     */
656
-    public function setRequest(RequestInterface $request)
657
-    {
658
-        $this->request = $request;
659
-    }
16
+	/**
17
+	 *    $_completed - TRUE if this step has fully completed it's duties
18
+	 *
19
+	 * @access protected
20
+	 * @type bool $_completed
21
+	 */
22
+	protected $_completed = false;
23
+
24
+	/**
25
+	 *    $_is_current_step - TRUE if this is the current step
26
+	 *
27
+	 * @access protected
28
+	 * @type bool $_is_current_step
29
+	 */
30
+	protected $_is_current_step = false;
31
+
32
+	/**
33
+	 *    $_order - when the reg step should be run relative to other steps
34
+	 *
35
+	 * @access protected
36
+	 * @type int $_template
37
+	 */
38
+	protected $_order = 0;
39
+
40
+	/**
41
+	 *    $_slug - URL param for this step
42
+	 *
43
+	 * @access protected
44
+	 * @type string $_slug
45
+	 */
46
+	protected $_slug;
47
+
48
+	/**
49
+	 *    $_name - Step Name - translatable string
50
+	 *
51
+	 * @access protected
52
+	 * @type string $_slug
53
+	 */
54
+	protected $_name;
55
+
56
+	/**
57
+	 *    $_submit_button_text - translatable string that appears on this step's submit button
58
+	 *
59
+	 * @access protected
60
+	 * @type string $_slug
61
+	 */
62
+	protected $_submit_button_text;
63
+
64
+	/**
65
+	 *    $_template - template name
66
+	 *
67
+	 * @access protected
68
+	 * @type string $_template
69
+	 */
70
+	protected $_template;
71
+
72
+	/**
73
+	 *    $_reg_form_name - the form input name and id attribute
74
+	 *
75
+	 * @access protected
76
+	 * @var string $_reg_form_name
77
+	 */
78
+	protected $_reg_form_name;
79
+
80
+	/**
81
+	 *    $_success_message - text to display upon successful form submission
82
+	 *
83
+	 * @access private
84
+	 * @var string $_success_message
85
+	 */
86
+	protected $_success_message;
87
+
88
+	/**
89
+	 *    $_instructions - a brief description of how to complete the reg step.
90
+	 *    Usually displayed in conjunction with the previous step's success message.
91
+	 *
92
+	 * @access private
93
+	 * @var string $_instructions
94
+	 */
95
+	protected $_instructions;
96
+
97
+	/**
98
+	 *    $_valid_data - the normalized and validated data for this step
99
+	 *
100
+	 * @access public
101
+	 * @var array $_valid_data
102
+	 */
103
+	protected $_valid_data = [];
104
+
105
+	/**
106
+	 *    $reg_form - the registration form for this step
107
+	 *
108
+	 * @access public
109
+	 * @var EE_Form_Section_Proper $reg_form
110
+	 */
111
+	public $reg_form;
112
+
113
+	/**
114
+	 *    $checkout - EE_Checkout object for handling the properties of the current checkout process
115
+	 *
116
+	 * @access public
117
+	 * @var EE_Checkout $checkout
118
+	 */
119
+	public $checkout;
120
+
121
+	/**
122
+	 * @var RequestInterface $request
123
+	 */
124
+	protected $request;
125
+
126
+
127
+	/**
128
+	 * @return void
129
+	 */
130
+	abstract public function translate_js_strings();
131
+
132
+
133
+	/**
134
+	 * @return void
135
+	 */
136
+	abstract public function enqueue_styles_and_scripts();
137
+
138
+
139
+	/**
140
+	 * @return boolean
141
+	 */
142
+	abstract public function initialize_reg_step();
143
+
144
+
145
+	/**
146
+	 * @return string
147
+	 */
148
+	abstract public function generate_reg_form();
149
+
150
+
151
+	/**
152
+	 * @return boolean
153
+	 */
154
+	abstract public function process_reg_step();
155
+
156
+
157
+	/**
158
+	 * @return boolean
159
+	 */
160
+	abstract public function update_reg_step();
161
+
162
+
163
+	/**
164
+	 * @return boolean
165
+	 */
166
+	public function completed()
167
+	{
168
+		return $this->_completed;
169
+	}
170
+
171
+
172
+	/**
173
+	 * set_completed - toggles $_completed to TRUE
174
+	 */
175
+	public function set_completed()
176
+	{
177
+		// DEBUG LOG
178
+		// $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
179
+		$this->_completed = apply_filters('FHEE__EE_SPCO_Reg_Step__set_completed___completed', true, $this);
180
+	}
181
+
182
+
183
+	/**
184
+	 * set_completed - toggles $_completed to FALSE
185
+	 */
186
+	public function set_not_completed()
187
+	{
188
+		$this->_completed = false;
189
+	}
190
+
191
+
192
+	/**
193
+	 * @return string
194
+	 */
195
+	public function name()
196
+	{
197
+		return $this->_name;
198
+	}
199
+
200
+
201
+	/**
202
+	 * @return string
203
+	 */
204
+	public function slug()
205
+	{
206
+		return $this->_slug;
207
+	}
208
+
209
+
210
+	/**
211
+	 * submit_button_text
212
+	 * the text that appears on the reg step form submit button
213
+	 *
214
+	 * @return string
215
+	 */
216
+	public function submit_button_text()
217
+	{
218
+		return $this->_submit_button_text;
219
+	}
220
+
221
+
222
+	/**
223
+	 * set_submit_button_text
224
+	 * sets the text that appears on the reg step form submit button
225
+	 *
226
+	 * @param string $submit_button_text
227
+	 */
228
+	public function set_submit_button_text($submit_button_text = '')
229
+	{
230
+		if (! empty($submit_button_text)) {
231
+			$this->_submit_button_text = $submit_button_text;
232
+		} elseif ($this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
233
+			if ($this->checkout->revisit) {
234
+				$this->_submit_button_text = sprintf(
235
+					esc_html__('Update %s', 'event_espresso'),
236
+					$this->checkout->current_step->name()
237
+				);
238
+			} else {
239
+				$this->_submit_button_text = sprintf(
240
+					esc_html__('Proceed to %s', 'event_espresso'),
241
+					$this->checkout->next_step->name()
242
+				);
243
+			}
244
+		}
245
+		// filters the submit button text
246
+		$this->_submit_button_text = apply_filters(
247
+			'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
248
+			$this->_submit_button_text,
249
+			$this->checkout
250
+		);
251
+	}
252
+
253
+
254
+	/**
255
+	 * @param boolean $is_current_step
256
+	 */
257
+	public function set_is_current_step($is_current_step)
258
+	{
259
+		$this->_is_current_step = $is_current_step;
260
+	}
261
+
262
+
263
+	/**
264
+	 * @return boolean
265
+	 */
266
+	public function is_current_step()
267
+	{
268
+		return $this->_is_current_step;
269
+	}
270
+
271
+
272
+	/**
273
+	 * @return boolean
274
+	 */
275
+	public function is_final_step()
276
+	{
277
+		return $this instanceof EE_SPCO_Reg_Step_Finalize_Registration;
278
+	}
279
+
280
+
281
+	/**
282
+	 * @param int $order
283
+	 */
284
+	public function set_order($order)
285
+	{
286
+		$this->_order = $order;
287
+	}
288
+
289
+
290
+	/**
291
+	 * @return int
292
+	 */
293
+	public function order()
294
+	{
295
+		return $this->_order;
296
+	}
297
+
298
+
299
+	/**
300
+	 * @return string
301
+	 */
302
+	public function template()
303
+	{
304
+		return $this->_template;
305
+	}
306
+
307
+
308
+	/**
309
+	 * @return string
310
+	 */
311
+	public function success_message()
312
+	{
313
+		return $this->_success_message;
314
+	}
315
+
316
+
317
+	/**
318
+	 * _set_success_message
319
+	 *
320
+	 * @param string $success_message
321
+	 */
322
+	protected function _set_success_message($success_message)
323
+	{
324
+		$this->_success_message = $success_message;
325
+	}
326
+
327
+
328
+	/**
329
+	 * _reset_success_message
330
+	 *
331
+	 * @return void
332
+	 */
333
+	protected function _reset_success_message()
334
+	{
335
+		$this->_success_message = '';
336
+	}
337
+
338
+
339
+	/**
340
+	 * @return string
341
+	 */
342
+	public function _instructions()
343
+	{
344
+		return $this->_instructions;
345
+	}
346
+
347
+
348
+	/**
349
+	 * @param string $instructions
350
+	 */
351
+	public function set_instructions($instructions)
352
+	{
353
+		$this->_instructions = apply_filters(
354
+			'FHEE__EE_SPCO_Reg_Step__set_instructions__instructions',
355
+			$instructions,
356
+			$this
357
+		);
358
+	}
359
+
360
+
361
+	/**
362
+	 * @param array $valid_data
363
+	 */
364
+	public function set_valid_data($valid_data)
365
+	{
366
+		$this->_valid_data = $valid_data;
367
+	}
368
+
369
+
370
+	/**
371
+	 * @return array
372
+	 * @throws EE_Error
373
+	 * @throws EE_Error
374
+	 */
375
+	public function valid_data()
376
+	{
377
+		if (empty($this->_valid_data)) {
378
+			$this->_valid_data = $this->reg_form->valid_data();
379
+		}
380
+		return $this->_valid_data;
381
+	}
382
+
383
+
384
+	/**
385
+	 * @return string
386
+	 */
387
+	public function reg_form_name()
388
+	{
389
+		if (empty($this->_reg_form_name)) {
390
+			$this->set_reg_form_name('ee-spco-' . $this->slug() . '-reg-step-form');
391
+		}
392
+		return $this->_reg_form_name;
393
+	}
394
+
395
+
396
+	/**
397
+	 * @param string $reg_form_name
398
+	 */
399
+	protected function set_reg_form_name($reg_form_name)
400
+	{
401
+		$this->_reg_form_name = $reg_form_name;
402
+	}
403
+
404
+
405
+	/**
406
+	 * reg_step_url
407
+	 *
408
+	 * @param string $action
409
+	 * @return string
410
+	 */
411
+	public function reg_step_url($action = '')
412
+	{
413
+		$query_args = ['step' => $this->slug()];
414
+		if (! empty($action)) {
415
+			$query_args['action'] = $action;
416
+		}
417
+		// final step has no display
418
+		if ($this instanceof EE_SPCO_Reg_Step_Finalize_Registration && $action === 'display_spco_reg_step') {
419
+			$query_args['action'] = 'process_reg_step';
420
+		}
421
+		if ($this->checkout->revisit) {
422
+			$query_args['revisit'] = true;
423
+		}
424
+		if ($this->checkout->reg_url_link) {
425
+			$query_args['e_reg_url_link'] = $this->checkout->reg_url_link;
426
+		}
427
+		return add_query_arg($query_args, $this->checkout->reg_page_base_url);
428
+	}
429
+
430
+
431
+	/**
432
+	 * creates the default hidden inputs section
433
+	 *
434
+	 * @return EE_Form_Section_Proper
435
+	 * @throws EE_Error
436
+	 */
437
+	public function reg_step_hidden_inputs()
438
+	{
439
+		// hidden inputs for admin registrations
440
+		if ($this->checkout->admin_request) {
441
+			return new EE_Form_Section_Proper(
442
+				[
443
+					'layout_strategy' => new EE_Div_Per_Section_Layout(),
444
+					'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
445
+					'subsections'     => [
446
+						'next_step' => new EE_Fixed_Hidden_Input(
447
+							[
448
+								'html_name' => 'next_step',
449
+								'html_id'   => 'spco-' . $this->slug() . '-next-step',
450
+								'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
451
+									? $this->checkout->next_step->slug()
452
+									: '',
453
+							]
454
+						),
455
+					],
456
+				]
457
+			);
458
+		}
459
+		// hidden inputs for frontend registrations
460
+		return new EE_Form_Section_Proper(
461
+			[
462
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
463
+				'html_id'         => 'ee-' . $this->slug() . '-hidden-inputs',
464
+				'subsections'     => [
465
+					'action'         => new EE_Fixed_Hidden_Input(
466
+						[
467
+							'html_name' => 'action',
468
+							'html_id'   => 'spco-' . $this->slug() . '-action',
469
+							'default'   => apply_filters(
470
+								'FHEE__EE_SPCO_Reg_Step__reg_step_hidden_inputs__default_form_action',
471
+								empty($this->checkout->reg_url_link)
472
+									? 'process_reg_step'
473
+									: 'update_reg_step',
474
+								$this
475
+							),
476
+						]
477
+					),
478
+					'next_step'      => new EE_Fixed_Hidden_Input(
479
+						[
480
+							'html_name' => 'next_step',
481
+							'html_id'   => 'spco-' . $this->slug() . '-next-step',
482
+							'default'   => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
483
+								? $this->checkout->next_step->slug()
484
+								: '',
485
+						]
486
+					),
487
+					'e_reg_url_link' => new EE_Fixed_Hidden_Input(
488
+						[
489
+							'html_name' => 'e_reg_url_link',
490
+							'html_id'   => 'spco-reg_url_link',
491
+							'default'   => $this->checkout->reg_url_link,
492
+						]
493
+					),
494
+					'revisit'        => new EE_Fixed_Hidden_Input(
495
+						[
496
+							'html_name' => 'revisit',
497
+							'html_id'   => 'spco-revisit',
498
+							'default'   => $this->checkout->revisit,
499
+						]
500
+					),
501
+				],
502
+			]
503
+		);
504
+	}
505
+
506
+
507
+	/**
508
+	 * generate_reg_form_for_actions
509
+	 *
510
+	 * @param array $actions
511
+	 * @return void
512
+	 */
513
+	public function generate_reg_form_for_actions($actions = [])
514
+	{
515
+		$actions                           = array_merge(
516
+			[
517
+				'generate_reg_form',
518
+				'display_spco_reg_step',
519
+				'process_reg_step',
520
+				'update_reg_step',
521
+			],
522
+			$actions
523
+		);
524
+		$this->checkout->generate_reg_form = in_array($this->checkout->action, $actions, true);
525
+	}
526
+
527
+
528
+	/**
529
+	 * @return string
530
+	 * @throws EE_Error
531
+	 */
532
+	public function display_reg_form()
533
+	{
534
+		$html = '';
535
+		if ($this->reg_form instanceof EE_Form_Section_Proper) {
536
+			do_action('AHEE__EE_SPCO_Reg_Step__display_reg_form__reg_form', $this->reg_form, $this);
537
+			$html .= ! $this->checkout->admin_request ? $this->reg_form->form_open($this->reg_step_url()) : '';
538
+			if ($this->request->isAjax()) {
539
+				$this->reg_form->localize_validation_rules();
540
+				$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
541
+			}
542
+			$html .= $this->reg_form->get_html();
543
+			$html .= ! $this->checkout->admin_request ? $this->reg_step_submit_button() : '';
544
+			$html .= ! $this->checkout->admin_request ? $this->reg_form->form_close() : '';
545
+		}
546
+		return $html;
547
+	}
548
+
549
+
550
+	/**
551
+	 * div_class - returns nothing for current step, but a css class of "hidden" for others
552
+	 *
553
+	 * @return string
554
+	 * @throws EE_Error
555
+	 */
556
+	public function reg_step_submit_button()
557
+	{
558
+		if (! $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
559
+			return '';
560
+		}
561
+		ob_start();
562
+		do_action(
563
+			'AHEE__before_spco_whats_next_buttons',
564
+			$this->slug(),
565
+			$this->checkout->next_step->slug(),
566
+			$this->checkout
567
+		);
568
+		$html = ob_get_clean();
569
+		// generate submit button
570
+		$submit_btn = new EE_Submit_Input(
571
+			[
572
+				'html_name'             => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
573
+				'html_id'               => 'spco-go-to-step-' . $this->checkout->next_step->slug(),
574
+				'html_class'            => 'spco-next-step-btn',
575
+				'other_html_attributes' => ' rel="' . $this->slug() . '"',
576
+				'default'               => $this->submit_button_text(),
577
+			]
578
+		);
579
+		$submit_btn->set_button_css_attributes(true, 'large');
580
+		$submit_btn_html = $submit_btn->get_html_for_input();
581
+		$html            .= EEH_HTML::div(
582
+			apply_filters('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', $submit_btn_html, $this),
583
+			'spco-' . $this->slug() . '-whats-next-buttons-dv',
584
+			'spco-whats-next-buttons'
585
+		);
586
+		return $html;
587
+	}
588
+
589
+
590
+	/**
591
+	 * div_class - returns nothing for current step, but a css class of "hidden" for others
592
+	 *
593
+	 * @return string
594
+	 */
595
+	public function div_class()
596
+	{
597
+		return $this->is_current_step() ? '' : ' hidden';
598
+	}
599
+
600
+
601
+	/**
602
+	 * div_class - returns  a css class of "hidden" for current step, but nothing for others
603
+	 *
604
+	 * @return string
605
+	 */
606
+	public function edit_lnk_url()
607
+	{
608
+		return add_query_arg(['step' => $this->slug()], $this->checkout->reg_page_base_url);
609
+	}
610
+
611
+
612
+	/**
613
+	 * div_class - returns  a css class of "hidden" for current step, but nothing for others
614
+	 *
615
+	 * @return string
616
+	 */
617
+	public function edit_link_class()
618
+	{
619
+		return $this->is_current_step() ? ' hidden' : '';
620
+	}
621
+
622
+
623
+	/**
624
+	 * update_checkout with changes that have been made to the cart
625
+	 *
626
+	 * @return void
627
+	 * @throws EE_Error
628
+	 * @throws ReflectionException
629
+	 */
630
+	public function update_checkout()
631
+	{
632
+		// grab the cart grand total and reset TXN total
633
+		$this->checkout->transaction->set_total($this->checkout->cart->get_cart_grand_total());
634
+		$this->checkout->stash_transaction_and_checkout();
635
+	}
636
+
637
+
638
+	/**
639
+	 *    __sleep
640
+	 * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon
641
+	 * serialization EE_Checkout will handle the reimplementation of itself upon waking, but we won't bother with the
642
+	 * reg form, because if needed, it will be regenerated anyways
643
+	 *
644
+	 * @return array
645
+	 */
646
+	public function __sleep()
647
+	{
648
+		// remove the reg form and the checkout
649
+		return array_diff(array_keys(get_object_vars($this)), ['reg_form', 'checkout']);
650
+	}
651
+
652
+
653
+	/**
654
+	 * @param RequestInterface $request
655
+	 */
656
+	public function setRequest(RequestInterface $request)
657
+	{
658
+		$this->request = $request;
659
+	}
660 660
 }
Please login to merge, or discard this patch.
core/services/request/files/FilesDataHandler.php 2 patches
Indentation   +251 added lines, -251 removed lines patch added patch discarded remove patch
@@ -40,279 +40,279 @@
 block discarded – undo
40 40
  */
41 41
 class FilesDataHandler
42 42
 {
43
-    /**
44
-     * @var Request
45
-     */
46
-    protected $request;
43
+	/**
44
+	 * @var Request
45
+	 */
46
+	protected $request;
47 47
 
48
-    /**
49
-     * @var CollectionInterface | FileSubmissionInterface[]
50
-     */
51
-    protected $file_objects;
48
+	/**
49
+	 * @var CollectionInterface | FileSubmissionInterface[]
50
+	 */
51
+	protected $file_objects;
52 52
 
53
-    /**
54
-     * @var bool
55
-     */
56
-    protected $initialized = false;
53
+	/**
54
+	 * @var bool
55
+	 */
56
+	protected $initialized = false;
57 57
 
58 58
 
59
-    /**
60
-     * FilesDataHandler constructor.
61
-     *
62
-     * @param Request $request
63
-     */
64
-    public function __construct(Request $request)
65
-    {
66
-        $this->request = $request;
67
-    }
59
+	/**
60
+	 * FilesDataHandler constructor.
61
+	 *
62
+	 * @param Request $request
63
+	 */
64
+	public function __construct(Request $request)
65
+	{
66
+		$this->request = $request;
67
+	}
68 68
 
69 69
 
70
-    /**
71
-     * @return CollectionInterface | FileSubmissionInterface[]
72
-     * @throws UnexpectedValueException
73
-     * @throws InvalidArgumentException
74
-     * @since 4.9.80.p
75
-     */
76
-    protected function getFileObjects()
77
-    {
78
-        $this->initialize();
79
-        return $this->file_objects;
80
-    }
70
+	/**
71
+	 * @return CollectionInterface | FileSubmissionInterface[]
72
+	 * @throws UnexpectedValueException
73
+	 * @throws InvalidArgumentException
74
+	 * @since 4.9.80.p
75
+	 */
76
+	protected function getFileObjects()
77
+	{
78
+		$this->initialize();
79
+		return $this->file_objects;
80
+	}
81 81
 
82 82
 
83
-    /**
84
-     * Sets up the file objects from the request's $_FILES data.
85
-     *
86
-     * @throws UnexpectedValueException
87
-     * @throws InvalidArgumentException
88
-     * @throws InvalidInterfaceException
89
-     * @since 4.9.80.p
90
-     */
91
-    protected function initialize()
92
-    {
93
-        if ($this->initialized) {
94
-            return;
95
-        }
96
-        $this->file_objects = new Collection(
97
-        // collection interface
98
-            'EventEspresso\core\services\request\files\FileSubmissionInterface',
99
-            // collection name
100
-            'submitted_files'
101
-        );
102
-        $files_raw_data     = $this->request->filesParams();
103
-        if (empty($files_raw_data)) {
104
-            return;
105
-        }
106
-        if ($this->isStrangeFilesArray($files_raw_data)) {
107
-            $data = $this->fixFilesDataArray($files_raw_data);
108
-        } else {
109
-            $data = $files_raw_data;
110
-        }
111
-        $this->createFileObjects($data);
112
-        $this->initialized = true;
113
-    }
83
+	/**
84
+	 * Sets up the file objects from the request's $_FILES data.
85
+	 *
86
+	 * @throws UnexpectedValueException
87
+	 * @throws InvalidArgumentException
88
+	 * @throws InvalidInterfaceException
89
+	 * @since 4.9.80.p
90
+	 */
91
+	protected function initialize()
92
+	{
93
+		if ($this->initialized) {
94
+			return;
95
+		}
96
+		$this->file_objects = new Collection(
97
+		// collection interface
98
+			'EventEspresso\core\services\request\files\FileSubmissionInterface',
99
+			// collection name
100
+			'submitted_files'
101
+		);
102
+		$files_raw_data     = $this->request->filesParams();
103
+		if (empty($files_raw_data)) {
104
+			return;
105
+		}
106
+		if ($this->isStrangeFilesArray($files_raw_data)) {
107
+			$data = $this->fixFilesDataArray($files_raw_data);
108
+		} else {
109
+			$data = $files_raw_data;
110
+		}
111
+		$this->createFileObjects($data);
112
+		$this->initialized = true;
113
+	}
114 114
 
115 115
 
116
-    /**
117
-     * Detects if $_FILES is a weird multi-dimensional array that needs fixing or not.
118
-     *
119
-     * @param $files_data
120
-     * @return bool
121
-     * @throws UnexpectedValueException
122
-     * @since 4.9.80.p
123
-     */
124
-    protected function isStrangeFilesArray($files_data)
125
-    {
126
-        if (! is_array($files_data)) {
127
-            throw new UnexpectedValueException(
128
-                sprintf(
129
-                    esc_html__(
130
-                        'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
131
-                        'event_espresso'
132
-                    ),
133
-                    (string) $files_data
134
-                )
135
-            );
136
-        }
137
-        $first_value = reset($files_data);
138
-        if (! is_array($first_value)) {
139
-            throw new UnexpectedValueException(
140
-                sprintf(
141
-                    esc_html__(
142
-                        'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
143
-                        'event_espresso'
144
-                    ),
145
-                    (string) $first_value
146
-                )
147
-            );
148
-        }
149
-        $first_sub_array_item = reset($first_value);
150
-        if (is_array($first_sub_array_item)) {
151
-            // not just a 2d array
152
-            return true;
153
-        }
154
-        // yep, just 2d array
155
-        return false;
156
-    }
116
+	/**
117
+	 * Detects if $_FILES is a weird multi-dimensional array that needs fixing or not.
118
+	 *
119
+	 * @param $files_data
120
+	 * @return bool
121
+	 * @throws UnexpectedValueException
122
+	 * @since 4.9.80.p
123
+	 */
124
+	protected function isStrangeFilesArray($files_data)
125
+	{
126
+		if (! is_array($files_data)) {
127
+			throw new UnexpectedValueException(
128
+				sprintf(
129
+					esc_html__(
130
+						'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
131
+						'event_espresso'
132
+					),
133
+					(string) $files_data
134
+				)
135
+			);
136
+		}
137
+		$first_value = reset($files_data);
138
+		if (! is_array($first_value)) {
139
+			throw new UnexpectedValueException(
140
+				sprintf(
141
+					esc_html__(
142
+						'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
143
+						'event_espresso'
144
+					),
145
+					(string) $first_value
146
+				)
147
+			);
148
+		}
149
+		$first_sub_array_item = reset($first_value);
150
+		if (is_array($first_sub_array_item)) {
151
+			// not just a 2d array
152
+			return true;
153
+		}
154
+		// yep, just 2d array
155
+		return false;
156
+	}
157 157
 
158 158
 
159
-    /**
160
-     * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file"
161
-     * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with
162
-     * "name", "size", "tmp_name", etc. So that file's data is located at "my[name][hierarchical][form]",
163
-     * "my[size][hierarchical][form]", "my[tmp_name][hierarchical][form]", etc. It's really weird.
164
-     *
165
-     * @param $files_data
166
-     * @return array
167
-     * @since 4.9.80.p
168
-     */
169
-    protected function fixFilesDataArray($files_data)
170
-    {
171
-        $sane_files_array = [];
172
-        foreach ($files_data as $top_level_name => $top_level_children) {
173
-            $sub_array                           = [];
174
-            $sane_files_array[ $top_level_name ] = [];
175
-            foreach ($top_level_children as $file_data_part => $second_level_children) {
176
-                foreach ($second_level_children as $next_level_name => $sub_values) {
177
-                    $sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part);
178
-                }
179
-                $sane_files_array[ $top_level_name ] = array_replace_recursive(
180
-                    $sub_array,
181
-                    $sane_files_array[ $top_level_name ]
182
-                );
183
-            }
184
-        }
185
-        return $sane_files_array;
186
-    }
159
+	/**
160
+	 * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file"
161
+	 * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with
162
+	 * "name", "size", "tmp_name", etc. So that file's data is located at "my[name][hierarchical][form]",
163
+	 * "my[size][hierarchical][form]", "my[tmp_name][hierarchical][form]", etc. It's really weird.
164
+	 *
165
+	 * @param $files_data
166
+	 * @return array
167
+	 * @since 4.9.80.p
168
+	 */
169
+	protected function fixFilesDataArray($files_data)
170
+	{
171
+		$sane_files_array = [];
172
+		foreach ($files_data as $top_level_name => $top_level_children) {
173
+			$sub_array                           = [];
174
+			$sane_files_array[ $top_level_name ] = [];
175
+			foreach ($top_level_children as $file_data_part => $second_level_children) {
176
+				foreach ($second_level_children as $next_level_name => $sub_values) {
177
+					$sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part);
178
+				}
179
+				$sane_files_array[ $top_level_name ] = array_replace_recursive(
180
+					$sub_array,
181
+					$sane_files_array[ $top_level_name ]
182
+				);
183
+			}
184
+		}
185
+		return $sane_files_array;
186
+	}
187 187
 
188 188
 
189
-    /**
190
-     * Recursively explores the array until it finds a leaf node, and tacks `$type` as a final index in front of it.
191
-     *
192
-     * @param $data array|string
193
-     * @param $type 'name', 'tmp_name', 'size', or 'error'
194
-     * @return array
195
-     * @since 4.9.80.p
196
-     */
197
-    protected function organizeFilesData($data, $type)
198
-    {
199
-        if (! is_array($data)) {
200
-            return [
201
-                $type => $data,
202
-            ];
203
-        }
204
-        $organized_data = [];
205
-        foreach ($data as $input_name_part => $sub_inputs_or_value) {
206
-            if (is_array($sub_inputs_or_value)) {
207
-                $organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type);
208
-            } else {
209
-                $organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value;
210
-            }
211
-        }
212
-        return $organized_data;
213
-    }
189
+	/**
190
+	 * Recursively explores the array until it finds a leaf node, and tacks `$type` as a final index in front of it.
191
+	 *
192
+	 * @param $data array|string
193
+	 * @param $type 'name', 'tmp_name', 'size', or 'error'
194
+	 * @return array
195
+	 * @since 4.9.80.p
196
+	 */
197
+	protected function organizeFilesData($data, $type)
198
+	{
199
+		if (! is_array($data)) {
200
+			return [
201
+				$type => $data,
202
+			];
203
+		}
204
+		$organized_data = [];
205
+		foreach ($data as $input_name_part => $sub_inputs_or_value) {
206
+			if (is_array($sub_inputs_or_value)) {
207
+				$organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type);
208
+			} else {
209
+				$organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value;
210
+			}
211
+		}
212
+		return $organized_data;
213
+	}
214 214
 
215 215
 
216
-    /**
217
-     * Takes the organized $_FILES array (where all file info is located at the same spot as you'd expect an input
218
-     * to be in post data, with all the file's data located side-by-side in an array) and creates a
219
-     * multi-dimensional array of FileSubmissionInterface objects. Stores it in `$this->file_objects`.
220
-     *
221
-     * @param array $organized_files   $_FILES but organized like $_POST
222
-     * @param array $name_parts_so_far for multidimensional HTML form names,
223
-     * @throws UnexpectedValueException
224
-     * @throws InvalidArgumentException
225
-     * @since 4.9.80.p
226
-     */
227
-    protected function createFileObjects($organized_files, $name_parts_so_far = [])
228
-    {
229
-        if (! is_array($organized_files)) {
230
-            throw new UnexpectedValueException(
231
-                sprintf(
232
-                    esc_html__(
233
-                        'Unexpected PHP $organized_files data format. "%1$s" was expected to be an array.',
234
-                        'event_espresso'
235
-                    ),
236
-                    (string) $organized_files
237
-                )
238
-            );
239
-        }
240
-        foreach ($organized_files as $key => $value) {
241
-            $this_input_name_parts = $name_parts_so_far;
242
-            array_push(
243
-                $this_input_name_parts,
244
-                $key
245
-            );
246
-            if (isset($value['name'], $value['tmp_name'], $value['size'])) {
247
-                $html_name = $this->inputNameFromParts($this_input_name_parts);
248
-                $this->file_objects->add(
249
-                    new FileSubmission(
250
-                        $value['name'],
251
-                        $value['tmp_name'],
252
-                        $value['size'],
253
-                        $value['error']
254
-                    ),
255
-                    $html_name
256
-                );
257
-            } else {
258
-                $this->createFileObjects($value, $this_input_name_parts);
259
-            }
260
-        }
261
-    }
216
+	/**
217
+	 * Takes the organized $_FILES array (where all file info is located at the same spot as you'd expect an input
218
+	 * to be in post data, with all the file's data located side-by-side in an array) and creates a
219
+	 * multi-dimensional array of FileSubmissionInterface objects. Stores it in `$this->file_objects`.
220
+	 *
221
+	 * @param array $organized_files   $_FILES but organized like $_POST
222
+	 * @param array $name_parts_so_far for multidimensional HTML form names,
223
+	 * @throws UnexpectedValueException
224
+	 * @throws InvalidArgumentException
225
+	 * @since 4.9.80.p
226
+	 */
227
+	protected function createFileObjects($organized_files, $name_parts_so_far = [])
228
+	{
229
+		if (! is_array($organized_files)) {
230
+			throw new UnexpectedValueException(
231
+				sprintf(
232
+					esc_html__(
233
+						'Unexpected PHP $organized_files data format. "%1$s" was expected to be an array.',
234
+						'event_espresso'
235
+					),
236
+					(string) $organized_files
237
+				)
238
+			);
239
+		}
240
+		foreach ($organized_files as $key => $value) {
241
+			$this_input_name_parts = $name_parts_so_far;
242
+			array_push(
243
+				$this_input_name_parts,
244
+				$key
245
+			);
246
+			if (isset($value['name'], $value['tmp_name'], $value['size'])) {
247
+				$html_name = $this->inputNameFromParts($this_input_name_parts);
248
+				$this->file_objects->add(
249
+					new FileSubmission(
250
+						$value['name'],
251
+						$value['tmp_name'],
252
+						$value['size'],
253
+						$value['error']
254
+					),
255
+					$html_name
256
+				);
257
+			} else {
258
+				$this->createFileObjects($value, $this_input_name_parts);
259
+			}
260
+		}
261
+	}
262 262
 
263 263
 
264
-    /**
265
-     * Takes the input name parts, like `['my', 'great', 'file', 'input1']`
266
-     * and returns the HTML name for it, "my[great][file][input1]"
267
-     *
268
-     * @throws UnexpectedValueException
269
-     * @since 4.9.80.p
270
-     */
271
-    protected function inputNameFromParts($parts)
272
-    {
273
-        if (! is_array($parts)) {
274
-            throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso'));
275
-        }
276
-        $generated_string = '';
277
-        foreach ($parts as $part) {
278
-            $part = (string) $part;
279
-            // wrap all but the first part in []
280
-            $generated_string .= $generated_string === '' ? $part : '[' . $part . ']';
281
-        }
282
-        return $generated_string;
283
-    }
264
+	/**
265
+	 * Takes the input name parts, like `['my', 'great', 'file', 'input1']`
266
+	 * and returns the HTML name for it, "my[great][file][input1]"
267
+	 *
268
+	 * @throws UnexpectedValueException
269
+	 * @since 4.9.80.p
270
+	 */
271
+	protected function inputNameFromParts($parts)
272
+	{
273
+		if (! is_array($parts)) {
274
+			throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso'));
275
+		}
276
+		$generated_string = '';
277
+		foreach ($parts as $part) {
278
+			$part = (string) $part;
279
+			// wrap all but the first part in []
280
+			$generated_string .= $generated_string === '' ? $part : '[' . $part . ']';
281
+		}
282
+		return $generated_string;
283
+	}
284 284
 
285 285
 
286
-    /**
287
-     * Gets the input by the indicated $name_parts.
288
-     * Eg if you're looking for an input named "my[great][file][input1]", $name_parts
289
-     * should be `['my', 'great', 'file', 'input1']`.
290
-     * Alternatively, you could use `FileDataHandler::getFileObject('my[great][file][input1]');`
291
-     *
292
-     * @param $name_parts
293
-     * @return FileSubmissionInterface
294
-     * @throws UnexpectedValueException
295
-     * @since 4.9.80.p
296
-     */
297
-    public function getFileObjectFromNameParts($name_parts)
298
-    {
299
-        return $this->getFileObjects()->get($this->inputNameFromParts($name_parts));
300
-    }
286
+	/**
287
+	 * Gets the input by the indicated $name_parts.
288
+	 * Eg if you're looking for an input named "my[great][file][input1]", $name_parts
289
+	 * should be `['my', 'great', 'file', 'input1']`.
290
+	 * Alternatively, you could use `FileDataHandler::getFileObject('my[great][file][input1]');`
291
+	 *
292
+	 * @param $name_parts
293
+	 * @return FileSubmissionInterface
294
+	 * @throws UnexpectedValueException
295
+	 * @since 4.9.80.p
296
+	 */
297
+	public function getFileObjectFromNameParts($name_parts)
298
+	{
299
+		return $this->getFileObjects()->get($this->inputNameFromParts($name_parts));
300
+	}
301 301
 
302 302
 
303
-    /**
304
-     * Gets the FileSubmissionInterface corresponding to the HTML name provided.
305
-     *
306
-     * @param $html_name
307
-     * @return mixed
308
-     * @throws InvalidArgumentException
309
-     * @throws UnexpectedValueException
310
-     * @since 4.9.80.p
311
-     */
312
-    public function getFileObject($html_name)
313
-    {
314
-        return $this->getFileObjects()->get($html_name);
315
-    }
303
+	/**
304
+	 * Gets the FileSubmissionInterface corresponding to the HTML name provided.
305
+	 *
306
+	 * @param $html_name
307
+	 * @return mixed
308
+	 * @throws InvalidArgumentException
309
+	 * @throws UnexpectedValueException
310
+	 * @since 4.9.80.p
311
+	 */
312
+	public function getFileObject($html_name)
313
+	{
314
+		return $this->getFileObjects()->get($html_name);
315
+	}
316 316
 }
317 317
 // End of file FilesDataHandler.php
318 318
 // Location: EventEspresso\core\services\request\files/FilesDataHandler.php
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
             // collection name
100 100
             'submitted_files'
101 101
         );
102
-        $files_raw_data     = $this->request->filesParams();
102
+        $files_raw_data = $this->request->filesParams();
103 103
         if (empty($files_raw_data)) {
104 104
             return;
105 105
         }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      */
124 124
     protected function isStrangeFilesArray($files_data)
125 125
     {
126
-        if (! is_array($files_data)) {
126
+        if ( ! is_array($files_data)) {
127 127
             throw new UnexpectedValueException(
128 128
                 sprintf(
129 129
                     esc_html__(
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
             );
136 136
         }
137 137
         $first_value = reset($files_data);
138
-        if (! is_array($first_value)) {
138
+        if ( ! is_array($first_value)) {
139 139
             throw new UnexpectedValueException(
140 140
                 sprintf(
141 141
                     esc_html__(
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
         $sane_files_array = [];
172 172
         foreach ($files_data as $top_level_name => $top_level_children) {
173 173
             $sub_array                           = [];
174
-            $sane_files_array[ $top_level_name ] = [];
174
+            $sane_files_array[$top_level_name] = [];
175 175
             foreach ($top_level_children as $file_data_part => $second_level_children) {
176 176
                 foreach ($second_level_children as $next_level_name => $sub_values) {
177
-                    $sub_array[ $next_level_name ] = $this->organizeFilesData($sub_values, $file_data_part);
177
+                    $sub_array[$next_level_name] = $this->organizeFilesData($sub_values, $file_data_part);
178 178
                 }
179
-                $sane_files_array[ $top_level_name ] = array_replace_recursive(
179
+                $sane_files_array[$top_level_name] = array_replace_recursive(
180 180
                     $sub_array,
181
-                    $sane_files_array[ $top_level_name ]
181
+                    $sane_files_array[$top_level_name]
182 182
                 );
183 183
             }
184 184
         }
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
      */
197 197
     protected function organizeFilesData($data, $type)
198 198
     {
199
-        if (! is_array($data)) {
199
+        if ( ! is_array($data)) {
200 200
             return [
201 201
                 $type => $data,
202 202
             ];
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
         $organized_data = [];
205 205
         foreach ($data as $input_name_part => $sub_inputs_or_value) {
206 206
             if (is_array($sub_inputs_or_value)) {
207
-                $organized_data[ $input_name_part ] = $this->organizeFilesData($sub_inputs_or_value, $type);
207
+                $organized_data[$input_name_part] = $this->organizeFilesData($sub_inputs_or_value, $type);
208 208
             } else {
209
-                $organized_data[ $input_name_part ][ $type ] = $sub_inputs_or_value;
209
+                $organized_data[$input_name_part][$type] = $sub_inputs_or_value;
210 210
             }
211 211
         }
212 212
         return $organized_data;
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
      */
227 227
     protected function createFileObjects($organized_files, $name_parts_so_far = [])
228 228
     {
229
-        if (! is_array($organized_files)) {
229
+        if ( ! is_array($organized_files)) {
230 230
             throw new UnexpectedValueException(
231 231
                 sprintf(
232 232
                     esc_html__(
@@ -270,14 +270,14 @@  discard block
 block discarded – undo
270 270
      */
271 271
     protected function inputNameFromParts($parts)
272 272
     {
273
-        if (! is_array($parts)) {
273
+        if ( ! is_array($parts)) {
274 274
             throw new UnexpectedValueException(esc_html__('Name parts should be an array.', 'event_espresso'));
275 275
         }
276 276
         $generated_string = '';
277 277
         foreach ($parts as $part) {
278 278
             $part = (string) $part;
279 279
             // wrap all but the first part in []
280
-            $generated_string .= $generated_string === '' ? $part : '[' . $part . ']';
280
+            $generated_string .= $generated_string === '' ? $part : '['.$part.']';
281 281
         }
282 282
         return $generated_string;
283 283
     }
Please login to merge, or discard this patch.
core/espresso_definitions.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@  discard block
 block discarded – undo
7 7
 define('EE_SUPPORT_EMAIL', '[email protected]');
8 8
 // used to be DIRECTORY_SEPARATOR, but that caused issues on windows
9 9
 if (! defined('DS')) {
10
-    define('DS', '/');
10
+	define('DS', '/');
11 11
 }
12 12
 if (! defined('PS')) {
13
-    define('PS', PATH_SEPARATOR);
13
+	define('PS', PATH_SEPARATOR);
14 14
 }
15 15
 if (! defined('SP')) {
16
-    define('SP', ' ');
16
+	define('SP', ' ');
17 17
 }
18 18
 if (! defined('EENL')) {
19
-    define('EENL', "\n");
19
+	define('EENL', "\n");
20 20
 }
21 21
 // define the plugin directory and URL
22 22
 define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages/');
71 71
 // check for DOMPDF fonts in uploads
72 72
 if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts/')) {
73
-    define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts/');
73
+	define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts/');
74 74
 }
75 75
 // just a handy constant occasionally needed for finding values representing infinity in the DB
76 76
 // you're better to use this than its straight value (currently -1) in case you ever
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 define('EE_INF_IN_DB', -1);
79 79
 define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX);
80 80
 if (! defined('EE_DEBUG')) {
81
-    define('EE_DEBUG', false);
81
+	define('EE_DEBUG', false);
82 82
 }
83 83
 // for older WP versions
84 84
 if (! defined('MONTH_IN_SECONDS')) {
85
-    define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
85
+	define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
86 86
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -6,81 +6,81 @@
 block discarded – undo
6 6
 define('EE_MIN_PHP_VER_RECOMMENDED', '5.6.32');
7 7
 define('EE_SUPPORT_EMAIL', '[email protected]');
8 8
 // used to be DIRECTORY_SEPARATOR, but that caused issues on windows
9
-if (! defined('DS')) {
9
+if ( ! defined('DS')) {
10 10
     define('DS', '/');
11 11
 }
12
-if (! defined('PS')) {
12
+if ( ! defined('PS')) {
13 13
     define('PS', PATH_SEPARATOR);
14 14
 }
15
-if (! defined('SP')) {
15
+if ( ! defined('SP')) {
16 16
     define('SP', ' ');
17 17
 }
18
-if (! defined('EENL')) {
18
+if ( ! defined('EENL')) {
19 19
     define('EENL', "\n");
20 20
 }
21 21
 // define the plugin directory and URL
22 22
 define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
23
-define('EE_PLUGIN_DIR_PATH', dirname(EVENT_ESPRESSO_MAIN_FILE) . '/');
23
+define('EE_PLUGIN_DIR_PATH', dirname(EVENT_ESPRESSO_MAIN_FILE).'/');
24 24
 define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
25 25
 // main root folder paths
26
-define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages/');
27
-define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core/');
28
-define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules/');
29
-define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public/');
30
-define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes/');
31
-define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets/');
32
-define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods/');
33
-define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated/');
26
+define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages/');
27
+define('EE_CORE', EE_PLUGIN_DIR_PATH.'core/');
28
+define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules/');
29
+define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public/');
30
+define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes/');
31
+define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets/');
32
+define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods/');
33
+define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated/');
34 34
 // core system paths
35
-define('EE_ADMIN', EE_CORE . 'admin/');
36
-define('EE_CPTS', EE_CORE . 'CPTs/');
37
-define('EE_CLASSES', EE_CORE . 'db_classes/');
38
-define('EE_INTERFACES', EE_CORE . 'interfaces/');
39
-define('EE_BUSINESS', EE_CORE . 'business/');
40
-define('EE_MODELS', EE_CORE . 'db_models/');
41
-define('EE_HELPERS', EE_CORE . 'helpers/');
42
-define('EE_LIBRARIES', EE_CORE . 'libraries/');
43
-define('EE_TEMPLATES', EE_CORE . 'templates/');
44
-define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs/');
45
-define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets/');
46
-define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections/');
35
+define('EE_ADMIN', EE_CORE.'admin/');
36
+define('EE_CPTS', EE_CORE.'CPTs/');
37
+define('EE_CLASSES', EE_CORE.'db_classes/');
38
+define('EE_INTERFACES', EE_CORE.'interfaces/');
39
+define('EE_BUSINESS', EE_CORE.'business/');
40
+define('EE_MODELS', EE_CORE.'db_models/');
41
+define('EE_HELPERS', EE_CORE.'helpers/');
42
+define('EE_LIBRARIES', EE_CORE.'libraries/');
43
+define('EE_TEMPLATES', EE_CORE.'templates/');
44
+define('EE_THIRD_PARTY', EE_CORE.'third_party_libs/');
45
+define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets/');
46
+define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections/');
47 47
 // gateways
48
-define('EE_GATEWAYS', EE_MODULES . 'gateways/');
49
-define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules/gateways/');
48
+define('EE_GATEWAYS', EE_MODULES.'gateways/');
49
+define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules/gateways/');
50 50
 // asset URL paths
51
-define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core/templates/');
52
-define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets/');
53
-define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images/');
54
-define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core/third_party_libs/');
55
-define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
56
-define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
51
+define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core/templates/');
52
+define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets/');
53
+define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images/');
54
+define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core/third_party_libs/');
55
+define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/');
56
+define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/');
57 57
 // define upload paths
58 58
 $uploads = wp_upload_dir();
59 59
 // define the uploads directory and URL
60
-define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . '/espresso/');
61
-define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . '/espresso/');
60
+define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].'/espresso/');
61
+define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].'/espresso/');
62 62
 // define the templates directory and URL
63
-define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . '/espresso/templates/');
64
-define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . '/espresso/templates/');
63
+define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].'/espresso/templates/');
64
+define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].'/espresso/templates/');
65 65
 // define the gateway directory and URL
66
-define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . '/espresso/gateways/');
67
-define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . '/espresso/gateways/');
66
+define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].'/espresso/gateways/');
67
+define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].'/espresso/gateways/');
68 68
 // languages folder/path
69
-define('EE_LANGUAGES_SAFE_LOC', '../' . 'uploads/' . 'espresso/languages/');
70
-define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages/');
69
+define('EE_LANGUAGES_SAFE_LOC', '../'.'uploads/'.'espresso/languages/');
70
+define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages/');
71 71
 // check for DOMPDF fonts in uploads
72
-if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts/')) {
73
-    define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts/');
72
+if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts/')) {
73
+    define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts/');
74 74
 }
75 75
 // just a handy constant occasionally needed for finding values representing infinity in the DB
76 76
 // you're better to use this than its straight value (currently -1) in case you ever
77 77
 // want to change its default value! or find when -1 means infinity
78 78
 define('EE_INF_IN_DB', -1);
79 79
 define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX);
80
-if (! defined('EE_DEBUG')) {
80
+if ( ! defined('EE_DEBUG')) {
81 81
     define('EE_DEBUG', false);
82 82
 }
83 83
 // for older WP versions
84
-if (! defined('MONTH_IN_SECONDS')) {
84
+if ( ! defined('MONTH_IN_SECONDS')) {
85 85
     define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
86 86
 }
Please login to merge, or discard this patch.
core/domain/services/pue/Stats.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
     public function statsCallback()
75 75
     {
76 76
         // returns a callback that can is used to retrieve the stats to send along to the pue server.
77
-        return function () {
77
+        return function() {
78 78
             // we only send stats one a week, so let's see if our stat timestamp has expired.
79
-            if (! $this->sendStats()) {
79
+            if ( ! $this->sendStats()) {
80 80
                 return array();
81 81
             }
82 82
             return $this->stats_gatherer->stats();
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
      */
125 125
     public static function optinText($extra = true)
126 126
     {
127
-        if (! $extra) {
127
+        if ( ! $extra) {
128 128
             echo '<h2 class="ee-admin-settings-hdr" '
129
-                 . (! $extra ? 'id="UXIP_settings"' : '')
129
+                 . ( ! $extra ? 'id="UXIP_settings"' : '')
130 130
                  . '>'
131 131
                  . esc_html__('User eXperience Improvement Program (UXIP)', 'event_espresso')
132 132
                  . EEH_Template::get_help_tab_link('organization_logo_info')
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
                 ),
158 158
                 '<a href="https://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">',
159 159
                 '</a>',
160
-                '<a href="' . $settings_url . '" target="_blank">',
160
+                '<a href="'.$settings_url.'" target="_blank">',
161 161
                 '</a>'
162 162
             );
163 163
         }
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
     {
172 172
         wp_register_script(
173 173
             'ee-data-optin-js',
174
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-data-optin.js',
174
+            EE_GLOBAL_ASSETS_URL.'scripts/ee-data-optin.js',
175 175
             array('jquery'),
176 176
             EVENT_ESPRESSO_VERSION,
177 177
             true
178 178
         );
179 179
         wp_register_style(
180 180
             'ee-data-optin-css',
181
-            EE_GLOBAL_ASSETS_URL . 'css/ee-data-optin.css',
181
+            EE_GLOBAL_ASSETS_URL.'css/ee-data-optin.css',
182 182
             array(),
183 183
             EVENT_ESPRESSO_VERSION
184 184
         );
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
         $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
198 198
         $nonce = $request->getRequestParam('nonce');
199 199
         // verify nonce
200
-        if (! $nonce || ! wp_verify_nonce($nonce, 'ee-data-optin')) {
200
+        if ( ! $nonce || ! wp_verify_nonce($nonce, 'ee-data-optin')) {
201 201
             exit();
202 202
         }
203 203
 
Please login to merge, or discard this patch.
Indentation   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -21,86 +21,86 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class Stats
23 23
 {
24
-    const OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS = 'ee_uxip_stats_expiry';
25
-
26
-    /**
27
-     * @var Config
28
-     */
29
-    private $config;
30
-
31
-
32
-    /**
33
-     * @var StatsGatherer
34
-     */
35
-    private $stats_gatherer;
36
-
37
-
38
-    /**
39
-     * @var EE_Maintenance_Mode
40
-     */
41
-    private $maintenance_mode;
42
-
43
-    public function __construct(
44
-        Config $config,
45
-        EE_Maintenance_Mode $maintenance_mode,
46
-        StatsGatherer $stats_gatherer
47
-    ) {
48
-        $this->config = $config;
49
-        $this->maintenance_mode = $maintenance_mode;
50
-        $this->stats_gatherer = $stats_gatherer;
51
-        $this->setUxipNotices();
52
-    }
53
-
54
-
55
-    /**
56
-     * Displays uxip opt-in notice if necessary.
57
-     */
58
-    private function setUxipNotices()
59
-    {
60
-        if ($this->canDisplayNotices()) {
61
-            add_action('admin_notices', array($this, 'optinNotice'));
62
-            add_action('admin_enqueue_scripts', array($this, 'enqueueScripts'));
63
-            add_action('wp_ajax_espresso_data_optin', array($this, 'ajaxHandler'));
64
-        }
65
-    }
66
-
67
-
68
-    /**
69
-     * This returns the callback that PluginUpdateEngineChecker will use for getting any extra stats to send.
70
-     *
71
-     * @return Closure
72
-     */
73
-    public function statsCallback()
74
-    {
75
-        // returns a callback that can is used to retrieve the stats to send along to the pue server.
76
-        return function () {
77
-            // we only send stats one a week, so let's see if our stat timestamp has expired.
78
-            if (! $this->sendStats()) {
79
-                return array();
80
-            }
81
-            return $this->stats_gatherer->stats();
82
-        };
83
-    }
84
-
85
-
86
-    /**
87
-     * Return whether notices can be displayed or not
88
-     *
89
-     * @return bool
90
-     */
91
-    private function canDisplayNotices()
92
-    {
93
-        return ! $this->config->hasNotifiedForUxip()
94
-               && $this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance;
95
-    }
96
-
97
-
98
-    /**
99
-     * Callback for the admin_notices hook that outputs the UXIP optin-in notice.
100
-     */
101
-    public function optinNotice()
102
-    {
103
-        ?>
24
+	const OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS = 'ee_uxip_stats_expiry';
25
+
26
+	/**
27
+	 * @var Config
28
+	 */
29
+	private $config;
30
+
31
+
32
+	/**
33
+	 * @var StatsGatherer
34
+	 */
35
+	private $stats_gatherer;
36
+
37
+
38
+	/**
39
+	 * @var EE_Maintenance_Mode
40
+	 */
41
+	private $maintenance_mode;
42
+
43
+	public function __construct(
44
+		Config $config,
45
+		EE_Maintenance_Mode $maintenance_mode,
46
+		StatsGatherer $stats_gatherer
47
+	) {
48
+		$this->config = $config;
49
+		$this->maintenance_mode = $maintenance_mode;
50
+		$this->stats_gatherer = $stats_gatherer;
51
+		$this->setUxipNotices();
52
+	}
53
+
54
+
55
+	/**
56
+	 * Displays uxip opt-in notice if necessary.
57
+	 */
58
+	private function setUxipNotices()
59
+	{
60
+		if ($this->canDisplayNotices()) {
61
+			add_action('admin_notices', array($this, 'optinNotice'));
62
+			add_action('admin_enqueue_scripts', array($this, 'enqueueScripts'));
63
+			add_action('wp_ajax_espresso_data_optin', array($this, 'ajaxHandler'));
64
+		}
65
+	}
66
+
67
+
68
+	/**
69
+	 * This returns the callback that PluginUpdateEngineChecker will use for getting any extra stats to send.
70
+	 *
71
+	 * @return Closure
72
+	 */
73
+	public function statsCallback()
74
+	{
75
+		// returns a callback that can is used to retrieve the stats to send along to the pue server.
76
+		return function () {
77
+			// we only send stats one a week, so let's see if our stat timestamp has expired.
78
+			if (! $this->sendStats()) {
79
+				return array();
80
+			}
81
+			return $this->stats_gatherer->stats();
82
+		};
83
+	}
84
+
85
+
86
+	/**
87
+	 * Return whether notices can be displayed or not
88
+	 *
89
+	 * @return bool
90
+	 */
91
+	private function canDisplayNotices()
92
+	{
93
+		return ! $this->config->hasNotifiedForUxip()
94
+			   && $this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance;
95
+	}
96
+
97
+
98
+	/**
99
+	 * Callback for the admin_notices hook that outputs the UXIP optin-in notice.
100
+	 */
101
+	public function optinNotice()
102
+	{
103
+		?>
104 104
         <div class="updated data-collect-optin" id="espresso-data-collect-optin-container">
105 105
             <div id="data-collect-optin-options-container">
106 106
                 <span class="dashicons dashicons-admin-site"></span>
@@ -113,128 +113,128 @@  discard block
 block discarded – undo
113 113
             </div>
114 114
         </div>
115 115
         <?php
116
-    }
117
-
118
-
119
-    /**
120
-     * Retrieves the optin text (static so it can be used in multiple places as necessary).
121
-     *
122
-     * @param bool $extra
123
-     */
124
-    public static function optinText($extra = true)
125
-    {
126
-        if (! $extra) {
127
-            echo '<h2 class="ee-admin-settings-hdr" '
128
-                 . (! $extra ? 'id="UXIP_settings"' : '')
129
-                 . '>'
130
-                 . esc_html__('User eXperience Improvement Program (UXIP)', 'event_espresso')
131
-                 . EEH_Template::get_help_tab_link('organization_logo_info')
132
-                 . '</h2>';
133
-            printf(
134
-                esc_html__(
135
-                    '%1$sPlease help us make Event Espresso better and vote for your favorite features.%2$s The %3$sUser eXperience Improvement Program (UXIP)%4$s, has been created so when you use Event Espresso you are voting for the features and settings that are important to you. The UXIP helps us understand how you use our products and services, track problems and in what context. If you opt-out of the UXIP you essentially elect for us to disregard how you use Event Espresso as we build new features and make changes. Participation in the program is completely voluntary and it is disabled by default. The end results of the UXIP are software improvements to better meet your needs. The data we collect will never be sold, traded, or misused in any way. %5$sPlease see our %6$sPrivacy Policy%7$s for more information.',
136
-                    'event_espresso'
137
-                ),
138
-                '<p><em>',
139
-                '</em></p>',
140
-                '<a href="https://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">',
141
-                '</a>',
142
-                '<br><br>',
143
-                '<a href="https://eventespresso.com/about/privacy-policy/" target="_blank">',
144
-                '</a>'
145
-            );
146
-        } else {
147
-            $settings_url = EEH_URL::add_query_args_and_nonce(
148
-                array('action' => 'default'),
149
-                admin_url('admin.php?page=espresso_general_settings')
150
-            );
151
-            $settings_url .= '#UXIP_settings';
152
-            printf(
153
-                esc_html__(
154
-                    'The Event Espresso UXIP feature is not yet active on your site. For %1$smore info%2$s and to opt-in %3$sclick here%4$s.',
155
-                    'event_espresso'
156
-                ),
157
-                '<a href="https://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">',
158
-                '</a>',
159
-                '<a href="' . $settings_url . '" target="_blank">',
160
-                '</a>'
161
-            );
162
-        }
163
-    }
164
-
165
-
166
-    /**
167
-     * Callback for admin_enqueue_scripts that sets up the scripts and styles for the uxip notice
168
-     */
169
-    public function enqueueScripts()
170
-    {
171
-        wp_register_script(
172
-            'ee-data-optin-js',
173
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-data-optin.js',
174
-            array('jquery'),
175
-            EVENT_ESPRESSO_VERSION,
176
-            true
177
-        );
178
-        wp_register_style(
179
-            'ee-data-optin-css',
180
-            EE_GLOBAL_ASSETS_URL . 'css/ee-data-optin.css',
181
-            array(),
182
-            EVENT_ESPRESSO_VERSION
183
-        );
184
-
185
-        wp_enqueue_script('ee-data-optin-js');
186
-        wp_enqueue_style('ee-data-optin-css');
187
-    }
188
-
189
-
190
-    /**
191
-     * Callback for wp_ajax_espresso_data_optin that handles the ajax request
192
-     */
193
-    public function ajaxHandler()
194
-    {
195
-        /** @var RequestInterface $request */
196
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
197
-        $nonce = $request->getRequestParam('nonce');
198
-        // verify nonce
199
-        if (! $nonce || ! wp_verify_nonce($nonce, 'ee-data-optin')) {
200
-            exit();
201
-        }
202
-
203
-        // update has notified option
204
-        $this->config->setHasNotifiedAboutUxip();
205
-        exit();
206
-    }
207
-
208
-
209
-    /**
210
-     * Used to determine whether additional stats are sent.
211
-     */
212
-    private function sendStats()
213
-    {
214
-        return $this->config->isOptedInForUxip()
215
-               && $this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
216
-               && $this->statSendTimestampExpired();
217
-    }
218
-
219
-
220
-    /**
221
-     * Returns true when the timestamp used to track whether stats get sent (currently a weekly interval) is expired.
222
-     * Returns false otherwise.
223
-     *
224
-     * @return bool
225
-     */
226
-    private function statSendTimestampExpired()
227
-    {
228
-        $current_expiry = get_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, null);
229
-        if ($current_expiry === null) {
230
-            add_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, time() + WEEK_IN_SECONDS, '', 'no');
231
-            return true;
232
-        }
233
-
234
-        if (time() > (int) $current_expiry) {
235
-            update_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, time() + WEEK_IN_SECONDS);
236
-            return true;
237
-        }
238
-        return false;
239
-    }
116
+	}
117
+
118
+
119
+	/**
120
+	 * Retrieves the optin text (static so it can be used in multiple places as necessary).
121
+	 *
122
+	 * @param bool $extra
123
+	 */
124
+	public static function optinText($extra = true)
125
+	{
126
+		if (! $extra) {
127
+			echo '<h2 class="ee-admin-settings-hdr" '
128
+				 . (! $extra ? 'id="UXIP_settings"' : '')
129
+				 . '>'
130
+				 . esc_html__('User eXperience Improvement Program (UXIP)', 'event_espresso')
131
+				 . EEH_Template::get_help_tab_link('organization_logo_info')
132
+				 . '</h2>';
133
+			printf(
134
+				esc_html__(
135
+					'%1$sPlease help us make Event Espresso better and vote for your favorite features.%2$s The %3$sUser eXperience Improvement Program (UXIP)%4$s, has been created so when you use Event Espresso you are voting for the features and settings that are important to you. The UXIP helps us understand how you use our products and services, track problems and in what context. If you opt-out of the UXIP you essentially elect for us to disregard how you use Event Espresso as we build new features and make changes. Participation in the program is completely voluntary and it is disabled by default. The end results of the UXIP are software improvements to better meet your needs. The data we collect will never be sold, traded, or misused in any way. %5$sPlease see our %6$sPrivacy Policy%7$s for more information.',
136
+					'event_espresso'
137
+				),
138
+				'<p><em>',
139
+				'</em></p>',
140
+				'<a href="https://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">',
141
+				'</a>',
142
+				'<br><br>',
143
+				'<a href="https://eventespresso.com/about/privacy-policy/" target="_blank">',
144
+				'</a>'
145
+			);
146
+		} else {
147
+			$settings_url = EEH_URL::add_query_args_and_nonce(
148
+				array('action' => 'default'),
149
+				admin_url('admin.php?page=espresso_general_settings')
150
+			);
151
+			$settings_url .= '#UXIP_settings';
152
+			printf(
153
+				esc_html__(
154
+					'The Event Espresso UXIP feature is not yet active on your site. For %1$smore info%2$s and to opt-in %3$sclick here%4$s.',
155
+					'event_espresso'
156
+				),
157
+				'<a href="https://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">',
158
+				'</a>',
159
+				'<a href="' . $settings_url . '" target="_blank">',
160
+				'</a>'
161
+			);
162
+		}
163
+	}
164
+
165
+
166
+	/**
167
+	 * Callback for admin_enqueue_scripts that sets up the scripts and styles for the uxip notice
168
+	 */
169
+	public function enqueueScripts()
170
+	{
171
+		wp_register_script(
172
+			'ee-data-optin-js',
173
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-data-optin.js',
174
+			array('jquery'),
175
+			EVENT_ESPRESSO_VERSION,
176
+			true
177
+		);
178
+		wp_register_style(
179
+			'ee-data-optin-css',
180
+			EE_GLOBAL_ASSETS_URL . 'css/ee-data-optin.css',
181
+			array(),
182
+			EVENT_ESPRESSO_VERSION
183
+		);
184
+
185
+		wp_enqueue_script('ee-data-optin-js');
186
+		wp_enqueue_style('ee-data-optin-css');
187
+	}
188
+
189
+
190
+	/**
191
+	 * Callback for wp_ajax_espresso_data_optin that handles the ajax request
192
+	 */
193
+	public function ajaxHandler()
194
+	{
195
+		/** @var RequestInterface $request */
196
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
197
+		$nonce = $request->getRequestParam('nonce');
198
+		// verify nonce
199
+		if (! $nonce || ! wp_verify_nonce($nonce, 'ee-data-optin')) {
200
+			exit();
201
+		}
202
+
203
+		// update has notified option
204
+		$this->config->setHasNotifiedAboutUxip();
205
+		exit();
206
+	}
207
+
208
+
209
+	/**
210
+	 * Used to determine whether additional stats are sent.
211
+	 */
212
+	private function sendStats()
213
+	{
214
+		return $this->config->isOptedInForUxip()
215
+			   && $this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
216
+			   && $this->statSendTimestampExpired();
217
+	}
218
+
219
+
220
+	/**
221
+	 * Returns true when the timestamp used to track whether stats get sent (currently a weekly interval) is expired.
222
+	 * Returns false otherwise.
223
+	 *
224
+	 * @return bool
225
+	 */
226
+	private function statSendTimestampExpired()
227
+	{
228
+		$current_expiry = get_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, null);
229
+		if ($current_expiry === null) {
230
+			add_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, time() + WEEK_IN_SECONDS, '', 'no');
231
+			return true;
232
+		}
233
+
234
+		if (time() > (int) $current_expiry) {
235
+			update_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, time() + WEEK_IN_SECONDS);
236
+			return true;
237
+		}
238
+		return false;
239
+	}
240 240
 }
Please login to merge, or discard this patch.
core/EE_Log.core.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public static function instance()
50 50
     {
51
-        if (! self::$_instance instanceof EE_Log) {
51
+        if ( ! self::$_instance instanceof EE_Log) {
52 52
             self::$_instance = new self();
53 53
         }
54 54
         return self::$_instance;
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     private function __construct()
62 62
     {
63 63
 
64
-        if (! EE_Registry::instance()->CFG->admin->use_remote_logging) {
64
+        if ( ! EE_Registry::instance()->CFG->admin->use_remote_logging) {
65 65
             return;
66 66
         }
67 67
 
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
      */
106 106
     private function _format_message($file = '', $function = '', $message = '', $type = '')
107 107
     {
108
-        $msg = '----------------------------------------------------------------------------------------' . PHP_EOL;
109
-        $msg .= '[' . current_time('mysql') . '] ';
108
+        $msg = '----------------------------------------------------------------------------------------'.PHP_EOL;
109
+        $msg .= '['.current_time('mysql').'] ';
110 110
         $msg .= ! empty($file) ? basename($file) : '';
111 111
         $msg .= ! empty($file) && ! empty($function) ? ' -> ' : '';
112
-        $msg .= ! empty($function) ? $function . '()' : '';
112
+        $msg .= ! empty($function) ? $function.'()' : '';
113 113
         $msg .= PHP_EOL;
114 114
         $type = ! empty($type) ? $type : 'log message';
115
-        $msg .= ! empty($message) ? "\t" . '[' . $type . '] ' . $message . PHP_EOL : '';
115
+        $msg .= ! empty($message) ? "\t".'['.$type.'] '.$message.PHP_EOL : '';
116 116
         return $msg;
117 117
     }
118 118
 
@@ -164,18 +164,18 @@  discard block
 block discarded – undo
164 164
 
165 165
         /** @var RequestInterface $request */
166 166
         $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
167
-        $data = 'domain=' . $request->getServerParam('HTTP_HOST');
168
-        $data .= '&ip=' . $request->getServerParam('SERVER_ADDR');
169
-        $data .= '&server_type=' . $request->getServerParam('SERVER_SOFTWARE');
170
-        $data .= '&time=' . time();
171
-        $data .= '&remote_log=' . $this->_log;
167
+        $data = 'domain='.$request->getServerParam('HTTP_HOST');
168
+        $data .= '&ip='.$request->getServerParam('SERVER_ADDR');
169
+        $data .= '&server_type='.$request->getServerParam('SERVER_SOFTWARE');
170
+        $data .= '&time='.time();
171
+        $data .= '&remote_log='.$this->_log;
172 172
         $data .= '&action=save';
173 173
 
174 174
         if (defined('EELOGGING_PASS')) {
175
-            $data .= '&pass=' . EELOGGING_PASS;
175
+            $data .= '&pass='.EELOGGING_PASS;
176 176
         }
177 177
         if (defined('EELOGGING_KEY')) {
178
-            $data .= '&key=' . EELOGGING_KEY;
178
+            $data .= '&key='.EELOGGING_KEY;
179 179
         }
180 180
 
181 181
         $c = curl_init($this->_remote_logging_url);
Please login to merge, or discard this patch.
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -19,197 +19,197 @@
 block discarded – undo
19 19
  */
20 20
 class EE_Log
21 21
 {
22
-    /**
23
-     * @var string
24
-     */
25
-    private $_log = '';
26
-
27
-    /**
28
-     * Used for remote logging
29
-     *
30
-     * @var string
31
-     */
32
-    private $_remote_logging_url = '';
33
-
34
-    /**
35
-     * @var string
36
-     */
37
-    private $_remote_log = '';
38
-
39
-    /**
40
-     * @var EE_Log
41
-     */
42
-    private static $_instance;
43
-
44
-
45
-    /**
46
-     * @return EE_Log
47
-     */
48
-    public static function instance()
49
-    {
50
-        if (! self::$_instance instanceof EE_Log) {
51
-            self::$_instance = new self();
52
-        }
53
-        return self::$_instance;
54
-    }
55
-
56
-    /**
57
-     * @access private
58
-     * @return EE_Log
59
-     */
60
-    private function __construct()
61
-    {
62
-
63
-        if (! EE_Registry::instance()->CFG->admin->use_remote_logging) {
64
-            return;
65
-        }
66
-
67
-        $this->_remote_logging_url = EE_Registry::instance()->CFG->admin->remote_logging_url;
68
-        $this->_remote_log = '';
69
-
70
-        if (EE_Registry::instance()->CFG->admin->use_remote_logging) {
71
-            add_action('shutdown', array($this, 'send_log'), 9999);
72
-        }
73
-    }
74
-
75
-
76
-    /**
77
-     *    verify_filesystem
78
-     * tests that the required files and folders exist and are writable
79
-     *
80
-     */
81
-    public function verify_filesystem()
82
-    {
83
-        $msg = esc_html__(
84
-            'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.',
85
-            'event_espresso'
86
-        );
87
-        EE_Error::doing_it_wrong(
88
-            __METHOD__,
89
-            $msg,
90
-            '4.10.1.p'
91
-        );
92
-    }
93
-
94
-
95
-    /**
96
-     *    _format_message
97
-     *    makes yer log entries look all purdy
98
-     *
99
-     * @param string $file
100
-     * @param string $function
101
-     * @param string $message
102
-     * @param string $type
103
-     * @return string
104
-     */
105
-    private function _format_message($file = '', $function = '', $message = '', $type = '')
106
-    {
107
-        $msg = '----------------------------------------------------------------------------------------' . PHP_EOL;
108
-        $msg .= '[' . current_time('mysql') . '] ';
109
-        $msg .= ! empty($file) ? basename($file) : '';
110
-        $msg .= ! empty($file) && ! empty($function) ? ' -> ' : '';
111
-        $msg .= ! empty($function) ? $function . '()' : '';
112
-        $msg .= PHP_EOL;
113
-        $type = ! empty($type) ? $type : 'log message';
114
-        $msg .= ! empty($message) ? "\t" . '[' . $type . '] ' . $message . PHP_EOL : '';
115
-        return $msg;
116
-    }
117
-
118
-
119
-    /**
120
-     *    log
121
-     * adds content to the EE_Log->_log property which gets written to file during the WP 'shutdown' hookpoint via the
122
-     * EE_Log::write_log() callback
123
-     *
124
-     * @param string $file
125
-     * @param string $function
126
-     * @param string $message
127
-     * @param string $type
128
-     */
129
-    public function log($file = '', $function = '', $message = '', $type = '')
130
-    {
131
-        $this->_log .= $this->_format_message($file, $function, $message, $type);
132
-    }
133
-
134
-
135
-    /**
136
-     * write_log
137
-     * appends the results of the 'AHEE_log' filter to the espresso log file
138
-     */
139
-    public function write_log()
140
-    {
141
-        $msg = esc_html__(
142
-            'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.',
143
-            'event_espresso'
144
-        );
145
-        EE_Error::doing_it_wrong(
146
-            __METHOD__,
147
-            $msg,
148
-            '4.10.1.p'
149
-        );
150
-    }
151
-
152
-
153
-    /**
154
-     * send_log
155
-     * sends the espresso log to a remote URL via a PHP cURL request
156
-     */
157
-    public function send_log()
158
-    {
159
-
160
-        if (empty($this->_remote_logging_url)) {
161
-            return;
162
-        }
163
-
164
-        /** @var RequestInterface $request */
165
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
166
-        $data = 'domain=' . $request->getServerParam('HTTP_HOST');
167
-        $data .= '&ip=' . $request->getServerParam('SERVER_ADDR');
168
-        $data .= '&server_type=' . $request->getServerParam('SERVER_SOFTWARE');
169
-        $data .= '&time=' . time();
170
-        $data .= '&remote_log=' . $this->_log;
171
-        $data .= '&action=save';
172
-
173
-        if (defined('EELOGGING_PASS')) {
174
-            $data .= '&pass=' . EELOGGING_PASS;
175
-        }
176
-        if (defined('EELOGGING_KEY')) {
177
-            $data .= '&key=' . EELOGGING_KEY;
178
-        }
179
-
180
-        $c = curl_init($this->_remote_logging_url);
181
-        curl_setopt($c, CURLOPT_POST, true);
182
-        curl_setopt($c, CURLOPT_POSTFIELDS, $data);
183
-        curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
184
-        curl_exec($c);
185
-        curl_close($c);
186
-    }
187
-
188
-
189
-    /**
190
-     * write_debug
191
-     * writes the contents of the current request's data to a log file.
192
-     * previous entries are overwritten
193
-     */
194
-    public function write_debug()
195
-    {
196
-        $msg = esc_html__(
197
-            'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.',
198
-            'event_espresso'
199
-        );
200
-        EE_Error::doing_it_wrong(
201
-            __METHOD__,
202
-            $msg,
203
-            '4.10.1.p'
204
-        );
205
-    }
206
-
207
-
208
-    /**
209
-     * __clone
210
-     */
211
-    public function __clone()
212
-    {
213
-        trigger_error(esc_html__('Clone is not allowed.', 'event_espresso'), E_USER_ERROR);
214
-    }
22
+	/**
23
+	 * @var string
24
+	 */
25
+	private $_log = '';
26
+
27
+	/**
28
+	 * Used for remote logging
29
+	 *
30
+	 * @var string
31
+	 */
32
+	private $_remote_logging_url = '';
33
+
34
+	/**
35
+	 * @var string
36
+	 */
37
+	private $_remote_log = '';
38
+
39
+	/**
40
+	 * @var EE_Log
41
+	 */
42
+	private static $_instance;
43
+
44
+
45
+	/**
46
+	 * @return EE_Log
47
+	 */
48
+	public static function instance()
49
+	{
50
+		if (! self::$_instance instanceof EE_Log) {
51
+			self::$_instance = new self();
52
+		}
53
+		return self::$_instance;
54
+	}
55
+
56
+	/**
57
+	 * @access private
58
+	 * @return EE_Log
59
+	 */
60
+	private function __construct()
61
+	{
62
+
63
+		if (! EE_Registry::instance()->CFG->admin->use_remote_logging) {
64
+			return;
65
+		}
66
+
67
+		$this->_remote_logging_url = EE_Registry::instance()->CFG->admin->remote_logging_url;
68
+		$this->_remote_log = '';
69
+
70
+		if (EE_Registry::instance()->CFG->admin->use_remote_logging) {
71
+			add_action('shutdown', array($this, 'send_log'), 9999);
72
+		}
73
+	}
74
+
75
+
76
+	/**
77
+	 *    verify_filesystem
78
+	 * tests that the required files and folders exist and are writable
79
+	 *
80
+	 */
81
+	public function verify_filesystem()
82
+	{
83
+		$msg = esc_html__(
84
+			'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.',
85
+			'event_espresso'
86
+		);
87
+		EE_Error::doing_it_wrong(
88
+			__METHOD__,
89
+			$msg,
90
+			'4.10.1.p'
91
+		);
92
+	}
93
+
94
+
95
+	/**
96
+	 *    _format_message
97
+	 *    makes yer log entries look all purdy
98
+	 *
99
+	 * @param string $file
100
+	 * @param string $function
101
+	 * @param string $message
102
+	 * @param string $type
103
+	 * @return string
104
+	 */
105
+	private function _format_message($file = '', $function = '', $message = '', $type = '')
106
+	{
107
+		$msg = '----------------------------------------------------------------------------------------' . PHP_EOL;
108
+		$msg .= '[' . current_time('mysql') . '] ';
109
+		$msg .= ! empty($file) ? basename($file) : '';
110
+		$msg .= ! empty($file) && ! empty($function) ? ' -> ' : '';
111
+		$msg .= ! empty($function) ? $function . '()' : '';
112
+		$msg .= PHP_EOL;
113
+		$type = ! empty($type) ? $type : 'log message';
114
+		$msg .= ! empty($message) ? "\t" . '[' . $type . '] ' . $message . PHP_EOL : '';
115
+		return $msg;
116
+	}
117
+
118
+
119
+	/**
120
+	 *    log
121
+	 * adds content to the EE_Log->_log property which gets written to file during the WP 'shutdown' hookpoint via the
122
+	 * EE_Log::write_log() callback
123
+	 *
124
+	 * @param string $file
125
+	 * @param string $function
126
+	 * @param string $message
127
+	 * @param string $type
128
+	 */
129
+	public function log($file = '', $function = '', $message = '', $type = '')
130
+	{
131
+		$this->_log .= $this->_format_message($file, $function, $message, $type);
132
+	}
133
+
134
+
135
+	/**
136
+	 * write_log
137
+	 * appends the results of the 'AHEE_log' filter to the espresso log file
138
+	 */
139
+	public function write_log()
140
+	{
141
+		$msg = esc_html__(
142
+			'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.',
143
+			'event_espresso'
144
+		);
145
+		EE_Error::doing_it_wrong(
146
+			__METHOD__,
147
+			$msg,
148
+			'4.10.1.p'
149
+		);
150
+	}
151
+
152
+
153
+	/**
154
+	 * send_log
155
+	 * sends the espresso log to a remote URL via a PHP cURL request
156
+	 */
157
+	public function send_log()
158
+	{
159
+
160
+		if (empty($this->_remote_logging_url)) {
161
+			return;
162
+		}
163
+
164
+		/** @var RequestInterface $request */
165
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
166
+		$data = 'domain=' . $request->getServerParam('HTTP_HOST');
167
+		$data .= '&ip=' . $request->getServerParam('SERVER_ADDR');
168
+		$data .= '&server_type=' . $request->getServerParam('SERVER_SOFTWARE');
169
+		$data .= '&time=' . time();
170
+		$data .= '&remote_log=' . $this->_log;
171
+		$data .= '&action=save';
172
+
173
+		if (defined('EELOGGING_PASS')) {
174
+			$data .= '&pass=' . EELOGGING_PASS;
175
+		}
176
+		if (defined('EELOGGING_KEY')) {
177
+			$data .= '&key=' . EELOGGING_KEY;
178
+		}
179
+
180
+		$c = curl_init($this->_remote_logging_url);
181
+		curl_setopt($c, CURLOPT_POST, true);
182
+		curl_setopt($c, CURLOPT_POSTFIELDS, $data);
183
+		curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
184
+		curl_exec($c);
185
+		curl_close($c);
186
+	}
187
+
188
+
189
+	/**
190
+	 * write_debug
191
+	 * writes the contents of the current request's data to a log file.
192
+	 * previous entries are overwritten
193
+	 */
194
+	public function write_debug()
195
+	{
196
+		$msg = esc_html__(
197
+			'The Local File Logging functionality was removed permanently. Remote Logging is recommended instead.',
198
+			'event_espresso'
199
+		);
200
+		EE_Error::doing_it_wrong(
201
+			__METHOD__,
202
+			$msg,
203
+			'4.10.1.p'
204
+		);
205
+	}
206
+
207
+
208
+	/**
209
+	 * __clone
210
+	 */
211
+	public function __clone()
212
+	{
213
+		trigger_error(esc_html__('Clone is not allowed.', 'event_espresso'), E_USER_ERROR);
214
+	}
215 215
 }
Please login to merge, or discard this patch.