Completed
Branch dependabot/composer/wp-graphql... (64393b)
by
unknown
04:29
created
core/libraries/messages/EE_Messenger_Collection_Loader.lib.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
     {
67 67
         // make sure autoloaders are set (fail-safe)
68 68
         EED_Messages::set_autoloaders();
69
-        $folder = ! empty($folder) ? $folder : EE_LIBRARIES . 'messages/messenger';
70
-        $folder .= $folder[ strlen($folder) - 1 ] != '/' ? '/' : '';
69
+        $folder = ! empty($folder) ? $folder : EE_LIBRARIES.'messages/messenger';
70
+        $folder .= $folder[strlen($folder) - 1] != '/' ? '/' : '';
71 71
         // get all the files in that folder that end in ".class.php
72 72
         $filepaths = apply_filters(
73 73
             'FHEE__EE_messages__get_installed__messenger_files',
74
-            glob($folder . '*.class.php')
74
+            glob($folder.'*.class.php')
75 75
         );
76 76
         if (empty($filepaths)) {
77 77
             return;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
                 continue;
88 88
             }
89 89
 
90
-            if (! class_exists($messenger_class_name)) {
90
+            if ( ! class_exists($messenger_class_name)) {
91 91
                 throw new EE_Error(
92 92
                     sprintf(
93 93
                         esc_html__('The "%1$s" messenger class can\'t be loaded from %2$s.  Likely there is a typo in the class name or the file name.', 'event_espresso'),
Please login to merge, or discard this patch.
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -13,127 +13,127 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Messenger_Collection_Loader
15 15
 {
16
-    /**
17
-     * @type EE_Messenger_Collection $_messenger_collection
18
-     */
19
-    protected $_messenger_collection = null;
20
-
21
-
22
-
23
-    /**
24
-     * EE_Messenger_Collection_Loader constructor.
25
-     *
26
-     * @param EE_Messenger_Collection $messengers
27
-     */
28
-    public function __construct(EE_Messenger_Collection $messengers)
29
-    {
30
-        $this->set_messenger_collection($messengers);
31
-    }
32
-
33
-
34
-
35
-    /**
36
-     * @return EE_Messenger_Collection
37
-     */
38
-    public function messenger_collection()
39
-    {
40
-        return $this->_messenger_collection;
41
-    }
42
-
43
-
44
-
45
-    /**
46
-     * @param mixed $messengers
47
-     */
48
-    public function set_messenger_collection(EE_Messenger_Collection $messengers)
49
-    {
50
-        $this->_messenger_collection = $messengers;
51
-    }
52
-
53
-
54
-
55
-    /**
56
-     * load_messengers
57
-     * globs the supplied filepath and adds any found
58
-     *
59
-     * @param  string $folder
60
-     * @throws \EE_Error
61
-     */
62
-    public function load_messengers_from_folder($folder = '')
63
-    {
64
-        // make sure autoloaders are set (fail-safe)
65
-        EED_Messages::set_autoloaders();
66
-        $folder = ! empty($folder) ? $folder : EE_LIBRARIES . 'messages/messenger';
67
-        $folder .= $folder[ strlen($folder) - 1 ] != '/' ? '/' : '';
68
-        // get all the files in that folder that end in ".class.php
69
-        $filepaths = apply_filters(
70
-            'FHEE__EE_messages__get_installed__messenger_files',
71
-            glob($folder . '*.class.php')
72
-        );
73
-        if (empty($filepaths)) {
74
-            return;
75
-        }
76
-        foreach ((array) $filepaths as $file_path) {
77
-            // extract filename from path
78
-            $file_path = basename($file_path);
79
-            // now remove any file extensions
80
-            $messenger_class_name = substr($file_path, 0, strpos($file_path, '.'));
81
-
82
-            // first check to see if the class name represents an actual messenger class.
83
-            if (strpos(strtolower($messenger_class_name), 'messenger') === false) {
84
-                continue;
85
-            }
86
-
87
-            if (! class_exists($messenger_class_name)) {
88
-                throw new EE_Error(
89
-                    sprintf(
90
-                        esc_html__('The "%1$s" messenger class can\'t be loaded from %2$s.  Likely there is a typo in the class name or the file name.', 'event_espresso'),
91
-                        $messenger_class_name,
92
-                        $file_path
93
-                    )
94
-                );
95
-            }
96
-
97
-            $this->_load_messenger(new $messenger_class_name());
98
-        }
99
-    }
100
-
101
-
102
-    /**
103
-     * load_messengers
104
-     * globs the supplied filepath and adds any found
105
-     *
106
-     * @return array
107
-     */
108
-    public function load_active_messengers_from_db()
109
-    {
110
-        // make sure autoloaders are set (fail-safe)
111
-        EED_Messages::set_autoloaders();
112
-        $active_messengers = apply_filters(
113
-            'FHEE__EEH_MSG_Template__get_active_messengers_in_db',
114
-            get_option('ee_active_messengers', array())
115
-        );
116
-        foreach ((array) $active_messengers as $active_messenger_classname => $active_messenger) {
117
-            $this->_load_messenger($active_messenger);
118
-        }
119
-    }
120
-
121
-
122
-
123
-    /**
124
-     * load_messenger
125
-     *
126
-     * @param \EE_messenger $messenger
127
-     * @return bool
128
-     */
129
-    protected function _load_messenger(EE_messenger $messenger)
130
-    {
131
-        if ($this->messenger_collection()->has_by_name($messenger->name)) {
132
-            return true;
133
-        }
134
-        return $this->messenger_collection()->add(
135
-            $messenger,
136
-            $messenger->name
137
-        );
138
-    }
16
+	/**
17
+	 * @type EE_Messenger_Collection $_messenger_collection
18
+	 */
19
+	protected $_messenger_collection = null;
20
+
21
+
22
+
23
+	/**
24
+	 * EE_Messenger_Collection_Loader constructor.
25
+	 *
26
+	 * @param EE_Messenger_Collection $messengers
27
+	 */
28
+	public function __construct(EE_Messenger_Collection $messengers)
29
+	{
30
+		$this->set_messenger_collection($messengers);
31
+	}
32
+
33
+
34
+
35
+	/**
36
+	 * @return EE_Messenger_Collection
37
+	 */
38
+	public function messenger_collection()
39
+	{
40
+		return $this->_messenger_collection;
41
+	}
42
+
43
+
44
+
45
+	/**
46
+	 * @param mixed $messengers
47
+	 */
48
+	public function set_messenger_collection(EE_Messenger_Collection $messengers)
49
+	{
50
+		$this->_messenger_collection = $messengers;
51
+	}
52
+
53
+
54
+
55
+	/**
56
+	 * load_messengers
57
+	 * globs the supplied filepath and adds any found
58
+	 *
59
+	 * @param  string $folder
60
+	 * @throws \EE_Error
61
+	 */
62
+	public function load_messengers_from_folder($folder = '')
63
+	{
64
+		// make sure autoloaders are set (fail-safe)
65
+		EED_Messages::set_autoloaders();
66
+		$folder = ! empty($folder) ? $folder : EE_LIBRARIES . 'messages/messenger';
67
+		$folder .= $folder[ strlen($folder) - 1 ] != '/' ? '/' : '';
68
+		// get all the files in that folder that end in ".class.php
69
+		$filepaths = apply_filters(
70
+			'FHEE__EE_messages__get_installed__messenger_files',
71
+			glob($folder . '*.class.php')
72
+		);
73
+		if (empty($filepaths)) {
74
+			return;
75
+		}
76
+		foreach ((array) $filepaths as $file_path) {
77
+			// extract filename from path
78
+			$file_path = basename($file_path);
79
+			// now remove any file extensions
80
+			$messenger_class_name = substr($file_path, 0, strpos($file_path, '.'));
81
+
82
+			// first check to see if the class name represents an actual messenger class.
83
+			if (strpos(strtolower($messenger_class_name), 'messenger') === false) {
84
+				continue;
85
+			}
86
+
87
+			if (! class_exists($messenger_class_name)) {
88
+				throw new EE_Error(
89
+					sprintf(
90
+						esc_html__('The "%1$s" messenger class can\'t be loaded from %2$s.  Likely there is a typo in the class name or the file name.', 'event_espresso'),
91
+						$messenger_class_name,
92
+						$file_path
93
+					)
94
+				);
95
+			}
96
+
97
+			$this->_load_messenger(new $messenger_class_name());
98
+		}
99
+	}
100
+
101
+
102
+	/**
103
+	 * load_messengers
104
+	 * globs the supplied filepath and adds any found
105
+	 *
106
+	 * @return array
107
+	 */
108
+	public function load_active_messengers_from_db()
109
+	{
110
+		// make sure autoloaders are set (fail-safe)
111
+		EED_Messages::set_autoloaders();
112
+		$active_messengers = apply_filters(
113
+			'FHEE__EEH_MSG_Template__get_active_messengers_in_db',
114
+			get_option('ee_active_messengers', array())
115
+		);
116
+		foreach ((array) $active_messengers as $active_messenger_classname => $active_messenger) {
117
+			$this->_load_messenger($active_messenger);
118
+		}
119
+	}
120
+
121
+
122
+
123
+	/**
124
+	 * load_messenger
125
+	 *
126
+	 * @param \EE_messenger $messenger
127
+	 * @return bool
128
+	 */
129
+	protected function _load_messenger(EE_messenger $messenger)
130
+	{
131
+		if ($this->messenger_collection()->has_by_name($messenger->name)) {
132
+			return true;
133
+		}
134
+		return $this->messenger_collection()->add(
135
+			$messenger,
136
+			$messenger->name
137
+		);
138
+	}
139 139
 }
Please login to merge, or discard this patch.
messages/defaults/default/html_receipt_ticket_line_item_pms.template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 <tr class="item">
9 9
     <td>[LINE_ITEM_NAME][LINE_ITEM_TAXABLE_*]</td>
10 10
     <td colspan="2">[LINE_ITEM_DESCRIPTION]
11
-        <p class="ticket-note"><?php echo sprintf(esc_html__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), '[TKT_USES_* schema=' . esc_html__('any', 'event_espresso') . ']'); ?></p>
11
+        <p class="ticket-note"><?php echo sprintf(esc_html__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), '[TKT_USES_* schema='.esc_html__('any', 'event_espresso').']'); ?></p>
12 12
     </td>
13 13
     <td class="item_c">[LINE_ITEM_QUANTITY]</td>
14 14
     <td class="item_c">[LINE_ITEM_AMOUNT]</td>
Please login to merge, or discard this patch.
core/libraries/messages/defaults/EE_Messages_Template_Pack.core.php 2 patches
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -166,20 +166,20 @@  discard block
 block discarded – undo
166 166
         // make sure required props have been set
167 167
 
168 168
         // if label is empty then throw an error because we should have it defined by now.
169
-        if (! isset($this->label)) {
169
+        if ( ! isset($this->label)) {
170 170
             throw new EE_Error(sprintf(esc_html__('The label property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
171 171
         }
172 172
 
173 173
 
174 174
         // the reference for this template pack
175
-        if (! isset($this->dbref)) {
175
+        if ( ! isset($this->dbref)) {
176 176
             throw new EE_Error(sprintf(esc_html__('The dbref property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
177 177
         }
178 178
 
179 179
         // make sure dbref is safe
180 180
         $this->dbref = str_replace('-', '_', sanitize_key($this->dbref));
181 181
 
182
-        $should_be = 'EE_Messages_Template_Pack_' . str_replace(' ', '_', ucwords(str_replace('_', ' ', $this->dbref)));
182
+        $should_be = 'EE_Messages_Template_Pack_'.str_replace(' ', '_', ucwords(str_replace('_', ' ', $this->dbref)));
183 183
 
184 184
         if ($should_be !== $classname) {
185 185
             throw new EE_Error(sprintf(esc_html__('The name of the template pack instantiated class is "%s".  It should be "%s".  Make sure that the name of the template pack class matches is prepended with "EE_Messages_Template_Pack_" and appended with a sentence case iteration of the value for your template pack\'s dbref property.', 'event_espresso'), $classname, $should_be));
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
      */
237 237
     public function get_templates(EE_messenger $messenger, EE_message_type $message_type)
238 238
     {
239
-        return isset($this->_templates[ $messenger->name ][ $message_type->name ]) ? $this->_templates[ $messenger->name ][ $message_type->name ] : $this->_get_templates($messenger, $message_type);
239
+        return isset($this->_templates[$messenger->name][$message_type->name]) ? $this->_templates[$messenger->name][$message_type->name] : $this->_get_templates($messenger, $message_type);
240 240
     }
241 241
 
242 242
 
@@ -286,18 +286,18 @@  discard block
 block discarded – undo
286 286
                         foreach ($sub_fields as $sub_field => $sub_field_details) {
287 287
                             // make sure that the template_field_ref matches what the main template field is for this template group.
288 288
                             $template_field_ref = $sub_field == 'main' ? $main_field : $sub_field;
289
-                            $templates[ $context ][ $main_field ][ $sub_field ] = $this->_get_specific_template($default_pack, $messenger, $message_type, $template_field_ref, $context);
289
+                            $templates[$context][$main_field][$sub_field] = $this->_get_specific_template($default_pack, $messenger, $message_type, $template_field_ref, $context);
290 290
                         }
291 291
                     }
292 292
                 } else {
293
-                    $templates[ $context ][ $field ] = $this->_get_specific_template($default_pack, $messenger, $message_type, $field, $context);
293
+                    $templates[$context][$field] = $this->_get_specific_template($default_pack, $messenger, $message_type, $field, $context);
294 294
                 }
295 295
             }
296 296
         }
297 297
 
298 298
         $templates = apply_filters('FHEE__EE_Template_Pack___get_templates__templates', $templates, $messenger, $message_type, $this);
299 299
 
300
-        $this->_templates[ $messenger->name ][ $message_type->name ] = $templates;
300
+        $this->_templates[$messenger->name][$message_type->name] = $templates;
301 301
          return $templates;
302 302
     }
303 303
 
@@ -323,13 +323,13 @@  discard block
 block discarded – undo
323 323
         $filtered_base_path = apply_filters('FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', $this->_base_path, $messenger, $message_type, $field, $context, $this);
324 324
 
325 325
         $master_templates = $message_type->get_master_templates();
326
-        $master_templates_mt = isset($master_templates[ $messenger->name ]) ? $master_templates[ $messenger->name ] : $message_type->name;
327
-        $full_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '_' . $context . '.template.php';
328
-        $fallback_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '.template.php';
329
-        $mt_defined_full_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php';
330
-        $mt_defined_fallback_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php';
331
-        $base_defined_full_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php';
332
-        $base_defined_fallback_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php';
326
+        $master_templates_mt = isset($master_templates[$messenger->name]) ? $master_templates[$messenger->name] : $message_type->name;
327
+        $full_path = $filtered_base_path.$messenger->name.'_'.$message_type->name.'_'.$field.'_'.$context.'.template.php';
328
+        $fallback_path = $filtered_base_path.$messenger->name.'_'.$message_type->name.'_'.$field.'.template.php';
329
+        $mt_defined_full_path = $filtered_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'_'.$context.'.template.php';
330
+        $mt_defined_fallback_path = $filtered_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'.template.php';
331
+        $base_defined_full_path = $this->_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'_'.$context.'.template.php';
332
+        $base_defined_fallback_path = $this->_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'.template.php';
333 333
 
334 334
         /**
335 335
          * Template checks are done hierarchically in the following order:
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
             $actual_path = '';
360 360
         }
361 361
         if (empty($actual_path)) {
362
-            $contents = isset($default_templates[ $context ][ $field ]) ? $default_templates[ $context ][ $field ] : '';
362
+            $contents = isset($default_templates[$context][$field]) ? $default_templates[$context][$field] : '';
363 363
         } else {
364 364
             $contents = EEH_Template::display_template($actual_path, array(), true);
365 365
         }
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
      */
381 381
     public function get_supports()
382 382
     {
383
-        $supports = apply_filters('FHEE__' . get_class($this) . '__get_supports', $this->_supports);
383
+        $supports = apply_filters('FHEE__'.get_class($this).'__get_supports', $this->_supports);
384 384
         return apply_filters('FHEE__EE_Messages_Template_Pack__get_supports', $supports, $this);
385 385
     }
386 386
 
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
     public function get_default_variation_labels($messenger = '')
400 400
     {
401 401
         $label = empty($messenger) ? $this->_default_variation_labels : array();
402
-        $label = empty($label) && ! empty($this->_default_variation_labels[ $messenger ]) ? $this->_default_variation_labels[ $messenger ] : esc_html__('Default', 'event_espresso');
402
+        $label = empty($label) && ! empty($this->_default_variation_labels[$messenger]) ? $this->_default_variation_labels[$messenger] : esc_html__('Default', 'event_espresso');
403 403
 
404 404
         return apply_filters('FHEE__EE_Messages_Template_Pack__get_default_variation_labels', $label, $this->_default_variation_labels, $messenger);
405 405
     }
@@ -419,24 +419,24 @@  discard block
 block discarded – undo
419 419
      */
420 420
     public function get_variations($messenger = '', $message_type = '')
421 421
     {
422
-        $messenger_variations = ! empty($messenger) && isset($this->_variations[ $messenger ]) ? $this->_variations[ $messenger ] : array();
422
+        $messenger_variations = ! empty($messenger) && isset($this->_variations[$messenger]) ? $this->_variations[$messenger] : array();
423 423
 
424 424
         // message_type provided? IF so, then we've requested a specific set of variations, so we need to make sure we set it as empty if that's not present.
425
-        $variations = !empty($messenger) && !empty($message_type) && isset($messenger_variations[ $message_type ]) ? $messenger_variations[ $message_type ] : array();
425
+        $variations = ! empty($messenger) && ! empty($message_type) && isset($messenger_variations[$message_type]) ? $messenger_variations[$message_type] : array();
426 426
 
427 427
         // now let's account for the possibility we just want all the variations for a messenger (which is indicated by providing the messenger but not the message type).
428
-        $variations = empty($variations) && !empty($messenger) && empty($message_type) ? $messenger_variations : $variations;
428
+        $variations = empty($variations) && ! empty($messenger) && empty($message_type) ? $messenger_variations : $variations;
429 429
 
430 430
         // filter per template pack and globally.
431
-        $variations = apply_filters('FHEE__' . get_class($this) . '__get_variations', $variations, $messenger, $message_type);
431
+        $variations = apply_filters('FHEE__'.get_class($this).'__get_variations', $variations, $messenger, $message_type);
432 432
         $variations = apply_filters('FHEE__EE_Messages_Template_Pack__get_variations', $variations, $messenger, $message_type, $this);
433 433
 
434 434
         // prepend the _default_variation, but ONLY if we're returning the fully validated array.
435
-        if (!empty($messenger) && !empty($message_type) && ! empty($variations)) {
436
-            $variations = array( 'default' => $this->get_default_variation_labels($messenger) ) + $variations;
435
+        if ( ! empty($messenger) && ! empty($message_type) && ! empty($variations)) {
436
+            $variations = array('default' => $this->get_default_variation_labels($messenger)) + $variations;
437 437
         }
438 438
 
439
-        return empty($variations) ? array( 'default' => $this->get_default_variation_labels('dft') ) : $variations;
439
+        return empty($variations) ? array('default' => $this->get_default_variation_labels('dft')) : $variations;
440 440
     }
441 441
 
442 442
 
@@ -463,23 +463,23 @@  discard block
 block discarded – undo
463 463
         $base = $url ? $this->_base_url : $this->_base_path;
464 464
         $base_path = $this->_base_path;
465 465
 
466
-        if (! $skip_filters) {
467
-            $base =  apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', $base, $messenger, $message_type, $type, $variation, $url, $file_extension, $this);
466
+        if ( ! $skip_filters) {
467
+            $base = apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', $base, $messenger, $message_type, $type, $variation, $url, $file_extension, $this);
468 468
             $base_path = apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path', $base_path, $messenger, $message_type, $type, $variation, false, $file_extension, $this);
469 469
         }
470 470
 
471 471
         $default_pack = get_class($this) != 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : $this;
472 472
 
473 473
         // possible variation paths considering whether message type is present or not in the file name.
474
-        $path_string = 'variations/' . $messenger . '_' . $message_type . '_'  . $type . '_' . $variation . $file_extension;
475
-        $default_path_string = 'variations/' . $messenger . '_' . $type . '_' . $variation . $file_extension;
474
+        $path_string = 'variations/'.$messenger.'_'.$message_type.'_'.$type.'_'.$variation.$file_extension;
475
+        $default_path_string = 'variations/'.$messenger.'_'.$type.'_'.$variation.$file_extension;
476 476
 
477 477
         // first see if fully validated file exists.
478
-        if (is_readable($base_path . $path_string)) {
479
-            $variation_path = $base . $path_string;
478
+        if (is_readable($base_path.$path_string)) {
479
+            $variation_path = $base.$path_string;
480 480
         // otherwise see if default exists.
481
-        } elseif (is_readable($base_path . $default_path_string)) {
482
-            $variation_path = $base . $default_path_string;
481
+        } elseif (is_readable($base_path.$default_path_string)) {
482
+            $variation_path = $base.$default_path_string;
483 483
         } else {
484 484
             $variation_path = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_default_variation($messenger, $message_type, $type, $url, $file_extension) : '';
485 485
         }
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
         }
490 490
 
491 491
         // filter result
492
-        $variation_path = apply_filters('FHEE__' . get_class($this) . '__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url);
492
+        $variation_path = apply_filters('FHEE__'.get_class($this).'__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url);
493 493
         return apply_filters('FHEE__EE_Messages_Template_Pack__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, $this);
494 494
     }
495 495
 
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
     {
510 510
         $default_pack = get_class($this) !== 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : null;
511 511
 
512
-        $path_string = $this->_base_path . $messenger . '_' . $type . '_wrapper.template.php';
512
+        $path_string = $this->_base_path.$messenger.'_'.$type.'_wrapper.template.php';
513 513
 
514 514
         if (is_readable($path_string)) {
515 515
             $template = $path_string;
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
         }
519 519
 
520 520
         // filter
521
-        $template = apply_filters('FHEE__' . get_class($this) . '__get_wrapper', $template, $messenger, $type);
521
+        $template = apply_filters('FHEE__'.get_class($this).'__get_wrapper', $template, $messenger, $type);
522 522
         return apply_filters('FHEE__EE_Messages_Template_Pack__get_wrapper', $template, $messenger, $type, $this);
523 523
     }
524 524
 }
Please login to merge, or discard this patch.
Indentation   +469 added lines, -469 removed lines patch added patch discarded remove patch
@@ -12,511 +12,511 @@
 block discarded – undo
12 12
  */
13 13
 abstract class EE_Messages_Template_Pack
14 14
 {
15
-    /**
16
-     * This defines the base_path where the templates are located.
17
-     *
18
-     * @since            4.5.0
19
-     *
20
-     * @var string
21
-     */
22
-    protected $_base_path;
15
+	/**
16
+	 * This defines the base_path where the templates are located.
17
+	 *
18
+	 * @since            4.5.0
19
+	 *
20
+	 * @var string
21
+	 */
22
+	protected $_base_path;
23 23
 
24 24
 
25 25
 
26 26
 
27
-    /**
28
-     * This defines the base_url where things are found for this template pack (possibly variations).
29
-     *
30
-     * @since 4.5.0
31
-     *
32
-     * @var string
33
-     */
34
-    protected $_base_url;
27
+	/**
28
+	 * This defines the base_url where things are found for this template pack (possibly variations).
29
+	 *
30
+	 * @since 4.5.0
31
+	 *
32
+	 * @var string
33
+	 */
34
+	protected $_base_url;
35 35
 
36 36
 
37 37
 
38
-    /**
39
-     * localized label for this template pack
40
-     *
41
-     * @since            4.5.0
42
-     *
43
-     * @var string
44
-     */
45
-    public $label;
38
+	/**
39
+	 * localized label for this template pack
40
+	 *
41
+	 * @since            4.5.0
42
+	 *
43
+	 * @var string
44
+	 */
45
+	public $label;
46 46
 
47 47
 
48 48
 
49 49
 
50
-    /**
51
-     * used to contain a description for the template pack.
52
-     *
53
-     * @since 4.5.0
54
-     *
55
-     * @var string
56
-     */
57
-    public $description;
50
+	/**
51
+	 * used to contain a description for the template pack.
52
+	 *
53
+	 * @since 4.5.0
54
+	 *
55
+	 * @var string
56
+	 */
57
+	public $description;
58 58
 
59 59
 
60 60
 
61 61
 
62
-    /**
63
-     * How this template is referenced in the db
64
-     *
65
-     * @since 4.5.0
66
-     *
67
-     * @var string
68
-     */
69
-    public $dbref;
62
+	/**
63
+	 * How this template is referenced in the db
64
+	 *
65
+	 * @since 4.5.0
66
+	 *
67
+	 * @var string
68
+	 */
69
+	public $dbref;
70 70
 
71 71
 
72 72
 
73 73
 
74
-    /**
75
-     * This is an array indexed by messenger and with an array of message types as values that indicate what messenger and message type this template pack supports by default.  It is possible for this to be modified by plugins via filters, but out of the box, this is what the template pack supports.
76
-     *
77
-     * @since 4.5.0
78
-     *
79
-     * @var array.
80
-     */
81
-    protected $_supports = array();
74
+	/**
75
+	 * This is an array indexed by messenger and with an array of message types as values that indicate what messenger and message type this template pack supports by default.  It is possible for this to be modified by plugins via filters, but out of the box, this is what the template pack supports.
76
+	 *
77
+	 * @since 4.5.0
78
+	 *
79
+	 * @var array.
80
+	 */
81
+	protected $_supports = array();
82 82
 
83 83
 
84 84
 
85 85
 
86 86
 
87
-    /**
88
-     * Holds the retrieved default templates for this template pack in a multidimensional array indexed by context and field, for a given messenger and message type.  Example format:
89
-     *
90
-     * $templates = array(
91
-     *  'email' => array(
92
-     *      'registration' => array(
93
-     *          'admin' => array(
94
-     *              'to' => 'contents',
95
-     *              'from' => 'contents',
96
-     *              'subject' => 'contents',
97
-     *              'content' => 'contents',
98
-     *              'event_list' => 'contents',
99
-     *              'attendee_list' => 'contents'
100
-     *          ),
101
-     *          'attendee' => array(
102
-     *              'to' => 'contents',
103
-     *              'from' => 'contents',
104
-     *              'subject' => 'contents',
105
-     *              'content' => 'contents',
106
-     *              'event_list' => 'contents',
107
-     *              'attendee_list' => 'contents',
108
-     *          ),
109
-     *      )
110
-     *  )
111
-     * )
112
-     *
113
-     * @since 4.5.0
114
-     *
115
-     * @var array
116
-     */
117
-    protected $_templates = array();
87
+	/**
88
+	 * Holds the retrieved default templates for this template pack in a multidimensional array indexed by context and field, for a given messenger and message type.  Example format:
89
+	 *
90
+	 * $templates = array(
91
+	 *  'email' => array(
92
+	 *      'registration' => array(
93
+	 *          'admin' => array(
94
+	 *              'to' => 'contents',
95
+	 *              'from' => 'contents',
96
+	 *              'subject' => 'contents',
97
+	 *              'content' => 'contents',
98
+	 *              'event_list' => 'contents',
99
+	 *              'attendee_list' => 'contents'
100
+	 *          ),
101
+	 *          'attendee' => array(
102
+	 *              'to' => 'contents',
103
+	 *              'from' => 'contents',
104
+	 *              'subject' => 'contents',
105
+	 *              'content' => 'contents',
106
+	 *              'event_list' => 'contents',
107
+	 *              'attendee_list' => 'contents',
108
+	 *          ),
109
+	 *      )
110
+	 *  )
111
+	 * )
112
+	 *
113
+	 * @since 4.5.0
114
+	 *
115
+	 * @var array
116
+	 */
117
+	protected $_templates = array();
118 118
 
119 119
 
120 120
 
121 121
 
122 122
 
123 123
 
124
-    /**
125
-     * Template Packs must ALWAYS have a default variation defined.  This property allow one to override the default variation labels per messenger.
126
-     * example:
127
-     * $this->_default_variation_labels = array( 'email' =>  esc_html__('Default', 'event_espresso' ) );
128
-     *
129
-     * @var array
130
-     */
131
-    protected $_default_variation_labels = array();
124
+	/**
125
+	 * Template Packs must ALWAYS have a default variation defined.  This property allow one to override the default variation labels per messenger.
126
+	 * example:
127
+	 * $this->_default_variation_labels = array( 'email' =>  esc_html__('Default', 'event_espresso' ) );
128
+	 *
129
+	 * @var array
130
+	 */
131
+	protected $_default_variation_labels = array();
132 132
 
133 133
 
134 134
 
135 135
 
136
-    /**
137
-     * This is an array of extra css variations for message templates indexed by messenger with the values as an array or message types the variations apply to as the key  and then values are an array with variation slugs as the key and label as the value. Note the default variation is not included in this array.  So the structure is:
138
-     * array(
139
-     *  'email' => array(
140
-     *  )
141
-     * )
142
-     *
143
-     * Keep in mind that this property is used both for indicating valid variations for a given message type and messenger but the variation files themselves are ONLY unique to the messenger.  So if you have a variation for the html messenger referenced by the slug "sunset_red" Then the variation file for the main type will be html_main_sunset_red.css.  All the array in this property allows you to do, is indicate that with certain message types the sunset_red variation is available but for other message types its not.  But you could NOT have a sunset_red variation file for one messenger/message_type and a different one for another messenger/message_type.  If you want different css looks then you can define a different structural layout for the template , messenger, message type combination and in the same sunset_red.css variation file just add css specific to that layout.
144
-     *
145
-     * @since 4.5.0
146
-     *
147
-     * @var array
148
-     */
149
-    public $_variations = array();
150
-
151
-
152
-
153
-
154
-    /**
155
-     * Template pack constructor
156
-     *
157
-     * @since 4.5.0
158
-     */
159
-    public function __construct()
160
-    {
161
-        $this->_set_props();
162
-        // make sure classname is correct
163
-        $classname = get_class($this);
164
-        // make sure required props have been set
165
-
166
-        // if label is empty then throw an error because we should have it defined by now.
167
-        if (! isset($this->label)) {
168
-            throw new EE_Error(sprintf(esc_html__('The label property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
169
-        }
170
-
171
-
172
-        // the reference for this template pack
173
-        if (! isset($this->dbref)) {
174
-            throw new EE_Error(sprintf(esc_html__('The dbref property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
175
-        }
176
-
177
-        // make sure dbref is safe
178
-        $this->dbref = str_replace('-', '_', sanitize_key($this->dbref));
179
-
180
-        $should_be = 'EE_Messages_Template_Pack_' . str_replace(' ', '_', ucwords(str_replace('_', ' ', $this->dbref)));
181
-
182
-        if ($should_be !== $classname) {
183
-            throw new EE_Error(sprintf(esc_html__('The name of the template pack instantiated class is "%s".  It should be "%s".  Make sure that the name of the template pack class matches is prepended with "EE_Messages_Template_Pack_" and appended with a sentence case iteration of the value for your template pack\'s dbref property.', 'event_espresso'), $classname, $should_be));
184
-        }
185
-
186
-        // if _base_path is not set then throw an error because a base path string is needed.
187
-        if (empty($this->_base_path)) {
188
-            throw new EE_Error(sprintf(esc_html__('The _base_path property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
189
-        }
190
-
191
-
192
-        // if _base_url is not set then throw an error because a  string is needed for variations.
193
-        if (empty($this->_base_url)) {
194
-            throw new EE_Error(sprintf(esc_html__('The _base_url property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
195
-        }
196
-
197
-
198
-        // if $supports is not set then throw an error because that effectively means this template_pack does not have any templates!
199
-        if (empty($this->_supports)) {
200
-            throw new EE_Error(sprintf(esc_html__('The supports property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
201
-        }
202
-    }
203
-
204
-
205
-
206
-    /**
207
-     * This method should be used to define the following properties:
208
-     * - label
209
-     * - dbref
210
-     * - description
211
-     * - _base_path
212
-     * - _base_url
213
-     * - supports
214
-     * - variations
215
-     *
216
-     * @since 4.5.0
217
-     * @return void.
218
-     * @abstract
219
-     */
220
-    abstract protected function _set_props();
221
-
222
-
223
-
224
-
225
-    /**
226
-     * Wrapper for get_templates() ( @see get_templates() for documentation)
227
-     *
228
-     * @since 4.5.0
229
-     *
230
-     * @param EE_messenger    $messenger
231
-     * @param EE_message_type $message_type
232
-     *
233
-     * @return array
234
-     */
235
-    public function get_templates(EE_messenger $messenger, EE_message_type $message_type)
236
-    {
237
-        return isset($this->_templates[ $messenger->name ][ $message_type->name ]) ? $this->_templates[ $messenger->name ][ $message_type->name ] : $this->_get_templates($messenger, $message_type);
238
-    }
239
-
240
-
241
-
242
-
243
-    /**
244
-     * This takes the incoming messenger and message type objects, uses them to get the set fields and contexts, then attempts to retrieve the templates matching those for this given template pack.
245
-     *
246
-     * @since 4.5.0
247
-     *
248
-     * @param EE_messenger    $messenger
249
-     * @param EE_message_type $message_type
250
-     *
251
-     * @return array          Returns an multi-level associative array indexed by template context and field in the format:
252
-     *                                array( 'context' => array( 'field' => 'value', 'another-field', 'value' ) );
253
-     */
254
-    protected function _get_templates(EE_messenger $messenger, EE_message_type $message_type)
255
-    {
256
-        $templates = array();
257
-
258
-        /**
259
-         * Retrieving the default pack for later usage of default templates for template packs that
260
-         * are NOT the default pack ( or an extension of the default pack ).
261
-         * We ONLY set this variable to be the default pack IF the loaded class is NOT the default
262
-         * pack.  This prevents recursion in _get_specific_template().  The intention is that for
263
-         * template packs that are NOT default packs, we use the default template pack to provide
264
-         * the final fallback templates if there aren't any defined for the called template pack.
265
-         *
266
-         * @type EE_Messages_Template_Pack_Default | null $default_pack
267
-         */
268
-        $default_pack = ! $this instanceof EE_Messages_Template_Pack_Default ? new EE_Messages_Template_Pack_Default() : null;
269
-
270
-        $fields = $messenger->get_template_fields();
271
-        $contexts = $message_type->get_contexts();
272
-
273
-
274
-        foreach ($contexts as $context => $details) {
275
-            foreach ($fields as $field => $field_details) {
276
-                if (empty($field_details)) {
277
-                    continue;
278
-                }
279
-                /**
280
-                 * is this a field array (linked to a main field)?
281
-                 */
282
-                if ($field == 'extra') {
283
-                    foreach ($field_details as $main_field => $sub_fields) {
284
-                        foreach ($sub_fields as $sub_field => $sub_field_details) {
285
-                            // make sure that the template_field_ref matches what the main template field is for this template group.
286
-                            $template_field_ref = $sub_field == 'main' ? $main_field : $sub_field;
287
-                            $templates[ $context ][ $main_field ][ $sub_field ] = $this->_get_specific_template($default_pack, $messenger, $message_type, $template_field_ref, $context);
288
-                        }
289
-                    }
290
-                } else {
291
-                    $templates[ $context ][ $field ] = $this->_get_specific_template($default_pack, $messenger, $message_type, $field, $context);
292
-                }
293
-            }
294
-        }
295
-
296
-        $templates = apply_filters('FHEE__EE_Template_Pack___get_templates__templates', $templates, $messenger, $message_type, $this);
297
-
298
-        $this->_templates[ $messenger->name ][ $message_type->name ] = $templates;
299
-         return $templates;
300
-    }
301
-
302
-
303
-    /**
304
-     * Utility method for retrieving a specific template matching the given parameters
305
-     *
306
-     * @param null | EE_Messages_Template_Pack_Default $default_pack
307
-     * @param EE_messenger                             $messenger
308
-     * @param EE_message_type                          $message_type
309
-     * @param string                                   $field          The field reference for the specific template being looked up.
310
-     * @param string                                   $context      The context reference for the specific template being looked up
311
-     *
312
-     * @return string          The template contents.
313
-     */
314
-    protected function _get_specific_template($default_pack, EE_messenger $messenger, EE_message_type $message_type, $field, $context)
315
-    {
316
-
317
-        // default templates
318
-        $default_templates = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_templates($messenger, $message_type) : array();
319
-
320
-        // first we allow for the $_base_path to be filtered.  However, we assign this to a new variable so that we have the original base_path as a fallback.
321
-        $filtered_base_path = apply_filters('FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', $this->_base_path, $messenger, $message_type, $field, $context, $this);
322
-
323
-        $master_templates = $message_type->get_master_templates();
324
-        $master_templates_mt = isset($master_templates[ $messenger->name ]) ? $master_templates[ $messenger->name ] : $message_type->name;
325
-        $full_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '_' . $context . '.template.php';
326
-        $fallback_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '.template.php';
327
-        $mt_defined_full_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php';
328
-        $mt_defined_fallback_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php';
329
-        $base_defined_full_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php';
330
-        $base_defined_fallback_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php';
331
-
332
-        /**
333
-         * Template checks are done hierarchically in the following order:
334
-         *
335
-         * - a match for the full messenger name, message type, context and field in the full path for the given template pack.
336
-         * - a match for the full messenger name, message type, field in the full path for the given template pack.
337
-         * - a match for the full messenger name, message type, field, context in the path grabbed for the related message type defined in the _master_templates property for the message type (i.e. all registration message types share the same template as the main registration message type).
338
-         * - match for the full messenger name, message type, field for the related message type defined in the _master templates property for the message type
339
-         * - a match for a default template matching the messenger, name, context, field (as set by the default template packs).
340
-         * - empty string.
341
-         */
342
-
343
-
344
-        if (is_readable($full_path)) {
345
-            $actual_path = $full_path;
346
-        } elseif (is_readable($fallback_path)) {
347
-            $actual_path = $fallback_path;
348
-        } elseif (is_readable($mt_defined_full_path)) {
349
-            $actual_path = $mt_defined_full_path;
350
-        } elseif (is_readable($mt_defined_fallback_path)) {
351
-            $actual_path = $mt_defined_fallback_path;
352
-        } elseif (is_readable($base_defined_full_path)) {
353
-            $actual_path = $base_defined_full_path;
354
-        } elseif (is_readable($base_defined_fallback_path)) {
355
-            $actual_path = $base_defined_fallback_path;
356
-        } else {
357
-            $actual_path = '';
358
-        }
359
-        if (empty($actual_path)) {
360
-            $contents = isset($default_templates[ $context ][ $field ]) ? $default_templates[ $context ][ $field ] : '';
361
-        } else {
362
-            $contents = EEH_Template::display_template($actual_path, array(), true);
363
-        }
364
-
365
-        return apply_filters('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', $contents, $actual_path, $messenger, $message_type, $field, $context, $this);
366
-    }
367
-
368
-
369
-
370
-
371
-
372
-    /**
373
-     * Return filtered _supports property.
374
-     *
375
-     * @since 4.5.0
376
-     *
377
-     * @return array
378
-     */
379
-    public function get_supports()
380
-    {
381
-        $supports = apply_filters('FHEE__' . get_class($this) . '__get_supports', $this->_supports);
382
-        return apply_filters('FHEE__EE_Messages_Template_Pack__get_supports', $supports, $this);
383
-    }
384
-
385
-
386
-
387
-
388
-    /**
389
-     * This simply returns the $_default_variation_labels property value.
390
-     *
391
-     * @since 4.5.0
392
-     *
393
-     * @param string $messenger if the messenger slug is returned then the default label for the specific messenger is retrieved.  If it doesn't exist then the esc_html__('Default', 'event_espresso') is returned.  If NO value is provided then whatever is set on the _default_variation_labels property is returned.
394
-     *
395
-     * @return array|string
396
-     */
397
-    public function get_default_variation_labels($messenger = '')
398
-    {
399
-        $label = empty($messenger) ? $this->_default_variation_labels : array();
400
-        $label = empty($label) && ! empty($this->_default_variation_labels[ $messenger ]) ? $this->_default_variation_labels[ $messenger ] : esc_html__('Default', 'event_espresso');
401
-
402
-        return apply_filters('FHEE__EE_Messages_Template_Pack__get_default_variation_labels', $label, $this->_default_variation_labels, $messenger);
403
-    }
404
-
405
-
406
-
407
-
408
-
409
-    /**
410
-     * This simply returns the _variations property.
411
-     *
412
-     * @since 4.5.0
413
-     *
414
-     * @param string $messenger if included then css variations matching the messenger are returned.  Otherwise, just the default variation is included.  If both message type AND messenger are empty then all variations are returned.
415
-     * @param string $message_type if included then css variations matching the message_type are returned (must have $messenger set).  Otherwise the array of variations per message type are returned.  If message_type is provided but NOT the messenger, then just all variations for all messengers are returned.
416
-     * @return array
417
-     */
418
-    public function get_variations($messenger = '', $message_type = '')
419
-    {
420
-        $messenger_variations = ! empty($messenger) && isset($this->_variations[ $messenger ]) ? $this->_variations[ $messenger ] : array();
421
-
422
-        // message_type provided? IF so, then we've requested a specific set of variations, so we need to make sure we set it as empty if that's not present.
423
-        $variations = !empty($messenger) && !empty($message_type) && isset($messenger_variations[ $message_type ]) ? $messenger_variations[ $message_type ] : array();
424
-
425
-        // now let's account for the possibility we just want all the variations for a messenger (which is indicated by providing the messenger but not the message type).
426
-        $variations = empty($variations) && !empty($messenger) && empty($message_type) ? $messenger_variations : $variations;
427
-
428
-        // filter per template pack and globally.
429
-        $variations = apply_filters('FHEE__' . get_class($this) . '__get_variations', $variations, $messenger, $message_type);
430
-        $variations = apply_filters('FHEE__EE_Messages_Template_Pack__get_variations', $variations, $messenger, $message_type, $this);
431
-
432
-        // prepend the _default_variation, but ONLY if we're returning the fully validated array.
433
-        if (!empty($messenger) && !empty($message_type) && ! empty($variations)) {
434
-            $variations = array( 'default' => $this->get_default_variation_labels($messenger) ) + $variations;
435
-        }
436
-
437
-        return empty($variations) ? array( 'default' => $this->get_default_variation_labels('dft') ) : $variations;
438
-    }
439
-
440
-
441
-
442
-
443
-    /**
444
-     * This is typically called by EE_messenger objects to get the specific css variation defined for the messenger, message_type and type (i.e. inline, wpeditor, preview etc.)
445
-     *
446
-     * @since 4.5.0
447
-     *
448
-     * @param string $messenger messenger slug
449
-     * @param string $message_type message_type slug
450
-     * @param string $type           variation type (i.e. inline, base, wpeditor, preview etc. //this varies per messenger).
451
-     * @param string $variation    this should match one of the defined variations in the _variations property on this class.
452
-     * @param string $file_extension  What type of file the variation file is (defaults to css)
453
-     * @param bool   $url          if true then return the url otherwise path.
454
-     * @param bool   $skip_filters This should not be set directly, its used internally to skip filters when the default template pack is called internally as the fallback.
455
-     *
456
-     * @return string The variation path or url (typically css reference)
457
-     */
458
-    public function get_variation($messenger, $message_type, $type, $variation, $url = true, $file_extension = '.css', $skip_filters = false)
459
-    {
136
+	/**
137
+	 * This is an array of extra css variations for message templates indexed by messenger with the values as an array or message types the variations apply to as the key  and then values are an array with variation slugs as the key and label as the value. Note the default variation is not included in this array.  So the structure is:
138
+	 * array(
139
+	 *  'email' => array(
140
+	 *  )
141
+	 * )
142
+	 *
143
+	 * Keep in mind that this property is used both for indicating valid variations for a given message type and messenger but the variation files themselves are ONLY unique to the messenger.  So if you have a variation for the html messenger referenced by the slug "sunset_red" Then the variation file for the main type will be html_main_sunset_red.css.  All the array in this property allows you to do, is indicate that with certain message types the sunset_red variation is available but for other message types its not.  But you could NOT have a sunset_red variation file for one messenger/message_type and a different one for another messenger/message_type.  If you want different css looks then you can define a different structural layout for the template , messenger, message type combination and in the same sunset_red.css variation file just add css specific to that layout.
144
+	 *
145
+	 * @since 4.5.0
146
+	 *
147
+	 * @var array
148
+	 */
149
+	public $_variations = array();
150
+
151
+
152
+
153
+
154
+	/**
155
+	 * Template pack constructor
156
+	 *
157
+	 * @since 4.5.0
158
+	 */
159
+	public function __construct()
160
+	{
161
+		$this->_set_props();
162
+		// make sure classname is correct
163
+		$classname = get_class($this);
164
+		// make sure required props have been set
165
+
166
+		// if label is empty then throw an error because we should have it defined by now.
167
+		if (! isset($this->label)) {
168
+			throw new EE_Error(sprintf(esc_html__('The label property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
169
+		}
170
+
171
+
172
+		// the reference for this template pack
173
+		if (! isset($this->dbref)) {
174
+			throw new EE_Error(sprintf(esc_html__('The dbref property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
175
+		}
176
+
177
+		// make sure dbref is safe
178
+		$this->dbref = str_replace('-', '_', sanitize_key($this->dbref));
179
+
180
+		$should_be = 'EE_Messages_Template_Pack_' . str_replace(' ', '_', ucwords(str_replace('_', ' ', $this->dbref)));
181
+
182
+		if ($should_be !== $classname) {
183
+			throw new EE_Error(sprintf(esc_html__('The name of the template pack instantiated class is "%s".  It should be "%s".  Make sure that the name of the template pack class matches is prepended with "EE_Messages_Template_Pack_" and appended with a sentence case iteration of the value for your template pack\'s dbref property.', 'event_espresso'), $classname, $should_be));
184
+		}
185
+
186
+		// if _base_path is not set then throw an error because a base path string is needed.
187
+		if (empty($this->_base_path)) {
188
+			throw new EE_Error(sprintf(esc_html__('The _base_path property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
189
+		}
190
+
191
+
192
+		// if _base_url is not set then throw an error because a  string is needed for variations.
193
+		if (empty($this->_base_url)) {
194
+			throw new EE_Error(sprintf(esc_html__('The _base_url property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
195
+		}
196
+
197
+
198
+		// if $supports is not set then throw an error because that effectively means this template_pack does not have any templates!
199
+		if (empty($this->_supports)) {
200
+			throw new EE_Error(sprintf(esc_html__('The supports property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
201
+		}
202
+	}
203
+
204
+
205
+
206
+	/**
207
+	 * This method should be used to define the following properties:
208
+	 * - label
209
+	 * - dbref
210
+	 * - description
211
+	 * - _base_path
212
+	 * - _base_url
213
+	 * - supports
214
+	 * - variations
215
+	 *
216
+	 * @since 4.5.0
217
+	 * @return void.
218
+	 * @abstract
219
+	 */
220
+	abstract protected function _set_props();
221
+
222
+
223
+
224
+
225
+	/**
226
+	 * Wrapper for get_templates() ( @see get_templates() for documentation)
227
+	 *
228
+	 * @since 4.5.0
229
+	 *
230
+	 * @param EE_messenger    $messenger
231
+	 * @param EE_message_type $message_type
232
+	 *
233
+	 * @return array
234
+	 */
235
+	public function get_templates(EE_messenger $messenger, EE_message_type $message_type)
236
+	{
237
+		return isset($this->_templates[ $messenger->name ][ $message_type->name ]) ? $this->_templates[ $messenger->name ][ $message_type->name ] : $this->_get_templates($messenger, $message_type);
238
+	}
239
+
240
+
241
+
242
+
243
+	/**
244
+	 * This takes the incoming messenger and message type objects, uses them to get the set fields and contexts, then attempts to retrieve the templates matching those for this given template pack.
245
+	 *
246
+	 * @since 4.5.0
247
+	 *
248
+	 * @param EE_messenger    $messenger
249
+	 * @param EE_message_type $message_type
250
+	 *
251
+	 * @return array          Returns an multi-level associative array indexed by template context and field in the format:
252
+	 *                                array( 'context' => array( 'field' => 'value', 'another-field', 'value' ) );
253
+	 */
254
+	protected function _get_templates(EE_messenger $messenger, EE_message_type $message_type)
255
+	{
256
+		$templates = array();
257
+
258
+		/**
259
+		 * Retrieving the default pack for later usage of default templates for template packs that
260
+		 * are NOT the default pack ( or an extension of the default pack ).
261
+		 * We ONLY set this variable to be the default pack IF the loaded class is NOT the default
262
+		 * pack.  This prevents recursion in _get_specific_template().  The intention is that for
263
+		 * template packs that are NOT default packs, we use the default template pack to provide
264
+		 * the final fallback templates if there aren't any defined for the called template pack.
265
+		 *
266
+		 * @type EE_Messages_Template_Pack_Default | null $default_pack
267
+		 */
268
+		$default_pack = ! $this instanceof EE_Messages_Template_Pack_Default ? new EE_Messages_Template_Pack_Default() : null;
269
+
270
+		$fields = $messenger->get_template_fields();
271
+		$contexts = $message_type->get_contexts();
272
+
273
+
274
+		foreach ($contexts as $context => $details) {
275
+			foreach ($fields as $field => $field_details) {
276
+				if (empty($field_details)) {
277
+					continue;
278
+				}
279
+				/**
280
+				 * is this a field array (linked to a main field)?
281
+				 */
282
+				if ($field == 'extra') {
283
+					foreach ($field_details as $main_field => $sub_fields) {
284
+						foreach ($sub_fields as $sub_field => $sub_field_details) {
285
+							// make sure that the template_field_ref matches what the main template field is for this template group.
286
+							$template_field_ref = $sub_field == 'main' ? $main_field : $sub_field;
287
+							$templates[ $context ][ $main_field ][ $sub_field ] = $this->_get_specific_template($default_pack, $messenger, $message_type, $template_field_ref, $context);
288
+						}
289
+					}
290
+				} else {
291
+					$templates[ $context ][ $field ] = $this->_get_specific_template($default_pack, $messenger, $message_type, $field, $context);
292
+				}
293
+			}
294
+		}
295
+
296
+		$templates = apply_filters('FHEE__EE_Template_Pack___get_templates__templates', $templates, $messenger, $message_type, $this);
297
+
298
+		$this->_templates[ $messenger->name ][ $message_type->name ] = $templates;
299
+		 return $templates;
300
+	}
301
+
302
+
303
+	/**
304
+	 * Utility method for retrieving a specific template matching the given parameters
305
+	 *
306
+	 * @param null | EE_Messages_Template_Pack_Default $default_pack
307
+	 * @param EE_messenger                             $messenger
308
+	 * @param EE_message_type                          $message_type
309
+	 * @param string                                   $field          The field reference for the specific template being looked up.
310
+	 * @param string                                   $context      The context reference for the specific template being looked up
311
+	 *
312
+	 * @return string          The template contents.
313
+	 */
314
+	protected function _get_specific_template($default_pack, EE_messenger $messenger, EE_message_type $message_type, $field, $context)
315
+	{
316
+
317
+		// default templates
318
+		$default_templates = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_templates($messenger, $message_type) : array();
319
+
320
+		// first we allow for the $_base_path to be filtered.  However, we assign this to a new variable so that we have the original base_path as a fallback.
321
+		$filtered_base_path = apply_filters('FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', $this->_base_path, $messenger, $message_type, $field, $context, $this);
322
+
323
+		$master_templates = $message_type->get_master_templates();
324
+		$master_templates_mt = isset($master_templates[ $messenger->name ]) ? $master_templates[ $messenger->name ] : $message_type->name;
325
+		$full_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '_' . $context . '.template.php';
326
+		$fallback_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '.template.php';
327
+		$mt_defined_full_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php';
328
+		$mt_defined_fallback_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php';
329
+		$base_defined_full_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php';
330
+		$base_defined_fallback_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php';
331
+
332
+		/**
333
+		 * Template checks are done hierarchically in the following order:
334
+		 *
335
+		 * - a match for the full messenger name, message type, context and field in the full path for the given template pack.
336
+		 * - a match for the full messenger name, message type, field in the full path for the given template pack.
337
+		 * - a match for the full messenger name, message type, field, context in the path grabbed for the related message type defined in the _master_templates property for the message type (i.e. all registration message types share the same template as the main registration message type).
338
+		 * - match for the full messenger name, message type, field for the related message type defined in the _master templates property for the message type
339
+		 * - a match for a default template matching the messenger, name, context, field (as set by the default template packs).
340
+		 * - empty string.
341
+		 */
342
+
343
+
344
+		if (is_readable($full_path)) {
345
+			$actual_path = $full_path;
346
+		} elseif (is_readable($fallback_path)) {
347
+			$actual_path = $fallback_path;
348
+		} elseif (is_readable($mt_defined_full_path)) {
349
+			$actual_path = $mt_defined_full_path;
350
+		} elseif (is_readable($mt_defined_fallback_path)) {
351
+			$actual_path = $mt_defined_fallback_path;
352
+		} elseif (is_readable($base_defined_full_path)) {
353
+			$actual_path = $base_defined_full_path;
354
+		} elseif (is_readable($base_defined_fallback_path)) {
355
+			$actual_path = $base_defined_fallback_path;
356
+		} else {
357
+			$actual_path = '';
358
+		}
359
+		if (empty($actual_path)) {
360
+			$contents = isset($default_templates[ $context ][ $field ]) ? $default_templates[ $context ][ $field ] : '';
361
+		} else {
362
+			$contents = EEH_Template::display_template($actual_path, array(), true);
363
+		}
364
+
365
+		return apply_filters('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', $contents, $actual_path, $messenger, $message_type, $field, $context, $this);
366
+	}
367
+
368
+
369
+
370
+
371
+
372
+	/**
373
+	 * Return filtered _supports property.
374
+	 *
375
+	 * @since 4.5.0
376
+	 *
377
+	 * @return array
378
+	 */
379
+	public function get_supports()
380
+	{
381
+		$supports = apply_filters('FHEE__' . get_class($this) . '__get_supports', $this->_supports);
382
+		return apply_filters('FHEE__EE_Messages_Template_Pack__get_supports', $supports, $this);
383
+	}
384
+
385
+
386
+
387
+
388
+	/**
389
+	 * This simply returns the $_default_variation_labels property value.
390
+	 *
391
+	 * @since 4.5.0
392
+	 *
393
+	 * @param string $messenger if the messenger slug is returned then the default label for the specific messenger is retrieved.  If it doesn't exist then the esc_html__('Default', 'event_espresso') is returned.  If NO value is provided then whatever is set on the _default_variation_labels property is returned.
394
+	 *
395
+	 * @return array|string
396
+	 */
397
+	public function get_default_variation_labels($messenger = '')
398
+	{
399
+		$label = empty($messenger) ? $this->_default_variation_labels : array();
400
+		$label = empty($label) && ! empty($this->_default_variation_labels[ $messenger ]) ? $this->_default_variation_labels[ $messenger ] : esc_html__('Default', 'event_espresso');
401
+
402
+		return apply_filters('FHEE__EE_Messages_Template_Pack__get_default_variation_labels', $label, $this->_default_variation_labels, $messenger);
403
+	}
404
+
405
+
406
+
407
+
408
+
409
+	/**
410
+	 * This simply returns the _variations property.
411
+	 *
412
+	 * @since 4.5.0
413
+	 *
414
+	 * @param string $messenger if included then css variations matching the messenger are returned.  Otherwise, just the default variation is included.  If both message type AND messenger are empty then all variations are returned.
415
+	 * @param string $message_type if included then css variations matching the message_type are returned (must have $messenger set).  Otherwise the array of variations per message type are returned.  If message_type is provided but NOT the messenger, then just all variations for all messengers are returned.
416
+	 * @return array
417
+	 */
418
+	public function get_variations($messenger = '', $message_type = '')
419
+	{
420
+		$messenger_variations = ! empty($messenger) && isset($this->_variations[ $messenger ]) ? $this->_variations[ $messenger ] : array();
421
+
422
+		// message_type provided? IF so, then we've requested a specific set of variations, so we need to make sure we set it as empty if that's not present.
423
+		$variations = !empty($messenger) && !empty($message_type) && isset($messenger_variations[ $message_type ]) ? $messenger_variations[ $message_type ] : array();
424
+
425
+		// now let's account for the possibility we just want all the variations for a messenger (which is indicated by providing the messenger but not the message type).
426
+		$variations = empty($variations) && !empty($messenger) && empty($message_type) ? $messenger_variations : $variations;
427
+
428
+		// filter per template pack and globally.
429
+		$variations = apply_filters('FHEE__' . get_class($this) . '__get_variations', $variations, $messenger, $message_type);
430
+		$variations = apply_filters('FHEE__EE_Messages_Template_Pack__get_variations', $variations, $messenger, $message_type, $this);
431
+
432
+		// prepend the _default_variation, but ONLY if we're returning the fully validated array.
433
+		if (!empty($messenger) && !empty($message_type) && ! empty($variations)) {
434
+			$variations = array( 'default' => $this->get_default_variation_labels($messenger) ) + $variations;
435
+		}
436
+
437
+		return empty($variations) ? array( 'default' => $this->get_default_variation_labels('dft') ) : $variations;
438
+	}
439
+
440
+
441
+
442
+
443
+	/**
444
+	 * This is typically called by EE_messenger objects to get the specific css variation defined for the messenger, message_type and type (i.e. inline, wpeditor, preview etc.)
445
+	 *
446
+	 * @since 4.5.0
447
+	 *
448
+	 * @param string $messenger messenger slug
449
+	 * @param string $message_type message_type slug
450
+	 * @param string $type           variation type (i.e. inline, base, wpeditor, preview etc. //this varies per messenger).
451
+	 * @param string $variation    this should match one of the defined variations in the _variations property on this class.
452
+	 * @param string $file_extension  What type of file the variation file is (defaults to css)
453
+	 * @param bool   $url          if true then return the url otherwise path.
454
+	 * @param bool   $skip_filters This should not be set directly, its used internally to skip filters when the default template pack is called internally as the fallback.
455
+	 *
456
+	 * @return string The variation path or url (typically css reference)
457
+	 */
458
+	public function get_variation($messenger, $message_type, $type, $variation, $url = true, $file_extension = '.css', $skip_filters = false)
459
+	{
460 460
 
461
-        $base = $url ? $this->_base_url : $this->_base_path;
462
-        $base_path = $this->_base_path;
461
+		$base = $url ? $this->_base_url : $this->_base_path;
462
+		$base_path = $this->_base_path;
463 463
 
464
-        if (! $skip_filters) {
465
-            $base =  apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', $base, $messenger, $message_type, $type, $variation, $url, $file_extension, $this);
466
-            $base_path = apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path', $base_path, $messenger, $message_type, $type, $variation, false, $file_extension, $this);
467
-        }
464
+		if (! $skip_filters) {
465
+			$base =  apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', $base, $messenger, $message_type, $type, $variation, $url, $file_extension, $this);
466
+			$base_path = apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path', $base_path, $messenger, $message_type, $type, $variation, false, $file_extension, $this);
467
+		}
468 468
 
469
-        $default_pack = get_class($this) != 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : $this;
470
-
471
-        // possible variation paths considering whether message type is present or not in the file name.
472
-        $path_string = 'variations/' . $messenger . '_' . $message_type . '_'  . $type . '_' . $variation . $file_extension;
473
-        $default_path_string = 'variations/' . $messenger . '_' . $type . '_' . $variation . $file_extension;
474
-
475
-        // first see if fully validated file exists.
476
-        if (is_readable($base_path . $path_string)) {
477
-            $variation_path = $base . $path_string;
478
-        // otherwise see if default exists.
479
-        } elseif (is_readable($base_path . $default_path_string)) {
480
-            $variation_path = $base . $default_path_string;
481
-        } else {
482
-            $variation_path = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_default_variation($messenger, $message_type, $type, $url, $file_extension) : '';
483
-        }
469
+		$default_pack = get_class($this) != 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : $this;
470
+
471
+		// possible variation paths considering whether message type is present or not in the file name.
472
+		$path_string = 'variations/' . $messenger . '_' . $message_type . '_'  . $type . '_' . $variation . $file_extension;
473
+		$default_path_string = 'variations/' . $messenger . '_' . $type . '_' . $variation . $file_extension;
474
+
475
+		// first see if fully validated file exists.
476
+		if (is_readable($base_path . $path_string)) {
477
+			$variation_path = $base . $path_string;
478
+		// otherwise see if default exists.
479
+		} elseif (is_readable($base_path . $default_path_string)) {
480
+			$variation_path = $base . $default_path_string;
481
+		} else {
482
+			$variation_path = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_default_variation($messenger, $message_type, $type, $url, $file_extension) : '';
483
+		}
484 484
 
485
-        if ($skip_filters) {
486
-            return $variation_path;
487
-        }
488
-
489
-        // filter result
490
-        $variation_path = apply_filters('FHEE__' . get_class($this) . '__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url);
491
-        return apply_filters('FHEE__EE_Messages_Template_Pack__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, $this);
492
-    }
493
-
494
-
495
-
496
-
497
-
498
-    /**
499
-     * This method is used to return the wrapper template for the given template pack.  If the given template pack does not include any wrapper templates then the default is used.
500
-     *
501
-     * @param string $messenger What messenger the wrapper is for.
502
-     * @param string $type           What type of wrapper is being returned ( for messengers that may have more than one wrapper )
503
-     *
504
-     * @return string returns the path for the requested wrapper template.
505
-     */
506
-    public function get_wrapper($messenger, $type = 'main')
507
-    {
508
-        $default_pack = get_class($this) !== 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : null;
509
-
510
-        $path_string = $this->_base_path . $messenger . '_' . $type . '_wrapper.template.php';
511
-
512
-        if (is_readable($path_string)) {
513
-            $template = $path_string;
514
-        } else {
515
-            $template = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_wrapper($messenger, $type) : '';
516
-        }
517
-
518
-        // filter
519
-        $template = apply_filters('FHEE__' . get_class($this) . '__get_wrapper', $template, $messenger, $type);
520
-        return apply_filters('FHEE__EE_Messages_Template_Pack__get_wrapper', $template, $messenger, $type, $this);
521
-    }
485
+		if ($skip_filters) {
486
+			return $variation_path;
487
+		}
488
+
489
+		// filter result
490
+		$variation_path = apply_filters('FHEE__' . get_class($this) . '__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url);
491
+		return apply_filters('FHEE__EE_Messages_Template_Pack__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, $this);
492
+	}
493
+
494
+
495
+
496
+
497
+
498
+	/**
499
+	 * This method is used to return the wrapper template for the given template pack.  If the given template pack does not include any wrapper templates then the default is used.
500
+	 *
501
+	 * @param string $messenger What messenger the wrapper is for.
502
+	 * @param string $type           What type of wrapper is being returned ( for messengers that may have more than one wrapper )
503
+	 *
504
+	 * @return string returns the path for the requested wrapper template.
505
+	 */
506
+	public function get_wrapper($messenger, $type = 'main')
507
+	{
508
+		$default_pack = get_class($this) !== 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : null;
509
+
510
+		$path_string = $this->_base_path . $messenger . '_' . $type . '_wrapper.template.php';
511
+
512
+		if (is_readable($path_string)) {
513
+			$template = $path_string;
514
+		} else {
515
+			$template = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_wrapper($messenger, $type) : '';
516
+		}
517
+
518
+		// filter
519
+		$template = apply_filters('FHEE__' . get_class($this) . '__get_wrapper', $template, $messenger, $type);
520
+		return apply_filters('FHEE__EE_Messages_Template_Pack__get_wrapper', $template, $messenger, $type, $this);
521
+	}
522 522
 }
Please login to merge, or discard this patch.
libraries/messages/defaults/EE_Messages_Template_Pack_Default.class.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
         $this->label = esc_html__('Default', 'event_espresso');
17 17
         $this->dbref = 'default';
18 18
         $this->description = esc_html__('This is the default template pack included with Event Espresso core messages system.', 'event_espresso');
19
-        $this->_base_url = EE_PLUGIN_DIR_URL . 'core/libraries/messages/defaults/default/';
20
-        $this->_base_path = EE_LIBRARIES . 'messages/defaults/default/';
19
+        $this->_base_url = EE_PLUGIN_DIR_URL.'core/libraries/messages/defaults/default/';
20
+        $this->_base_path = EE_LIBRARIES.'messages/defaults/default/';
21 21
         $this->_supports = array(
22 22
             'email' => array(
23 23
                 'cancelled_registration', 'declined_registration', 'not_approved_registration', 'pending_approval', 'registration',
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
         $base = $url ? $this->_base_url : $this->_base_path;
64 64
         $base_path = $this->_base_path;
65 65
         // possible variation paths considering whether message type is present or not in the file name.
66
-        $path_string = 'variations/' . $messenger . '_' . $message_type . '_'  . $type . '_default' . $file_extension;
67
-        $default_path_string = 'variations/' . $messenger . '_' . $type . '_default' . $file_extension;
66
+        $path_string = 'variations/'.$messenger.'_'.$message_type.'_'.$type.'_default'.$file_extension;
67
+        $default_path_string = 'variations/'.$messenger.'_'.$type.'_default'.$file_extension;
68 68
         // first see if fully validated file exists.
69
-        if (is_readable($base_path . $path_string)) {
70
-            $variation_path = $base . $path_string;
69
+        if (is_readable($base_path.$path_string)) {
70
+            $variation_path = $base.$path_string;
71 71
         // otherwise see if default exists.
72
-        } elseif (is_readable($base_path . $default_path_string)) {
73
-            $variation_path = $base . $default_path_string;
72
+        } elseif (is_readable($base_path.$default_path_string)) {
73
+            $variation_path = $base.$default_path_string;
74 74
         } else {
75 75
             // no matches found so nothing is present.
76 76
             $variation_path = '';
Please login to merge, or discard this patch.
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -10,71 +10,71 @@
 block discarded – undo
10 10
  */
11 11
 class EE_Messages_Template_Pack_Default extends EE_Messages_Template_Pack
12 12
 {
13
-    public function _set_props()
14
-    {
15
-        $this->label = esc_html__('Default', 'event_espresso');
16
-        $this->dbref = 'default';
17
-        $this->description = esc_html__('This is the default template pack included with Event Espresso core messages system.', 'event_espresso');
18
-        $this->_base_url = EE_PLUGIN_DIR_URL . 'core/libraries/messages/defaults/default/';
19
-        $this->_base_path = EE_LIBRARIES . 'messages/defaults/default/';
20
-        $this->_supports = array(
21
-            'email' => array(
22
-                'cancelled_registration', 'declined_registration', 'not_approved_registration', 'pending_approval', 'registration',
23
-                    'registration_summary',
24
-                'payment_declined', 'payment', 'payment_refund', 'payment_reminder'
25
-                ),
26
-            'html' => array(
27
-                'receipt', 'invoice'
28
-                )
29
-            );
30
-        $this->_default_variation_labels = array(
31
-            'email' => esc_html__('Default', 'event_espresso'),
32
-            'html' =>  esc_html__('Simple', 'event_espresso')
33
-             );
34
-        $this->_variations = array(
35
-            'html' => array(
36
-                'receipt' =>
37
-                    array(
38
-                    'bauhaus' => esc_html__('Bauhaus', 'event_espresso'),
39
-                    'ejs' => esc_html__('Elliot Jay Stocks', 'event_espresso'),
40
-                    'horizon' => esc_html__('Horizon', 'event_espresso'),
41
-                    'lola' => esc_html__('Lola', 'event_espresso'),
42
-                    'tranquility' => esc_html__('Tranquility', 'event_espresso'),
43
-                    'union' => esc_html__('Union', 'event_espresso'),
44
-                    ),
45
-                'invoice' =>
46
-                    array(
47
-                    'bauhaus' => esc_html__('Bauhaus', 'event_espresso'),
48
-                    'ejs' => esc_html__('Elliot Jay Stocks', 'event_espresso'),
49
-                    'horizon' => esc_html__('Horizon', 'event_espresso'),
50
-                    'lola' => esc_html__('Lola', 'event_espresso'),
51
-                    'tranquility' => esc_html__('Tranquility', 'event_espresso'),
52
-                    'union' => esc_html__('Union', 'event_espresso'),
53
-                    )
54
-                )
55
-            );
56
-    }
13
+	public function _set_props()
14
+	{
15
+		$this->label = esc_html__('Default', 'event_espresso');
16
+		$this->dbref = 'default';
17
+		$this->description = esc_html__('This is the default template pack included with Event Espresso core messages system.', 'event_espresso');
18
+		$this->_base_url = EE_PLUGIN_DIR_URL . 'core/libraries/messages/defaults/default/';
19
+		$this->_base_path = EE_LIBRARIES . 'messages/defaults/default/';
20
+		$this->_supports = array(
21
+			'email' => array(
22
+				'cancelled_registration', 'declined_registration', 'not_approved_registration', 'pending_approval', 'registration',
23
+					'registration_summary',
24
+				'payment_declined', 'payment', 'payment_refund', 'payment_reminder'
25
+				),
26
+			'html' => array(
27
+				'receipt', 'invoice'
28
+				)
29
+			);
30
+		$this->_default_variation_labels = array(
31
+			'email' => esc_html__('Default', 'event_espresso'),
32
+			'html' =>  esc_html__('Simple', 'event_espresso')
33
+			 );
34
+		$this->_variations = array(
35
+			'html' => array(
36
+				'receipt' =>
37
+					array(
38
+					'bauhaus' => esc_html__('Bauhaus', 'event_espresso'),
39
+					'ejs' => esc_html__('Elliot Jay Stocks', 'event_espresso'),
40
+					'horizon' => esc_html__('Horizon', 'event_espresso'),
41
+					'lola' => esc_html__('Lola', 'event_espresso'),
42
+					'tranquility' => esc_html__('Tranquility', 'event_espresso'),
43
+					'union' => esc_html__('Union', 'event_espresso'),
44
+					),
45
+				'invoice' =>
46
+					array(
47
+					'bauhaus' => esc_html__('Bauhaus', 'event_espresso'),
48
+					'ejs' => esc_html__('Elliot Jay Stocks', 'event_espresso'),
49
+					'horizon' => esc_html__('Horizon', 'event_espresso'),
50
+					'lola' => esc_html__('Lola', 'event_espresso'),
51
+					'tranquility' => esc_html__('Tranquility', 'event_espresso'),
52
+					'union' => esc_html__('Union', 'event_espresso'),
53
+					)
54
+				)
55
+			);
56
+	}
57 57
 
58 58
 
59 59
 
60
-    public function get_default_variation($messenger, $message_type, $type, $url, $file_extension)
61
-    {
62
-        $base = $url ? $this->_base_url : $this->_base_path;
63
-        $base_path = $this->_base_path;
64
-        // possible variation paths considering whether message type is present or not in the file name.
65
-        $path_string = 'variations/' . $messenger . '_' . $message_type . '_'  . $type . '_default' . $file_extension;
66
-        $default_path_string = 'variations/' . $messenger . '_' . $type . '_default' . $file_extension;
67
-        // first see if fully validated file exists.
68
-        if (is_readable($base_path . $path_string)) {
69
-            $variation_path = $base . $path_string;
70
-        // otherwise see if default exists.
71
-        } elseif (is_readable($base_path . $default_path_string)) {
72
-            $variation_path = $base . $default_path_string;
73
-        } else {
74
-            // no matches found so nothing is present.
75
-            $variation_path = '';
76
-        }
60
+	public function get_default_variation($messenger, $message_type, $type, $url, $file_extension)
61
+	{
62
+		$base = $url ? $this->_base_url : $this->_base_path;
63
+		$base_path = $this->_base_path;
64
+		// possible variation paths considering whether message type is present or not in the file name.
65
+		$path_string = 'variations/' . $messenger . '_' . $message_type . '_'  . $type . '_default' . $file_extension;
66
+		$default_path_string = 'variations/' . $messenger . '_' . $type . '_default' . $file_extension;
67
+		// first see if fully validated file exists.
68
+		if (is_readable($base_path . $path_string)) {
69
+			$variation_path = $base . $path_string;
70
+		// otherwise see if default exists.
71
+		} elseif (is_readable($base_path . $default_path_string)) {
72
+			$variation_path = $base . $default_path_string;
73
+		} else {
74
+			// no matches found so nothing is present.
75
+			$variation_path = '';
76
+		}
77 77
 
78
-        return $variation_path;
79
-    }
78
+		return $variation_path;
79
+	}
80 80
 }
Please login to merge, or discard this patch.
core/libraries/messages/EE_Payment_Base_message_type.lib.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
         $transaction = $registration->transaction();
55 55
 
56 56
         // bail early if no transaction
57
-        if (! $transaction instanceof EE_Transaction) {
57
+        if ( ! $transaction instanceof EE_Transaction) {
58 58
             throw new EE_Error(esc_html__('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso'));
59 59
         }
60 60
 
61
-        $payment = ! empty($id) ? EEM_Payment::instance()->get_one(array( array( 'PAY_ID' => $id, 'TXN_ID' => $transaction->ID() ) )) : 0;
61
+        $payment = ! empty($id) ? EEM_Payment::instance()->get_one(array(array('PAY_ID' => $id, 'TXN_ID' => $transaction->ID()))) : 0;
62 62
 
63
-        return array( $transaction, $payment );
63
+        return array($transaction, $payment);
64 64
     }
65 65
 
66 66
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     protected function _get_admin_content_events_edit_for_messenger(EE_messenger $messenger)
69 69
     {
70 70
         // this is just a test
71
-        return $this->name . ' Message Type for ' . $messenger->name . ' Messenger ';
71
+        return $this->name.' Message Type for '.$messenger->name.' Messenger ';
72 72
     }
73 73
 
74 74
     /**
Please login to merge, or discard this patch.
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -12,67 +12,67 @@
 block discarded – undo
12 12
  */
13 13
 abstract class EE_Payment_Base_message_type extends EE_message_type
14 14
 {
15
-    /**
16
-     * @see parent::get_priority() for documentation.
17
-     * @return int
18
-     */
19
-    public function get_priority()
20
-    {
21
-        return EEM_Message::priority_high;
22
-    }
15
+	/**
16
+	 * @see parent::get_priority() for documentation.
17
+	 * @return int
18
+	 */
19
+	public function get_priority()
20
+	{
21
+		return EEM_Message::priority_high;
22
+	}
23 23
 
24 24
 
25 25
 
26 26
 
27
-    /**
28
-     * see abstract declaration in parent class for details.
29
-     */
30
-    protected function _set_admin_pages()
31
-    {
32
-        $this->admin_registered_pages = array(
33
-            'events_edit' => true
34
-            );
35
-    }
27
+	/**
28
+	 * see abstract declaration in parent class for details.
29
+	 */
30
+	protected function _set_admin_pages()
31
+	{
32
+		$this->admin_registered_pages = array(
33
+			'events_edit' => true
34
+			);
35
+	}
36 36
 
37 37
 
38 38
 
39
-    protected function _set_data_handler()
40
-    {
41
-        $this->_data_handler = 'Gateways';
42
-    }
39
+	protected function _set_data_handler()
40
+	{
41
+		$this->_data_handler = 'Gateways';
42
+	}
43 43
 
44 44
 
45 45
 
46 46
 
47
-    protected function _get_data_for_context($context, EE_Registration $registration, $id)
48
-    {
47
+	protected function _get_data_for_context($context, EE_Registration $registration, $id)
48
+	{
49 49
 
50
-        // use the registration to get the transaction.
51
-        $transaction = $registration->transaction();
50
+		// use the registration to get the transaction.
51
+		$transaction = $registration->transaction();
52 52
 
53
-        // bail early if no transaction
54
-        if (! $transaction instanceof EE_Transaction) {
55
-            throw new EE_Error(esc_html__('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso'));
56
-        }
53
+		// bail early if no transaction
54
+		if (! $transaction instanceof EE_Transaction) {
55
+			throw new EE_Error(esc_html__('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso'));
56
+		}
57 57
 
58
-        $payment = ! empty($id) ? EEM_Payment::instance()->get_one(array( array( 'PAY_ID' => $id, 'TXN_ID' => $transaction->ID() ) )) : 0;
58
+		$payment = ! empty($id) ? EEM_Payment::instance()->get_one(array( array( 'PAY_ID' => $id, 'TXN_ID' => $transaction->ID() ) )) : 0;
59 59
 
60
-        return array( $transaction, $payment );
61
-    }
60
+		return array( $transaction, $payment );
61
+	}
62 62
 
63 63
 
64 64
 
65
-    protected function _get_admin_content_events_edit_for_messenger(EE_messenger $messenger)
66
-    {
67
-        // this is just a test
68
-        return $this->name . ' Message Type for ' . $messenger->name . ' Messenger ';
69
-    }
65
+	protected function _get_admin_content_events_edit_for_messenger(EE_messenger $messenger)
66
+	{
67
+		// this is just a test
68
+		return $this->name . ' Message Type for ' . $messenger->name . ' Messenger ';
69
+	}
70 70
 
71
-    /**
72
-     * This message type doesn't need any settings so we are just setting to empty array.
73
-     */
74
-    protected function _set_admin_settings_fields()
75
-    {
76
-        $this->_admin_settings_fields = array();
77
-    }
71
+	/**
72
+	 * This message type doesn't need any settings so we are just setting to empty array.
73
+	 */
74
+	protected function _set_admin_settings_fields()
75
+	{
76
+		$this->_admin_settings_fields = array();
77
+	}
78 78
 }
Please login to merge, or discard this patch.
core/libraries/messages/EE_Message_Generated_From_Token.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             return $this->_message;
94 94
         }
95 95
         $message = EEM_Message::instance()->get_one_by_token($this->token);
96
-        if (! $message instanceof EE_Message) {
96
+        if ( ! $message instanceof EE_Message) {
97 97
             throw new EE_Error(
98 98
                 sprintf(
99 99
                     esc_html__('Unable to retrieve generated message from DB using given token: "%1$s"', 'event_espresso'),
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
         }
104 104
         $message->set_STS_ID(EEM_Message::status_idle);
105 105
 
106
-        if (! $this->_sending_messenger instanceof EE_messenger) {
106
+        if ( ! $this->_sending_messenger instanceof EE_messenger) {
107 107
             $message->set_STS_ID(EEM_Message::status_failed);
108 108
             $message->set_error_message(
109 109
                 sprintf(
Please login to merge, or discard this patch.
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -11,111 +11,111 @@
 block discarded – undo
11 11
  */
12 12
 class EE_Message_Generated_From_Token extends EE_Message_To_Generate implements EEI_Has_Sending_Messenger
13 13
 {
14
-    /**
15
-     * Sending messenger
16
-     *
17
-     * @type EE_messenger | string
18
-     */
19
-    protected $_sending_messenger = '';
20
-
21
-
22
-    /**
23
-     * Holds the incoming token;
24
-     * @type string
25
-     */
26
-    public $token = '';
27
-
28
-
29
-    /**
30
-     * Constructor
31
-     *
32
-     * @param   string    $sending_messenger_slug     This is used to set what messenger is used to "send"
33
-     *                                                the EE_Message retrieved from the DB via the given token.
34
-     * @param   string $token                         This is a token for a Message that should already exist int the db.
35
-     *                                                This is then used to populate the properties in here.
36
-     * @param   EE_Message_Resource_Manager $message_resource_manager
37
-     */
38
-    public function __construct($token, $sending_messenger_slug, EE_Message_Resource_Manager $message_resource_manager)
39
-    {
40
-        $this->token = $token;
41
-        $this->_sending_messenger = $this->_set_sending_messenger($sending_messenger_slug, $message_resource_manager);
42
-        $this->_message = $this->_generate_message();
43
-        // set params for parent from the message object
44
-        parent::__construct(
45
-            $this->_message->messenger(),
46
-            $this->_message->message_type(),
47
-            array(),
48
-            $this->_message->context(),
49
-            false
50
-        );
51
-    }
52
-
53
-
54
-
55
-    /**
56
-     * @param string                       $sending_messenger_slug
57
-     * @param \EE_Message_Resource_Manager $message_resource_manager
58
-     * @return \EE_messenger | string
59
-     */
60
-    protected function _set_sending_messenger(
61
-        $sending_messenger_slug,
62
-        EE_Message_Resource_Manager $message_resource_manager
63
-    ) {
64
-        $sending_messenger = $message_resource_manager->get_active_messenger($sending_messenger_slug);
65
-        return $sending_messenger instanceof EE_messenger ? $sending_messenger : $sending_messenger_slug;
66
-    }
67
-
68
-
69
-
70
-    /**
71
-     * @return EE_messenger
72
-     */
73
-    public function sending_messenger()
74
-    {
75
-        return $this->_sending_messenger;
76
-    }
77
-
78
-
79
-
80
-    /**
81
-     * generates an EE_Message using the supplied arguments and some defaults
82
-     *
83
-     * @param array $properties
84
-     * @return EE_Message
85
-     * @throws \EE_Error
86
-     */
87
-    protected function _generate_message($properties = array())
88
-    {
89
-        // a message was generated immediately but the parent class will call this again
90
-        if ($this->_message instanceof EE_Message) {
91
-            return $this->_message;
92
-        }
93
-        $message = EEM_Message::instance()->get_one_by_token($this->token);
94
-        if (! $message instanceof EE_Message) {
95
-            throw new EE_Error(
96
-                sprintf(
97
-                    esc_html__('Unable to retrieve generated message from DB using given token: "%1$s"', 'event_espresso'),
98
-                    $this->token
99
-                )
100
-            );
101
-        }
102
-        $message->set_STS_ID(EEM_Message::status_idle);
103
-
104
-        if (! $this->_sending_messenger instanceof EE_messenger) {
105
-            $message->set_STS_ID(EEM_Message::status_failed);
106
-            $message->set_error_message(
107
-                sprintf(
108
-                    esc_html__('Unable to send message because the "%1$s" messenger is not active or not installed', 'event_espresso'),
109
-                    $this->_sending_messenger
110
-                )
111
-            );
112
-        }
113
-
114
-        // set properties
115
-        $this->_valid = true;
116
-        $this->_messenger = $message->messenger_object();
117
-        $this->_message_type = $message->message_type_object();
118
-        $this->_send_now = $message->send_now();
119
-        return $message;
120
-    }
14
+	/**
15
+	 * Sending messenger
16
+	 *
17
+	 * @type EE_messenger | string
18
+	 */
19
+	protected $_sending_messenger = '';
20
+
21
+
22
+	/**
23
+	 * Holds the incoming token;
24
+	 * @type string
25
+	 */
26
+	public $token = '';
27
+
28
+
29
+	/**
30
+	 * Constructor
31
+	 *
32
+	 * @param   string    $sending_messenger_slug     This is used to set what messenger is used to "send"
33
+	 *                                                the EE_Message retrieved from the DB via the given token.
34
+	 * @param   string $token                         This is a token for a Message that should already exist int the db.
35
+	 *                                                This is then used to populate the properties in here.
36
+	 * @param   EE_Message_Resource_Manager $message_resource_manager
37
+	 */
38
+	public function __construct($token, $sending_messenger_slug, EE_Message_Resource_Manager $message_resource_manager)
39
+	{
40
+		$this->token = $token;
41
+		$this->_sending_messenger = $this->_set_sending_messenger($sending_messenger_slug, $message_resource_manager);
42
+		$this->_message = $this->_generate_message();
43
+		// set params for parent from the message object
44
+		parent::__construct(
45
+			$this->_message->messenger(),
46
+			$this->_message->message_type(),
47
+			array(),
48
+			$this->_message->context(),
49
+			false
50
+		);
51
+	}
52
+
53
+
54
+
55
+	/**
56
+	 * @param string                       $sending_messenger_slug
57
+	 * @param \EE_Message_Resource_Manager $message_resource_manager
58
+	 * @return \EE_messenger | string
59
+	 */
60
+	protected function _set_sending_messenger(
61
+		$sending_messenger_slug,
62
+		EE_Message_Resource_Manager $message_resource_manager
63
+	) {
64
+		$sending_messenger = $message_resource_manager->get_active_messenger($sending_messenger_slug);
65
+		return $sending_messenger instanceof EE_messenger ? $sending_messenger : $sending_messenger_slug;
66
+	}
67
+
68
+
69
+
70
+	/**
71
+	 * @return EE_messenger
72
+	 */
73
+	public function sending_messenger()
74
+	{
75
+		return $this->_sending_messenger;
76
+	}
77
+
78
+
79
+
80
+	/**
81
+	 * generates an EE_Message using the supplied arguments and some defaults
82
+	 *
83
+	 * @param array $properties
84
+	 * @return EE_Message
85
+	 * @throws \EE_Error
86
+	 */
87
+	protected function _generate_message($properties = array())
88
+	{
89
+		// a message was generated immediately but the parent class will call this again
90
+		if ($this->_message instanceof EE_Message) {
91
+			return $this->_message;
92
+		}
93
+		$message = EEM_Message::instance()->get_one_by_token($this->token);
94
+		if (! $message instanceof EE_Message) {
95
+			throw new EE_Error(
96
+				sprintf(
97
+					esc_html__('Unable to retrieve generated message from DB using given token: "%1$s"', 'event_espresso'),
98
+					$this->token
99
+				)
100
+			);
101
+		}
102
+		$message->set_STS_ID(EEM_Message::status_idle);
103
+
104
+		if (! $this->_sending_messenger instanceof EE_messenger) {
105
+			$message->set_STS_ID(EEM_Message::status_failed);
106
+			$message->set_error_message(
107
+				sprintf(
108
+					esc_html__('Unable to send message because the "%1$s" messenger is not active or not installed', 'event_espresso'),
109
+					$this->_sending_messenger
110
+				)
111
+			);
112
+		}
113
+
114
+		// set properties
115
+		$this->_valid = true;
116
+		$this->_messenger = $message->messenger_object();
117
+		$this->_message_type = $message->message_type_object();
118
+		$this->_send_now = $message->send_now();
119
+		return $message;
120
+	}
121 121
 }
Please login to merge, or discard this patch.
core/libraries/messages/EE_Registration_Base_message_type.lib.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     protected function _get_admin_content_events_edit_for_messenger(EE_messenger $messenger)
37 37
     {
38 38
         // this is just a test
39
-        return $this->name . ' Message Type for ' . $messenger->name . ' Messenger ';
39
+        return $this->name.' Message Type for '.$messenger->name.' Messenger ';
40 40
     }
41 41
 
42 42
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
                     if (isset($data_type[1]) && $data_type[1] instanceof EE_Registration) {
56 56
                         $regs = $data_type;
57 57
                     } else {
58
-                        $regs = is_array($data_type[0]) ? $data_type[0] : array( $maybe_reg );
58
+                        $regs = is_array($data_type[0]) ? $data_type[0] : array($maybe_reg);
59 59
                     }
60 60
 
61 61
                     foreach ($regs as $reg) {
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                             $this->_regs_for_sending[] = $reg->ID();
64 64
                         }
65 65
                     }
66
-                    $this->_data = isset($this->_data[1]) ? array( $maybe_reg->transaction(), null, $this->_data[1] ) : array( $maybe_reg->transaction() );
66
+                    $this->_data = isset($this->_data[1]) ? array($maybe_reg->transaction(), null, $this->_data[1]) : array($maybe_reg->transaction());
67 67
                     $this->_data_handler = 'Gateways';
68 68
                 } else {
69 69
                     $this->_data_handler = 'Gateways';
@@ -82,17 +82,17 @@  discard block
 block discarded – undo
82 82
 
83 83
     protected function _get_data_for_context($context, EE_Registration $registration, $id)
84 84
     {
85
-        if ($context  == 'admin') {
85
+        if ($context == 'admin') {
86 86
             // use the registration to get the transaction.
87 87
             $transaction = $registration->transaction();
88 88
 
89 89
             // bail early if no transaction
90
-            if (! $transaction instanceof EE_Transaction) {
90
+            if ( ! $transaction instanceof EE_Transaction) {
91 91
                 throw new EE_Error(esc_html__('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso'));
92 92
             }
93 93
 
94
-            $payment = !empty($id) ? EEM_Payment::instance()->get_one(array( array( 'PAY_ID' => $id, 'TXN_ID' => $transaction->ID() ) )) : 0;
95
-            return array( $transaction, $payment );
94
+            $payment = ! empty($id) ? EEM_Payment::instance()->get_one(array(array('PAY_ID' => $id, 'TXN_ID' => $transaction->ID()))) : 0;
95
+            return array($transaction, $payment);
96 96
         } else {
97 97
             return $registration;
98 98
         }
Please login to merge, or discard this patch.
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -12,126 +12,126 @@
 block discarded – undo
12 12
  */
13 13
 abstract class EE_Registration_Base_message_type extends EE_message_type
14 14
 {
15
-    /**
16
-     * @see parent::get_priority() for documentation.
17
-     * @return int
18
-     */
19
-    public function get_priority()
20
-    {
21
-        return EEM_Message::priority_medium;
22
-    }
23
-
24
-
25
-
26
-    protected function _set_admin_pages()
27
-    {
28
-        $this->admin_registered_pages = array(
29
-            'events_edit' => true
30
-            );
31
-    }
32
-
33
-
34
-    protected function _get_admin_content_events_edit_for_messenger(EE_messenger $messenger)
35
-    {
36
-        // this is just a test
37
-        return $this->name . ' Message Type for ' . $messenger->name . ' Messenger ';
38
-    }
39
-
40
-
41
-
42
-
43
-    protected function _set_data_handler()
44
-    {
45
-        if (is_array($this->_data)) {
46
-            $data_type = reset($this->_data);
47
-
48
-            if (is_array($data_type)) {
49
-                // grab the first item and see if its a registration.
50
-                $maybe_reg = isset($data_type[0]) && is_array($data_type[0]) ? reset($data_type[0]) : reset($data_type);
51
-                if ($maybe_reg instanceof EE_Registration) {
52
-                    // is $data_type itself just an array of registrations?
53
-                    if (isset($data_type[1]) && $data_type[1] instanceof EE_Registration) {
54
-                        $regs = $data_type;
55
-                    } else {
56
-                        $regs = is_array($data_type[0]) ? $data_type[0] : array( $maybe_reg );
57
-                    }
58
-
59
-                    foreach ($regs as $reg) {
60
-                        if ($reg instanceof EE_Registration) {
61
-                            $this->_regs_for_sending[] = $reg->ID();
62
-                        }
63
-                    }
64
-                    $this->_data = isset($this->_data[1]) ? array( $maybe_reg->transaction(), null, $this->_data[1] ) : array( $maybe_reg->transaction() );
65
-                    $this->_data_handler = 'Gateways';
66
-                } else {
67
-                    $this->_data_handler = 'Gateways';
68
-                }
69
-            } else {
70
-                $this->_data_handler = $data_type instanceof EE_Registration ? 'REG' : 'Gateways';
71
-            }
72
-        } else {
73
-            $this->_data_handler = $this->_data instanceof EE_Registration ? 'REG' : 'Gateways';
74
-        }
75
-
76
-        $this->_single_message = $this->_data_handler == 'REG' ? true : false;
77
-    }
78
-
79
-
80
-
81
-    protected function _get_data_for_context($context, EE_Registration $registration, $id)
82
-    {
83
-        if ($context  == 'admin') {
84
-            // use the registration to get the transaction.
85
-            $transaction = $registration->transaction();
86
-
87
-            // bail early if no transaction
88
-            if (! $transaction instanceof EE_Transaction) {
89
-                throw new EE_Error(esc_html__('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso'));
90
-            }
91
-
92
-            $payment = !empty($id) ? EEM_Payment::instance()->get_one(array( array( 'PAY_ID' => $id, 'TXN_ID' => $transaction->ID() ) )) : 0;
93
-            return array( $transaction, $payment );
94
-        } else {
95
-            return $registration;
96
-        }
97
-    }
98
-
99
-
100
-
101
-    /**
102
-     * Setup admin settings for this message type.
103
-     */
104
-    protected function _set_admin_settings_fields()
105
-    {
106
-        $this->_admin_settings_fields = array();
107
-    }
108
-
109
-
110
-
111
-
112
-
113
-    /**
114
-     * returns an array of addressee objects for event_admins
115
-     *
116
-     * @access protected
117
-     * @return array array of EE_Messages_Addressee objects
118
-     */
119
-    protected function _admin_addressees()
120
-    {
121
-        if ($this->_single_message) {
122
-            return array();
123
-        }
124
-        return parent::_admin_addressees();
125
-    }
126
-
127
-
128
-
129
-    protected function _primary_attendee_addressees()
130
-    {
131
-        if ($this->_single_message) {
132
-            return array();
133
-        }
134
-
135
-        return parent::_primary_attendee_addressees();
136
-    }
15
+	/**
16
+	 * @see parent::get_priority() for documentation.
17
+	 * @return int
18
+	 */
19
+	public function get_priority()
20
+	{
21
+		return EEM_Message::priority_medium;
22
+	}
23
+
24
+
25
+
26
+	protected function _set_admin_pages()
27
+	{
28
+		$this->admin_registered_pages = array(
29
+			'events_edit' => true
30
+			);
31
+	}
32
+
33
+
34
+	protected function _get_admin_content_events_edit_for_messenger(EE_messenger $messenger)
35
+	{
36
+		// this is just a test
37
+		return $this->name . ' Message Type for ' . $messenger->name . ' Messenger ';
38
+	}
39
+
40
+
41
+
42
+
43
+	protected function _set_data_handler()
44
+	{
45
+		if (is_array($this->_data)) {
46
+			$data_type = reset($this->_data);
47
+
48
+			if (is_array($data_type)) {
49
+				// grab the first item and see if its a registration.
50
+				$maybe_reg = isset($data_type[0]) && is_array($data_type[0]) ? reset($data_type[0]) : reset($data_type);
51
+				if ($maybe_reg instanceof EE_Registration) {
52
+					// is $data_type itself just an array of registrations?
53
+					if (isset($data_type[1]) && $data_type[1] instanceof EE_Registration) {
54
+						$regs = $data_type;
55
+					} else {
56
+						$regs = is_array($data_type[0]) ? $data_type[0] : array( $maybe_reg );
57
+					}
58
+
59
+					foreach ($regs as $reg) {
60
+						if ($reg instanceof EE_Registration) {
61
+							$this->_regs_for_sending[] = $reg->ID();
62
+						}
63
+					}
64
+					$this->_data = isset($this->_data[1]) ? array( $maybe_reg->transaction(), null, $this->_data[1] ) : array( $maybe_reg->transaction() );
65
+					$this->_data_handler = 'Gateways';
66
+				} else {
67
+					$this->_data_handler = 'Gateways';
68
+				}
69
+			} else {
70
+				$this->_data_handler = $data_type instanceof EE_Registration ? 'REG' : 'Gateways';
71
+			}
72
+		} else {
73
+			$this->_data_handler = $this->_data instanceof EE_Registration ? 'REG' : 'Gateways';
74
+		}
75
+
76
+		$this->_single_message = $this->_data_handler == 'REG' ? true : false;
77
+	}
78
+
79
+
80
+
81
+	protected function _get_data_for_context($context, EE_Registration $registration, $id)
82
+	{
83
+		if ($context  == 'admin') {
84
+			// use the registration to get the transaction.
85
+			$transaction = $registration->transaction();
86
+
87
+			// bail early if no transaction
88
+			if (! $transaction instanceof EE_Transaction) {
89
+				throw new EE_Error(esc_html__('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso'));
90
+			}
91
+
92
+			$payment = !empty($id) ? EEM_Payment::instance()->get_one(array( array( 'PAY_ID' => $id, 'TXN_ID' => $transaction->ID() ) )) : 0;
93
+			return array( $transaction, $payment );
94
+		} else {
95
+			return $registration;
96
+		}
97
+	}
98
+
99
+
100
+
101
+	/**
102
+	 * Setup admin settings for this message type.
103
+	 */
104
+	protected function _set_admin_settings_fields()
105
+	{
106
+		$this->_admin_settings_fields = array();
107
+	}
108
+
109
+
110
+
111
+
112
+
113
+	/**
114
+	 * returns an array of addressee objects for event_admins
115
+	 *
116
+	 * @access protected
117
+	 * @return array array of EE_Messages_Addressee objects
118
+	 */
119
+	protected function _admin_addressees()
120
+	{
121
+		if ($this->_single_message) {
122
+			return array();
123
+		}
124
+		return parent::_admin_addressees();
125
+	}
126
+
127
+
128
+
129
+	protected function _primary_attendee_addressees()
130
+	{
131
+		if ($this->_single_message) {
132
+			return array();
133
+		}
134
+
135
+		return parent::_primary_attendee_addressees();
136
+	}
137 137
 }
Please login to merge, or discard this patch.
core/libraries/qtips/EE_Qtip_Config.lib.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@
 block discarded – undo
207 207
     {
208 208
         foreach ($this->_qtipsa as $qt) {
209 209
             // make sure we have what we need.
210
-            if (! isset($qt['content_id']) || ! isset($qt['target']) || ! isset($qt['content'])) {
210
+            if ( ! isset($qt['content_id']) || ! isset($qt['target']) || ! isset($qt['content'])) {
211 211
                 throw new EE_Error(
212 212
                     sprintf(
213 213
                         esc_html__(
Please login to merge, or discard this patch.
Indentation   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -14,235 +14,235 @@  discard block
 block discarded – undo
14 14
  */
15 15
 abstract class EE_Qtip_Config extends EE_Base
16 16
 {
17
-    /**
18
-     * This will hold the qtips setup array (setup by children)
19
-     *
20
-     * @access protected
21
-     * @var array
22
-     */
23
-    protected $_qtipsa;
17
+	/**
18
+	 * This will hold the qtips setup array (setup by children)
19
+	 *
20
+	 * @access protected
21
+	 * @var array
22
+	 */
23
+	protected $_qtipsa;
24 24
 
25 25
 
26
-    /**
27
-     * This holds the constructed EE_Qtip objects
28
-     *
29
-     * @access protected
30
-     * @var EE_Qtip
31
-     */
32
-    protected $_qtips;
26
+	/**
27
+	 * This holds the constructed EE_Qtip objects
28
+	 *
29
+	 * @access protected
30
+	 * @var EE_Qtip
31
+	 */
32
+	protected $_qtips;
33 33
 
34 34
 
35
-    /**
36
-     * an array of default options for instantiated qtip js objects
37
-     *
38
-     * @access protected
39
-     * @var array
40
-     */
41
-    protected $_default_options;
35
+	/**
36
+	 * an array of default options for instantiated qtip js objects
37
+	 *
38
+	 * @access protected
39
+	 * @var array
40
+	 */
41
+	protected $_default_options;
42 42
 
43 43
 
44
-    /**
45
-     * constructor
46
-     *
47
-     * @access public
48
-     */
49
-    public function __construct()
50
-    {
51
-        $this->_qtipsa = $this->_qtips = array();
52
-        $this->_set_default_options();
53
-        $this->_set_tips_array();
54
-        $this->_construct_tips();
55
-    }
44
+	/**
45
+	 * constructor
46
+	 *
47
+	 * @access public
48
+	 */
49
+	public function __construct()
50
+	{
51
+		$this->_qtipsa = $this->_qtips = array();
52
+		$this->_set_default_options();
53
+		$this->_set_tips_array();
54
+		$this->_construct_tips();
55
+	}
56 56
 
57 57
 
58
-    /**
59
-     * Children define this method and its purpose is to setup the $_qtipsa property.  The format of this property is:
60
-     *
61
-     * $qtipsa = array(
62
-     *        0 => array(
63
-     *            'content_id' => 'some_unique_id_for_referencing_content', //just the string
64
-     *            'content' => 'html/text content for the qtip',
65
-     *            'target' => '#target-element', //use the same schema as jQuery selectors.  This will match what the
66
-     *            target is for the qTip in the dom (i.e. if class then '.some-class').
67
-     *            'options' => array() //use this to override any of the default options for this specific qtip.
68
-     *        )
69
-     * );
70
-     *
71
-     * @abstract
72
-     * @access protected
73
-     * @return void
74
-     */
75
-    abstract protected function _set_tips_array();
58
+	/**
59
+	 * Children define this method and its purpose is to setup the $_qtipsa property.  The format of this property is:
60
+	 *
61
+	 * $qtipsa = array(
62
+	 *        0 => array(
63
+	 *            'content_id' => 'some_unique_id_for_referencing_content', //just the string
64
+	 *            'content' => 'html/text content for the qtip',
65
+	 *            'target' => '#target-element', //use the same schema as jQuery selectors.  This will match what the
66
+	 *            target is for the qTip in the dom (i.e. if class then '.some-class').
67
+	 *            'options' => array() //use this to override any of the default options for this specific qtip.
68
+	 *        )
69
+	 * );
70
+	 *
71
+	 * @abstract
72
+	 * @access protected
73
+	 * @return void
74
+	 */
75
+	abstract protected function _set_tips_array();
76 76
 
77 77
 
78
-    /**
79
-     * all the default options for the qtip js are defined here.  Children class can override the defaults for all the
80
-     * qtips defined in their config OR just leave it and have the parent default options apply.
81
-     *
82
-     * commented out options are there for reference so you know which can be defined by the child.
83
-     *
84
-     * Note: children do NOT have to define all these options.  Just define the ones to override.
85
-     *
86
-     * @link   http://qtip2.com/options
87
-     *
88
-     * @access protected
89
-     * @return void
90
-     */
91
-    protected function _set_default_options()
92
-    {
93
-        $this->_default_options = array(
94
-            // 'id' => 'unique_id_referncing_qtip_instance',
95
-            'prerender'      => false,
96
-            // increases page load if true,
97
-            'suppress'       => true,
98
-            // whether default browser tooltips are suppressed.
99
-            'content'        => array(
100
-                'button' => false,
101
-                // what you want for the close button text/link.
102
-                'title'  => true,
103
-                // Options: "string", true.  If TRUE then the title attribute of the target will be used (if available). If "string" then we'll use that as the title.
104
-                'clone'  => true,
105
-                // Options: true|false.  if true then the text will be cloned from the content instead of removed from the dom.
106
-            ),
107
-            'show_only_once' => false,
108
-            // this is NOT a qtip2 library option, but is something added for EE specific use.  If set to true, this means that this particular tooltip will only show ONCE for the user and then a cookie will be saved so that it doesn't show again (after exit).
109
-            'position'       => array(
110
-                'my'        => 'top left',
111
-                // top left || top center || top right || right top || right center || right bottom || bottom right || bottom center || bottom left || left bottom || left center || left top
112
-                'at'        => 'bottom right',
113
-                // same options as above.
114
-                'target'    => 'event',
115
-                // if u use jQuery::#selector, js will parse to a jQuery selector || 'mouse' (at mouse cursor position) || 'event' (position at target that triggered the tooltip), or an array containing an absolute x/y position on page.
116
-                'container' => false,
117
-                // what HTML element the tooltip is appended to (it's containing element). jquery object.  Use 'jQuery::#selector' and js will parse'
118
-                'viewport'  => true,
119
-                // @link http://qtip2.com/plugins#viewport
120
-                'adjust'    => array(
121
-                    'x'      => 0,
122
-                    // adjust position on x axis by 0 pixels.
123
-                    'y'      => 0,
124
-                    // adjust position on y axis by 0 pixels.
125
-                    'mouse'  => true,
126
-                    // when position['target'] is set to 'mouse', tooltip will follow mouse when hovering over the target.  False, stops following.
127
-                    'resize' => true,
128
-                    // adjust tooltip position when window is resized.
129
-                    'scroll' => true,
130
-                    // position of tooltip adjusted when window (or position.container) is scrolled.
131
-                    'method' => 'flipinvert',
132
-                    // @link http://qtip2.com/plugins#viewport
133
-                ),
134
-            ),
135
-            'show'           => array(
136
-                'event'  => 'mouseenter',
137
-                // what event triggers tooltip to be shown.  Any jQuery standard event or custom events can be used. space separated events provide multiple triggers.
138
-                'target' => false,
139
-                // options jQuery::#selector|false.  Used to indicate which html element will trigger show event.  When false, the element the qtip() method was called upon is used.
140
-                'delay'  => 90,
141
-                // time in millisecons by which to delay showing of tooltip.
142
-                'solo'   => false,
143
-                // determines whether tooltip will hid all others when triggered. Options: true (hide all) || false (ignore) || string (parent selector for which qtips get hidden)
144
-                'modal'  => array(
145
-                    'on'         => false, // does tooltip trigger modal?
146
-                    'blur'       => true, // does clicking on the dimmed background hide the tooltip and remove the dim?
147
-                    'escape'     => true, // hitting escape key hide the tooltip and cancel modal
148
-                    'stealfocus' => true, // can users focus on inputs and elelments outside of tooltip when modal on?
149
-                ),
150
-            ),
151
-            'hide'           => array(
152
-                'event'    => 'mouseleave',
153
-                // similar as what you do for show.event.
154
-                'target'   => false,
155
-                // Options jQuery::#selector. which html element will trigger hide event. When false, the element the .qtip() method was called upon is used.
156
-                'delay'    => 0,
157
-                // set time in milliseconds for delaying the hide of the tooltip
158
-                'inactive' => false,
159
-                // if integer, time in millisecons in which the tooltip should be hidden if remains inactive (not interacted with)
160
-                'fixed'    => false,
161
-                // when set to true, the tooltip will not hide if moused over.
162
-                'leave'    => 'window',
163
-                // specify whether the tooltip will hide when leaving the window it's conained within.
164
-                'distance' => false,
165
-                // if integer, distance in pixels that the tooltip hides when the mouse is moved from the point it triggered the tooltip.
166
-            ),
167
-            'style'          => array(
168
-                'classes' => 'qtip-tipsy',
169
-                // Options "string", false.  A space separated string containing all class names which should be added ot the main qTip element. See options for styles in comment block at end of this class.
170
-                'def'     => true,
171
-                // set to false and the default qtip class does not get applied
172
-                'widget'  => false,
173
-                // whether ui-widget classes of the themeroller UI styles are applied to tooltip.
174
-                'width'   => false,
175
-                // Options: "string", integer, false.  with this you can override all applied CSS width styles for tooltip.  Can be any valid width CSS value. (does not override min/max width styles)
176
-                'height'  => false,
177
-                // same as above except applies to height.
178
-                'tip'     => array(
179
-                    'corner' => true,
180
-                    // where in relation to the tooltip the speech bubble tip is applied. Options: true, "corner string" (see position), false.  true inherits
181
-                    'mimic'  => false,
182
-                    // see documentation @link http://qtip2.com/plugins#tips
183
-                    'border' => true,
184
-                    // Options: true, integer. determines the width of the border that surrounds the tip element.  True inherits from tooltip.
185
-                    'width'  => 6,
186
-                    // width of rendered tip in pixels in relation to the side of the tooltip the tip is on.
187
-                    'height' => 6,
188
-                    // works the same as tip.width
189
-                    'offset' => 0,
190
-                    // use to set the offset of the tip in relation to its corner position.
191
-                ),
192
-            ),
78
+	/**
79
+	 * all the default options for the qtip js are defined here.  Children class can override the defaults for all the
80
+	 * qtips defined in their config OR just leave it and have the parent default options apply.
81
+	 *
82
+	 * commented out options are there for reference so you know which can be defined by the child.
83
+	 *
84
+	 * Note: children do NOT have to define all these options.  Just define the ones to override.
85
+	 *
86
+	 * @link   http://qtip2.com/options
87
+	 *
88
+	 * @access protected
89
+	 * @return void
90
+	 */
91
+	protected function _set_default_options()
92
+	{
93
+		$this->_default_options = array(
94
+			// 'id' => 'unique_id_referncing_qtip_instance',
95
+			'prerender'      => false,
96
+			// increases page load if true,
97
+			'suppress'       => true,
98
+			// whether default browser tooltips are suppressed.
99
+			'content'        => array(
100
+				'button' => false,
101
+				// what you want for the close button text/link.
102
+				'title'  => true,
103
+				// Options: "string", true.  If TRUE then the title attribute of the target will be used (if available). If "string" then we'll use that as the title.
104
+				'clone'  => true,
105
+				// Options: true|false.  if true then the text will be cloned from the content instead of removed from the dom.
106
+			),
107
+			'show_only_once' => false,
108
+			// this is NOT a qtip2 library option, but is something added for EE specific use.  If set to true, this means that this particular tooltip will only show ONCE for the user and then a cookie will be saved so that it doesn't show again (after exit).
109
+			'position'       => array(
110
+				'my'        => 'top left',
111
+				// top left || top center || top right || right top || right center || right bottom || bottom right || bottom center || bottom left || left bottom || left center || left top
112
+				'at'        => 'bottom right',
113
+				// same options as above.
114
+				'target'    => 'event',
115
+				// if u use jQuery::#selector, js will parse to a jQuery selector || 'mouse' (at mouse cursor position) || 'event' (position at target that triggered the tooltip), or an array containing an absolute x/y position on page.
116
+				'container' => false,
117
+				// what HTML element the tooltip is appended to (it's containing element). jquery object.  Use 'jQuery::#selector' and js will parse'
118
+				'viewport'  => true,
119
+				// @link http://qtip2.com/plugins#viewport
120
+				'adjust'    => array(
121
+					'x'      => 0,
122
+					// adjust position on x axis by 0 pixels.
123
+					'y'      => 0,
124
+					// adjust position on y axis by 0 pixels.
125
+					'mouse'  => true,
126
+					// when position['target'] is set to 'mouse', tooltip will follow mouse when hovering over the target.  False, stops following.
127
+					'resize' => true,
128
+					// adjust tooltip position when window is resized.
129
+					'scroll' => true,
130
+					// position of tooltip adjusted when window (or position.container) is scrolled.
131
+					'method' => 'flipinvert',
132
+					// @link http://qtip2.com/plugins#viewport
133
+				),
134
+			),
135
+			'show'           => array(
136
+				'event'  => 'mouseenter',
137
+				// what event triggers tooltip to be shown.  Any jQuery standard event or custom events can be used. space separated events provide multiple triggers.
138
+				'target' => false,
139
+				// options jQuery::#selector|false.  Used to indicate which html element will trigger show event.  When false, the element the qtip() method was called upon is used.
140
+				'delay'  => 90,
141
+				// time in millisecons by which to delay showing of tooltip.
142
+				'solo'   => false,
143
+				// determines whether tooltip will hid all others when triggered. Options: true (hide all) || false (ignore) || string (parent selector for which qtips get hidden)
144
+				'modal'  => array(
145
+					'on'         => false, // does tooltip trigger modal?
146
+					'blur'       => true, // does clicking on the dimmed background hide the tooltip and remove the dim?
147
+					'escape'     => true, // hitting escape key hide the tooltip and cancel modal
148
+					'stealfocus' => true, // can users focus on inputs and elelments outside of tooltip when modal on?
149
+				),
150
+			),
151
+			'hide'           => array(
152
+				'event'    => 'mouseleave',
153
+				// similar as what you do for show.event.
154
+				'target'   => false,
155
+				// Options jQuery::#selector. which html element will trigger hide event. When false, the element the .qtip() method was called upon is used.
156
+				'delay'    => 0,
157
+				// set time in milliseconds for delaying the hide of the tooltip
158
+				'inactive' => false,
159
+				// if integer, time in millisecons in which the tooltip should be hidden if remains inactive (not interacted with)
160
+				'fixed'    => false,
161
+				// when set to true, the tooltip will not hide if moused over.
162
+				'leave'    => 'window',
163
+				// specify whether the tooltip will hide when leaving the window it's conained within.
164
+				'distance' => false,
165
+				// if integer, distance in pixels that the tooltip hides when the mouse is moved from the point it triggered the tooltip.
166
+			),
167
+			'style'          => array(
168
+				'classes' => 'qtip-tipsy',
169
+				// Options "string", false.  A space separated string containing all class names which should be added ot the main qTip element. See options for styles in comment block at end of this class.
170
+				'def'     => true,
171
+				// set to false and the default qtip class does not get applied
172
+				'widget'  => false,
173
+				// whether ui-widget classes of the themeroller UI styles are applied to tooltip.
174
+				'width'   => false,
175
+				// Options: "string", integer, false.  with this you can override all applied CSS width styles for tooltip.  Can be any valid width CSS value. (does not override min/max width styles)
176
+				'height'  => false,
177
+				// same as above except applies to height.
178
+				'tip'     => array(
179
+					'corner' => true,
180
+					// where in relation to the tooltip the speech bubble tip is applied. Options: true, "corner string" (see position), false.  true inherits
181
+					'mimic'  => false,
182
+					// see documentation @link http://qtip2.com/plugins#tips
183
+					'border' => true,
184
+					// Options: true, integer. determines the width of the border that surrounds the tip element.  True inherits from tooltip.
185
+					'width'  => 6,
186
+					// width of rendered tip in pixels in relation to the side of the tooltip the tip is on.
187
+					'height' => 6,
188
+					// works the same as tip.width
189
+					'offset' => 0,
190
+					// use to set the offset of the tip in relation to its corner position.
191
+				),
192
+			),
193 193
 
194
-        );
195
-    }
194
+		);
195
+	}
196 196
 
197 197
 
198
-    /**
199
-     * This takes the set $_qtipsa array property and loops through it to set the EE_Qtip objects and assign them to
200
-     * the $_qtips property
201
-     *
202
-     * @access protected
203
-     * @return void
204
-     */
205
-    protected function _construct_tips()
206
-    {
207
-        foreach ($this->_qtipsa as $qt) {
208
-            // make sure we have what we need.
209
-            if (! isset($qt['content_id']) || ! isset($qt['target']) || ! isset($qt['content'])) {
210
-                throw new EE_Error(
211
-                    sprintf(
212
-                        esc_html__(
213
-                            'There is something wrong with the _qtipsa property setup for the %s qtip config class.  The dump of the current array index is: %s.<br /><br />Please check that it is setup correctly.',
214
-                            'event_espresso'
215
-                        ),
216
-                        get_class($this),
217
-                        var_export($qt, true)
218
-                    )
219
-                );
220
-            }
198
+	/**
199
+	 * This takes the set $_qtipsa array property and loops through it to set the EE_Qtip objects and assign them to
200
+	 * the $_qtips property
201
+	 *
202
+	 * @access protected
203
+	 * @return void
204
+	 */
205
+	protected function _construct_tips()
206
+	{
207
+		foreach ($this->_qtipsa as $qt) {
208
+			// make sure we have what we need.
209
+			if (! isset($qt['content_id']) || ! isset($qt['target']) || ! isset($qt['content'])) {
210
+				throw new EE_Error(
211
+					sprintf(
212
+						esc_html__(
213
+							'There is something wrong with the _qtipsa property setup for the %s qtip config class.  The dump of the current array index is: %s.<br /><br />Please check that it is setup correctly.',
214
+							'event_espresso'
215
+						),
216
+						get_class($this),
217
+						var_export($qt, true)
218
+					)
219
+				);
220
+			}
221 221
 
222
-            // make sure the options include defaults and just override via set config.
223
-            $options_override = isset($qt['options']) ? (array) $qt['options'] : array();
224
-            $options = array_merge($this->_default_options, $options_override);
225
-            $setup = array(
226
-                'content_id' => $qt['content_id'],
227
-                'options'    => $options,
228
-                'target'     => $qt['target'],
229
-                'content'    => $qt['content'],
230
-            );
231
-            $this->_qtips[] = new EE_Qtip($setup);
232
-        }
233
-    }
222
+			// make sure the options include defaults and just override via set config.
223
+			$options_override = isset($qt['options']) ? (array) $qt['options'] : array();
224
+			$options = array_merge($this->_default_options, $options_override);
225
+			$setup = array(
226
+				'content_id' => $qt['content_id'],
227
+				'options'    => $options,
228
+				'target'     => $qt['target'],
229
+				'content'    => $qt['content'],
230
+			);
231
+			$this->_qtips[] = new EE_Qtip($setup);
232
+		}
233
+	}
234 234
 
235 235
 
236
-    /**
237
-     * return the _qtips property contents
238
-     *
239
-     * @access public
240
-     * @return EE_Qtip[]
241
-     */
242
-    public function get_tips()
243
-    {
244
-        return $this->_qtips;
245
-    }
236
+	/**
237
+	 * return the _qtips property contents
238
+	 *
239
+	 * @access public
240
+	 * @return EE_Qtip[]
241
+	 */
242
+	public function get_tips()
243
+	{
244
+		return $this->_qtips;
245
+	}
246 246
 }
247 247
 
248 248
 // class names you can use for tooltip styles
@@ -294,17 +294,17 @@  discard block
 block discarded – undo
294 294
  */
295 295
 class EE_Qtip extends EE_Base
296 296
 {
297
-    public $content_id;
298
-    public $options;
299
-    public $target;
300
-    public $content;
297
+	public $content_id;
298
+	public $options;
299
+	public $target;
300
+	public $content;
301 301
 
302
-    public function __construct($setup_array)
303
-    {
304
-        foreach ($setup_array as $prop => $value) {
305
-            if (EEH_Class_Tools::has_property($this, $prop)) {
306
-                $this->{$prop} = $value;
307
-            }
308
-        }
309
-    }
302
+	public function __construct($setup_array)
303
+	{
304
+		foreach ($setup_array as $prop => $value) {
305
+			if (EEH_Class_Tools::has_property($this, $prop)) {
306
+				$this->{$prop} = $value;
307
+			}
308
+		}
309
+	}
310 310
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/db/EEME_Base.lib.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function __construct()
73 73
     {
74
-        if (! $this->_model_name_extended) {
74
+        if ( ! $this->_model_name_extended) {
75 75
             throw new EE_Error(
76 76
                 esc_html__(
77 77
                     "When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'",
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                 )
80 80
             );
81 81
         }
82
-        $construct_end_action = 'AHEE__EEM_' . $this->_model_name_extended . '__construct__end';
82
+        $construct_end_action = 'AHEE__EEM_'.$this->_model_name_extended.'__construct__end';
83 83
         if (did_action($construct_end_action)) {
84 84
             throw new EE_Error(
85 85
                 sprintf(
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
             );
95 95
         }
96 96
         add_filter(
97
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__tables',
97
+            'FHEE__EEM_'.$this->_model_name_extended.'__construct__tables',
98 98
             array($this, 'add_extra_tables_on_filter')
99 99
         );
100 100
         add_filter(
101
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__fields',
101
+            'FHEE__EEM_'.$this->_model_name_extended.'__construct__fields',
102 102
             array($this, 'add_extra_fields_on_filter')
103 103
         );
104 104
         add_filter(
105
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__model_relations',
105
+            'FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations',
106 106
             array($this, 'add_extra_relations_on_filter')
107 107
         );
108 108
         $this->_register_extending_methods();
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
     {
128 128
         if ($this->_extra_fields) {
129 129
             foreach ($this->_extra_fields as $table_alias => $fields) {
130
-                if (! isset($existing_fields[ $table_alias ])) {
131
-                    $existing_fields[ $table_alias ] = array();
130
+                if ( ! isset($existing_fields[$table_alias])) {
131
+                    $existing_fields[$table_alias] = array();
132 132
                 }
133
-                $existing_fields[ $table_alias ] = array_merge(
134
-                    (array) $existing_fields[ $table_alias ],
135
-                    $this->_extra_fields[ $table_alias ]
133
+                $existing_fields[$table_alias] = array_merge(
134
+                    (array) $existing_fields[$table_alias],
135
+                    $this->_extra_fields[$table_alias]
136 136
                 );
137 137
             }
138 138
         }
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
                 $callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model";
164 164
                 add_filter(
165 165
                     $callback_name,
166
-                    array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
166
+                    array($this, self::dynamic_callback_method_prefix.$method_name_on_model),
167 167
                     10,
168 168
                     10
169 169
                 );
@@ -178,15 +178,15 @@  discard block
 block discarded – undo
178 178
     public function deregister()
179 179
     {
180 180
         remove_filter(
181
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__tables',
181
+            'FHEE__EEM_'.$this->_model_name_extended.'__construct__tables',
182 182
             array($this, 'add_extra_tables_on_filter')
183 183
         );
184 184
         remove_filter(
185
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__fields',
185
+            'FHEE__EEM_'.$this->_model_name_extended.'__construct__fields',
186 186
             array($this, 'add_extra_fields_on_filter')
187 187
         );
188 188
         remove_filter(
189
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__model_relations',
189
+            'FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations',
190 190
             array($this, 'add_extra_relations_on_filter')
191 191
         );
192 192
         $all_methods = get_class_methods(get_class($this));
@@ -196,13 +196,13 @@  discard block
 block discarded – undo
196 196
                 $callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model";
197 197
                 remove_filter(
198 198
                     $callback_name,
199
-                    array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
199
+                    array($this, self::dynamic_callback_method_prefix.$method_name_on_model),
200 200
                     10
201 201
                 );
202 202
             }
203 203
         }
204 204
         /** @var EEM_Base $model_to_reset */
205
-        $model_to_reset = 'EEM_' . $this->_model_name_extended;
205
+        $model_to_reset = 'EEM_'.$this->_model_name_extended;
206 206
         if (class_exists($model_to_reset)) {
207 207
             $model_to_reset::reset();
208 208
         }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
             // phpcs:disable WordPress.WP.I18n.SingleUnderscoreGetTextFunction
225 225
             $this->_ = $model_called;
226 226
             // phpcs:enable
227
-            $extending_method = self::extending_method_prefix . $method_called_on_model;
227
+            $extending_method = self::extending_method_prefix.$method_called_on_model;
228 228
             if (method_exists($this, $extending_method)) {
229 229
                 return call_user_func_array(array($this, $extending_method), $args_provided_to_method_on_model);
230 230
             } else {
Please login to merge, or discard this patch.
Indentation   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -43,211 +43,211 @@
 block discarded – undo
43 43
  */
44 44
 abstract class EEME_Base
45 45
 {
46
-    const extending_method_prefix = 'ext_';
47
-    const dynamic_callback_method_prefix = 'dynamic_callback_method_';
48
-
49
-    protected $_extra_tables = array();
50
-    protected $_extra_fields = array();
51
-    protected $_extra_relations = array();
52
-
53
-    /**
54
-     * The model name that is extended (not classname)
55
-     *
56
-     * @var string
57
-     */
58
-    protected $_model_name_extended = null;
59
-
60
-    /**
61
-     * The model this extends
62
-     *
63
-     * @var EEM_Base
64
-     */
65
-    protected $_ = null;
66
-
67
-
68
-    /**
69
-     * @throws \EE_Error
70
-     */
71
-    public function __construct()
72
-    {
73
-        if (! $this->_model_name_extended) {
74
-            throw new EE_Error(
75
-                esc_html__(
76
-                    "When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'",
77
-                    "event_espresso"
78
-                )
79
-            );
80
-        }
81
-        $construct_end_action = 'AHEE__EEM_' . $this->_model_name_extended . '__construct__end';
82
-        if (did_action($construct_end_action)) {
83
-            throw new EE_Error(
84
-                sprintf(
85
-                    esc_html__(
86
-                        "Hooked in model extension '%s' too late! The model %s has already been used! We know because the action %s has been fired",
87
-                        "event_espresso"
88
-                    ),
89
-                    get_class($this),
90
-                    $this->_model_name_extended,
91
-                    $construct_end_action
92
-                )
93
-            );
94
-        }
95
-        add_filter(
96
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__tables',
97
-            array($this, 'add_extra_tables_on_filter')
98
-        );
99
-        add_filter(
100
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__fields',
101
-            array($this, 'add_extra_fields_on_filter')
102
-        );
103
-        add_filter(
104
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__model_relations',
105
-            array($this, 'add_extra_relations_on_filter')
106
-        );
107
-        $this->_register_extending_methods();
108
-    }
109
-
110
-
111
-    /**
112
-     * @param array $existing_tables
113
-     * @return array
114
-     */
115
-    public function add_extra_tables_on_filter($existing_tables)
116
-    {
117
-        return array_merge((array) $existing_tables, $this->_extra_tables);
118
-    }
119
-
120
-
121
-    /**
122
-     * @param array $existing_fields
123
-     * @return array
124
-     */
125
-    public function add_extra_fields_on_filter($existing_fields)
126
-    {
127
-        if ($this->_extra_fields) {
128
-            foreach ($this->_extra_fields as $table_alias => $fields) {
129
-                if (! isset($existing_fields[ $table_alias ])) {
130
-                    $existing_fields[ $table_alias ] = array();
131
-                }
132
-                $existing_fields[ $table_alias ] = array_merge(
133
-                    (array) $existing_fields[ $table_alias ],
134
-                    $this->_extra_fields[ $table_alias ]
135
-                );
136
-            }
137
-        }
138
-        return $existing_fields;
139
-    }
140
-
141
-
142
-    /**
143
-     * @param array $existing_relations
144
-     * @return array
145
-     */
146
-    public function add_extra_relations_on_filter($existing_relations)
147
-    {
148
-        return array_merge((array) $existing_relations, $this->_extra_relations);
149
-    }
150
-
151
-
152
-    /**
153
-     * scans the child of EEME_Base for functions starting with ext_, and magically makes them functions on the
154
-     * model extended. (Internally uses filters, and the __call magic method)
155
-     */
156
-    protected function _register_extending_methods()
157
-    {
158
-        $all_methods = get_class_methods(get_class($this));
159
-        foreach ($all_methods as $method_name) {
160
-            if (strpos($method_name, self::extending_method_prefix) === 0) {
161
-                $method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name);
162
-                $callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model";
163
-                add_filter(
164
-                    $callback_name,
165
-                    array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
166
-                    10,
167
-                    10
168
-                );
169
-            }
170
-        }
171
-    }
172
-
173
-    /**
174
-     * scans the child of EEME_Base for functions starting with ext_, and magically REMOVES them as functions on the
175
-     * model extended. (Internally uses filters, and the __call magic method)
176
-     */
177
-    public function deregister()
178
-    {
179
-        remove_filter(
180
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__tables',
181
-            array($this, 'add_extra_tables_on_filter')
182
-        );
183
-        remove_filter(
184
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__fields',
185
-            array($this, 'add_extra_fields_on_filter')
186
-        );
187
-        remove_filter(
188
-            'FHEE__EEM_' . $this->_model_name_extended . '__construct__model_relations',
189
-            array($this, 'add_extra_relations_on_filter')
190
-        );
191
-        $all_methods = get_class_methods(get_class($this));
192
-        foreach ($all_methods as $method_name) {
193
-            if (strpos($method_name, self::extending_method_prefix) === 0) {
194
-                $method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name);
195
-                $callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model";
196
-                remove_filter(
197
-                    $callback_name,
198
-                    array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
199
-                    10
200
-                );
201
-            }
202
-        }
203
-        /** @var EEM_Base $model_to_reset */
204
-        $model_to_reset = 'EEM_' . $this->_model_name_extended;
205
-        if (class_exists($model_to_reset)) {
206
-            $model_to_reset::reset();
207
-        }
208
-    }
209
-
210
-
211
-    /**
212
-     * @param string $callback_method_name
213
-     * @param array  $args
214
-     * @return mixed
215
-     * @throws EE_Error
216
-     */
217
-    public function __call($callback_method_name, $args)
218
-    {
219
-        if (strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0) {
220
-            // it's a dynamic callback for a method name
221
-            $method_called_on_model = str_replace(self::dynamic_callback_method_prefix, '', $callback_method_name);
222
-            list($original_return_val, $model_called, $args_provided_to_method_on_model) = (array) $args;
223
-            // phpcs:disable WordPress.WP.I18n.SingleUnderscoreGetTextFunction
224
-            $this->_ = $model_called;
225
-            // phpcs:enable
226
-            $extending_method = self::extending_method_prefix . $method_called_on_model;
227
-            if (method_exists($this, $extending_method)) {
228
-                return call_user_func_array(array($this, $extending_method), $args_provided_to_method_on_model);
229
-            } else {
230
-                throw new EE_Error(
231
-                    sprintf(
232
-                        esc_html__(
233
-                            "An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)",
234
-                            "event_espresso"
235
-                        ),
236
-                        $this->_model_name_extended,
237
-                        get_class($this),
238
-                        $extending_method,
239
-                        $extending_method
240
-                    )
241
-                );
242
-            }
243
-        } else {
244
-            throw new EE_Error(
245
-                sprintf(
246
-                    esc_html__("There is no method named '%s' on '%s'", "event_espresso"),
247
-                    $callback_method_name,
248
-                    get_class($this)
249
-                )
250
-            );
251
-        }
252
-    }
46
+	const extending_method_prefix = 'ext_';
47
+	const dynamic_callback_method_prefix = 'dynamic_callback_method_';
48
+
49
+	protected $_extra_tables = array();
50
+	protected $_extra_fields = array();
51
+	protected $_extra_relations = array();
52
+
53
+	/**
54
+	 * The model name that is extended (not classname)
55
+	 *
56
+	 * @var string
57
+	 */
58
+	protected $_model_name_extended = null;
59
+
60
+	/**
61
+	 * The model this extends
62
+	 *
63
+	 * @var EEM_Base
64
+	 */
65
+	protected $_ = null;
66
+
67
+
68
+	/**
69
+	 * @throws \EE_Error
70
+	 */
71
+	public function __construct()
72
+	{
73
+		if (! $this->_model_name_extended) {
74
+			throw new EE_Error(
75
+				esc_html__(
76
+					"When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'",
77
+					"event_espresso"
78
+				)
79
+			);
80
+		}
81
+		$construct_end_action = 'AHEE__EEM_' . $this->_model_name_extended . '__construct__end';
82
+		if (did_action($construct_end_action)) {
83
+			throw new EE_Error(
84
+				sprintf(
85
+					esc_html__(
86
+						"Hooked in model extension '%s' too late! The model %s has already been used! We know because the action %s has been fired",
87
+						"event_espresso"
88
+					),
89
+					get_class($this),
90
+					$this->_model_name_extended,
91
+					$construct_end_action
92
+				)
93
+			);
94
+		}
95
+		add_filter(
96
+			'FHEE__EEM_' . $this->_model_name_extended . '__construct__tables',
97
+			array($this, 'add_extra_tables_on_filter')
98
+		);
99
+		add_filter(
100
+			'FHEE__EEM_' . $this->_model_name_extended . '__construct__fields',
101
+			array($this, 'add_extra_fields_on_filter')
102
+		);
103
+		add_filter(
104
+			'FHEE__EEM_' . $this->_model_name_extended . '__construct__model_relations',
105
+			array($this, 'add_extra_relations_on_filter')
106
+		);
107
+		$this->_register_extending_methods();
108
+	}
109
+
110
+
111
+	/**
112
+	 * @param array $existing_tables
113
+	 * @return array
114
+	 */
115
+	public function add_extra_tables_on_filter($existing_tables)
116
+	{
117
+		return array_merge((array) $existing_tables, $this->_extra_tables);
118
+	}
119
+
120
+
121
+	/**
122
+	 * @param array $existing_fields
123
+	 * @return array
124
+	 */
125
+	public function add_extra_fields_on_filter($existing_fields)
126
+	{
127
+		if ($this->_extra_fields) {
128
+			foreach ($this->_extra_fields as $table_alias => $fields) {
129
+				if (! isset($existing_fields[ $table_alias ])) {
130
+					$existing_fields[ $table_alias ] = array();
131
+				}
132
+				$existing_fields[ $table_alias ] = array_merge(
133
+					(array) $existing_fields[ $table_alias ],
134
+					$this->_extra_fields[ $table_alias ]
135
+				);
136
+			}
137
+		}
138
+		return $existing_fields;
139
+	}
140
+
141
+
142
+	/**
143
+	 * @param array $existing_relations
144
+	 * @return array
145
+	 */
146
+	public function add_extra_relations_on_filter($existing_relations)
147
+	{
148
+		return array_merge((array) $existing_relations, $this->_extra_relations);
149
+	}
150
+
151
+
152
+	/**
153
+	 * scans the child of EEME_Base for functions starting with ext_, and magically makes them functions on the
154
+	 * model extended. (Internally uses filters, and the __call magic method)
155
+	 */
156
+	protected function _register_extending_methods()
157
+	{
158
+		$all_methods = get_class_methods(get_class($this));
159
+		foreach ($all_methods as $method_name) {
160
+			if (strpos($method_name, self::extending_method_prefix) === 0) {
161
+				$method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name);
162
+				$callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model";
163
+				add_filter(
164
+					$callback_name,
165
+					array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
166
+					10,
167
+					10
168
+				);
169
+			}
170
+		}
171
+	}
172
+
173
+	/**
174
+	 * scans the child of EEME_Base for functions starting with ext_, and magically REMOVES them as functions on the
175
+	 * model extended. (Internally uses filters, and the __call magic method)
176
+	 */
177
+	public function deregister()
178
+	{
179
+		remove_filter(
180
+			'FHEE__EEM_' . $this->_model_name_extended . '__construct__tables',
181
+			array($this, 'add_extra_tables_on_filter')
182
+		);
183
+		remove_filter(
184
+			'FHEE__EEM_' . $this->_model_name_extended . '__construct__fields',
185
+			array($this, 'add_extra_fields_on_filter')
186
+		);
187
+		remove_filter(
188
+			'FHEE__EEM_' . $this->_model_name_extended . '__construct__model_relations',
189
+			array($this, 'add_extra_relations_on_filter')
190
+		);
191
+		$all_methods = get_class_methods(get_class($this));
192
+		foreach ($all_methods as $method_name) {
193
+			if (strpos($method_name, self::extending_method_prefix) === 0) {
194
+				$method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name);
195
+				$callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model";
196
+				remove_filter(
197
+					$callback_name,
198
+					array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
199
+					10
200
+				);
201
+			}
202
+		}
203
+		/** @var EEM_Base $model_to_reset */
204
+		$model_to_reset = 'EEM_' . $this->_model_name_extended;
205
+		if (class_exists($model_to_reset)) {
206
+			$model_to_reset::reset();
207
+		}
208
+	}
209
+
210
+
211
+	/**
212
+	 * @param string $callback_method_name
213
+	 * @param array  $args
214
+	 * @return mixed
215
+	 * @throws EE_Error
216
+	 */
217
+	public function __call($callback_method_name, $args)
218
+	{
219
+		if (strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0) {
220
+			// it's a dynamic callback for a method name
221
+			$method_called_on_model = str_replace(self::dynamic_callback_method_prefix, '', $callback_method_name);
222
+			list($original_return_val, $model_called, $args_provided_to_method_on_model) = (array) $args;
223
+			// phpcs:disable WordPress.WP.I18n.SingleUnderscoreGetTextFunction
224
+			$this->_ = $model_called;
225
+			// phpcs:enable
226
+			$extending_method = self::extending_method_prefix . $method_called_on_model;
227
+			if (method_exists($this, $extending_method)) {
228
+				return call_user_func_array(array($this, $extending_method), $args_provided_to_method_on_model);
229
+			} else {
230
+				throw new EE_Error(
231
+					sprintf(
232
+						esc_html__(
233
+							"An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)",
234
+							"event_espresso"
235
+						),
236
+						$this->_model_name_extended,
237
+						get_class($this),
238
+						$extending_method,
239
+						$extending_method
240
+					)
241
+				);
242
+			}
243
+		} else {
244
+			throw new EE_Error(
245
+				sprintf(
246
+					esc_html__("There is no method named '%s' on '%s'", "event_espresso"),
247
+					$callback_method_name,
248
+					get_class($this)
249
+				)
250
+			);
251
+		}
252
+	}
253 253
 }
Please login to merge, or discard this patch.