Completed
Branch rest-authorization (c7240a)
by
unknown
02:23
created
core/libraries/shortcodes/EE_Shortcodes.lib.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
     public function get_shortcode_helper()
148 148
     {
149
-        if (! $this->_shortcode_helper instanceof EEH_Parse_Shortcodes) {
149
+        if ( ! $this->_shortcode_helper instanceof EEH_Parse_Shortcodes) {
150 150
             $this->_set_shortcode_helper();
151 151
         }
152 152
         return $this->_shortcode_helper;
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
 
171 171
         // we need to setup any dynamic shortcodes so that they work with the array_key_exists
172 172
         preg_match_all('/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches);
173
-        $sc_to_verify = ! empty($matches[0]) ? $matches[0][0] . ']' : $shortcode;
173
+        $sc_to_verify = ! empty($matches[0]) ? $matches[0][0].']' : $shortcode;
174 174
 
175 175
         // first we want to make sure this is a valid shortcode
176
-        if (! array_key_exists($sc_to_verify, $this->_shortcodes)) {
176
+        if ( ! array_key_exists($sc_to_verify, $this->_shortcodes)) {
177 177
             return false;
178 178
         } //get out, this parser doesn't handle the incoming shortcode.
179 179
         $this->_data = $data;
180 180
         $this->_extra_data = $extra_data;
181 181
         $this->_set_messages_properties();
182 182
         $parsed = apply_filters(
183
-            'FHEE__' . get_class($this) . '__parser_after',
183
+            'FHEE__'.get_class($this).'__parser_after',
184 184
             $this->_parser($shortcode),
185 185
             $shortcode,
186 186
             $data,
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
      */
202 202
     public function get_shortcodes()
203 203
     {
204
-        $this->_shortcodes = apply_filters('FHEE__' . get_class($this) . '__shortcodes', $this->_shortcodes, $this);
204
+        $this->_shortcodes = apply_filters('FHEE__'.get_class($this).'__shortcodes', $this->_shortcodes, $this);
205 205
 
206 206
         // note the below filter applies to ALL shortcode parsers... be careful!
207 207
         $this->_shortcodes = apply_filters('FHEE__EE_Shortcodes__shortcodes', $this->_shortcodes, $this);
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
     {
249 249
 
250 250
         // first test to make sure we've got an array!
251
-        if (! is_array($this->_data)) {
251
+        if ( ! is_array($this->_data)) {
252 252
             throw new EE_Error(
253 253
                 sprintf(
254 254
                     esc_html__(
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
         }
263 263
 
264 264
         // next test to make sure we've got the required template in the index!
265
-        if (! isset($this->_data['template'])) {
265
+        if ( ! isset($this->_data['template'])) {
266 266
             throw new EE_Error(
267 267
                 sprintf(
268 268
                     esc_html__(
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
         }
275 275
 
276 276
         // next test to make sure we've got got a data index in the incoming data array
277
-        if (! isset($this->_data['data'])) {
277
+        if ( ! isset($this->_data['data'])) {
278 278
             throw new EE_Error(
279 279
                 esc_html__(
280 280
                     'The incoming data does not have the required data index in its array',
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
     {
304 304
         // make sure the required wp helper function is present
305 305
         // require the shortcode file if necessary
306
-        if (! function_exists('shortcode_parse_atts')) {
307
-            require_once(ABSPATH . WPINC . '/shortcodes.php');
306
+        if ( ! function_exists('shortcode_parse_atts')) {
307
+            require_once(ABSPATH.WPINC.'/shortcodes.php');
308 308
         }
309 309
 
310 310
         // let's get any attributes that may be present and set the defaults.
@@ -329,15 +329,15 @@  discard block
 block discarded – undo
329 329
     protected function _mutate_conditional_block_in_template($shortcode, $show = true)
330 330
     {
331 331
         // first let's get all the matches in the template for this particular shortcode.
332
-        preg_match_all('~' . $this->_get_conditional_block_regex($shortcode) . '~', $this->_data['template'], $matches);
332
+        preg_match_all('~'.$this->_get_conditional_block_regex($shortcode).'~', $this->_data['template'], $matches);
333 333
 
334 334
         if ($matches && is_array($matches[0]) && ! empty($matches[0])) {
335 335
             // we need to hide all instances of the matches
336 336
             foreach ($matches[0] as $index => $content_to_show_or_hide) {
337 337
                 $content_to_show_or_hide = preg_quote($content_to_show_or_hide);
338
-                $replacement = $show ? $matches[4][ $index ] : '';
338
+                $replacement = $show ? $matches[4][$index] : '';
339 339
                 $this->_data['template'] = preg_replace(
340
-                    '~' . $content_to_show_or_hide . '~',
340
+                    '~'.$content_to_show_or_hide.'~',
341 341
                     $replacement,
342 342
                     $this->_data['template']
343 343
                 );
Please login to merge, or discard this patch.
Indentation   +452 added lines, -452 removed lines patch added patch discarded remove patch
@@ -16,456 +16,456 @@
 block discarded – undo
16 16
  */
17 17
 abstract class EE_Shortcodes extends EE_Base
18 18
 {
19
-    /**
20
-     * holds label for library
21
-     * This is used for referencing the library label
22
-     *
23
-     * @access public
24
-     * @var string
25
-     */
26
-    public $label;
27
-
28
-
29
-    /**
30
-     * This property is used for referencing a short description of the library
31
-     *
32
-     * @access public
33
-     * @var string
34
-     */
35
-    public $description;
36
-
37
-
38
-    /**
39
-     * This will hold an array of shortcodes with the key as the shortcode ([shortcode]) and the value as a
40
-     * label/description for the shortcode.
41
-     *
42
-     * @access protected
43
-     * @var array
44
-     */
45
-    protected $_shortcodes;
46
-
47
-
48
-    /**
49
-     * This will hold the incoming data item sent to the parser method
50
-     *
51
-     * @access protected
52
-     * @var mixed (array|object)
53
-     */
54
-    protected $_data;
55
-
56
-
57
-    /**
58
-     * some shortcodes may require extra data to parse.  This property is provided for that.
59
-     *
60
-     * @var array
61
-     */
62
-    protected $_extra_data;
63
-
64
-
65
-    /**
66
-     * EE_messenger used to generate the template being parsed.
67
-     *
68
-     * @since 4.5.0
69
-     * @var EE_messenger
70
-     */
71
-    protected $_messenger;
72
-
73
-
74
-    /**
75
-     * message type used to generate the template being parsed.
76
-     *
77
-     * @since 4.5.0
78
-     * @var EE_message_type
79
-     */
80
-    protected $_message_type;
81
-
82
-
83
-    /**
84
-     * context used for the template being parsed
85
-     *
86
-     * @since 4.5.0
87
-     * @var string
88
-     */
89
-    protected $_context;
90
-
91
-
92
-    /**
93
-     * Specific Message Template Group ID
94
-     *
95
-     * @since 4.5.0
96
-     * @var int
97
-     */
98
-    protected $_GRP_ID;
99
-
100
-
101
-    /**
102
-     * @since 4.9.0
103
-     * @type EE_Message
104
-     */
105
-    protected $_message;
106
-
107
-
108
-    /**
109
-     * This will hold an instance of the EEH_Parse_Shortcodes helper that will be used when handling list type
110
-     * shortcodes
111
-     *
112
-     * @var EEH_Parse_Shortcodes
113
-     */
114
-    protected $_shortcode_helper;
115
-
116
-
117
-    public function __construct()
118
-    {
119
-        $this->_set_defaults();
120
-        $this->_init_props();
121
-    }
122
-
123
-
124
-    /**
125
-     * This sets the defaults for the properties.  Child classes will override these properties in their _init_props
126
-     * method
127
-     */
128
-    private function _set_defaults()
129
-    {
130
-        $this->name = $this->description = '';
131
-        $this->_shortcodes = array();
132
-        $this->_set_shortcode_helper();
133
-    }
134
-
135
-
136
-    /**
137
-     * loads an instance of the EE_Shortcode_Parser helper when requested
138
-     */
139
-    protected function _set_shortcode_helper()
140
-    {
141
-        // get shortcode_replace instance- set when _get_messages is called in child...
142
-        $this->_shortcode_helper = new EEH_Parse_Shortcodes();
143
-    }
144
-
145
-
146
-    public function get_shortcode_helper()
147
-    {
148
-        if (! $this->_shortcode_helper instanceof EEH_Parse_Shortcodes) {
149
-            $this->_set_shortcode_helper();
150
-        }
151
-        return $this->_shortcode_helper;
152
-    }
153
-
154
-
155
-    /**
156
-     * This is the public method for kicking of the parser included with each child.  It can be overridden by child
157
-     * classes if necessary (see EE_Questions_Answers for example)
158
-     *
159
-     * @param  string $shortcode incoming shortcode to be parsed
160
-     * @param  mixed (object|array) $data       incoming data to be be used for parsing
161
-     * @param  mixed (object|array) $extra_data extra incoming data (usually EE_Messages_Addressee)
162
-     * @return string            parsed shortcode.
163
-     */
164
-    public function parser($shortcode, $data, $extra_data = array())
165
-    {
166
-
167
-        // filter setup shortcodes
168
-        $this->_shortcodes = $this->get_shortcodes();
169
-
170
-        // we need to setup any dynamic shortcodes so that they work with the array_key_exists
171
-        preg_match_all('/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches);
172
-        $sc_to_verify = ! empty($matches[0]) ? $matches[0][0] . ']' : $shortcode;
173
-
174
-        // first we want to make sure this is a valid shortcode
175
-        if (! array_key_exists($sc_to_verify, $this->_shortcodes)) {
176
-            return false;
177
-        } //get out, this parser doesn't handle the incoming shortcode.
178
-        $this->_data = $data;
179
-        $this->_extra_data = $extra_data;
180
-        $this->_set_messages_properties();
181
-        $parsed = apply_filters(
182
-            'FHEE__' . get_class($this) . '__parser_after',
183
-            $this->_parser($shortcode),
184
-            $shortcode,
185
-            $data,
186
-            $extra_data,
187
-            $this
188
-        );
189
-
190
-        // note the below filter applies to ALL shortcode parsers... be careful!
191
-        return apply_filters('FHEE__EE_Shortcodes__parser_after', $parsed, $shortcode, $data, $extra_data, $this);
192
-    }
193
-
194
-
195
-    /**
196
-     * This method just returns the shortcodes in the $_shortcodes array property.
197
-     *
198
-     * @access public
199
-     * @return array array of shortcodes => description pairs
200
-     */
201
-    public function get_shortcodes()
202
-    {
203
-        $this->_shortcodes = apply_filters('FHEE__' . get_class($this) . '__shortcodes', $this->_shortcodes, $this);
204
-
205
-        // note the below filter applies to ALL shortcode parsers... be careful!
206
-        $this->_shortcodes = apply_filters('FHEE__EE_Shortcodes__shortcodes', $this->_shortcodes, $this);
207
-
208
-        return $this->_shortcodes;
209
-    }
210
-
211
-
212
-    /**
213
-     * Child classes use this method to set the $name, $description, and $_shortcodes properties.
214
-     *
215
-     * @abstract
216
-     * @access protected
217
-     * @return void
218
-     */
219
-    abstract protected function _init_props();
220
-
221
-
222
-    /**
223
-     * This method will give parsing instructions for each shortcode defined in the _shortcodes array.  Child methods
224
-     * will have to take care of handling.
225
-     *
226
-     * @abstract
227
-     * @access protected
228
-     * @param string $shortcode    the shortcode to be parsed.
229
-     * @param mixed (object|array) $data      incoming data for the parser.  The data could be either an object or
230
-     *                             array because there are some shortcodes that might be replaced by prepared data that
231
-     *                             has multiple items in a list (i.e. list of attendees in an event and we're showing
232
-     *                             fname/lname for each attendee).  In this case data will be in an array.  Otherwise
233
-     *                             the data shoudl be in a properly formatted object.  The
234
-     *                             EEH_Parse_Shortcodes.helper.php describes the data object we're expecting.
235
-     * @return string parsed shortcode
236
-     */
237
-    abstract protected function _parser($shortcode);
238
-
239
-
240
-    /**
241
-     * This just validates incoming data for list type shortcode parsers (and they call this method) to make sure it
242
-     * meets their requirements
243
-     *
244
-     * @return mixed (void|exception) If validation fails we'll throw an exception.
245
-     */
246
-    protected function _validate_list_requirements()
247
-    {
248
-
249
-        // first test to make sure we've got an array!
250
-        if (! is_array($this->_data)) {
251
-            throw new EE_Error(
252
-                sprintf(
253
-                    esc_html__(
254
-                        'Expecting an array for the data sent to %s. Instead it was %s',
255
-                        'event_espresso'
256
-                    ),
257
-                    get_class($this),
258
-                    gettype($this->_data)
259
-                )
260
-            );
261
-        }
262
-
263
-        // next test to make sure we've got the required template in the index!
264
-        if (! isset($this->_data['template'])) {
265
-            throw new EE_Error(
266
-                sprintf(
267
-                    esc_html__(
268
-                        'The incoming data does not have the required template index in its array',
269
-                        'event_espresso'
270
-                    )
271
-                )
272
-            );
273
-        }
274
-
275
-        // next test to make sure we've got got a data index in the incoming data array
276
-        if (! isset($this->_data['data'])) {
277
-            throw new EE_Error(
278
-                esc_html__(
279
-                    'The incoming data does not have the required data index in its array',
280
-                    'event_espresso'
281
-                )
282
-            );
283
-        }
284
-
285
-        // all is well let's make sure _extra_data always has the values needed.
286
-        // let's make sure that extra_data includes all templates (for later parsing if necessary)
287
-        if (empty($this->_extra_data) || (empty($this->_extra_data['data']) && empty($this->_extra_data['template']))) {
288
-            $this->_extra_data['data'] = $this->_data['data'];
289
-            $this->_extra_data['template'] = $this->_data['template'];
290
-        }
291
-    }
292
-
293
-
294
-    /**
295
-     * This returns any attributes that may be existing on an EE_Shortcode
296
-     *
297
-     * @since 4.5.0
298
-     * @param string $shortcode incoming shortcode
299
-     * @return array An array with the attributes
300
-     */
301
-    protected function _get_shortcode_attrs($shortcode)
302
-    {
303
-        // make sure the required wp helper function is present
304
-        // require the shortcode file if necessary
305
-        if (! function_exists('shortcode_parse_atts')) {
306
-            require_once(ABSPATH . WPINC . '/shortcodes.php');
307
-        }
308
-
309
-        // let's get any attributes that may be present and set the defaults.
310
-        $shortcode_to_parse = str_replace('[', '', str_replace(']', '', $shortcode));
311
-        return shortcode_parse_atts($shortcode_to_parse);
312
-    }
313
-
314
-
315
-    /**
316
-     * Conditional blocks are shortcode patterns with an opening conditional tag `[IF_*]` and a corresponding
317
-     * closing tag (eg `[/IF_*]`).  The content within the tags will be displayed/hidden depending on whatever
318
-     * conditions existed in the opening tag.  This method handles parsing the actual template to show/hide this
319
-     * conditional content.
320
-     *
321
-     * @since 4.9.32
322
-     *
323
-     * @param string $shortcode This should be original shortcode as used in the template and passed to the parser.
324
-     * @param bool   $show      true means the opening and closing tags are removed and the content is left showing,
325
-     *                          false means the opening and closing tags and the contained content are removed.
326
-     * @return string     The template for the shortcode is returned.
327
-     */
328
-    protected function _mutate_conditional_block_in_template($shortcode, $show = true)
329
-    {
330
-        // first let's get all the matches in the template for this particular shortcode.
331
-        preg_match_all('~' . $this->_get_conditional_block_regex($shortcode) . '~', $this->_data['template'], $matches);
332
-
333
-        if ($matches && is_array($matches[0]) && ! empty($matches[0])) {
334
-            // we need to hide all instances of the matches
335
-            foreach ($matches[0] as $index => $content_to_show_or_hide) {
336
-                $content_to_show_or_hide = preg_quote($content_to_show_or_hide);
337
-                $replacement = $show ? $matches[4][ $index ] : '';
338
-                $this->_data['template'] = preg_replace(
339
-                    '~' . $content_to_show_or_hide . '~',
340
-                    $replacement,
341
-                    $this->_data['template']
342
-                );
343
-            }
344
-        }
345
-        // return $template
346
-        return $this->_data['template'];
347
-    }
348
-
349
-
350
-    /**
351
-     * This returns the regex pattern to use for conditional shortcodes parsing.
352
-     *
353
-     * Note: regex comes in part from the WP `get_shortcode_regex` expression in \wp-includes\shortcodes.php
354
-     *
355
-     * @param $shortcode
356
-     * @since 4.9.32
357
-     * @return string
358
-     */
359
-    private function _get_conditional_block_regex($shortcode)
360
-    {
361
-        // get just the shortcode tag for the match
362
-        preg_match('@\[([^<>&/\[\]\x00-\x20=]++)@', $shortcode, $shortcode_tag_matches);
363
-        if (empty($shortcode_tag_matches[1])) {
364
-            return $this->_data['template'];
365
-        }
366
-
367
-        $shortcode_tag = $shortcode_tag_matches[1];
368
-        // get attributes_part_of_tag
369
-        $attributes_part = preg_quote(str_replace(array($shortcode_tag, '[', ']'), '', $shortcode));
370
-        // escape
371
-        $shortcode_tag = preg_quote($shortcode_tag);
372
-
373
-        return
374
-            '\['                                  // Opening Bracket
375
-            . "($shortcode_tag)$attributes_part"    // 1: Shortcode Name
376
-            . '(?![\w-])'                           // Not followed by word character or hyphen
377
-            . '('                                   // 2: Unroll the loop: Inside the opening shortcode tag
378
-            . '[^\]\/]*'                          // Not a closing bracket or forward slash
379
-            . '(?:'
380
-            . '\/(?!\])'                      // A forward slash not followed by a closing bracket
381
-            . '[^\]\/]*'                      // Not a closing bracket or forward slash.
382
-            . ')*?'
383
-            . ')'
384
-            . '(?:'
385
-            . '(\/)'                              // 3. Self closing tag ...
386
-            . '\]'                                // ... and closing bracket
387
-            . '|'
388
-            . '\]'                                // Closing bracket
389
-            . '(?:'
390
-            . '('                             // 4: Unroll the loop: Optionally, anything between the opening and closing brackets
391
-            . '[^\[]*+'                   // Not an opening bracket
392
-            . '(?:'
393
-            . '\[(?!\/\1\])'          // An opening bracket not followed by the closing shortcode tag.
394
-            . '[^\[]*+'               // Not an opening bracket
395
-            . ')*+'
396
-            . ')'
397
-            . '\[\/\1\]'                      // Closing shortcode tag
398
-            . ')?'
399
-            . ')';
400
-    }
401
-
402
-
403
-    /**
404
-     * This sets the properties related to the messages system
405
-     *
406
-     * @since 4.5.0
407
-     * @return void
408
-     */
409
-    protected function _set_messages_properties()
410
-    {
411
-        // should be in _extra_data
412
-        if (isset($this->_extra_data['messenger'])) {
413
-            $this->_messenger = $this->_extra_data['messenger'];
414
-            $this->_message_type = $this->_extra_data['message_type'];
415
-            $this->_context = $this->_extra_data['message'] instanceof EE_Message
416
-                ? $this->_extra_data['message']->context() : '';
417
-            $this->_GRP_ID = $this->_extra_data['message'] instanceof EE_Message
418
-                ? $this->_extra_data['message']->GRP_ID() : 0;
419
-            $this->_message = $this->_extra_data['message'] instanceof EE_Message ? $this->_extra_data['message']
420
-                : null;
421
-        }
422
-    }
423
-
424
-
425
-    /**
426
-     * This returns whatever the set message type object is that was set on this shortcode parser.
427
-     *
428
-     * @since 4.5.0
429
-     * @return EE_message_type
430
-     */
431
-    public function get_set_message_type()
432
-    {
433
-        return $this->_message_type;
434
-    }
435
-
436
-
437
-    /**
438
-     * This returns whatever the set messenger object is that was set on this shortcode parser
439
-     *
440
-     * @since 4.5.0
441
-     * @return EE_messenger
442
-     */
443
-    public function get_set_messenger()
444
-    {
445
-        return $this->_messenger;
446
-    }
447
-
448
-
449
-    /**
450
-     * This returns whatever the set context string is on this shortcode parser.
451
-     *
452
-     * @since 4.5.0
453
-     * @return string
454
-     */
455
-    public function get_set_context()
456
-    {
457
-        return $this->_context;
458
-    }
459
-
460
-
461
-    /**
462
-     * This returns whatever the set EE_Message object is on this shortcode.
463
-     *
464
-     * @since 4.9.0
465
-     * @return EE_Message
466
-     */
467
-    public function get_set_message()
468
-    {
469
-        return $this->_message;
470
-    }
19
+	/**
20
+	 * holds label for library
21
+	 * This is used for referencing the library label
22
+	 *
23
+	 * @access public
24
+	 * @var string
25
+	 */
26
+	public $label;
27
+
28
+
29
+	/**
30
+	 * This property is used for referencing a short description of the library
31
+	 *
32
+	 * @access public
33
+	 * @var string
34
+	 */
35
+	public $description;
36
+
37
+
38
+	/**
39
+	 * This will hold an array of shortcodes with the key as the shortcode ([shortcode]) and the value as a
40
+	 * label/description for the shortcode.
41
+	 *
42
+	 * @access protected
43
+	 * @var array
44
+	 */
45
+	protected $_shortcodes;
46
+
47
+
48
+	/**
49
+	 * This will hold the incoming data item sent to the parser method
50
+	 *
51
+	 * @access protected
52
+	 * @var mixed (array|object)
53
+	 */
54
+	protected $_data;
55
+
56
+
57
+	/**
58
+	 * some shortcodes may require extra data to parse.  This property is provided for that.
59
+	 *
60
+	 * @var array
61
+	 */
62
+	protected $_extra_data;
63
+
64
+
65
+	/**
66
+	 * EE_messenger used to generate the template being parsed.
67
+	 *
68
+	 * @since 4.5.0
69
+	 * @var EE_messenger
70
+	 */
71
+	protected $_messenger;
72
+
73
+
74
+	/**
75
+	 * message type used to generate the template being parsed.
76
+	 *
77
+	 * @since 4.5.0
78
+	 * @var EE_message_type
79
+	 */
80
+	protected $_message_type;
81
+
82
+
83
+	/**
84
+	 * context used for the template being parsed
85
+	 *
86
+	 * @since 4.5.0
87
+	 * @var string
88
+	 */
89
+	protected $_context;
90
+
91
+
92
+	/**
93
+	 * Specific Message Template Group ID
94
+	 *
95
+	 * @since 4.5.0
96
+	 * @var int
97
+	 */
98
+	protected $_GRP_ID;
99
+
100
+
101
+	/**
102
+	 * @since 4.9.0
103
+	 * @type EE_Message
104
+	 */
105
+	protected $_message;
106
+
107
+
108
+	/**
109
+	 * This will hold an instance of the EEH_Parse_Shortcodes helper that will be used when handling list type
110
+	 * shortcodes
111
+	 *
112
+	 * @var EEH_Parse_Shortcodes
113
+	 */
114
+	protected $_shortcode_helper;
115
+
116
+
117
+	public function __construct()
118
+	{
119
+		$this->_set_defaults();
120
+		$this->_init_props();
121
+	}
122
+
123
+
124
+	/**
125
+	 * This sets the defaults for the properties.  Child classes will override these properties in their _init_props
126
+	 * method
127
+	 */
128
+	private function _set_defaults()
129
+	{
130
+		$this->name = $this->description = '';
131
+		$this->_shortcodes = array();
132
+		$this->_set_shortcode_helper();
133
+	}
134
+
135
+
136
+	/**
137
+	 * loads an instance of the EE_Shortcode_Parser helper when requested
138
+	 */
139
+	protected function _set_shortcode_helper()
140
+	{
141
+		// get shortcode_replace instance- set when _get_messages is called in child...
142
+		$this->_shortcode_helper = new EEH_Parse_Shortcodes();
143
+	}
144
+
145
+
146
+	public function get_shortcode_helper()
147
+	{
148
+		if (! $this->_shortcode_helper instanceof EEH_Parse_Shortcodes) {
149
+			$this->_set_shortcode_helper();
150
+		}
151
+		return $this->_shortcode_helper;
152
+	}
153
+
154
+
155
+	/**
156
+	 * This is the public method for kicking of the parser included with each child.  It can be overridden by child
157
+	 * classes if necessary (see EE_Questions_Answers for example)
158
+	 *
159
+	 * @param  string $shortcode incoming shortcode to be parsed
160
+	 * @param  mixed (object|array) $data       incoming data to be be used for parsing
161
+	 * @param  mixed (object|array) $extra_data extra incoming data (usually EE_Messages_Addressee)
162
+	 * @return string            parsed shortcode.
163
+	 */
164
+	public function parser($shortcode, $data, $extra_data = array())
165
+	{
166
+
167
+		// filter setup shortcodes
168
+		$this->_shortcodes = $this->get_shortcodes();
169
+
170
+		// we need to setup any dynamic shortcodes so that they work with the array_key_exists
171
+		preg_match_all('/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches);
172
+		$sc_to_verify = ! empty($matches[0]) ? $matches[0][0] . ']' : $shortcode;
173
+
174
+		// first we want to make sure this is a valid shortcode
175
+		if (! array_key_exists($sc_to_verify, $this->_shortcodes)) {
176
+			return false;
177
+		} //get out, this parser doesn't handle the incoming shortcode.
178
+		$this->_data = $data;
179
+		$this->_extra_data = $extra_data;
180
+		$this->_set_messages_properties();
181
+		$parsed = apply_filters(
182
+			'FHEE__' . get_class($this) . '__parser_after',
183
+			$this->_parser($shortcode),
184
+			$shortcode,
185
+			$data,
186
+			$extra_data,
187
+			$this
188
+		);
189
+
190
+		// note the below filter applies to ALL shortcode parsers... be careful!
191
+		return apply_filters('FHEE__EE_Shortcodes__parser_after', $parsed, $shortcode, $data, $extra_data, $this);
192
+	}
193
+
194
+
195
+	/**
196
+	 * This method just returns the shortcodes in the $_shortcodes array property.
197
+	 *
198
+	 * @access public
199
+	 * @return array array of shortcodes => description pairs
200
+	 */
201
+	public function get_shortcodes()
202
+	{
203
+		$this->_shortcodes = apply_filters('FHEE__' . get_class($this) . '__shortcodes', $this->_shortcodes, $this);
204
+
205
+		// note the below filter applies to ALL shortcode parsers... be careful!
206
+		$this->_shortcodes = apply_filters('FHEE__EE_Shortcodes__shortcodes', $this->_shortcodes, $this);
207
+
208
+		return $this->_shortcodes;
209
+	}
210
+
211
+
212
+	/**
213
+	 * Child classes use this method to set the $name, $description, and $_shortcodes properties.
214
+	 *
215
+	 * @abstract
216
+	 * @access protected
217
+	 * @return void
218
+	 */
219
+	abstract protected function _init_props();
220
+
221
+
222
+	/**
223
+	 * This method will give parsing instructions for each shortcode defined in the _shortcodes array.  Child methods
224
+	 * will have to take care of handling.
225
+	 *
226
+	 * @abstract
227
+	 * @access protected
228
+	 * @param string $shortcode    the shortcode to be parsed.
229
+	 * @param mixed (object|array) $data      incoming data for the parser.  The data could be either an object or
230
+	 *                             array because there are some shortcodes that might be replaced by prepared data that
231
+	 *                             has multiple items in a list (i.e. list of attendees in an event and we're showing
232
+	 *                             fname/lname for each attendee).  In this case data will be in an array.  Otherwise
233
+	 *                             the data shoudl be in a properly formatted object.  The
234
+	 *                             EEH_Parse_Shortcodes.helper.php describes the data object we're expecting.
235
+	 * @return string parsed shortcode
236
+	 */
237
+	abstract protected function _parser($shortcode);
238
+
239
+
240
+	/**
241
+	 * This just validates incoming data for list type shortcode parsers (and they call this method) to make sure it
242
+	 * meets their requirements
243
+	 *
244
+	 * @return mixed (void|exception) If validation fails we'll throw an exception.
245
+	 */
246
+	protected function _validate_list_requirements()
247
+	{
248
+
249
+		// first test to make sure we've got an array!
250
+		if (! is_array($this->_data)) {
251
+			throw new EE_Error(
252
+				sprintf(
253
+					esc_html__(
254
+						'Expecting an array for the data sent to %s. Instead it was %s',
255
+						'event_espresso'
256
+					),
257
+					get_class($this),
258
+					gettype($this->_data)
259
+				)
260
+			);
261
+		}
262
+
263
+		// next test to make sure we've got the required template in the index!
264
+		if (! isset($this->_data['template'])) {
265
+			throw new EE_Error(
266
+				sprintf(
267
+					esc_html__(
268
+						'The incoming data does not have the required template index in its array',
269
+						'event_espresso'
270
+					)
271
+				)
272
+			);
273
+		}
274
+
275
+		// next test to make sure we've got got a data index in the incoming data array
276
+		if (! isset($this->_data['data'])) {
277
+			throw new EE_Error(
278
+				esc_html__(
279
+					'The incoming data does not have the required data index in its array',
280
+					'event_espresso'
281
+				)
282
+			);
283
+		}
284
+
285
+		// all is well let's make sure _extra_data always has the values needed.
286
+		// let's make sure that extra_data includes all templates (for later parsing if necessary)
287
+		if (empty($this->_extra_data) || (empty($this->_extra_data['data']) && empty($this->_extra_data['template']))) {
288
+			$this->_extra_data['data'] = $this->_data['data'];
289
+			$this->_extra_data['template'] = $this->_data['template'];
290
+		}
291
+	}
292
+
293
+
294
+	/**
295
+	 * This returns any attributes that may be existing on an EE_Shortcode
296
+	 *
297
+	 * @since 4.5.0
298
+	 * @param string $shortcode incoming shortcode
299
+	 * @return array An array with the attributes
300
+	 */
301
+	protected function _get_shortcode_attrs($shortcode)
302
+	{
303
+		// make sure the required wp helper function is present
304
+		// require the shortcode file if necessary
305
+		if (! function_exists('shortcode_parse_atts')) {
306
+			require_once(ABSPATH . WPINC . '/shortcodes.php');
307
+		}
308
+
309
+		// let's get any attributes that may be present and set the defaults.
310
+		$shortcode_to_parse = str_replace('[', '', str_replace(']', '', $shortcode));
311
+		return shortcode_parse_atts($shortcode_to_parse);
312
+	}
313
+
314
+
315
+	/**
316
+	 * Conditional blocks are shortcode patterns with an opening conditional tag `[IF_*]` and a corresponding
317
+	 * closing tag (eg `[/IF_*]`).  The content within the tags will be displayed/hidden depending on whatever
318
+	 * conditions existed in the opening tag.  This method handles parsing the actual template to show/hide this
319
+	 * conditional content.
320
+	 *
321
+	 * @since 4.9.32
322
+	 *
323
+	 * @param string $shortcode This should be original shortcode as used in the template and passed to the parser.
324
+	 * @param bool   $show      true means the opening and closing tags are removed and the content is left showing,
325
+	 *                          false means the opening and closing tags and the contained content are removed.
326
+	 * @return string     The template for the shortcode is returned.
327
+	 */
328
+	protected function _mutate_conditional_block_in_template($shortcode, $show = true)
329
+	{
330
+		// first let's get all the matches in the template for this particular shortcode.
331
+		preg_match_all('~' . $this->_get_conditional_block_regex($shortcode) . '~', $this->_data['template'], $matches);
332
+
333
+		if ($matches && is_array($matches[0]) && ! empty($matches[0])) {
334
+			// we need to hide all instances of the matches
335
+			foreach ($matches[0] as $index => $content_to_show_or_hide) {
336
+				$content_to_show_or_hide = preg_quote($content_to_show_or_hide);
337
+				$replacement = $show ? $matches[4][ $index ] : '';
338
+				$this->_data['template'] = preg_replace(
339
+					'~' . $content_to_show_or_hide . '~',
340
+					$replacement,
341
+					$this->_data['template']
342
+				);
343
+			}
344
+		}
345
+		// return $template
346
+		return $this->_data['template'];
347
+	}
348
+
349
+
350
+	/**
351
+	 * This returns the regex pattern to use for conditional shortcodes parsing.
352
+	 *
353
+	 * Note: regex comes in part from the WP `get_shortcode_regex` expression in \wp-includes\shortcodes.php
354
+	 *
355
+	 * @param $shortcode
356
+	 * @since 4.9.32
357
+	 * @return string
358
+	 */
359
+	private function _get_conditional_block_regex($shortcode)
360
+	{
361
+		// get just the shortcode tag for the match
362
+		preg_match('@\[([^<>&/\[\]\x00-\x20=]++)@', $shortcode, $shortcode_tag_matches);
363
+		if (empty($shortcode_tag_matches[1])) {
364
+			return $this->_data['template'];
365
+		}
366
+
367
+		$shortcode_tag = $shortcode_tag_matches[1];
368
+		// get attributes_part_of_tag
369
+		$attributes_part = preg_quote(str_replace(array($shortcode_tag, '[', ']'), '', $shortcode));
370
+		// escape
371
+		$shortcode_tag = preg_quote($shortcode_tag);
372
+
373
+		return
374
+			'\['                                  // Opening Bracket
375
+			. "($shortcode_tag)$attributes_part"    // 1: Shortcode Name
376
+			. '(?![\w-])'                           // Not followed by word character or hyphen
377
+			. '('                                   // 2: Unroll the loop: Inside the opening shortcode tag
378
+			. '[^\]\/]*'                          // Not a closing bracket or forward slash
379
+			. '(?:'
380
+			. '\/(?!\])'                      // A forward slash not followed by a closing bracket
381
+			. '[^\]\/]*'                      // Not a closing bracket or forward slash.
382
+			. ')*?'
383
+			. ')'
384
+			. '(?:'
385
+			. '(\/)'                              // 3. Self closing tag ...
386
+			. '\]'                                // ... and closing bracket
387
+			. '|'
388
+			. '\]'                                // Closing bracket
389
+			. '(?:'
390
+			. '('                             // 4: Unroll the loop: Optionally, anything between the opening and closing brackets
391
+			. '[^\[]*+'                   // Not an opening bracket
392
+			. '(?:'
393
+			. '\[(?!\/\1\])'          // An opening bracket not followed by the closing shortcode tag.
394
+			. '[^\[]*+'               // Not an opening bracket
395
+			. ')*+'
396
+			. ')'
397
+			. '\[\/\1\]'                      // Closing shortcode tag
398
+			. ')?'
399
+			. ')';
400
+	}
401
+
402
+
403
+	/**
404
+	 * This sets the properties related to the messages system
405
+	 *
406
+	 * @since 4.5.0
407
+	 * @return void
408
+	 */
409
+	protected function _set_messages_properties()
410
+	{
411
+		// should be in _extra_data
412
+		if (isset($this->_extra_data['messenger'])) {
413
+			$this->_messenger = $this->_extra_data['messenger'];
414
+			$this->_message_type = $this->_extra_data['message_type'];
415
+			$this->_context = $this->_extra_data['message'] instanceof EE_Message
416
+				? $this->_extra_data['message']->context() : '';
417
+			$this->_GRP_ID = $this->_extra_data['message'] instanceof EE_Message
418
+				? $this->_extra_data['message']->GRP_ID() : 0;
419
+			$this->_message = $this->_extra_data['message'] instanceof EE_Message ? $this->_extra_data['message']
420
+				: null;
421
+		}
422
+	}
423
+
424
+
425
+	/**
426
+	 * This returns whatever the set message type object is that was set on this shortcode parser.
427
+	 *
428
+	 * @since 4.5.0
429
+	 * @return EE_message_type
430
+	 */
431
+	public function get_set_message_type()
432
+	{
433
+		return $this->_message_type;
434
+	}
435
+
436
+
437
+	/**
438
+	 * This returns whatever the set messenger object is that was set on this shortcode parser
439
+	 *
440
+	 * @since 4.5.0
441
+	 * @return EE_messenger
442
+	 */
443
+	public function get_set_messenger()
444
+	{
445
+		return $this->_messenger;
446
+	}
447
+
448
+
449
+	/**
450
+	 * This returns whatever the set context string is on this shortcode parser.
451
+	 *
452
+	 * @since 4.5.0
453
+	 * @return string
454
+	 */
455
+	public function get_set_context()
456
+	{
457
+		return $this->_context;
458
+	}
459
+
460
+
461
+	/**
462
+	 * This returns whatever the set EE_Message object is on this shortcode.
463
+	 *
464
+	 * @since 4.9.0
465
+	 * @return EE_Message
466
+	 */
467
+	public function get_set_message()
468
+	{
469
+		return $this->_message;
470
+	}
471 471
 }
Please login to merge, or discard this patch.
core/libraries/iframe_display/IframeEmbedButton.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
         $id
97 97
     ) {
98 98
         // make sure this is ONLY when editing and the event id has been set.
99
-        if (! empty($id)) {
99
+        if ( ! empty($id)) {
100 100
             $post = get_post($id);
101 101
             // if NOT event then let's get out.
102 102
             if ($post->post_type !== 'espresso_events') {
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
                 : array($this->route_name => $embedButtonHtml) + $filterable_content;
170 170
         } else {
171 171
             $filterable_content = $this->append_filterable_content
172
-                ? $filterable_content . $embedButtonHtml
173
-                : $embedButtonHtml . $filterable_content;
172
+                ? $filterable_content.$embedButtonHtml
173
+                : $embedButtonHtml.$filterable_content;
174 174
         }
175 175
         return $filterable_content;
176 176
     }
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
         $iframe_module_routes = isset(\EE_Registry::$i18n_js_strings['iframe_module_routes'])
196 196
             ? \EE_Registry::$i18n_js_strings['iframe_module_routes']
197 197
             : array();
198
-        $iframe_module_routes[ $this->route_name ] = $this->route_name;
198
+        $iframe_module_routes[$this->route_name] = $this->route_name;
199 199
         \EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes;
200 200
         $iframe_embed_html = \EEH_HTML::link(
201 201
             '#',
@@ -207,20 +207,20 @@  discard block
 block discarded – undo
207 207
                 ),
208 208
                 \EEH_Inflector::add_indefinite_article($this->iframe_name)
209 209
             ),
210
-            esc_attr($this->route_name) . "-iframe-embed-trigger-js",
211
-            'iframe-embed-trigger-js button ' . esc_attr($button_class),
210
+            esc_attr($this->route_name)."-iframe-embed-trigger-js",
211
+            'iframe-embed-trigger-js button '.esc_attr($button_class),
212 212
             '',
213
-            ' data-iframe_embed_button="#' . esc_attr($this->route_name) . '-iframe-js" tabindex="-1"'
213
+            ' data-iframe_embed_button="#'.esc_attr($this->route_name).'-iframe-js" tabindex="-1"'
214 214
         );
215 215
         $iframe_embed_html .= \EEH_HTML::div(
216 216
             '',
217
-            esc_attr($this->route_name) . "-iframe-js",
217
+            esc_attr($this->route_name)."-iframe-js",
218 218
             'iframe-embed-wrapper-js',
219 219
             'display:none;'
220 220
         );
221 221
         $iframe_embed_html .= esc_html(
222 222
             \EEH_HTML::div(
223
-                '<iframe src="' . esc_url_raw(add_query_arg($query_args, site_url())) . '" width="100%" height="100%"></iframe>',
223
+                '<iframe src="'.esc_url_raw(add_query_arg($query_args, site_url())).'" width="100%" height="100%"></iframe>',
224 224
                 '',
225 225
                 '',
226 226
                 'width:100%; height: 500px;'
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
         );
247 247
         wp_register_script(
248 248
             'iframe_embed_button',
249
-            plugin_dir_url(__FILE__) . 'iframe-embed-button.js',
249
+            plugin_dir_url(__FILE__).'iframe-embed-button.js',
250 250
             array('ee-dialog'),
251 251
             EVENT_ESPRESSO_VERSION,
252 252
             true
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
                 'event_espresso'
280 280
             )
281 281
         );
282
-        $html .= ' &nbsp; ' . implode(' &nbsp; ', $embed_buttons) . ' ';
282
+        $html .= ' &nbsp; '.implode(' &nbsp; ', $embed_buttons).' ';
283 283
         $html .= \EEH_HTML::br(2);
284 284
         return $html;
285 285
     }
Please login to merge, or discard this patch.
Indentation   +245 added lines, -245 removed lines patch added patch discarded remove patch
@@ -13,274 +13,274 @@
 block discarded – undo
13 13
  */
14 14
 abstract class IframeEmbedButton
15 15
 {
16
-    /**
17
-     * @var string $iframe_name
18
-     */
19
-    private $iframe_name;
16
+	/**
17
+	 * @var string $iframe_name
18
+	 */
19
+	private $iframe_name;
20 20
 
21
-    /**
22
-     * @var string $route_name
23
-     */
24
-    private $route_name;
21
+	/**
22
+	 * @var string $route_name
23
+	 */
24
+	private $route_name;
25 25
 
26
-    /**
27
-     * @var string $slug
28
-     */
29
-    private $slug;
26
+	/**
27
+	 * @var string $slug
28
+	 */
29
+	private $slug;
30 30
 
31
-    /**
32
-     * @var boolean $append_filterable_content
33
-     */
34
-    private $append_filterable_content;
31
+	/**
32
+	 * @var boolean $append_filterable_content
33
+	 */
34
+	private $append_filterable_content;
35 35
 
36 36
 
37
-    /**
38
-     * IframeEmbedButton constructor.
39
-     *
40
-     * @param string $iframe_name i18n name for the iframe. This will be used in HTML
41
-     * @param string $route_name  the name of the registered route
42
-     * @param string $slug        URL slug used for the thing the iframe button is being embedded in.
43
-     *                            will most likely be "event" since that's the only usage atm
44
-     */
45
-    public function __construct($iframe_name, $route_name, $slug = 'event')
46
-    {
47
-        $this->iframe_name = $iframe_name;
48
-        $this->route_name = $route_name;
49
-        $this->slug = $slug;
50
-    }
37
+	/**
38
+	 * IframeEmbedButton constructor.
39
+	 *
40
+	 * @param string $iframe_name i18n name for the iframe. This will be used in HTML
41
+	 * @param string $route_name  the name of the registered route
42
+	 * @param string $slug        URL slug used for the thing the iframe button is being embedded in.
43
+	 *                            will most likely be "event" since that's the only usage atm
44
+	 */
45
+	public function __construct($iframe_name, $route_name, $slug = 'event')
46
+	{
47
+		$this->iframe_name = $iframe_name;
48
+		$this->route_name = $route_name;
49
+		$this->slug = $slug;
50
+	}
51 51
 
52 52
 
53
-    /**
54
-     * Adds an iframe embed code button to the Event editor.
55
-     */
56
-    public function addEventEditorIframeEmbedButtonFilter()
57
-    {
58
-        // add button for iframe code to event editor.
59
-        add_filter(
60
-            'get_sample_permalink_html',
61
-            array($this, 'appendIframeEmbedButtonToSamplePermalinkHtml'),
62
-            10,
63
-            2
64
-        );
65
-        add_action(
66
-            'admin_enqueue_scripts',
67
-            array($this, 'embedButtonAssets'),
68
-            10
69
-        );
70
-    }
53
+	/**
54
+	 * Adds an iframe embed code button to the Event editor.
55
+	 */
56
+	public function addEventEditorIframeEmbedButtonFilter()
57
+	{
58
+		// add button for iframe code to event editor.
59
+		add_filter(
60
+			'get_sample_permalink_html',
61
+			array($this, 'appendIframeEmbedButtonToSamplePermalinkHtml'),
62
+			10,
63
+			2
64
+		);
65
+		add_action(
66
+			'admin_enqueue_scripts',
67
+			array($this, 'embedButtonAssets'),
68
+			10
69
+		);
70
+	}
71 71
 
72 72
 
73
-    /**
74
-     * @param $permalink_string
75
-     * @param $id
76
-     * @return string
77
-     */
78
-    public function appendIframeEmbedButtonToSamplePermalinkHtml($permalink_string, $id)
79
-    {
80
-        return $this->eventEditorIframeEmbedButton(
81
-            $permalink_string,
82
-            $id
83
-        );
84
-    }
73
+	/**
74
+	 * @param $permalink_string
75
+	 * @param $id
76
+	 * @return string
77
+	 */
78
+	public function appendIframeEmbedButtonToSamplePermalinkHtml($permalink_string, $id)
79
+	{
80
+		return $this->eventEditorIframeEmbedButton(
81
+			$permalink_string,
82
+			$id
83
+		);
84
+	}
85 85
 
86 86
 
87
-    /**
88
-     * iframe embed code button to the Event editor.
89
-     *
90
-     * @param string $permalink_string
91
-     * @param int    $id
92
-     * @return string
93
-     */
94
-    public function eventEditorIframeEmbedButton(
95
-        $permalink_string,
96
-        $id
97
-    ) {
98
-        // make sure this is ONLY when editing and the event id has been set.
99
-        if (! empty($id)) {
100
-            $post = get_post($id);
101
-            // if NOT event then let's get out.
102
-            if ($post->post_type !== 'espresso_events') {
103
-                return $permalink_string;
104
-            }
105
-            $permalink_string .= $this->embedButtonHtml(
106
-                array($this->slug => $id),
107
-                'button-small'
108
-            );
109
-        }
110
-        return $permalink_string;
111
-    }
87
+	/**
88
+	 * iframe embed code button to the Event editor.
89
+	 *
90
+	 * @param string $permalink_string
91
+	 * @param int    $id
92
+	 * @return string
93
+	 */
94
+	public function eventEditorIframeEmbedButton(
95
+		$permalink_string,
96
+		$id
97
+	) {
98
+		// make sure this is ONLY when editing and the event id has been set.
99
+		if (! empty($id)) {
100
+			$post = get_post($id);
101
+			// if NOT event then let's get out.
102
+			if ($post->post_type !== 'espresso_events') {
103
+				return $permalink_string;
104
+			}
105
+			$permalink_string .= $this->embedButtonHtml(
106
+				array($this->slug => $id),
107
+				'button-small'
108
+			);
109
+		}
110
+		return $permalink_string;
111
+	}
112 112
 
113 113
 
114
-    /**
115
-     * Adds an iframe embed code button via a WP do_action() as determined by the first parameter
116
-     *
117
-     * @param string $action name of the WP do_action() to hook into
118
-     */
119
-    public function addActionIframeEmbedButton($action)
120
-    {
121
-        // add button for iframe code to event editor.
122
-        add_action(
123
-            $action,
124
-            array($this, 'addActionIframeEmbedButtonCallback'),
125
-            10,
126
-            2
127
-        );
128
-    }
114
+	/**
115
+	 * Adds an iframe embed code button via a WP do_action() as determined by the first parameter
116
+	 *
117
+	 * @param string $action name of the WP do_action() to hook into
118
+	 */
119
+	public function addActionIframeEmbedButton($action)
120
+	{
121
+		// add button for iframe code to event editor.
122
+		add_action(
123
+			$action,
124
+			array($this, 'addActionIframeEmbedButtonCallback'),
125
+			10,
126
+			2
127
+		);
128
+	}
129 129
 
130 130
 
131
-    /**
132
-     * @return void
133
-     */
134
-    public function addActionIframeEmbedButtonCallback()
135
-    {
136
-        echo wp_kses($this->embedButtonHtml(), AllowedTags::getWithFormTags());
137
-    }
131
+	/**
132
+	 * @return void
133
+	 */
134
+	public function addActionIframeEmbedButtonCallback()
135
+	{
136
+		echo wp_kses($this->embedButtonHtml(), AllowedTags::getWithFormTags());
137
+	}
138 138
 
139 139
 
140
-    /**
141
-     * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter
142
-     *
143
-     * @param string $filter     name of the WP apply_filters() to hook into
144
-     * @param bool   $append     if true, will add iframe embed button to end of content,
145
-     *                           else if false, will add to the beginning of the content
146
-     */
147
-    public function addFilterIframeEmbedButton($filter, $append = true)
148
-    {
149
-        $this->append_filterable_content = $append;
150
-        // add button for iframe code to event editor.
151
-        add_filter(
152
-            $filter,
153
-            array($this, 'addFilterIframeEmbedButtonCallback'),
154
-            10
155
-        );
156
-    }
140
+	/**
141
+	 * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter
142
+	 *
143
+	 * @param string $filter     name of the WP apply_filters() to hook into
144
+	 * @param bool   $append     if true, will add iframe embed button to end of content,
145
+	 *                           else if false, will add to the beginning of the content
146
+	 */
147
+	public function addFilterIframeEmbedButton($filter, $append = true)
148
+	{
149
+		$this->append_filterable_content = $append;
150
+		// add button for iframe code to event editor.
151
+		add_filter(
152
+			$filter,
153
+			array($this, 'addFilterIframeEmbedButtonCallback'),
154
+			10
155
+		);
156
+	}
157 157
 
158 158
 
159
-    /**
160
-     * @param array|string $filterable_content
161
-     * @return array|string
162
-     */
163
-    public function addFilterIframeEmbedButtonCallback($filterable_content)
164
-    {
165
-        $embedButtonHtml = $this->embedButtonHtml();
166
-        if (is_array($filterable_content)) {
167
-            $filterable_content = $this->append_filterable_content
168
-                ? $filterable_content + array($this->route_name => $embedButtonHtml)
169
-                : array($this->route_name => $embedButtonHtml) + $filterable_content;
170
-        } else {
171
-            $filterable_content = $this->append_filterable_content
172
-                ? $filterable_content . $embedButtonHtml
173
-                : $embedButtonHtml . $filterable_content;
174
-        }
175
-        return $filterable_content;
176
-    }
159
+	/**
160
+	 * @param array|string $filterable_content
161
+	 * @return array|string
162
+	 */
163
+	public function addFilterIframeEmbedButtonCallback($filterable_content)
164
+	{
165
+		$embedButtonHtml = $this->embedButtonHtml();
166
+		if (is_array($filterable_content)) {
167
+			$filterable_content = $this->append_filterable_content
168
+				? $filterable_content + array($this->route_name => $embedButtonHtml)
169
+				: array($this->route_name => $embedButtonHtml) + $filterable_content;
170
+		} else {
171
+			$filterable_content = $this->append_filterable_content
172
+				? $filterable_content . $embedButtonHtml
173
+				: $embedButtonHtml . $filterable_content;
174
+		}
175
+		return $filterable_content;
176
+	}
177 177
 
178 178
 
179
-    /**
180
-     * iframe_embed_html
181
-     *
182
-     * @param array  $query_args
183
-     * @param string $button_class
184
-     * @return string
185
-     */
186
-    public function embedButtonHtml($query_args = array(), $button_class = '')
187
-    {
188
-        // incoming args will replace the defaults listed here in the second array (union preserves first array)
189
-        $query_args = (array) $query_args + array($this->route_name => 'iframe');
190
-        $query_args = (array) apply_filters(
191
-            'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args',
192
-            $query_args
193
-        );
194
-        // add this route to our localized vars
195
-        $iframe_module_routes = isset(\EE_Registry::$i18n_js_strings['iframe_module_routes'])
196
-            ? \EE_Registry::$i18n_js_strings['iframe_module_routes']
197
-            : array();
198
-        $iframe_module_routes[ $this->route_name ] = $this->route_name;
199
-        \EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes;
200
-        $iframe_embed_html = \EEH_HTML::link(
201
-            '#',
202
-            sprintf(esc_html__('Embed %1$s', 'event_espresso'), $this->iframe_name),
203
-            sprintf(
204
-                esc_html__(
205
-                    'click here to generate code for embedding %1$s iframe into another site.',
206
-                    'event_espresso'
207
-                ),
208
-                \EEH_Inflector::add_indefinite_article($this->iframe_name)
209
-            ),
210
-            esc_attr($this->route_name) . "-iframe-embed-trigger-js",
211
-            'iframe-embed-trigger-js button ' . esc_attr($button_class),
212
-            '',
213
-            ' data-iframe_embed_button="#' . esc_attr($this->route_name) . '-iframe-js" tabindex="-1"'
214
-        );
215
-        $iframe_embed_html .= \EEH_HTML::div(
216
-            '',
217
-            esc_attr($this->route_name) . "-iframe-js",
218
-            'iframe-embed-wrapper-js',
219
-            'display:none;'
220
-        );
221
-        $iframe_embed_html .= esc_html(
222
-            \EEH_HTML::div(
223
-                '<iframe src="' . esc_url_raw(add_query_arg($query_args, site_url())) . '" width="100%" height="100%"></iframe>',
224
-                '',
225
-                '',
226
-                'width:100%; height: 500px;'
227
-            )
228
-        );
229
-        $iframe_embed_html .= \EEH_HTML::divx();
230
-        return $iframe_embed_html;
231
-    }
179
+	/**
180
+	 * iframe_embed_html
181
+	 *
182
+	 * @param array  $query_args
183
+	 * @param string $button_class
184
+	 * @return string
185
+	 */
186
+	public function embedButtonHtml($query_args = array(), $button_class = '')
187
+	{
188
+		// incoming args will replace the defaults listed here in the second array (union preserves first array)
189
+		$query_args = (array) $query_args + array($this->route_name => 'iframe');
190
+		$query_args = (array) apply_filters(
191
+			'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args',
192
+			$query_args
193
+		);
194
+		// add this route to our localized vars
195
+		$iframe_module_routes = isset(\EE_Registry::$i18n_js_strings['iframe_module_routes'])
196
+			? \EE_Registry::$i18n_js_strings['iframe_module_routes']
197
+			: array();
198
+		$iframe_module_routes[ $this->route_name ] = $this->route_name;
199
+		\EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes;
200
+		$iframe_embed_html = \EEH_HTML::link(
201
+			'#',
202
+			sprintf(esc_html__('Embed %1$s', 'event_espresso'), $this->iframe_name),
203
+			sprintf(
204
+				esc_html__(
205
+					'click here to generate code for embedding %1$s iframe into another site.',
206
+					'event_espresso'
207
+				),
208
+				\EEH_Inflector::add_indefinite_article($this->iframe_name)
209
+			),
210
+			esc_attr($this->route_name) . "-iframe-embed-trigger-js",
211
+			'iframe-embed-trigger-js button ' . esc_attr($button_class),
212
+			'',
213
+			' data-iframe_embed_button="#' . esc_attr($this->route_name) . '-iframe-js" tabindex="-1"'
214
+		);
215
+		$iframe_embed_html .= \EEH_HTML::div(
216
+			'',
217
+			esc_attr($this->route_name) . "-iframe-js",
218
+			'iframe-embed-wrapper-js',
219
+			'display:none;'
220
+		);
221
+		$iframe_embed_html .= esc_html(
222
+			\EEH_HTML::div(
223
+				'<iframe src="' . esc_url_raw(add_query_arg($query_args, site_url())) . '" width="100%" height="100%"></iframe>',
224
+				'',
225
+				'',
226
+				'width:100%; height: 500px;'
227
+			)
228
+		);
229
+		$iframe_embed_html .= \EEH_HTML::divx();
230
+		return $iframe_embed_html;
231
+	}
232 232
 
233 233
 
234
-    /**
235
-     * enqueue iframe button js
236
-     */
237
-    public function embedButtonAssets()
238
-    {
239
-        \EE_Registry::$i18n_js_strings['iframe_embed_title'] = esc_html__(
240
-            'copy and paste the following into any other site\'s content to display this event:',
241
-            'event_espresso'
242
-        );
243
-        \EE_Registry::$i18n_js_strings['iframe_embed_close_msg'] = esc_html__(
244
-            'click anywhere outside of this window to close it.',
245
-            'event_espresso'
246
-        );
247
-        wp_register_script(
248
-            'iframe_embed_button',
249
-            plugin_dir_url(__FILE__) . 'iframe-embed-button.js',
250
-            array('ee-dialog'),
251
-            EVENT_ESPRESSO_VERSION,
252
-            true
253
-        );
254
-        wp_enqueue_script('iframe_embed_button');
255
-    }
234
+	/**
235
+	 * enqueue iframe button js
236
+	 */
237
+	public function embedButtonAssets()
238
+	{
239
+		\EE_Registry::$i18n_js_strings['iframe_embed_title'] = esc_html__(
240
+			'copy and paste the following into any other site\'s content to display this event:',
241
+			'event_espresso'
242
+		);
243
+		\EE_Registry::$i18n_js_strings['iframe_embed_close_msg'] = esc_html__(
244
+			'click anywhere outside of this window to close it.',
245
+			'event_espresso'
246
+		);
247
+		wp_register_script(
248
+			'iframe_embed_button',
249
+			plugin_dir_url(__FILE__) . 'iframe-embed-button.js',
250
+			array('ee-dialog'),
251
+			EVENT_ESPRESSO_VERSION,
252
+			true
253
+		);
254
+		wp_enqueue_script('iframe_embed_button');
255
+	}
256 256
 
257 257
 
258
-    /**
259
-     * generates embed button sections for admin pages
260
-     *
261
-     * @param array $embed_buttons
262
-     * @return string
263
-     */
264
-    public function addIframeEmbedButtonsSection(array $embed_buttons)
265
-    {
266
-        $embed_buttons = (array) apply_filters(
267
-            'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons',
268
-            $embed_buttons
269
-        );
270
-        if (empty($embed_buttons)) {
271
-            return '';
272
-        }
273
-        // add button for iframe code to event editor.
274
-        $html = \EEH_HTML::br(2);
275
-        $html .= \EEH_HTML::h3(esc_html__('iFrame Embed Code', 'event_espresso'));
276
-        $html .= \EEH_HTML::p(
277
-            esc_html__(
278
-                'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.',
279
-                'event_espresso'
280
-            )
281
-        );
282
-        $html .= ' &nbsp; ' . implode(' &nbsp; ', $embed_buttons) . ' ';
283
-        $html .= \EEH_HTML::br(2);
284
-        return $html;
285
-    }
258
+	/**
259
+	 * generates embed button sections for admin pages
260
+	 *
261
+	 * @param array $embed_buttons
262
+	 * @return string
263
+	 */
264
+	public function addIframeEmbedButtonsSection(array $embed_buttons)
265
+	{
266
+		$embed_buttons = (array) apply_filters(
267
+			'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons',
268
+			$embed_buttons
269
+		);
270
+		if (empty($embed_buttons)) {
271
+			return '';
272
+		}
273
+		// add button for iframe code to event editor.
274
+		$html = \EEH_HTML::br(2);
275
+		$html .= \EEH_HTML::h3(esc_html__('iFrame Embed Code', 'event_espresso'));
276
+		$html .= \EEH_HTML::p(
277
+			esc_html__(
278
+				'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.',
279
+				'event_espresso'
280
+			)
281
+		);
282
+		$html .= ' &nbsp; ' . implode(' &nbsp; ', $embed_buttons) . ' ';
283
+		$html .= \EEH_HTML::br(2);
284
+		return $html;
285
+	}
286 286
 }
Please login to merge, or discard this patch.
libraries/payment_methods/templates/payment_details_content.template.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (! defined('EVENT_ESPRESSO_VERSION')) {
4
-    exit('No direct script access allowed');
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 /**
7 7
  * payment_details_content
@@ -11,5 +11,5 @@  discard block
 block discarded – undo
11 11
  */
12 12
 $gateway_response = $payment->gateway_response();
13 13
 if (! empty($gateway_response)) {
14
-    echo '<span class="error payment-problem">' . esc_html($gateway_response) . '</span>';
14
+	echo '<span class="error payment-problem">' . esc_html($gateway_response) . '</span>';
15 15
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (! defined('EVENT_ESPRESSO_VERSION')) {
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4 4
     exit('No direct script access allowed');
5 5
 }
6 6
 /**
@@ -10,6 +10,6 @@  discard block
 block discarded – undo
10 10
  * @var EE_Payment_Method $payment_method
11 11
  */
12 12
 $gateway_response = $payment->gateway_response();
13
-if (! empty($gateway_response)) {
14
-    echo '<span class="error payment-problem">' . esc_html($gateway_response) . '</span>';
13
+if ( ! empty($gateway_response)) {
14
+    echo '<span class="error payment-problem">'.esc_html($gateway_response).'</span>';
15 15
 }
Please login to merge, or discard this patch.
core/libraries/messages/EE_Message_Type_Collection.lib.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -174,7 +174,7 @@
 block discarded – undo
174 174
             $this->rewind();
175 175
             while ($this->valid()) {
176 176
                 echo '<h5 style="color:#2EA2CC;">
177
-                    ' . __CLASS__ . ' class : <span style="color:#E76700">' . esc_html($this->getInfo()) . '</span>
177
+                    ' . __CLASS__.' class : <span style="color:#E76700">'.esc_html($this->getInfo()).'</span>
178 178
                     </h5>';
179 179
                 $this->next();
180 180
             }
Please login to merge, or discard this patch.
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -13,143 +13,143 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Message_Type_Collection extends EE_Object_Collection
15 15
 {
16
-    /**
17
-     * EE_Message_Type_Collection constructor.
18
-     */
19
-    public function __construct()
20
-    {
21
-        $this->interface = 'EE_message_type';
22
-    }
23
-
24
-
25
-
26
-    /**
27
-     * attaches an object to the Collection
28
-     * and sets any supplied data associated with the current iterator entry
29
-     * by calling EE_Object_Collection::set_info()
30
-     *
31
-     * @param object $object
32
-     * @param mixed  $info
33
-     * @return bool
34
-     */
35
-    public function add($object, $info = ''): bool
36
-    {
37
-        $info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
38
-        return parent::add($object, $info);
39
-    }
40
-
41
-
42
-
43
-    /**
44
-     * Sets the data associated with an object in the Collection
45
-     * if no $info is supplied, then the spl_object_hash() is used
46
-     *
47
-     * @param object $object
48
-     * @param mixed  $info
49
-     * @return bool
50
-     */
51
-    public function set_info($object, $info = ''): bool
52
-    {
53
-        $info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
54
-        return parent::set_info($object, $info);
55
-    }
56
-
57
-
58
-
59
-    /**
60
-     * finds and returns an object in the Collection based on the info that was set using addObject()
61
-     * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
62
-     *
63
-     * @param mixed
64
-     * @return null | object
65
-     */
66
-    public function get_by_info($info = '')
67
-    {
68
-        return parent::get_by_info(str_replace(' ', '_', strtolower($info)));
69
-    }
70
-
71
-
72
-
73
-    /**
74
-     * returns TRUE or FALSE depending on whether the supplied object is within the Collection
75
-     *
76
-     * @param object $object
77
-     * @return bool
78
-     */
79
-    public function has($object): bool
80
-    {
81
-        return parent::has($object);
82
-    }
83
-
84
-
85
-
86
-    /**
87
-     * returns TRUE or FALSE depending on whether the supplied message_type classname is within the Collection
88
-     *
89
-     * @param string $message_type_name
90
-     * @return bool
91
-     */
92
-    public function has_by_name(string $message_type_name): bool
93
-    {
94
-        return $this->get_by_info($message_type_name) instanceof $this->interface;
95
-    }
96
-
97
-
98
-
99
-    /**
100
-     * detaches an object from the Collection
101
-     *
102
-     * @param $object
103
-     * @return bool
104
-     */
105
-    public function remove($object): bool
106
-    {
107
-        return parent::remove($object);
108
-    }
109
-
110
-
111
-
112
-    /**
113
-     * advances pointer to the provided object
114
-     *
115
-     * @param $object
116
-     * @return void
117
-     */
118
-    public function set_current($object)
119
-    {
120
-        parent::set_current($object);
121
-    }
122
-
123
-
124
-
125
-    /**
126
-     * advances pointer to the object whose info matches that which was provided
127
-     *
128
-     * @param $info
129
-     * @return void
130
-     */
131
-    public function set_current_by_info($info)
132
-    {
133
-        parent::set_current_by_info($info);
134
-    }
135
-
136
-
137
-
138
-    /**
139
-     * displays list of collection classes if WP_DEBUG is on
140
-     *
141
-     * @return void
142
-     */
143
-    public function show_collection_classes()
144
-    {
145
-        if (WP_DEBUG) {
146
-            $this->rewind();
147
-            while ($this->valid()) {
148
-                echo '<h5 style="color:#2EA2CC;">
16
+	/**
17
+	 * EE_Message_Type_Collection constructor.
18
+	 */
19
+	public function __construct()
20
+	{
21
+		$this->interface = 'EE_message_type';
22
+	}
23
+
24
+
25
+
26
+	/**
27
+	 * attaches an object to the Collection
28
+	 * and sets any supplied data associated with the current iterator entry
29
+	 * by calling EE_Object_Collection::set_info()
30
+	 *
31
+	 * @param object $object
32
+	 * @param mixed  $info
33
+	 * @return bool
34
+	 */
35
+	public function add($object, $info = ''): bool
36
+	{
37
+		$info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
38
+		return parent::add($object, $info);
39
+	}
40
+
41
+
42
+
43
+	/**
44
+	 * Sets the data associated with an object in the Collection
45
+	 * if no $info is supplied, then the spl_object_hash() is used
46
+	 *
47
+	 * @param object $object
48
+	 * @param mixed  $info
49
+	 * @return bool
50
+	 */
51
+	public function set_info($object, $info = ''): bool
52
+	{
53
+		$info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
54
+		return parent::set_info($object, $info);
55
+	}
56
+
57
+
58
+
59
+	/**
60
+	 * finds and returns an object in the Collection based on the info that was set using addObject()
61
+	 * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
62
+	 *
63
+	 * @param mixed
64
+	 * @return null | object
65
+	 */
66
+	public function get_by_info($info = '')
67
+	{
68
+		return parent::get_by_info(str_replace(' ', '_', strtolower($info)));
69
+	}
70
+
71
+
72
+
73
+	/**
74
+	 * returns TRUE or FALSE depending on whether the supplied object is within the Collection
75
+	 *
76
+	 * @param object $object
77
+	 * @return bool
78
+	 */
79
+	public function has($object): bool
80
+	{
81
+		return parent::has($object);
82
+	}
83
+
84
+
85
+
86
+	/**
87
+	 * returns TRUE or FALSE depending on whether the supplied message_type classname is within the Collection
88
+	 *
89
+	 * @param string $message_type_name
90
+	 * @return bool
91
+	 */
92
+	public function has_by_name(string $message_type_name): bool
93
+	{
94
+		return $this->get_by_info($message_type_name) instanceof $this->interface;
95
+	}
96
+
97
+
98
+
99
+	/**
100
+	 * detaches an object from the Collection
101
+	 *
102
+	 * @param $object
103
+	 * @return bool
104
+	 */
105
+	public function remove($object): bool
106
+	{
107
+		return parent::remove($object);
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 * advances pointer to the provided object
114
+	 *
115
+	 * @param $object
116
+	 * @return void
117
+	 */
118
+	public function set_current($object)
119
+	{
120
+		parent::set_current($object);
121
+	}
122
+
123
+
124
+
125
+	/**
126
+	 * advances pointer to the object whose info matches that which was provided
127
+	 *
128
+	 * @param $info
129
+	 * @return void
130
+	 */
131
+	public function set_current_by_info($info)
132
+	{
133
+		parent::set_current_by_info($info);
134
+	}
135
+
136
+
137
+
138
+	/**
139
+	 * displays list of collection classes if WP_DEBUG is on
140
+	 *
141
+	 * @return void
142
+	 */
143
+	public function show_collection_classes()
144
+	{
145
+		if (WP_DEBUG) {
146
+			$this->rewind();
147
+			while ($this->valid()) {
148
+				echo '<h5 style="color:#2EA2CC;">
149 149
                     ' . __CLASS__ . ' class : <span style="color:#E76700">' . esc_html($this->getInfo()) . '</span>
150 150
                     </h5>';
151
-                $this->next();
152
-            }
153
-        }
154
-    }
151
+				$this->next();
152
+			}
153
+		}
154
+	}
155 155
 }
Please login to merge, or discard this patch.
libraries/messages/defaults/default/html_receipt_ticket_list.template.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
         <div class="ticket-time-and-place-details">
25 25
             <div class="ticket-time-details">
26 26
                 <h4 class="sub-section-title no-bottom-margin">
27
-                    <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL . 'clock-16x16.png'); ?>">
27
+                    <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL.'clock-16x16.png'); ?>">
28 28
                     <?php esc_html_e('Date/Time:', 'event_espresso'); ?>
29 29
                 </h4>
30 30
                 <ul class="event-dates">[DATETIME_LIST]</ul>
31 31
             </div>
32 32
             <div class="ticket-place-details">
33 33
                 <h4 class="sub-section-title no-bottom-margin">
34
-                    <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL . 'location-pin-16x16.png'); ?>">
34
+                    <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL.'location-pin-16x16.png'); ?>">
35 35
                     <?php esc_html_e('Venue', 'event_espresso'); ?>
36 36
                 </h4>
37 37
                 <ul class="event-venues">
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         </div>
46 46
         <div class="ticket-registrations-area">
47 47
             <h4 class="sub-section-title">
48
-                <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL . 'users-16x16.png'); ?>">
48
+                <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL.'users-16x16.png'); ?>">
49 49
                 <?php esc_html_e("Registration Details", "event_espresso"); ?>
50 50
                 <span class="small-text link">
51 51
                     ( <a class="print_button noPrint" href="[PRIMARY_REGISTRANT_FRONTEND_EDIT_REG_LINK]">
Please login to merge, or discard this patch.
libraries/messages/defaults/default/html_receipt_event_list.template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 
7 7
 ?>
8 8
 <h3 class="section-title event-name">
9
-    <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL . 'calendar_year-24x24.png'); ?>">
9
+    <img class="icon" src="<?php echo esc_url_raw(EE_IMAGES_URL.'calendar_year-24x24.png'); ?>">
10 10
     <?php esc_html_e("Event Name:", "event_espresso") ?>
11 11
     <span class="plain-text">[EVENT_NAME]</span>
12 12
     <span class="small-text link">
Please login to merge, or discard this patch.
libraries/messages/defaults/default/html_receipt_attendee_list.template.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,11 +8,11 @@
 block discarded – undo
8 8
 <li class="ticket-registration">
9 9
     <table class="registration-details">
10 10
         <tr class="odd">
11
-            <th><?php	_e('Attendee', 'event_espresso');?></th>
11
+            <th><?php	_e('Attendee', 'event_espresso'); ?></th>
12 12
             <td>[FNAME] [LNAME] ([ATTENDEE_EMAIL])</td>
13 13
         </tr>
14 14
         <tr>
15
-            <th><?php esc_html_e("Registration Code:", "event_espresso");?></th>
15
+            <th><?php esc_html_e("Registration Code:", "event_espresso"); ?></th>
16 16
             <td>[REGISTRATION_CODE] - <span class="[REGISTRATION_STATUS_ID]">[REGISTRATION_STATUS_LABEL]</span></td>
17 17
         </tr>
18 18
     </table>
Please login to merge, or discard this patch.
core/libraries/messages/EE_Messenger_Collection.lib.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -189,7 +189,7 @@
 block discarded – undo
189 189
             $this->rewind();
190 190
             while ($this->valid()) {
191 191
                 echo '<h5 style="color:#2EA2CC;">
192
-                    ' . __CLASS__ . ' class : . <span style="color:#E76700">' . esc_html($this->getInfo()) . '</span>
192
+                    ' . __CLASS__.' class : . <span style="color:#E76700">'.esc_html($this->getInfo()).'</span>
193 193
                     </h5>';
194 194
                 $this->next();
195 195
             }
Please login to merge, or discard this patch.
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -13,128 +13,128 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Messenger_Collection extends EE_Object_Collection
15 15
 {
16
-    /**
17
-     * EE_Messenger_Collection constructor.
18
-     */
19
-    public function __construct()
20
-    {
21
-        $this->interface = 'EE_messenger';
22
-    }
23
-
24
-
25
-
26
-    /**
27
-     * attaches an object to the Collection
28
-     * and sets any supplied data associated with the current iterator entry
29
-     * by calling EE_Object_Collection::set_info()
30
-     *
31
-     * @param object $object
32
-     * @param mixed  $info
33
-     * @return bool
34
-     */
35
-    public function add($object, $info = ''): bool
36
-    {
37
-        $info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
38
-        return parent::add($object, $info);
39
-    }
40
-
41
-
42
-
43
-    /**
44
-     * Sets the data associated with an object in the Collection
45
-     * if no $info is supplied, then the spl_object_hash() is used
46
-     *
47
-     * @param object $object
48
-     * @param array|int|string $info
49
-     * @return bool
50
-     */
51
-    public function set_info($object, $info = ''): bool
52
-    {
53
-        $info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
54
-        return parent::set_info($object, $info);
55
-    }
56
-
57
-
58
-
59
-    /**
60
-     * finds and returns an object in the Collection based on the info that was set using addObject()
61
-     * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
62
-     *
63
-     * @param mixed
64
-     * @return null | object
65
-     */
66
-    public function get_by_info($info = '')
67
-    {
68
-        return parent::get_by_info(str_replace(' ', '_', strtolower($info)));
69
-    }
70
-
71
-
72
-
73
-    /**
74
-     * returns TRUE or FALSE depending on whether the supplied object is within the Collection
75
-     *
76
-     * @param object $object
77
-     * @return bool
78
-     */
79
-    public function has($object): bool
80
-    {
81
-        return parent::has($object);
82
-    }
83
-
84
-
85
-
86
-    /**
87
-     * returns TRUE or FALSE depending on whether the supplied messenger name is within the Collection
88
-     *
89
-     * @param string $messenger_name
90
-     * @return bool
91
-     */
92
-    public function has_by_name(string $messenger_name): bool
93
-    {
94
-        return $this->get_by_info($messenger_name) instanceof $this->interface;
95
-    }
96
-
97
-
98
-
99
-    /**
100
-     * detaches an object from the Collection
101
-     *
102
-     * @param $object
103
-     * @return bool
104
-     */
105
-    public function remove($object): bool
106
-    {
107
-        return parent::remove($object);
108
-    }
109
-
110
-
111
-
112
-    /**
113
-     * current object from the Collection
114
-     *
115
-     * @return EE_messenger
116
-     */
117
-    public function current(): EE_messenger
118
-    {
119
-        return parent::current();
120
-    }
121
-
122
-
123
-    /**
124
-     * displays list of collection classes if WP_DEBUG is on
125
-     *
126
-     * @return void
127
-     */
128
-    public function show_collection_classes()
129
-    {
130
-        if (WP_DEBUG) {
131
-            $this->rewind();
132
-            while ($this->valid()) {
133
-                echo '<h5 style="color:#2EA2CC;">
16
+	/**
17
+	 * EE_Messenger_Collection constructor.
18
+	 */
19
+	public function __construct()
20
+	{
21
+		$this->interface = 'EE_messenger';
22
+	}
23
+
24
+
25
+
26
+	/**
27
+	 * attaches an object to the Collection
28
+	 * and sets any supplied data associated with the current iterator entry
29
+	 * by calling EE_Object_Collection::set_info()
30
+	 *
31
+	 * @param object $object
32
+	 * @param mixed  $info
33
+	 * @return bool
34
+	 */
35
+	public function add($object, $info = ''): bool
36
+	{
37
+		$info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
38
+		return parent::add($object, $info);
39
+	}
40
+
41
+
42
+
43
+	/**
44
+	 * Sets the data associated with an object in the Collection
45
+	 * if no $info is supplied, then the spl_object_hash() is used
46
+	 *
47
+	 * @param object $object
48
+	 * @param array|int|string $info
49
+	 * @return bool
50
+	 */
51
+	public function set_info($object, $info = ''): bool
52
+	{
53
+		$info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
54
+		return parent::set_info($object, $info);
55
+	}
56
+
57
+
58
+
59
+	/**
60
+	 * finds and returns an object in the Collection based on the info that was set using addObject()
61
+	 * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
62
+	 *
63
+	 * @param mixed
64
+	 * @return null | object
65
+	 */
66
+	public function get_by_info($info = '')
67
+	{
68
+		return parent::get_by_info(str_replace(' ', '_', strtolower($info)));
69
+	}
70
+
71
+
72
+
73
+	/**
74
+	 * returns TRUE or FALSE depending on whether the supplied object is within the Collection
75
+	 *
76
+	 * @param object $object
77
+	 * @return bool
78
+	 */
79
+	public function has($object): bool
80
+	{
81
+		return parent::has($object);
82
+	}
83
+
84
+
85
+
86
+	/**
87
+	 * returns TRUE or FALSE depending on whether the supplied messenger name is within the Collection
88
+	 *
89
+	 * @param string $messenger_name
90
+	 * @return bool
91
+	 */
92
+	public function has_by_name(string $messenger_name): bool
93
+	{
94
+		return $this->get_by_info($messenger_name) instanceof $this->interface;
95
+	}
96
+
97
+
98
+
99
+	/**
100
+	 * detaches an object from the Collection
101
+	 *
102
+	 * @param $object
103
+	 * @return bool
104
+	 */
105
+	public function remove($object): bool
106
+	{
107
+		return parent::remove($object);
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 * current object from the Collection
114
+	 *
115
+	 * @return EE_messenger
116
+	 */
117
+	public function current(): EE_messenger
118
+	{
119
+		return parent::current();
120
+	}
121
+
122
+
123
+	/**
124
+	 * displays list of collection classes if WP_DEBUG is on
125
+	 *
126
+	 * @return void
127
+	 */
128
+	public function show_collection_classes()
129
+	{
130
+		if (WP_DEBUG) {
131
+			$this->rewind();
132
+			while ($this->valid()) {
133
+				echo '<h5 style="color:#2EA2CC;">
134 134
                     ' . __CLASS__ . ' class : . <span style="color:#E76700">' . esc_html($this->getInfo()) . '</span>
135 135
                     </h5>';
136
-                $this->next();
137
-            }
138
-        }
139
-    }
136
+				$this->next();
137
+			}
138
+		}
139
+	}
140 140
 }
Please login to merge, or discard this patch.
core/EE_Maintenance_Mode.core.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     public static function instance()
60 60
     {
61 61
         // check if class object is instantiated
62
-        if (! self::$_instance instanceof EE_Maintenance_Mode) {
62
+        if ( ! self::$_instance instanceof EE_Maintenance_Mode) {
63 63
             self::$_instance = new self();
64 64
         }
65 65
         return self::$_instance;
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
      */
185 185
     public static function disable_frontend_for_maintenance()
186 186
     {
187
-        return (! is_admin() && EE_Maintenance_Mode::instance()->level());
187
+        return ( ! is_admin() && EE_Maintenance_Mode::instance()->level());
188 188
     }
189 189
 
190 190
 
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
         ) {
200 200
             wp_register_style(
201 201
                 'espresso_default',
202
-                EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
202
+                EE_GLOBAL_ASSETS_URL.'css/espresso_default.css',
203 203
                 ['dashicons'],
204 204
                 EVENT_ESPRESSO_VERSION
205 205
             );
206 206
             wp_enqueue_style('espresso_default');
207 207
             wp_register_script(
208 208
                 'espresso_core',
209
-                EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
209
+                EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js',
210 210
                 ['jquery'],
211 211
                 EVENT_ESPRESSO_VERSION,
212 212
                 true
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
     public static function template_include()
227 227
     {
228 228
         // shut 'er down for maintenance ? then don't use any of our templates for our endpoints
229
-        return get_template_directory() . '/index.php';
229
+        return get_template_directory().'/index.php';
230 230
     }
231 231
 
232 232
 
@@ -278,10 +278,10 @@  discard block
 block discarded – undo
278 278
                 ),
279 279
                 '<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="',
280 280
                 '"><span class="dashicons dashicons-no"></span></a><p>',
281
-                ' &raquo; <a href="' . add_query_arg(
281
+                ' &raquo; <a href="'.add_query_arg(
282 282
                     ['page' => 'espresso_maintenance_settings'],
283 283
                     admin_url('admin.php')
284
-                ) . '">',
284
+                ).'">',
285 285
                 '</a></p></div>'
286 286
             );
287 287
         }
Please login to merge, or discard this patch.
Indentation   +334 added lines, -334 removed lines patch added patch discarded remove patch
@@ -15,340 +15,340 @@
 block discarded – undo
15 15
  */
16 16
 class EE_Maintenance_Mode implements ResettableInterface
17 17
 {
18
-    /**
19
-     * constants available to client code for interpreting the values of EE_Maintenance_Mode::level().
20
-     * level_0_not_in_maintenance means the site is NOT in maintenance mode (so everything's normal)
21
-     */
22
-    const level_0_not_in_maintenance = 0;
23
-
24
-    /**
25
-     * level_1_frontend_only_maintenance means that the site's frontend EE code should be completely disabled
26
-     * but the admin backend should be running as normal. Maybe an admin can view the frontend though
27
-     */
28
-    const level_1_frontend_only_maintenance = 1;
29
-
30
-    /**
31
-     * level_2_complete_maintenance means the frontend AND EE backend code are disabled. The only system running
32
-     * is the maintenance mode stuff, which will require users to update all addons, and then finish running all
33
-     * migration scripts before taking the site out of maintenance mode
34
-     */
35
-    const level_2_complete_maintenance = 2;
36
-
37
-    /**
38
-     * the name of the option which stores the current level of maintenance mode
39
-     */
40
-    const option_name_maintenance_mode = 'ee_maintenance_mode';
41
-
42
-
43
-    /**
44
-     * @var EE_Maintenance_Mode $_instance
45
-     */
46
-    private static $_instance;
47
-
48
-    /**
49
-     * @var EE_Registry $EE
50
-     */
51
-    protected $EE;
52
-
53
-
54
-    /**
55
-     * @singleton method used to instantiate class object
56
-     * @return EE_Maintenance_Mode
57
-     */
58
-    public static function instance()
59
-    {
60
-        // check if class object is instantiated
61
-        if (! self::$_instance instanceof EE_Maintenance_Mode) {
62
-            self::$_instance = new self();
63
-        }
64
-        return self::$_instance;
65
-    }
66
-
67
-
68
-    /**
69
-     * Resets maintenance mode (mostly just re-checks whether we should be in maintenance mode)
70
-     *
71
-     * @return EE_Maintenance_Mode
72
-     * @throws EE_Error
73
-     */
74
-    public static function reset()
75
-    {
76
-        self::instance()->set_maintenance_mode_if_db_old();
77
-        return self::instance();
78
-    }
79
-
80
-
81
-    /**
82
-     *private constructor to prevent direct creation
83
-     */
84
-    private function __construct()
85
-    {
86
-        // if M-Mode level 2 is engaged, we still need basic assets loaded
87
-        add_action('wp_enqueue_scripts', [$this, 'load_assets_required_for_m_mode']);
88
-        // shut 'er down for maintenance ?
89
-        add_filter('the_content', [$this, 'the_content'], 2);
90
-        // add powered by EE msg
91
-        add_action('shutdown', [$this, 'display_maintenance_mode_notice'], 10);
92
-    }
93
-
94
-
95
-    /**
96
-     * retrieves the maintenance mode option value from the db
97
-     *
98
-     * @return int
99
-     */
100
-    public function real_level()
101
-    {
102
-        return (int) get_option(self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance);
103
-    }
104
-
105
-
106
-    /**
107
-     * Returns whether the models reportedly are able to run queries or not
108
-     * (ie, if the system thinks their tables are present and up-to-date).
109
-     *
110
-     * @return boolean
111
-     */
112
-    public function models_can_query()
113
-    {
114
-        return $this->real_level() !== EE_Maintenance_Mode::level_2_complete_maintenance;
115
-    }
116
-
117
-
118
-    /**
119
-     * Determines whether we're in maintenance mode and what level. However, while the site
120
-     * is in level 1 maintenance, and an admin visits the frontend, this function makes it appear
121
-     * to them as if teh site isn't in maintenance mode.
122
-     * EE_Maintenance_Mode::level_0_not_in_maintenance => not in maintenance mode (in normal mode)
123
-     * EE_Maintenance_Mode::level_1_frontend_only_maintenance=> frontend-only maintenance mode
124
-     * EE_Maintenance_Mode::level_2_complete_maintenance => frontend and backend maintenance mode
125
-     *
126
-     * @return int
127
-     */
128
-    public function level()
129
-    {
130
-        $maintenance_mode_level = $this->real_level();
131
-        // if this is an admin request, we'll be honest... except if it's ajax, because that might be from the frontend
132
-        if (
133
-            $maintenance_mode_level === EE_Maintenance_Mode::level_1_frontend_only_maintenance// we're in level 1
134
-            && ((defined('DOING_AJAX') && DOING_AJAX) || ! is_admin()) // on non-ajax frontend requests
135
-            && current_user_can('administrator') // when the user is an admin
136
-        ) {
137
-            $maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance;
138
-        }
139
-        return $maintenance_mode_level;
140
-    }
141
-
142
-
143
-    /**
144
-     * Determines if we need to put EE in maintenance mode because the database needs updating
145
-     *
146
-     * @return boolean true if DB is old and maintenance mode was triggered; false otherwise
147
-     * @throws EE_Error
148
-     */
149
-    public function set_maintenance_mode_if_db_old()
150
-    {
151
-        LoaderFactory::getLoader()->getShared('Data_Migration_Manager');
152
-        if (EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) {
153
-            update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance);
154
-            return true;
155
-        }
156
-        if ($this->level() === self::level_2_complete_maintenance) {
157
-            // we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run
158
-            // then we shouldn't be in mm2. (Maybe an addon got deactivated?)
159
-            update_option(self::option_name_maintenance_mode, self::level_0_not_in_maintenance);
160
-            return false;
161
-        }
162
-        return false;
163
-    }
164
-
165
-
166
-    /**
167
-     * Updates the maintenance level on the site
168
-     *
169
-     * @param int $level
170
-     * @return void
171
-     */
172
-    public function set_maintenance_level($level)
173
-    {
174
-        do_action('AHEE__EE_Maintenance_Mode__set_maintenance_level', $level);
175
-        update_option(self::option_name_maintenance_mode, (int) $level);
176
-    }
177
-
178
-
179
-    /**
180
-     * returns TRUE if M-Mode is engaged and the current request is not for the admin
181
-     *
182
-     * @return bool
183
-     */
184
-    public static function disable_frontend_for_maintenance()
185
-    {
186
-        return (! is_admin() && EE_Maintenance_Mode::instance()->level());
187
-    }
188
-
189
-
190
-    /**
191
-     * @return void
192
-     */
193
-    public function load_assets_required_for_m_mode()
194
-    {
195
-        if (
196
-            $this->real_level() === EE_Maintenance_Mode::level_2_complete_maintenance
197
-            && ! wp_script_is('espresso_core')
198
-        ) {
199
-            wp_register_style(
200
-                'espresso_default',
201
-                EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
202
-                ['dashicons'],
203
-                EVENT_ESPRESSO_VERSION
204
-            );
205
-            wp_enqueue_style('espresso_default');
206
-            wp_register_script(
207
-                'espresso_core',
208
-                EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
209
-                ['jquery'],
210
-                EVENT_ESPRESSO_VERSION,
211
-                true
212
-            );
213
-            wp_enqueue_script('espresso_core');
214
-        }
215
-    }
216
-
217
-
218
-    /**
219
-     * replacement EE CPT template that displays message notifying site visitors
220
-     * that EE has been temporarily placed into maintenance mode
221
-     * does NOT get called on non-EE-CPT requests
222
-     *
223
-     * @return    string
224
-     */
225
-    public static function template_include()
226
-    {
227
-        // shut 'er down for maintenance ? then don't use any of our templates for our endpoints
228
-        return get_template_directory() . '/index.php';
229
-    }
230
-
231
-
232
-    /**
233
-     * displays message notifying site visitors that EE has been temporarily
234
-     * placed into maintenance mode when post_type != EE CPT
235
-     *
236
-     * @param string $the_content
237
-     * @return string
238
-     */
239
-    public function the_content($the_content)
240
-    {
241
-        // check if M-mode is engaged and for EE shortcode
242
-        if ($this->level() && strpos($the_content, '[ESPRESSO_') !== false) {
243
-            // this can eventually be moved to a template, or edited via admin. But for now...
244
-            $the_content = sprintf(
245
-                esc_html__(
246
-                    '%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s',
247
-                    'event_espresso'
248
-                ),
249
-                '<h3>',
250
-                '</h3><p>',
251
-                '</p>'
252
-            );
253
-        }
254
-        return $the_content;
255
-    }
256
-
257
-
258
-    /**
259
-     * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode
260
-     */
261
-    public function display_maintenance_mode_notice()
262
-    {
263
-        /** @var CurrentPage $current_page */
264
-        $current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class);
265
-        // check if M-mode is engaged and for EE shortcode
266
-        if (
267
-            ! (defined('DOING_AJAX') && DOING_AJAX)
268
-            && $this->real_level()
269
-            && ! is_admin()
270
-            && current_user_can('administrator')
271
-            && $current_page->isEspressoPage()
272
-        ) {
273
-            printf(
274
-                esc_html__(
275
-                    '%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s',
276
-                    'event_espresso'
277
-                ),
278
-                '<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="',
279
-                '"><span class="dashicons dashicons-no"></span></a><p>',
280
-                ' &raquo; <a href="' . add_query_arg(
281
-                    ['page' => 'espresso_maintenance_settings'],
282
-                    admin_url('admin.php')
283
-                ) . '">',
284
-                '</a></p></div>'
285
-            );
286
-        }
287
-    }
288
-    // espresso-notices important-notice ee-attention
289
-
290
-
291
-    /**
292
-     * override magic methods
293
-     */
294
-    final public function __destruct()
295
-    {
296
-    }
297
-
298
-
299
-    final public function __call($a, $b)
300
-    {
301
-    }
302
-
303
-
304
-    final public function __get($a)
305
-    {
306
-    }
307
-
308
-
309
-    final public function __set($a, $b)
310
-    {
311
-    }
312
-
313
-
314
-    final public function __isset($a)
315
-    {
316
-    }
317
-
318
-
319
-    final public function __unset($a)
320
-    {
321
-    }
322
-
323
-
324
-    final public function __sleep()
325
-    {
326
-        return [];
327
-    }
328
-
329
-
330
-    final public function __wakeup()
331
-    {
332
-    }
333
-
334
-
335
-    final public function __invoke()
336
-    {
337
-    }
338
-
339
-
340
-    final public static function __set_state($a = null)
341
-    {
342
-        return EE_Maintenance_Mode::instance();
343
-    }
344
-
345
-
346
-    final public function __clone()
347
-    {
348
-    }
18
+	/**
19
+	 * constants available to client code for interpreting the values of EE_Maintenance_Mode::level().
20
+	 * level_0_not_in_maintenance means the site is NOT in maintenance mode (so everything's normal)
21
+	 */
22
+	const level_0_not_in_maintenance = 0;
23
+
24
+	/**
25
+	 * level_1_frontend_only_maintenance means that the site's frontend EE code should be completely disabled
26
+	 * but the admin backend should be running as normal. Maybe an admin can view the frontend though
27
+	 */
28
+	const level_1_frontend_only_maintenance = 1;
29
+
30
+	/**
31
+	 * level_2_complete_maintenance means the frontend AND EE backend code are disabled. The only system running
32
+	 * is the maintenance mode stuff, which will require users to update all addons, and then finish running all
33
+	 * migration scripts before taking the site out of maintenance mode
34
+	 */
35
+	const level_2_complete_maintenance = 2;
36
+
37
+	/**
38
+	 * the name of the option which stores the current level of maintenance mode
39
+	 */
40
+	const option_name_maintenance_mode = 'ee_maintenance_mode';
41
+
42
+
43
+	/**
44
+	 * @var EE_Maintenance_Mode $_instance
45
+	 */
46
+	private static $_instance;
47
+
48
+	/**
49
+	 * @var EE_Registry $EE
50
+	 */
51
+	protected $EE;
52
+
53
+
54
+	/**
55
+	 * @singleton method used to instantiate class object
56
+	 * @return EE_Maintenance_Mode
57
+	 */
58
+	public static function instance()
59
+	{
60
+		// check if class object is instantiated
61
+		if (! self::$_instance instanceof EE_Maintenance_Mode) {
62
+			self::$_instance = new self();
63
+		}
64
+		return self::$_instance;
65
+	}
66
+
67
+
68
+	/**
69
+	 * Resets maintenance mode (mostly just re-checks whether we should be in maintenance mode)
70
+	 *
71
+	 * @return EE_Maintenance_Mode
72
+	 * @throws EE_Error
73
+	 */
74
+	public static function reset()
75
+	{
76
+		self::instance()->set_maintenance_mode_if_db_old();
77
+		return self::instance();
78
+	}
79
+
80
+
81
+	/**
82
+	 *private constructor to prevent direct creation
83
+	 */
84
+	private function __construct()
85
+	{
86
+		// if M-Mode level 2 is engaged, we still need basic assets loaded
87
+		add_action('wp_enqueue_scripts', [$this, 'load_assets_required_for_m_mode']);
88
+		// shut 'er down for maintenance ?
89
+		add_filter('the_content', [$this, 'the_content'], 2);
90
+		// add powered by EE msg
91
+		add_action('shutdown', [$this, 'display_maintenance_mode_notice'], 10);
92
+	}
93
+
94
+
95
+	/**
96
+	 * retrieves the maintenance mode option value from the db
97
+	 *
98
+	 * @return int
99
+	 */
100
+	public function real_level()
101
+	{
102
+		return (int) get_option(self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance);
103
+	}
104
+
105
+
106
+	/**
107
+	 * Returns whether the models reportedly are able to run queries or not
108
+	 * (ie, if the system thinks their tables are present and up-to-date).
109
+	 *
110
+	 * @return boolean
111
+	 */
112
+	public function models_can_query()
113
+	{
114
+		return $this->real_level() !== EE_Maintenance_Mode::level_2_complete_maintenance;
115
+	}
116
+
117
+
118
+	/**
119
+	 * Determines whether we're in maintenance mode and what level. However, while the site
120
+	 * is in level 1 maintenance, and an admin visits the frontend, this function makes it appear
121
+	 * to them as if teh site isn't in maintenance mode.
122
+	 * EE_Maintenance_Mode::level_0_not_in_maintenance => not in maintenance mode (in normal mode)
123
+	 * EE_Maintenance_Mode::level_1_frontend_only_maintenance=> frontend-only maintenance mode
124
+	 * EE_Maintenance_Mode::level_2_complete_maintenance => frontend and backend maintenance mode
125
+	 *
126
+	 * @return int
127
+	 */
128
+	public function level()
129
+	{
130
+		$maintenance_mode_level = $this->real_level();
131
+		// if this is an admin request, we'll be honest... except if it's ajax, because that might be from the frontend
132
+		if (
133
+			$maintenance_mode_level === EE_Maintenance_Mode::level_1_frontend_only_maintenance// we're in level 1
134
+			&& ((defined('DOING_AJAX') && DOING_AJAX) || ! is_admin()) // on non-ajax frontend requests
135
+			&& current_user_can('administrator') // when the user is an admin
136
+		) {
137
+			$maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance;
138
+		}
139
+		return $maintenance_mode_level;
140
+	}
141
+
142
+
143
+	/**
144
+	 * Determines if we need to put EE in maintenance mode because the database needs updating
145
+	 *
146
+	 * @return boolean true if DB is old and maintenance mode was triggered; false otherwise
147
+	 * @throws EE_Error
148
+	 */
149
+	public function set_maintenance_mode_if_db_old()
150
+	{
151
+		LoaderFactory::getLoader()->getShared('Data_Migration_Manager');
152
+		if (EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) {
153
+			update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance);
154
+			return true;
155
+		}
156
+		if ($this->level() === self::level_2_complete_maintenance) {
157
+			// we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run
158
+			// then we shouldn't be in mm2. (Maybe an addon got deactivated?)
159
+			update_option(self::option_name_maintenance_mode, self::level_0_not_in_maintenance);
160
+			return false;
161
+		}
162
+		return false;
163
+	}
164
+
165
+
166
+	/**
167
+	 * Updates the maintenance level on the site
168
+	 *
169
+	 * @param int $level
170
+	 * @return void
171
+	 */
172
+	public function set_maintenance_level($level)
173
+	{
174
+		do_action('AHEE__EE_Maintenance_Mode__set_maintenance_level', $level);
175
+		update_option(self::option_name_maintenance_mode, (int) $level);
176
+	}
177
+
178
+
179
+	/**
180
+	 * returns TRUE if M-Mode is engaged and the current request is not for the admin
181
+	 *
182
+	 * @return bool
183
+	 */
184
+	public static function disable_frontend_for_maintenance()
185
+	{
186
+		return (! is_admin() && EE_Maintenance_Mode::instance()->level());
187
+	}
188
+
189
+
190
+	/**
191
+	 * @return void
192
+	 */
193
+	public function load_assets_required_for_m_mode()
194
+	{
195
+		if (
196
+			$this->real_level() === EE_Maintenance_Mode::level_2_complete_maintenance
197
+			&& ! wp_script_is('espresso_core')
198
+		) {
199
+			wp_register_style(
200
+				'espresso_default',
201
+				EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
202
+				['dashicons'],
203
+				EVENT_ESPRESSO_VERSION
204
+			);
205
+			wp_enqueue_style('espresso_default');
206
+			wp_register_script(
207
+				'espresso_core',
208
+				EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
209
+				['jquery'],
210
+				EVENT_ESPRESSO_VERSION,
211
+				true
212
+			);
213
+			wp_enqueue_script('espresso_core');
214
+		}
215
+	}
216
+
217
+
218
+	/**
219
+	 * replacement EE CPT template that displays message notifying site visitors
220
+	 * that EE has been temporarily placed into maintenance mode
221
+	 * does NOT get called on non-EE-CPT requests
222
+	 *
223
+	 * @return    string
224
+	 */
225
+	public static function template_include()
226
+	{
227
+		// shut 'er down for maintenance ? then don't use any of our templates for our endpoints
228
+		return get_template_directory() . '/index.php';
229
+	}
230
+
231
+
232
+	/**
233
+	 * displays message notifying site visitors that EE has been temporarily
234
+	 * placed into maintenance mode when post_type != EE CPT
235
+	 *
236
+	 * @param string $the_content
237
+	 * @return string
238
+	 */
239
+	public function the_content($the_content)
240
+	{
241
+		// check if M-mode is engaged and for EE shortcode
242
+		if ($this->level() && strpos($the_content, '[ESPRESSO_') !== false) {
243
+			// this can eventually be moved to a template, or edited via admin. But for now...
244
+			$the_content = sprintf(
245
+				esc_html__(
246
+					'%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s',
247
+					'event_espresso'
248
+				),
249
+				'<h3>',
250
+				'</h3><p>',
251
+				'</p>'
252
+			);
253
+		}
254
+		return $the_content;
255
+	}
256
+
257
+
258
+	/**
259
+	 * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode
260
+	 */
261
+	public function display_maintenance_mode_notice()
262
+	{
263
+		/** @var CurrentPage $current_page */
264
+		$current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class);
265
+		// check if M-mode is engaged and for EE shortcode
266
+		if (
267
+			! (defined('DOING_AJAX') && DOING_AJAX)
268
+			&& $this->real_level()
269
+			&& ! is_admin()
270
+			&& current_user_can('administrator')
271
+			&& $current_page->isEspressoPage()
272
+		) {
273
+			printf(
274
+				esc_html__(
275
+					'%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s',
276
+					'event_espresso'
277
+				),
278
+				'<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="',
279
+				'"><span class="dashicons dashicons-no"></span></a><p>',
280
+				' &raquo; <a href="' . add_query_arg(
281
+					['page' => 'espresso_maintenance_settings'],
282
+					admin_url('admin.php')
283
+				) . '">',
284
+				'</a></p></div>'
285
+			);
286
+		}
287
+	}
288
+	// espresso-notices important-notice ee-attention
289
+
290
+
291
+	/**
292
+	 * override magic methods
293
+	 */
294
+	final public function __destruct()
295
+	{
296
+	}
297
+
298
+
299
+	final public function __call($a, $b)
300
+	{
301
+	}
302
+
303
+
304
+	final public function __get($a)
305
+	{
306
+	}
307
+
308
+
309
+	final public function __set($a, $b)
310
+	{
311
+	}
312
+
313
+
314
+	final public function __isset($a)
315
+	{
316
+	}
317
+
318
+
319
+	final public function __unset($a)
320
+	{
321
+	}
322
+
323
+
324
+	final public function __sleep()
325
+	{
326
+		return [];
327
+	}
328
+
329
+
330
+	final public function __wakeup()
331
+	{
332
+	}
333
+
334
+
335
+	final public function __invoke()
336
+	{
337
+	}
338
+
339
+
340
+	final public static function __set_state($a = null)
341
+	{
342
+		return EE_Maintenance_Mode::instance();
343
+	}
344
+
345
+
346
+	final public function __clone()
347
+	{
348
+	}
349 349
 
350 350
 
351
-    final public static function __callStatic($a, $b)
352
-    {
353
-    }
351
+	final public static function __callStatic($a, $b)
352
+	{
353
+	}
354 354
 }
Please login to merge, or discard this patch.