Completed
Branch fix/remove-joyride (be4b28)
by
unknown
05:31 queued 02:38
created
core/data_migration_scripts/EE_Data_Migration_Script_Stage.core.php 1 patch
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -37,103 +37,103 @@
 block discarded – undo
37 37
  */
38 38
 abstract class EE_Data_Migration_Script_Stage extends EE_Data_Migration_Class_Base
39 39
 {
40
-    /**
41
-     * The migration script this is a stage of
42
-     *
43
-     * @var EE_Data_Migration_Script_Base
44
-     */
45
-    protected $_migration_script;
40
+	/**
41
+	 * The migration script this is a stage of
42
+	 *
43
+	 * @var EE_Data_Migration_Script_Base
44
+	 */
45
+	protected $_migration_script;
46 46
 
47
-    /**
48
-     * This should eb called to essentially 'finalize' construction of the stage.
49
-     * This isn't done on the main constructor in order to avoid repetitive code. Instead, this is
50
-     * called by EE_Data_Migration_Script_Base's __construct() method so children don't have to
51
-     *
52
-     * @param EE_Data_Migration_Script_Base $migration_script
53
-     */
54
-    public function _construct_finalize($migration_script)
55
-    {
56
-        $this->_migration_script = $migration_script;
57
-    }
47
+	/**
48
+	 * This should eb called to essentially 'finalize' construction of the stage.
49
+	 * This isn't done on the main constructor in order to avoid repetitive code. Instead, this is
50
+	 * called by EE_Data_Migration_Script_Base's __construct() method so children don't have to
51
+	 *
52
+	 * @param EE_Data_Migration_Script_Base $migration_script
53
+	 */
54
+	public function _construct_finalize($migration_script)
55
+	{
56
+		$this->_migration_script = $migration_script;
57
+	}
58 58
 
59
-    /**
60
-     * Migrates X old records to the new format. If a fatal error is encountered it is NOT caught here,
61
-     * but is propagated upwards for catching. So basically, the _migration_step() function implemented by children
62
-     * needs to catch exceptions and decide what's a fatal error and what isn't.
63
-     *
64
-     * @param int $num_items_to_migrate
65
-     * @return int
66
-     */
67
-    public function migration_step($num_items_to_migrate = 50)
68
-    {
69
-        // before we run the migration step, we want ot take note of warnings that get outputted
70
-        ob_start();
71
-        $items_migrated = $this->_migration_step($num_items_to_migrate);
72
-        $output = ob_get_contents();
73
-        ob_end_clean();
74
-        if ($output) {
75
-            $this->add_error($output);
76
-        }
77
-        $this->_records_migrated += $items_migrated;
78
-        return $items_migrated;
79
-    }
59
+	/**
60
+	 * Migrates X old records to the new format. If a fatal error is encountered it is NOT caught here,
61
+	 * but is propagated upwards for catching. So basically, the _migration_step() function implemented by children
62
+	 * needs to catch exceptions and decide what's a fatal error and what isn't.
63
+	 *
64
+	 * @param int $num_items_to_migrate
65
+	 * @return int
66
+	 */
67
+	public function migration_step($num_items_to_migrate = 50)
68
+	{
69
+		// before we run the migration step, we want ot take note of warnings that get outputted
70
+		ob_start();
71
+		$items_migrated = $this->_migration_step($num_items_to_migrate);
72
+		$output = ob_get_contents();
73
+		ob_end_clean();
74
+		if ($output) {
75
+			$this->add_error($output);
76
+		}
77
+		$this->_records_migrated += $items_migrated;
78
+		return $items_migrated;
79
+	}
80 80
 
81 81
 
82
-    /**
83
-     * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property
84
-     * accordingly. Note: it should not alter the count of items migrated. That is done in the public function that
85
-     * calls this. IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the
86
-     * last migration step, otherwise it should always return $num_items_to_migrate. (Eg, if we're migrating attendees
87
-     * rows from the database, and $num_items_to_migrate is set to 50, then we SHOULD actually migrate 50 rows,but at
88
-     * very least we MUST report/return 50 items migrated)
89
-     *
90
-     * @param int $num_items_to_migrate
91
-     * @return int number of items ACTUALLY migrated
92
-     */
93
-    abstract protected function _migration_step($num_items_to_migrate = 50);
82
+	/**
83
+	 * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property
84
+	 * accordingly. Note: it should not alter the count of items migrated. That is done in the public function that
85
+	 * calls this. IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the
86
+	 * last migration step, otherwise it should always return $num_items_to_migrate. (Eg, if we're migrating attendees
87
+	 * rows from the database, and $num_items_to_migrate is set to 50, then we SHOULD actually migrate 50 rows,but at
88
+	 * very least we MUST report/return 50 items migrated)
89
+	 *
90
+	 * @param int $num_items_to_migrate
91
+	 * @return int number of items ACTUALLY migrated
92
+	 */
93
+	abstract protected function _migration_step($num_items_to_migrate = 50);
94 94
 
95
-    /**
96
-     * Counts the records that have been migrated so far
97
-     *
98
-     * @return int
99
-     */
100
-    public function count_records_migrated()
101
-    {
102
-        return $this->_records_migrated;
103
-    }
95
+	/**
96
+	 * Counts the records that have been migrated so far
97
+	 *
98
+	 * @return int
99
+	 */
100
+	public function count_records_migrated()
101
+	{
102
+		return $this->_records_migrated;
103
+	}
104 104
 
105
-    /**
106
-     * returns an array of strings describing errors
107
-     *
108
-     * @return array
109
-     */
110
-    public function get_errors()
111
-    {
112
-        return $this->_errors;
113
-    }
105
+	/**
106
+	 * returns an array of strings describing errors
107
+	 *
108
+	 * @return array
109
+	 */
110
+	public function get_errors()
111
+	{
112
+		return $this->_errors;
113
+	}
114 114
 
115 115
 
116
-    /**
117
-     * Sets all of the properties of this script stage to match what's in the array, which is assumed
118
-     * to have been made from the properties_as_array() function.
119
-     *
120
-     * @param array $array_of_properties like what's produced from properties_as_array() method
121
-     */
122
-    public function instantiate_from_array_of_properties($array_of_properties)
123
-    {
124
-        unset($array_of_properties['class']);
125
-        foreach ($array_of_properties as $property_name => $property_value) {
126
-            $this->{$property_name} = $property_value;
127
-        }
128
-    }
116
+	/**
117
+	 * Sets all of the properties of this script stage to match what's in the array, which is assumed
118
+	 * to have been made from the properties_as_array() function.
119
+	 *
120
+	 * @param array $array_of_properties like what's produced from properties_as_array() method
121
+	 */
122
+	public function instantiate_from_array_of_properties($array_of_properties)
123
+	{
124
+		unset($array_of_properties['class']);
125
+		foreach ($array_of_properties as $property_name => $property_value) {
126
+			$this->{$property_name} = $property_value;
127
+		}
128
+	}
129 129
 
130
-    /**
131
-     * Gets the script this is a stage of
132
-     *
133
-     * @return EE_Data_Migration_Script_Base
134
-     */
135
-    protected function get_migration_script()
136
-    {
137
-        return $this->_migration_script;
138
-    }
130
+	/**
131
+	 * Gets the script this is a stage of
132
+	 *
133
+	 * @return EE_Data_Migration_Script_Base
134
+	 */
135
+	protected function get_migration_script()
136
+	{
137
+		return $this->_migration_script;
138
+	}
139 139
 }
Please login to merge, or discard this patch.
core/EE_Psr4AutoloaderInit.core.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,15 +29,15 @@
 block discarded – undo
29 29
     public function initializeAutoloader()
30 30
     {
31 31
         static $initialized = false;
32
-        if (! $initialized) {
32
+        if ( ! $initialized) {
33 33
             // instantiate PSR4 autoloader
34
-            espresso_load_required('Psr4Autoloader', EE_CORE . 'Psr4Autoloader.php');
34
+            espresso_load_required('Psr4Autoloader', EE_CORE.'Psr4Autoloader.php');
35 35
             EE_Psr4AutoloaderInit::$psr4_loader = new Psr4Autoloader();
36 36
             // register the autoloader
37 37
             EE_Psr4AutoloaderInit::$psr4_loader->register();
38 38
             // register the base directories for the namespace prefix
39 39
             EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspresso', EE_PLUGIN_DIR_PATH);
40
-            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoBatchRequest', EE_LIBRARIES . 'batch');
40
+            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoBatchRequest', EE_LIBRARIES.'batch');
41 41
             EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoVendor', EE_THIRD_PARTY);
42 42
             $initialized = true;
43 43
         }
Please login to merge, or discard this patch.
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -15,38 +15,38 @@
 block discarded – undo
15 15
  */
16 16
 class EE_Psr4AutoloaderInit
17 17
 {
18
-    /**
19
-     * @type \EventEspresso\core\Psr4Autoloader
20
-     */
21
-    protected static $psr4_loader;
18
+	/**
19
+	 * @type \EventEspresso\core\Psr4Autoloader
20
+	 */
21
+	protected static $psr4_loader;
22 22
 
23 23
 
24
-    /**
25
-     * @return \EventEspresso\core\Psr4Autoloader
26
-     */
27
-    public function initializeAutoloader()
28
-    {
29
-        static $initialized = false;
30
-        if (! $initialized) {
31
-            // instantiate PSR4 autoloader
32
-            espresso_load_required('Psr4Autoloader', EE_CORE . 'Psr4Autoloader.php');
33
-            EE_Psr4AutoloaderInit::$psr4_loader = new Psr4Autoloader();
34
-            // register the autoloader
35
-            EE_Psr4AutoloaderInit::$psr4_loader->register();
36
-            // register the base directories for the namespace prefix
37
-            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspresso', EE_PLUGIN_DIR_PATH);
38
-            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoBatchRequest', EE_LIBRARIES . 'batch');
39
-            EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoVendor', EE_THIRD_PARTY);
40
-            $initialized = true;
41
-        }
42
-    }
24
+	/**
25
+	 * @return \EventEspresso\core\Psr4Autoloader
26
+	 */
27
+	public function initializeAutoloader()
28
+	{
29
+		static $initialized = false;
30
+		if (! $initialized) {
31
+			// instantiate PSR4 autoloader
32
+			espresso_load_required('Psr4Autoloader', EE_CORE . 'Psr4Autoloader.php');
33
+			EE_Psr4AutoloaderInit::$psr4_loader = new Psr4Autoloader();
34
+			// register the autoloader
35
+			EE_Psr4AutoloaderInit::$psr4_loader->register();
36
+			// register the base directories for the namespace prefix
37
+			EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspresso', EE_PLUGIN_DIR_PATH);
38
+			EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoBatchRequest', EE_LIBRARIES . 'batch');
39
+			EE_Psr4AutoloaderInit::$psr4_loader->addNamespace('EventEspressoVendor', EE_THIRD_PARTY);
40
+			$initialized = true;
41
+		}
42
+	}
43 43
 
44 44
 
45
-    /**
46
-     * @return \EventEspresso\core\Psr4Autoloader
47
-     */
48
-    public static function psr4_loader()
49
-    {
50
-        return self::$psr4_loader;
51
-    }
45
+	/**
46
+	 * @return \EventEspresso\core\Psr4Autoloader
47
+	 */
48
+	public static function psr4_loader()
49
+	{
50
+		return self::$psr4_loader;
51
+	}
52 52
 }
Please login to merge, or discard this patch.
core/admin/EE_Help_Tour.core.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
     public function get_stops()
257 257
     {
258 258
         foreach ($this->_stops as $ind => $stop) {
259
-            if (! isset($stop['button_text'])) {
260
-                $this->_stops[ $ind ]['button_text'] = $this->_options['button_text'];
259
+            if ( ! isset($stop['button_text'])) {
260
+                $this->_stops[$ind]['button_text'] = $this->_options['button_text'];
261 261
             }
262 262
         }
263 263
         return $this->_stops;
@@ -277,6 +277,6 @@  discard block
 block discarded – undo
277 277
                 $this->_options['pauseAfter'][] = $ind;
278 278
             }
279 279
         }
280
-        return apply_filters('FHEE__' . get_class($this) . '__get_options', $this->_options, $this);
280
+        return apply_filters('FHEE__'.get_class($this).'__get_options', $this->_options, $this);
281 281
     }
282 282
 }
Please login to merge, or discard this patch.
Indentation   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -17,271 +17,271 @@
 block discarded – undo
17 17
  */
18 18
 abstract class EE_Help_Tour extends EE_Base
19 19
 {
20
-    /**
21
-     * This is the label for the tour. It is used when regenerating restart buttons for the tour. Set this in the
22
-     * constructor of the child class.
23
-     *
24
-     * @access protected
25
-     * @var string
26
-     */
27
-    protected $_label = '';
28
-
29
-
30
-    /**
31
-     * This is the slug for the tour.  It should be unique from all tours and is used for starting a tour and setting
32
-     * cookies for the tour. Set this in the constructor of the child class.
33
-     *
34
-     * @access protected
35
-     * @var string
36
-     */
37
-    protected $_slug = '';
38
-
39
-
40
-    /**
41
-     * This will contain the formatted array for the stops that gets used by EE_Admin_Page->_add_help_tour() for
42
-     * setting up a tour on a given page. format for array is: array(
43
-     *        0 => array(
44
-     *            'id' => 'id_element', //if attached to an css id for an element then use this param. id's will take
45
-     *            precendence even if you also set class.
46
-     *            'class' => 'class_element', //if attached to a css class for an element anchoring the stop then use
47
-     *            this param. The first element for that class is the anchor. If the class or the id are empty then the
48
-     *            stop will be a modal on the page anchored to the main body.
49
-     *            'custom_class' => 'some_custom_class', //optional custom class to add for this stop.
50
-     *            'button_text' => 'custom text for button', //optional
51
-     *            'content' => 'The content for the stop', //required
52
-     *            'pause_after' => false, //indicate if you want the tour to pause after this stop and it will get
53
-     *            added to the pauseAfter global option array setup for the joyride instance. This is only applicable
54
-     *            when this tour has been set to run on timer.
55
-     *            'options' => array(
56
-     *                //override any of the global options set via the help_tour "option_callback" for the joyride
57
-     *                instance on this specific stop.
58
-     *                )
59
-     *            )
60
-     *        );
61
-     *
62
-     * @access protected
63
-     * @var array
64
-     */
65
-    protected $_stops = array();
66
-
67
-
68
-    /**
69
-     * This contains any stop specific options for the tour.
70
-     * defaults are set but child classes can override.
71
-     *
72
-     * @access protected
73
-     * @var array
74
-     */
75
-    protected $_options = array();
76
-
77
-
78
-    /**
79
-     * holds anything found in the request object (however we override any _gets with _post data).
80
-     *
81
-     * @access protected
82
-     * @var array
83
-     */
84
-    protected $_req_data = array();
85
-
86
-
87
-    /**
88
-     * a flag that is set on init for whether this help_tour is happening on a caf install or not.
89
-     *
90
-     * @var boolean
91
-     */
92
-    protected $_is_caf = false;
93
-
94
-
95
-    /**
96
-     * _constructor
97
-     * initialized the tour object and sets up important properties required to setup the tour.
98
-     *
99
-     * @access public
100
-     * @param boolean $caf used to indicate if this tour is happening on caf install or not.
101
-     * @return void
102
-     */
103
-    public function __construct($caf = false)
104
-    {
105
-        $this->_is_caf = $caf;
106
-        /** @var RequestInterface $request */
107
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
108
-        $this->_req_data = $request->requestParams();
109
-        $this->_set_tour_properties();
110
-        $this->_set_tour_stops();
111
-        $this->_set_tour_options();
112
-
113
-        // make sure the last tour stop has "end tour" for its button
114
-        $end = array_pop($this->_stops);
115
-        $end['button_text'] = esc_html__('End Tour', 'event_espresso');
116
-        // add back to stops
117
-        $this->_stops[] = $end;
118
-    }
119
-
120
-
121
-    /**
122
-     * required method that has the sole purpose of setting up the tour $_label and $_slug properties
123
-     *
124
-     * @abstract
125
-     * @access protected
126
-     * @return void
127
-     */
128
-    abstract protected function _set_tour_properties();
129
-
130
-
131
-    /**
132
-     * required method that's sole purpose is to setup the $_stops property
133
-     *
134
-     * @abstract
135
-     * @access protected
136
-     * @return void
137
-     */
138
-    abstract protected function _set_tour_stops();
139
-
140
-
141
-    /**
142
-     * The method can optionally be overridden by child classes to set the _options array if there are any default
143
-     * options the child wishes to override for a this tour. See property definition for more info
144
-     *
145
-     * @access protected
146
-     * @return void
147
-     */
148
-    protected function _set_tour_options($options = array())
149
-    {
150
-        $defaults = array(
151
-            'tipLocation'           => 'bottom',
152
-            // 'top', 'bottom', 'right', 'left' in relation to parent
153
-            'nubPosition'           => 'auto',
154
-            // override on a per tooltip bases. can be "auto", "right", "top", "bottom", "left"
155
-            'tipAdjustmentY'        => 0,
156
-            // allow for adjustment of tip
157
-            'tipAdjustmentX'        => 0,
158
-            // allow for adjustment of tip
159
-            'scroll'                => true,
160
-            // whether to scrollTo the next step or not
161
-            'scrollSpeed'           => 300,
162
-            // Page scrolling speed in ms
163
-            'timer'                 => 0,
164
-            // 0 = off, all other numbers = time(ms)
165
-            'autoStart'             => true,
166
-            // true or false - false tour starts when restart called
167
-            'startTimerOnClick'     => true,
168
-            // true/false to start timer on first click
169
-            'nextButton'            => true,
170
-            // true/false for next button visibility
171
-            'button_text'           => esc_html__('Next', 'event_espresso'),
172
-            'tipAnimation'          => 'fade',
173
-            // 'pop' or 'fade' in each tip
174
-            'pauseAfter'            => array(),
175
-            // array of indexes where to pause the tour after
176
-            'tipAnimationFadeSpeed' => 300,
177
-            // if 'fade'- speed in ms of transition
178
-            'cookieMonster'         => true,
179
-            // true/false for whether cookies are used
180
-            'cookieName'            => $this->get_slug(),
181
-            // choose your own cookie name (setup will add the prefix for the specific page joyride)
182
-            // set to false or yoursite.com
183
-            'cookieDomain'          => false,
184
-            // Where the tip be attached if not inline
185
-            // 'tipContainer' => 'body',
186
-            'modal'                 => false,
187
-            // Whether to cover page with modal during the tour
188
-            'expose'                => false,
189
-            // Whether to expose the elements at each step in the tour (requires modal:true),
190
-            'postExposeCallback'    => 'EEHelpTour.postExposeCallback',
191
-            // A method to call after an element has been exposed
192
-            'preRideCallback'       => 'EEHelpTour_preRideCallback',
193
-            // A method to call before the tour starts (passed index, tip, and cloned exposed element)
194
-            'postRideCallback'      => 'EEHelpTour_postRideCallback',
195
-            // a method to call once the tour closes.  This will correspond to the name of a js method that will have to be defined in loaded js.
196
-            'preStepCallback'       => 'EEHelpTour_preStepCallback',
197
-            // A method to call before each step
198
-            'postStepCallback'      => 'EEHelpTour_postStepCallback',
199
-            // A method to call after each step (remember this will correspond with a js method that you will have to define in a js file BEFORE ee-help-tour.js loads, if the default methods do not exist, then ee-help-tour.js just substitues empty functions $.noop)/**/
200
-        );
201
-
202
-        $options = ! empty($options) && is_array($options) ? array_merge($defaults, $options) : $defaults;
203
-        $this->_options = $options;
204
-    }
205
-
206
-
207
-    /**
208
-     * getter functions to return all the properties for the tour.
209
-     */
210
-
211
-
212
-    /**
213
-     * get_slug
214
-     *
215
-     * @return string slug for the tour
216
-     */
217
-    public function get_slug()
218
-    {
219
-        if (empty($this->_slug)) {
220
-            throw new EE_Error(
221
-                sprintf(
222
-                    esc_html__(
223
-                        'There is no slug set for the help tour class (%s). Make sure that the $_slug property is set in the class constructor',
224
-                        'event_espresso'
225
-                    ),
226
-                    get_class($this)
227
-                )
228
-            );
229
-        }
230
-        return $this->_slug;
231
-    }
232
-
233
-
234
-    /**
235
-     * get_label
236
-     *
237
-     * @return string
238
-     */
239
-    public function get_label()
240
-    {
241
-        if (empty($this->_label)) {
242
-            throw new EE_Error(
243
-                sprintf(
244
-                    esc_html__(
245
-                        'There is no label set for the help tour class (%s). Make sure that the $_label property is set in the class constructor',
246
-                        'event_espresso'
247
-                    ),
248
-                    get_class($this)
249
-                )
250
-            );
251
-        }
252
-        return $this->_label;
253
-    }
254
-
255
-
256
-    /**
257
-     * get_stops
258
-     *
259
-     * @return array
260
-     */
261
-    public function get_stops()
262
-    {
263
-        foreach ($this->_stops as $ind => $stop) {
264
-            if (! isset($stop['button_text'])) {
265
-                $this->_stops[ $ind ]['button_text'] = $this->_options['button_text'];
266
-            }
267
-        }
268
-        return $this->_stops;
269
-    }
270
-
271
-
272
-    /**
273
-     * get options
274
-     *
275
-     * @return array
276
-     */
277
-    public function get_options()
278
-    {
279
-        // let's make sure there are not pauses set
280
-        foreach ($this->_stops as $ind => $stop) {
281
-            if (isset($stop['pause_after']) && $stop['pause_after']) {
282
-                $this->_options['pauseAfter'][] = $ind;
283
-            }
284
-        }
285
-        return apply_filters('FHEE__' . get_class($this) . '__get_options', $this->_options, $this);
286
-    }
20
+	/**
21
+	 * This is the label for the tour. It is used when regenerating restart buttons for the tour. Set this in the
22
+	 * constructor of the child class.
23
+	 *
24
+	 * @access protected
25
+	 * @var string
26
+	 */
27
+	protected $_label = '';
28
+
29
+
30
+	/**
31
+	 * This is the slug for the tour.  It should be unique from all tours and is used for starting a tour and setting
32
+	 * cookies for the tour. Set this in the constructor of the child class.
33
+	 *
34
+	 * @access protected
35
+	 * @var string
36
+	 */
37
+	protected $_slug = '';
38
+
39
+
40
+	/**
41
+	 * This will contain the formatted array for the stops that gets used by EE_Admin_Page->_add_help_tour() for
42
+	 * setting up a tour on a given page. format for array is: array(
43
+	 *        0 => array(
44
+	 *            'id' => 'id_element', //if attached to an css id for an element then use this param. id's will take
45
+	 *            precendence even if you also set class.
46
+	 *            'class' => 'class_element', //if attached to a css class for an element anchoring the stop then use
47
+	 *            this param. The first element for that class is the anchor. If the class or the id are empty then the
48
+	 *            stop will be a modal on the page anchored to the main body.
49
+	 *            'custom_class' => 'some_custom_class', //optional custom class to add for this stop.
50
+	 *            'button_text' => 'custom text for button', //optional
51
+	 *            'content' => 'The content for the stop', //required
52
+	 *            'pause_after' => false, //indicate if you want the tour to pause after this stop and it will get
53
+	 *            added to the pauseAfter global option array setup for the joyride instance. This is only applicable
54
+	 *            when this tour has been set to run on timer.
55
+	 *            'options' => array(
56
+	 *                //override any of the global options set via the help_tour "option_callback" for the joyride
57
+	 *                instance on this specific stop.
58
+	 *                )
59
+	 *            )
60
+	 *        );
61
+	 *
62
+	 * @access protected
63
+	 * @var array
64
+	 */
65
+	protected $_stops = array();
66
+
67
+
68
+	/**
69
+	 * This contains any stop specific options for the tour.
70
+	 * defaults are set but child classes can override.
71
+	 *
72
+	 * @access protected
73
+	 * @var array
74
+	 */
75
+	protected $_options = array();
76
+
77
+
78
+	/**
79
+	 * holds anything found in the request object (however we override any _gets with _post data).
80
+	 *
81
+	 * @access protected
82
+	 * @var array
83
+	 */
84
+	protected $_req_data = array();
85
+
86
+
87
+	/**
88
+	 * a flag that is set on init for whether this help_tour is happening on a caf install or not.
89
+	 *
90
+	 * @var boolean
91
+	 */
92
+	protected $_is_caf = false;
93
+
94
+
95
+	/**
96
+	 * _constructor
97
+	 * initialized the tour object and sets up important properties required to setup the tour.
98
+	 *
99
+	 * @access public
100
+	 * @param boolean $caf used to indicate if this tour is happening on caf install or not.
101
+	 * @return void
102
+	 */
103
+	public function __construct($caf = false)
104
+	{
105
+		$this->_is_caf = $caf;
106
+		/** @var RequestInterface $request */
107
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
108
+		$this->_req_data = $request->requestParams();
109
+		$this->_set_tour_properties();
110
+		$this->_set_tour_stops();
111
+		$this->_set_tour_options();
112
+
113
+		// make sure the last tour stop has "end tour" for its button
114
+		$end = array_pop($this->_stops);
115
+		$end['button_text'] = esc_html__('End Tour', 'event_espresso');
116
+		// add back to stops
117
+		$this->_stops[] = $end;
118
+	}
119
+
120
+
121
+	/**
122
+	 * required method that has the sole purpose of setting up the tour $_label and $_slug properties
123
+	 *
124
+	 * @abstract
125
+	 * @access protected
126
+	 * @return void
127
+	 */
128
+	abstract protected function _set_tour_properties();
129
+
130
+
131
+	/**
132
+	 * required method that's sole purpose is to setup the $_stops property
133
+	 *
134
+	 * @abstract
135
+	 * @access protected
136
+	 * @return void
137
+	 */
138
+	abstract protected function _set_tour_stops();
139
+
140
+
141
+	/**
142
+	 * The method can optionally be overridden by child classes to set the _options array if there are any default
143
+	 * options the child wishes to override for a this tour. See property definition for more info
144
+	 *
145
+	 * @access protected
146
+	 * @return void
147
+	 */
148
+	protected function _set_tour_options($options = array())
149
+	{
150
+		$defaults = array(
151
+			'tipLocation'           => 'bottom',
152
+			// 'top', 'bottom', 'right', 'left' in relation to parent
153
+			'nubPosition'           => 'auto',
154
+			// override on a per tooltip bases. can be "auto", "right", "top", "bottom", "left"
155
+			'tipAdjustmentY'        => 0,
156
+			// allow for adjustment of tip
157
+			'tipAdjustmentX'        => 0,
158
+			// allow for adjustment of tip
159
+			'scroll'                => true,
160
+			// whether to scrollTo the next step or not
161
+			'scrollSpeed'           => 300,
162
+			// Page scrolling speed in ms
163
+			'timer'                 => 0,
164
+			// 0 = off, all other numbers = time(ms)
165
+			'autoStart'             => true,
166
+			// true or false - false tour starts when restart called
167
+			'startTimerOnClick'     => true,
168
+			// true/false to start timer on first click
169
+			'nextButton'            => true,
170
+			// true/false for next button visibility
171
+			'button_text'           => esc_html__('Next', 'event_espresso'),
172
+			'tipAnimation'          => 'fade',
173
+			// 'pop' or 'fade' in each tip
174
+			'pauseAfter'            => array(),
175
+			// array of indexes where to pause the tour after
176
+			'tipAnimationFadeSpeed' => 300,
177
+			// if 'fade'- speed in ms of transition
178
+			'cookieMonster'         => true,
179
+			// true/false for whether cookies are used
180
+			'cookieName'            => $this->get_slug(),
181
+			// choose your own cookie name (setup will add the prefix for the specific page joyride)
182
+			// set to false or yoursite.com
183
+			'cookieDomain'          => false,
184
+			// Where the tip be attached if not inline
185
+			// 'tipContainer' => 'body',
186
+			'modal'                 => false,
187
+			// Whether to cover page with modal during the tour
188
+			'expose'                => false,
189
+			// Whether to expose the elements at each step in the tour (requires modal:true),
190
+			'postExposeCallback'    => 'EEHelpTour.postExposeCallback',
191
+			// A method to call after an element has been exposed
192
+			'preRideCallback'       => 'EEHelpTour_preRideCallback',
193
+			// A method to call before the tour starts (passed index, tip, and cloned exposed element)
194
+			'postRideCallback'      => 'EEHelpTour_postRideCallback',
195
+			// a method to call once the tour closes.  This will correspond to the name of a js method that will have to be defined in loaded js.
196
+			'preStepCallback'       => 'EEHelpTour_preStepCallback',
197
+			// A method to call before each step
198
+			'postStepCallback'      => 'EEHelpTour_postStepCallback',
199
+			// A method to call after each step (remember this will correspond with a js method that you will have to define in a js file BEFORE ee-help-tour.js loads, if the default methods do not exist, then ee-help-tour.js just substitues empty functions $.noop)/**/
200
+		);
201
+
202
+		$options = ! empty($options) && is_array($options) ? array_merge($defaults, $options) : $defaults;
203
+		$this->_options = $options;
204
+	}
205
+
206
+
207
+	/**
208
+	 * getter functions to return all the properties for the tour.
209
+	 */
210
+
211
+
212
+	/**
213
+	 * get_slug
214
+	 *
215
+	 * @return string slug for the tour
216
+	 */
217
+	public function get_slug()
218
+	{
219
+		if (empty($this->_slug)) {
220
+			throw new EE_Error(
221
+				sprintf(
222
+					esc_html__(
223
+						'There is no slug set for the help tour class (%s). Make sure that the $_slug property is set in the class constructor',
224
+						'event_espresso'
225
+					),
226
+					get_class($this)
227
+				)
228
+			);
229
+		}
230
+		return $this->_slug;
231
+	}
232
+
233
+
234
+	/**
235
+	 * get_label
236
+	 *
237
+	 * @return string
238
+	 */
239
+	public function get_label()
240
+	{
241
+		if (empty($this->_label)) {
242
+			throw new EE_Error(
243
+				sprintf(
244
+					esc_html__(
245
+						'There is no label set for the help tour class (%s). Make sure that the $_label property is set in the class constructor',
246
+						'event_espresso'
247
+					),
248
+					get_class($this)
249
+				)
250
+			);
251
+		}
252
+		return $this->_label;
253
+	}
254
+
255
+
256
+	/**
257
+	 * get_stops
258
+	 *
259
+	 * @return array
260
+	 */
261
+	public function get_stops()
262
+	{
263
+		foreach ($this->_stops as $ind => $stop) {
264
+			if (! isset($stop['button_text'])) {
265
+				$this->_stops[ $ind ]['button_text'] = $this->_options['button_text'];
266
+			}
267
+		}
268
+		return $this->_stops;
269
+	}
270
+
271
+
272
+	/**
273
+	 * get options
274
+	 *
275
+	 * @return array
276
+	 */
277
+	public function get_options()
278
+	{
279
+		// let's make sure there are not pauses set
280
+		foreach ($this->_stops as $ind => $stop) {
281
+			if (isset($stop['pause_after']) && $stop['pause_after']) {
282
+				$this->_options['pauseAfter'][] = $ind;
283
+			}
284
+		}
285
+		return apply_filters('FHEE__' . get_class($this) . '__get_options', $this->_options, $this);
286
+	}
287 287
 }
Please login to merge, or discard this patch.
core/libraries/messages/EE_Message_Factory.lib.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     public static function instance(EE_Message_Resource_Manager $Message_Resource_Manager)
52 52
     {
53 53
         // check if class object is instantiated, and instantiated properly
54
-        if (! self::$_instance instanceof EE_Message_Factory) {
54
+        if ( ! self::$_instance instanceof EE_Message_Factory) {
55 55
             self::$_instance = new EE_Message_Factory($Message_Resource_Manager);
56 56
         }
57 57
         return self::$_instance;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
     protected function _create($props_n_values = array())
128 128
     {
129 129
         $new_instance = false;
130
-        if (! empty($props_n_values['MSG_ID'])) {
130
+        if ( ! empty($props_n_values['MSG_ID'])) {
131 131
             $message = EE_Message::new_instance_from_db($props_n_values);
132 132
         } else {
133 133
             $message = EE_Message::new_instance($props_n_values);
Please login to merge, or discard this patch.
Indentation   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -13,175 +13,175 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Message_Factory
15 15
 {
16
-    /**
17
-     * @type EE_Message_Factory $_instance
18
-     */
19
-    protected static $_instance = null;
20
-
21
-
22
-    /**
23
-     * @type EE_Message_Resource_Manager $_message_resource_manager
24
-     */
25
-    protected $_message_resource_manager;
26
-
27
-
28
-
29
-    /**
30
-     * EE_Message_Factory constructor.
31
-     *
32
-     * @access protected
33
-     * @param \EE_Message_Resource_Manager $Message_Resource_Manager
34
-     */
35
-    protected function __construct(
36
-        EE_Message_Resource_Manager $Message_Resource_Manager
37
-    ) {
38
-        $this->_message_resource_manager = $Message_Resource_Manager;
39
-    }
40
-
41
-
42
-
43
-    /**
44
-     * @singleton method used to instantiate class object
45
-     * @access    public
46
-     * @param \EE_Message_Resource_Manager $Message_Resource_Manager
47
-     * @return \EE_Message_Factory instance
48
-     */
49
-    public static function instance(EE_Message_Resource_Manager $Message_Resource_Manager)
50
-    {
51
-        // check if class object is instantiated, and instantiated properly
52
-        if (! self::$_instance instanceof EE_Message_Factory) {
53
-            self::$_instance = new EE_Message_Factory($Message_Resource_Manager);
54
-        }
55
-        return self::$_instance;
56
-    }
57
-
58
-
59
-
60
-    /**
61
-     * @access public
62
-     * @param  array $props_n_values
63
-     * @return EE_Message
64
-     */
65
-    public static function create($props_n_values = array())
66
-    {
67
-        /** @type EE_Message_Factory $Message_Factory */
68
-        $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory');
69
-        return $Message_Factory->_create($props_n_values);
70
-    }
71
-
72
-
73
-
74
-    /**
75
-     * @access public
76
-     * @param  \EE_Message $message
77
-     * @return \EE_Message
78
-     * @throws \EE_Error
79
-     */
80
-    public static function set_messenger_and_message_type(EE_Message $message)
81
-    {
82
-        /** @type EE_Message_Factory $Message_Factory */
83
-        $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory');
84
-        return $Message_Factory->_set_messenger_and_message_type($message);
85
-    }
86
-
87
-
88
-
89
-    /**
90
-     * @access public
91
-     * @param  \EE_Message $message
92
-     * @return \EE_Message
93
-     * @throws \EE_Error
94
-     */
95
-    public static function set_messenger(EE_Message $message)
96
-    {
97
-        /** @type EE_Message_Factory $Message_Factory */
98
-        $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory');
99
-        return $Message_Factory->_set_messenger($message);
100
-    }
101
-
102
-
103
-
104
-    /**
105
-     * @access public
106
-     * @param  \EE_Message $message
107
-     * @return \EE_Message
108
-     * @throws \EE_Error
109
-     */
110
-    public static function set_message_type(EE_Message $message)
111
-    {
112
-        /** @type EE_Message_Factory $Message_Factory */
113
-        $Message_Factory = EE_Registry::instance()->load_lib('Message_Factory');
114
-        return $Message_Factory->_set_message_type($message);
115
-    }
116
-
117
-
118
-
119
-    /**
120
-     * @access protected
121
-     * @param  array $props_n_values
122
-     * @return \EE_Message
123
-     * @throws \EE_Error
124
-     */
125
-    protected function _create($props_n_values = array())
126
-    {
127
-        $new_instance = false;
128
-        if (! empty($props_n_values['MSG_ID'])) {
129
-            $message = EE_Message::new_instance_from_db($props_n_values);
130
-        } else {
131
-            $message = EE_Message::new_instance($props_n_values);
132
-            $new_instance = true;
133
-        }
134
-        return $this->_set_messenger_and_message_type($message, $new_instance);
135
-    }
136
-
137
-
138
-
139
-    /**
140
-     * @access public
141
-     * @param  \EE_Message $message
142
-     * @param  bool        $new_instance Whether the message type was setup from the database (false) or not (true)
143
-     * @return \EE_Message
144
-     * @throws \EE_Error
145
-     */
146
-    protected function _set_messenger_and_message_type(EE_Message $message, $new_instance = false)
147
-    {
148
-        $message = $this->_set_messenger($message);
149
-        $message = $this->_set_message_type($message, $new_instance);
150
-        return $message;
151
-    }
152
-
153
-
154
-
155
-    /**
156
-     * @access protected
157
-     * @param  \EE_Message $message
158
-     * @return \EE_Message
159
-     * @throws \EE_Error
160
-     */
161
-    protected function _set_messenger(EE_Message $message)
162
-    {
163
-        $messenger = $this->_message_resource_manager->get_messenger($message->messenger());
164
-        if ($messenger instanceof EE_messenger) {
165
-            $message->set_messenger_object($messenger);
166
-        }
167
-        return $message;
168
-    }
169
-
170
-
171
-
172
-    /**
173
-     * @access protected
174
-     * @param  \EE_Message $message
175
-     * @param  bool        $new_instance Whether the message type was setup from the database (false) or not (true)
176
-     * @return \EE_Message
177
-     * @throws \EE_Error
178
-     */
179
-    protected function _set_message_type(EE_Message $message, $new_instance = false)
180
-    {
181
-        $message_type = $this->_message_resource_manager->get_message_type($message->message_type());
182
-        if ($message_type instanceof EE_message_type) {
183
-            $message->set_message_type_object($message_type, $new_instance);
184
-        }
185
-        return $message;
186
-    }
16
+	/**
17
+	 * @type EE_Message_Factory $_instance
18
+	 */
19
+	protected static $_instance = null;
20
+
21
+
22
+	/**
23
+	 * @type EE_Message_Resource_Manager $_message_resource_manager
24
+	 */
25
+	protected $_message_resource_manager;
26
+
27
+
28
+
29
+	/**
30
+	 * EE_Message_Factory constructor.
31
+	 *
32
+	 * @access protected
33
+	 * @param \EE_Message_Resource_Manager $Message_Resource_Manager
34
+	 */
35
+	protected function __construct(
36
+		EE_Message_Resource_Manager $Message_Resource_Manager
37
+	) {
38
+		$this->_message_resource_manager = $Message_Resource_Manager;
39
+	}
40
+
41
+
42
+
43
+	/**
44
+	 * @singleton method used to instantiate class object
45
+	 * @access    public
46
+	 * @param \EE_Message_Resource_Manager $Message_Resource_Manager
47
+	 * @return \EE_Message_Factory instance
48
+	 */
49
+	public static function instance(EE_Message_Resource_Manager $Message_Resource_Manager)
50
+	{
51
+		// check if class object is instantiated, and instantiated properly
52
+		if (! self::$_instance instanceof EE_Message_Factory) {
53
+			self::$_instance = new EE_Message_Factory($Message_Resource_Manager);
54
+		}
55
+		return self::$_instance;
56
+	}
57
+
58
+
59
+
60
+	/**
61
+	 * @access public
62
+	 * @param  array $props_n_values
63
+	 * @return EE_Message
64
+	 */
65
+	public static function create($props_n_values = array())
66
+	{
67
+		/** @type EE_Message_Factory $Message_Factory */
68
+		$Message_Factory = EE_Registry::instance()->load_lib('Message_Factory');
69
+		return $Message_Factory->_create($props_n_values);
70
+	}
71
+
72
+
73
+
74
+	/**
75
+	 * @access public
76
+	 * @param  \EE_Message $message
77
+	 * @return \EE_Message
78
+	 * @throws \EE_Error
79
+	 */
80
+	public static function set_messenger_and_message_type(EE_Message $message)
81
+	{
82
+		/** @type EE_Message_Factory $Message_Factory */
83
+		$Message_Factory = EE_Registry::instance()->load_lib('Message_Factory');
84
+		return $Message_Factory->_set_messenger_and_message_type($message);
85
+	}
86
+
87
+
88
+
89
+	/**
90
+	 * @access public
91
+	 * @param  \EE_Message $message
92
+	 * @return \EE_Message
93
+	 * @throws \EE_Error
94
+	 */
95
+	public static function set_messenger(EE_Message $message)
96
+	{
97
+		/** @type EE_Message_Factory $Message_Factory */
98
+		$Message_Factory = EE_Registry::instance()->load_lib('Message_Factory');
99
+		return $Message_Factory->_set_messenger($message);
100
+	}
101
+
102
+
103
+
104
+	/**
105
+	 * @access public
106
+	 * @param  \EE_Message $message
107
+	 * @return \EE_Message
108
+	 * @throws \EE_Error
109
+	 */
110
+	public static function set_message_type(EE_Message $message)
111
+	{
112
+		/** @type EE_Message_Factory $Message_Factory */
113
+		$Message_Factory = EE_Registry::instance()->load_lib('Message_Factory');
114
+		return $Message_Factory->_set_message_type($message);
115
+	}
116
+
117
+
118
+
119
+	/**
120
+	 * @access protected
121
+	 * @param  array $props_n_values
122
+	 * @return \EE_Message
123
+	 * @throws \EE_Error
124
+	 */
125
+	protected function _create($props_n_values = array())
126
+	{
127
+		$new_instance = false;
128
+		if (! empty($props_n_values['MSG_ID'])) {
129
+			$message = EE_Message::new_instance_from_db($props_n_values);
130
+		} else {
131
+			$message = EE_Message::new_instance($props_n_values);
132
+			$new_instance = true;
133
+		}
134
+		return $this->_set_messenger_and_message_type($message, $new_instance);
135
+	}
136
+
137
+
138
+
139
+	/**
140
+	 * @access public
141
+	 * @param  \EE_Message $message
142
+	 * @param  bool        $new_instance Whether the message type was setup from the database (false) or not (true)
143
+	 * @return \EE_Message
144
+	 * @throws \EE_Error
145
+	 */
146
+	protected function _set_messenger_and_message_type(EE_Message $message, $new_instance = false)
147
+	{
148
+		$message = $this->_set_messenger($message);
149
+		$message = $this->_set_message_type($message, $new_instance);
150
+		return $message;
151
+	}
152
+
153
+
154
+
155
+	/**
156
+	 * @access protected
157
+	 * @param  \EE_Message $message
158
+	 * @return \EE_Message
159
+	 * @throws \EE_Error
160
+	 */
161
+	protected function _set_messenger(EE_Message $message)
162
+	{
163
+		$messenger = $this->_message_resource_manager->get_messenger($message->messenger());
164
+		if ($messenger instanceof EE_messenger) {
165
+			$message->set_messenger_object($messenger);
166
+		}
167
+		return $message;
168
+	}
169
+
170
+
171
+
172
+	/**
173
+	 * @access protected
174
+	 * @param  \EE_Message $message
175
+	 * @param  bool        $new_instance Whether the message type was setup from the database (false) or not (true)
176
+	 * @return \EE_Message
177
+	 * @throws \EE_Error
178
+	 */
179
+	protected function _set_message_type(EE_Message $message, $new_instance = false)
180
+	{
181
+		$message_type = $this->_message_resource_manager->get_message_type($message->message_type());
182
+		if ($message_type instanceof EE_message_type) {
183
+			$message->set_message_type_object($message_type, $new_instance);
184
+		}
185
+		return $message;
186
+	}
187 187
 }
Please login to merge, or discard this patch.
core/libraries/messages/data_class/EE_Messages_Addressee.class.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -302,7 +302,7 @@
 block discarded – undo
302 302
             }
303 303
         }
304 304
         // if user_id present we'll use this to set the fname and lname and admin_email.
305
-        if (! empty($this->user_id)) {
305
+        if ( ! empty($this->user_id)) {
306 306
             $this->user_id = (int) $this->user_id;
307 307
             $user = get_userdata($this->user_id);
308 308
             $this->fname = $user->user_firstname;
Please login to merge, or discard this patch.
Indentation   +295 added lines, -295 removed lines patch added patch discarded remove patch
@@ -13,299 +13,299 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Messages_Addressee extends EE_Base
15 15
 {
16
-    /**
17
-     * Identifier properties for the recipient
18
-     */
19
-
20
-    /**
21
-     * if available we'll use this to set the fname and lname (admin)
22
-     *
23
-     * @var int
24
-     */
25
-    public $user_id;
26
-
27
-    /**
28
-     * this will always be the admin fname (set later via incoming user_id)
29
-     *
30
-     * @var string
31
-     */
32
-    public $fname;
33
-
34
-    /**
35
-     * this will always be the admin lname (set later via incoming user_id)
36
-     *
37
-     * @var string
38
-     */
39
-    public $lname;
40
-
41
-    /**
42
-     * @var int
43
-     */
44
-    public $primary_registration_id;
45
-
46
-    /**
47
-     * @var int
48
-     */
49
-    public $attendee_registration_id;
50
-
51
-    /**
52
-     * This is should represent the data object that can be used to regenerate this addressee if needed.
53
-     * It is saved to the MSG_recipient_ID column in the generated EE_Message using this data.
54
-     *
55
-     * @var int
56
-     */
57
-    public $recipient_id;
58
-
59
-    /**
60
-     * This represents the reference to the EE_Base_Class child that the $recipient_ID is for (eg. 'Registration',
61
-     * 'Attendee') It is saved to the MSG_recipient_type column in the generated EE_Message using this data.
62
-     *
63
-     * @var string
64
-     */
65
-    public $recipient_type;
66
-
67
-    /**
68
-     * communication related
69
-     */
70
-    /**
71
-     * @var string
72
-     */
73
-    public $attendee_email;
74
-
75
-    /**
76
-     * @var string
77
-     */
78
-    public $primary_attendee_email;
79
-
80
-    /**
81
-     * @var string
82
-     */
83
-    public $admin_email;
84
-
85
-
86
-
87
-    /**
88
-     * Attendee related
89
-     */
90
-
91
-    /**
92
-     * holds the attendee object for the primary attendee
93
-     *
94
-     * @var EE_Attendee
95
-     */
96
-    public $primary_att_obj;
97
-
98
-    /**
99
-     * holds the registration object for the primary attendee
100
-     *
101
-     * @var EE_Registration
102
-     */
103
-    public $primary_reg_obj;
104
-
105
-    /**
106
-     * holds the attendee object for an attendee
107
-     *
108
-     * @var EE_Attendee
109
-     */
110
-    public $att_obj;
111
-
112
-    /**
113
-     * holds the registration object for an attendee
114
-     *
115
-     * @var EE_Registration
116
-     */
117
-    public $reg_obj;
118
-
119
-    /**
120
-     * array of EE_Question objects (indexed by EE_Answer->ID())
121
-     *
122
-     * @var EE_Question[]
123
-     */
124
-    public $questions;
125
-
126
-    /**
127
-     * array of EE_Answer objects
128
-     *
129
-     * @var EE_Answer[]
130
-     */
131
-    public $answers;
132
-
133
-
134
-
135
-    /**
136
-     * event related
137
-     */
138
-
139
-    /**
140
-     * This will hold all event info/
141
-     * @var EE_Event[]
142
-     */
143
-    public $events;
144
-
145
-    /**
146
-     * holds all the attendees for an event.
147
-     *
148
-     * @var EE_Attendee[]
149
-     */
150
-    public $attendees;
151
-
152
-    /**
153
-     * holds all the purchased tickets for an event
154
-     *
155
-     * @var EE_Ticket[]
156
-     */
157
-    public $tickets;
158
-
159
-    /**
160
-     * holds an array of line items indexed by parent ticket line item ids and values are array of children of that
161
-     * line item
162
-     *
163
-     * @var EE_Line_Item[]
164
-     */
165
-    public $line_items_with_children;
166
-
167
-    /**
168
-     * holds all the datetimes accessed via the tickets purchased for the event
169
-     *
170
-     * @var EE_Datetime[]
171
-     */
172
-    public $datetimes;
173
-
174
-    /**
175
-     * holds all registrations for a transaction (with cached relations on that registration)
176
-     *
177
-     * @var EE_Registration[]
178
-     */
179
-    public $registrations;
180
-
181
-
182
-
183
-    /**
184
-     * txn related
185
-     */
186
-
187
-    /**
188
-     * @var array
189
-     */
190
-    public $billing;
191
-
192
-    /**
193
-     *total taxes
194
-     *
195
-     * @var array
196
-     */
197
-    public $taxes;
198
-
199
-    /**
200
-     * @var EE_Line_Item[]
201
-     */
202
-    public $tax_line_items;
203
-
204
-    /**
205
-     * @var EE_Line_Item[]
206
-     */
207
-    public $additional_line_items;
208
-
209
-    /**
210
-     * @var EE_Line_Item
211
-     */
212
-    public $grand_total_line_item;
213
-
214
-    /**
215
-     * @var EE_Transaction
216
-     */
217
-    public $txn;
218
-
219
-    /**
220
-     * @var EE_Payment
221
-     */
222
-    public $payment;
223
-
224
-    /**
225
-     * @var EE_Payment[]
226
-     */
227
-    public $payments;
228
-
229
-    /**
230
-     * @var EE_Transaction[]
231
-     */
232
-    public $txn_objs;
233
-
234
-    /**
235
-     * @var EE_Registration[]
236
-     */
237
-    public $reg_objs;
238
-
239
-    /**
240
-     * total number of ALL tickets purchased for the txn.
241
-     *
242
-     * @var int
243
-     */
244
-    public $total_ticket_count;
245
-
246
-
247
-
248
-    /**
249
-     * things that get set later by parsers
250
-     */
251
-
252
-    /**
253
-     * @var string $event_list
254
-     */
255
-    public $event_list;
256
-
257
-    /**
258
-     * @var string
259
-     */
260
-    public $attendee_list;
261
-
262
-
263
-
264
-    /**
265
-     * This just holds the incoming data
266
-     *
267
-     * @var array
268
-     */
269
-    protected $_data;
270
-
271
-
272
-
273
-    /**
274
-     * constructor
275
-     *
276
-     * @access public
277
-     * @param array $addressee_data We're expecting an incoming array of data that will be used to fill the properties
278
-     *                              for the object.
279
-     */
280
-    public function __construct($addressee_data)
281
-    {
282
-        $this->_data = $addressee_data;
283
-        $this->_set_properties();
284
-    }
285
-
286
-
287
-
288
-    /**
289
-     * This simply loops through the data and makes sure that each item is present in the incoming data.  If it is then
290
-     * it is assigned to the property.
291
-     *
292
-     * @access protected
293
-     * @return void.
294
-     */
295
-    protected function _set_properties()
296
-    {
297
-        foreach ($this->_data as $prop => $value) {
298
-            if (property_exists($this, $prop)) {
299
-                $this->{$prop} = $value;
300
-            }
301
-        }
302
-        // if user_id present we'll use this to set the fname and lname and admin_email.
303
-        if (! empty($this->user_id)) {
304
-            $this->user_id = (int) $this->user_id;
305
-            $user = get_userdata($this->user_id);
306
-            $this->fname = $user->user_firstname;
307
-            $this->lname = $user->user_lastname;
308
-            $this->admin_email = $user->user_email;
309
-        }
310
-    }
16
+	/**
17
+	 * Identifier properties for the recipient
18
+	 */
19
+
20
+	/**
21
+	 * if available we'll use this to set the fname and lname (admin)
22
+	 *
23
+	 * @var int
24
+	 */
25
+	public $user_id;
26
+
27
+	/**
28
+	 * this will always be the admin fname (set later via incoming user_id)
29
+	 *
30
+	 * @var string
31
+	 */
32
+	public $fname;
33
+
34
+	/**
35
+	 * this will always be the admin lname (set later via incoming user_id)
36
+	 *
37
+	 * @var string
38
+	 */
39
+	public $lname;
40
+
41
+	/**
42
+	 * @var int
43
+	 */
44
+	public $primary_registration_id;
45
+
46
+	/**
47
+	 * @var int
48
+	 */
49
+	public $attendee_registration_id;
50
+
51
+	/**
52
+	 * This is should represent the data object that can be used to regenerate this addressee if needed.
53
+	 * It is saved to the MSG_recipient_ID column in the generated EE_Message using this data.
54
+	 *
55
+	 * @var int
56
+	 */
57
+	public $recipient_id;
58
+
59
+	/**
60
+	 * This represents the reference to the EE_Base_Class child that the $recipient_ID is for (eg. 'Registration',
61
+	 * 'Attendee') It is saved to the MSG_recipient_type column in the generated EE_Message using this data.
62
+	 *
63
+	 * @var string
64
+	 */
65
+	public $recipient_type;
66
+
67
+	/**
68
+	 * communication related
69
+	 */
70
+	/**
71
+	 * @var string
72
+	 */
73
+	public $attendee_email;
74
+
75
+	/**
76
+	 * @var string
77
+	 */
78
+	public $primary_attendee_email;
79
+
80
+	/**
81
+	 * @var string
82
+	 */
83
+	public $admin_email;
84
+
85
+
86
+
87
+	/**
88
+	 * Attendee related
89
+	 */
90
+
91
+	/**
92
+	 * holds the attendee object for the primary attendee
93
+	 *
94
+	 * @var EE_Attendee
95
+	 */
96
+	public $primary_att_obj;
97
+
98
+	/**
99
+	 * holds the registration object for the primary attendee
100
+	 *
101
+	 * @var EE_Registration
102
+	 */
103
+	public $primary_reg_obj;
104
+
105
+	/**
106
+	 * holds the attendee object for an attendee
107
+	 *
108
+	 * @var EE_Attendee
109
+	 */
110
+	public $att_obj;
111
+
112
+	/**
113
+	 * holds the registration object for an attendee
114
+	 *
115
+	 * @var EE_Registration
116
+	 */
117
+	public $reg_obj;
118
+
119
+	/**
120
+	 * array of EE_Question objects (indexed by EE_Answer->ID())
121
+	 *
122
+	 * @var EE_Question[]
123
+	 */
124
+	public $questions;
125
+
126
+	/**
127
+	 * array of EE_Answer objects
128
+	 *
129
+	 * @var EE_Answer[]
130
+	 */
131
+	public $answers;
132
+
133
+
134
+
135
+	/**
136
+	 * event related
137
+	 */
138
+
139
+	/**
140
+	 * This will hold all event info/
141
+	 * @var EE_Event[]
142
+	 */
143
+	public $events;
144
+
145
+	/**
146
+	 * holds all the attendees for an event.
147
+	 *
148
+	 * @var EE_Attendee[]
149
+	 */
150
+	public $attendees;
151
+
152
+	/**
153
+	 * holds all the purchased tickets for an event
154
+	 *
155
+	 * @var EE_Ticket[]
156
+	 */
157
+	public $tickets;
158
+
159
+	/**
160
+	 * holds an array of line items indexed by parent ticket line item ids and values are array of children of that
161
+	 * line item
162
+	 *
163
+	 * @var EE_Line_Item[]
164
+	 */
165
+	public $line_items_with_children;
166
+
167
+	/**
168
+	 * holds all the datetimes accessed via the tickets purchased for the event
169
+	 *
170
+	 * @var EE_Datetime[]
171
+	 */
172
+	public $datetimes;
173
+
174
+	/**
175
+	 * holds all registrations for a transaction (with cached relations on that registration)
176
+	 *
177
+	 * @var EE_Registration[]
178
+	 */
179
+	public $registrations;
180
+
181
+
182
+
183
+	/**
184
+	 * txn related
185
+	 */
186
+
187
+	/**
188
+	 * @var array
189
+	 */
190
+	public $billing;
191
+
192
+	/**
193
+	 *total taxes
194
+	 *
195
+	 * @var array
196
+	 */
197
+	public $taxes;
198
+
199
+	/**
200
+	 * @var EE_Line_Item[]
201
+	 */
202
+	public $tax_line_items;
203
+
204
+	/**
205
+	 * @var EE_Line_Item[]
206
+	 */
207
+	public $additional_line_items;
208
+
209
+	/**
210
+	 * @var EE_Line_Item
211
+	 */
212
+	public $grand_total_line_item;
213
+
214
+	/**
215
+	 * @var EE_Transaction
216
+	 */
217
+	public $txn;
218
+
219
+	/**
220
+	 * @var EE_Payment
221
+	 */
222
+	public $payment;
223
+
224
+	/**
225
+	 * @var EE_Payment[]
226
+	 */
227
+	public $payments;
228
+
229
+	/**
230
+	 * @var EE_Transaction[]
231
+	 */
232
+	public $txn_objs;
233
+
234
+	/**
235
+	 * @var EE_Registration[]
236
+	 */
237
+	public $reg_objs;
238
+
239
+	/**
240
+	 * total number of ALL tickets purchased for the txn.
241
+	 *
242
+	 * @var int
243
+	 */
244
+	public $total_ticket_count;
245
+
246
+
247
+
248
+	/**
249
+	 * things that get set later by parsers
250
+	 */
251
+
252
+	/**
253
+	 * @var string $event_list
254
+	 */
255
+	public $event_list;
256
+
257
+	/**
258
+	 * @var string
259
+	 */
260
+	public $attendee_list;
261
+
262
+
263
+
264
+	/**
265
+	 * This just holds the incoming data
266
+	 *
267
+	 * @var array
268
+	 */
269
+	protected $_data;
270
+
271
+
272
+
273
+	/**
274
+	 * constructor
275
+	 *
276
+	 * @access public
277
+	 * @param array $addressee_data We're expecting an incoming array of data that will be used to fill the properties
278
+	 *                              for the object.
279
+	 */
280
+	public function __construct($addressee_data)
281
+	{
282
+		$this->_data = $addressee_data;
283
+		$this->_set_properties();
284
+	}
285
+
286
+
287
+
288
+	/**
289
+	 * This simply loops through the data and makes sure that each item is present in the incoming data.  If it is then
290
+	 * it is assigned to the property.
291
+	 *
292
+	 * @access protected
293
+	 * @return void.
294
+	 */
295
+	protected function _set_properties()
296
+	{
297
+		foreach ($this->_data as $prop => $value) {
298
+			if (property_exists($this, $prop)) {
299
+				$this->{$prop} = $value;
300
+			}
301
+		}
302
+		// if user_id present we'll use this to set the fname and lname and admin_email.
303
+		if (! empty($this->user_id)) {
304
+			$this->user_id = (int) $this->user_id;
305
+			$user = get_userdata($this->user_id);
306
+			$this->fname = $user->user_firstname;
307
+			$this->lname = $user->user_lastname;
308
+			$this->admin_email = $user->user_email;
309
+		}
310
+	}
311 311
 }
Please login to merge, or discard this patch.
messages/data_class/EE_Messages_Registrations_incoming_data.class.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     {
29 29
 
30 30
         // validate that the first element in the array is an EE_Registration object.
31
-        if (! reset($data) instanceof EE_Registration) {
31
+        if ( ! reset($data) instanceof EE_Registration) {
32 32
             throw new EE_Error(
33 33
                 esc_html__(
34 34
                     'The EE_Message_Registrations_incoming_data class expects an array of EE_Registration objects.',
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
             if ($registration instanceof EE_Registration) {
78 78
                 $transaction = $registration->transaction();
79 79
                 if ($transaction instanceof EE_Transaction) {
80
-                    $transactions[ $transaction->ID() ] = $transaction;
80
+                    $transactions[$transaction->ID()] = $transaction;
81 81
                 }
82 82
             }
83 83
         }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public static function convert_data_for_persistent_storage($registrations)
99 99
     {
100
-        if (! self::validateRegistrationsForConversion($registrations)) {
100
+        if ( ! self::validateRegistrationsForConversion($registrations)) {
101 101
             return array();
102 102
         }
103 103
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         // k nope so let's pull from the registrations
111 111
         $registration_ids = array_filter(
112 112
             array_map(
113
-                function ($registration) {
113
+                function($registration) {
114 114
                     if ($registration instanceof EE_Registration) {
115 115
                         return $registration->ID();
116 116
                     }
Please login to merge, or discard this patch.
Indentation   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -15,172 +15,172 @@
 block discarded – undo
15 15
  */
16 16
 class EE_Messages_Registrations_incoming_data extends EE_Messages_incoming_data
17 17
 {
18
-    /**
19
-     * Constructor.
20
-     *
21
-     * @param  EE_Registration[] $data expecting an array of EE_Registration objects.
22
-     * @throws EE_Error
23
-     * @access protected
24
-     */
25
-    public function __construct($data = array())
26
-    {
27
-
28
-        // validate that the first element in the array is an EE_Registration object.
29
-        if (! reset($data) instanceof EE_Registration) {
30
-            throw new EE_Error(
31
-                esc_html__(
32
-                    'The EE_Message_Registrations_incoming_data class expects an array of EE_Registration objects.',
33
-                    'event_espresso'
34
-                )
35
-            );
36
-        }
37
-        parent::__construct($data);
38
-    }
39
-
40
-
41
-    /**
42
-     * setup the data.
43
-     * Sets up the expected data object for the messages prep using incoming registration objects.
44
-     *
45
-     * @return void
46
-     * @throws EE_Error
47
-     * @throws EntityNotFoundException
48
-     * @access protected
49
-     */
50
-    protected function _setup_data()
51
-    {
52
-        // we'll loop through each contact and setup the data needed.  Note that many properties will just be set as
53
-        // empty because this data handler is for a very specific set of data (i.e. just what's related to the
54
-        // registration).
55
-
56
-        $this->reg_objs = $this->data();
57
-        $this->txn      = $this->_maybe_get_transaction();
58
-        $this->_assemble_data();
59
-    }
60
-
61
-
62
-    /**
63
-     * If the incoming registrations all share the same transaction then this will return the transaction object shared
64
-     * among the registrations. Otherwise the transaction object is set to null because its intended to only represent
65
-     * one transaction.
66
-     *
67
-     * @return EE_Transaction|null
68
-     * @throws EE_Error
69
-     * @throws EntityNotFoundException
70
-     */
71
-    protected function _maybe_get_transaction()
72
-    {
73
-        $transactions = array();
74
-        foreach ($this->reg_objs as $registration) {
75
-            if ($registration instanceof EE_Registration) {
76
-                $transaction = $registration->transaction();
77
-                if ($transaction instanceof EE_Transaction) {
78
-                    $transactions[ $transaction->ID() ] = $transaction;
79
-                }
80
-            }
81
-        }
82
-        return count($transactions) === 1 ? reset($transactions) : null;
83
-    }
84
-
85
-
86
-    /**
87
-     * Returns database safe representation of the data later used to when instantiating this object.
88
-     *
89
-     * @param array $registrations The incoming data to be prepped.
90
-     * @return EE_Registration[] The data being prepared for the db
91
-     * @throws EE_Error
92
-     * @throws InvalidArgumentException
93
-     * @throws InvalidDataTypeException
94
-     * @throws InvalidInterfaceException
95
-     */
96
-    public static function convert_data_for_persistent_storage($registrations)
97
-    {
98
-        if (! self::validateRegistrationsForConversion($registrations)) {
99
-            return array();
100
-        }
101
-
102
-        // is this an array of ints?
103
-        $first_item = reset($registrations);
104
-        if (is_int($first_item)) {
105
-            return $registrations;
106
-        }
107
-
108
-        // k nope so let's pull from the registrations
109
-        $registration_ids = array_filter(
110
-            array_map(
111
-                function ($registration) {
112
-                    if ($registration instanceof EE_Registration) {
113
-                        return $registration->ID();
114
-                    }
115
-                    return false;
116
-                },
117
-                $registrations
118
-            )
119
-        );
120
-
121
-        return $registration_ids;
122
-    }
123
-
124
-
125
-    /**
126
-     * This validates incoming registrations (considers whether they are ids or EE_Registration objects.
127
-     *
128
-     * @param array $registrations Could be EE_Registration[] or int[]
129
-     * @return bool
130
-     * @throws EE_Error
131
-     * @throws InvalidArgumentException
132
-     * @throws InvalidDataTypeException
133
-     * @throws InvalidInterfaceException
134
-     */
135
-    protected static function validateRegistrationsForConversion($registrations)
136
-    {
137
-        if (is_array($registrations)) {
138
-            $first_item = reset($registrations);
139
-            if ($first_item instanceof EE_Registration) {
140
-                return true;
141
-            }
142
-            if (is_int($first_item)) {
143
-                // k let's some basic validation here.  This isn't foolproof but better than nothing.
144
-                // the purpose of this validation is to verify that the ids sent in match valid registrations existing
145
-                // in the db.  If the count is different, then we know they aren't valid.
146
-                $count_for_ids = EEM_Registration::instance()->count(
147
-                    array(
148
-                        array(
149
-                            'REG_ID' => array('IN', $registrations)
150
-                        )
151
-                    )
152
-                );
153
-                return $count_for_ids === count($registrations);
154
-            }
155
-        }
156
-        return false;
157
-    }
158
-
159
-
160
-    /**
161
-     * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage
162
-     * can be sent into this method and converted back into the format used for instantiating with this data handler.
163
-     *
164
-     * @param array $data
165
-     * @return EE_Registration[]
166
-     * @throws EE_Error
167
-     * @throws InvalidArgumentException
168
-     * @throws InvalidDataTypeException
169
-     * @throws InvalidInterfaceException
170
-     */
171
-    public static function convert_data_from_persistent_storage($data)
172
-    {
173
-        // since this was added later, we need to account of possible back compat issues where data already queued for
174
-        // generation is in the old format, which is an array of EE_Registration objects.  So if that's the case, then
175
-        // let's just return them
176
-        // @see https://events.codebasehq.com/projects/event-espresso/tickets/10127
177
-        if (is_array($data) && reset($data) instanceof EE_Registration) {
178
-            return $data;
179
-        }
180
-
181
-        $registrations = is_array($data)
182
-            ? EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $data))))
183
-            : array();
184
-        return $registrations;
185
-    }
18
+	/**
19
+	 * Constructor.
20
+	 *
21
+	 * @param  EE_Registration[] $data expecting an array of EE_Registration objects.
22
+	 * @throws EE_Error
23
+	 * @access protected
24
+	 */
25
+	public function __construct($data = array())
26
+	{
27
+
28
+		// validate that the first element in the array is an EE_Registration object.
29
+		if (! reset($data) instanceof EE_Registration) {
30
+			throw new EE_Error(
31
+				esc_html__(
32
+					'The EE_Message_Registrations_incoming_data class expects an array of EE_Registration objects.',
33
+					'event_espresso'
34
+				)
35
+			);
36
+		}
37
+		parent::__construct($data);
38
+	}
39
+
40
+
41
+	/**
42
+	 * setup the data.
43
+	 * Sets up the expected data object for the messages prep using incoming registration objects.
44
+	 *
45
+	 * @return void
46
+	 * @throws EE_Error
47
+	 * @throws EntityNotFoundException
48
+	 * @access protected
49
+	 */
50
+	protected function _setup_data()
51
+	{
52
+		// we'll loop through each contact and setup the data needed.  Note that many properties will just be set as
53
+		// empty because this data handler is for a very specific set of data (i.e. just what's related to the
54
+		// registration).
55
+
56
+		$this->reg_objs = $this->data();
57
+		$this->txn      = $this->_maybe_get_transaction();
58
+		$this->_assemble_data();
59
+	}
60
+
61
+
62
+	/**
63
+	 * If the incoming registrations all share the same transaction then this will return the transaction object shared
64
+	 * among the registrations. Otherwise the transaction object is set to null because its intended to only represent
65
+	 * one transaction.
66
+	 *
67
+	 * @return EE_Transaction|null
68
+	 * @throws EE_Error
69
+	 * @throws EntityNotFoundException
70
+	 */
71
+	protected function _maybe_get_transaction()
72
+	{
73
+		$transactions = array();
74
+		foreach ($this->reg_objs as $registration) {
75
+			if ($registration instanceof EE_Registration) {
76
+				$transaction = $registration->transaction();
77
+				if ($transaction instanceof EE_Transaction) {
78
+					$transactions[ $transaction->ID() ] = $transaction;
79
+				}
80
+			}
81
+		}
82
+		return count($transactions) === 1 ? reset($transactions) : null;
83
+	}
84
+
85
+
86
+	/**
87
+	 * Returns database safe representation of the data later used to when instantiating this object.
88
+	 *
89
+	 * @param array $registrations The incoming data to be prepped.
90
+	 * @return EE_Registration[] The data being prepared for the db
91
+	 * @throws EE_Error
92
+	 * @throws InvalidArgumentException
93
+	 * @throws InvalidDataTypeException
94
+	 * @throws InvalidInterfaceException
95
+	 */
96
+	public static function convert_data_for_persistent_storage($registrations)
97
+	{
98
+		if (! self::validateRegistrationsForConversion($registrations)) {
99
+			return array();
100
+		}
101
+
102
+		// is this an array of ints?
103
+		$first_item = reset($registrations);
104
+		if (is_int($first_item)) {
105
+			return $registrations;
106
+		}
107
+
108
+		// k nope so let's pull from the registrations
109
+		$registration_ids = array_filter(
110
+			array_map(
111
+				function ($registration) {
112
+					if ($registration instanceof EE_Registration) {
113
+						return $registration->ID();
114
+					}
115
+					return false;
116
+				},
117
+				$registrations
118
+			)
119
+		);
120
+
121
+		return $registration_ids;
122
+	}
123
+
124
+
125
+	/**
126
+	 * This validates incoming registrations (considers whether they are ids or EE_Registration objects.
127
+	 *
128
+	 * @param array $registrations Could be EE_Registration[] or int[]
129
+	 * @return bool
130
+	 * @throws EE_Error
131
+	 * @throws InvalidArgumentException
132
+	 * @throws InvalidDataTypeException
133
+	 * @throws InvalidInterfaceException
134
+	 */
135
+	protected static function validateRegistrationsForConversion($registrations)
136
+	{
137
+		if (is_array($registrations)) {
138
+			$first_item = reset($registrations);
139
+			if ($first_item instanceof EE_Registration) {
140
+				return true;
141
+			}
142
+			if (is_int($first_item)) {
143
+				// k let's some basic validation here.  This isn't foolproof but better than nothing.
144
+				// the purpose of this validation is to verify that the ids sent in match valid registrations existing
145
+				// in the db.  If the count is different, then we know they aren't valid.
146
+				$count_for_ids = EEM_Registration::instance()->count(
147
+					array(
148
+						array(
149
+							'REG_ID' => array('IN', $registrations)
150
+						)
151
+					)
152
+				);
153
+				return $count_for_ids === count($registrations);
154
+			}
155
+		}
156
+		return false;
157
+	}
158
+
159
+
160
+	/**
161
+	 * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage
162
+	 * can be sent into this method and converted back into the format used for instantiating with this data handler.
163
+	 *
164
+	 * @param array $data
165
+	 * @return EE_Registration[]
166
+	 * @throws EE_Error
167
+	 * @throws InvalidArgumentException
168
+	 * @throws InvalidDataTypeException
169
+	 * @throws InvalidInterfaceException
170
+	 */
171
+	public static function convert_data_from_persistent_storage($data)
172
+	{
173
+		// since this was added later, we need to account of possible back compat issues where data already queued for
174
+		// generation is in the old format, which is an array of EE_Registration objects.  So if that's the case, then
175
+		// let's just return them
176
+		// @see https://events.codebasehq.com/projects/event-espresso/tickets/10127
177
+		if (is_array($data) && reset($data) instanceof EE_Registration) {
178
+			return $data;
179
+		}
180
+
181
+		$registrations = is_array($data)
182
+			? EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $data))))
183
+			: array();
184
+		return $registrations;
185
+	}
186 186
 }
Please login to merge, or discard this patch.
validators/email/EE_Messages_Email_Payment_Refund_Validator.class.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,18 +32,18 @@
 block discarded – undo
32 32
 
33 33
         // modify just event_list
34 34
         $new_config['event_list'] = array(
35
-            'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization','recipient_details', 'recipient_list', 'event_author', 'primary_registration_details', 'primary_registration_list')
35
+            'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'recipient_details', 'recipient_list', 'event_author', 'primary_registration_details', 'primary_registration_list')
36 36
             );
37 37
         $new_config['ticket_list'] = array(
38 38
             'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'recipient_details', 'transaction')
39 39
             );
40 40
         $new_config['content'] = array(
41
-            'shortcodes' => array('event_list','attendee_list', 'ticket_list', 'organization', 'recipient_details', 'recipient_list', 'transaction', 'primary_registration_details', 'primary_registration_list', 'messenger')
41
+            'shortcodes' => array('event_list', 'attendee_list', 'ticket_list', 'organization', 'recipient_details', 'recipient_list', 'transaction', 'primary_registration_details', 'primary_registration_list', 'messenger')
42 42
             );
43 43
         $this->_messenger->set_validator_config($new_config);
44 44
 
45 45
         if ($this->_context != 'admin') {
46
-            $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list');
46
+            $this->_valid_shortcodes_modifier[$this->_context]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list');
47 47
         }
48 48
 
49 49
         $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]');
Please login to merge, or discard this patch.
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -13,37 +13,37 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Messages_Email_Payment_Refund_Validator extends EE_Messages_Validator
15 15
 {
16
-    public function __construct($fields, $context)
17
-    {
18
-        $this->_m_name = 'email';
19
-        $this->_mt_name = 'payment_refund';
16
+	public function __construct($fields, $context)
17
+	{
18
+		$this->_m_name = 'email';
19
+		$this->_mt_name = 'payment_refund';
20 20
 
21
-        parent::__construct($fields, $context);
22
-    }
21
+		parent::__construct($fields, $context);
22
+	}
23 23
 
24
-    /**
25
-     * at this point no custom validation needed for this messenger/message_type combo.
26
-     */
27
-    protected function _modify_validator()
28
-    {
29
-        $new_config = $this->_messenger->get_validator_config();
24
+	/**
25
+	 * at this point no custom validation needed for this messenger/message_type combo.
26
+	 */
27
+	protected function _modify_validator()
28
+	{
29
+		$new_config = $this->_messenger->get_validator_config();
30 30
 
31
-        // modify just event_list
32
-        $new_config['event_list'] = array(
33
-            'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization','recipient_details', 'recipient_list', 'event_author', 'primary_registration_details', 'primary_registration_list')
34
-            );
35
-        $new_config['ticket_list'] = array(
36
-            'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'recipient_details', 'transaction')
37
-            );
38
-        $new_config['content'] = array(
39
-            'shortcodes' => array('event_list','attendee_list', 'ticket_list', 'organization', 'recipient_details', 'recipient_list', 'transaction', 'primary_registration_details', 'primary_registration_list', 'messenger')
40
-            );
41
-        $this->_messenger->set_validator_config($new_config);
31
+		// modify just event_list
32
+		$new_config['event_list'] = array(
33
+			'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization','recipient_details', 'recipient_list', 'event_author', 'primary_registration_details', 'primary_registration_list')
34
+			);
35
+		$new_config['ticket_list'] = array(
36
+			'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'recipient_details', 'transaction')
37
+			);
38
+		$new_config['content'] = array(
39
+			'shortcodes' => array('event_list','attendee_list', 'ticket_list', 'organization', 'recipient_details', 'recipient_list', 'transaction', 'primary_registration_details', 'primary_registration_list', 'messenger')
40
+			);
41
+		$this->_messenger->set_validator_config($new_config);
42 42
 
43
-        if ($this->_context != 'admin') {
44
-            $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list');
45
-        }
43
+		if ($this->_context != 'admin') {
44
+			$this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list');
45
+		}
46 46
 
47
-        $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]');
48
-    }
47
+		$this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]');
48
+	}
49 49
 }
Please login to merge, or discard this patch.
validators/email/EE_Messages_Email_Registration_Summary_Validator.class.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
         $this->_messenger->set_validator_config($new_config);
39 39
 
40 40
         if ($this->_context != 'admin') {
41
-            $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list');
41
+            $this->_valid_shortcodes_modifier[$this->_context]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list');
42 42
         }
43 43
 
44 44
         $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]');
Please login to merge, or discard this patch.
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -14,31 +14,31 @@
 block discarded – undo
14 14
  */
15 15
 class EE_Messages_Email_Registration_Summary_Validator extends EE_Messages_Validator
16 16
 {
17
-    public function __construct($fields, $context)
18
-    {
19
-        $this->_m_name = 'email';
20
-        $this->_mt_name = 'registration_summary';
17
+	public function __construct($fields, $context)
18
+	{
19
+		$this->_m_name = 'email';
20
+		$this->_mt_name = 'registration_summary';
21 21
 
22
-        parent::__construct($fields, $context);
23
-    }
22
+		parent::__construct($fields, $context);
23
+	}
24 24
 
25
-    /**
26
-     * custom validator (restricting what was originally set by the messenger)
27
-     */
28
-    protected function _modify_validator()
29
-    {
30
-        $new_config = $this->_messenger->get_validator_config();
31
-        // modify just event_list
32
-        $new_config['event_list'] = array(
33
-            'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'),
34
-            'required' => array('[EVENT_LIST]')
35
-            );
36
-        $this->_messenger->set_validator_config($new_config);
25
+	/**
26
+	 * custom validator (restricting what was originally set by the messenger)
27
+	 */
28
+	protected function _modify_validator()
29
+	{
30
+		$new_config = $this->_messenger->get_validator_config();
31
+		// modify just event_list
32
+		$new_config['event_list'] = array(
33
+			'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list'),
34
+			'required' => array('[EVENT_LIST]')
35
+			);
36
+		$this->_messenger->set_validator_config($new_config);
37 37
 
38
-        if ($this->_context != 'admin') {
39
-            $this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list');
40
-        }
38
+		if ($this->_context != 'admin') {
39
+			$this->_valid_shortcodes_modifier[ $this->_context ]['event_list'] = array('event', 'attendee_list', 'ticket_list', 'datetime_list', 'venue', 'organization', 'event_author', 'primary_registration_details', 'primary_registration_list', 'recipient_details', 'recipient_list');
40
+		}
41 41
 
42
-        $this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]');
43
-    }
42
+		$this->_specific_shortcode_excludes['content'] = array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]');
43
+	}
44 44
 }
Please login to merge, or discard this patch.
core/libraries/messages/messenger/EE_Email_messenger.class.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
             ),
57 57
             '<code>wp_mail</code>'
58 58
         );
59
-        $this->label               = array(
59
+        $this->label = array(
60 60
             'singular' => esc_html__('email', 'event_espresso'),
61 61
             'plural'   => esc_html__('emails', 'event_espresso'),
62 62
         );
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
             $this->_body(),
439 439
             $this->_headers()
440 440
         );
441
-        if (! $success) {
441
+        if ( ! $success) {
442 442
             EE_Error::add_error(
443 443
                 sprintf(
444 444
                     esc_html__(
@@ -482,8 +482,8 @@  discard block
 block discarded – undo
482 482
         $this->_ensure_has_from_email_address();
483 483
         $from    = $this->_from;
484 484
         $headers = array(
485
-            'From:' . $from,
486
-            'Reply-To:' . $from,
485
+            'From:'.$from,
486
+            'Reply-To:'.$from,
487 487
             'Content-Type:text/html; charset=utf-8',
488 488
         );
489 489
 
@@ -492,8 +492,8 @@  discard block
 block discarded – undo
492 492
          * cover back compat where there may be users who have saved cc values in their db for the newsletter message
493 493
          * type which they are no longer able to change.
494 494
          */
495
-        if (! empty($this->_cc) && ! $this->_incoming_message_type instanceof EE_Newsletter_message_type) {
496
-            $headers[] = 'cc: ' . $this->_cc;
495
+        if ( ! empty($this->_cc) && ! $this->_incoming_message_type instanceof EE_Newsletter_message_type) {
496
+            $headers[] = 'cc: '.$this->_cc;
497 497
         }
498 498
 
499 499
         // but wait!  Header's for the from is NOT reliable because some plugins don't respect From: as set in the
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
             'from'      => $this->_from,
601 601
             'main_body' => wpautop($this->_content),
602 602
         );
603
-        $body                 = $this->_get_main_template($preview);
603
+        $body = $this->_get_main_template($preview);
604 604
 
605 605
         /**
606 606
          * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched.
@@ -610,10 +610,10 @@  discard block
 block discarded – undo
610 610
          */
611 611
         if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) {
612 612
             // require CssToInlineStyles library and its dependencies via composer autoloader
613
-            require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php';
613
+            require_once EE_THIRD_PARTY.'cssinliner/vendor/autoload.php';
614 614
 
615 615
             // now if this isn't a preview, let's setup the body so it has inline styles
616
-            if (! $preview || ($preview && defined('DOING_AJAX'))) {
616
+            if ( ! $preview || ($preview && defined('DOING_AJAX'))) {
617 617
                 $style = file_get_contents(
618 618
                     $this->get_variation(
619 619
                         $this->_tmp_pack,
Please login to merge, or discard this patch.
Indentation   +644 added lines, -644 removed lines patch added patch discarded remove patch
@@ -5,648 +5,648 @@
 block discarded – undo
5 5
  */
6 6
 class EE_Email_messenger extends EE_messenger
7 7
 {
8
-    /**
9
-     * To field for email
10
-     * @var string
11
-     */
12
-    protected $_to = '';
13
-
14
-
15
-    /**
16
-     * CC field for email.
17
-     * @var string
18
-     */
19
-    protected $_cc = '';
20
-
21
-    /**
22
-     * From field for email
23
-     * @var string
24
-     */
25
-    protected $_from = '';
26
-
27
-
28
-    /**
29
-     * Subject field for email
30
-     * @var string
31
-     */
32
-    protected $_subject = '';
33
-
34
-
35
-    /**
36
-     * Content field for email
37
-     * @var string
38
-     */
39
-    protected $_content = '';
40
-
41
-
42
-    /**
43
-     * constructor
44
-     *
45
-     * @access public
46
-     */
47
-    public function __construct()
48
-    {
49
-        // set name and description properties
50
-        $this->name                = 'email';
51
-        $this->description         = sprintf(
52
-            esc_html__(
53
-                'This messenger delivers messages via email using the built-in %s function included with WordPress',
54
-                'event_espresso'
55
-            ),
56
-            '<code>wp_mail</code>'
57
-        );
58
-        $this->label               = array(
59
-            'singular' => esc_html__('email', 'event_espresso'),
60
-            'plural'   => esc_html__('emails', 'event_espresso'),
61
-        );
62
-        $this->activate_on_install = true;
63
-
64
-        // we're using defaults so let's call parent constructor that will take care of setting up all the other
65
-        // properties
66
-        parent::__construct();
67
-    }
68
-
69
-
70
-    /**
71
-     * see abstract declaration in parent class for details.
72
-     */
73
-    protected function _set_admin_pages()
74
-    {
75
-        $this->admin_registered_pages = array(
76
-            'events_edit' => true,
77
-        );
78
-    }
79
-
80
-
81
-    /**
82
-     * see abstract declaration in parent class for details
83
-     */
84
-    protected function _set_valid_shortcodes()
85
-    {
86
-        // remember by leaving the other fields not set, those fields will inherit the valid shortcodes from the
87
-        // message type.
88
-        $this->_valid_shortcodes = array(
89
-            'to'   => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
90
-            'cc' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
91
-            'from' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
92
-        );
93
-    }
94
-
95
-
96
-    /**
97
-     * see abstract declaration in parent class for details
98
-     *
99
-     * @access protected
100
-     * @return void
101
-     */
102
-    protected function _set_validator_config()
103
-    {
104
-        $valid_shortcodes = $this->get_valid_shortcodes();
105
-
106
-        $this->_validator_config = array(
107
-            'to'            => array(
108
-                'shortcodes' => $valid_shortcodes['to'],
109
-                'type'       => 'email',
110
-            ),
111
-            'cc' => array(
112
-                'shortcodes' => $valid_shortcodes['to'],
113
-                'type' => 'email',
114
-            ),
115
-            'from'          => array(
116
-                'shortcodes' => $valid_shortcodes['from'],
117
-                'type'       => 'email',
118
-            ),
119
-            'subject'       => array(
120
-                'shortcodes' => array(
121
-                    'organization',
122
-                    'primary_registration_details',
123
-                    'event_author',
124
-                    'primary_registration_details',
125
-                    'recipient_details',
126
-                ),
127
-            ),
128
-            'content'       => array(
129
-                'shortcodes' => array(
130
-                    'event_list',
131
-                    'attendee_list',
132
-                    'ticket_list',
133
-                    'organization',
134
-                    'primary_registration_details',
135
-                    'primary_registration_list',
136
-                    'event_author',
137
-                    'recipient_details',
138
-                    'recipient_list',
139
-                    'transaction',
140
-                    'messenger',
141
-                ),
142
-            ),
143
-            'attendee_list' => array(
144
-                'shortcodes' => array('attendee', 'event_list', 'ticket_list'),
145
-                'required'   => array('[ATTENDEE_LIST]'),
146
-            ),
147
-            'event_list'    => array(
148
-                'shortcodes' => array(
149
-                    'event',
150
-                    'attendee_list',
151
-                    'ticket_list',
152
-                    'venue',
153
-                    'datetime_list',
154
-                    'attendee',
155
-                    'primary_registration_details',
156
-                    'primary_registration_list',
157
-                    'event_author',
158
-                    'recipient_details',
159
-                    'recipient_list',
160
-                ),
161
-                'required'   => array('[EVENT_LIST]'),
162
-            ),
163
-            'ticket_list'   => array(
164
-                'shortcodes' => array(
165
-                    'event_list',
166
-                    'attendee_list',
167
-                    'ticket',
168
-                    'datetime_list',
169
-                    'primary_registration_details',
170
-                    'recipient_details',
171
-                ),
172
-                'required'   => array('[TICKET_LIST]'),
173
-            ),
174
-            'datetime_list' => array(
175
-                'shortcodes' => array('datetime'),
176
-                'required'   => array('[DATETIME_LIST]'),
177
-            ),
178
-        );
179
-    }
180
-
181
-
182
-    /**
183
-     * @see   parent EE_messenger class for docs
184
-     * @since 4.5.0
185
-     */
186
-    public function do_secondary_messenger_hooks($sending_messenger_name)
187
-    {
188
-        if ($sending_messenger_name === 'html') {
189
-            add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
190
-        }
191
-    }
192
-
193
-
194
-    public function add_email_css(
195
-        $variation_path,
196
-        $messenger,
197
-        $message_type,
198
-        $type,
199
-        $variation,
200
-        $file_extension,
201
-        $url,
202
-        EE_Messages_Template_Pack $template_pack
203
-    ) {
204
-        // prevent recursion on this callback.
205
-        remove_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10);
206
-        $variation = $this->get_variation($template_pack, $message_type, $url, 'main', $variation, false);
207
-
208
-        add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
209
-        return $variation;
210
-    }
211
-
212
-
213
-    /**
214
-     * See parent for details
215
-     *
216
-     * @access protected
217
-     * @return void
218
-     */
219
-    protected function _set_test_settings_fields()
220
-    {
221
-        $this->_test_settings_fields = array(
222
-            'to'      => array(
223
-                'input'      => 'text',
224
-                'label'      => esc_html__('Send a test email to', 'event_espresso'),
225
-                'type'       => 'email',
226
-                'required'   => false,
227
-                'validation' => true,
228
-                'css_class'  => 'large-text',
229
-                'format'     => '%s',
230
-                'default'    => get_bloginfo('admin_email'),
231
-            ),
232
-            'subject' => array(
233
-                'input'      => 'hidden',
234
-                'label'      => '',
235
-                'type'       => 'string',
236
-                'required'   => false,
237
-                'validation' => false,
238
-                'format'     => '%s',
239
-                'value'      => sprintf(esc_html__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')),
240
-                'default'    => '',
241
-                'css_class'  => '',
242
-            ),
243
-        );
244
-    }
245
-
246
-
247
-    /**
248
-     * _set_template_fields
249
-     * This sets up the fields that a messenger requires for the message to go out.
250
-     *
251
-     * @access  protected
252
-     * @return void
253
-     */
254
-    protected function _set_template_fields()
255
-    {
256
-        // any extra template fields that are NOT used by the messenger but will get used by a messenger field for
257
-        // shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field
258
-        // they relate to.  This is important for the Messages_admin to know what fields to display to the user.
259
-        //  Also, notice that the "values" are equal to the field type that messages admin will use to know what
260
-        // kind of field to display. The values ALSO have one index labeled "shortcode".  the values in that array
261
-        // indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be
262
-        // displayed.  If the required shortcode isn't part of the shortcodes array then the field is not needed and
263
-        // will not be displayed/parsed.
264
-        $this->_template_fields = array(
265
-            'to'      => array(
266
-                'input'      => 'text',
267
-                'label'      => esc_html_x(
268
-                    'To',
269
-                    'Label for the "To" field for email addresses',
270
-                    'event_espresso'
271
-                ),
272
-                'type'       => 'string',
273
-                'required'   => true,
274
-                'validation' => true,
275
-                'css_class'  => 'large-text',
276
-                'format'     => '%s',
277
-            ),
278
-            'cc'      => array(
279
-                'input'      => 'text',
280
-                'label'      => esc_html_x(
281
-                    'CC',
282
-                    'Label for the "Carbon Copy" field used for additional email addresses',
283
-                    'event_espresso'
284
-                ),
285
-                'type'       => 'string',
286
-                'required'   => false,
287
-                'validation' => true,
288
-                'css_class'  => 'large-text',
289
-                'format'     => '%s',
290
-            ),
291
-            'from'    => array(
292
-                'input'      => 'text',
293
-                'label'      => esc_html_x(
294
-                    'From',
295
-                    'Label for the "From" field for email addresses.',
296
-                    'event_espresso'
297
-                ),
298
-                'type'       => 'string',
299
-                'required'   => true,
300
-                'validation' => true,
301
-                'css_class'  => 'large-text',
302
-                'format'     => '%s',
303
-            ),
304
-            'subject' => array(
305
-                'input'      => 'text',
306
-                'label'      => esc_html_x(
307
-                    'Subject',
308
-                    'Label for the "Subject" field (short description of contents) for emails.',
309
-                    'event_espresso'
310
-                ),
311
-                'type'       => 'string',
312
-                'required'   => true,
313
-                'validation' => true,
314
-                'css_class'  => 'large-text',
315
-                'format'     => '%s',
316
-            ),
317
-            'content' => '',
318
-            // left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field.
319
-            'extra'   => array(
320
-                'content' => array(
321
-                    'main'          => array(
322
-                        'input'      => 'wp_editor',
323
-                        'label'      => esc_html__('Main Content', 'event_espresso'),
324
-                        'type'       => 'string',
325
-                        'required'   => true,
326
-                        'validation' => true,
327
-                        'format'     => '%s',
328
-                        'rows'       => '15',
329
-                    ),
330
-                    'event_list'    => array(
331
-                        'input'               => 'wp_editor',
332
-                        'label'               => '[EVENT_LIST]',
333
-                        'type'                => 'string',
334
-                        'required'            => true,
335
-                        'validation'          => true,
336
-                        'format'              => '%s',
337
-                        'rows'                => '15',
338
-                        'shortcodes_required' => array('[EVENT_LIST]'),
339
-                    ),
340
-                    'attendee_list' => array(
341
-                        'input'               => 'textarea',
342
-                        'label'               => '[ATTENDEE_LIST]',
343
-                        'type'                => 'string',
344
-                        'required'            => true,
345
-                        'validation'          => true,
346
-                        'format'              => '%s',
347
-                        'css_class'           => 'large-text',
348
-                        'rows'                => '5',
349
-                        'shortcodes_required' => array('[ATTENDEE_LIST]'),
350
-                    ),
351
-                    'ticket_list'   => array(
352
-                        'input'               => 'textarea',
353
-                        'label'               => '[TICKET_LIST]',
354
-                        'type'                => 'string',
355
-                        'required'            => true,
356
-                        'validation'          => true,
357
-                        'format'              => '%s',
358
-                        'css_class'           => 'large-text',
359
-                        'rows'                => '10',
360
-                        'shortcodes_required' => array('[TICKET_LIST]'),
361
-                    ),
362
-                    'datetime_list' => array(
363
-                        'input'               => 'textarea',
364
-                        'label'               => '[DATETIME_LIST]',
365
-                        'type'                => 'string',
366
-                        'required'            => true,
367
-                        'validation'          => true,
368
-                        'format'              => '%s',
369
-                        'css_class'           => 'large-text',
370
-                        'rows'                => '10',
371
-                        'shortcodes_required' => array('[DATETIME_LIST]'),
372
-                    ),
373
-                ),
374
-            ),
375
-        );
376
-    }
377
-
378
-
379
-    /**
380
-     * See definition of this class in parent
381
-     */
382
-    protected function _set_default_message_types()
383
-    {
384
-        $this->_default_message_types = array(
385
-            'payment',
386
-            'payment_refund',
387
-            'registration',
388
-            'not_approved_registration',
389
-            'pending_approval',
390
-        );
391
-    }
392
-
393
-
394
-    /**
395
-     * @see   definition of this class in parent
396
-     * @since 4.5.0
397
-     */
398
-    protected function _set_valid_message_types()
399
-    {
400
-        $this->_valid_message_types = array(
401
-            'payment',
402
-            'registration',
403
-            'not_approved_registration',
404
-            'declined_registration',
405
-            'cancelled_registration',
406
-            'pending_approval',
407
-            'registration_summary',
408
-            'payment_reminder',
409
-            'payment_declined',
410
-            'payment_refund',
411
-        );
412
-    }
413
-
414
-
415
-    /**
416
-     * setting up admin_settings_fields for messenger.
417
-     */
418
-    protected function _set_admin_settings_fields()
419
-    {
420
-    }
421
-
422
-    /**
423
-     * We just deliver the messages don't kill us!!
424
-     *
425
-     * @return bool|WP_Error true if message delivered, false if it didn't deliver OR bubble up any error object if
426
-     *              present.
427
-     * @throws EE_Error
428
-     * @throws \TijsVerkoyen\CssToInlineStyles\Exception
429
-     */
430
-    protected function _send_message()
431
-    {
432
-        $success = wp_mail(
433
-            $this->_to,
434
-            // some old values for subject may be expecting HTML entities to be decoded in the subject
435
-            // and subjects aren't interpreted as HTML, so there should be no HTML in them
436
-            wp_strip_all_tags(wp_specialchars_decode($this->_subject, ENT_QUOTES)),
437
-            $this->_body(),
438
-            $this->_headers()
439
-        );
440
-        if (! $success) {
441
-            EE_Error::add_error(
442
-                sprintf(
443
-                    esc_html__(
444
-                        'The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s',
445
-                        'event_espresso'
446
-                    ),
447
-                    $this->_to,
448
-                    $this->_from,
449
-                    '<br />'
450
-                ),
451
-                __FILE__,
452
-                __FUNCTION__,
453
-                __LINE__
454
-            );
455
-        }
456
-        return $success;
457
-    }
458
-
459
-
460
-    /**
461
-     * see parent for definition
462
-     *
463
-     * @return string html body of the message content and the related css.
464
-     * @throws EE_Error
465
-     * @throws \TijsVerkoyen\CssToInlineStyles\Exception
466
-     */
467
-    protected function _preview()
468
-    {
469
-        return $this->_body(true);
470
-    }
471
-
472
-
473
-    /**
474
-     * Setup headers for email
475
-     *
476
-     * @access protected
477
-     * @return string formatted header for email
478
-     */
479
-    protected function _headers()
480
-    {
481
-        $this->_ensure_has_from_email_address();
482
-        $from    = $this->_from;
483
-        $headers = array(
484
-            'From:' . $from,
485
-            'Reply-To:' . $from,
486
-            'Content-Type:text/html; charset=utf-8',
487
-        );
488
-
489
-        /**
490
-         * Second condition added as a result of https://events.codebasehq.com/projects/event-espresso/tickets/11416 to
491
-         * cover back compat where there may be users who have saved cc values in their db for the newsletter message
492
-         * type which they are no longer able to change.
493
-         */
494
-        if (! empty($this->_cc) && ! $this->_incoming_message_type instanceof EE_Newsletter_message_type) {
495
-            $headers[] = 'cc: ' . $this->_cc;
496
-        }
497
-
498
-        // but wait!  Header's for the from is NOT reliable because some plugins don't respect From: as set in the
499
-        // header.
500
-        add_filter('wp_mail_from', array($this, 'set_from_address'), 100);
501
-        add_filter('wp_mail_from_name', array($this, 'set_from_name'), 100);
502
-        return apply_filters('FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this);
503
-    }
504
-
505
-
506
-    /**
507
-     * This simply ensures that the from address is not empty.  If it is, then we use whatever is set as the site email
508
-     * address for the from address to avoid problems with sending emails.
509
-     */
510
-    protected function _ensure_has_from_email_address()
511
-    {
512
-        if (empty($this->_from)) {
513
-            $this->_from = get_bloginfo('admin_email');
514
-        }
515
-    }
516
-
517
-
518
-    /**
519
-     * This simply parses whatever is set as the $_from address and determines if it is in the format {name} <{email}>
520
-     * or just {email} and returns an array with the "from_name" and "from_email" as the values. Note from_name *MAY*
521
-     * be empty
522
-     *
523
-     * @since 4.3.1
524
-     * @return array
525
-     */
526
-    private function _parse_from()
527
-    {
528
-        if (strpos($this->_from, '<') !== false) {
529
-            $from_name = substr($this->_from, 0, strpos($this->_from, '<') - 1);
530
-            $from_name = str_replace('"', '', $from_name);
531
-            $from_name = trim($from_name);
532
-
533
-            $from_email = substr($this->_from, strpos($this->_from, '<') + 1);
534
-            $from_email = str_replace('>', '', $from_email);
535
-            $from_email = trim($from_email);
536
-        } elseif (trim($this->_from) !== '') {
537
-            $from_name  = '';
538
-            $from_email = trim($this->_from);
539
-        } else {
540
-            $from_name = $from_email = '';
541
-        }
542
-        return array($from_name, $from_email);
543
-    }
544
-
545
-
546
-    /**
547
-     * Callback for the wp_mail_from filter.
548
-     *
549
-     * @since 4.3.1
550
-     * @param string $from_email What the original from_email is.
551
-     * @return string
552
-     */
553
-    public function set_from_address($from_email)
554
-    {
555
-        $parsed_from = $this->_parse_from();
556
-        // includes fallback if the parsing failed.
557
-        $from_email = is_array($parsed_from) && ! empty($parsed_from[1])
558
-            ? $parsed_from[1]
559
-            : get_bloginfo('admin_email');
560
-        return $from_email;
561
-    }
562
-
563
-
564
-    /**
565
-     * Callback fro the wp_mail_from_name filter.
566
-     *
567
-     * @since 4.3.1
568
-     * @param string $from_name The original from_name.
569
-     * @return string
570
-     */
571
-    public function set_from_name($from_name)
572
-    {
573
-        $parsed_from = $this->_parse_from();
574
-        if (is_array($parsed_from) && ! empty($parsed_from[0])) {
575
-            $from_name = $parsed_from[0];
576
-        }
577
-
578
-        // if from name is "WordPress" let's sub in the site name instead (more friendly!)
579
-        // but realize the default name is HTML entity-encoded
580
-        $from_name = $from_name == 'WordPress' ? wp_specialchars_decode(get_bloginfo(), ENT_QUOTES) : $from_name;
581
-
582
-        return $from_name;
583
-    }
584
-
585
-
586
-    /**
587
-     * setup body for email
588
-     *
589
-     * @param bool $preview will determine whether this is preview template or not.
590
-     * @return string formatted body for email.
591
-     * @throws EE_Error
592
-     * @throws \TijsVerkoyen\CssToInlineStyles\Exception
593
-     */
594
-    protected function _body($preview = false)
595
-    {
596
-        // setup template args!
597
-        $this->_template_args = array(
598
-            'subject'   => $this->_subject,
599
-            'from'      => $this->_from,
600
-            'main_body' => wpautop($this->_content),
601
-        );
602
-        $body                 = $this->_get_main_template($preview);
603
-
604
-        /**
605
-         * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched.
606
-         *
607
-         * @type    bool $preview Indicates whether a preview is being generated or not.
608
-         * @return  bool    true  indicates to use the inliner, false bypasses it.
609
-         */
610
-        if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) {
611
-            // require CssToInlineStyles library and its dependencies via composer autoloader
612
-            require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php';
613
-
614
-            // now if this isn't a preview, let's setup the body so it has inline styles
615
-            if (! $preview || ($preview && defined('DOING_AJAX'))) {
616
-                $style = file_get_contents(
617
-                    $this->get_variation(
618
-                        $this->_tmp_pack,
619
-                        $this->_incoming_message_type->name,
620
-                        false,
621
-                        'main',
622
-                        $this->_variation
623
-                    ),
624
-                    true
625
-                );
626
-                $CSS   = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($body, $style);
627
-                // for some reason the library has a bracket and new line at the beginning.  This takes care of that.
628
-                $body  = ltrim($CSS->convert(true), ">\n");
629
-                // see https://events.codebasehq.com/projects/event-espresso/tickets/8609
630
-                $body  = ltrim($body, "<?");
631
-            }
632
-        }
633
-        return $body;
634
-    }
635
-
636
-
637
-    /**
638
-     * This just returns any existing test settings that might be saved in the database
639
-     *
640
-     * @access public
641
-     * @return array
642
-     */
643
-    public function get_existing_test_settings()
644
-    {
645
-        $settings = parent::get_existing_test_settings();
646
-        // override subject if present because we always want it to be fresh.
647
-        if (is_array($settings) && ! empty($settings['subject'])) {
648
-            $settings['subject'] = sprintf(esc_html__('Test email sent from %s', 'event_espresso'), get_bloginfo('name'));
649
-        }
650
-        return $settings;
651
-    }
8
+	/**
9
+	 * To field for email
10
+	 * @var string
11
+	 */
12
+	protected $_to = '';
13
+
14
+
15
+	/**
16
+	 * CC field for email.
17
+	 * @var string
18
+	 */
19
+	protected $_cc = '';
20
+
21
+	/**
22
+	 * From field for email
23
+	 * @var string
24
+	 */
25
+	protected $_from = '';
26
+
27
+
28
+	/**
29
+	 * Subject field for email
30
+	 * @var string
31
+	 */
32
+	protected $_subject = '';
33
+
34
+
35
+	/**
36
+	 * Content field for email
37
+	 * @var string
38
+	 */
39
+	protected $_content = '';
40
+
41
+
42
+	/**
43
+	 * constructor
44
+	 *
45
+	 * @access public
46
+	 */
47
+	public function __construct()
48
+	{
49
+		// set name and description properties
50
+		$this->name                = 'email';
51
+		$this->description         = sprintf(
52
+			esc_html__(
53
+				'This messenger delivers messages via email using the built-in %s function included with WordPress',
54
+				'event_espresso'
55
+			),
56
+			'<code>wp_mail</code>'
57
+		);
58
+		$this->label               = array(
59
+			'singular' => esc_html__('email', 'event_espresso'),
60
+			'plural'   => esc_html__('emails', 'event_espresso'),
61
+		);
62
+		$this->activate_on_install = true;
63
+
64
+		// we're using defaults so let's call parent constructor that will take care of setting up all the other
65
+		// properties
66
+		parent::__construct();
67
+	}
68
+
69
+
70
+	/**
71
+	 * see abstract declaration in parent class for details.
72
+	 */
73
+	protected function _set_admin_pages()
74
+	{
75
+		$this->admin_registered_pages = array(
76
+			'events_edit' => true,
77
+		);
78
+	}
79
+
80
+
81
+	/**
82
+	 * see abstract declaration in parent class for details
83
+	 */
84
+	protected function _set_valid_shortcodes()
85
+	{
86
+		// remember by leaving the other fields not set, those fields will inherit the valid shortcodes from the
87
+		// message type.
88
+		$this->_valid_shortcodes = array(
89
+			'to'   => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
90
+			'cc' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
91
+			'from' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
92
+		);
93
+	}
94
+
95
+
96
+	/**
97
+	 * see abstract declaration in parent class for details
98
+	 *
99
+	 * @access protected
100
+	 * @return void
101
+	 */
102
+	protected function _set_validator_config()
103
+	{
104
+		$valid_shortcodes = $this->get_valid_shortcodes();
105
+
106
+		$this->_validator_config = array(
107
+			'to'            => array(
108
+				'shortcodes' => $valid_shortcodes['to'],
109
+				'type'       => 'email',
110
+			),
111
+			'cc' => array(
112
+				'shortcodes' => $valid_shortcodes['to'],
113
+				'type' => 'email',
114
+			),
115
+			'from'          => array(
116
+				'shortcodes' => $valid_shortcodes['from'],
117
+				'type'       => 'email',
118
+			),
119
+			'subject'       => array(
120
+				'shortcodes' => array(
121
+					'organization',
122
+					'primary_registration_details',
123
+					'event_author',
124
+					'primary_registration_details',
125
+					'recipient_details',
126
+				),
127
+			),
128
+			'content'       => array(
129
+				'shortcodes' => array(
130
+					'event_list',
131
+					'attendee_list',
132
+					'ticket_list',
133
+					'organization',
134
+					'primary_registration_details',
135
+					'primary_registration_list',
136
+					'event_author',
137
+					'recipient_details',
138
+					'recipient_list',
139
+					'transaction',
140
+					'messenger',
141
+				),
142
+			),
143
+			'attendee_list' => array(
144
+				'shortcodes' => array('attendee', 'event_list', 'ticket_list'),
145
+				'required'   => array('[ATTENDEE_LIST]'),
146
+			),
147
+			'event_list'    => array(
148
+				'shortcodes' => array(
149
+					'event',
150
+					'attendee_list',
151
+					'ticket_list',
152
+					'venue',
153
+					'datetime_list',
154
+					'attendee',
155
+					'primary_registration_details',
156
+					'primary_registration_list',
157
+					'event_author',
158
+					'recipient_details',
159
+					'recipient_list',
160
+				),
161
+				'required'   => array('[EVENT_LIST]'),
162
+			),
163
+			'ticket_list'   => array(
164
+				'shortcodes' => array(
165
+					'event_list',
166
+					'attendee_list',
167
+					'ticket',
168
+					'datetime_list',
169
+					'primary_registration_details',
170
+					'recipient_details',
171
+				),
172
+				'required'   => array('[TICKET_LIST]'),
173
+			),
174
+			'datetime_list' => array(
175
+				'shortcodes' => array('datetime'),
176
+				'required'   => array('[DATETIME_LIST]'),
177
+			),
178
+		);
179
+	}
180
+
181
+
182
+	/**
183
+	 * @see   parent EE_messenger class for docs
184
+	 * @since 4.5.0
185
+	 */
186
+	public function do_secondary_messenger_hooks($sending_messenger_name)
187
+	{
188
+		if ($sending_messenger_name === 'html') {
189
+			add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
190
+		}
191
+	}
192
+
193
+
194
+	public function add_email_css(
195
+		$variation_path,
196
+		$messenger,
197
+		$message_type,
198
+		$type,
199
+		$variation,
200
+		$file_extension,
201
+		$url,
202
+		EE_Messages_Template_Pack $template_pack
203
+	) {
204
+		// prevent recursion on this callback.
205
+		remove_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10);
206
+		$variation = $this->get_variation($template_pack, $message_type, $url, 'main', $variation, false);
207
+
208
+		add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
209
+		return $variation;
210
+	}
211
+
212
+
213
+	/**
214
+	 * See parent for details
215
+	 *
216
+	 * @access protected
217
+	 * @return void
218
+	 */
219
+	protected function _set_test_settings_fields()
220
+	{
221
+		$this->_test_settings_fields = array(
222
+			'to'      => array(
223
+				'input'      => 'text',
224
+				'label'      => esc_html__('Send a test email to', 'event_espresso'),
225
+				'type'       => 'email',
226
+				'required'   => false,
227
+				'validation' => true,
228
+				'css_class'  => 'large-text',
229
+				'format'     => '%s',
230
+				'default'    => get_bloginfo('admin_email'),
231
+			),
232
+			'subject' => array(
233
+				'input'      => 'hidden',
234
+				'label'      => '',
235
+				'type'       => 'string',
236
+				'required'   => false,
237
+				'validation' => false,
238
+				'format'     => '%s',
239
+				'value'      => sprintf(esc_html__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')),
240
+				'default'    => '',
241
+				'css_class'  => '',
242
+			),
243
+		);
244
+	}
245
+
246
+
247
+	/**
248
+	 * _set_template_fields
249
+	 * This sets up the fields that a messenger requires for the message to go out.
250
+	 *
251
+	 * @access  protected
252
+	 * @return void
253
+	 */
254
+	protected function _set_template_fields()
255
+	{
256
+		// any extra template fields that are NOT used by the messenger but will get used by a messenger field for
257
+		// shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field
258
+		// they relate to.  This is important for the Messages_admin to know what fields to display to the user.
259
+		//  Also, notice that the "values" are equal to the field type that messages admin will use to know what
260
+		// kind of field to display. The values ALSO have one index labeled "shortcode".  the values in that array
261
+		// indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be
262
+		// displayed.  If the required shortcode isn't part of the shortcodes array then the field is not needed and
263
+		// will not be displayed/parsed.
264
+		$this->_template_fields = array(
265
+			'to'      => array(
266
+				'input'      => 'text',
267
+				'label'      => esc_html_x(
268
+					'To',
269
+					'Label for the "To" field for email addresses',
270
+					'event_espresso'
271
+				),
272
+				'type'       => 'string',
273
+				'required'   => true,
274
+				'validation' => true,
275
+				'css_class'  => 'large-text',
276
+				'format'     => '%s',
277
+			),
278
+			'cc'      => array(
279
+				'input'      => 'text',
280
+				'label'      => esc_html_x(
281
+					'CC',
282
+					'Label for the "Carbon Copy" field used for additional email addresses',
283
+					'event_espresso'
284
+				),
285
+				'type'       => 'string',
286
+				'required'   => false,
287
+				'validation' => true,
288
+				'css_class'  => 'large-text',
289
+				'format'     => '%s',
290
+			),
291
+			'from'    => array(
292
+				'input'      => 'text',
293
+				'label'      => esc_html_x(
294
+					'From',
295
+					'Label for the "From" field for email addresses.',
296
+					'event_espresso'
297
+				),
298
+				'type'       => 'string',
299
+				'required'   => true,
300
+				'validation' => true,
301
+				'css_class'  => 'large-text',
302
+				'format'     => '%s',
303
+			),
304
+			'subject' => array(
305
+				'input'      => 'text',
306
+				'label'      => esc_html_x(
307
+					'Subject',
308
+					'Label for the "Subject" field (short description of contents) for emails.',
309
+					'event_espresso'
310
+				),
311
+				'type'       => 'string',
312
+				'required'   => true,
313
+				'validation' => true,
314
+				'css_class'  => 'large-text',
315
+				'format'     => '%s',
316
+			),
317
+			'content' => '',
318
+			// left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field.
319
+			'extra'   => array(
320
+				'content' => array(
321
+					'main'          => array(
322
+						'input'      => 'wp_editor',
323
+						'label'      => esc_html__('Main Content', 'event_espresso'),
324
+						'type'       => 'string',
325
+						'required'   => true,
326
+						'validation' => true,
327
+						'format'     => '%s',
328
+						'rows'       => '15',
329
+					),
330
+					'event_list'    => array(
331
+						'input'               => 'wp_editor',
332
+						'label'               => '[EVENT_LIST]',
333
+						'type'                => 'string',
334
+						'required'            => true,
335
+						'validation'          => true,
336
+						'format'              => '%s',
337
+						'rows'                => '15',
338
+						'shortcodes_required' => array('[EVENT_LIST]'),
339
+					),
340
+					'attendee_list' => array(
341
+						'input'               => 'textarea',
342
+						'label'               => '[ATTENDEE_LIST]',
343
+						'type'                => 'string',
344
+						'required'            => true,
345
+						'validation'          => true,
346
+						'format'              => '%s',
347
+						'css_class'           => 'large-text',
348
+						'rows'                => '5',
349
+						'shortcodes_required' => array('[ATTENDEE_LIST]'),
350
+					),
351
+					'ticket_list'   => array(
352
+						'input'               => 'textarea',
353
+						'label'               => '[TICKET_LIST]',
354
+						'type'                => 'string',
355
+						'required'            => true,
356
+						'validation'          => true,
357
+						'format'              => '%s',
358
+						'css_class'           => 'large-text',
359
+						'rows'                => '10',
360
+						'shortcodes_required' => array('[TICKET_LIST]'),
361
+					),
362
+					'datetime_list' => array(
363
+						'input'               => 'textarea',
364
+						'label'               => '[DATETIME_LIST]',
365
+						'type'                => 'string',
366
+						'required'            => true,
367
+						'validation'          => true,
368
+						'format'              => '%s',
369
+						'css_class'           => 'large-text',
370
+						'rows'                => '10',
371
+						'shortcodes_required' => array('[DATETIME_LIST]'),
372
+					),
373
+				),
374
+			),
375
+		);
376
+	}
377
+
378
+
379
+	/**
380
+	 * See definition of this class in parent
381
+	 */
382
+	protected function _set_default_message_types()
383
+	{
384
+		$this->_default_message_types = array(
385
+			'payment',
386
+			'payment_refund',
387
+			'registration',
388
+			'not_approved_registration',
389
+			'pending_approval',
390
+		);
391
+	}
392
+
393
+
394
+	/**
395
+	 * @see   definition of this class in parent
396
+	 * @since 4.5.0
397
+	 */
398
+	protected function _set_valid_message_types()
399
+	{
400
+		$this->_valid_message_types = array(
401
+			'payment',
402
+			'registration',
403
+			'not_approved_registration',
404
+			'declined_registration',
405
+			'cancelled_registration',
406
+			'pending_approval',
407
+			'registration_summary',
408
+			'payment_reminder',
409
+			'payment_declined',
410
+			'payment_refund',
411
+		);
412
+	}
413
+
414
+
415
+	/**
416
+	 * setting up admin_settings_fields for messenger.
417
+	 */
418
+	protected function _set_admin_settings_fields()
419
+	{
420
+	}
421
+
422
+	/**
423
+	 * We just deliver the messages don't kill us!!
424
+	 *
425
+	 * @return bool|WP_Error true if message delivered, false if it didn't deliver OR bubble up any error object if
426
+	 *              present.
427
+	 * @throws EE_Error
428
+	 * @throws \TijsVerkoyen\CssToInlineStyles\Exception
429
+	 */
430
+	protected function _send_message()
431
+	{
432
+		$success = wp_mail(
433
+			$this->_to,
434
+			// some old values for subject may be expecting HTML entities to be decoded in the subject
435
+			// and subjects aren't interpreted as HTML, so there should be no HTML in them
436
+			wp_strip_all_tags(wp_specialchars_decode($this->_subject, ENT_QUOTES)),
437
+			$this->_body(),
438
+			$this->_headers()
439
+		);
440
+		if (! $success) {
441
+			EE_Error::add_error(
442
+				sprintf(
443
+					esc_html__(
444
+						'The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s',
445
+						'event_espresso'
446
+					),
447
+					$this->_to,
448
+					$this->_from,
449
+					'<br />'
450
+				),
451
+				__FILE__,
452
+				__FUNCTION__,
453
+				__LINE__
454
+			);
455
+		}
456
+		return $success;
457
+	}
458
+
459
+
460
+	/**
461
+	 * see parent for definition
462
+	 *
463
+	 * @return string html body of the message content and the related css.
464
+	 * @throws EE_Error
465
+	 * @throws \TijsVerkoyen\CssToInlineStyles\Exception
466
+	 */
467
+	protected function _preview()
468
+	{
469
+		return $this->_body(true);
470
+	}
471
+
472
+
473
+	/**
474
+	 * Setup headers for email
475
+	 *
476
+	 * @access protected
477
+	 * @return string formatted header for email
478
+	 */
479
+	protected function _headers()
480
+	{
481
+		$this->_ensure_has_from_email_address();
482
+		$from    = $this->_from;
483
+		$headers = array(
484
+			'From:' . $from,
485
+			'Reply-To:' . $from,
486
+			'Content-Type:text/html; charset=utf-8',
487
+		);
488
+
489
+		/**
490
+		 * Second condition added as a result of https://events.codebasehq.com/projects/event-espresso/tickets/11416 to
491
+		 * cover back compat where there may be users who have saved cc values in their db for the newsletter message
492
+		 * type which they are no longer able to change.
493
+		 */
494
+		if (! empty($this->_cc) && ! $this->_incoming_message_type instanceof EE_Newsletter_message_type) {
495
+			$headers[] = 'cc: ' . $this->_cc;
496
+		}
497
+
498
+		// but wait!  Header's for the from is NOT reliable because some plugins don't respect From: as set in the
499
+		// header.
500
+		add_filter('wp_mail_from', array($this, 'set_from_address'), 100);
501
+		add_filter('wp_mail_from_name', array($this, 'set_from_name'), 100);
502
+		return apply_filters('FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this);
503
+	}
504
+
505
+
506
+	/**
507
+	 * This simply ensures that the from address is not empty.  If it is, then we use whatever is set as the site email
508
+	 * address for the from address to avoid problems with sending emails.
509
+	 */
510
+	protected function _ensure_has_from_email_address()
511
+	{
512
+		if (empty($this->_from)) {
513
+			$this->_from = get_bloginfo('admin_email');
514
+		}
515
+	}
516
+
517
+
518
+	/**
519
+	 * This simply parses whatever is set as the $_from address and determines if it is in the format {name} <{email}>
520
+	 * or just {email} and returns an array with the "from_name" and "from_email" as the values. Note from_name *MAY*
521
+	 * be empty
522
+	 *
523
+	 * @since 4.3.1
524
+	 * @return array
525
+	 */
526
+	private function _parse_from()
527
+	{
528
+		if (strpos($this->_from, '<') !== false) {
529
+			$from_name = substr($this->_from, 0, strpos($this->_from, '<') - 1);
530
+			$from_name = str_replace('"', '', $from_name);
531
+			$from_name = trim($from_name);
532
+
533
+			$from_email = substr($this->_from, strpos($this->_from, '<') + 1);
534
+			$from_email = str_replace('>', '', $from_email);
535
+			$from_email = trim($from_email);
536
+		} elseif (trim($this->_from) !== '') {
537
+			$from_name  = '';
538
+			$from_email = trim($this->_from);
539
+		} else {
540
+			$from_name = $from_email = '';
541
+		}
542
+		return array($from_name, $from_email);
543
+	}
544
+
545
+
546
+	/**
547
+	 * Callback for the wp_mail_from filter.
548
+	 *
549
+	 * @since 4.3.1
550
+	 * @param string $from_email What the original from_email is.
551
+	 * @return string
552
+	 */
553
+	public function set_from_address($from_email)
554
+	{
555
+		$parsed_from = $this->_parse_from();
556
+		// includes fallback if the parsing failed.
557
+		$from_email = is_array($parsed_from) && ! empty($parsed_from[1])
558
+			? $parsed_from[1]
559
+			: get_bloginfo('admin_email');
560
+		return $from_email;
561
+	}
562
+
563
+
564
+	/**
565
+	 * Callback fro the wp_mail_from_name filter.
566
+	 *
567
+	 * @since 4.3.1
568
+	 * @param string $from_name The original from_name.
569
+	 * @return string
570
+	 */
571
+	public function set_from_name($from_name)
572
+	{
573
+		$parsed_from = $this->_parse_from();
574
+		if (is_array($parsed_from) && ! empty($parsed_from[0])) {
575
+			$from_name = $parsed_from[0];
576
+		}
577
+
578
+		// if from name is "WordPress" let's sub in the site name instead (more friendly!)
579
+		// but realize the default name is HTML entity-encoded
580
+		$from_name = $from_name == 'WordPress' ? wp_specialchars_decode(get_bloginfo(), ENT_QUOTES) : $from_name;
581
+
582
+		return $from_name;
583
+	}
584
+
585
+
586
+	/**
587
+	 * setup body for email
588
+	 *
589
+	 * @param bool $preview will determine whether this is preview template or not.
590
+	 * @return string formatted body for email.
591
+	 * @throws EE_Error
592
+	 * @throws \TijsVerkoyen\CssToInlineStyles\Exception
593
+	 */
594
+	protected function _body($preview = false)
595
+	{
596
+		// setup template args!
597
+		$this->_template_args = array(
598
+			'subject'   => $this->_subject,
599
+			'from'      => $this->_from,
600
+			'main_body' => wpautop($this->_content),
601
+		);
602
+		$body                 = $this->_get_main_template($preview);
603
+
604
+		/**
605
+		 * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched.
606
+		 *
607
+		 * @type    bool $preview Indicates whether a preview is being generated or not.
608
+		 * @return  bool    true  indicates to use the inliner, false bypasses it.
609
+		 */
610
+		if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) {
611
+			// require CssToInlineStyles library and its dependencies via composer autoloader
612
+			require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php';
613
+
614
+			// now if this isn't a preview, let's setup the body so it has inline styles
615
+			if (! $preview || ($preview && defined('DOING_AJAX'))) {
616
+				$style = file_get_contents(
617
+					$this->get_variation(
618
+						$this->_tmp_pack,
619
+						$this->_incoming_message_type->name,
620
+						false,
621
+						'main',
622
+						$this->_variation
623
+					),
624
+					true
625
+				);
626
+				$CSS   = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($body, $style);
627
+				// for some reason the library has a bracket and new line at the beginning.  This takes care of that.
628
+				$body  = ltrim($CSS->convert(true), ">\n");
629
+				// see https://events.codebasehq.com/projects/event-espresso/tickets/8609
630
+				$body  = ltrim($body, "<?");
631
+			}
632
+		}
633
+		return $body;
634
+	}
635
+
636
+
637
+	/**
638
+	 * This just returns any existing test settings that might be saved in the database
639
+	 *
640
+	 * @access public
641
+	 * @return array
642
+	 */
643
+	public function get_existing_test_settings()
644
+	{
645
+		$settings = parent::get_existing_test_settings();
646
+		// override subject if present because we always want it to be fresh.
647
+		if (is_array($settings) && ! empty($settings['subject'])) {
648
+			$settings['subject'] = sprintf(esc_html__('Test email sent from %s', 'event_espresso'), get_bloginfo('name'));
649
+		}
650
+		return $settings;
651
+	}
652 652
 }
Please login to merge, or discard this patch.