Completed
Branch FET/11183/improvements-to-pue-... (232f50)
by
unknown
43:46 queued 26:36
created
core/helpers/EEH_Qtip_Loader.helper.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	public static function instance() {
34 34
 		// check if class object is instantiated
35
-		if ( self::$_instance === NULL  or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EEH_Qtip_Loader )) {
35
+		if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EEH_Qtip_Loader)) {
36 36
 			self::$_instance = new self();
37 37
 		}
38 38
 		return self::$_instance;
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 	 */
49 49
 	private function __construct() {
50 50
 		//let's just make sure this is instantiated in the right place.
51
-		if ( did_action( 'wp_print_styles' ) || did_action( 'admin_head' )) {
52
-			EE_Error::doing_it_wrong( 'EEH_Qtip_Loader', __('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso' ), '4.1' );
51
+		if (did_action('wp_print_styles') || did_action('admin_head')) {
52
+			EE_Error::doing_it_wrong('EEH_Qtip_Loader', __('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso'), '4.1');
53 53
 		}
54 54
 	}
55 55
 
@@ -61,25 +61,25 @@  discard block
 block discarded – undo
61 61
 	 * @return void
62 62
 	 */
63 63
 	public function register_and_enqueue() {
64
-		$qtips_js = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.js' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.js';
65
-		$qtip_map = EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.map';
66
-		$qtipcss = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.css' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.css';
64
+		$qtips_js = ! defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.js' : EE_THIRD_PARTY_URL.'qtip/jquery.qtip.js';
65
+		$qtip_map = EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.map';
66
+		$qtipcss = ! defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.css' : EE_THIRD_PARTY_URL.'qtip/jquery.qtip.css';
67 67
 
68
-		wp_register_script('qtip-map', $qtip_map, array(), '3', TRUE );
69
-		wp_register_script('qtip', $qtips_js, array('jquery'), '3.0.3', TRUE );
70
-		wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS . 'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, TRUE );
68
+		wp_register_script('qtip-map', $qtip_map, array(), '3', TRUE);
69
+		wp_register_script('qtip', $qtips_js, array('jquery'), '3.0.3', TRUE);
70
+		wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS.'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, TRUE);
71 71
 
72
-		wp_register_style('qtip-css', $qtipcss, array(), '2.2' );
72
+		wp_register_style('qtip-css', $qtipcss, array(), '2.2');
73 73
 
74 74
 		//k now let's see if there are any registered qtips.  If there are, then we need to setup the localized script for ee-qtip-helper.js (and enqueue ee-qtip-helper.js of course!)
75
-		if ( !empty( $this->_qtips ) ) {
75
+		if ( ! empty($this->_qtips)) {
76 76
 			wp_enqueue_script('ee-qtip-helper');
77 77
 			wp_enqueue_style('qtip-css');
78 78
 			$qtips = array();
79
-			foreach ( $this->_qtips as $qtip ) {
79
+			foreach ($this->_qtips as $qtip) {
80 80
 				$qts = $qtip->get_tips();
81
-				foreach ( $qts as $qt ) {
82
-					if ( ! $qt instanceof EE_Qtip )
81
+				foreach ($qts as $qt) {
82
+					if ( ! $qt instanceof EE_Qtip)
83 83
 						continue;
84 84
 					$qtips[] = array(
85 85
 						'content_id' => $qt->content_id,
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 						);
89 89
 				}
90 90
 			}
91
-			if ( !empty($qtips) )
92
-				wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ) );
91
+			if ( ! empty($qtips))
92
+				wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array('qtips' => $qtips));
93 93
 
94 94
 		} else {
95 95
 			//qtips has been requested without any registration (so assuming its just directly used in the admin).
@@ -111,24 +111,24 @@  discard block
 block discarded – undo
111 111
 	 * @param  string|array $configname name of the Qtip class (full class name is expected and will be used for looking for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array, then we loop through the array to instantiate and setup the qtips]
112 112
 	 * @return void
113 113
 	 */
114
-	public function register( $configname, $paths = array() ) {
114
+	public function register($configname, $paths = array()) {
115 115
 
116 116
 		//let's just make sure this is instantiated in the right place.
117
-		if ( did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts') ) {
118
-			EE_Error::doing_it_wrong( 'EEH_Qtip_Loader->register()', __('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso' ), '4.1' );
117
+		if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) {
118
+			EE_Error::doing_it_wrong('EEH_Qtip_Loader->register()', __('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso'), '4.1');
119 119
 		}
120 120
 
121 121
 		$configname = (array) $configname; //typecast to array
122
-		foreach ( $configname as $config ) {
123
-			$this->_register( $config, $paths );
122
+		foreach ($configname as $config) {
123
+			$this->_register($config, $paths);
124 124
 		}
125 125
 
126 126
 		//hook into appropriate footer
127 127
 		$footer_action = is_admin() ? 'admin_footer' : 'wp_footer';
128
-		add_action($footer_action, array($this, 'setup_qtip'), 10 );
128
+		add_action($footer_action, array($this, 'setup_qtip'), 10);
129 129
 
130 130
 		//make sure we "turn on" qtip js.
131
-		add_filter('FHEE_load_qtip', '__return_true' );
131
+		add_filter('FHEE_load_qtip', '__return_true');
132 132
 	}
133 133
 
134 134
 
@@ -142,15 +142,15 @@  discard block
 block discarded – undo
142 142
 	 * @throws EE_Error
143 143
 	 * @return void
144 144
 	 */
145
-	private function _register( $config, $paths ) {
145
+	private function _register($config, $paths) {
146 146
 		//before doing anything we have to make sure that EE_Qtip_Config parent is required.
147
-		EE_Registry::instance()->load_lib( 'Qtip_Config', array(), TRUE );
147
+		EE_Registry::instance()->load_lib('Qtip_Config', array(), TRUE);
148 148
 
149
-		if ( !empty( $paths ) ) {
149
+		if ( ! empty($paths)) {
150 150
 			$paths = (array) $paths;
151
-			foreach ( $paths as $path ) {
152
-				$path = $path . $config . '.lib.php';
153
-				if ( !is_readable($path ) ) {
151
+			foreach ($paths as $path) {
152
+				$path = $path.$config.'.lib.php';
153
+				if ( ! is_readable($path)) {
154 154
 					continue;
155 155
 				} else {
156 156
 					require_once $path;
@@ -159,26 +159,26 @@  discard block
 block discarded – undo
159 159
 		}
160 160
 
161 161
 		//does class exist at this point?  If it does then let's instantiate.  If it doesn't then let's continue with other paths.
162
-		if ( !class_exists($config) ) {
163
-			$path = EE_LIBRARIES . 'qtips/' . $config . '.lib.php';
164
-			if ( !is_readable($path ) ) {
165
-				throw new EE_Error( sprintf( __('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable.  Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config ) );
162
+		if ( ! class_exists($config)) {
163
+			$path = EE_LIBRARIES.'qtips/'.$config.'.lib.php';
164
+			if ( ! is_readable($path)) {
165
+				throw new EE_Error(sprintf(__('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable.  Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config));
166 166
 			} else {
167 167
 				require_once $path;
168 168
 			}
169 169
 		}
170 170
 
171 171
 		//now we attempt a class_exists one more time.
172
-		if ( !class_exists( $config ) )
173
-			throw new EE_Error( sprintf( __('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config ) );
172
+		if ( ! class_exists($config))
173
+			throw new EE_Error(sprintf(__('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config));
174 174
 
175 175
 		//made it HERE?  FINALLY, let's get things setup.
176 176
 		$a = new ReflectionClass($config);
177 177
 		$qtip = $a->newInstance();
178 178
 
179 179
 		//verify that $qtip is a valid object
180
-		if ( ! $qtip instanceof EE_Qtip_Config )
181
-			throw new EE_Error( sprintf( esc_html__( 'The class given for the Qtip loader (%1$s) is not a child of the %2$sEE_Qtip_Config%3$s class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config, '<strong>', '</strong>' ) );
180
+		if ( ! $qtip instanceof EE_Qtip_Config)
181
+			throw new EE_Error(sprintf(esc_html__('The class given for the Qtip loader (%1$s) is not a child of the %2$sEE_Qtip_Config%3$s class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config, '<strong>', '</strong>'));
182 182
 
183 183
 		$this->_qtips[] = $a->newInstance();
184 184
 
@@ -194,12 +194,12 @@  discard block
 block discarded – undo
194 194
 	 * @return void
195 195
 	 */
196 196
 	public function setup_qtip() {
197
-		if ( empty( $this->_qtips ) )
197
+		if (empty($this->_qtips))
198 198
 			return; //no qtips!
199 199
 
200 200
 		$content = array();
201 201
 
202
-		foreach ( $this->_qtips as $qtip ) {
202
+		foreach ($this->_qtips as $qtip) {
203 203
 			$content[] = $this->_generate_content_container($qtip);
204 204
 		}
205 205
 
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
 	private function _generate_content_container($qtip) {
217 217
 		$qts = $qtip->get_tips();
218 218
 		$content = array();
219
-		foreach ( $qts as $qt ) {
220
-			if ( ! $qt instanceof EE_Qtip )
219
+		foreach ($qts as $qt) {
220
+			if ( ! $qt instanceof EE_Qtip)
221 221
 				continue;
222
-			$content[] = '<div class="ee-qtip-helper-content hidden" id="' . $qt->content_id . '">' . $qt->content . '</div>';
222
+			$content[] = '<div class="ee-qtip-helper-content hidden" id="'.$qt->content_id.'">'.$qt->content.'</div>';
223 223
 		}
224 224
 
225 225
 		return implode('<br />', $content);
Please login to merge, or discard this patch.
core/domain/DomainBase.php 2 patches
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -19,126 +19,126 @@
 block discarded – undo
19 19
 abstract class DomainBase implements DomainInterface
20 20
 {
21 21
 
22
-    /**
23
-     * Equivalent to `__FILE__` for main plugin file.
24
-     *
25
-     * @var FilePath
26
-     */
27
-    private $plugin_file;
22
+	/**
23
+	 * Equivalent to `__FILE__` for main plugin file.
24
+	 *
25
+	 * @var FilePath
26
+	 */
27
+	private $plugin_file;
28 28
 
29
-    /**
30
-     * String indicating version for plugin
31
-     *
32
-     * @var string
33
-     */
34
-    private $version;
35
-
36
-    /**
37
-     * @var string $plugin_basename
38
-     */
39
-    private $plugin_basename;
40
-
41
-    /**
42
-     * @var string $plugin_path
43
-     */
44
-    private $plugin_path;
45
-
46
-    /**
47
-     * @var string $plugin_url
48
-     */
49
-    private $plugin_url;
50
-
51
-
52
-
53
-    /**
54
-     * Initializes internal properties.
55
-     *
56
-     * @param FilePath $plugin_file
57
-     * @param Version  $version
58
-     */
59
-    public function __construct(FilePath $plugin_file, Version $version)
60
-    {
61
-        $this->plugin_file = $plugin_file;
62
-        $this->version = $version;
63
-        $this->plugin_basename = plugin_basename($this->pluginFile());
64
-        $this->plugin_path = plugin_dir_path($this->pluginFile());
65
-        $this->plugin_url = plugin_dir_url($this->pluginFile());
66
-    }
67
-
68
-
69
-    /**
70
-     * @return string
71
-     */
72
-    public function pluginFile()
73
-    {
74
-        return (string) $this->plugin_file;
75
-    }
76
-
77
-
78
-
79
-    /**
80
-     * @return string
81
-     */
82
-    public function pluginBasename()
83
-    {
84
-        return $this->plugin_basename;
85
-    }
86
-
87
-
88
-
89
-    /**
90
-     * @return string
91
-     */
92
-    public function pluginPath()
93
-    {
94
-        return $this->plugin_path;
95
-    }
96
-
97
-
98
-
99
-    /**
100
-     * @return string
101
-     */
102
-    public function pluginUrl()
103
-    {
104
-        return $this->plugin_url;
105
-    }
106
-
107
-
108
-
109
-    /**
110
-     * @return string
111
-     */
112
-    public function version()
113
-    {
114
-        return (string) $this->version;
115
-    }
116
-
117
-
118
-
119
-    /**
120
-     * @return Version
121
-     */
122
-    public function versionValueObject()
123
-    {
124
-        return $this->version;
125
-    }
126
-
127
-
128
-    /**
129
-     * @return string
130
-     */
131
-    public function distributionAssetsPath()
132
-    {
133
-        return $this->pluginPath() . 'assets/dist/';
134
-    }
29
+	/**
30
+	 * String indicating version for plugin
31
+	 *
32
+	 * @var string
33
+	 */
34
+	private $version;
35
+
36
+	/**
37
+	 * @var string $plugin_basename
38
+	 */
39
+	private $plugin_basename;
40
+
41
+	/**
42
+	 * @var string $plugin_path
43
+	 */
44
+	private $plugin_path;
45
+
46
+	/**
47
+	 * @var string $plugin_url
48
+	 */
49
+	private $plugin_url;
50
+
51
+
52
+
53
+	/**
54
+	 * Initializes internal properties.
55
+	 *
56
+	 * @param FilePath $plugin_file
57
+	 * @param Version  $version
58
+	 */
59
+	public function __construct(FilePath $plugin_file, Version $version)
60
+	{
61
+		$this->plugin_file = $plugin_file;
62
+		$this->version = $version;
63
+		$this->plugin_basename = plugin_basename($this->pluginFile());
64
+		$this->plugin_path = plugin_dir_path($this->pluginFile());
65
+		$this->plugin_url = plugin_dir_url($this->pluginFile());
66
+	}
67
+
68
+
69
+	/**
70
+	 * @return string
71
+	 */
72
+	public function pluginFile()
73
+	{
74
+		return (string) $this->plugin_file;
75
+	}
76
+
77
+
78
+
79
+	/**
80
+	 * @return string
81
+	 */
82
+	public function pluginBasename()
83
+	{
84
+		return $this->plugin_basename;
85
+	}
86
+
87
+
88
+
89
+	/**
90
+	 * @return string
91
+	 */
92
+	public function pluginPath()
93
+	{
94
+		return $this->plugin_path;
95
+	}
96
+
97
+
98
+
99
+	/**
100
+	 * @return string
101
+	 */
102
+	public function pluginUrl()
103
+	{
104
+		return $this->plugin_url;
105
+	}
106
+
107
+
108
+
109
+	/**
110
+	 * @return string
111
+	 */
112
+	public function version()
113
+	{
114
+		return (string) $this->version;
115
+	}
116
+
117
+
118
+
119
+	/**
120
+	 * @return Version
121
+	 */
122
+	public function versionValueObject()
123
+	{
124
+		return $this->version;
125
+	}
126
+
127
+
128
+	/**
129
+	 * @return string
130
+	 */
131
+	public function distributionAssetsPath()
132
+	{
133
+		return $this->pluginPath() . 'assets/dist/';
134
+	}
135 135
 
136
-
137
-    /**
138
-     * @return string
139
-     */
140
-    public function distributionAssetsUrl()
141
-    {
142
-        return $this->pluginUrl() . 'assets/dist/';
143
-    }
136
+
137
+	/**
138
+	 * @return string
139
+	 */
140
+	public function distributionAssetsUrl()
141
+	{
142
+		return $this->pluginUrl() . 'assets/dist/';
143
+	}
144 144
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     public function distributionAssetsPath()
132 132
     {
133
-        return $this->pluginPath() . 'assets/dist/';
133
+        return $this->pluginPath().'assets/dist/';
134 134
     }
135 135
 
136 136
 
@@ -139,6 +139,6 @@  discard block
 block discarded – undo
139 139
      */
140 140
     public function distributionAssetsUrl()
141 141
     {
142
-        return $this->pluginUrl() . 'assets/dist/';
142
+        return $this->pluginUrl().'assets/dist/';
143 143
     }
144 144
 }
Please login to merge, or discard this patch.
core/services/request/InvalidRequestStackMiddlewareException.php 2 patches
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -19,33 +19,33 @@
 block discarded – undo
19 19
 class InvalidRequestStackMiddlewareException extends InvalidDataTypeException
20 20
 {
21 21
 
22
-    /**
23
-     * @param  mixed     $middleware_app_class
24
-     * @param  string    $message
25
-     * @param int        $code
26
-     * @param Exception $previous
27
-     */
28
-    public function __construct($middleware_app_class, $message = '', $code = 0, Exception $previous = null)
29
-    {
30
-        if(is_array($middleware_app_class)) {
31
-            $middleware_app_class = reset($middleware_app_class);
32
-        }
33
-        if (empty($message)) {
34
-            $message = sprintf(
35
-                esc_html__(
36
-                    'The supplied Request Stack Middleware class "%1$s" is invalid or could no be found.',
37
-                    'event_espresso'
38
-                ),
39
-                $middleware_app_class
40
-            );
41
-        }
42
-        parent::__construct(
43
-            '$middleware_app_class',
44
-            $middleware_app_class,
45
-            'EventEspresso\core\services\request\middleware\Middleware',
46
-            $message,
47
-            $code,
48
-            $previous
49
-        );
50
-    }
22
+	/**
23
+	 * @param  mixed     $middleware_app_class
24
+	 * @param  string    $message
25
+	 * @param int        $code
26
+	 * @param Exception $previous
27
+	 */
28
+	public function __construct($middleware_app_class, $message = '', $code = 0, Exception $previous = null)
29
+	{
30
+		if(is_array($middleware_app_class)) {
31
+			$middleware_app_class = reset($middleware_app_class);
32
+		}
33
+		if (empty($message)) {
34
+			$message = sprintf(
35
+				esc_html__(
36
+					'The supplied Request Stack Middleware class "%1$s" is invalid or could no be found.',
37
+					'event_espresso'
38
+				),
39
+				$middleware_app_class
40
+			);
41
+		}
42
+		parent::__construct(
43
+			'$middleware_app_class',
44
+			$middleware_app_class,
45
+			'EventEspresso\core\services\request\middleware\Middleware',
46
+			$message,
47
+			$code,
48
+			$previous
49
+		);
50
+	}
51 51
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
      */
28 28
     public function __construct($middleware_app_class, $message = '', $code = 0, Exception $previous = null)
29 29
     {
30
-        if(is_array($middleware_app_class)) {
30
+        if (is_array($middleware_app_class)) {
31 31
             $middleware_app_class = reset($middleware_app_class);
32 32
         }
33 33
         if (empty($message)) {
Please login to merge, or discard this patch.
core/services/request/RequestStackBuilder.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -24,97 +24,97 @@
 block discarded – undo
24 24
 class RequestStackBuilder extends SplDoublyLinkedList
25 25
 {
26 26
 
27
-    /**
28
-     * @type LoaderInterface $loader
29
-     */
30
-    private $loader;
27
+	/**
28
+	 * @type LoaderInterface $loader
29
+	 */
30
+	private $loader;
31 31
 
32 32
 
33
-    /**
34
-     * RequestStackBuilder constructor.
35
-     *
36
-     * @param LoaderInterface $loader
37
-     */
38
-    public function __construct(LoaderInterface $loader)
39
-    {
40
-        $this->loader = $loader;
41
-        $this->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO | SplDoublyLinkedList::IT_MODE_KEEP);
42
-    }
33
+	/**
34
+	 * RequestStackBuilder constructor.
35
+	 *
36
+	 * @param LoaderInterface $loader
37
+	 */
38
+	public function __construct(LoaderInterface $loader)
39
+	{
40
+		$this->loader = $loader;
41
+		$this->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO | SplDoublyLinkedList::IT_MODE_KEEP);
42
+	}
43 43
 
44 44
 
45
-    /**
46
-     * builds decorated middleware stack
47
-     * by continuously injecting previous middleware app into the next
48
-     *
49
-     * @param RequestStackCoreAppInterface $application
50
-     * @return RequestStack
51
-     * @throws Exception
52
-     */
53
-    public function resolve(RequestStackCoreAppInterface $application)
54
-    {
55
-        $core_app = $application;
56
-        // NOW... because the RequestStack is following the decorator pattern,
57
-        // the first stack app we add will end up at the center of the stack,
58
-        // and will end up being the last item to actually run, but we don't want that!
59
-        // Basically we're dealing with TWO stacks, and transferring items from one to the other,
60
-        // BUT... we want the final stack to be in the same order as the first.
61
-        // So we need to reverse the iterator mode when transferring items,
62
-        // because if we don't, the second stack will end  up in the incorrect order.
63
-        $this->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_KEEP);
64
-        for ($this->rewind(); $this->valid(); $this->next()) {
65
-            try {
66
-                $middleware_app       = $this->validateMiddlewareAppDetails($this->current(), true);
67
-                $middleware_app_class = array_shift($middleware_app);
68
-                $middleware_app_args  = is_array($middleware_app) ? $middleware_app : array();
69
-                $middleware_app_args  = array($application, $this->loader) + $middleware_app_args;
70
-                $application          = $this->loader->getShared($middleware_app_class, $middleware_app_args);
71
-            } catch (InvalidRequestStackMiddlewareException $exception) {
72
-                if(WP_DEBUG) {
73
-                    new ExceptionStackTraceDisplay($exception);
74
-                    continue;
75
-                }
76
-                error_log($exception->getMessage());
77
-            }
78
-        }
79
-        return new RequestStack($application, $core_app);
80
-    }
45
+	/**
46
+	 * builds decorated middleware stack
47
+	 * by continuously injecting previous middleware app into the next
48
+	 *
49
+	 * @param RequestStackCoreAppInterface $application
50
+	 * @return RequestStack
51
+	 * @throws Exception
52
+	 */
53
+	public function resolve(RequestStackCoreAppInterface $application)
54
+	{
55
+		$core_app = $application;
56
+		// NOW... because the RequestStack is following the decorator pattern,
57
+		// the first stack app we add will end up at the center of the stack,
58
+		// and will end up being the last item to actually run, but we don't want that!
59
+		// Basically we're dealing with TWO stacks, and transferring items from one to the other,
60
+		// BUT... we want the final stack to be in the same order as the first.
61
+		// So we need to reverse the iterator mode when transferring items,
62
+		// because if we don't, the second stack will end  up in the incorrect order.
63
+		$this->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_KEEP);
64
+		for ($this->rewind(); $this->valid(); $this->next()) {
65
+			try {
66
+				$middleware_app       = $this->validateMiddlewareAppDetails($this->current(), true);
67
+				$middleware_app_class = array_shift($middleware_app);
68
+				$middleware_app_args  = is_array($middleware_app) ? $middleware_app : array();
69
+				$middleware_app_args  = array($application, $this->loader) + $middleware_app_args;
70
+				$application          = $this->loader->getShared($middleware_app_class, $middleware_app_args);
71
+			} catch (InvalidRequestStackMiddlewareException $exception) {
72
+				if(WP_DEBUG) {
73
+					new ExceptionStackTraceDisplay($exception);
74
+					continue;
75
+				}
76
+				error_log($exception->getMessage());
77
+			}
78
+		}
79
+		return new RequestStack($application, $core_app);
80
+	}
81 81
 
82 82
 
83
-    /**
84
-     * Ensures that the app details that have been pushed onto RequestStackBuilder
85
-     * are all ordered correctly so that the middleware can be properly constructed
86
-     *
87
-     * @param array $middleware_app
88
-     * @param bool  $recurse
89
-     * @return array
90
-     * @throws InvalidRequestStackMiddlewareException
91
-     */
92
-    protected function validateMiddlewareAppDetails(array $middleware_app, $recurse = false)
93
-    {
94
-        $middleware_app_class = reset($middleware_app);
95
-        // is array empty ?
96
-        if($middleware_app_class === false) {
97
-            throw new InvalidRequestStackMiddlewareException($middleware_app_class);
98
-        }
99
-        // are the class and arguments in the wrong order ?
100
-        if(is_array($middleware_app_class)) {
101
-            if ($recurse === true) {
102
-                return $this->validateMiddlewareAppDetails(array_reverse($middleware_app));
103
-            }
104
-            throw new InvalidRequestStackMiddlewareException($middleware_app_class);
105
-        }
106
-        // is filter callback working like legacy middleware and sending a numerically indexed array ?
107
-        if(is_int($middleware_app_class)) {
108
-            if ($recurse === true) {
109
-                $middleware_app = array_reverse($middleware_app);
110
-                return $this->validateMiddlewareAppDetails(array(reset($middleware_app), array()));
111
-            }
112
-            throw new InvalidRequestStackMiddlewareException($middleware_app_class);
113
-        }
114
-        // is $middleware_app_class a valid FQCN (or class is already loaded) ?
115
-        if(! class_exists($middleware_app_class)) {
116
-            throw new InvalidRequestStackMiddlewareException($middleware_app_class);
117
-        }
118
-        return $middleware_app;
119
-    }
83
+	/**
84
+	 * Ensures that the app details that have been pushed onto RequestStackBuilder
85
+	 * are all ordered correctly so that the middleware can be properly constructed
86
+	 *
87
+	 * @param array $middleware_app
88
+	 * @param bool  $recurse
89
+	 * @return array
90
+	 * @throws InvalidRequestStackMiddlewareException
91
+	 */
92
+	protected function validateMiddlewareAppDetails(array $middleware_app, $recurse = false)
93
+	{
94
+		$middleware_app_class = reset($middleware_app);
95
+		// is array empty ?
96
+		if($middleware_app_class === false) {
97
+			throw new InvalidRequestStackMiddlewareException($middleware_app_class);
98
+		}
99
+		// are the class and arguments in the wrong order ?
100
+		if(is_array($middleware_app_class)) {
101
+			if ($recurse === true) {
102
+				return $this->validateMiddlewareAppDetails(array_reverse($middleware_app));
103
+			}
104
+			throw new InvalidRequestStackMiddlewareException($middleware_app_class);
105
+		}
106
+		// is filter callback working like legacy middleware and sending a numerically indexed array ?
107
+		if(is_int($middleware_app_class)) {
108
+			if ($recurse === true) {
109
+				$middleware_app = array_reverse($middleware_app);
110
+				return $this->validateMiddlewareAppDetails(array(reset($middleware_app), array()));
111
+			}
112
+			throw new InvalidRequestStackMiddlewareException($middleware_app_class);
113
+		}
114
+		// is $middleware_app_class a valid FQCN (or class is already loaded) ?
115
+		if(! class_exists($middleware_app_class)) {
116
+			throw new InvalidRequestStackMiddlewareException($middleware_app_class);
117
+		}
118
+		return $middleware_app;
119
+	}
120 120
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
                 $middleware_app_args  = array($application, $this->loader) + $middleware_app_args;
70 70
                 $application          = $this->loader->getShared($middleware_app_class, $middleware_app_args);
71 71
             } catch (InvalidRequestStackMiddlewareException $exception) {
72
-                if(WP_DEBUG) {
72
+                if (WP_DEBUG) {
73 73
                     new ExceptionStackTraceDisplay($exception);
74 74
                     continue;
75 75
                 }
@@ -93,18 +93,18 @@  discard block
 block discarded – undo
93 93
     {
94 94
         $middleware_app_class = reset($middleware_app);
95 95
         // is array empty ?
96
-        if($middleware_app_class === false) {
96
+        if ($middleware_app_class === false) {
97 97
             throw new InvalidRequestStackMiddlewareException($middleware_app_class);
98 98
         }
99 99
         // are the class and arguments in the wrong order ?
100
-        if(is_array($middleware_app_class)) {
100
+        if (is_array($middleware_app_class)) {
101 101
             if ($recurse === true) {
102 102
                 return $this->validateMiddlewareAppDetails(array_reverse($middleware_app));
103 103
             }
104 104
             throw new InvalidRequestStackMiddlewareException($middleware_app_class);
105 105
         }
106 106
         // is filter callback working like legacy middleware and sending a numerically indexed array ?
107
-        if(is_int($middleware_app_class)) {
107
+        if (is_int($middleware_app_class)) {
108 108
             if ($recurse === true) {
109 109
                 $middleware_app = array_reverse($middleware_app);
110 110
                 return $this->validateMiddlewareAppDetails(array(reset($middleware_app), array()));
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
             throw new InvalidRequestStackMiddlewareException($middleware_app_class);
113 113
         }
114 114
         // is $middleware_app_class a valid FQCN (or class is already loaded) ?
115
-        if(! class_exists($middleware_app_class)) {
115
+        if ( ! class_exists($middleware_app_class)) {
116 116
             throw new InvalidRequestStackMiddlewareException($middleware_app_class);
117 117
         }
118 118
         return $middleware_app;
Please login to merge, or discard this patch.
core/domain/DomainInterface.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -16,49 +16,49 @@
 block discarded – undo
16 16
 interface DomainInterface extends InterminableInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @return string
21
-     * @throws DomainException
22
-     */
23
-    public function pluginFile();
19
+	/**
20
+	 * @return string
21
+	 * @throws DomainException
22
+	 */
23
+	public function pluginFile();
24 24
 
25 25
 
26
-    /**
27
-     * @return string
28
-     * @throws DomainException
29
-     */
30
-    public function pluginBasename();
26
+	/**
27
+	 * @return string
28
+	 * @throws DomainException
29
+	 */
30
+	public function pluginBasename();
31 31
 
32 32
 
33
-    /**
34
-     * @return string
35
-     */
36
-    public function pluginPath();
33
+	/**
34
+	 * @return string
35
+	 */
36
+	public function pluginPath();
37 37
 
38 38
 
39
-    /**
40
-     * @return string
41
-     * @throws DomainException
42
-     */
43
-    public function pluginUrl();
39
+	/**
40
+	 * @return string
41
+	 * @throws DomainException
42
+	 */
43
+	public function pluginUrl();
44 44
 
45 45
 
46
-    /**
47
-     * @return string
48
-     * @throws DomainException
49
-     */
50
-    public function version();
46
+	/**
47
+	 * @return string
48
+	 * @throws DomainException
49
+	 */
50
+	public function version();
51 51
 
52 52
 
53
-    /**
54
-     * @return string
55
-     */
56
-    public function distributionAssetsPath();
53
+	/**
54
+	 * @return string
55
+	 */
56
+	public function distributionAssetsPath();
57 57
 
58 58
 
59
-    /**
60
-     * @return string
61
-     */
62
-    public function distributionAssetsUrl();
59
+	/**
60
+	 * @return string
61
+	 */
62
+	public function distributionAssetsUrl();
63 63
 
64 64
 }
Please login to merge, or discard this patch.
core/services/assets/Registry.php 1 patch
Indentation   +449 added lines, -449 removed lines patch added patch discarded remove patch
@@ -24,459 +24,459 @@
 block discarded – undo
24 24
 class Registry
25 25
 {
26 26
 
27
-    /**
28
-     * @var EE_Template_Config $template_config
29
-     */
30
-    protected $template_config;
31
-
32
-    /**
33
-     * @var EE_Currency_Config $currency_config
34
-     */
35
-    protected $currency_config;
36
-
37
-    /**
38
-     * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
39
-     *
40
-     * @var array
41
-     */
42
-    protected $jsdata = array();
43
-
44
-
45
-    /**
46
-     * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
47
-     * page source.
48
-     * @var array
49
-     */
50
-    protected $script_handles_with_data = array();
51
-
52
-
53
-    /**
54
-     * @var DomainInterface
55
-     */
56
-    protected $domain;
57
-
58
-
59
-    /**
60
-     * Registry constructor.
61
-     * Hooking into WP actions for script registry.
62
-     *
63
-     * @param EE_Template_Config $template_config
64
-     * @param EE_Currency_Config $currency_config
65
-     * @param DomainInterface    $domain
66
-     */
67
-    public function __construct(
68
-        EE_Template_Config $template_config,
69
-        EE_Currency_Config $currency_config,
70
-        DomainInterface $domain
71
-    ) {
72
-        $this->template_config = $template_config;
73
-        $this->currency_config = $currency_config;
74
-        $this->domain = $domain;
75
-        add_action('wp_enqueue_scripts', array($this, 'scripts'), 1);
76
-        add_action('admin_enqueue_scripts', array($this, 'scripts'), 1);
77
-        add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2);
78
-        add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2);
79
-        add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
80
-        add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
81
-    }
82
-
83
-
84
-
85
-    /**
86
-     * Callback for the WP script actions.
87
-     * Used to register globally accessible core scripts.
88
-     * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency.
89
-     */
90
-    public function scripts()
91
-    {
92
-        global $wp_version;
93
-        wp_register_script(
94
-            'eejs-core',
95
-            EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js',
96
-            array(),
97
-            EVENT_ESPRESSO_VERSION,
98
-            true
99
-        );
100
-        //only run this if WordPress 4.4.0 > is in use.
101
-        if (version_compare($wp_version, '4.4.0', '>')) {
102
-            //js.api
103
-            wp_register_script(
104
-                'eejs-api',
105
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
106
-                array('underscore', 'eejs-core'),
107
-                EVENT_ESPRESSO_VERSION,
108
-                true
109
-            );
110
-            $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
111
-            $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
112
-        }
113
-        if (! is_admin()) {
114
-            $this->loadCoreCss();
115
-        }
116
-        $this->loadCoreJs();
117
-        $this->loadJqueryValidate();
118
-        $this->loadAccountingJs();
119
-        $this->loadQtipJs();
120
-    }
121
-
122
-
123
-
124
-    /**
125
-     * Call back for the script print in frontend and backend.
126
-     * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
127
-     *
128
-     * @since 4.9.31.rc.015
129
-     */
130
-    public function enqueueData()
131
-    {
132
-        $this->removeAlreadyRegisteredDataForScriptHandles();
133
-        wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata));
134
-        wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
135
-        $this->localizeAccountingJs();
136
-        $this->addRegisteredScriptHandlesWithData('eejs-core');
137
-        $this->addRegisteredScriptHandlesWithData('espresso_core');
138
-    }
139
-
140
-
141
-
142
-    /**
143
-     * Used to add data to eejs.data object.
144
-     * Note:  Overriding existing data is not allowed.
145
-     * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
146
-     * If the data you add is something like this:
147
-     *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
148
-     * It will be exposed in the page source as:
149
-     *  eejs.data.my_plugin_data.foo == gar
150
-     *
151
-     * @param string       $key   Key used to access your data
152
-     * @param string|array $value Value to attach to key
153
-     * @throws InvalidArgumentException
154
-     */
155
-    public function addData($key, $value)
156
-    {
157
-        if ($this->verifyDataNotExisting($key)) {
158
-            $this->jsdata[$key] = $value;
159
-        }
160
-    }
161
-
162
-
163
-
164
-    /**
165
-     * Similar to addData except this allows for users to push values to an existing key where the values on key are
166
-     * elements in an array.
167
-     * When you use this method, the value you include will be appended to the end of an array on $key.
168
-     * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript
169
-     * object like this, eejs.data.test = [ my_data,
170
-     * ]
171
-     * If there has already been a scalar value attached to the data object given key, then
172
-     * this will throw an exception.
173
-     *
174
-     * @param string       $key   Key to attach data to.
175
-     * @param string|array $value Value being registered.
176
-     * @throws InvalidArgumentException
177
-     */
178
-    public function pushData($key, $value)
179
-    {
180
-        if (isset($this->jsdata[$key])
181
-            && ! is_array($this->jsdata[$key])
182
-        ) {
183
-            throw new invalidArgumentException(
184
-                sprintf(
185
-                    __(
186
-                        'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
27
+	/**
28
+	 * @var EE_Template_Config $template_config
29
+	 */
30
+	protected $template_config;
31
+
32
+	/**
33
+	 * @var EE_Currency_Config $currency_config
34
+	 */
35
+	protected $currency_config;
36
+
37
+	/**
38
+	 * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
39
+	 *
40
+	 * @var array
41
+	 */
42
+	protected $jsdata = array();
43
+
44
+
45
+	/**
46
+	 * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
47
+	 * page source.
48
+	 * @var array
49
+	 */
50
+	protected $script_handles_with_data = array();
51
+
52
+
53
+	/**
54
+	 * @var DomainInterface
55
+	 */
56
+	protected $domain;
57
+
58
+
59
+	/**
60
+	 * Registry constructor.
61
+	 * Hooking into WP actions for script registry.
62
+	 *
63
+	 * @param EE_Template_Config $template_config
64
+	 * @param EE_Currency_Config $currency_config
65
+	 * @param DomainInterface    $domain
66
+	 */
67
+	public function __construct(
68
+		EE_Template_Config $template_config,
69
+		EE_Currency_Config $currency_config,
70
+		DomainInterface $domain
71
+	) {
72
+		$this->template_config = $template_config;
73
+		$this->currency_config = $currency_config;
74
+		$this->domain = $domain;
75
+		add_action('wp_enqueue_scripts', array($this, 'scripts'), 1);
76
+		add_action('admin_enqueue_scripts', array($this, 'scripts'), 1);
77
+		add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2);
78
+		add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2);
79
+		add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
80
+		add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
81
+	}
82
+
83
+
84
+
85
+	/**
86
+	 * Callback for the WP script actions.
87
+	 * Used to register globally accessible core scripts.
88
+	 * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency.
89
+	 */
90
+	public function scripts()
91
+	{
92
+		global $wp_version;
93
+		wp_register_script(
94
+			'eejs-core',
95
+			EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js',
96
+			array(),
97
+			EVENT_ESPRESSO_VERSION,
98
+			true
99
+		);
100
+		//only run this if WordPress 4.4.0 > is in use.
101
+		if (version_compare($wp_version, '4.4.0', '>')) {
102
+			//js.api
103
+			wp_register_script(
104
+				'eejs-api',
105
+				EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
106
+				array('underscore', 'eejs-core'),
107
+				EVENT_ESPRESSO_VERSION,
108
+				true
109
+			);
110
+			$this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
111
+			$this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
112
+		}
113
+		if (! is_admin()) {
114
+			$this->loadCoreCss();
115
+		}
116
+		$this->loadCoreJs();
117
+		$this->loadJqueryValidate();
118
+		$this->loadAccountingJs();
119
+		$this->loadQtipJs();
120
+	}
121
+
122
+
123
+
124
+	/**
125
+	 * Call back for the script print in frontend and backend.
126
+	 * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
127
+	 *
128
+	 * @since 4.9.31.rc.015
129
+	 */
130
+	public function enqueueData()
131
+	{
132
+		$this->removeAlreadyRegisteredDataForScriptHandles();
133
+		wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata));
134
+		wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
135
+		$this->localizeAccountingJs();
136
+		$this->addRegisteredScriptHandlesWithData('eejs-core');
137
+		$this->addRegisteredScriptHandlesWithData('espresso_core');
138
+	}
139
+
140
+
141
+
142
+	/**
143
+	 * Used to add data to eejs.data object.
144
+	 * Note:  Overriding existing data is not allowed.
145
+	 * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
146
+	 * If the data you add is something like this:
147
+	 *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
148
+	 * It will be exposed in the page source as:
149
+	 *  eejs.data.my_plugin_data.foo == gar
150
+	 *
151
+	 * @param string       $key   Key used to access your data
152
+	 * @param string|array $value Value to attach to key
153
+	 * @throws InvalidArgumentException
154
+	 */
155
+	public function addData($key, $value)
156
+	{
157
+		if ($this->verifyDataNotExisting($key)) {
158
+			$this->jsdata[$key] = $value;
159
+		}
160
+	}
161
+
162
+
163
+
164
+	/**
165
+	 * Similar to addData except this allows for users to push values to an existing key where the values on key are
166
+	 * elements in an array.
167
+	 * When you use this method, the value you include will be appended to the end of an array on $key.
168
+	 * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript
169
+	 * object like this, eejs.data.test = [ my_data,
170
+	 * ]
171
+	 * If there has already been a scalar value attached to the data object given key, then
172
+	 * this will throw an exception.
173
+	 *
174
+	 * @param string       $key   Key to attach data to.
175
+	 * @param string|array $value Value being registered.
176
+	 * @throws InvalidArgumentException
177
+	 */
178
+	public function pushData($key, $value)
179
+	{
180
+		if (isset($this->jsdata[$key])
181
+			&& ! is_array($this->jsdata[$key])
182
+		) {
183
+			throw new invalidArgumentException(
184
+				sprintf(
185
+					__(
186
+						'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
187 187
                          push values to this data element when it is an array.',
188
-                        'event_espresso'
189
-                    ),
190
-                    $key,
191
-                    __METHOD__
192
-                )
193
-            );
194
-        }
195
-        $this->jsdata[$key][] = $value;
196
-    }
197
-
198
-
199
-
200
-    /**
201
-     * Used to set content used by javascript for a template.
202
-     * Note: Overrides of existing registered templates are not allowed.
203
-     *
204
-     * @param string $template_reference
205
-     * @param string $template_content
206
-     * @throws InvalidArgumentException
207
-     */
208
-    public function addTemplate($template_reference, $template_content)
209
-    {
210
-        if (! isset($this->jsdata['templates'])) {
211
-            $this->jsdata['templates'] = array();
212
-        }
213
-        //no overrides allowed.
214
-        if (isset($this->jsdata['templates'][$template_reference])) {
215
-            throw new invalidArgumentException(
216
-                sprintf(
217
-                    __(
218
-                        'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
219
-                        'event_espresso'
220
-                    ),
221
-                    $template_reference
222
-                )
223
-            );
224
-        }
225
-        $this->jsdata['templates'][$template_reference] = $template_content;
226
-    }
227
-
228
-
229
-
230
-    /**
231
-     * Retrieve the template content already registered for the given reference.
232
-     *
233
-     * @param string $template_reference
234
-     * @return string
235
-     */
236
-    public function getTemplate($template_reference)
237
-    {
238
-        return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference])
239
-            ? $this->jsdata['templates'][$template_reference]
240
-            : '';
241
-    }
242
-
243
-
244
-
245
-    /**
246
-     * Retrieve registered data.
247
-     *
248
-     * @param string $key Name of key to attach data to.
249
-     * @return mixed                If there is no for the given key, then false is returned.
250
-     */
251
-    public function getData($key)
252
-    {
253
-        return isset($this->jsdata[$key])
254
-            ? $this->jsdata[$key]
255
-            : false;
256
-    }
257
-
258
-
259
-
260
-    /**
261
-     * Verifies whether the given data exists already on the jsdata array.
262
-     * Overriding data is not allowed.
263
-     *
264
-     * @param string $key Index for data.
265
-     * @return bool        If valid then return true.
266
-     * @throws InvalidArgumentException if data already exists.
267
-     */
268
-    protected function verifyDataNotExisting($key)
269
-    {
270
-        if (isset($this->jsdata[$key])) {
271
-            if (is_array($this->jsdata[$key])) {
272
-                throw new InvalidArgumentException(
273
-                    sprintf(
274
-                        __(
275
-                            'The value for %1$s already exists in the Registry::eejs object.
188
+						'event_espresso'
189
+					),
190
+					$key,
191
+					__METHOD__
192
+				)
193
+			);
194
+		}
195
+		$this->jsdata[$key][] = $value;
196
+	}
197
+
198
+
199
+
200
+	/**
201
+	 * Used to set content used by javascript for a template.
202
+	 * Note: Overrides of existing registered templates are not allowed.
203
+	 *
204
+	 * @param string $template_reference
205
+	 * @param string $template_content
206
+	 * @throws InvalidArgumentException
207
+	 */
208
+	public function addTemplate($template_reference, $template_content)
209
+	{
210
+		if (! isset($this->jsdata['templates'])) {
211
+			$this->jsdata['templates'] = array();
212
+		}
213
+		//no overrides allowed.
214
+		if (isset($this->jsdata['templates'][$template_reference])) {
215
+			throw new invalidArgumentException(
216
+				sprintf(
217
+					__(
218
+						'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
219
+						'event_espresso'
220
+					),
221
+					$template_reference
222
+				)
223
+			);
224
+		}
225
+		$this->jsdata['templates'][$template_reference] = $template_content;
226
+	}
227
+
228
+
229
+
230
+	/**
231
+	 * Retrieve the template content already registered for the given reference.
232
+	 *
233
+	 * @param string $template_reference
234
+	 * @return string
235
+	 */
236
+	public function getTemplate($template_reference)
237
+	{
238
+		return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference])
239
+			? $this->jsdata['templates'][$template_reference]
240
+			: '';
241
+	}
242
+
243
+
244
+
245
+	/**
246
+	 * Retrieve registered data.
247
+	 *
248
+	 * @param string $key Name of key to attach data to.
249
+	 * @return mixed                If there is no for the given key, then false is returned.
250
+	 */
251
+	public function getData($key)
252
+	{
253
+		return isset($this->jsdata[$key])
254
+			? $this->jsdata[$key]
255
+			: false;
256
+	}
257
+
258
+
259
+
260
+	/**
261
+	 * Verifies whether the given data exists already on the jsdata array.
262
+	 * Overriding data is not allowed.
263
+	 *
264
+	 * @param string $key Index for data.
265
+	 * @return bool        If valid then return true.
266
+	 * @throws InvalidArgumentException if data already exists.
267
+	 */
268
+	protected function verifyDataNotExisting($key)
269
+	{
270
+		if (isset($this->jsdata[$key])) {
271
+			if (is_array($this->jsdata[$key])) {
272
+				throw new InvalidArgumentException(
273
+					sprintf(
274
+						__(
275
+							'The value for %1$s already exists in the Registry::eejs object.
276 276
                             Overrides are not allowed. Since the value of this data is an array, you may want to use the
277 277
                             %2$s method to push your value to the array.',
278
-                            'event_espresso'
279
-                        ),
280
-                        $key,
281
-                        'pushData()'
282
-                    )
283
-                );
284
-            }
285
-            throw new InvalidArgumentException(
286
-                sprintf(
287
-                    __(
288
-                        'The value for %1$s already exists in the Registry::eejs object. Overrides are not
278
+							'event_espresso'
279
+						),
280
+						$key,
281
+						'pushData()'
282
+					)
283
+				);
284
+			}
285
+			throw new InvalidArgumentException(
286
+				sprintf(
287
+					__(
288
+						'The value for %1$s already exists in the Registry::eejs object. Overrides are not
289 289
                         allowed.  Consider attaching your value to a different key',
290
-                        'event_espresso'
291
-                    ),
292
-                    $key
293
-                )
294
-            );
295
-        }
296
-        return true;
297
-    }
298
-
299
-
300
-
301
-    /**
302
-     * registers core default stylesheets
303
-     */
304
-    private function loadCoreCss()
305
-    {
306
-        if ($this->template_config->enable_default_style) {
307
-            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
308
-                ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
309
-                : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
310
-            wp_register_style(
311
-                'espresso_default',
312
-                $default_stylesheet_path,
313
-                array('dashicons'),
314
-                EVENT_ESPRESSO_VERSION
315
-            );
316
-            //Load custom style sheet if available
317
-            if ($this->template_config->custom_style_sheet !== null) {
318
-                wp_register_style(
319
-                    'espresso_custom_css',
320
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
321
-                    array('espresso_default'),
322
-                    EVENT_ESPRESSO_VERSION
323
-                );
324
-            }
325
-        }
326
-    }
327
-
328
-
329
-
330
-    /**
331
-     * registers core default javascript
332
-     */
333
-    private function loadCoreJs()
334
-    {
335
-        // load core js
336
-        wp_register_script(
337
-            'espresso_core',
338
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
339
-            array('jquery'),
340
-            EVENT_ESPRESSO_VERSION,
341
-            true
342
-        );
343
-    }
344
-
345
-
346
-
347
-    /**
348
-     * registers jQuery Validate for form validation
349
-     */
350
-    private function loadJqueryValidate()
351
-    {
352
-        // register jQuery Validate and additional methods
353
-        wp_register_script(
354
-            'jquery-validate',
355
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
356
-            array('jquery'),
357
-            '1.15.0',
358
-            true
359
-        );
360
-        wp_register_script(
361
-            'jquery-validate-extra-methods',
362
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
363
-            array('jquery', 'jquery-validate'),
364
-            '1.15.0',
365
-            true
366
-        );
367
-    }
368
-
369
-
370
-
371
-    /**
372
-     * registers accounting.js for performing client-side calculations
373
-     */
374
-    private function loadAccountingJs()
375
-    {
376
-        //accounting.js library
377
-        // @link http://josscrowcroft.github.io/accounting.js/
378
-        wp_register_script(
379
-            'ee-accounting-core',
380
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
381
-            array('underscore'),
382
-            '0.3.2',
383
-            true
384
-        );
385
-        wp_register_script(
386
-            'ee-accounting',
387
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
388
-            array('ee-accounting-core'),
389
-            EVENT_ESPRESSO_VERSION,
390
-            true
391
-        );
392
-    }
393
-
394
-
395
-
396
-    /**
397
-     * registers accounting.js for performing client-side calculations
398
-     */
399
-    private function localizeAccountingJs()
400
-    {
401
-        wp_localize_script(
402
-            'ee-accounting',
403
-            'EE_ACCOUNTING_CFG',
404
-            array(
405
-                'currency' => array(
406
-                    'symbol'    => $this->currency_config->sign,
407
-                    'format'    => array(
408
-                        'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
409
-                        'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
410
-                        'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
411
-                    ),
412
-                    'decimal'   => $this->currency_config->dec_mrk,
413
-                    'thousand'  => $this->currency_config->thsnds,
414
-                    'precision' => $this->currency_config->dec_plc,
415
-                ),
416
-                'number'   => array(
417
-                    'precision' => $this->currency_config->dec_plc,
418
-                    'thousand'  => $this->currency_config->thsnds,
419
-                    'decimal'   => $this->currency_config->dec_mrk,
420
-                ),
421
-            )
422
-        );
423
-        $this->addRegisteredScriptHandlesWithData('ee-accounting');
424
-    }
425
-
426
-
427
-
428
-    /**
429
-     * registers assets for cleaning your ears
430
-     */
431
-    private function loadQtipJs()
432
-    {
433
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
434
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
435
-        if (apply_filters('FHEE_load_qtip', false)) {
436
-            EEH_Qtip_Loader::instance()->register_and_enqueue();
437
-        }
438
-    }
439
-
440
-
441
-    /**
442
-     * This is used to set registered script handles that have data.
443
-     * @param string $script_handle
444
-     */
445
-    private function addRegisteredScriptHandlesWithData($script_handle)
446
-    {
447
-        $this->script_handles_with_data[$script_handle] = $script_handle;
448
-    }
449
-
450
-
451
-    /**
452
-     * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the
453
-     * Dependency stored in WP_Scripts if its set.
454
-     */
455
-    private function removeAlreadyRegisteredDataForScriptHandles()
456
-    {
457
-        if (empty($this->script_handles_with_data)) {
458
-            return;
459
-        }
460
-        foreach ($this->script_handles_with_data as $script_handle) {
461
-            $this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
462
-        }
463
-    }
464
-
465
-
466
-    /**
467
-     * Removes any data dependency registered in WP_Scripts if its set.
468
-     * @param string $script_handle
469
-     */
470
-    private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
471
-    {
472
-        if (isset($this->script_handles_with_data[$script_handle])) {
473
-            global $wp_scripts;
474
-            if ($wp_scripts->get_data($script_handle, 'data')) {
475
-                unset($wp_scripts->registered[$script_handle]->extra['data']);
476
-                unset($this->script_handles_with_data[$script_handle]);
477
-            }
478
-        }
479
-    }
290
+						'event_espresso'
291
+					),
292
+					$key
293
+				)
294
+			);
295
+		}
296
+		return true;
297
+	}
298
+
299
+
300
+
301
+	/**
302
+	 * registers core default stylesheets
303
+	 */
304
+	private function loadCoreCss()
305
+	{
306
+		if ($this->template_config->enable_default_style) {
307
+			$default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
308
+				? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
309
+				: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
310
+			wp_register_style(
311
+				'espresso_default',
312
+				$default_stylesheet_path,
313
+				array('dashicons'),
314
+				EVENT_ESPRESSO_VERSION
315
+			);
316
+			//Load custom style sheet if available
317
+			if ($this->template_config->custom_style_sheet !== null) {
318
+				wp_register_style(
319
+					'espresso_custom_css',
320
+					EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
321
+					array('espresso_default'),
322
+					EVENT_ESPRESSO_VERSION
323
+				);
324
+			}
325
+		}
326
+	}
327
+
328
+
329
+
330
+	/**
331
+	 * registers core default javascript
332
+	 */
333
+	private function loadCoreJs()
334
+	{
335
+		// load core js
336
+		wp_register_script(
337
+			'espresso_core',
338
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
339
+			array('jquery'),
340
+			EVENT_ESPRESSO_VERSION,
341
+			true
342
+		);
343
+	}
344
+
345
+
346
+
347
+	/**
348
+	 * registers jQuery Validate for form validation
349
+	 */
350
+	private function loadJqueryValidate()
351
+	{
352
+		// register jQuery Validate and additional methods
353
+		wp_register_script(
354
+			'jquery-validate',
355
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
356
+			array('jquery'),
357
+			'1.15.0',
358
+			true
359
+		);
360
+		wp_register_script(
361
+			'jquery-validate-extra-methods',
362
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
363
+			array('jquery', 'jquery-validate'),
364
+			'1.15.0',
365
+			true
366
+		);
367
+	}
368
+
369
+
370
+
371
+	/**
372
+	 * registers accounting.js for performing client-side calculations
373
+	 */
374
+	private function loadAccountingJs()
375
+	{
376
+		//accounting.js library
377
+		// @link http://josscrowcroft.github.io/accounting.js/
378
+		wp_register_script(
379
+			'ee-accounting-core',
380
+			EE_THIRD_PARTY_URL . 'accounting/accounting.js',
381
+			array('underscore'),
382
+			'0.3.2',
383
+			true
384
+		);
385
+		wp_register_script(
386
+			'ee-accounting',
387
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
388
+			array('ee-accounting-core'),
389
+			EVENT_ESPRESSO_VERSION,
390
+			true
391
+		);
392
+	}
393
+
394
+
395
+
396
+	/**
397
+	 * registers accounting.js for performing client-side calculations
398
+	 */
399
+	private function localizeAccountingJs()
400
+	{
401
+		wp_localize_script(
402
+			'ee-accounting',
403
+			'EE_ACCOUNTING_CFG',
404
+			array(
405
+				'currency' => array(
406
+					'symbol'    => $this->currency_config->sign,
407
+					'format'    => array(
408
+						'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
409
+						'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
410
+						'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
411
+					),
412
+					'decimal'   => $this->currency_config->dec_mrk,
413
+					'thousand'  => $this->currency_config->thsnds,
414
+					'precision' => $this->currency_config->dec_plc,
415
+				),
416
+				'number'   => array(
417
+					'precision' => $this->currency_config->dec_plc,
418
+					'thousand'  => $this->currency_config->thsnds,
419
+					'decimal'   => $this->currency_config->dec_mrk,
420
+				),
421
+			)
422
+		);
423
+		$this->addRegisteredScriptHandlesWithData('ee-accounting');
424
+	}
425
+
426
+
427
+
428
+	/**
429
+	 * registers assets for cleaning your ears
430
+	 */
431
+	private function loadQtipJs()
432
+	{
433
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
434
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
435
+		if (apply_filters('FHEE_load_qtip', false)) {
436
+			EEH_Qtip_Loader::instance()->register_and_enqueue();
437
+		}
438
+	}
439
+
440
+
441
+	/**
442
+	 * This is used to set registered script handles that have data.
443
+	 * @param string $script_handle
444
+	 */
445
+	private function addRegisteredScriptHandlesWithData($script_handle)
446
+	{
447
+		$this->script_handles_with_data[$script_handle] = $script_handle;
448
+	}
449
+
450
+
451
+	/**
452
+	 * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the
453
+	 * Dependency stored in WP_Scripts if its set.
454
+	 */
455
+	private function removeAlreadyRegisteredDataForScriptHandles()
456
+	{
457
+		if (empty($this->script_handles_with_data)) {
458
+			return;
459
+		}
460
+		foreach ($this->script_handles_with_data as $script_handle) {
461
+			$this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
462
+		}
463
+	}
464
+
465
+
466
+	/**
467
+	 * Removes any data dependency registered in WP_Scripts if its set.
468
+	 * @param string $script_handle
469
+	 */
470
+	private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
471
+	{
472
+		if (isset($this->script_handles_with_data[$script_handle])) {
473
+			global $wp_scripts;
474
+			if ($wp_scripts->get_data($script_handle, 'data')) {
475
+				unset($wp_scripts->registered[$script_handle]->extra['data']);
476
+				unset($this->script_handles_with_data[$script_handle]);
477
+			}
478
+		}
479
+	}
480 480
 
481 481
 
482 482
 }
Please login to merge, or discard this patch.
core/libraries/messages/messenger/EE_Email_messenger.class.php 2 patches
Indentation   +645 added lines, -645 removed lines patch added patch discarded remove patch
@@ -8,649 +8,649 @@
 block discarded – undo
8 8
 class EE_Email_messenger extends EE_messenger
9 9
 {
10 10
 
11
-    /**
12
-     * To field for email
13
-     * @var string
14
-     */
15
-    protected $_to = '';
16
-
17
-
18
-    /**
19
-     * CC field for email.
20
-     * @var string
21
-     */
22
-    protected $_cc = '';
23
-
24
-    /**
25
-     * From field for email
26
-     * @var string
27
-     */
28
-    protected $_from = '';
29
-
30
-
31
-    /**
32
-     * Subject field for email
33
-     * @var string
34
-     */
35
-    protected $_subject = '';
36
-
37
-
38
-    /**
39
-     * Content field for email
40
-     * @var string
41
-     */
42
-    protected $_content = '';
43
-
44
-
45
-    /**
46
-     * constructor
47
-     *
48
-     * @access public
49
-     */
50
-    public function __construct()
51
-    {
52
-        //set name and description properties
53
-        $this->name                = 'email';
54
-        $this->description         = sprintf(
55
-            esc_html__(
56
-                'This messenger delivers messages via email using the built-in %s function included with WordPress',
57
-                'event_espresso'
58
-            ),
59
-            '<code>wp_mail</code>'
60
-        );
61
-        $this->label               = array(
62
-            'singular' => esc_html__('email', 'event_espresso'),
63
-            'plural'   => esc_html__('emails', 'event_espresso'),
64
-        );
65
-        $this->activate_on_install = true;
66
-
67
-        //we're using defaults so let's call parent constructor that will take care of setting up all the other
68
-        // properties
69
-        parent::__construct();
70
-    }
71
-
72
-
73
-    /**
74
-     * see abstract declaration in parent class for details.
75
-     */
76
-    protected function _set_admin_pages()
77
-    {
78
-        $this->admin_registered_pages = array(
79
-            'events_edit' => true,
80
-        );
81
-    }
82
-
83
-
84
-    /**
85
-     * see abstract declaration in parent class for details
86
-     */
87
-    protected function _set_valid_shortcodes()
88
-    {
89
-        //remember by leaving the other fields not set, those fields will inherit the valid shortcodes from the
90
-        // message type.
91
-        $this->_valid_shortcodes = array(
92
-            'to'   => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
93
-            'cc' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
94
-            'from' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
95
-        );
96
-    }
97
-
98
-
99
-    /**
100
-     * see abstract declaration in parent class for details
101
-     *
102
-     * @access protected
103
-     * @return void
104
-     */
105
-    protected function _set_validator_config()
106
-    {
107
-        $valid_shortcodes = $this->get_valid_shortcodes();
108
-
109
-        $this->_validator_config = array(
110
-            'to'            => array(
111
-                'shortcodes' => $valid_shortcodes['to'],
112
-                'type'       => 'email',
113
-            ),
114
-            'cc' => array(
115
-                'shortcodes' => $valid_shortcodes['to'],
116
-                'type' => 'email',
117
-            ),
118
-            'from'          => array(
119
-                'shortcodes' => $valid_shortcodes['from'],
120
-                'type'       => 'email',
121
-            ),
122
-            'subject'       => array(
123
-                'shortcodes' => array(
124
-                    'organization',
125
-                    'primary_registration_details',
126
-                    'event_author',
127
-                    'primary_registration_details',
128
-                    'recipient_details',
129
-                ),
130
-            ),
131
-            'content'       => array(
132
-                'shortcodes' => array(
133
-                    'event_list',
134
-                    'attendee_list',
135
-                    'ticket_list',
136
-                    'organization',
137
-                    'primary_registration_details',
138
-                    'primary_registration_list',
139
-                    'event_author',
140
-                    'recipient_details',
141
-                    'recipient_list',
142
-                    'transaction',
143
-                    'messenger',
144
-                ),
145
-            ),
146
-            'attendee_list' => array(
147
-                'shortcodes' => array('attendee', 'event_list', 'ticket_list'),
148
-                'required'   => array('[ATTENDEE_LIST]'),
149
-            ),
150
-            'event_list'    => array(
151
-                'shortcodes' => array(
152
-                    'event',
153
-                    'attendee_list',
154
-                    'ticket_list',
155
-                    'venue',
156
-                    'datetime_list',
157
-                    'attendee',
158
-                    'primary_registration_details',
159
-                    'primary_registration_list',
160
-                    'event_author',
161
-                    'recipient_details',
162
-                    'recipient_list',
163
-                ),
164
-                'required'   => array('[EVENT_LIST]'),
165
-            ),
166
-            'ticket_list'   => array(
167
-                'shortcodes' => array(
168
-                    'event_list',
169
-                    'attendee_list',
170
-                    'ticket',
171
-                    'datetime_list',
172
-                    'primary_registration_details',
173
-                    'recipient_details',
174
-                ),
175
-                'required'   => array('[TICKET_LIST]'),
176
-            ),
177
-            'datetime_list' => array(
178
-                'shortcodes' => array('datetime'),
179
-                'required'   => array('[DATETIME_LIST]'),
180
-            ),
181
-        );
182
-    }
183
-
184
-
185
-    /**
186
-     * @see   parent EE_messenger class for docs
187
-     * @since 4.5.0
188
-     */
189
-    public function do_secondary_messenger_hooks($sending_messenger_name)
190
-    {
191
-        if ($sending_messenger_name = 'html') {
192
-            add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
193
-        }
194
-    }
195
-
196
-
197
-    public function add_email_css(
198
-        $variation_path,
199
-        $messenger,
200
-        $message_type,
201
-        $type,
202
-        $variation,
203
-        $file_extension,
204
-        $url,
205
-        EE_Messages_Template_Pack $template_pack
206
-    ) {
207
-        //prevent recursion on this callback.
208
-        remove_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10);
209
-        $variation = $this->get_variation($template_pack, $message_type, $url, 'main', $variation, false);
210
-
211
-        add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
212
-        return $variation;
213
-    }
214
-
215
-
216
-    /**
217
-     * See parent for details
218
-     *
219
-     * @access protected
220
-     * @return void
221
-     */
222
-    protected function _set_test_settings_fields()
223
-    {
224
-        $this->_test_settings_fields = array(
225
-            'to'      => array(
226
-                'input'      => 'text',
227
-                'label'      => esc_html__('Send a test email to', 'event_espresso'),
228
-                'type'       => 'email',
229
-                'required'   => true,
230
-                'validation' => true,
231
-                'css_class'  => 'large-text',
232
-                'format'     => '%s',
233
-                'default'    => get_bloginfo('admin_email'),
234
-            ),
235
-            'subject' => array(
236
-                'input'      => 'hidden',
237
-                'label'      => '',
238
-                'type'       => 'string',
239
-                'required'   => false,
240
-                'validation' => false,
241
-                'format'     => '%s',
242
-                'value'      => sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')),
243
-                'default'    => '',
244
-                'css_class'  => '',
245
-            ),
246
-        );
247
-    }
248
-
249
-
250
-    /**
251
-     * _set_template_fields
252
-     * This sets up the fields that a messenger requires for the message to go out.
253
-     *
254
-     * @access  protected
255
-     * @return void
256
-     */
257
-    protected function _set_template_fields()
258
-    {
259
-        // any extra template fields that are NOT used by the messenger but will get used by a messenger field for
260
-        // shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field
261
-        // they relate to.  This is important for the Messages_admin to know what fields to display to the user.
262
-        //  Also, notice that the "values" are equal to the field type that messages admin will use to know what
263
-        // kind of field to display. The values ALSO have one index labeled "shortcode".  the values in that array
264
-        // indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be
265
-        // displayed.  If the required shortcode isn't part of the shortcodes array then the field is not needed and
266
-        // will not be displayed/parsed.
267
-        $this->_template_fields = array(
268
-            'to'      => array(
269
-                'input'      => 'text',
270
-                'label'      => esc_html_x(
271
-                    'To',
272
-                    'Label for the "To" field for email addresses',
273
-                    'event_espresso'
274
-                ),
275
-                'type'       => 'string',
276
-                'required'   => true,
277
-                'validation' => true,
278
-                'css_class'  => 'large-text',
279
-                'format'     => '%s',
280
-            ),
281
-            'cc'      => array(
282
-                'input'      => 'text',
283
-                'label'      => esc_html_x(
284
-                    'CC',
285
-                    'Label for the "Carbon Copy" field used for additional email addresses',
286
-                    'event_espresso'
287
-                ),
288
-                'type'       => 'string',
289
-                'required'   => false,
290
-                'validation' => true,
291
-                'css_class'  => 'large-text',
292
-                'format'     => '%s',
293
-            ),
294
-            'from'    => array(
295
-                'input'      => 'text',
296
-                'label'      => esc_html_x(
297
-                    'From',
298
-                    'Label for the "From" field for email addresses.',
299
-                    'event_espresso'
300
-                ),
301
-                'type'       => 'string',
302
-                'required'   => true,
303
-                'validation' => true,
304
-                'css_class'  => 'large-text',
305
-                'format'     => '%s',
306
-            ),
307
-            'subject' => array(
308
-                'input'      => 'text',
309
-                'label'      => esc_html_x(
310
-                    'Subject',
311
-                    'Label for the "Subject" field (short description of contents) for emails.',
312
-                    'event_espresso'
313
-                ),
314
-                'type'       => 'string',
315
-                'required'   => true,
316
-                'validation' => true,
317
-                'css_class'  => 'large-text',
318
-                'format'     => '%s',
319
-            ),
320
-            'content' => '',
321
-            //left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field.
322
-            'extra'   => array(
323
-                'content' => array(
324
-                    'main'          => array(
325
-                        'input'      => 'wp_editor',
326
-                        'label'      => esc_html__('Main Content', 'event_espresso'),
327
-                        'type'       => 'string',
328
-                        'required'   => true,
329
-                        'validation' => true,
330
-                        'format'     => '%s',
331
-                        'rows'       => '15',
332
-                    ),
333
-                    'event_list'    => array(
334
-                        'input'               => 'wp_editor',
335
-                        'label'               => '[EVENT_LIST]',
336
-                        'type'                => 'string',
337
-                        'required'            => true,
338
-                        'validation'          => true,
339
-                        'format'              => '%s',
340
-                        'rows'                => '15',
341
-                        'shortcodes_required' => array('[EVENT_LIST]'),
342
-                    ),
343
-                    'attendee_list' => array(
344
-                        'input'               => 'textarea',
345
-                        'label'               => '[ATTENDEE_LIST]',
346
-                        'type'                => 'string',
347
-                        'required'            => true,
348
-                        'validation'          => true,
349
-                        'format'              => '%s',
350
-                        'css_class'           => 'large-text',
351
-                        'rows'                => '5',
352
-                        'shortcodes_required' => array('[ATTENDEE_LIST]'),
353
-                    ),
354
-                    'ticket_list'   => array(
355
-                        'input'               => 'textarea',
356
-                        'label'               => '[TICKET_LIST]',
357
-                        'type'                => 'string',
358
-                        'required'            => true,
359
-                        'validation'          => true,
360
-                        'format'              => '%s',
361
-                        'css_class'           => 'large-text',
362
-                        'rows'                => '10',
363
-                        'shortcodes_required' => array('[TICKET_LIST]'),
364
-                    ),
365
-                    'datetime_list' => array(
366
-                        'input'               => 'textarea',
367
-                        'label'               => '[DATETIME_LIST]',
368
-                        'type'                => 'string',
369
-                        'required'            => true,
370
-                        'validation'          => true,
371
-                        'format'              => '%s',
372
-                        'css_class'           => 'large-text',
373
-                        'rows'                => '10',
374
-                        'shortcodes_required' => array('[DATETIME_LIST]'),
375
-                    ),
376
-                ),
377
-            ),
378
-        );
379
-    }
380
-
381
-
382
-    /**
383
-     * See definition of this class in parent
384
-     */
385
-    protected function _set_default_message_types()
386
-    {
387
-        $this->_default_message_types = array(
388
-            'payment',
389
-            'payment_refund',
390
-            'registration',
391
-            'not_approved_registration',
392
-            'pending_approval',
393
-        );
394
-    }
395
-
396
-
397
-    /**
398
-     * @see   definition of this class in parent
399
-     * @since 4.5.0
400
-     */
401
-    protected function _set_valid_message_types()
402
-    {
403
-        $this->_valid_message_types = array(
404
-            'payment',
405
-            'registration',
406
-            'not_approved_registration',
407
-            'declined_registration',
408
-            'cancelled_registration',
409
-            'pending_approval',
410
-            'registration_summary',
411
-            'payment_reminder',
412
-            'payment_declined',
413
-            'payment_refund',
414
-        );
415
-    }
416
-
417
-
418
-    /**
419
-     * setting up admin_settings_fields for messenger.
420
-     */
421
-    protected function _set_admin_settings_fields()
422
-    {
423
-    }
424
-
425
-    /**
426
-     * We just deliver the messages don't kill us!!
427
-     *
428
-     * @return bool|WP_Error true if message delivered, false if it didn't deliver OR bubble up any error object if
429
-     *              present.
430
-     * @throws EE_Error
431
-     * @throws \TijsVerkoyen\CssToInlineStyles\Exception
432
-     */
433
-    protected function _send_message()
434
-    {
435
-        $success = wp_mail(
436
-            $this->_to,
437
-            //some old values for subject may be expecting HTML entities to be decoded in the subject
438
-            //and subjects aren't interpreted as HTML, so there should be no HTML in them
439
-            wp_strip_all_tags(wp_specialchars_decode($this->_subject, ENT_QUOTES)),
440
-            $this->_body(),
441
-            $this->_headers()
442
-        );
443
-        if (! $success) {
444
-            EE_Error::add_error(
445
-                sprintf(
446
-                    esc_html__(
447
-                        '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',
448
-                        'event_espresso'
449
-                    ),
450
-                    $this->_to,
451
-                    $this->_from,
452
-                    '<br />'
453
-                ),
454
-                __FILE__,
455
-                __FUNCTION__,
456
-                __LINE__
457
-            );
458
-        }
459
-        return $success;
460
-    }
461
-
462
-
463
-    /**
464
-     * see parent for definition
465
-     *
466
-     * @return string html body of the message content and the related css.
467
-     * @throws EE_Error
468
-     * @throws \TijsVerkoyen\CssToInlineStyles\Exception
469
-     */
470
-    protected function _preview()
471
-    {
472
-        return $this->_body(true);
473
-    }
474
-
475
-
476
-    /**
477
-     * Setup headers for email
478
-     *
479
-     * @access protected
480
-     * @return string formatted header for email
481
-     */
482
-    protected function _headers()
483
-    {
484
-        $this->_ensure_has_from_email_address();
485
-        $from    = $this->_from;
486
-        $headers = array(
487
-            'From:' . $from,
488
-            'Reply-To:' . $from,
489
-            'Content-Type:text/html; charset=utf-8',
490
-        );
491
-
492
-        /**
493
-         * Second condition added as a result of https://events.codebasehq.com/projects/event-espresso/tickets/11416 to
494
-         * cover back compat where there may be users who have saved cc values in their db for the newsletter message
495
-         * type which they are no longer able to change.
496
-         */
497
-        if (! empty($this->_cc) && ! $this->_incoming_message_type instanceof EE_Newsletter_message_type) {
498
-            $headers[] = 'cc: ' . $this->_cc;
499
-        }
500
-
501
-        //but wait!  Header's for the from is NOT reliable because some plugins don't respect From: as set in the
502
-        // header.
503
-        add_filter('wp_mail_from', array($this, 'set_from_address'), 100);
504
-        add_filter('wp_mail_from_name', array($this, 'set_from_name'), 100);
505
-        return apply_filters('FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this);
506
-    }
507
-
508
-
509
-    /**
510
-     * This simply ensures that the from address is not empty.  If it is, then we use whatever is set as the site email
511
-     * address for the from address to avoid problems with sending emails.
512
-     */
513
-    protected function _ensure_has_from_email_address()
514
-    {
515
-        if (empty($this->_from)) {
516
-            $this->_from = get_bloginfo('admin_email');
517
-        }
518
-    }
519
-
520
-
521
-    /**
522
-     * This simply parses whatever is set as the $_from address and determines if it is in the format {name} <{email}>
523
-     * or just {email} and returns an array with the "from_name" and "from_email" as the values. Note from_name *MAY*
524
-     * be empty
525
-     *
526
-     * @since 4.3.1
527
-     * @return array
528
-     */
529
-    private function _parse_from()
530
-    {
531
-        if (strpos($this->_from, '<') !== false) {
532
-            $from_name = substr($this->_from, 0, strpos($this->_from, '<') - 1);
533
-            $from_name = str_replace('"', '', $from_name);
534
-            $from_name = trim($from_name);
535
-
536
-            $from_email = substr($this->_from, strpos($this->_from, '<') + 1);
537
-            $from_email = str_replace('>', '', $from_email);
538
-            $from_email = trim($from_email);
539
-        } elseif (trim($this->_from) !== '') {
540
-            $from_name  = '';
541
-            $from_email = trim($this->_from);
542
-        } else {
543
-            $from_name = $from_email = '';
544
-        }
545
-        return array($from_name, $from_email);
546
-    }
547
-
548
-
549
-    /**
550
-     * Callback for the wp_mail_from filter.
551
-     *
552
-     * @since 4.3.1
553
-     * @param string $from_email What the original from_email is.
554
-     * @return string
555
-     */
556
-    public function set_from_address($from_email)
557
-    {
558
-        $parsed_from = $this->_parse_from();
559
-        //includes fallback if the parsing failed.
560
-        $from_email = is_array($parsed_from) && ! empty($parsed_from[1])
561
-            ? $parsed_from[1]
562
-            : get_bloginfo('admin_email');
563
-        return $from_email;
564
-    }
565
-
566
-
567
-    /**
568
-     * Callback fro the wp_mail_from_name filter.
569
-     *
570
-     * @since 4.3.1
571
-     * @param string $from_name The original from_name.
572
-     * @return string
573
-     */
574
-    public function set_from_name($from_name)
575
-    {
576
-        $parsed_from = $this->_parse_from();
577
-        if (is_array($parsed_from) && ! empty($parsed_from[0])) {
578
-            $from_name = $parsed_from[0];
579
-        }
580
-
581
-        //if from name is "WordPress" let's sub in the site name instead (more friendly!)
582
-        //but realize the default name is HTML entity-encoded
583
-        $from_name = $from_name == 'WordPress' ? wp_specialchars_decode(get_bloginfo(), ENT_QUOTES) : $from_name;
584
-
585
-        return $from_name;
586
-    }
587
-
588
-
589
-    /**
590
-     * setup body for email
591
-     *
592
-     * @param bool $preview will determine whether this is preview template or not.
593
-     * @return string formatted body for email.
594
-     * @throws EE_Error
595
-     * @throws \TijsVerkoyen\CssToInlineStyles\Exception
596
-     */
597
-    protected function _body($preview = false)
598
-    {
599
-        //setup template args!
600
-        $this->_template_args = array(
601
-            'subject'   => $this->_subject,
602
-            'from'      => $this->_from,
603
-            'main_body' => wpautop($this->_content),
604
-        );
605
-        $body                 = $this->_get_main_template($preview);
606
-
607
-        /**
608
-         * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched.
609
-         *
610
-         * @type    bool $preview Indicates whether a preview is being generated or not.
611
-         * @return  bool    true  indicates to use the inliner, false bypasses it.
612
-         */
613
-        if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) {
614
-            //require CssToInlineStyles library and its dependencies via composer autoloader
615
-            require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php';
616
-
617
-            //now if this isn't a preview, let's setup the body so it has inline styles
618
-            if (! $preview || ($preview && defined('DOING_AJAX'))) {
619
-                $style = file_get_contents(
620
-                    $this->get_variation(
621
-                        $this->_tmp_pack,
622
-                        $this->_incoming_message_type->name,
623
-                        false,
624
-                        'main',
625
-                        $this->_variation
626
-                    ),
627
-                    true
628
-                );
629
-                $CSS   = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($body, $style);
630
-                //for some reason the library has a bracket and new line at the beginning.  This takes care of that.
631
-                $body  = ltrim($CSS->convert(true), ">\n");
632
-                //see https://events.codebasehq.com/projects/event-espresso/tickets/8609
633
-                $body  = ltrim($body, "<?");
634
-            }
635
-
636
-        }
637
-        return $body;
638
-    }
639
-
640
-
641
-    /**
642
-     * This just returns any existing test settings that might be saved in the database
643
-     *
644
-     * @access public
645
-     * @return array
646
-     */
647
-    public function get_existing_test_settings()
648
-    {
649
-        $settings = parent::get_existing_test_settings();
650
-        //override subject if present because we always want it to be fresh.
651
-        if (is_array($settings) && ! empty($settings['subject'])) {
652
-            $settings['subject'] = sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name'));
653
-        }
654
-        return $settings;
655
-    }
11
+	/**
12
+	 * To field for email
13
+	 * @var string
14
+	 */
15
+	protected $_to = '';
16
+
17
+
18
+	/**
19
+	 * CC field for email.
20
+	 * @var string
21
+	 */
22
+	protected $_cc = '';
23
+
24
+	/**
25
+	 * From field for email
26
+	 * @var string
27
+	 */
28
+	protected $_from = '';
29
+
30
+
31
+	/**
32
+	 * Subject field for email
33
+	 * @var string
34
+	 */
35
+	protected $_subject = '';
36
+
37
+
38
+	/**
39
+	 * Content field for email
40
+	 * @var string
41
+	 */
42
+	protected $_content = '';
43
+
44
+
45
+	/**
46
+	 * constructor
47
+	 *
48
+	 * @access public
49
+	 */
50
+	public function __construct()
51
+	{
52
+		//set name and description properties
53
+		$this->name                = 'email';
54
+		$this->description         = sprintf(
55
+			esc_html__(
56
+				'This messenger delivers messages via email using the built-in %s function included with WordPress',
57
+				'event_espresso'
58
+			),
59
+			'<code>wp_mail</code>'
60
+		);
61
+		$this->label               = array(
62
+			'singular' => esc_html__('email', 'event_espresso'),
63
+			'plural'   => esc_html__('emails', 'event_espresso'),
64
+		);
65
+		$this->activate_on_install = true;
66
+
67
+		//we're using defaults so let's call parent constructor that will take care of setting up all the other
68
+		// properties
69
+		parent::__construct();
70
+	}
71
+
72
+
73
+	/**
74
+	 * see abstract declaration in parent class for details.
75
+	 */
76
+	protected function _set_admin_pages()
77
+	{
78
+		$this->admin_registered_pages = array(
79
+			'events_edit' => true,
80
+		);
81
+	}
82
+
83
+
84
+	/**
85
+	 * see abstract declaration in parent class for details
86
+	 */
87
+	protected function _set_valid_shortcodes()
88
+	{
89
+		//remember by leaving the other fields not set, those fields will inherit the valid shortcodes from the
90
+		// message type.
91
+		$this->_valid_shortcodes = array(
92
+			'to'   => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
93
+			'cc' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
94
+			'from' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
95
+		);
96
+	}
97
+
98
+
99
+	/**
100
+	 * see abstract declaration in parent class for details
101
+	 *
102
+	 * @access protected
103
+	 * @return void
104
+	 */
105
+	protected function _set_validator_config()
106
+	{
107
+		$valid_shortcodes = $this->get_valid_shortcodes();
108
+
109
+		$this->_validator_config = array(
110
+			'to'            => array(
111
+				'shortcodes' => $valid_shortcodes['to'],
112
+				'type'       => 'email',
113
+			),
114
+			'cc' => array(
115
+				'shortcodes' => $valid_shortcodes['to'],
116
+				'type' => 'email',
117
+			),
118
+			'from'          => array(
119
+				'shortcodes' => $valid_shortcodes['from'],
120
+				'type'       => 'email',
121
+			),
122
+			'subject'       => array(
123
+				'shortcodes' => array(
124
+					'organization',
125
+					'primary_registration_details',
126
+					'event_author',
127
+					'primary_registration_details',
128
+					'recipient_details',
129
+				),
130
+			),
131
+			'content'       => array(
132
+				'shortcodes' => array(
133
+					'event_list',
134
+					'attendee_list',
135
+					'ticket_list',
136
+					'organization',
137
+					'primary_registration_details',
138
+					'primary_registration_list',
139
+					'event_author',
140
+					'recipient_details',
141
+					'recipient_list',
142
+					'transaction',
143
+					'messenger',
144
+				),
145
+			),
146
+			'attendee_list' => array(
147
+				'shortcodes' => array('attendee', 'event_list', 'ticket_list'),
148
+				'required'   => array('[ATTENDEE_LIST]'),
149
+			),
150
+			'event_list'    => array(
151
+				'shortcodes' => array(
152
+					'event',
153
+					'attendee_list',
154
+					'ticket_list',
155
+					'venue',
156
+					'datetime_list',
157
+					'attendee',
158
+					'primary_registration_details',
159
+					'primary_registration_list',
160
+					'event_author',
161
+					'recipient_details',
162
+					'recipient_list',
163
+				),
164
+				'required'   => array('[EVENT_LIST]'),
165
+			),
166
+			'ticket_list'   => array(
167
+				'shortcodes' => array(
168
+					'event_list',
169
+					'attendee_list',
170
+					'ticket',
171
+					'datetime_list',
172
+					'primary_registration_details',
173
+					'recipient_details',
174
+				),
175
+				'required'   => array('[TICKET_LIST]'),
176
+			),
177
+			'datetime_list' => array(
178
+				'shortcodes' => array('datetime'),
179
+				'required'   => array('[DATETIME_LIST]'),
180
+			),
181
+		);
182
+	}
183
+
184
+
185
+	/**
186
+	 * @see   parent EE_messenger class for docs
187
+	 * @since 4.5.0
188
+	 */
189
+	public function do_secondary_messenger_hooks($sending_messenger_name)
190
+	{
191
+		if ($sending_messenger_name = 'html') {
192
+			add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
193
+		}
194
+	}
195
+
196
+
197
+	public function add_email_css(
198
+		$variation_path,
199
+		$messenger,
200
+		$message_type,
201
+		$type,
202
+		$variation,
203
+		$file_extension,
204
+		$url,
205
+		EE_Messages_Template_Pack $template_pack
206
+	) {
207
+		//prevent recursion on this callback.
208
+		remove_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10);
209
+		$variation = $this->get_variation($template_pack, $message_type, $url, 'main', $variation, false);
210
+
211
+		add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
212
+		return $variation;
213
+	}
214
+
215
+
216
+	/**
217
+	 * See parent for details
218
+	 *
219
+	 * @access protected
220
+	 * @return void
221
+	 */
222
+	protected function _set_test_settings_fields()
223
+	{
224
+		$this->_test_settings_fields = array(
225
+			'to'      => array(
226
+				'input'      => 'text',
227
+				'label'      => esc_html__('Send a test email to', 'event_espresso'),
228
+				'type'       => 'email',
229
+				'required'   => true,
230
+				'validation' => true,
231
+				'css_class'  => 'large-text',
232
+				'format'     => '%s',
233
+				'default'    => get_bloginfo('admin_email'),
234
+			),
235
+			'subject' => array(
236
+				'input'      => 'hidden',
237
+				'label'      => '',
238
+				'type'       => 'string',
239
+				'required'   => false,
240
+				'validation' => false,
241
+				'format'     => '%s',
242
+				'value'      => sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')),
243
+				'default'    => '',
244
+				'css_class'  => '',
245
+			),
246
+		);
247
+	}
248
+
249
+
250
+	/**
251
+	 * _set_template_fields
252
+	 * This sets up the fields that a messenger requires for the message to go out.
253
+	 *
254
+	 * @access  protected
255
+	 * @return void
256
+	 */
257
+	protected function _set_template_fields()
258
+	{
259
+		// any extra template fields that are NOT used by the messenger but will get used by a messenger field for
260
+		// shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field
261
+		// they relate to.  This is important for the Messages_admin to know what fields to display to the user.
262
+		//  Also, notice that the "values" are equal to the field type that messages admin will use to know what
263
+		// kind of field to display. The values ALSO have one index labeled "shortcode".  the values in that array
264
+		// indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be
265
+		// displayed.  If the required shortcode isn't part of the shortcodes array then the field is not needed and
266
+		// will not be displayed/parsed.
267
+		$this->_template_fields = array(
268
+			'to'      => array(
269
+				'input'      => 'text',
270
+				'label'      => esc_html_x(
271
+					'To',
272
+					'Label for the "To" field for email addresses',
273
+					'event_espresso'
274
+				),
275
+				'type'       => 'string',
276
+				'required'   => true,
277
+				'validation' => true,
278
+				'css_class'  => 'large-text',
279
+				'format'     => '%s',
280
+			),
281
+			'cc'      => array(
282
+				'input'      => 'text',
283
+				'label'      => esc_html_x(
284
+					'CC',
285
+					'Label for the "Carbon Copy" field used for additional email addresses',
286
+					'event_espresso'
287
+				),
288
+				'type'       => 'string',
289
+				'required'   => false,
290
+				'validation' => true,
291
+				'css_class'  => 'large-text',
292
+				'format'     => '%s',
293
+			),
294
+			'from'    => array(
295
+				'input'      => 'text',
296
+				'label'      => esc_html_x(
297
+					'From',
298
+					'Label for the "From" field for email addresses.',
299
+					'event_espresso'
300
+				),
301
+				'type'       => 'string',
302
+				'required'   => true,
303
+				'validation' => true,
304
+				'css_class'  => 'large-text',
305
+				'format'     => '%s',
306
+			),
307
+			'subject' => array(
308
+				'input'      => 'text',
309
+				'label'      => esc_html_x(
310
+					'Subject',
311
+					'Label for the "Subject" field (short description of contents) for emails.',
312
+					'event_espresso'
313
+				),
314
+				'type'       => 'string',
315
+				'required'   => true,
316
+				'validation' => true,
317
+				'css_class'  => 'large-text',
318
+				'format'     => '%s',
319
+			),
320
+			'content' => '',
321
+			//left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field.
322
+			'extra'   => array(
323
+				'content' => array(
324
+					'main'          => array(
325
+						'input'      => 'wp_editor',
326
+						'label'      => esc_html__('Main Content', 'event_espresso'),
327
+						'type'       => 'string',
328
+						'required'   => true,
329
+						'validation' => true,
330
+						'format'     => '%s',
331
+						'rows'       => '15',
332
+					),
333
+					'event_list'    => array(
334
+						'input'               => 'wp_editor',
335
+						'label'               => '[EVENT_LIST]',
336
+						'type'                => 'string',
337
+						'required'            => true,
338
+						'validation'          => true,
339
+						'format'              => '%s',
340
+						'rows'                => '15',
341
+						'shortcodes_required' => array('[EVENT_LIST]'),
342
+					),
343
+					'attendee_list' => array(
344
+						'input'               => 'textarea',
345
+						'label'               => '[ATTENDEE_LIST]',
346
+						'type'                => 'string',
347
+						'required'            => true,
348
+						'validation'          => true,
349
+						'format'              => '%s',
350
+						'css_class'           => 'large-text',
351
+						'rows'                => '5',
352
+						'shortcodes_required' => array('[ATTENDEE_LIST]'),
353
+					),
354
+					'ticket_list'   => array(
355
+						'input'               => 'textarea',
356
+						'label'               => '[TICKET_LIST]',
357
+						'type'                => 'string',
358
+						'required'            => true,
359
+						'validation'          => true,
360
+						'format'              => '%s',
361
+						'css_class'           => 'large-text',
362
+						'rows'                => '10',
363
+						'shortcodes_required' => array('[TICKET_LIST]'),
364
+					),
365
+					'datetime_list' => array(
366
+						'input'               => 'textarea',
367
+						'label'               => '[DATETIME_LIST]',
368
+						'type'                => 'string',
369
+						'required'            => true,
370
+						'validation'          => true,
371
+						'format'              => '%s',
372
+						'css_class'           => 'large-text',
373
+						'rows'                => '10',
374
+						'shortcodes_required' => array('[DATETIME_LIST]'),
375
+					),
376
+				),
377
+			),
378
+		);
379
+	}
380
+
381
+
382
+	/**
383
+	 * See definition of this class in parent
384
+	 */
385
+	protected function _set_default_message_types()
386
+	{
387
+		$this->_default_message_types = array(
388
+			'payment',
389
+			'payment_refund',
390
+			'registration',
391
+			'not_approved_registration',
392
+			'pending_approval',
393
+		);
394
+	}
395
+
396
+
397
+	/**
398
+	 * @see   definition of this class in parent
399
+	 * @since 4.5.0
400
+	 */
401
+	protected function _set_valid_message_types()
402
+	{
403
+		$this->_valid_message_types = array(
404
+			'payment',
405
+			'registration',
406
+			'not_approved_registration',
407
+			'declined_registration',
408
+			'cancelled_registration',
409
+			'pending_approval',
410
+			'registration_summary',
411
+			'payment_reminder',
412
+			'payment_declined',
413
+			'payment_refund',
414
+		);
415
+	}
416
+
417
+
418
+	/**
419
+	 * setting up admin_settings_fields for messenger.
420
+	 */
421
+	protected function _set_admin_settings_fields()
422
+	{
423
+	}
424
+
425
+	/**
426
+	 * We just deliver the messages don't kill us!!
427
+	 *
428
+	 * @return bool|WP_Error true if message delivered, false if it didn't deliver OR bubble up any error object if
429
+	 *              present.
430
+	 * @throws EE_Error
431
+	 * @throws \TijsVerkoyen\CssToInlineStyles\Exception
432
+	 */
433
+	protected function _send_message()
434
+	{
435
+		$success = wp_mail(
436
+			$this->_to,
437
+			//some old values for subject may be expecting HTML entities to be decoded in the subject
438
+			//and subjects aren't interpreted as HTML, so there should be no HTML in them
439
+			wp_strip_all_tags(wp_specialchars_decode($this->_subject, ENT_QUOTES)),
440
+			$this->_body(),
441
+			$this->_headers()
442
+		);
443
+		if (! $success) {
444
+			EE_Error::add_error(
445
+				sprintf(
446
+					esc_html__(
447
+						'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',
448
+						'event_espresso'
449
+					),
450
+					$this->_to,
451
+					$this->_from,
452
+					'<br />'
453
+				),
454
+				__FILE__,
455
+				__FUNCTION__,
456
+				__LINE__
457
+			);
458
+		}
459
+		return $success;
460
+	}
461
+
462
+
463
+	/**
464
+	 * see parent for definition
465
+	 *
466
+	 * @return string html body of the message content and the related css.
467
+	 * @throws EE_Error
468
+	 * @throws \TijsVerkoyen\CssToInlineStyles\Exception
469
+	 */
470
+	protected function _preview()
471
+	{
472
+		return $this->_body(true);
473
+	}
474
+
475
+
476
+	/**
477
+	 * Setup headers for email
478
+	 *
479
+	 * @access protected
480
+	 * @return string formatted header for email
481
+	 */
482
+	protected function _headers()
483
+	{
484
+		$this->_ensure_has_from_email_address();
485
+		$from    = $this->_from;
486
+		$headers = array(
487
+			'From:' . $from,
488
+			'Reply-To:' . $from,
489
+			'Content-Type:text/html; charset=utf-8',
490
+		);
491
+
492
+		/**
493
+		 * Second condition added as a result of https://events.codebasehq.com/projects/event-espresso/tickets/11416 to
494
+		 * cover back compat where there may be users who have saved cc values in their db for the newsletter message
495
+		 * type which they are no longer able to change.
496
+		 */
497
+		if (! empty($this->_cc) && ! $this->_incoming_message_type instanceof EE_Newsletter_message_type) {
498
+			$headers[] = 'cc: ' . $this->_cc;
499
+		}
500
+
501
+		//but wait!  Header's for the from is NOT reliable because some plugins don't respect From: as set in the
502
+		// header.
503
+		add_filter('wp_mail_from', array($this, 'set_from_address'), 100);
504
+		add_filter('wp_mail_from_name', array($this, 'set_from_name'), 100);
505
+		return apply_filters('FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this);
506
+	}
507
+
508
+
509
+	/**
510
+	 * This simply ensures that the from address is not empty.  If it is, then we use whatever is set as the site email
511
+	 * address for the from address to avoid problems with sending emails.
512
+	 */
513
+	protected function _ensure_has_from_email_address()
514
+	{
515
+		if (empty($this->_from)) {
516
+			$this->_from = get_bloginfo('admin_email');
517
+		}
518
+	}
519
+
520
+
521
+	/**
522
+	 * This simply parses whatever is set as the $_from address and determines if it is in the format {name} <{email}>
523
+	 * or just {email} and returns an array with the "from_name" and "from_email" as the values. Note from_name *MAY*
524
+	 * be empty
525
+	 *
526
+	 * @since 4.3.1
527
+	 * @return array
528
+	 */
529
+	private function _parse_from()
530
+	{
531
+		if (strpos($this->_from, '<') !== false) {
532
+			$from_name = substr($this->_from, 0, strpos($this->_from, '<') - 1);
533
+			$from_name = str_replace('"', '', $from_name);
534
+			$from_name = trim($from_name);
535
+
536
+			$from_email = substr($this->_from, strpos($this->_from, '<') + 1);
537
+			$from_email = str_replace('>', '', $from_email);
538
+			$from_email = trim($from_email);
539
+		} elseif (trim($this->_from) !== '') {
540
+			$from_name  = '';
541
+			$from_email = trim($this->_from);
542
+		} else {
543
+			$from_name = $from_email = '';
544
+		}
545
+		return array($from_name, $from_email);
546
+	}
547
+
548
+
549
+	/**
550
+	 * Callback for the wp_mail_from filter.
551
+	 *
552
+	 * @since 4.3.1
553
+	 * @param string $from_email What the original from_email is.
554
+	 * @return string
555
+	 */
556
+	public function set_from_address($from_email)
557
+	{
558
+		$parsed_from = $this->_parse_from();
559
+		//includes fallback if the parsing failed.
560
+		$from_email = is_array($parsed_from) && ! empty($parsed_from[1])
561
+			? $parsed_from[1]
562
+			: get_bloginfo('admin_email');
563
+		return $from_email;
564
+	}
565
+
566
+
567
+	/**
568
+	 * Callback fro the wp_mail_from_name filter.
569
+	 *
570
+	 * @since 4.3.1
571
+	 * @param string $from_name The original from_name.
572
+	 * @return string
573
+	 */
574
+	public function set_from_name($from_name)
575
+	{
576
+		$parsed_from = $this->_parse_from();
577
+		if (is_array($parsed_from) && ! empty($parsed_from[0])) {
578
+			$from_name = $parsed_from[0];
579
+		}
580
+
581
+		//if from name is "WordPress" let's sub in the site name instead (more friendly!)
582
+		//but realize the default name is HTML entity-encoded
583
+		$from_name = $from_name == 'WordPress' ? wp_specialchars_decode(get_bloginfo(), ENT_QUOTES) : $from_name;
584
+
585
+		return $from_name;
586
+	}
587
+
588
+
589
+	/**
590
+	 * setup body for email
591
+	 *
592
+	 * @param bool $preview will determine whether this is preview template or not.
593
+	 * @return string formatted body for email.
594
+	 * @throws EE_Error
595
+	 * @throws \TijsVerkoyen\CssToInlineStyles\Exception
596
+	 */
597
+	protected function _body($preview = false)
598
+	{
599
+		//setup template args!
600
+		$this->_template_args = array(
601
+			'subject'   => $this->_subject,
602
+			'from'      => $this->_from,
603
+			'main_body' => wpautop($this->_content),
604
+		);
605
+		$body                 = $this->_get_main_template($preview);
606
+
607
+		/**
608
+		 * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched.
609
+		 *
610
+		 * @type    bool $preview Indicates whether a preview is being generated or not.
611
+		 * @return  bool    true  indicates to use the inliner, false bypasses it.
612
+		 */
613
+		if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) {
614
+			//require CssToInlineStyles library and its dependencies via composer autoloader
615
+			require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php';
616
+
617
+			//now if this isn't a preview, let's setup the body so it has inline styles
618
+			if (! $preview || ($preview && defined('DOING_AJAX'))) {
619
+				$style = file_get_contents(
620
+					$this->get_variation(
621
+						$this->_tmp_pack,
622
+						$this->_incoming_message_type->name,
623
+						false,
624
+						'main',
625
+						$this->_variation
626
+					),
627
+					true
628
+				);
629
+				$CSS   = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($body, $style);
630
+				//for some reason the library has a bracket and new line at the beginning.  This takes care of that.
631
+				$body  = ltrim($CSS->convert(true), ">\n");
632
+				//see https://events.codebasehq.com/projects/event-espresso/tickets/8609
633
+				$body  = ltrim($body, "<?");
634
+			}
635
+
636
+		}
637
+		return $body;
638
+	}
639
+
640
+
641
+	/**
642
+	 * This just returns any existing test settings that might be saved in the database
643
+	 *
644
+	 * @access public
645
+	 * @return array
646
+	 */
647
+	public function get_existing_test_settings()
648
+	{
649
+		$settings = parent::get_existing_test_settings();
650
+		//override subject if present because we always want it to be fresh.
651
+		if (is_array($settings) && ! empty($settings['subject'])) {
652
+			$settings['subject'] = sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name'));
653
+		}
654
+		return $settings;
655
+	}
656 656
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
             ),
59 59
             '<code>wp_mail</code>'
60 60
         );
61
-        $this->label               = array(
61
+        $this->label = array(
62 62
             'singular' => esc_html__('email', 'event_espresso'),
63 63
             'plural'   => esc_html__('emails', 'event_espresso'),
64 64
         );
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
             $this->_body(),
441 441
             $this->_headers()
442 442
         );
443
-        if (! $success) {
443
+        if ( ! $success) {
444 444
             EE_Error::add_error(
445 445
                 sprintf(
446 446
                     esc_html__(
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
         $this->_ensure_has_from_email_address();
485 485
         $from    = $this->_from;
486 486
         $headers = array(
487
-            'From:' . $from,
488
-            'Reply-To:' . $from,
487
+            'From:'.$from,
488
+            'Reply-To:'.$from,
489 489
             'Content-Type:text/html; charset=utf-8',
490 490
         );
491 491
 
@@ -494,8 +494,8 @@  discard block
 block discarded – undo
494 494
          * cover back compat where there may be users who have saved cc values in their db for the newsletter message
495 495
          * type which they are no longer able to change.
496 496
          */
497
-        if (! empty($this->_cc) && ! $this->_incoming_message_type instanceof EE_Newsletter_message_type) {
498
-            $headers[] = 'cc: ' . $this->_cc;
497
+        if ( ! empty($this->_cc) && ! $this->_incoming_message_type instanceof EE_Newsletter_message_type) {
498
+            $headers[] = 'cc: '.$this->_cc;
499 499
         }
500 500
 
501 501
         //but wait!  Header's for the from is NOT reliable because some plugins don't respect From: as set in the
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
             'from'      => $this->_from,
603 603
             'main_body' => wpautop($this->_content),
604 604
         );
605
-        $body                 = $this->_get_main_template($preview);
605
+        $body = $this->_get_main_template($preview);
606 606
 
607 607
         /**
608 608
          * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched.
@@ -612,10 +612,10 @@  discard block
 block discarded – undo
612 612
          */
613 613
         if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) {
614 614
             //require CssToInlineStyles library and its dependencies via composer autoloader
615
-            require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php';
615
+            require_once EE_THIRD_PARTY.'cssinliner/vendor/autoload.php';
616 616
 
617 617
             //now if this isn't a preview, let's setup the body so it has inline styles
618
-            if (! $preview || ($preview && defined('DOING_AJAX'))) {
618
+            if ( ! $preview || ($preview && defined('DOING_AJAX'))) {
619 619
                 $style = file_get_contents(
620 620
                     $this->get_variation(
621 621
                         $this->_tmp_pack,
Please login to merge, or discard this patch.
core/libraries/messages/EE_Messages_Base.lib.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -300,20 +300,20 @@
 block discarded – undo
300 300
 	}
301 301
 
302 302
 
303
-    /**
304
-     * Allows a message type to specifically exclude template fields for the provided messenger.
305
-     * Filtered so this can be programmatically altered as well.
306
-     * @param string $messenger_name name of messenger
307
-     * @return array
308
-     */
303
+	/**
304
+	 * Allows a message type to specifically exclude template fields for the provided messenger.
305
+	 * Filtered so this can be programmatically altered as well.
306
+	 * @param string $messenger_name name of messenger
307
+	 * @return array
308
+	 */
309 309
 	public function excludedFieldsForMessenger($messenger_name)
310
-    {
311
-        return apply_filters(
312
-            'FHEE__EE_Messages_Base__excludedFieldForMessenger',
313
-            array(),
314
-            $messenger_name,
315
-            $this->name,
316
-            $this
317
-        );
318
-    }
310
+	{
311
+		return apply_filters(
312
+			'FHEE__EE_Messages_Base__excludedFieldForMessenger',
313
+			array(),
314
+			$messenger_name,
315
+			$this->name,
316
+			$this
317
+		);
318
+	}
319 319
 }
Please login to merge, or discard this patch.
core/helpers/EEH_MSG_Template.helper.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 		if ( ! empty( $sending_messenger ) ) {
493 493
 			$with_messengers = $message_type->with_messengers();
494 494
 			if ( ! isset( $with_messengers[$message->messenger()] )
495
-			     || ! in_array( $sending_messenger, $with_messengers[$message->messenger()] ) ) {
495
+				 || ! in_array( $sending_messenger, $with_messengers[$message->messenger()] ) ) {
496 496
 				throw new EE_Error(
497 497
 					sprintf(
498 498
 						__(
@@ -1202,14 +1202,14 @@  discard block
 block discarded – undo
1202 1202
 			return array();
1203 1203
 		}
1204 1204
 
1205
-        $excluded_fields_for_messenger = $message_type->excludedFieldsForMessenger($messenger_name);
1205
+		$excluded_fields_for_messenger = $message_type->excludedFieldsForMessenger($messenger_name);
1206 1206
 
1207 1207
 		//okay now let's assemble an array with the messenger template fields added to the message_type contexts.
1208 1208
 		foreach ( $message_type->get_contexts() as $context => $details ) {
1209 1209
 			foreach ( $messenger->get_template_fields() as $field => $value ) {
1210
-			    if (in_array($field, $excluded_fields_for_messenger, true)) {
1211
-			        continue;
1212
-                }
1210
+				if (in_array($field, $excluded_fields_for_messenger, true)) {
1211
+					continue;
1212
+				}
1213 1213
 				$template_fields[ $context ][ $field ] = $value;
1214 1214
 			}
1215 1215
 		}
Please login to merge, or discard this patch.
Spacing   +197 added lines, -197 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION') )
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('NO direct script access allowed');
5 5
 
6 6
 /**
@@ -59,24 +59,24 @@  discard block
 block discarded – undo
59 59
 	 *                was not a new generated template but just reactivated (which only happens for global templates that
60 60
 	 *                already exist in the database.
61 61
 	 */
62
-	public static function generate_new_templates( $messenger, $message_types, $GRP_ID = 0, $global = false ) {
62
+	public static function generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false) {
63 63
 		//make sure message_type is an array.
64 64
 		$message_types = (array) $message_types;
65 65
 		$templates = array();
66 66
 
67
-		if ( empty( $messenger ) ) {
68
-			throw new EE_Error( __('We need a messenger to generate templates!', 'event_espresso') );
67
+		if (empty($messenger)) {
68
+			throw new EE_Error(__('We need a messenger to generate templates!', 'event_espresso'));
69 69
 		}
70 70
 
71 71
 		//if we STILL have empty $message_types then we need to generate an error message b/c we NEED message types to do the template files.
72
-		if ( empty( $message_types ) ) {
73
-			throw new EE_Error( __('We need at least one message type to generate templates!', 'event_espresso') );
72
+		if (empty($message_types)) {
73
+			throw new EE_Error(__('We need at least one message type to generate templates!', 'event_espresso'));
74 74
 		}
75 75
 
76 76
 		EEH_MSG_Template::_set_autoloader();
77
-		foreach ( $message_types as $message_type ) {
77
+		foreach ($message_types as $message_type) {
78 78
 			//if global then let's attempt to get the GRP_ID for this combo IF GRP_ID is empty.
79
-			if ( $global && empty( $GRP_ID ) ) {
79
+			if ($global && empty($GRP_ID)) {
80 80
 				$GRP_ID = EEM_Message_Template_Group::instance()->get_one(
81 81
 					array(
82 82
 						array(
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 			// if this is global template generation.
92 92
 			// First let's determine if we already HAVE global templates for this messenger and message_type combination.
93 93
 			//  If we do then NO generation!!
94
-			if ( $global && EEH_MSG_Template::already_generated( $messenger, $message_type, $GRP_ID ) ) {
94
+			if ($global && EEH_MSG_Template::already_generated($messenger, $message_type, $GRP_ID)) {
95 95
 				$templates[] = array(
96 96
 					'GRP_ID' => $GRP_ID,
97 97
 					'MTP_context' => '',
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 				//we already have generated templates for this so let's go to the next message type.
100 100
 				continue;
101 101
 			}
102
-			$new_message_template_group = EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $global );
102
+			$new_message_template_group = EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $global);
103 103
 
104
-			if ( ! $new_message_template_group ) {
104
+			if ( ! $new_message_template_group) {
105 105
 				continue;
106 106
 			}
107 107
 			$templates[] = $new_message_template_group;
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
 	 * @param  int $GRP_ID        GRP ID ( if a custom template) (if not provided then we're just doing global template check)
119 119
 	 * @return bool                true = generated, false = hasn't been generated.
120 120
 	 */
121
-	public static function already_generated( $messenger, $message_type, $GRP_ID = 0 ) {
121
+	public static function already_generated($messenger, $message_type, $GRP_ID = 0) {
122 122
 		EEH_MSG_Template::_set_autoloader();
123 123
 		//what method we use depends on whether we have an GRP_ID or not
124
-		$count = empty( $GRP_ID )
124
+		$count = empty($GRP_ID)
125 125
 			? EEM_Message_Template::instance()->count(
126 126
 				array(
127 127
 					array(
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 					)
132 132
 				)
133 133
 			)
134
-			: EEM_Message_Template::instance()->count( array( array( 'GRP_ID' => $GRP_ID ) ) );
134
+			: EEM_Message_Template::instance()->count(array(array('GRP_ID' => $GRP_ID)));
135 135
 
136 136
 		return $count > 0;
137 137
 	}
@@ -147,15 +147,15 @@  discard block
 block discarded – undo
147 147
 	 * @param  array  $message_type_names  Message type slug
148 148
 	 * @return  int 						count of updated records.
149 149
 	 */
150
-	public static function update_to_active( $messenger_names, $message_type_names ) {
151
-		$messenger_names = is_array( $messenger_names ) ? $messenger_names : array( $messenger_names );
152
-		$message_type_names = is_array( $message_type_names ) ? $message_type_names : array( $message_type_names );
150
+	public static function update_to_active($messenger_names, $message_type_names) {
151
+		$messenger_names = is_array($messenger_names) ? $messenger_names : array($messenger_names);
152
+		$message_type_names = is_array($message_type_names) ? $message_type_names : array($message_type_names);
153 153
 		return EEM_Message_Template_Group::instance()->update(
154
-			array( 'MTP_is_active' => 1 ),
154
+			array('MTP_is_active' => 1),
155 155
 			array(
156 156
 				array(
157
-					'MTP_messenger' 	=> array( 'IN', $messenger_names ),
158
-					'MTP_message_type'  => array( 'IN', $message_type_names )
157
+					'MTP_messenger' 	=> array('IN', $messenger_names),
158
+					'MTP_message_type'  => array('IN', $message_type_names)
159 159
 				)
160 160
 			)
161 161
 		);
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 *
177 177
 	 * @return int  count of updated records.
178 178
 	 */
179
-	public static function update_to_inactive( $messenger_names = array(), $message_type_names = array() ) {
179
+	public static function update_to_inactive($messenger_names = array(), $message_type_names = array()) {
180 180
 		return EEM_Message_Template_Group::instance()->deactivate_message_template_groups_for(
181 181
 			$messenger_names,
182 182
 			$message_type_names
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
 	 * @param string $type
194 194
 	 * @return array array consisting of installed messenger objects and installed message type objects.
195 195
 	 */
196
-	public static function get_installed_message_objects( $type = 'all' ) {
196
+	public static function get_installed_message_objects($type = 'all') {
197 197
 		self::_set_autoloader();
198
-		$message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
198
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
199 199
 		return array(
200 200
 			'messenger' => $message_resource_manager->installed_messengers(),
201 201
 			'message_type' => $message_resource_manager->installed_message_types()
@@ -231,74 +231,74 @@  discard block
 block discarded – undo
231 231
 		$context = 'admin',
232 232
 		$merged = false
233 233
 	) {
234
-		$messenger_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $messenger ) ) );
235
-		$mt_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $message_type ) ) );
234
+		$messenger_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $messenger)));
235
+		$mt_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $message_type)));
236 236
 		/** @var EE_Message_Resource_Manager $message_resource_manager */
237
-		$message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
237
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
238 238
 		//convert slug to object
239
-		$messenger = $message_resource_manager->get_messenger( $messenger );
239
+		$messenger = $message_resource_manager->get_messenger($messenger);
240 240
 
241 241
 		//if messenger isn't a EE_messenger resource then bail.
242
-		if ( ! $messenger instanceof EE_messenger ) {
242
+		if ( ! $messenger instanceof EE_messenger) {
243 243
 			return array();
244 244
 		}
245 245
 
246 246
 		//validate class for getting our list of shortcodes
247
-		$classname = 'EE_Messages_' . $messenger_name . '_' . $mt_name . '_Validator';
248
-		if ( ! class_exists( $classname ) ) {
249
-			$msg[] = __( 'The Validator class was unable to load', 'event_espresso' );
247
+		$classname = 'EE_Messages_'.$messenger_name.'_'.$mt_name.'_Validator';
248
+		if ( ! class_exists($classname)) {
249
+			$msg[] = __('The Validator class was unable to load', 'event_espresso');
250 250
 			$msg[] = sprintf(
251
-				__( 'The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', 'event_espresso' ),
251
+				__('The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', 'event_espresso'),
252 252
 				$classname
253 253
 			);
254
-			throw new EE_Error( implode( '||', $msg ) );
254
+			throw new EE_Error(implode('||', $msg));
255 255
 		}
256 256
 
257 257
 		/** @type EE_Messages_Validator $_VLD */
258
-		$_VLD = new $classname( array(), $context );
258
+		$_VLD = new $classname(array(), $context);
259 259
 		$valid_shortcodes = $_VLD->get_validators();
260 260
 
261 261
 		//let's make sure we're only getting the shortcode part of the validators
262 262
 		$shortcodes = array();
263
-		foreach ( $valid_shortcodes as $field => $validators ) {
264
-			$shortcodes[ $field ] = $validators['shortcodes'];
263
+		foreach ($valid_shortcodes as $field => $validators) {
264
+			$shortcodes[$field] = $validators['shortcodes'];
265 265
 		}
266 266
 		$valid_shortcodes = $shortcodes;
267 267
 
268 268
 		//if not all fields let's make sure we ONLY include the shortcodes for the specified fields.
269
-		if ( ! empty( $fields ) ) {
269
+		if ( ! empty($fields)) {
270 270
 			$specified_shortcodes = array();
271
-			foreach ( $fields as $field ) {
272
-				if ( isset( $valid_shortcodes[ $field ] ) ) {
273
-					$specified_shortcodes[ $field ] = $valid_shortcodes[ $field ];
271
+			foreach ($fields as $field) {
272
+				if (isset($valid_shortcodes[$field])) {
273
+					$specified_shortcodes[$field] = $valid_shortcodes[$field];
274 274
 				}
275 275
 			}
276 276
 			$valid_shortcodes = $specified_shortcodes;
277 277
 		}
278 278
 
279 279
 		//if not merged then let's replace the fields with the localized fields
280
-		if ( ! $merged ) {
280
+		if ( ! $merged) {
281 281
 			//let's get all the fields for the set messenger so that we can get the localized label and use that in the returned array.
282 282
 			$field_settings = $messenger->get_template_fields();
283 283
 			$localized = array();
284
-			foreach ( $valid_shortcodes as $field => $shortcodes ) {
284
+			foreach ($valid_shortcodes as $field => $shortcodes) {
285 285
 				//get localized field label
286
-				if ( isset( $field_settings[ $field ] ) ) {
286
+				if (isset($field_settings[$field])) {
287 287
 					//possible that this is used as a main field.
288
-					if ( empty( $field_settings[ $field ] ) ) {
289
-						if ( isset( $field_settings['extra'][ $field ] ) ) {
290
-							$_field = $field_settings['extra'][ $field ]['main']['label'];
288
+					if (empty($field_settings[$field])) {
289
+						if (isset($field_settings['extra'][$field])) {
290
+							$_field = $field_settings['extra'][$field]['main']['label'];
291 291
 						} else {
292 292
 							$_field = $field;
293 293
 						}
294 294
 					} else {
295
-						$_field = $field_settings[ $field ]['label'];
295
+						$_field = $field_settings[$field]['label'];
296 296
 					}
297
-				} else if ( isset( $field_settings['extra'] ) ) {
297
+				} else if (isset($field_settings['extra'])) {
298 298
 					//loop through extra "main fields" and see if any of their children have our field
299
-					foreach ( $field_settings['extra'] as $main_field => $fields ) {
300
-						if ( isset( $fields[ $field ] ) ) {
301
-							$_field = $fields[ $field ]['label'];
299
+					foreach ($field_settings['extra'] as $main_field => $fields) {
300
+						if (isset($fields[$field])) {
301
+							$_field = $fields[$field]['label'];
302 302
 						} else {
303 303
 							$_field = $field;
304 304
 						}
@@ -306,22 +306,22 @@  discard block
 block discarded – undo
306 306
 				} else {
307 307
 					$_field = $field;
308 308
 				}
309
-				if ( isset( $_field ) ) {
310
-					$localized[ $_field ] = $shortcodes;
309
+				if (isset($_field)) {
310
+					$localized[$_field] = $shortcodes;
311 311
 				}
312 312
 			}
313 313
 			$valid_shortcodes = $localized;
314 314
 		}
315 315
 
316 316
 		//if $merged then let's merge all the shortcodes into one list NOT indexed by field.
317
-		if ( $merged ) {
317
+		if ($merged) {
318 318
 			$merged_codes = array();
319
-			foreach ( $valid_shortcodes as $field => $shortcode ) {
320
-				foreach ( $shortcode as $code => $label ) {
321
-					if ( isset( $merged_codes[ $code ] ) ) {
319
+			foreach ($valid_shortcodes as $field => $shortcode) {
320
+				foreach ($shortcode as $code => $label) {
321
+					if (isset($merged_codes[$code])) {
322 322
 						continue;
323 323
 					} else {
324
-						$merged_codes[ $code ] = $label;
324
+						$merged_codes[$code] = $label;
325 325
 					}
326 326
 				}
327 327
 			}
@@ -341,10 +341,10 @@  discard block
 block discarded – undo
341 341
 	 * @throws \EE_Error
342 342
 	 * @return EE_messenger
343 343
 	 */
344
-	public static function messenger_obj( $messenger ) {
344
+	public static function messenger_obj($messenger) {
345 345
 		/** @type EE_Message_Resource_Manager $Message_Resource_Manager */
346
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
347
-		return $Message_Resource_Manager->get_messenger( $messenger );
346
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
347
+		return $Message_Resource_Manager->get_messenger($messenger);
348 348
 	}
349 349
 
350 350
 
@@ -357,10 +357,10 @@  discard block
 block discarded – undo
357 357
 	 * @throws \EE_Error
358 358
 	 * @return EE_message_type
359 359
 	 */
360
-	public static function message_type_obj( $message_type ) {
360
+	public static function message_type_obj($message_type) {
361 361
 		/** @type EE_Message_Resource_Manager $Message_Resource_Manager */
362
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
363
-		return $Message_Resource_Manager->get_message_type( $message_type );
362
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
363
+		return $Message_Resource_Manager->get_message_type($message_type);
364 364
 	}
365 365
 
366 366
 
@@ -374,11 +374,11 @@  discard block
 block discarded – undo
374 374
 	 * @param  string   $message_type message type to check for.
375 375
 	 * @return boolean
376 376
 	 */
377
-	public static function is_mt_active( $message_type ) {
377
+	public static function is_mt_active($message_type) {
378 378
 		/** @type EE_Message_Resource_Manager $Message_Resource_Manager */
379
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
379
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
380 380
 		$active_mts = $Message_Resource_Manager->list_of_active_message_types();
381
-		return in_array( $message_type, $active_mts );
381
+		return in_array($message_type, $active_mts);
382 382
 	}
383 383
 
384 384
 
@@ -391,10 +391,10 @@  discard block
 block discarded – undo
391 391
 	 * @param  string  $messenger slug for messenger to check.
392 392
 	 * @return boolean
393 393
 	 */
394
-	public static function is_messenger_active( $messenger ) {
394
+	public static function is_messenger_active($messenger) {
395 395
 		/** @type EE_Message_Resource_Manager $Message_Resource_Manager */
396
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
397
-		$active_messenger = $Message_Resource_Manager->get_active_messenger( $messenger );
396
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
397
+		$active_messenger = $Message_Resource_Manager->get_active_messenger($messenger);
398 398
 		return $active_messenger instanceof EE_messenger ? true : false;
399 399
 	}
400 400
 
@@ -412,11 +412,11 @@  discard block
 block discarded – undo
412 412
 	public static function get_active_messengers_in_db() {
413 413
 		EE_Error::doing_it_wrong(
414 414
 			__METHOD__,
415
-			__( 'Please use EE_Message_Resource_Manager::get_active_messengers_option() instead.', 'event_espresso' ),
415
+			__('Please use EE_Message_Resource_Manager::get_active_messengers_option() instead.', 'event_espresso'),
416 416
 			'4.9.0'
417 417
 		);
418 418
 		/** @var EE_Message_Resource_Manager $Message_Resource_Manager */
419
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
419
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
420 420
 		return $Message_Resource_Manager->get_active_messengers_option();
421 421
 	}
422 422
 
@@ -433,15 +433,15 @@  discard block
 block discarded – undo
433 433
 	 *
434 434
 	 * @return bool FALSE if not updated, TRUE if updated.
435 435
 	 */
436
-	public static function update_active_messengers_in_db( $data_to_save ) {
436
+	public static function update_active_messengers_in_db($data_to_save) {
437 437
 		EE_Error::doing_it_wrong(
438 438
 			__METHOD__,
439
-			__( 'Please use EE_Message_Resource_Manager::update_active_messengers_option() instead.', 'event_espresso' ),
439
+			__('Please use EE_Message_Resource_Manager::update_active_messengers_option() instead.', 'event_espresso'),
440 440
 			'4.9.0'
441 441
 		);
442 442
 		/** @var EE_Message_Resource_Manager $Message_Resource_Manager */
443
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
444
-		return $Message_Resource_Manager->update_active_messengers_option( $data_to_save );
443
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
444
+		return $Message_Resource_Manager->update_active_messengers_option($data_to_save);
445 445
 	}
446 446
 
447 447
 
@@ -465,34 +465,34 @@  discard block
 block discarded – undo
465 465
 		$sending_messenger = ''
466 466
 	) {
467 467
 		//first determine if the url can be to the EE_Message object.
468
-		if ( ! $message_type->always_generate() ) {
469
-			return EEH_MSG_Template::generate_browser_trigger( $message );
468
+		if ( ! $message_type->always_generate()) {
469
+			return EEH_MSG_Template::generate_browser_trigger($message);
470 470
 		}
471 471
 
472 472
 		//if $registration object is not valid then exit early because there's nothing that can be generated.
473
-		if ( ! $registration instanceof EE_Registration ) {
473
+		if ( ! $registration instanceof EE_Registration) {
474 474
 			throw new EE_Error(
475
-				__( 'Incoming value for registration is not a valid EE_Registration object.', 'event_espresso' )
475
+				__('Incoming value for registration is not a valid EE_Registration object.', 'event_espresso')
476 476
 			);
477 477
 		}
478 478
 
479 479
 		//validate given context
480 480
 		$contexts = $message_type->get_contexts();
481
-		if ( $message->context() !== '' && ! isset( $contexts[$message->context()] ) ) {
481
+		if ($message->context() !== '' && ! isset($contexts[$message->context()])) {
482 482
 			throw new EE_Error(
483 483
 				sprintf(
484
-					__( 'The context %s is not a valid context for %s.', 'event_espresso' ),
484
+					__('The context %s is not a valid context for %s.', 'event_espresso'),
485 485
 					$message->context(),
486
-					get_class( $message_type )
486
+					get_class($message_type)
487 487
 				)
488 488
 			);
489 489
 		}
490 490
 
491 491
 		//valid sending messenger but only if sending messenger set.  Otherwise generating messenger is used.
492
-		if ( ! empty( $sending_messenger ) ) {
492
+		if ( ! empty($sending_messenger)) {
493 493
 			$with_messengers = $message_type->with_messengers();
494
-			if ( ! isset( $with_messengers[$message->messenger()] )
495
-			     || ! in_array( $sending_messenger, $with_messengers[$message->messenger()] ) ) {
494
+			if ( ! isset($with_messengers[$message->messenger()])
495
+			     || ! in_array($sending_messenger, $with_messengers[$message->messenger()])) {
496 496
 				throw new EE_Error(
497 497
 					sprintf(
498 498
 						__(
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 							'event_espresso'
501 501
 						),
502 502
 						$sending_messenger,
503
-						get_class( $message_type )
503
+						get_class($message_type)
504 504
 					)
505 505
 				);
506 506
 			}
@@ -523,14 +523,14 @@  discard block
 block discarded – undo
523 523
 	 * @param EE_Message $message
524 524
 	 * @return string.
525 525
 	 */
526
-	public static function generate_browser_trigger( EE_Message $message ) {
526
+	public static function generate_browser_trigger(EE_Message $message) {
527 527
 		$query_args = array(
528 528
 			'ee' => 'msg_browser_trigger',
529 529
 			'token' => $message->MSG_token()
530 530
 		);
531 531
 		return apply_filters(
532 532
 			'FHEE__EEH_MSG_Template__generate_browser_trigger',
533
-			add_query_arg( $query_args, site_url() ),
533
+			add_query_arg($query_args, site_url()),
534 534
 			$message
535 535
 		);
536 536
 	}
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 	 * @param EE_Message $message
546 546
 	 * @return string
547 547
 	 */
548
-	public static function generate_error_display_trigger( EE_Message $message ) {
548
+	public static function generate_error_display_trigger(EE_Message $message) {
549 549
 		return apply_filters(
550 550
 			'FHEE__EEH_MSG_Template__generate_error_display_trigger',
551 551
 			add_query_arg(
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 			'GRP_ID' => $message_template_group,
596 596
 			'id' => $data_id
597 597
 			);
598
-		$url = add_query_arg( $query_args, get_home_url() );
598
+		$url = add_query_arg($query_args, get_home_url());
599 599
 
600 600
 		//made it here so now we can just get the url and filter it.  Filtered globally and by message type.
601 601
 		$url = apply_filters(
@@ -623,9 +623,9 @@  discard block
 block discarded – undo
623 623
 	 * @param string $type  What action to return.
624 624
 	 * @return string
625 625
 	 */
626
-	public static function get_message_action_icon( $type ) {
626
+	public static function get_message_action_icon($type) {
627 627
 		$action_icons = self::get_message_action_icons();
628
-		return isset( $action_icons[ $type ] ) ? $action_icons[ $type ] : '';
628
+		return isset($action_icons[$type]) ? $action_icons[$type] : '';
629 629
 	}
630 630
 
631 631
 
@@ -637,34 +637,34 @@  discard block
 block discarded – undo
637 637
 	 * @return array
638 638
 	 */
639 639
 	public static function get_message_action_icons() {
640
-		return apply_filters( 'FHEE__EEH_MSG_Template__message_action_icons',
640
+		return apply_filters('FHEE__EEH_MSG_Template__message_action_icons',
641 641
 			array(
642 642
 				'view' => array(
643
-					'label' => __( 'View Message', 'event_espresso' ),
643
+					'label' => __('View Message', 'event_espresso'),
644 644
 					'css_class' => 'dashicons dashicons-welcome-view-site',
645 645
 				),
646 646
 				'error' => array(
647
-					'label' => __( 'View Error Message', 'event_espresso' ),
647
+					'label' => __('View Error Message', 'event_espresso'),
648 648
 					'css_class' => 'dashicons dashicons-info',
649 649
 				),
650 650
 				'see_notifications_for' => array(
651
-					'label' => __( 'View Related Messages', 'event_espresso' ),
651
+					'label' => __('View Related Messages', 'event_espresso'),
652 652
 					'css_class' => 'dashicons dashicons-megaphone',
653 653
 				),
654 654
 				'generate_now' => array(
655
-					'label' => __( 'Generate the message now.', 'event_espresso' ),
655
+					'label' => __('Generate the message now.', 'event_espresso'),
656 656
 					'css_class' => 'dashicons dashicons-admin-tools',
657 657
 				),
658 658
 				'send_now' => array(
659
-					'label' => __( 'Send Immediately', 'event_espresso' ),
659
+					'label' => __('Send Immediately', 'event_espresso'),
660 660
 					'css_class' => 'dashicons dashicons-controls-forward',
661 661
 				),
662 662
 				'queue_for_resending' => array(
663
-					'label' => __( 'Queue for Resending', 'event_espresso' ),
663
+					'label' => __('Queue for Resending', 'event_espresso'),
664 664
 					'css_class' => 'dashicons dashicons-controls-repeat',
665 665
 				),
666 666
 				'view_transaction' => array(
667
-					'label' => __( 'View related Transaction', 'event_espresso' ),
667
+					'label' => __('View related Transaction', 'event_espresso'),
668 668
 					'css_class' => 'dashicons dashicons-cart',
669 669
 				)
670 670
 			)
@@ -683,9 +683,9 @@  discard block
 block discarded – undo
683 683
 	 *
684 684
 	 * @return string
685 685
 	 */
686
-	public static function get_message_action_url( $type, EE_Message $message = null, $query_params = array() ) {
687
-		$action_urls = self::get_message_action_urls( $message, $query_params );
688
-		return isset( $action_urls[ $type ] )  ? $action_urls[ $type ] : '';
686
+	public static function get_message_action_url($type, EE_Message $message = null, $query_params = array()) {
687
+		$action_urls = self::get_message_action_urls($message, $query_params);
688
+		return isset($action_urls[$type]) ? $action_urls[$type] : '';
689 689
 	}
690 690
 
691 691
 
@@ -700,15 +700,15 @@  discard block
 block discarded – undo
700 700
 	 *
701 701
 	 * @return array
702 702
 	 */
703
-	public static function get_message_action_urls( EE_Message $message = null, $query_params = array() ) {
704
-		EE_Registry::instance()->load_helper( 'URL' );
703
+	public static function get_message_action_urls(EE_Message $message = null, $query_params = array()) {
704
+		EE_Registry::instance()->load_helper('URL');
705 705
 		//if $message is not an instance of EE_Message then let's just do a dummy.
706
-		$message = empty( $message ) ? EE_Message_Factory::create() : $message;
707
-		$action_urls =  apply_filters(
706
+		$message = empty($message) ? EE_Message_Factory::create() : $message;
707
+		$action_urls = apply_filters(
708 708
 			'FHEE__EEH_MSG_Template__get_message_action_url',
709 709
 			array(
710
-				'view' => EEH_MSG_Template::generate_browser_trigger( $message ),
711
-				'error' => EEH_MSG_Template::generate_error_display_trigger( $message ),
710
+				'view' => EEH_MSG_Template::generate_browser_trigger($message),
711
+				'error' => EEH_MSG_Template::generate_error_display_trigger($message),
712 712
 				'see_notifications_for' => EEH_URL::add_query_args_and_nonce(
713 713
 					array_merge(
714 714
 						array(
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 						),
719 719
 						$query_params
720 720
 					),
721
-					admin_url( 'admin.php' )
721
+					admin_url('admin.php')
722 722
 				),
723 723
 				'generate_now' => EEH_URL::add_query_args_and_nonce(
724 724
 					array(
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 						'action' => 'generate_now',
727 727
 						'MSG_ID' => $message->ID()
728 728
 					),
729
-					admin_url( 'admin.php' )
729
+					admin_url('admin.php')
730 730
 				),
731 731
 				'send_now' => EEH_URL::add_query_args_and_nonce(
732 732
 					array(
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 						'action' => 'send_now',
735 735
 						'MSG_ID' => $message->ID()
736 736
 					),
737
-					admin_url( 'admin.php' )
737
+					admin_url('admin.php')
738 738
 				),
739 739
 				'queue_for_resending' => EEH_URL::add_query_args_and_nonce(
740 740
 					array(
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 						'action' => 'queue_for_resending',
743 743
 						'MSG_ID' => $message->ID()
744 744
 					),
745
-					admin_url( 'admin.php' )
745
+					admin_url('admin.php')
746 746
 				),
747 747
 			)
748 748
 		);
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 					'action' => 'view_transaction',
761 761
 					'TXN_ID' => $message->TXN_ID()
762 762
 				),
763
-				admin_url( 'admin.php' )
763
+				admin_url('admin.php')
764 764
 			);
765 765
 		} else {
766 766
 			$action_urls['view_transaction'] = '';
@@ -781,26 +781,26 @@  discard block
 block discarded – undo
781 781
 	 *
782 782
 	 * @return string
783 783
 	 */
784
-	public static function get_message_action_link( $type, EE_Message $message = null, $query_params = array() ) {
785
-		$url = EEH_MSG_Template::get_message_action_url( $type, $message, $query_params );
786
-		$icon_css = EEH_MSG_Template::get_message_action_icon( $type );
787
-		$title = isset( $icon_css['label'] ) ? 'title="' . $icon_css['label'] . '"' : '';
784
+	public static function get_message_action_link($type, EE_Message $message = null, $query_params = array()) {
785
+		$url = EEH_MSG_Template::get_message_action_url($type, $message, $query_params);
786
+		$icon_css = EEH_MSG_Template::get_message_action_icon($type);
787
+		$title = isset($icon_css['label']) ? 'title="'.$icon_css['label'].'"' : '';
788 788
 
789
-		if ( empty( $url ) || empty( $icon_css ) || ! isset( $icon_css['css_class'] ) ) {
789
+		if (empty($url) || empty($icon_css) || ! isset($icon_css['css_class'])) {
790 790
 			return '';
791 791
 		}
792 792
 
793 793
 		$icon_css['css_class'] .= esc_attr(
794 794
 			apply_filters(
795 795
 				'FHEE__EEH_MSG_Template__get_message_action_link__icon_css_class',
796
-				' js-ee-message-action-link ee-message-action-link-' . $type,
796
+				' js-ee-message-action-link ee-message-action-link-'.$type,
797 797
 				$type,
798 798
 				$message,
799 799
 				$query_params
800 800
 			)
801 801
 		);
802 802
 
803
-		return '<a href="' . $url . '"' . $title . '><span class="' . esc_attr( $icon_css['css_class'] ) . '"></span></a>';
803
+		return '<a href="'.$url.'"'.$title.'><span class="'.esc_attr($icon_css['css_class']).'"></span></a>';
804 804
 
805 805
 	}
806 806
 
@@ -838,9 +838,9 @@  discard block
 block discarded – undo
838 838
 	 * @param $reg_status
839 839
 	 * @return string
840 840
 	 */
841
-	public static function convert_reg_status_to_message_type( $reg_status ) {
841
+	public static function convert_reg_status_to_message_type($reg_status) {
842 842
 		$reg_status_array = self::reg_status_to_message_type_array();
843
-		return isset( $reg_status_array[$reg_status] ) ? $reg_status_array[$reg_status] : '';
843
+		return isset($reg_status_array[$reg_status]) ? $reg_status_array[$reg_status] : '';
844 844
 	}
845 845
 
846 846
 
@@ -874,9 +874,9 @@  discard block
 block discarded – undo
874 874
 	 * @param $payment_status
875 875
 	 * @return string
876 876
 	 */
877
-	public static function convert_payment_status_to_message_type( $payment_status ) {
877
+	public static function convert_payment_status_to_message_type($payment_status) {
878 878
 		$payment_status_array = self::payment_status_to_message_type_array();
879
-		return isset( $payment_status_array[$payment_status] ) ? $payment_status_array[$payment_status] : '';
879
+		return isset($payment_status_array[$payment_status]) ? $payment_status_array[$payment_status] : '';
880 880
 	}
881 881
 
882 882
 
@@ -887,32 +887,32 @@  discard block
 block discarded – undo
887 887
 	 *
888 888
 	 * @return EE_Messages_Template_Pack
889 889
 	 */
890
-	public static function get_template_pack( $template_pack_name ) {
891
-		if ( ! self::$_template_pack_collection instanceof EE_Object_Collection ) {
890
+	public static function get_template_pack($template_pack_name) {
891
+		if ( ! self::$_template_pack_collection instanceof EE_Object_Collection) {
892 892
 			self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection();
893 893
 		}
894 894
 
895 895
 		//first see if in collection already
896
-		$template_pack = self::$_template_pack_collection->get_by_name( $template_pack_name );
896
+		$template_pack = self::$_template_pack_collection->get_by_name($template_pack_name);
897 897
 
898
-		if ( $template_pack instanceof EE_Messages_Template_Pack ) {
898
+		if ($template_pack instanceof EE_Messages_Template_Pack) {
899 899
 			return $template_pack;
900 900
 		}
901 901
 
902 902
 		//nope...let's get it.
903 903
 		//not set yet so let's attempt to get it.
904
-		$pack_class_name = 'EE_Messages_Template_Pack_' . str_replace(
904
+		$pack_class_name = 'EE_Messages_Template_Pack_'.str_replace(
905 905
 				' ',
906 906
 				'_',
907 907
 				ucwords(
908
-					str_replace( '_', ' ', $template_pack_name )
908
+					str_replace('_', ' ', $template_pack_name)
909 909
 				)
910 910
 			);
911
-		if ( ! class_exists( $pack_class_name ) && $template_pack_name !== 'default' ) {
912
-			return self::get_template_pack( 'default' );
911
+		if ( ! class_exists($pack_class_name) && $template_pack_name !== 'default') {
912
+			return self::get_template_pack('default');
913 913
 		} else {
914 914
 			$template_pack = new $pack_class_name;
915
-			self::$_template_pack_collection->add( $template_pack );
915
+			self::$_template_pack_collection->add($template_pack);
916 916
 			return $template_pack;
917 917
 		}
918 918
 	}
@@ -930,26 +930,26 @@  discard block
 block discarded – undo
930 930
 	 */
931 931
 	public static function get_template_pack_collection() {
932 932
 		$new_collection = false;
933
-		if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection ) {
933
+		if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection) {
934 934
 			self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection();
935 935
 			$new_collection = true;
936 936
 		}
937 937
 
938 938
 		//glob the defaults directory for messages
939
-		$templates = glob( EE_LIBRARIES . 'messages/defaults/*', GLOB_ONLYDIR );
940
-		foreach( $templates as $template_path ) {
939
+		$templates = glob(EE_LIBRARIES.'messages/defaults/*', GLOB_ONLYDIR);
940
+		foreach ($templates as $template_path) {
941 941
 			//grab folder name
942
-			$template = basename( $template_path );
942
+			$template = basename($template_path);
943 943
 
944
-			if ( ! $new_collection ) {
944
+			if ( ! $new_collection) {
945 945
 				//already have it?
946
-				if ( self::$_template_pack_collection->get_by_name( $template ) instanceof EE_Messages_Template_Pack ) {
946
+				if (self::$_template_pack_collection->get_by_name($template) instanceof EE_Messages_Template_Pack) {
947 947
 					continue;
948 948
 				}
949 949
 			}
950 950
 
951 951
 			//setup classname.
952
-			$template_pack_class_name = 'EE_Messages_Template_Pack_' . str_replace(
952
+			$template_pack_class_name = 'EE_Messages_Template_Pack_'.str_replace(
953 953
 					' ',
954 954
 					'_',
955 955
 					ucwords(
@@ -960,20 +960,20 @@  discard block
 block discarded – undo
960 960
 						)
961 961
 					)
962 962
 				);
963
-			if ( ! class_exists( $template_pack_class_name ) ) {
963
+			if ( ! class_exists($template_pack_class_name)) {
964 964
 				continue;
965 965
 			}
966
-			self::$_template_pack_collection->add( new $template_pack_class_name );
966
+			self::$_template_pack_collection->add(new $template_pack_class_name);
967 967
 		}
968 968
 
969 969
 		/**
970 970
 		 * Filter for plugins to add in any additional template packs
971 971
 		 * Note the filter name here is for backward compat, this used to be found in EED_Messages.
972 972
 		 */
973
-		$additional_template_packs = apply_filters( 'FHEE__EED_Messages__get_template_packs__template_packs', array() );
974
-		foreach ( (array) $additional_template_packs as $template_pack ) {
975
-			if ( ! self::$_template_pack_collection->contains($template_pack ) ) {
976
-				self::$_template_pack_collection->add( $template_pack );
973
+		$additional_template_packs = apply_filters('FHEE__EED_Messages__get_template_packs__template_packs', array());
974
+		foreach ((array) $additional_template_packs as $template_pack) {
975
+			if ( ! self::$_template_pack_collection->contains($template_pack)) {
976
+				self::$_template_pack_collection->add($template_pack);
977 977
 			}
978 978
 		}
979 979
 		return self::$_template_pack_collection;
@@ -991,16 +991,16 @@  discard block
 block discarded – undo
991 991
 	 * @return array
992 992
 	 * @throws \EE_Error
993 993
 	 */
994
-	public static function create_new_templates( $messenger_name, $message_type_name, $GRP_ID = 0, $global = false ) {
994
+	public static function create_new_templates($messenger_name, $message_type_name, $GRP_ID = 0, $global = false) {
995 995
 		/** @type EE_Message_Resource_Manager $Message_Resource_Manager */
996
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
997
-		$messenger = $Message_Resource_Manager->valid_messenger( $messenger_name );
998
-		$message_type = $Message_Resource_Manager->valid_message_type( $message_type_name );
999
-		if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger( $messenger, $message_type, $global ) ) {
996
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
997
+		$messenger = $Message_Resource_Manager->valid_messenger($messenger_name);
998
+		$message_type = $Message_Resource_Manager->valid_message_type($message_type_name);
999
+		if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger($messenger, $message_type, $global)) {
1000 1000
 			return array();
1001 1001
 		}
1002 1002
 		//whew made it this far!  Okay, let's go ahead and create the templates then
1003
-		return EEH_MSG_Template::_create_new_templates( $messenger, $message_type, $GRP_ID, $global );
1003
+		return EEH_MSG_Template::_create_new_templates($messenger, $message_type, $GRP_ID, $global);
1004 1004
 	}
1005 1005
 
1006 1006
 
@@ -1012,15 +1012,15 @@  discard block
 block discarded – undo
1012 1012
 	 * @param                  $global
1013 1013
 	 * @return array|mixed
1014 1014
 	 */
1015
-	protected static function _create_new_templates( EE_messenger $messenger, EE_message_type $message_type, $GRP_ID, $global ) {
1015
+	protected static function _create_new_templates(EE_messenger $messenger, EE_message_type $message_type, $GRP_ID, $global) {
1016 1016
 		//if we're creating a custom template then we don't need to use the defaults class
1017
-		if ( ! $global ) {
1018
-			return EEH_MSG_Template::_create_custom_template_group( $messenger, $message_type, $GRP_ID );
1017
+		if ( ! $global) {
1018
+			return EEH_MSG_Template::_create_custom_template_group($messenger, $message_type, $GRP_ID);
1019 1019
 		}
1020 1020
 		/** @type EE_Messages_Template_Defaults $Message_Template_Defaults */
1021 1021
 		$Message_Template_Defaults = EE_Registry::factory(
1022 1022
 			'EE_Messages_Template_Defaults',
1023
-			array( $messenger, $message_type, $GRP_ID )
1023
+			array($messenger, $message_type, $GRP_ID)
1024 1024
 		);
1025 1025
 		//generate templates
1026 1026
 		$success = $Message_Template_Defaults->create_new_templates();
@@ -1028,10 +1028,10 @@  discard block
 block discarded – undo
1028 1028
 		//if creating the template failed.  Then we should deactivate the related message_type for the messenger because
1029 1029
 		//its not active if it doesn't have a template.  Note this is only happening for GLOBAL template creation
1030 1030
 		//attempts.
1031
-		if ( ! $success ) {
1031
+		if ( ! $success) {
1032 1032
 			/** @var EE_Message_Resource_Manager $message_resource_manager */
1033
-			$message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
1034
-			$message_resource_manager->deactivate_message_type_for_messenger( $message_type->name, $messenger->name );
1033
+			$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1034
+			$message_resource_manager->deactivate_message_type_for_messenger($message_type->name, $messenger->name);
1035 1035
 		}
1036 1036
 
1037 1037
 		/**
@@ -1059,11 +1059,11 @@  discard block
 block discarded – undo
1059 1059
 	 * 										)
1060 1060
 	 * @access private
1061 1061
 	 */
1062
-	private static function _create_custom_template_group( EE_messenger $messenger, EE_message_type $message_type, $GRP_ID ) {
1062
+	private static function _create_custom_template_group(EE_messenger $messenger, EE_message_type $message_type, $GRP_ID) {
1063 1063
 		//defaults
1064
-		$success = array( 'GRP_ID' => null, 'MTP_context' => '' );
1064
+		$success = array('GRP_ID' => null, 'MTP_context' => '');
1065 1065
 		//get the template group to use as a template from the db.  If $GRP_ID is empty then we'll assume the base will be the global template matching the messenger and message type.
1066
-		$Message_Template_Group = empty( $GRP_ID )
1066
+		$Message_Template_Group = empty($GRP_ID)
1067 1067
 			? EEM_Message_Template_Group::instance()->get_one(
1068 1068
 				array(
1069 1069
 					array(
@@ -1073,9 +1073,9 @@  discard block
 block discarded – undo
1073 1073
 					)
1074 1074
 				)
1075 1075
 			)
1076
-			: EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
1076
+			: EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
1077 1077
 		//if we don't have a mtg at this point then we need to bail.
1078
-		if ( ! $Message_Template_Group instanceof EE_Message_Template_Group ) {
1078
+		if ( ! $Message_Template_Group instanceof EE_Message_Template_Group) {
1079 1079
 			EE_Error::add_error(
1080 1080
 				sprintf(
1081 1081
 					__(
@@ -1094,42 +1094,42 @@  discard block
 block discarded – undo
1094 1094
 		$message_templates = $Message_Template_Group->message_templates();
1095 1095
 		//now we have what we need to setup the new template
1096 1096
 		$new_mtg = clone $Message_Template_Group;
1097
-		$new_mtg->set( 'GRP_ID', 0 );
1098
-		$new_mtg->set( 'MTP_is_global', false );
1099
-		$template_name = defined( 'DOING_AJAX' ) && ! empty( $_POST[ 'templateName' ] )
1100
-			? $_POST[ 'templateName' ]
1097
+		$new_mtg->set('GRP_ID', 0);
1098
+		$new_mtg->set('MTP_is_global', false);
1099
+		$template_name = defined('DOING_AJAX') && ! empty($_POST['templateName'])
1100
+			? $_POST['templateName']
1101 1101
 			: __(
1102 1102
 				'New Custom Template',
1103 1103
 				'event_espresso'
1104 1104
 			);
1105
-		$template_description = defined( "DOING_AJAX" ) && ! empty( $_POST[ 'templateDescription' ] )
1106
-			? $_POST[ 'templateDescription' ]
1105
+		$template_description = defined("DOING_AJAX") && ! empty($_POST['templateDescription'])
1106
+			? $_POST['templateDescription']
1107 1107
 			: sprintf(
1108 1108
 				__(
1109 1109
 					'This is a custom template that was created for the %s messenger and %s message type.',
1110 1110
 					'event_espresso'
1111 1111
 				),
1112
-				$new_mtg->messenger_obj()->label[ 'singular' ],
1113
-				$new_mtg->message_type_obj()->label[ 'singular' ]
1112
+				$new_mtg->messenger_obj()->label['singular'],
1113
+				$new_mtg->message_type_obj()->label['singular']
1114 1114
 			);
1115
-		$new_mtg->set( 'MTP_name', $template_name );
1116
-		$new_mtg->set( 'MTP_description', $template_description );
1115
+		$new_mtg->set('MTP_name', $template_name);
1116
+		$new_mtg->set('MTP_description', $template_description);
1117 1117
 		//remove ALL relations on this template group so they don't get saved!
1118
-		$new_mtg->_remove_relations( 'Message_Template' );
1118
+		$new_mtg->_remove_relations('Message_Template');
1119 1119
 		$new_mtg->save();
1120
-		$success[ 'GRP_ID' ] = $new_mtg->ID();
1121
-		$success[ 'template_name' ] = $template_name;
1120
+		$success['GRP_ID'] = $new_mtg->ID();
1121
+		$success['template_name'] = $template_name;
1122 1122
 		//add new message templates and add relation to.
1123
-		foreach ( $message_templates as $message_template ) {
1124
-			if ( ! $message_template instanceof EE_Message_Template ) {
1123
+		foreach ($message_templates as $message_template) {
1124
+			if ( ! $message_template instanceof EE_Message_Template) {
1125 1125
 				continue;
1126 1126
 			}
1127 1127
 			$new_message_template = clone $message_template;
1128
-			$new_message_template->set( 'MTP_ID', 0 );
1129
-			$new_message_template->set( 'GRP_ID', $new_mtg->ID() ); //relation
1128
+			$new_message_template->set('MTP_ID', 0);
1129
+			$new_message_template->set('GRP_ID', $new_mtg->ID()); //relation
1130 1130
 			$new_message_template->save();
1131
-			if ( empty( $success[ 'MTP_context' ] ) ) {
1132
-				$success[ 'MTP_context' ] = $new_message_template->get( 'MTP_context' );
1131
+			if (empty($success['MTP_context'])) {
1132
+				$success['MTP_context'] = $new_message_template->get('MTP_context');
1133 1133
 			}
1134 1134
 		}
1135 1135
 		return $success;
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
 		$global = false
1152 1152
 	) {
1153 1153
 		//is given message_type valid for given messenger (if this is not a global save)
1154
-		if ( $global ) {
1154
+		if ($global) {
1155 1155
 			return true;
1156 1156
 		}
1157 1157
 		$active_templates = EEM_Message_Template_Group::instance()->count(
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
 				)
1164 1164
 			)
1165 1165
 		);
1166
-		if ( $active_templates > 0 ) {
1166
+		if ($active_templates > 0) {
1167 1167
 			return true;
1168 1168
 		}
1169 1169
 		EE_Error::add_error(
@@ -1192,30 +1192,30 @@  discard block
 block discarded – undo
1192 1192
 	 * @param  string $message_type_name name of EE_message_type
1193 1193
 	 * @return array
1194 1194
 	 */
1195
-	public static function get_fields( $messenger_name, $message_type_name ) {
1195
+	public static function get_fields($messenger_name, $message_type_name) {
1196 1196
 		$template_fields = array();
1197 1197
 		/** @type EE_Message_Resource_Manager $Message_Resource_Manager */
1198
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
1199
-		$messenger = $Message_Resource_Manager->valid_messenger( $messenger_name );
1200
-		$message_type = $Message_Resource_Manager->valid_message_type( $message_type_name );
1201
-		if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger( $messenger, $message_type ) ) {
1198
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1199
+		$messenger = $Message_Resource_Manager->valid_messenger($messenger_name);
1200
+		$message_type = $Message_Resource_Manager->valid_message_type($message_type_name);
1201
+		if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger($messenger, $message_type)) {
1202 1202
 			return array();
1203 1203
 		}
1204 1204
 
1205 1205
         $excluded_fields_for_messenger = $message_type->excludedFieldsForMessenger($messenger_name);
1206 1206
 
1207 1207
 		//okay now let's assemble an array with the messenger template fields added to the message_type contexts.
1208
-		foreach ( $message_type->get_contexts() as $context => $details ) {
1209
-			foreach ( $messenger->get_template_fields() as $field => $value ) {
1208
+		foreach ($message_type->get_contexts() as $context => $details) {
1209
+			foreach ($messenger->get_template_fields() as $field => $value) {
1210 1210
 			    if (in_array($field, $excluded_fields_for_messenger, true)) {
1211 1211
 			        continue;
1212 1212
                 }
1213
-				$template_fields[ $context ][ $field ] = $value;
1213
+				$template_fields[$context][$field] = $value;
1214 1214
 			}
1215 1215
 		}
1216
-		if ( empty( $template_fields ) ) {
1216
+		if (empty($template_fields)) {
1217 1217
 			EE_Error::add_error(
1218
-				__( 'Something went wrong and we couldn\'t get any templates assembled', 'event_espresso' ),
1218
+				__('Something went wrong and we couldn\'t get any templates assembled', 'event_espresso'),
1219 1219
 				__FILE__,
1220 1220
 				__FUNCTION__,
1221 1221
 				__LINE__
Please login to merge, or discard this patch.