Completed
Branch FET-9046-messages-queue (bdca24)
by
unknown
547:25 queued 529:16
created
core/libraries/messages/EE_messages.lib.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 	 * >>>>>>>>>>>> 2 usages found in this file: ensure_message_type_is_active() and ensure_messenger_is_active()
232 232
 	 *
233 233
 	 * @param string $messenger_name
234
-	 * @param array $mts_to_activate (optional) An array of message types to activate with this messenger.  If
234
+	 * @param string[] $mts_to_activate (optional) An array of message types to activate with this messenger.  If
235 235
 	 *                             				included we do NOT setup the default message types (assuming
236 236
 	 *                             				they are already setup.)
237 237
 	 * @return boolean an array of generated templates or false if nothing generated/activated.
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 	 * @param  string $context This should correspond with a valid context for the message type
595 595
 	 * @param  string $messenger This should correspond with a valid messenger.
596 596
 	 * @param bool 	$send true we will do a test send using the messenger delivery, false we just do a regular preview
597
-	 * @return string          The body of the message.
597
+	 * @return boolean          The body of the message.
598 598
 	 */
599 599
 	public function preview_message( $type, $context, $messenger, $send = FALSE ) {
600 600
 		return EED_Messages::preview_message( $type, $context, $messenger, $send );
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 	 *
722 722
 	 * >>>>>>>>>>>> 1 usage in \EEH_MSG_Template::generate_new_templates()
723 723
 	 *
724
-	 * @param         $messenger
724
+	 * @param         string $messenger
725 725
 	 * @param  string $message_type message type that the templates are being created for
726 726
 	 * @param int     $GRP_ID
727 727
 	 * @param bool    $is_global
@@ -749,8 +749,8 @@  discard block
 block discarded – undo
749 749
 
750 750
 
751 751
 	/**
752
-	 * @param $GRP_ID
753
-	 * @param $is_global
752
+	 * @param integer $GRP_ID
753
+	 * @param boolean $is_global
754 754
 	 * @return array|mixed
755 755
 	 */
756 756
 	protected function _create_new_templates( $GRP_ID, $is_global) {
Please login to merge, or discard this patch.
Spacing   +165 added lines, -165 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
 /**
@@ -144,23 +144,23 @@  discard block
 block discarded – undo
144 144
 		$actives = is_array($_actives) ? array_keys($_actives) : $_actives;
145 145
 		$active_names = $this->_load_files('messenger', $actives);
146 146
 
147
-		if ( is_array($active_names) ) {
148
-			foreach ( $active_names as $name => $class ) {
147
+		if (is_array($active_names)) {
148
+			foreach ($active_names as $name => $class) {
149 149
 				$active = new $class();
150
-				if ( ! $active instanceof EE_Messenger ) {
150
+				if ( ! $active instanceof EE_Messenger) {
151 151
 					//we've got an error so let's bubble up the error_object to be caught by caller.
152 152
 					//todo: would be better to just catch the errors and then return any aggregated errors later.
153 153
 					EE_Error::add_error(
154 154
 						sprintf(
155
-							__( 'The "%1$s" messenger is not installed or is invalid', 'event_espresso' ),
155
+							__('The "%1$s" messenger is not installed or is invalid', 'event_espresso'),
156 156
 							$class
157 157
 						),
158 158
 						__FILE__, __FUNCTION__, __LINE__
159 159
 					);
160 160
 				}
161 161
 				$this->_active_messengers[$name] = $active;
162
-				$this->_active_message_types[$name] = ! empty( $_actives[$name]['settings'][$name . '-message_types'] )
163
-					? $_actives[$name]['settings'][$name . '-message_types']
162
+				$this->_active_message_types[$name] = ! empty($_actives[$name]['settings'][$name.'-message_types'])
163
+					? $_actives[$name]['settings'][$name.'-message_types']
164 164
 					: array();
165 165
 			}
166 166
 		}
@@ -176,13 +176,13 @@  discard block
 block discarded – undo
176 176
 	 * @param string $messenger_name
177 177
 	 * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive
178 178
 	 */
179
-	public function ensure_messenger_is_active( $messenger_name ){
179
+	public function ensure_messenger_is_active($messenger_name) {
180 180
 		//note: active messengers indexed by their names
181 181
 		$active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
182
-		if( ! isset( $active_messengers[ $messenger_name ] ) ) {
183
-			$this->activate_messenger( $messenger_name );
182
+		if ( ! isset($active_messengers[$messenger_name])) {
183
+			$this->activate_messenger($messenger_name);
184 184
 			return FALSE;
185
-		}else{
185
+		} else {
186 186
 			return TRUE;
187 187
 		}
188 188
 	}
@@ -201,19 +201,19 @@  discard block
 block discarded – undo
201 201
 	 * @return bool true if it got activated (or was active) and false if not.
202 202
 	 * @throws \EE_Error
203 203
 	 */
204
-	public function ensure_message_type_is_active( $message_type, $messenger ) {
204
+	public function ensure_message_type_is_active($message_type, $messenger) {
205 205
 		//first validate that the incoming messenger allows this message type to be activated.
206 206
 		$messengers = $this->get_installed_messengers();
207
-		if ( ! isset( $messengers[$messenger] ) ) {
208
-			throw new EE_Error( sprintf( __('The messenger sent to %s is not installed', 'event_espresso'), __METHOD__ ) );
207
+		if ( ! isset($messengers[$messenger])) {
208
+			throw new EE_Error(sprintf(__('The messenger sent to %s is not installed', 'event_espresso'), __METHOD__));
209 209
 		}
210 210
 
211 211
 		$msgr = $messengers[$messenger];
212 212
 		$valid_message_types = $msgr instanceof EE_Messenger ? $msgr->get_valid_message_types() : array();
213
-		if ( ! in_array( $message_type, $valid_message_types ) ) {
213
+		if ( ! in_array($message_type, $valid_message_types)) {
214 214
 			throw new EE_Error(
215 215
 				sprintf(
216
-					__('The message type (%1$s) sent to %2$s is not valid for the %3$s messenger.  Double-check the spelling and verify that message type has been registered as a valid type with the messenger.', 'event_espresso' ),
216
+					__('The message type (%1$s) sent to %2$s is not valid for the %3$s messenger.  Double-check the spelling and verify that message type has been registered as a valid type with the messenger.', 'event_espresso'),
217 217
 					$message_type,
218 218
 					__METHOD__,
219 219
 					$messenger
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		}
223 223
 
224 224
 		//all is good so let's just get it active
225
-		return $this->activate_messenger( $messenger, array( $message_type ) );
225
+		return $this->activate_messenger($messenger, array($message_type));
226 226
 	}
227 227
 
228 228
 	/**
@@ -236,40 +236,40 @@  discard block
 block discarded – undo
236 236
 	 *                             				they are already setup.)
237 237
 	 * @return boolean an array of generated templates or false if nothing generated/activated.
238 238
 	 */
239
-	public function activate_messenger( $messenger_name, $mts_to_activate = array() ){
239
+	public function activate_messenger($messenger_name, $mts_to_activate = array()) {
240 240
 		$active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
241 241
 		$message_types = $this->get_installed_message_types();
242 242
 		$installed_messengers = $this->get_installed_messengers();
243 243
 		$templates = false;
244 244
 		$settings = array();
245 245
 		//get has_active so we can be sure its kept up to date.
246
-		$has_activated = get_option( 'ee_has_activated_messenger' );
246
+		$has_activated = get_option('ee_has_activated_messenger');
247 247
 
248 248
 		//grab the messenger to work with.
249
-		$messenger = isset( $installed_messengers[$messenger_name] ) ? $installed_messengers[$messenger_name] : null;
249
+		$messenger = isset($installed_messengers[$messenger_name]) ? $installed_messengers[$messenger_name] : null;
250 250
 
251 251
 		//it's inactive. Activate it.
252 252
 
253
-		if( $messenger instanceof EE_Messenger ) {
254
-			$active_messengers[ $messenger->name ][ 'obj' ] = $messenger;
253
+		if ($messenger instanceof EE_Messenger) {
254
+			$active_messengers[$messenger->name]['obj'] = $messenger;
255 255
 
256 256
 			/** @var EE_Messenger[] $installed_messengers  */
257
-			$mts_to_activate = ! empty( $mts_to_activate ) ? $mts_to_activate :  $messenger->get_default_message_types();
258
-			foreach ( $mts_to_activate as $message_type ) {
257
+			$mts_to_activate = ! empty($mts_to_activate) ? $mts_to_activate : $messenger->get_default_message_types();
258
+			foreach ($mts_to_activate as $message_type) {
259 259
 				//we need to setup any initial settings for message types
260 260
 				/** @var EE_message_type[] $installed_mts */
261
-				$settings_fields = isset( $message_types[$message_type] ) ? $message_types[ $message_type ]->get_admin_settings_fields() : array();
262
-				if ( !empty( $settings_fields ) ) {
263
-					foreach ( $settings_fields as $field => $values ) {
264
-						$settings[$field] = $values[ 'default' ];
261
+				$settings_fields = isset($message_types[$message_type]) ? $message_types[$message_type]->get_admin_settings_fields() : array();
262
+				if ( ! empty($settings_fields)) {
263
+					foreach ($settings_fields as $field => $values) {
264
+						$settings[$field] = $values['default'];
265 265
 					}
266 266
 				} else {
267 267
 					$settings = array();
268 268
 				}
269 269
 
270
-				$active_messengers[ $messenger->name ][ 'settings' ][ $messenger->name . '-message_types' ][ $message_type ][ 'settings' ] = $settings;
270
+				$active_messengers[$messenger->name]['settings'][$messenger->name.'-message_types'][$message_type]['settings'] = $settings;
271 271
 
272
-				if (  ! empty( $has_activated[$messenger->name] ) && ! in_array( $message_type, $has_activated[$messenger->name] ) ) {
272
+				if ( ! empty($has_activated[$messenger->name]) && ! in_array($message_type, $has_activated[$messenger->name])) {
273 273
 					$has_activated[$messenger->name][] = $message_type;
274 274
 				}
275 275
 			}
@@ -277,22 +277,22 @@  discard block
 block discarded – undo
277 277
 			//setup any initial settings for the messenger
278 278
 			$msgr_settings = $messenger->get_admin_settings_fields();
279 279
 
280
-			if ( !empty( $msgr_settings ) ) {
281
-				foreach ( $msgr_settings as $field => $value ) {
282
-					$active_messengers[ $messenger->name ][ 'settings' ][ $field ] = $value;
280
+			if ( ! empty($msgr_settings)) {
281
+				foreach ($msgr_settings as $field => $value) {
282
+					$active_messengers[$messenger->name]['settings'][$field] = $value;
283 283
 				}
284 284
 			}
285 285
 
286
-			EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
287
-			update_option( 'ee_has_activated_messenger', $has_activated );
286
+			EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
287
+			update_option('ee_has_activated_messenger', $has_activated);
288 288
 
289 289
 			//make sure that the cached active_messengers is set on this object
290 290
 			$this->_active_messengers[$messenger->name] = $messenger;
291 291
 			$this->_active_message_types[$messenger->name] = $active_messengers[$messenger->name];
292 292
 
293 293
 			//might need to generate new templates
294
-			if ( ! empty( $mts_to_activate ) ) {
295
-				$templates = EEH_MSG_Template::generate_new_templates( $messenger->name, $mts_to_activate, 0, TRUE );
294
+			if ( ! empty($mts_to_activate)) {
295
+				$templates = EEH_MSG_Template::generate_new_templates($messenger->name, $mts_to_activate, 0, TRUE);
296 296
 			}
297 297
 		}
298 298
 
@@ -312,8 +312,8 @@  discard block
 block discarded – undo
312 312
 	 */
313 313
 	private function _load_files($kind, $actives) {
314 314
 		$active_names = array();
315
-		$base_path = EE_LIBRARIES . 'messages' . DS . $kind . DS;
316
-		if ( empty($actives) ) return false;
315
+		$base_path = EE_LIBRARIES.'messages'.DS.$kind.DS;
316
+		if (empty($actives)) return false;
317 317
 
318 318
 		//make sure autoloaders are set (fail-safe)
319 319
 		EED_Messages::set_autoloaders();
@@ -321,12 +321,12 @@  discard block
 block discarded – undo
321 321
 		//make sure $actives is an array
322 322
 		$actives = (array) $actives;
323 323
 
324
-		EE_Registry::instance()->load_helper( 'File' );
325
-		foreach ( $actives as $active ) {
326
-			$msg_name = 'EE_' . ucwords( str_replace( ' ', '_', $active) ) . '_' . $kind;
327
-			$filename = $msg_name . '.class.php';
328
-			$load_file = $base_path . DS . $filename;
329
-			if ( is_readable($load_file) ) {
324
+		EE_Registry::instance()->load_helper('File');
325
+		foreach ($actives as $active) {
326
+			$msg_name = 'EE_'.ucwords(str_replace(' ', '_', $active)).'_'.$kind;
327
+			$filename = $msg_name.'.class.php';
328
+			$load_file = $base_path.DS.$filename;
329
+			if (is_readable($load_file)) {
330 330
 				require_once($load_file);
331 331
 				$active_names[$active] = $msg_name;
332 332
 			} else {
@@ -357,25 +357,25 @@  discard block
 block discarded – undo
357 357
 	 * @param  string $kind        messenger or message_type?
358 358
 	 * @return void
359 359
 	 */
360
-	private function _unset_active( $active_name, $kind ) {
360
+	private function _unset_active($active_name, $kind) {
361 361
 		//pluralize
362 362
 		$active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
363
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
364
-		if ( $kind == 'messenger' ) {
365
-			unset( $active_messengers[$active_name] );
366
-			EEH_MSG_Template::update_to_inactive( $active_name );
367
-			if ( isset( $this->_active_messengers[$active_name] ) ) {
368
-				unset( $this->_active_messengers[$active_name] );
363
+		EE_Registry::instance()->load_helper('MSG_Template');
364
+		if ($kind == 'messenger') {
365
+			unset($active_messengers[$active_name]);
366
+			EEH_MSG_Template::update_to_inactive($active_name);
367
+			if (isset($this->_active_messengers[$active_name])) {
368
+				unset($this->_active_messengers[$active_name]);
369 369
 			}
370 370
 		} else {
371
-			foreach( $active_messengers as $messenger => $settings ) {
372
-				if ( ! empty( $settings['settings'][$messenger . '-message_types'][$active_name] ) ) {
373
-					unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$active_name] );
371
+			foreach ($active_messengers as $messenger => $settings) {
372
+				if ( ! empty($settings['settings'][$messenger.'-message_types'][$active_name])) {
373
+					unset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$active_name]);
374 374
 				}
375 375
 			}
376
-			EEH_MSG_Template::update_to_inactive( '', $active_name );
377
-			if ( isset( $this->_active_message_types[$active_name] ) ) {
378
-				unset( $this->_active_message_types[$active_name] );
376
+			EEH_MSG_Template::update_to_inactive('', $active_name);
377
+			if (isset($this->_active_message_types[$active_name])) {
378
+				unset($this->_active_message_types[$active_name]);
379 379
 			}
380 380
 		}
381 381
 
@@ -395,12 +395,12 @@  discard block
 block discarded – undo
395 395
 	 *
396 396
 	 * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send.
397 397
 	 */
398
-	public function is_generating_messenger_and_active( EE_Messenger $messenger, EE_message_type $message_type ) {
398
+	public function is_generating_messenger_and_active(EE_Messenger $messenger, EE_message_type $message_type) {
399 399
 		//get the $messengers the message type says it can be used with.
400 400
 		$used_with = $message_type->with_messengers();
401 401
 
402
-		foreach ( $used_with as $generating_msgr => $secondary_msgrs ) {
403
-			if ( $messenger->name == $generating_msgr && isset( $this->_active_message_types[$generating_msgr][$message_type->name] ) ) {
402
+		foreach ($used_with as $generating_msgr => $secondary_msgrs) {
403
+			if ($messenger->name == $generating_msgr && isset($this->_active_message_types[$generating_msgr][$message_type->name])) {
404 404
 				return true;
405 405
 			}
406 406
 		}
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
 	 * @param string    $messenger
421 421
 	 * @return EE_Messenger | null
422 422
 	 */
423
-	public function get_messenger_if_active( $messenger ) {
424
-		return ! empty( $this->_active_messengers[$messenger] ) ? $this->_active_messengers[$messenger] : null;
423
+	public function get_messenger_if_active($messenger) {
424
+		return ! empty($this->_active_messengers[$messenger]) ? $this->_active_messengers[$messenger] : null;
425 425
 	}
426 426
 
427 427
 
@@ -448,9 +448,9 @@  discard block
 block discarded – undo
448 448
 	 *                  'message_type' => null
449 449
 	 *                )
450 450
 	 */
451
-	public function validate_for_use( EE_Message $message ) {
451
+	public function validate_for_use(EE_Message $message) {
452 452
 		$validated_for_use['messenger'] = $this->get_messenger_if_active($message->messenger());
453
-		$validated_for_use['message_type'] = $this->get_active_message_type( $message->messenger(), $message->message_type() );
453
+		$validated_for_use['message_type'] = $this->get_active_message_type($message->messenger(), $message->message_type());
454 454
 		return $validated_for_use;
455 455
 	}
456 456
 
@@ -472,35 +472,35 @@  discard block
 block discarded – undo
472 472
 	 * @param bool  $send 			       Default TRUE.  If false, then this will just return the generated EE_Messages objects which might be used by the trigger to setup a batch message (typically html messenger uses it).
473 473
 	 * @return bool
474 474
 	 */
475
-	public function send_message( $type, $vars, $sending_messenger = '', $generating_messenger='', $context='', $send = TRUE ) {
476
-		$processor = new EE_Messages_Processor( $this );
475
+	public function send_message($type, $vars, $sending_messenger = '', $generating_messenger = '', $context = '', $send = TRUE) {
476
+		$processor = new EE_Messages_Processor($this);
477 477
 		$error = FALSE;
478 478
 
479 479
 		//try to intelligently determine what method we'll call based on the incoming data.
480 480
 		//if generating and sending are different then generate and send immediately.
481
-		if ( ! empty( $sending_messenger ) && $sending_messenger != $generating_messenger && $send ) {
481
+		if ( ! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) {
482 482
 			//in the legacy system, when generating and sending were different, that means all the
483 483
 			//vars are already in the request object.  So let's just use that.
484 484
 			try {
485
-				$mtg = new EE_Message_To_Generate_From_Request( $this, EE_Registry::instance()->REQ );
486
-				$processor->generate_and_send_now( $mtg );
487
-			} catch ( EE_Error $e ) {
488
-				$error_msg = __( 'Please note that a system message failed to send due to a technical issue.', 'event_espresso' );
485
+				$mtg = new EE_Message_To_Generate_From_Request($this, EE_Registry::instance()->REQ);
486
+				$processor->generate_and_send_now($mtg);
487
+			} catch (EE_Error $e) {
488
+				$error_msg = __('Please note that a system message failed to send due to a technical issue.', 'event_espresso');
489 489
 				// add specific message for developers if WP_DEBUG in on
490
-				$error_msg .= '||' . $e->getMessage();
491
-				EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
490
+				$error_msg .= '||'.$e->getMessage();
491
+				EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
492 492
 				$error = true;
493 493
 			}
494 494
 		} else {
495
-			$processor->generate_for_all_active_messengers( $type, $vars, $send );
495
+			$processor->generate_for_all_active_messengers($type, $vars, $send);
496 496
 			//let's find out if there were any errors and how many successfully were queued.
497
-			$count_errors = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_failed );
498
-			$count_queued = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete );
499
-			$count_retry = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_retry );
497
+			$count_errors = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_failed);
498
+			$count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete);
499
+			$count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry);
500 500
 			$count_errors = $count_errors + $count_retry;
501
-			if ( $count_errors > 0 ) {
501
+			if ($count_errors > 0) {
502 502
 				$error = true;
503
-				if ( $count_errors > 1 && $count_retry > 1 && $count_queued > 1  ) {
503
+				if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) {
504 504
 					$message = sprintf(
505 505
 						__(
506 506
 							'There were %d errors and %d messages successfully queued for generation and sending',
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 						$count_errors,
510 510
 						$count_queued
511 511
 					);
512
-				} elseif ( $count_errors > 1 && $count_queued === 1 ) {
512
+				} elseif ($count_errors > 1 && $count_queued === 1) {
513 513
 					$message = sprintf(
514 514
 						__(
515 515
 							'There were %d errors and %d message successfully queued for generation.',
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 						$count_errors,
519 519
 						$count_queued
520 520
 					);
521
-				} elseif ( $count_errors === 1 && $count_queued > 1 ) {
521
+				} elseif ($count_errors === 1 && $count_queued > 1) {
522 522
 					$message = sprintf(
523 523
 						__(
524 524
 							'There was %d error and %d messages successfully queued for generation.',
@@ -536,9 +536,9 @@  discard block
 block discarded – undo
536 536
 						$count_errors
537 537
 					);
538 538
 				}
539
-				EE_Error::add_error( $message, __FILE__, __FUNCTION__, __LINE__ );
539
+				EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__);
540 540
 			} else {
541
-				if ( $count_queued === 1 ) {
541
+				if ($count_queued === 1) {
542 542
 					$message = sprintf(
543 543
 						__(
544 544
 							'%d message successfully queued for generation.',
@@ -555,18 +555,18 @@  discard block
 block discarded – undo
555 555
 						$count_queued
556 556
 					);
557 557
 				}
558
-				EE_Error::add_success( $message );
558
+				EE_Error::add_success($message);
559 559
 			}
560 560
 		}
561 561
 		//if no error then return the generated message(s).
562
-		if ( ! $error && ! $send ) {
563
-			$generated_queue = $processor->generate_queue( false );
562
+		if ( ! $error && ! $send) {
563
+			$generated_queue = $processor->generate_queue(false);
564 564
 			//get message and return.
565 565
 			$generated_queue->get_queue()->rewind();
566 566
 			$messages = array();
567
-			while( $generated_queue->get_queue()->valid() ) {
567
+			while ($generated_queue->get_queue()->valid()) {
568 568
 				$message = $generated_queue->get_queue()->current();
569
-				if ( $message instanceof EE_Message ) {
569
+				if ($message instanceof EE_Message) {
570 570
 					//set properties that might be expected by add-ons (backward compat)
571 571
 					$message->content = $message->content();
572 572
 					$message->template_pack = $message->get_template_pack();
@@ -596,8 +596,8 @@  discard block
 block discarded – undo
596 596
 	 * @param bool 	$send true we will do a test send using the messenger delivery, false we just do a regular preview
597 597
 	 * @return string          The body of the message.
598 598
 	 */
599
-	public function preview_message( $type, $context, $messenger, $send = FALSE ) {
600
-		return EED_Messages::preview_message( $type, $context, $messenger, $send );
599
+	public function preview_message($type, $context, $messenger, $send = FALSE) {
600
+		return EED_Messages::preview_message($type, $context, $messenger, $send);
601 601
 	}
602 602
 
603 603
 
@@ -614,11 +614,11 @@  discard block
 block discarded – undo
614 614
 	 *
615 615
 	 * @return bool          success or fail.
616 616
 	 */
617
-	public function send_message_with_messenger_only( $messenger, $message_type, $message ) {
617
+	public function send_message_with_messenger_only($messenger, $message_type, $message) {
618 618
 		//setup for sending to new method.
619
-		$queue = new EE_Messages_Queue( $this );
619
+		$queue = new EE_Messages_Queue($this);
620 620
 		//make sure we have a proper message object
621
-		if ( ! $message instanceof EE_Message && is_object( $message ) && isset( $message->content ) ) {
621
+		if ( ! $message instanceof EE_Message && is_object($message) && isset($message->content)) {
622 622
 			$msg = EE_Message_Factory::create(
623 623
 				array(
624 624
 					'MSG_messenger' => $messenger,
@@ -631,15 +631,15 @@  discard block
 block discarded – undo
631 631
 			$msg = $message;
632 632
 		}
633 633
 
634
-		if ( ! $msg instanceof EE_Message ) {
634
+		if ( ! $msg instanceof EE_Message) {
635 635
 			return false;
636 636
 		}
637 637
 		//make sure any content in a content property (if not empty) is set on the MSG_content.
638
-		if ( ! empty( $msg->content ) ) {
639
-			$msg->set( 'MSG_content', $msg->content );
638
+		if ( ! empty($msg->content)) {
639
+			$msg->set('MSG_content', $msg->content);
640 640
 		}
641
-		$queue->add( $msg );
642
-		return EED_Messages::send_message_with_messenger_only( $messenger, $message_type, $queue );
641
+		$queue->add($msg);
642
+		return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue);
643 643
 	}
644 644
 
645 645
 
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 	 */
661 661
 	private function _validate_setup($messenger, $message_type, $is_global = FALSE) {
662 662
 
663
-		$message_type = strtolower(str_replace(' ', '_', $message_type) );
663
+		$message_type = strtolower(str_replace(' ', '_', $message_type));
664 664
 		$messenger = strtolower(str_replace(' ', '_', $messenger));
665 665
 		$installed_message_types = $this->get_installed_message_types();
666 666
 
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 
677 677
 
678 678
 		//do we have the necessary objects loaded?
679
-		if ( empty( $this->_messenger ) || empty( $this->_message_type ) ) {
679
+		if (empty($this->_messenger) || empty($this->_message_type)) {
680 680
 			throw new EE_Error(
681 681
 				sprintf(
682 682
 					__(
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 			);
690 690
 		}
691 691
 		//is given message_type valid for given messenger (if this is not a global save)
692
-		if ( !$is_global ) {
692
+		if ( ! $is_global) {
693 693
 			$has_active = EEM_Message_Template_Group::instance()->count(
694 694
 				array(
695 695
 					array(
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 					)
699 699
 				)
700 700
 			);
701
-			if ( $has_active == 0 ) {
701
+			if ($has_active == 0) {
702 702
 				EE_Error::add_error(
703 703
 					sprintf(
704 704
 						__(' The %1$s message type is not registered with the %2$s messenger. Please visit the Messenger activation page to assign this message type first if you want to use it.', 'event_espresso'),
@@ -728,16 +728,16 @@  discard block
 block discarded – undo
728 728
 	 * @return array|object if creation is successful then we return an array of info, otherwise an error_object is returned.
729 729
 	 * @throws \EE_Error
730 730
 	 */
731
-	public function create_new_templates( $messenger, $message_type, $GRP_ID = 0, $is_global = false ) {
731
+	public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) {
732 732
 
733 733
 		$valid_mt = $this->_validate_setup($messenger, $message_type, $is_global);
734 734
 
735
-		if ( is_wp_error($valid_mt) && $is_global ) {
735
+		if (is_wp_error($valid_mt) && $is_global) {
736 736
 			//we're setting up a brand new global templates (with messenger activation) so we're assuming that the message types sent in are valid.
737 737
 			$valid_mt = true;
738 738
 		}
739 739
 
740
-		if ( is_wp_error($valid_mt) ) {
740
+		if (is_wp_error($valid_mt)) {
741 741
 			//if we've still got no valid_mt then bubble up error object
742 742
 			return $valid_mt;
743 743
 		}
@@ -753,13 +753,13 @@  discard block
 block discarded – undo
753 753
 	 * @param $is_global
754 754
 	 * @return array|mixed
755 755
 	 */
756
-	protected function _create_new_templates( $GRP_ID, $is_global) {
756
+	protected function _create_new_templates($GRP_ID, $is_global) {
757 757
 
758 758
 		//if we're creating a custom template then we don't need to use the defaults class
759
-		if ( ! $is_global )
760
-			return $this->_create_custom_template_group( $GRP_ID );
759
+		if ( ! $is_global)
760
+			return $this->_create_custom_template_group($GRP_ID);
761 761
 
762
-		$DFLT = new EE_Message_Template_Defaults( $this, $this->_messenger->name, $this->_message_type->name, $GRP_ID );
762
+		$DFLT = new EE_Message_Template_Defaults($this, $this->_messenger->name, $this->_message_type->name, $GRP_ID);
763 763
 
764 764
 		//generate templates
765 765
 		$success = $DFLT->create_new_templates();
@@ -787,16 +787,16 @@  discard block
 block discarded – undo
787 787
 	 *                                     			)
788 788
 	 * @access private
789 789
 	 */
790
-	private function _create_custom_template_group( $GRP_ID ) {
790
+	private function _create_custom_template_group($GRP_ID) {
791 791
 		//defaults
792
-		$success = array( 'GRP_ID' => NULL, 'MTP_context' => '' );
792
+		$success = array('GRP_ID' => NULL, 'MTP_context' => '');
793 793
 
794 794
 		//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.
795
-		$mtg = empty( $GRP_ID ) ? EEM_Message_Template_Group::instance()->get_one( array( array( 'MTP_messenger' => $this->_messenger->name, 'MTP_message_type' => $this->_message_type->name, 'MTP_is_global' => TRUE ) ) ) : EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
795
+		$mtg = empty($GRP_ID) ? EEM_Message_Template_Group::instance()->get_one(array(array('MTP_messenger' => $this->_messenger->name, 'MTP_message_type' => $this->_message_type->name, 'MTP_is_global' => TRUE))) : EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
796 796
 
797 797
 		//if we don't have a mtg at this point then we need to bail.
798
-		if ( ! $mtg instanceof EE_Message_Template_Group ) {
799
-			EE_Error::add_error( sprintf( __('Something went wrong with generating the custom template from this group id: %s.  This usually happens when there is no matching message template group in the db.', 'event_espresso'), $GRP_ID ), __FILE__, __FUNCTION__, __LINE__ );
798
+		if ( ! $mtg instanceof EE_Message_Template_Group) {
799
+			EE_Error::add_error(sprintf(__('Something went wrong with generating the custom template from this group id: %s.  This usually happens when there is no matching message template group in the db.', 'event_espresso'), $GRP_ID), __FILE__, __FUNCTION__, __LINE__);
800 800
 			return $success;
801 801
 		}
802 802
 
@@ -808,27 +808,27 @@  discard block
 block discarded – undo
808 808
 		$new_mtg->set('GRP_ID', 0);
809 809
 		$new_mtg->set('MTP_is_global', FALSE);
810 810
 
811
-		$template_name = defined('DOING_AJAX') && !empty( $_POST['templateName'] ) ? $_POST['templateName'] : __('New Custom Template', 'event_espresso');
812
-		$template_description = defined("DOING_AJAX") && !empty( $_POST['templateDescription'] ) ? $_POST['templateDescription'] : sprintf( __('This is a custom template that was created for the %s messenger and %s message type.', 'event_espresso' ), $new_mtg->messenger_obj()->label['singular'], $new_mtg->message_type_obj()->label['singular'] );
811
+		$template_name = defined('DOING_AJAX') && ! empty($_POST['templateName']) ? $_POST['templateName'] : __('New Custom Template', 'event_espresso');
812
+		$template_description = defined("DOING_AJAX") && ! empty($_POST['templateDescription']) ? $_POST['templateDescription'] : sprintf(__('This is a custom template that was created for the %s messenger and %s message type.', 'event_espresso'), $new_mtg->messenger_obj()->label['singular'], $new_mtg->message_type_obj()->label['singular']);
813 813
 
814 814
 
815
-		$new_mtg->set('MTP_name', $template_name );
816
-		$new_mtg->set('MTP_description', $template_description );
815
+		$new_mtg->set('MTP_name', $template_name);
816
+		$new_mtg->set('MTP_description', $template_description);
817 817
 		//remove ALL relations on this template group so they don't get saved!
818
-		$new_mtg->_remove_relations( 'Message_Template' );
818
+		$new_mtg->_remove_relations('Message_Template');
819 819
 		$new_mtg->save();
820 820
 		$success['GRP_ID'] = $new_mtg->ID();
821 821
 		$success['template_name'] = $template_name;
822 822
 
823 823
 		//add new message templates and add relation to.
824
-		foreach ( $mtts as $mtt ) {
825
-			if ( ! $mtt instanceof EE_Message_Template )
824
+		foreach ($mtts as $mtt) {
825
+			if ( ! $mtt instanceof EE_Message_Template)
826 826
 				continue;
827 827
 			$nmtt = clone $mtt;
828 828
 			$nmtt->set('MTP_ID', 0);
829
-			$nmtt->set( 'GRP_ID', $new_mtg->ID() ); //relation
829
+			$nmtt->set('GRP_ID', $new_mtg->ID()); //relation
830 830
 			$nmtt->save();
831
-			if ( empty( $success['MTP_context'] ) )
831
+			if (empty($success['MTP_context']))
832 832
 				$success['MTP_context'] = $nmtt->get('MTP_context');
833 833
 		}
834 834
 
@@ -856,14 +856,14 @@  discard block
 block discarded – undo
856 856
 
857 857
 
858 858
 		//okay now let's assemble an array with the messenger template fields added to the message_type contexts.
859
-		foreach ( $this->_message_type->get_contexts() as $context => $details ) {
860
-			foreach ( $this->_messenger->get_template_fields() as $field => $value ) {
859
+		foreach ($this->_message_type->get_contexts() as $context => $details) {
860
+			foreach ($this->_messenger->get_template_fields() as $field => $value) {
861 861
 				$template_fields[$context][$field] = $value;
862 862
 			}
863 863
 		}
864 864
 
865
-		if ( empty($template_fields) ) {
866
-			EE_Error::add_error( __('Something went wrong and we couldn\'t get any templates assembled', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
865
+		if (empty($template_fields)) {
866
+			EE_Error::add_error(__('Something went wrong and we couldn\'t get any templates assembled', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
867 867
 			return FALSE;
868 868
 		}
869 869
 
@@ -884,30 +884,30 @@  discard block
 block discarded – undo
884 884
 	 * @return array                    multidimensional array of messenger and message_type objects
885 885
 	 *                                    (messengers index, and message_type index);
886 886
 	 */
887
-	public function get_installed( $type = 'all', $skip_cache = false ) {
887
+	public function get_installed($type = 'all', $skip_cache = false) {
888 888
 		$installed = array();
889 889
 
890 890
 		//first let's account for caching
891
-		if ( $skip_cache ) {
892
-			$message_base = EE_LIBRARIES . "messages" . DS;
891
+		if ($skip_cache) {
892
+			$message_base = EE_LIBRARIES."messages".DS;
893 893
 
894
-			$messenger_files = $type == 'all' || $type == 'messengers' ? scandir( $message_base . "messenger", 1) : NULL;
895
-			$messagetype_files = $type == 'all' || $type == 'message_types' ? scandir( $message_base . "message_type", 1) : NULL;
894
+			$messenger_files = $type == 'all' || $type == 'messengers' ? scandir($message_base."messenger", 1) : NULL;
895
+			$messagetype_files = $type == 'all' || $type == 'message_types' ? scandir($message_base."message_type", 1) : NULL;
896 896
 
897 897
 
898 898
 			//allow plugins to filter in their messenger/message_type files
899
-			$messenger_files = apply_filters('FHEE__EE_messages__get_installed__messenger_files', $messenger_files, $type );
900
-			$messagetype_files = apply_filters('FHEE__EE_messages__get_installed__messagetype_files', $messagetype_files, $type );
899
+			$messenger_files = apply_filters('FHEE__EE_messages__get_installed__messenger_files', $messenger_files, $type);
900
+			$messagetype_files = apply_filters('FHEE__EE_messages__get_installed__messagetype_files', $messagetype_files, $type);
901 901
 
902
-			$installed['messengers'] = !empty($messenger_files ) ? $this->_get_installed($messenger_files) : '';
903
-			$installed['message_types'] = !empty($messagetype_files) ? $this->_get_installed($messagetype_files) : '';
902
+			$installed['messengers'] = ! empty($messenger_files) ? $this->_get_installed($messenger_files) : '';
903
+			$installed['message_types'] = ! empty($messagetype_files) ? $this->_get_installed($messagetype_files) : '';
904 904
 		} else {
905 905
 			$installed['messengers'] = $this->get_installed_messengers();
906 906
 			$installed['message_types'] = $this->get_installed_message_types();
907 907
 		}
908 908
 
909 909
 
910
-		if ( $type != 'all' ) {
910
+		if ($type != 'all') {
911 911
 			$installed = $type == 'messengers' ? $installed['messengers'] : $installed['message_types'];
912 912
 		}
913 913
 
@@ -926,15 +926,15 @@  discard block
 block discarded – undo
926 926
 		$the_goods = array();
927 927
 		$filenames = (array) $filenames;
928 928
 		$replace = ".class.php";
929
-		foreach ( $filenames as $filename ) {
930
-			$classname = preg_match("/" . $replace . "/", $filename ) ? str_replace($replace, "", $filename) : false;
929
+		foreach ($filenames as $filename) {
930
+			$classname = preg_match("/".$replace."/", $filename) ? str_replace($replace, "", $filename) : false;
931 931
 
932 932
 			//no classname? no match? move along, nothing to see here. note, the stripos is checking to make sure the filename (classname) begins with EE.
933
-			if ( !$classname || 0 !== stripos($classname, 'EE') ) continue;
933
+			if ( ! $classname || 0 !== stripos($classname, 'EE')) continue;
934 934
 
935 935
 			//note: I'm not sure if this will work without including the file.  We do have autoloaders so it "may" work.
936 936
 			$object = new $classname();
937
-			$the_goods[ $object->name ] = $object;
937
+			$the_goods[$object->name] = $object;
938 938
 		}
939 939
 		return $the_goods;
940 940
 	}
@@ -959,9 +959,9 @@  discard block
 block discarded – undo
959 959
 	 */
960 960
 	public function get_active_message_types() {
961 961
 		$message_types = array();
962
-		foreach ( $this->_active_message_types as $messenger => $mtvalues ) {
963
-			foreach ( $mtvalues as $mt => $config ) {
964
-				if ( !in_array( $mt, $message_types ) )
962
+		foreach ($this->_active_message_types as $messenger => $mtvalues) {
963
+			foreach ($mtvalues as $mt => $config) {
964
+				if ( ! in_array($mt, $message_types))
965 965
 					$message_types[] = $mt;
966 966
 			}
967 967
 		}
@@ -982,8 +982,8 @@  discard block
 block discarded – undo
982 982
 		$message_types = array();
983 983
 		$message_type_refs = $this->get_active_message_types();
984 984
 		$installed_message_types = $this->get_installed_message_types();
985
-		foreach ( $message_type_refs as $ref ) {
986
-			if ( isset( $installed_message_types[$ref] ) ) {
985
+		foreach ($message_type_refs as $ref) {
986
+			if (isset($installed_message_types[$ref])) {
987 987
 				$message_types[] = $installed_message_types[$ref];
988 988
 			}
989 989
 		}
@@ -1004,17 +1004,17 @@  discard block
 block discarded – undo
1004 1004
 	 *
1005 1005
 	 * @return EE_message_type[]    (or empty array if none present)
1006 1006
 	 */
1007
-	public function get_active_message_types_per_messenger( $messenger ) {
1007
+	public function get_active_message_types_per_messenger($messenger) {
1008 1008
 		$messenger = (string) $messenger;
1009
-		if ( empty( $this->_active_message_types[$messenger] ) ) {
1009
+		if (empty($this->_active_message_types[$messenger])) {
1010 1010
 			return array();
1011 1011
 		}
1012 1012
 
1013 1013
 		$mts = array();
1014 1014
 		$message_types = $this->_active_message_types[$messenger];
1015 1015
 		$installed_message_types = $this->get_installed_message_types();
1016
-		foreach ( $message_types as $mt => $settings ) {
1017
-			if ( ! empty( $installed_message_types[$mt] ) )  {
1016
+		foreach ($message_types as $mt => $settings) {
1017
+			if ( ! empty($installed_message_types[$mt])) {
1018 1018
 				$mts[] = $installed_message_types[$mt];
1019 1019
 			}
1020 1020
 		}
@@ -1034,9 +1034,9 @@  discard block
 block discarded – undo
1034 1034
 	 *
1035 1035
 	 * @return EE_Message_Type|null
1036 1036
 	 */
1037
-	public function get_active_message_type( $messenger, $message_type ) {
1037
+	public function get_active_message_type($messenger, $message_type) {
1038 1038
 		$installed_message_types = $this->get_installed_message_types();
1039
-		if ( !empty( $this->_active_message_types[$messenger][$message_type] ) && !empty( $installed_message_types[$message_type] ) )  {
1039
+		if ( ! empty($this->_active_message_types[$messenger][$message_type]) && ! empty($installed_message_types[$message_type])) {
1040 1040
 			return $installed_message_types[$message_type];
1041 1041
 		}
1042 1042
 		return NULL;
@@ -1059,8 +1059,8 @@  discard block
 block discarded – undo
1059 1059
 	 * @return array|\EE_message_type[]
1060 1060
 	 */
1061 1061
 	public function get_installed_message_types() {
1062
-		$this->_installed_message_types = empty( $this->_installed_message_types )
1063
-			? $this->get_installed( 'message_types', true )
1062
+		$this->_installed_message_types = empty($this->_installed_message_types)
1063
+			? $this->get_installed('message_types', true)
1064 1064
 			: $this->_installed_message_types;
1065 1065
 		return $this->_installed_message_types;
1066 1066
 	}
@@ -1077,8 +1077,8 @@  discard block
 block discarded – undo
1077 1077
 	 * @return array
1078 1078
 	 */
1079 1079
 	public function get_installed_messengers() {
1080
-		$this->_installed_messengers = empty( $this->_installed_messengers )
1081
-			? $this->get_installed( 'messengers', true )
1080
+		$this->_installed_messengers = empty($this->_installed_messengers)
1081
+			? $this->get_installed('messengers', true)
1082 1082
 			: $this->_installed_messengers;
1083 1083
 		return $this->_installed_messengers;
1084 1084
 	}
@@ -1114,21 +1114,21 @@  discard block
 block discarded – undo
1114 1114
 	 * @param   bool    $slugs_only     Whether to return an array of just slugs and labels (true) or all contexts indexed by message type.
1115 1115
 	 * @return array
1116 1116
 	 */
1117
-	public function get_all_contexts( $slugs_only = true ) {
1117
+	public function get_all_contexts($slugs_only = true) {
1118 1118
 		$key = $slugs_only ? 'slugs' : 'all';
1119
-		if ( ! empty( $this->_contexts[$key] ) ) {
1119
+		if ( ! empty($this->_contexts[$key])) {
1120 1120
 			return $this->_contexts[$key];
1121 1121
 		}
1122 1122
 
1123 1123
 		//contexts has not been setup yet.  So let's get all active message type objects and loop through to get all
1124 1124
 		//unique contexts
1125 1125
 		$contexts = array();
1126
-		foreach ( $this->get_active_message_type_objects() as $mt ) {
1127
-			if ( $mt instanceof EE_message_type ) {
1126
+		foreach ($this->get_active_message_type_objects() as $mt) {
1127
+			if ($mt instanceof EE_message_type) {
1128 1128
 				$mt_contexts = $mt->get_contexts();
1129
-				if ( $slugs_only ) {
1130
-					foreach ( $mt_contexts as $context => $context_details ) {
1131
-						$contexts[ $context ] = $context_details['label'];
1129
+				if ($slugs_only) {
1130
+					foreach ($mt_contexts as $context => $context_details) {
1131
+						$contexts[$context] = $context_details['label'];
1132 1132
 					}
1133 1133
 				} else {
1134 1134
 					$contexts[$mt->name] = $mt_contexts;
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 	 * @param string $data_handler_reference
1153 1153
 	 * @return string
1154 1154
 	 */
1155
-	public function verify_and_retrieve_class_name_for_data_handler_reference( $data_handler_reference ) {
1155
+	public function verify_and_retrieve_class_name_for_data_handler_reference($data_handler_reference) {
1156 1156
 		return EE_Message_To_Generate::verify_and_retrieve_class_name_for_data_handler_reference(
1157 1157
 			$data_handler_reference
1158 1158
 		);
Please login to merge, or discard this patch.
Braces   +21 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@  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 7
 /**
7 8
  * EE_Messages class
@@ -182,7 +183,7 @@  discard block
 block discarded – undo
182 183
 		if( ! isset( $active_messengers[ $messenger_name ] ) ) {
183 184
 			$this->activate_messenger( $messenger_name );
184 185
 			return FALSE;
185
-		}else{
186
+		} else{
186 187
 			return TRUE;
187 188
 		}
188 189
 	}
@@ -313,7 +314,9 @@  discard block
 block discarded – undo
313 314
 	private function _load_files($kind, $actives) {
314 315
 		$active_names = array();
315 316
 		$base_path = EE_LIBRARIES . 'messages' . DS . $kind . DS;
316
-		if ( empty($actives) ) return false;
317
+		if ( empty($actives) ) {
318
+			return false;
319
+		}
317 320
 
318 321
 		//make sure autoloaders are set (fail-safe)
319 322
 		EED_Messages::set_autoloaders();
@@ -756,8 +759,9 @@  discard block
 block discarded – undo
756 759
 	protected function _create_new_templates( $GRP_ID, $is_global) {
757 760
 
758 761
 		//if we're creating a custom template then we don't need to use the defaults class
759
-		if ( ! $is_global )
760
-			return $this->_create_custom_template_group( $GRP_ID );
762
+		if ( ! $is_global ) {
763
+					return $this->_create_custom_template_group( $GRP_ID );
764
+		}
761 765
 
762 766
 		$DFLT = new EE_Message_Template_Defaults( $this, $this->_messenger->name, $this->_message_type->name, $GRP_ID );
763 767
 
@@ -822,14 +826,16 @@  discard block
 block discarded – undo
822 826
 
823 827
 		//add new message templates and add relation to.
824 828
 		foreach ( $mtts as $mtt ) {
825
-			if ( ! $mtt instanceof EE_Message_Template )
826
-				continue;
829
+			if ( ! $mtt instanceof EE_Message_Template ) {
830
+							continue;
831
+			}
827 832
 			$nmtt = clone $mtt;
828 833
 			$nmtt->set('MTP_ID', 0);
829 834
 			$nmtt->set( 'GRP_ID', $new_mtg->ID() ); //relation
830 835
 			$nmtt->save();
831
-			if ( empty( $success['MTP_context'] ) )
832
-				$success['MTP_context'] = $nmtt->get('MTP_context');
836
+			if ( empty( $success['MTP_context'] ) ) {
837
+							$success['MTP_context'] = $nmtt->get('MTP_context');
838
+			}
833 839
 		}
834 840
 
835 841
 		return $success;
@@ -930,7 +936,9 @@  discard block
 block discarded – undo
930 936
 			$classname = preg_match("/" . $replace . "/", $filename ) ? str_replace($replace, "", $filename) : false;
931 937
 
932 938
 			//no classname? no match? move along, nothing to see here. note, the stripos is checking to make sure the filename (classname) begins with EE.
933
-			if ( !$classname || 0 !== stripos($classname, 'EE') ) continue;
939
+			if ( !$classname || 0 !== stripos($classname, 'EE') ) {
940
+				continue;
941
+			}
934 942
 
935 943
 			//note: I'm not sure if this will work without including the file.  We do have autoloaders so it "may" work.
936 944
 			$object = new $classname();
@@ -961,8 +969,9 @@  discard block
 block discarded – undo
961 969
 		$message_types = array();
962 970
 		foreach ( $this->_active_message_types as $messenger => $mtvalues ) {
963 971
 			foreach ( $mtvalues as $mt => $config ) {
964
-				if ( !in_array( $mt, $message_types ) )
965
-					$message_types[] = $mt;
972
+				if ( !in_array( $mt, $message_types ) ) {
973
+									$message_types[] = $mt;
974
+				}
966 975
 			}
967 976
 		}
968 977
 
Please login to merge, or discard this patch.
core/EE_Registry.core.php 1 patch
Spacing   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 */
169 169
 	public static function instance() {
170 170
 		// check if class object is instantiated
171
-		if ( ! self::$_instance instanceof EE_Registry ) {
171
+		if ( ! self::$_instance instanceof EE_Registry) {
172 172
 			self::$_instance = new self();
173 173
 		}
174 174
 		return self::$_instance;
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 		$this->modules = new StdClass();
206 206
 		$this->shortcodes = new StdClass();
207 207
 		$this->widgets = new StdClass();
208
-		$this->load_core( 'Base', array(), true );
209
-		add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'init' ) );
208
+		$this->load_core('Base', array(), true);
209
+		add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init'));
210 210
 	}
211 211
 
212 212
 
@@ -219,10 +219,10 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	public function init() {
221 221
 		// Get current page protocol
222
-		$protocol = isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://';
222
+		$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
223 223
 		// Output admin-ajax.php URL with same protocol as current page
224
-		self::$i18n_js_strings[ 'ajax_url' ] = admin_url( 'admin-ajax.php', $protocol );
225
-		self::$i18n_js_strings[ 'wp_debug' ] = defined( 'WP_DEBUG' ) ? WP_DEBUG : false;
224
+		self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
225
+		self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false;
226 226
 	}
227 227
 
228 228
 
@@ -233,14 +233,14 @@  discard block
 block discarded – undo
233 233
 	 * @return string
234 234
 	 */
235 235
 	public static function localize_i18n_js_strings() {
236
-		$i18n_js_strings = (array)EE_Registry::$i18n_js_strings;
237
-		foreach ( $i18n_js_strings as $key => $value ) {
238
-			if ( is_scalar( $value ) ) {
239
-				$i18n_js_strings[ $key ] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8' );
236
+		$i18n_js_strings = (array) EE_Registry::$i18n_js_strings;
237
+		foreach ($i18n_js_strings as $key => $value) {
238
+			if (is_scalar($value)) {
239
+				$i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
240 240
 			}
241 241
 		}
242 242
 
243
-		return "/* <![CDATA[ */ var eei18n = " . wp_json_encode( $i18n_js_strings ) . '; /* ]]> */';
243
+		return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */';
244 244
 	}
245 245
 
246 246
 
@@ -248,15 +248,15 @@  discard block
 block discarded – undo
248 248
 	/**
249 249
 	 * @param mixed string | EED_Module $module
250 250
 	 */
251
-	public function add_module( $module ) {
252
-		if ( $module instanceof EED_Module ) {
253
-			$module_class = get_class( $module );
251
+	public function add_module($module) {
252
+		if ($module instanceof EED_Module) {
253
+			$module_class = get_class($module);
254 254
 			$this->modules->{$module_class} = $module;
255 255
 		} else {
256
-			if ( ! class_exists( 'EE_Module_Request_Router' ) ) {
257
-				$this->load_core( 'Module_Request_Router' );
256
+			if ( ! class_exists('EE_Module_Request_Router')) {
257
+				$this->load_core('Module_Request_Router');
258 258
 			}
259
-			$this->modules->{$module} = EE_Module_Request_Router::module_factory( $module );
259
+			$this->modules->{$module} = EE_Module_Request_Router::module_factory($module);
260 260
 		}
261 261
 	}
262 262
 
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 	 * @param string $module_name
267 267
 	 * @return mixed EED_Module | NULL
268 268
 	 */
269
-	public function get_module( $module_name = '' ) {
270
-		return isset( $this->modules->{$module_name} ) ? $this->modules->{$module_name} : null;
269
+	public function get_module($module_name = '') {
270
+		return isset($this->modules->{$module_name} ) ? $this->modules->{$module_name} : null;
271 271
 	}
272 272
 
273 273
 
@@ -282,18 +282,18 @@  discard block
 block discarded – undo
282 282
 	 * @param bool $resolve_dependencies
283 283
 	 * @return mixed
284 284
 	 */
285
-	public function load_core( $class_name, $arguments = array(), $load_only = false, $resolve_dependencies = false ) {
285
+	public function load_core($class_name, $arguments = array(), $load_only = false, $resolve_dependencies = false) {
286 286
 		$core_paths = apply_filters(
287 287
 			'FHEE__EE_Registry__load_core__core_paths',
288 288
 			array(
289 289
 				EE_CORE,
290 290
 				EE_ADMIN,
291 291
 				EE_CPTS,
292
-				EE_CORE . 'data_migration_scripts' . DS
292
+				EE_CORE.'data_migration_scripts'.DS
293 293
 			)
294 294
 		);
295 295
 		// retrieve instantiated class
296
-		return $this->_load( $core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only, $resolve_dependencies );
296
+		return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only, $resolve_dependencies);
297 297
 	}
298 298
 
299 299
 
@@ -307,15 +307,15 @@  discard block
 block discarded – undo
307 307
 	 * @param bool $load_only
308 308
 	 * @return mixed
309 309
 	 */
310
-	public function load_service( $class_name, $arguments = array(), $load_only = false ) {
310
+	public function load_service($class_name, $arguments = array(), $load_only = false) {
311 311
 		$service_paths = apply_filters(
312 312
 			'FHEE__EE_Registry__load_service__service_paths',
313 313
 			array(
314
-				EE_CORE . 'services' . DS,
314
+				EE_CORE.'services'.DS,
315 315
 			)
316 316
 		);
317 317
 		// retrieve instantiated class
318
-		return $this->_load( $service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only, true );
318
+		return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only, true);
319 319
 	}
320 320
 
321 321
 
@@ -328,9 +328,9 @@  discard block
 block discarded – undo
328 328
 	 * @param mixed $arguments
329 329
 	 * @return EE_Data_Migration_Script_Base
330 330
 	 */
331
-	public function load_dms( $class_name, $arguments = array() ) {
331
+	public function load_dms($class_name, $arguments = array()) {
332 332
 		// retrieve instantiated class
333
-		return $this->_load( EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false );
333
+		return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false);
334 334
 	}
335 335
 
336 336
 
@@ -345,14 +345,14 @@  discard block
 block discarded – undo
345 345
 	 * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default)
346 346
 	 * @return EE_Base_Class
347 347
 	 */
348
-	public function load_class( $class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false ) {
349
-		$paths = apply_filters( 'FHEE__EE_Registry__load_class__paths', array(
348
+	public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false) {
349
+		$paths = apply_filters('FHEE__EE_Registry__load_class__paths', array(
350 350
 			EE_CORE,
351 351
 			EE_CLASSES,
352 352
 			EE_BUSINESS
353
-		) );
353
+		));
354 354
 		// retrieve instantiated class
355
-		return $this->_load( $paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only );
355
+		return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only);
356 356
 	}
357 357
 
358 358
 
@@ -365,10 +365,10 @@  discard block
 block discarded – undo
365 365
 	 * @param bool $load_only
366 366
 	 * @return EEH_Base
367 367
 	 */
368
-	public function load_helper( $class_name, $arguments = array(), $load_only = true ) {
369
-		$helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array( EE_HELPERS ) );
368
+	public function load_helper($class_name, $arguments = array(), $load_only = true) {
369
+		$helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS));
370 370
 		// retrieve instantiated class
371
-		return $this->_load( $helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only );
371
+		return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only);
372 372
 	}
373 373
 
374 374
 
@@ -382,16 +382,16 @@  discard block
 block discarded – undo
382 382
 	 * @param bool $load_only
383 383
 	 * @return mixed
384 384
 	 */
385
-	public function load_lib( $class_name, $arguments = array(), $load_only = false ) {
385
+	public function load_lib($class_name, $arguments = array(), $load_only = false) {
386 386
 		$paths = array(
387 387
 			EE_LIBRARIES,
388
-			EE_LIBRARIES . 'messages' . DS,
389
-			EE_LIBRARIES . 'shortcodes' . DS,
390
-			EE_LIBRARIES . 'qtips' . DS,
391
-			EE_LIBRARIES . 'payment_methods' . DS,
388
+			EE_LIBRARIES.'messages'.DS,
389
+			EE_LIBRARIES.'shortcodes'.DS,
390
+			EE_LIBRARIES.'qtips'.DS,
391
+			EE_LIBRARIES.'payment_methods'.DS,
392 392
 		);
393 393
 		// retrieve instantiated class
394
-		return $this->_load( $paths, 'EE_', $class_name, 'lib', $arguments, false, true, $load_only );
394
+		return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, true, $load_only);
395 395
 	}
396 396
 
397 397
 
@@ -404,13 +404,13 @@  discard block
 block discarded – undo
404 404
 	 * @param bool $load_only
405 405
 	 * @return EEM_Base
406 406
 	 */
407
-	public function load_model( $class_name, $arguments = array(), $load_only = false ) {
408
-		$paths = apply_filters( 'FHEE__EE_Registry__load_model__paths', array(
407
+	public function load_model($class_name, $arguments = array(), $load_only = false) {
408
+		$paths = apply_filters('FHEE__EE_Registry__load_model__paths', array(
409 409
 			EE_MODELS,
410 410
 			EE_CORE
411
-		) );
411
+		));
412 412
 		// retrieve instantiated class
413
-		return $this->_load( $paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only );
413
+		return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only);
414 414
 	}
415 415
 
416 416
 
@@ -423,15 +423,15 @@  discard block
 block discarded – undo
423 423
 	 * @param bool $load_only
424 424
 	 * @return mixed
425 425
 	 */
426
-	public function load_model_class( $class_name, $arguments = array(), $load_only = true ) {
426
+	public function load_model_class($class_name, $arguments = array(), $load_only = true) {
427 427
 		$paths = array(
428
-			EE_MODELS . 'fields' . DS,
429
-			EE_MODELS . 'helpers' . DS,
430
-			EE_MODELS . 'relations' . DS,
431
-			EE_MODELS . 'strategies' . DS
428
+			EE_MODELS.'fields'.DS,
429
+			EE_MODELS.'helpers'.DS,
430
+			EE_MODELS.'relations'.DS,
431
+			EE_MODELS.'strategies'.DS
432 432
 		);
433 433
 		// retrieve instantiated class
434
-		return $this->_load( $paths, 'EE_', $class_name, '', $arguments, false, true, $load_only );
434
+		return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only);
435 435
 	}
436 436
 
437 437
 
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
 	 * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
442 442
 	 * @return boolean
443 443
 	 */
444
-	public function is_model_name( $model_name ) {
445
-		return isset( $this->models[ $model_name ] ) ? true : false;
444
+	public function is_model_name($model_name) {
445
+		return isset($this->models[$model_name]) ? true : false;
446 446
 	}
447 447
 
448 448
 
@@ -457,9 +457,9 @@  discard block
 block discarded – undo
457 457
 	 * @param bool $load_only
458 458
 	 * @return mixed
459 459
 	 */
460
-	public function load_file( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true ) {
460
+	public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true) {
461 461
 		// retrieve instantiated class
462
-		return $this->_load( $path_to_file, '', $file_name, $type, $arguments, false, true, $load_only );
462
+		return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only);
463 463
 	}
464 464
 
465 465
 
@@ -474,9 +474,9 @@  discard block
 block discarded – undo
474 474
 	 * @param bool $load_only
475 475
 	 * @return EE_Addon
476 476
 	 */
477
-	public function load_addon( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false ) {
477
+	public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false) {
478 478
 		// retrieve instantiated class
479
-		return $this->_load( $path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only );
479
+		return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only);
480 480
 	}
481 481
 
482 482
 
@@ -508,27 +508,27 @@  discard block
 block discarded – undo
508 508
 		$resolve_dependencies = false
509 509
 	) {
510 510
 		// strip php file extension
511
-		$class_name = str_replace( '.php', '', trim( $class_name ) );
511
+		$class_name = str_replace('.php', '', trim($class_name));
512 512
 		// does the class have a prefix ?
513
-		if ( ! empty( $class_prefix ) && $class_prefix != 'addon' ) {
513
+		if ( ! empty($class_prefix) && $class_prefix != 'addon') {
514 514
 			// make sure $class_prefix is uppercase
515
-			$class_prefix = strtoupper( trim( $class_prefix ) );
515
+			$class_prefix = strtoupper(trim($class_prefix));
516 516
 			// add class prefix ONCE!!!
517
-			$class_name = $class_prefix . str_replace( $class_prefix, '', $class_name );
517
+			$class_name = $class_prefix.str_replace($class_prefix, '', $class_name);
518 518
 		}
519 519
 		// return object if it's already cached
520
-		$cached_class = $this->_get_cached_class( $class_name, $class_prefix );
521
-		if ( $cached_class !== null ) {
520
+		$cached_class = $this->_get_cached_class($class_name, $class_prefix);
521
+		if ($cached_class !== null) {
522 522
 			return $cached_class;
523 523
 		}
524 524
 		// get full path to file
525
-		$path = $this->_resolve_path( $class_name, $type, $file_paths );
525
+		$path = $this->_resolve_path($class_name, $type, $file_paths);
526 526
 		// load the file
527
-		$this->_require_file( $path, $class_name, $type, $file_paths );
527
+		$this->_require_file($path, $class_name, $type, $file_paths);
528 528
 		// instantiate the requested object
529
-		$class_obj = $this->_create_object( $class_name, $arguments, $type, $from_db, $load_only, $resolve_dependencies );
529
+		$class_obj = $this->_create_object($class_name, $arguments, $type, $from_db, $load_only, $resolve_dependencies);
530 530
 		// save it for later... kinda like gum  { : $
531
-		$this->_set_cached_class( $class_obj, $class_name, $class_prefix, $from_db, $cache );
531
+		$this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db, $cache);
532 532
 		return $class_obj;
533 533
 	}
534 534
 
@@ -549,21 +549,21 @@  discard block
 block discarded – undo
549 549
 	 * @param string $class_prefix
550 550
 	 * @return null|object
551 551
 	 */
552
-	protected function _get_cached_class( $class_name, $class_prefix = '' ) {
553
-		if ( isset( $this->_class_abbreviations[ $class_name ] ) ) {
554
-			$class_abbreviation = $this->_class_abbreviations[ $class_name ];
552
+	protected function _get_cached_class($class_name, $class_prefix = '') {
553
+		if (isset($this->_class_abbreviations[$class_name])) {
554
+			$class_abbreviation = $this->_class_abbreviations[$class_name];
555 555
 		} else {
556 556
 			// have to specify something, but not anything that will conflict
557 557
 			$class_abbreviation = 'FANCY_BATMAN_PANTS';
558 558
 		}
559 559
 		// check if class has already been loaded, and return it if it has been
560
-		if ( isset( $this->{$class_abbreviation} ) && ! is_null( $this->{$class_abbreviation} ) ) {
560
+		if (isset($this->{$class_abbreviation} ) && ! is_null($this->{$class_abbreviation} )) {
561 561
 			return $this->{$class_abbreviation};
562
-		} else if ( isset ( $this->{$class_name} ) ) {
562
+		} else if (isset ($this->{$class_name} )) {
563 563
 			return $this->{$class_name};
564
-		} else if ( isset ( $this->LIB->{$class_name} ) ) {
564
+		} else if (isset ($this->LIB->{$class_name} )) {
565 565
 			return $this->LIB->{$class_name};
566
-		} else if ( $class_prefix == 'addon' && isset ( $this->addons->{$class_name} ) ) {
566
+		} else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name} )) {
567 567
 			return $this->addons->{$class_name};
568 568
 		}
569 569
 		return null;
@@ -584,20 +584,20 @@  discard block
 block discarded – undo
584 584
 	 * @param array $file_paths
585 585
 	 * @return string | bool
586 586
 	 */
587
-	protected function _resolve_path( $class_name, $type = '', $file_paths = array() ) {
587
+	protected function _resolve_path($class_name, $type = '', $file_paths = array()) {
588 588
 		// make sure $file_paths is an array
589
-		$file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths );
589
+		$file_paths = is_array($file_paths) ? $file_paths : array($file_paths);
590 590
 		// cycle thru paths
591
-		foreach ( $file_paths as $key => $file_path ) {
591
+		foreach ($file_paths as $key => $file_path) {
592 592
 			// convert all separators to proper DS, if no filepath, then use EE_CLASSES
593
-			$file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES;
593
+			$file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES;
594 594
 			// prep file type
595
-			$type = ! empty( $type ) ? trim( $type, '.' ) . '.' : '';
595
+			$type = ! empty($type) ? trim($type, '.').'.' : '';
596 596
 			// build full file path
597
-			$file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php';
597
+			$file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php';
598 598
 			//does the file exist and can be read ?
599
-			if ( is_readable( $file_paths[ $key ] ) ) {
600
-				return $file_paths[ $key ];
599
+			if (is_readable($file_paths[$key])) {
600
+				return $file_paths[$key];
601 601
 			}
602 602
 		}
603 603
 		return false;
@@ -619,29 +619,29 @@  discard block
 block discarded – undo
619 619
 	 * @return void
620 620
 	 * @throws \EE_Error
621 621
 	 */
622
-	protected function _require_file( $path, $class_name, $type = '', $file_paths = array() ) {
622
+	protected function _require_file($path, $class_name, $type = '', $file_paths = array()) {
623 623
 		// don't give up! you gotta...
624 624
 		try {
625 625
 			//does the file exist and can it be read ?
626
-			if ( ! $path ) {
626
+			if ( ! $path) {
627 627
 				// so sorry, can't find the file
628
-				throw new EE_Error (
628
+				throw new EE_Error(
629 629
 					sprintf(
630
-						__( 'The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso' ),
631
-						trim( $type, '.' ),
630
+						__('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso'),
631
+						trim($type, '.'),
632 632
 						$class_name,
633
-						'<br />' . implode( ',<br />', $file_paths )
633
+						'<br />'.implode(',<br />', $file_paths)
634 634
 					)
635 635
 				);
636 636
 			}
637 637
 			// get the file
638
-			require_once( $path );
638
+			require_once($path);
639 639
 			// if the class isn't already declared somewhere
640
-			if ( class_exists( $class_name, false ) === false ) {
640
+			if (class_exists($class_name, false) === false) {
641 641
 				// so sorry, not a class
642 642
 				throw new EE_Error(
643 643
 					sprintf(
644
-						__( 'The %s file %s does not appear to contain the %s Class.', 'event_espresso' ),
644
+						__('The %s file %s does not appear to contain the %s Class.', 'event_espresso'),
645 645
 						$type,
646 646
 						$path,
647 647
 						$class_name
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
 				);
650 650
 			}
651 651
 
652
-		} catch ( EE_Error $e ) {
652
+		} catch (EE_Error $e) {
653 653
 			$e->get_error();
654 654
 		}
655 655
 	}
@@ -681,52 +681,52 @@  discard block
 block discarded – undo
681 681
 	 * @return null | object
682 682
 	 * @throws \EE_Error
683 683
 	 */
684
-	protected function _create_object( $class_name, $arguments = array(), $type = '', $from_db = false, $load_only = false, $resolve_dependencies = true ) {
684
+	protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false, $load_only = false, $resolve_dependencies = true) {
685 685
 		$class_obj = null;
686
-		$resolve_dependencies = isset( $this->_auto_resolve_dependencies[ $class_name ] ) /*&& empty( $arguments )*/ ? true : $resolve_dependencies;
686
+		$resolve_dependencies = isset($this->_auto_resolve_dependencies[$class_name]) /*&& empty( $arguments )*/ ? true : $resolve_dependencies;
687 687
 		// don't give up! you gotta...
688 688
 		try {
689 689
 			// create reflection
690
-			$reflector = $this->get_ReflectionClass( $class_name );
690
+			$reflector = $this->get_ReflectionClass($class_name);
691 691
 			// make sure arguments are an array
692
-			$arguments = is_array( $arguments ) ? $arguments : array( $arguments );
692
+			$arguments = is_array($arguments) ? $arguments : array($arguments);
693 693
 			// and if arguments array is NOT numerically indexed, then we want it to stay as an array,
694 694
 			// so wrap it in an additional array so that it doesn't get split into multiple parameters
695
-			$arguments = isset( $arguments[ 0 ] ) ? $arguments : array( $arguments );
695
+			$arguments = isset($arguments[0]) ? $arguments : array($arguments);
696 696
 			// attempt to inject dependencies ?
697
-			if ( $resolve_dependencies && ! $from_db && ! $load_only && ! $reflector->isSubclassOf( 'EE_Base_Class' ) ) {
698
-				$arguments = $this->_resolve_dependencies( $reflector, $class_name, $arguments );
697
+			if ($resolve_dependencies && ! $from_db && ! $load_only && ! $reflector->isSubclassOf('EE_Base_Class')) {
698
+				$arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
699 699
 			}
700 700
 			// instantiate the class and add to the LIB array for tracking
701 701
 			// EE_Base_Classes are instantiated via new_instance by default (models call them via new_instance_from_db)
702
-			if ( $reflector->getConstructor() === null || $reflector->isAbstract() || $load_only ) {
702
+			if ($reflector->getConstructor() === null || $reflector->isAbstract() || $load_only) {
703 703
 				// no constructor = static methods only... nothing to instantiate, loading file was enough
704 704
 				//$instantiation_mode = "no constructor";
705 705
 				return true;
706
-			} else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) {
706
+			} else if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
707 707
 				//$instantiation_mode = "new_instance_from_db";
708
-				$class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments );
709
-			} else if ( method_exists( $class_name, 'new_instance' ) ) {
708
+				$class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments);
709
+			} else if (method_exists($class_name, 'new_instance')) {
710 710
 				//$instantiation_mode = "new_instance";
711
-				$class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments );
712
-			} else if ( method_exists( $class_name, 'instance' ) ) {
711
+				$class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments);
712
+			} else if (method_exists($class_name, 'instance')) {
713 713
 				//$instantiation_mode = "instance";
714
-				$class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments );
715
-			} else if ( $reflector->isInstantiable() ) {
714
+				$class_obj = call_user_func_array(array($class_name, 'instance'), $arguments);
715
+			} else if ($reflector->isInstantiable()) {
716 716
 				//$instantiation_mode = "isInstantiable";
717
-				$class_obj = $reflector->newInstanceArgs( $arguments );
718
-			} else if ( ! $load_only ) {
717
+				$class_obj = $reflector->newInstanceArgs($arguments);
718
+			} else if ( ! $load_only) {
719 719
 				// heh ? something's not right !
720 720
 				//$instantiation_mode = 'none';
721 721
 				throw new EE_Error(
722 722
 					sprintf(
723
-						__( 'The %s file %s could not be instantiated.', 'event_espresso' ),
723
+						__('The %s file %s could not be instantiated.', 'event_espresso'),
724 724
 						$type,
725 725
 						$class_name
726 726
 					)
727 727
 				);
728 728
 			}
729
-		} catch ( EE_Error $e ) {
729
+		} catch (EE_Error $e) {
730 730
 			$e->get_error();
731 731
 		}
732 732
 		return $class_obj;
@@ -744,14 +744,14 @@  discard block
 block discarded – undo
744 744
 	 * @param string $class_name
745 745
 	 * @return ReflectionClass
746 746
 	 */
747
-	public function get_ReflectionClass( $class_name ) {
747
+	public function get_ReflectionClass($class_name) {
748 748
 		if (
749
-			! isset( $this->_reflectors[ $class_name ] )
750
-			|| ! $this->_reflectors[ $class_name ] instanceof ReflectionClass
749
+			! isset($this->_reflectors[$class_name])
750
+			|| ! $this->_reflectors[$class_name] instanceof ReflectionClass
751 751
 		) {
752
-			$this->_reflectors[ $class_name ] = new ReflectionClass( $class_name );
752
+			$this->_reflectors[$class_name] = new ReflectionClass($class_name);
753 753
 		}
754
-		return $this->_reflectors[ $class_name ];
754
+		return $this->_reflectors[$class_name];
755 755
 	}
756 756
 
757 757
 
@@ -776,19 +776,19 @@  discard block
 block discarded – undo
776 776
 	 * @param array $arguments
777 777
 	 * @return array
778 778
 	 */
779
-	protected function _resolve_dependencies( ReflectionClass $reflector, $class_name, $arguments = array() ) {
779
+	protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array()) {
780 780
 		// let's examine the constructor
781 781
 		$constructor = $reflector->getConstructor();
782 782
 		// whu? huh? nothing?
783
-		if ( ! $constructor ) {
783
+		if ( ! $constructor) {
784 784
 			return $arguments;
785 785
 		}
786 786
 		// get constructor parameters
787 787
 		$params = $constructor->getParameters();
788 788
 		// and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
789
-		$argument_keys = array_keys( $arguments );
789
+		$argument_keys = array_keys($arguments);
790 790
 		// now loop thru all of the constructors expected parameters
791
-		foreach ( $params as $index => $param ) {
791
+		foreach ($params as $index => $param) {
792 792
 			// is this a dependency for a specific class ?
793 793
 			$param_class = $param->getClass() ? $param->getClass()->name : null;
794 794
 			if (
@@ -796,40 +796,40 @@  discard block
 block discarded – undo
796 796
 				$param_class === null ||
797 797
 				(
798 798
 					// something already exists in the incoming arguments for this param
799
-					isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] )
799
+					isset($argument_keys[$index], $arguments[$argument_keys[$index]])
800 800
 					// AND it's the correct class
801
-					&& $arguments[ $argument_keys[ $index ] ] instanceof $param_class
801
+					&& $arguments[$argument_keys[$index]] instanceof $param_class
802 802
 				)
803 803
 
804 804
 			) {
805 805
 				// so let's skip this argument and move on to the next
806 806
 				continue;
807 807
 			} else if (
808
-				isset( $this->_auto_resolve_dependencies[ $class_name ] )
809
-				&& in_array( $param_class, $this->_auto_resolve_dependencies[ $class_name ] )
808
+				isset($this->_auto_resolve_dependencies[$class_name])
809
+				&& in_array($param_class, $this->_auto_resolve_dependencies[$class_name])
810 810
 			) {
811 811
 				// we might have a dependency... let's try and find it in our cache
812
-				$cached_class = $this->_get_cached_class( $param_class );
812
+				$cached_class = $this->_get_cached_class($param_class);
813 813
 				$dependency = null;
814 814
 				// and grab it if it exists
815
-				if ( $cached_class instanceof $param_class ) {
815
+				if ($cached_class instanceof $param_class) {
816 816
 					$dependency = $cached_class;
817
-				} else if ( $param_class != $class_name ) {
818
-					$loader = EE_Dependency_Map::class_loader( $param_class );
817
+				} else if ($param_class != $class_name) {
818
+					$loader = EE_Dependency_Map::class_loader($param_class);
819 819
 					// or if not cached, then let's try and load it directly
820
-					$core_class = $this->$loader( $param_class );
820
+					$core_class = $this->$loader($param_class);
821 821
 					// as long as we aren't creating some recursive loading loop
822
-					if ( $core_class instanceof $param_class ) {
822
+					if ($core_class instanceof $param_class) {
823 823
 						$dependency = $core_class;
824 824
 					}
825 825
 				}
826 826
 				// did we successfully find the correct dependency ?
827
-				if ( $dependency instanceof $param_class ) {
827
+				if ($dependency instanceof $param_class) {
828 828
 					// then let's inject it into the incoming array of arguments at the correct location
829
-					array_splice( $arguments, $index, 1, array( $dependency ) );
829
+					array_splice($arguments, $index, 1, array($dependency));
830 830
 				}
831 831
 			} else {
832
-				$arguments[ $index ] = null;
832
+				$arguments[$index] = null;
833 833
 			}
834 834
 
835 835
 		}
@@ -858,16 +858,16 @@  discard block
 block discarded – undo
858 858
 	 * @param bool $cache
859 859
 	 * @return void
860 860
 	 */
861
-	protected function _set_cached_class( $class_obj, $class_name, $class_prefix = '', $from_db = false, $cache = true ) {
861
+	protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false, $cache = true) {
862 862
 		// return newly instantiated class
863
-		if ( isset( $this->_class_abbreviations[ $class_name ] ) ) {
864
-			$class_abbreviation = $this->_class_abbreviations[ $class_name ];
863
+		if (isset($this->_class_abbreviations[$class_name])) {
864
+			$class_abbreviation = $this->_class_abbreviations[$class_name];
865 865
 			$this->{$class_abbreviation} = $class_obj;
866
-		} else if ( property_exists( $this, $class_name ) ) {
866
+		} else if (property_exists($this, $class_name)) {
867 867
 			$this->{$class_name} = $class_obj;
868
-		} else if ( $class_prefix == 'addon' && $cache ) {
868
+		} else if ($class_prefix == 'addon' && $cache) {
869 869
 			$this->addons->{$class_name} = $class_obj;
870
-		} else if ( ! $from_db && $cache ) {
870
+		} else if ( ! $from_db && $cache) {
871 871
 			$this->LIB->{$class_name} = $class_obj;
872 872
 		}
873 873
 	}
@@ -880,9 +880,9 @@  discard block
 block discarded – undo
880 880
 	 * @param string $name
881 881
 	 * @return EE_Addon
882 882
 	 */
883
-	public function get_addon_by_name( $name ) {
884
-		foreach ( $this->addons as $addon ) {
885
-			if ( $addon->name() == $name ) {
883
+	public function get_addon_by_name($name) {
884
+		foreach ($this->addons as $addon) {
885
+			if ($addon->name() == $name) {
886 886
 				return $addon;
887 887
 			}
888 888
 		}
@@ -898,8 +898,8 @@  discard block
 block discarded – undo
898 898
 	 */
899 899
 	public function get_addons_by_name() {
900 900
 		$addons = array();
901
-		foreach ( $this->addons as $addon ) {
902
-			$addons[ $addon->name() ] = $addon;
901
+		foreach ($this->addons as $addon) {
902
+			$addons[$addon->name()] = $addon;
903 903
 		}
904 904
 		return $addons;
905 905
 	}
@@ -914,14 +914,14 @@  discard block
 block discarded – undo
914 914
 	 * @return \EEM_Base
915 915
 	 * @throws \EE_Error
916 916
 	 */
917
-	public function reset_model( $model_name ) {
918
-		$model = $this->load_model( $model_name );
919
-		$model_class_name = get_class( $model );
917
+	public function reset_model($model_name) {
918
+		$model = $this->load_model($model_name);
919
+		$model_class_name = get_class($model);
920 920
 		//get that model reset it and make sure we nuke the old reference to it
921
-		if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) {
921
+		if ($model instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) {
922 922
 			$this->LIB->$model_class_name = $model::reset();
923 923
 		} else {
924
-			throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) );
924
+			throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name));
925 925
 		}
926 926
 		return $this->LIB->$model_class_name;
927 927
 	}
@@ -939,15 +939,15 @@  discard block
 block discarded – undo
939 939
 	 * currently reinstantiate the singletons at the moment)
940 940
 	 * @return EE_Registry
941 941
 	 */
942
-	public static function reset( $hard = false, $reinstantiate = true ) {
942
+	public static function reset($hard = false, $reinstantiate = true) {
943 943
 		$instance = self::instance();
944
-		$instance->load_helper( 'Activation' );
944
+		$instance->load_helper('Activation');
945 945
 		EEH_Activation::reset();
946
-		$instance->CFG = EE_Config::reset( $hard, $reinstantiate );
946
+		$instance->CFG = EE_Config::reset($hard, $reinstantiate);
947 947
 		$instance->LIB->EE_Data_Migration_Manager = EE_Data_Migration_Manager::reset();
948 948
 		$instance->LIB = new stdClass();
949
-		foreach ( array_keys( $instance->non_abstract_db_models ) as $model_name ) {
950
-			$instance->reset_model( $model_name );
949
+		foreach (array_keys($instance->non_abstract_db_models) as $model_name) {
950
+			$instance->reset_model($model_name);
951 951
 		}
952 952
 		return $instance;
953 953
 	}
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
 	 * @param $a
968 968
 	 * @param $b
969 969
 	 */
970
-	final function __call( $a, $b ) {
970
+	final function __call($a, $b) {
971 971
 	}
972 972
 
973 973
 
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
 	/**
976 976
 	 * @param $a
977 977
 	 */
978
-	final function __get( $a ) {
978
+	final function __get($a) {
979 979
 	}
980 980
 
981 981
 
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
 	 * @param $a
985 985
 	 * @param $b
986 986
 	 */
987
-	final function __set( $a, $b ) {
987
+	final function __set($a, $b) {
988 988
 	}
989 989
 
990 990
 
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
 	/**
993 993
 	 * @param $a
994 994
 	 */
995
-	final function __isset( $a ) {
995
+	final function __isset($a) {
996 996
 	}
997 997
 
998 998
 
@@ -1000,7 +1000,7 @@  discard block
 block discarded – undo
1000 1000
 	/**
1001 1001
 	 * @param $a
1002 1002
 	 */
1003
-	final function __unset( $a ) {
1003
+	final function __unset($a) {
1004 1004
 	}
1005 1005
 
1006 1006
 
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
 	 * @param $a
1048 1048
 	 * @param $b
1049 1049
 	 */
1050
-	final static function __callStatic( $a, $b ) {
1050
+	final static function __callStatic($a, $b) {
1051 1051
 	}
1052 1052
 
1053 1053
 	/**
@@ -1056,9 +1056,9 @@  discard block
 block discarded – undo
1056 1056
 	 */
1057 1057
 	public function cpt_models() {
1058 1058
 		$cpt_models = array();
1059
-		foreach( $this->non_abstract_db_models as $short_name => $classname ) {
1060
-			if( is_subclass_of(  $classname, 'EEM_CPT_Base' ) ) {
1061
-				$cpt_models[ $short_name ] = $classname;
1059
+		foreach ($this->non_abstract_db_models as $short_name => $classname) {
1060
+			if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1061
+				$cpt_models[$short_name] = $classname;
1062 1062
 			}
1063 1063
 		}
1064 1064
 		return $cpt_models;
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	protected function __construct() {
43 43
 		$this->_register_core_dependencies();
44 44
 		$this->_register_core_class_loaders();
45
-		do_action( 'EE_Dependency_Map____construct' );
45
+		do_action('EE_Dependency_Map____construct');
46 46
 	}
47 47
 
48 48
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	public static function instance() {
56 56
 		// check if class object is instantiated, and instantiated properly
57
-		if ( ! self::$_instance instanceof EE_Dependency_Map ) {
57
+		if ( ! self::$_instance instanceof EE_Dependency_Map) {
58 58
 			self::$_instance = new EE_Dependency_Map();
59 59
 		}
60 60
 		return self::$_instance;
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 	 * @param array $dependencies
77 77
 	 * @return boolean
78 78
 	 */
79
-	public static function register_dependencies( $class, $dependencies ) {
80
-		if ( ! isset( self::$_dependency_map[ $class ] ) ) {
81
-			self::$_dependency_map[ $class ] = (array)$dependencies;
79
+	public static function register_dependencies($class, $dependencies) {
80
+		if ( ! isset(self::$_dependency_map[$class])) {
81
+			self::$_dependency_map[$class] = (array) $dependencies;
82 82
 			return true;
83 83
 		}
84 84
 		return false;
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
 	 * @param string $class_name
91 91
 	 * @return array
92 92
 	 */
93
-	public static function class_loader( $class_name ) {
94
-		return isset( self::$_class_loaders[ $class_name ] ) ? self::$_class_loaders[ $class_name ] : '';
93
+	public static function class_loader($class_name) {
94
+		return isset(self::$_class_loaders[$class_name]) ? self::$_class_loaders[$class_name] : '';
95 95
 	}
96 96
 
97 97
 
@@ -102,18 +102,18 @@  discard block
 block discarded – undo
102 102
 	 * @return bool
103 103
 	 * @throws \EE_Error
104 104
 	 */
105
-	public static function register_class_loader( $class_name, $loader = 'load_core' ) {
105
+	public static function register_class_loader($class_name, $loader = 'load_core') {
106 106
 		// check that loader method starts with "load_" and exists in EE_Registry
107
-		if ( strpos( $loader, 'load_' ) !== 0 || ! method_exists( EE_Registry::instance(), $loader ) ) {
107
+		if (strpos($loader, 'load_') !== 0 || ! method_exists(EE_Registry::instance(), $loader)) {
108 108
 			throw new EE_Error(
109 109
 				sprintf(
110
-					__( '"%1$s" is not a valid loader method on EE_Registry.', 'event_espresso' ),
110
+					__('"%1$s" is not a valid loader method on EE_Registry.', 'event_espresso'),
111 111
 					$loader
112 112
 				)
113 113
 			);
114 114
 		}
115
-		if ( ! isset( self::$_class_loaders[ $class_name ] ) ) {
116
-			self::$_class_loaders[ $class_name ] = $loader;
115
+		if ( ! isset(self::$_class_loaders[$class_name])) {
116
+			self::$_class_loaders[$class_name] = $loader;
117 117
 			return true;
118 118
 		}
119 119
 		return false;
Please login to merge, or discard this patch.
core/db_classes/EE_Message.class.php 1 patch
Spacing   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * EE_Message class
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
 	 * @param array $date_formats incoming date formats in an array.  First value is the date_format, second is time format.
49 49
 	 * @return EE_Message
50 50
 	 */
51
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
52
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__ );
51
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
52
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
53 53
 		//if object doesn't exist, let's generate a unique token on instantiation so that its available even before saving to db.
54
-		if ( ! $has_object ) {
55
-			EE_Registry::instance()->load_helper( 'URL' );
54
+		if ( ! $has_object) {
55
+			EE_Registry::instance()->load_helper('URL');
56 56
 			$props_n_values['MSG_token'] = EEH_URL::generate_unique_token();
57 57
 		}
58
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
58
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
59 59
 	}
60 60
 
61 61
 
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 	 * @param string $timezone
67 67
 	 * @return EE_Message
68 68
 	 */
69
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
70
-		return new self( $props_n_values, true, $timezone );
69
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
70
+		return new self($props_n_values, true, $timezone);
71 71
 	}
72 72
 
73 73
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @return int
79 79
 	 */
80 80
 	public function MSG_token() {
81
-		return $this->get( 'MSG_token' );
81
+		return $this->get('MSG_token');
82 82
 	}
83 83
 
84 84
 
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @param int $MSG_token
90 90
 	 */
91
-	public function set_MSG_token( $MSG_token) {
92
-		$this->set( 'MSG_token', $MSG_token );
91
+	public function set_MSG_token($MSG_token) {
92
+		$this->set('MSG_token', $MSG_token);
93 93
 	}
94 94
 
95 95
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @return int
102 102
 	 */
103 103
 	public function GRP_ID() {
104
-		return $this->get( 'GRP_ID' );
104
+		return $this->get('GRP_ID');
105 105
 	}
106 106
 
107 107
 
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 	 *
112 112
 	 * @param int $GRP_ID
113 113
 	 */
114
-	public function set_GRP_ID( $GRP_ID ) {
115
-		$this->set( 'GRP_ID', $GRP_ID );
114
+	public function set_GRP_ID($GRP_ID) {
115
+		$this->set('GRP_ID', $GRP_ID);
116 116
 	}
117 117
 
118 118
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * @return int
125 125
 	 */
126 126
 	public function TXN_ID() {
127
-		return $this->get( 'TXN_ID' );
127
+		return $this->get('TXN_ID');
128 128
 	}
129 129
 
130 130
 
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @param int $TXN_ID
136 136
 	 */
137
-	public function set_TXN_ID( $TXN_ID) {
138
-		$this->set( 'TXN_ID', $TXN_ID );
137
+	public function set_TXN_ID($TXN_ID) {
138
+		$this->set('TXN_ID', $TXN_ID);
139 139
 	}
140 140
 
141 141
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * @return string
148 148
 	 */
149 149
 	public function messenger() {
150
-		return $this->get( 'MSG_messenger' );
150
+		return $this->get('MSG_messenger');
151 151
 	}
152 152
 
153 153
 
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 	 *
158 158
 	 * @param string $messenger
159 159
 	 */
160
-	public function set_messenger( $messenger ) {
161
-		$this->set( 'MSG_messenger', $messenger );
160
+	public function set_messenger($messenger) {
161
+		$this->set('MSG_messenger', $messenger);
162 162
 	}
163 163
 
164 164
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 *
180 180
 	 * @param EE_Messenger $messenger
181 181
 	 */
182
-	public function set_messenger_object( EE_Messenger $messenger ) {
182
+	public function set_messenger_object(EE_Messenger $messenger) {
183 183
 		$this->_messenger = $messenger;
184 184
 	}
185 185
 
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 	 * @return bool
193 193
 	 * @throws \EE_Error
194 194
 	 */
195
-	public function valid_messenger( $throw_exceptions = false ) {
196
-		if ( $this->_messenger instanceof EE_Messenger ) {
195
+	public function valid_messenger($throw_exceptions = false) {
196
+		if ($this->_messenger instanceof EE_Messenger) {
197 197
 			return true;
198 198
 		}
199
-		if ( $throw_exceptions ) {
199
+		if ($throw_exceptions) {
200 200
 			throw new EE_Error(
201 201
 				sprintf(
202 202
 					__(
@@ -220,10 +220,10 @@  discard block
 block discarded – undo
220 220
 	 * @param   bool    $plural whether to return the plural label or not.
221 221
 	 * @return string
222 222
 	 */
223
-	public function messenger_label( $plural = false ) {
223
+	public function messenger_label($plural = false) {
224 224
 		$label_type = $plural ? 'plural' : 'singular';
225 225
 		$messenger = $this->messenger_object();
226
-		return $messenger instanceof EE_Messenger ? $messenger->label[ $label_type ] : $this->messenger();
226
+		return $messenger instanceof EE_Messenger ? $messenger->label[$label_type] : $this->messenger();
227 227
 	}
228 228
 
229 229
 
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	 * @return string
235 235
 	 */
236 236
 	public function message_type() {
237
-		return $this->get( 'MSG_message_type' );
237
+		return $this->get('MSG_message_type');
238 238
 	}
239 239
 
240 240
 
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
 	 *
245 245
 	 * @param string $message_type
246 246
 	 */
247
-	public function set_message_type( $message_type ) {
248
-		$this->set( 'MSG_message_type', $message_type );
247
+	public function set_message_type($message_type) {
248
+		$this->set('MSG_message_type', $message_type);
249 249
 	}
250 250
 
251 251
 
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @param EE_Message_Type $message_type
268 268
 	 */
269
-	public function set_message_type_object( EE_Message_Type $message_type ) {
269
+	public function set_message_type_object(EE_Message_Type $message_type) {
270 270
 		$this->_message_type = $message_type;
271 271
 	}
272 272
 
@@ -279,11 +279,11 @@  discard block
 block discarded – undo
279 279
 	 * @return bool
280 280
 	 * @throws \EE_Error
281 281
 	 */
282
-	public function valid_message_type( $throw_exceptions = false ) {
283
-		if ( $this->_message_type instanceof EE_Message_Type ) {
282
+	public function valid_message_type($throw_exceptions = false) {
283
+		if ($this->_message_type instanceof EE_Message_Type) {
284 284
 			return true;
285 285
 		}
286
-		if ( $throw_exceptions ) {
286
+		if ($throw_exceptions) {
287 287
 			throw new EE_Error(
288 288
 				sprintf(
289 289
 					__(
@@ -306,8 +306,8 @@  discard block
 block discarded – undo
306 306
 	 * @return bool
307 307
 	 * @throws \EE_Error
308 308
 	 */
309
-	public function is_valid( $throw_exceptions = false ) {
310
-		if ( $this->valid_messenger( $throw_exceptions ) && $this->valid_message_type( $throw_exceptions ) ) {
309
+	public function is_valid($throw_exceptions = false) {
310
+		if ($this->valid_messenger($throw_exceptions) && $this->valid_message_type($throw_exceptions)) {
311 311
 			return true;
312 312
 		}
313 313
 		return false;
@@ -323,10 +323,10 @@  discard block
 block discarded – undo
323 323
 	 * @param   bool    $plural whether to return the plural label or not.
324 324
 	 * @return string
325 325
 	 */
326
-	public function message_type_label( $plural = false ) {
326
+	public function message_type_label($plural = false) {
327 327
 		$label_type = $plural ? 'plural' : 'singular';
328 328
 		$message_type = $this->message_type_object();
329
-		return $message_type instanceof EE_message_type ? $message_type->label[ $label_type ] : $this->message_type();
329
+		return $message_type instanceof EE_message_type ? $message_type->label[$label_type] : $this->message_type();
330 330
 	}
331 331
 
332 332
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 	 * @return string
338 338
 	 */
339 339
 	public function context() {
340
-		return $this->get( 'MSG_context' );
340
+		return $this->get('MSG_context');
341 341
 	}
342 342
 
343 343
 
@@ -351,9 +351,9 @@  discard block
 block discarded – undo
351 351
 	 */
352 352
 	public function context_label() {
353 353
 		/** @type EE_Messages $messages_controller */
354
-		$messages_controller = EE_Registry::instance()->load_lib( 'messages' );
354
+		$messages_controller = EE_Registry::instance()->load_lib('messages');
355 355
 		$contexts = $messages_controller->get_all_contexts();
356
-		return isset( $contexts[ $this->context() ] ) ? $contexts[ $this->context() ] : $this->context();
356
+		return isset($contexts[$this->context()]) ? $contexts[$this->context()] : $this->context();
357 357
 	}
358 358
 
359 359
 
@@ -363,8 +363,8 @@  discard block
 block discarded – undo
363 363
 	 *
364 364
 	 * @param string $context
365 365
 	 */
366
-	public function set_context( $context ) {
367
-		$this->set( 'MSG_context', $context );
366
+	public function set_context($context) {
367
+		$this->set('MSG_context', $context);
368 368
 	}
369 369
 
370 370
 
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 	 * @return int
376 376
 	 */
377 377
 	public function recipient_ID() {
378
-		return $this->get( 'MSG_recipient_ID' );
378
+		return $this->get('MSG_recipient_ID');
379 379
 	}
380 380
 
381 381
 
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
 	 *
386 386
 	 * @param string $recipient_ID
387 387
 	 */
388
-	public function set_recipient_ID( $recipient_ID ) {
389
-		$this->set( 'MSG_recipient_ID', $recipient_ID );
388
+	public function set_recipient_ID($recipient_ID) {
389
+		$this->set('MSG_recipient_ID', $recipient_ID);
390 390
 	}
391 391
 
392 392
 
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 	 * @return string
398 398
 	 */
399 399
 	public function recipient_type() {
400
-		return $this->get( 'MSG_recipient_type' );
400
+		return $this->get('MSG_recipient_type');
401 401
 	}
402 402
 
403 403
 
@@ -409,11 +409,11 @@  discard block
 block discarded – undo
409 409
 	 * @return EE_Base_Class | null
410 410
 	 */
411 411
 	public function recipient_object() {
412
-		if ( ! $this->recipient_type() || ! $this->recipient_ID() ) {
412
+		if ( ! $this->recipient_type() || ! $this->recipient_ID()) {
413 413
 			return null;
414 414
 		}
415 415
 
416
-		return $this->get_first_related( $this->recipient_type() );
416
+		return $this->get_first_related($this->recipient_type());
417 417
 	}
418 418
 
419 419
 
@@ -423,8 +423,8 @@  discard block
 block discarded – undo
423 423
 	 *
424 424
 	 * @param string $recipient_type
425 425
 	 */
426
-	public function set_recipient_type( $recipient_type ) {
427
-		$this->set( 'MSG_recipient_type', $recipient_type );
426
+	public function set_recipient_type($recipient_type) {
427
+		$this->set('MSG_recipient_type', $recipient_type);
428 428
 	}
429 429
 
430 430
 
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 	 * @return string
436 436
 	 */
437 437
 	public function content() {
438
-		return $this->get( 'MSG_content' );
438
+		return $this->get('MSG_content');
439 439
 	}
440 440
 
441 441
 
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
 	 *
446 446
 	 * @param string $content
447 447
 	 */
448
-	public function set_content( $content ) {
449
-		$this->set( 'MSG_content', $content );
448
+	public function set_content($content) {
449
+		$this->set('MSG_content', $content);
450 450
 	}
451 451
 
452 452
 
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 	 * @return string
458 458
 	 */
459 459
 	public function subject() {
460
-		return $this->get( 'MSG_subject' );
460
+		return $this->get('MSG_subject');
461 461
 	}
462 462
 
463 463
 
@@ -467,8 +467,8 @@  discard block
 block discarded – undo
467 467
 	 *
468 468
 	 * @param string $subject
469 469
 	 */
470
-	public function set_subject( $subject ) {
471
-		$this->set( 'MSG_subject', $subject );
470
+	public function set_subject($subject) {
471
+		$this->set('MSG_subject', $subject);
472 472
 	}
473 473
 
474 474
 
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
 	 * @return string
480 480
 	 */
481 481
 	public function to() {
482
-		$to = $this->get( 'MSG_to' );
483
-		return empty( $to ) ? __( 'No recipient', 'event_espresso' ) : $to;
482
+		$to = $this->get('MSG_to');
483
+		return empty($to) ? __('No recipient', 'event_espresso') : $to;
484 484
 	}
485 485
 
486 486
 
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
 	 *
491 491
 	 * @param string $to
492 492
 	 */
493
-	public function set_to( $to ) {
494
-		$this->set( 'MSG_to', $to );
493
+	public function set_to($to) {
494
+		$this->set('MSG_to', $to);
495 495
 	}
496 496
 
497 497
 
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 	 * @return string
503 503
 	 */
504 504
 	public function from() {
505
-		return $this->get( 'MSG_from' );
505
+		return $this->get('MSG_from');
506 506
 	}
507 507
 
508 508
 
@@ -512,8 +512,8 @@  discard block
 block discarded – undo
512 512
 	 *
513 513
 	 * @param string $from
514 514
 	 */
515
-	public function set_from( $from ) {
516
-		$this->set( 'MSG_from', $from );
515
+	public function set_from($from) {
516
+		$this->set('MSG_from', $from);
517 517
 	}
518 518
 
519 519
 
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 	 * @return int
527 527
 	 */
528 528
 	public function priority() {
529
-		return $this->get( 'MSG_priority' );
529
+		return $this->get('MSG_priority');
530 530
 	}
531 531
 
532 532
 
@@ -536,8 +536,8 @@  discard block
 block discarded – undo
536 536
 	 *
537 537
 	 * @param int $priority
538 538
 	 */
539
-	public function set_priority( $priority ) {
540
-		$this->set( 'MSG_priority', $priority );
539
+	public function set_priority($priority) {
540
+		$this->set('MSG_priority', $priority);
541 541
 	}
542 542
 
543 543
 
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 	 * @return string
549 549
 	 */
550 550
 	public function STS_ID() {
551
-		return $this->get( 'STS_ID' );
551
+		return $this->get('STS_ID');
552 552
 	}
553 553
 
554 554
 
@@ -558,8 +558,8 @@  discard block
 block discarded – undo
558 558
 	 *
559 559
 	 * @param string $STS_ID
560 560
 	 */
561
-	public function set_STS_ID( $STS_ID ) {
562
-		$this->set( 'STS_ID', $STS_ID );
561
+	public function set_STS_ID($STS_ID) {
562
+		$this->set('STS_ID', $STS_ID);
563 563
 	}
564 564
 
565 565
 
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 	 * @return string
571 571
 	 */
572 572
 	public function created() {
573
-		return $this->get( 'MSG_created' );
573
+		return $this->get('MSG_created');
574 574
 	}
575 575
 
576 576
 
@@ -580,8 +580,8 @@  discard block
 block discarded – undo
580 580
 	 *
581 581
 	 * @param string $created
582 582
 	 */
583
-	public function set_created( $created ) {
584
-		$this->set( 'MSG_created', $created );
583
+	public function set_created($created) {
584
+		$this->set('MSG_created', $created);
585 585
 	}
586 586
 
587 587
 
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 	 * @return string
593 593
 	 */
594 594
 	public function modified() {
595
-		return $this->get( 'MSG_modified' );
595
+		return $this->get('MSG_modified');
596 596
 	}
597 597
 
598 598
 
@@ -602,8 +602,8 @@  discard block
 block discarded – undo
602 602
 	 *
603 603
 	 * @param string $modified
604 604
 	 */
605
-	public function set_modified( $modified ) {
606
-		$this->set( 'MSG_modified', $modified );
605
+	public function set_modified($modified) {
606
+		$this->set('MSG_modified', $modified);
607 607
 	}
608 608
 
609 609
 
@@ -613,8 +613,8 @@  discard block
 block discarded – undo
613 613
 	 * Sets generation data for this message.
614 614
 	 * @param mixed $data
615 615
 	 */
616
-	public function set_generation_data( $data ) {
617
-		$this->set_field_or_extra_meta( 'MSG_generation_data', $data );
616
+	public function set_generation_data($data) {
617
+		$this->set_field_or_extra_meta('MSG_generation_data', $data);
618 618
 	}
619 619
 
620 620
 
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 	 * @return mixed|null
627 627
 	 */
628 628
 	public function get_generation_data() {
629
-		return $this->get_field_or_extra_meta( 'MSG_generation_data' );
629
+		return $this->get_field_or_extra_meta('MSG_generation_data');
630 630
 	}
631 631
 
632 632
 
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 	 * @return mixed|null
638 638
 	 */
639 639
 	public function error_message() {
640
-		return $this->get_field_or_extra_meta( 'MSG_error' );
640
+		return $this->get_field_or_extra_meta('MSG_error');
641 641
 	}
642 642
 
643 643
 
@@ -646,8 +646,8 @@  discard block
 block discarded – undo
646 646
 	 * @param $message
647 647
 	 * @return bool|int
648 648
 	 */
649
-	public function set_error_message( $message ) {
650
-		return $this->set_field_or_extra_meta( 'MSG_error', $message );
649
+	public function set_error_message($message) {
650
+		return $this->set_field_or_extra_meta('MSG_error', $message);
651 651
 	}
652 652
 
653 653
 
@@ -661,18 +661,18 @@  discard block
 block discarded – undo
661 661
 		/**
662 662
 		 * This is deprecated functionality that will be removed eventually but included here now for backward compat.
663 663
 		 */
664
-		if ( ! empty( $this->template_pack ) ) {
664
+		if ( ! empty($this->template_pack)) {
665 665
 			return $this->template_pack;
666 666
 		}
667 667
 		/** @type EE_Message_Template_Group $grp */
668
-		$grp = $this->get_first_related( 'Message_Template_Group' );
668
+		$grp = $this->get_first_related('Message_Template_Group');
669 669
 		//if no group then let's try to get the first related group by internal messenger and message type (will use global grp).
670
-		if ( ! $grp instanceof EE_Message_Template_Group ) {
671
-			$grp = EEM_Message_Template_Group::instance()->get_one( array( array(
670
+		if ( ! $grp instanceof EE_Message_Template_Group) {
671
+			$grp = EEM_Message_Template_Group::instance()->get_one(array(array(
672 672
 				'MTP_messenger' => $this->messenger(),
673 673
 				'MTP_message_type' => $this->message_type(),
674 674
 				'MTP_is_global' => true
675
-			) ) );
675
+			)));
676 676
 		}
677 677
 
678 678
 		return $grp instanceof EE_Message_Template_Group ? $grp->get_template_pack() : null;
@@ -689,20 +689,20 @@  discard block
 block discarded – undo
689 689
 		/**
690 690
 		 * This is deprecated functionality that will be removed eventually but included here now for backward compat.
691 691
 		 */
692
-		if ( ! empty( $this->template_variation ) ) {
692
+		if ( ! empty($this->template_variation)) {
693 693
 			return $this->template_variation;
694 694
 		}
695 695
 
696 696
 		/** @type EE_Message_Template_Group $grp */
697
-		$grp = $this->get_first_related( 'Message_Template_Group' );
697
+		$grp = $this->get_first_related('Message_Template_Group');
698 698
 
699 699
 		//if no group then let's try to get the first related group by internal messenger and message type (will use global grp).
700
-		if ( ! $grp instanceof EE_Message_Template_Group ) {
701
-			$grp = EEM_Message_Template_Group::instance()->get_one( array( array(
700
+		if ( ! $grp instanceof EE_Message_Template_Group) {
701
+			$grp = EEM_Message_Template_Group::instance()->get_one(array(array(
702 702
 				'MTP_messenger' => $this->messenger(),
703 703
 				'MTP_message_type' => $this->message_type(),
704 704
 				'MTP_is_global' => true
705
-			) ) );
705
+			)));
706 706
 		}
707 707
 
708 708
 		return $grp instanceof EE_Message_Template_Group ? $grp->get_template_pack_variation() : '';
@@ -713,15 +713,15 @@  discard block
 block discarded – undo
713 713
 	 * @return string
714 714
 	 */
715 715
 	public function get_admin_details_link() {
716
-		EE_Registry::instance()->load_helper( 'URL' );
717
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
718
-		switch ( $this->STS_ID() ) {
716
+		EE_Registry::instance()->load_helper('URL');
717
+		EE_Registry::instance()->load_helper('MSG_Template');
718
+		switch ($this->STS_ID()) {
719 719
 			case EEM_Message::status_failed :
720
-				return EEH_MSG_Template::generate_error_display_trigger( $this );
720
+				return EEH_MSG_Template::generate_error_display_trigger($this);
721 721
 				break;
722 722
 
723 723
 			case EEM_Message::status_sent :
724
-				return EEH_MSG_Template::generate_browser_trigger( $this );
724
+				return EEH_MSG_Template::generate_browser_trigger($this);
725 725
 				break;
726 726
 
727 727
 			default :
@@ -742,13 +742,13 @@  discard block
 block discarded – undo
742 742
 	 * @return string
743 743
 	 */
744 744
 	public function get_admin_settings_link() {
745
-		EE_Registry::instance()->load_helper( 'URL' );
745
+		EE_Registry::instance()->load_helper('URL');
746 746
 		return EEH_URL::add_query_args_and_nonce(
747 747
 			array(
748 748
 				'page' => 'espresso_messages',
749 749
 				'action' => 'settings',
750 750
 			),
751
-			admin_url( 'admin.php' )
751
+			admin_url('admin.php')
752 752
 		);
753 753
 	}
754 754
 
@@ -757,13 +757,13 @@  discard block
 block discarded – undo
757 757
 	 * @return string
758 758
 	 */
759 759
 	public function get_admin_overview_link() {
760
-		EE_Registry::instance()->load_helper( 'URL' );
760
+		EE_Registry::instance()->load_helper('URL');
761 761
 		return EEH_URL::add_query_args_and_nonce(
762 762
 			array(
763 763
 				'page' => 'espresso_messages',
764 764
 				'action' => 'default',
765 765
 			),
766
-			admin_url( 'admin.php' )
766
+			admin_url('admin.php')
767 767
 		);
768 768
 	}
769 769
 
Please login to merge, or discard this patch.
core/EE_Load_Espresso_Core.core.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * @param 	EE_Response $response
51 51
 	 * @return 	EE_Response
52 52
 	 */
53
-	public function handle_request( EE_Request $request, EE_Response $response ) {
53
+	public function handle_request(EE_Request $request, EE_Response $response) {
54 54
 		$this->request = $request;
55 55
 		$this->response = $response;
56 56
 		// info about how to load classes required by other classes
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 		// workarounds for PHP < 5.3
61 61
 		$this->_load_class_tools();
62 62
 		// PSR4 Autoloaders
63
-		EE_Registry::instance()->load_core( 'EE_Psr4AutoloaderInit' );
63
+		EE_Registry::instance()->load_core('EE_Psr4AutoloaderInit');
64 64
 		// deprecated functions
65
-		espresso_load_required( 'EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php' );
65
+		espresso_load_required('EE_Deprecated', EE_CORE.'EE_Deprecated.core.php');
66 66
 		// load interfaces
67
-		espresso_load_required( 'EEI_Payment_Method_Interfaces', EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php' );
67
+		espresso_load_required('EEI_Payment_Method_Interfaces', EE_LIBRARIES.'payment_methods'.DS.'EEI_Payment_Method_Interfaces.php');
68 68
 		//// WP cron jobs
69
-		EE_Registry::instance()->load_core( 'Cron_Tasks' );
70
-		EE_Registry::instance()->load_core( 'EE_System' );
69
+		EE_Registry::instance()->load_core('Cron_Tasks');
70
+		EE_Registry::instance()->load_core('EE_System');
71 71
 
72 72
 		return $this->response;
73 73
 	}
@@ -81,15 +81,15 @@  discard block
 block discarded – undo
81 81
 	 * 	@return void
82 82
 	 */
83 83
 	private function _load_dependency_map() {
84
-		if ( is_readable( EE_CORE . 'EE_Dependency_Map.core.php' ) ) {
85
-			require_once( EE_CORE . 'EE_Dependency_Map.core.php' );
84
+		if (is_readable(EE_CORE.'EE_Dependency_Map.core.php')) {
85
+			require_once(EE_CORE.'EE_Dependency_Map.core.php');
86 86
 			EE_Dependency_Map::instance();
87 87
 		} else {
88 88
 			EE_Error::add_error(
89
-				__( 'The EE_Dependency_Map core class could not be loaded.', 'event_espresso' ),
89
+				__('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'),
90 90
 				__FILE__, __FUNCTION__, __LINE__
91 91
 			);
92
-			wp_die( EE_Error::get_notices() );
92
+			wp_die(EE_Error::get_notices());
93 93
 		}
94 94
 	}
95 95
 
@@ -102,15 +102,15 @@  discard block
 block discarded – undo
102 102
 	 * 	@return void
103 103
 	 */
104 104
 	private function _load_registry() {
105
-		if ( is_readable( EE_CORE . 'EE_Registry.core.php' )) {
106
-			require_once( EE_CORE . 'EE_Registry.core.php' );
105
+		if (is_readable(EE_CORE.'EE_Registry.core.php')) {
106
+			require_once(EE_CORE.'EE_Registry.core.php');
107 107
 			EE_Registry::instance();
108 108
 		} else {
109 109
 			EE_Error::add_error(
110
-				__( 'The EE_Registry core class could not be loaded.', 'event_espresso' ),
110
+				__('The EE_Registry core class could not be loaded.', 'event_espresso'),
111 111
 				__FILE__, __FUNCTION__, __LINE__
112 112
 			);
113
-			wp_die( EE_Error::get_notices() );
113
+			wp_die(EE_Error::get_notices());
114 114
 		}
115 115
 	}
116 116
 
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
 	 * 	@return void
123 123
 	 */
124 124
 	private function _load_class_tools() {
125
-		if ( is_readable( EE_HELPERS . 'EEH_Class_Tools.helper.php' )) {
126
-			require_once( EE_HELPERS . 'EEH_Class_Tools.helper.php' );
125
+		if (is_readable(EE_HELPERS.'EEH_Class_Tools.helper.php')) {
126
+			require_once(EE_HELPERS.'EEH_Class_Tools.helper.php');
127 127
 		} else {
128 128
 			EE_Error::add_error(
129
-				__( 'The EEH_Class_Tools helper could not be loaded.', 'event_espresso' ),
129
+				__('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'),
130 130
 				__FILE__, __FUNCTION__, __LINE__
131 131
 			);
132 132
 		}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 * @param \EE_Request $request
144 144
 	 * @param \EE_Response $response
145 145
 	 */
146
-	public function handle_response( EE_Request $request, EE_Response $response ) {
146
+	public function handle_response(EE_Request $request, EE_Response $response) {
147 147
 		//EEH_Debug_Tools::printr( $request, '$request', __FILE__, __LINE__ );
148 148
 		//EEH_Debug_Tools::printr( $response, '$response', __FILE__, __LINE__ );
149 149
 		//die();
Please login to merge, or discard this patch.
core/db_models/EEM_Message.model.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -92,42 +92,42 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return EEM_Message
94 94
 	 */
95
-	protected function __construct( $timezone = null ) {
96
-		$this->singular_item = __('Message','event_espresso');
97
-		$this->plural_item = __('Messages','event_espresso');
95
+	protected function __construct($timezone = null) {
96
+		$this->singular_item = __('Message', 'event_espresso');
97
+		$this->plural_item = __('Messages', 'event_espresso');
98 98
 
99 99
 		//used for token generator
100
-		EE_Registry::instance()->load_helper( 'URL' );
100
+		EE_Registry::instance()->load_helper('URL');
101 101
 
102 102
 		$this->_tables = array(
103
-			'Message'=>new EE_Primary_Table('esp_message','MSG_ID')
103
+			'Message'=>new EE_Primary_Table('esp_message', 'MSG_ID')
104 104
 		);
105 105
 
106 106
 		$allowed_priority = array(
107
-			self::priority_high => __( 'high', 'event_espresso' ),
108
-			self::priority_medium => __( 'medium', 'event_espresso' ),
109
-			self::priority_low => __( 'low', 'event_espresso' )
107
+			self::priority_high => __('high', 'event_espresso'),
108
+			self::priority_medium => __('medium', 'event_espresso'),
109
+			self::priority_low => __('low', 'event_espresso')
110 110
 		);
111 111
 
112 112
 		$this->_fields = array(
113 113
 			'Message'=>array(
114
-				'MSG_ID'=>new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID','event_espresso')),
115
-				'MSG_token' => new EE_Plain_Text_Field( 'MSG_token', __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', 'event_espresso' ), false, EEH_URL::generate_unique_token() ),
116
-				'GRP_ID'=>new EE_Foreign_Key_Int_Field( 'GRP_ID', __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso' ), true, 0, 'Message_Template_Group' ),
117
-				'TXN_ID' => new EE_Foreign_Key_Int_Field( 'TXN_ID', __( 'Foreign key to the related EE_Transaction.  This is required to give context for regenerating the specific message', 'event_espresso' ), true, 0, 'Transaction' ),
118
-				'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', __( 'Corresponds to the EE_Messenger::name used to send this message. This will also be used to attempt any resending of the message.', 'event_espresso' ), false, 'email' ),
119
-				'MSG_message_type' => new EE_Plain_Text_Field( 'MSG_message_type', __( 'Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso' ), false, 'receipt' ),
120
-				'MSG_context' => new EE_Plain_Text_Field( 'MSG_context', __( 'Context', 'event_espresso' ), false ),
121
-				'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field( 'MSG_recipient_ID', __( 'Recipient ID', 'event_espresso' ), true, null, array( 'Registration', 'Attendee', 'WP_User' ) ),
122
-				'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field( 'MSG_recipient_type', __( 'Recipient Type', 'event_espresso' ), true, null, array( 'Registration', 'Attendee', 'WP_User' ) ),
123
-				'MSG_content' => new EE_Maybe_Serialized_Text_Field( 'MSG_content', __( 'Content', 'event_espresso' ), true, '' ),
124
-				'MSG_to' => new EE_Maybe_Serialized_Text_Field( 'MSG_to', __( 'Address To', 'event_espresso' ), true ),
125
-				'MSG_from' => new EE_Maybe_Serialized_Text_Field( 'MSG_from', __( 'Address From', 'event_espresso' ), true ),
126
-				'MSG_subject' => new EE_Maybe_Serialized_Text_Field( 'MSG_subject', __( 'Subject', 'event_espresso' ), true, '' ),
127
-				'MSG_priority' => new EE_Enum_Integer_Field( 'MSG_priority', __( 'Priority', 'event_espresso' ), false, self::priority_low, $allowed_priority ),
128
-				'STS_ID' => new EE_Foreign_Key_String_Field( 'STS_ID', __( 'Status', 'event_espresso' ), false, self::status_incomplete, 'Status' ),
129
-				'MSG_created' => new EE_Datetime_Field( 'MSG_created', __( 'Created', 'event_espresso' ), false, time() ),
130
-				'MSG_modified' => new EE_Datetime_Field( 'MSG_modified', __( 'Modified', 'event_espresso' ), true, time() )
114
+				'MSG_ID'=>new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID', 'event_espresso')),
115
+				'MSG_token' => new EE_Plain_Text_Field('MSG_token', __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', 'event_espresso'), false, EEH_URL::generate_unique_token()),
116
+				'GRP_ID'=>new EE_Foreign_Key_Int_Field('GRP_ID', __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso'), true, 0, 'Message_Template_Group'),
117
+				'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', __('Foreign key to the related EE_Transaction.  This is required to give context for regenerating the specific message', 'event_espresso'), true, 0, 'Transaction'),
118
+				'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', __('Corresponds to the EE_Messenger::name used to send this message. This will also be used to attempt any resending of the message.', 'event_espresso'), false, 'email'),
119
+				'MSG_message_type' => new EE_Plain_Text_Field('MSG_message_type', __('Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso'), false, 'receipt'),
120
+				'MSG_context' => new EE_Plain_Text_Field('MSG_context', __('Context', 'event_espresso'), false),
121
+				'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field('MSG_recipient_ID', __('Recipient ID', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')),
122
+				'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field('MSG_recipient_type', __('Recipient Type', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')),
123
+				'MSG_content' => new EE_Maybe_Serialized_Text_Field('MSG_content', __('Content', 'event_espresso'), true, ''),
124
+				'MSG_to' => new EE_Maybe_Serialized_Text_Field('MSG_to', __('Address To', 'event_espresso'), true),
125
+				'MSG_from' => new EE_Maybe_Serialized_Text_Field('MSG_from', __('Address From', 'event_espresso'), true),
126
+				'MSG_subject' => new EE_Maybe_Serialized_Text_Field('MSG_subject', __('Subject', 'event_espresso'), true, ''),
127
+				'MSG_priority' => new EE_Enum_Integer_Field('MSG_priority', __('Priority', 'event_espresso'), false, self::priority_low, $allowed_priority),
128
+				'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status', 'event_espresso'), false, self::status_incomplete, 'Status'),
129
+				'MSG_created' => new EE_Datetime_Field('MSG_created', __('Created', 'event_espresso'), false, time()),
130
+				'MSG_modified' => new EE_Datetime_Field('MSG_modified', __('Modified', 'event_espresso'), true, time())
131 131
 			)
132 132
 		);
133 133
 		$this->_model_relations = array(
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 			'Message_Template_Group' => new EE_Belongs_To_Relation(),
138 138
 			'Transaction' => new EE_Belongs_To_Relation()
139 139
 		);
140
-		parent::__construct( $timezone );
140
+		parent::__construct($timezone);
141 141
 	}
142 142
 
143 143
 
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 	public function create_default_object() {
149 149
 		/** @type EE_Message $message */
150 150
 		$message = parent::create_default_object();
151
-		if ( $message instanceof EE_Message ) {
152
-			return EE_Message_Factory::set_messenger_and_message_type( $message );
151
+		if ($message instanceof EE_Message) {
152
+			return EE_Message_Factory::set_messenger_and_message_type($message);
153 153
 		}
154 154
 		return null;
155 155
 	}
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
 	 * @param mixed $cols_n_values
161 161
 	 * @return \EE_Message
162 162
 	 */
163
-	public function instantiate_class_from_array_or_object( $cols_n_values ) {
163
+	public function instantiate_class_from_array_or_object($cols_n_values) {
164 164
 		/** @type EE_Message $message */
165
-		$message = parent::instantiate_class_from_array_or_object( $cols_n_values );
166
-		if ( $message instanceof EE_Message ) {
167
-			return EE_Message_Factory::set_messenger_and_message_type( $message );
165
+		$message = parent::instantiate_class_from_array_or_object($cols_n_values);
166
+		if ($message instanceof EE_Message) {
167
+			return EE_Message_Factory::set_messenger_and_message_type($message);
168 168
 		}
169 169
 		return null;
170 170
 	}
@@ -177,13 +177,13 @@  discard block
 block discarded – undo
177 177
 	 * @param string $message_type the message type slug
178 178
 	 * @return boolean
179 179
 	 */
180
-	public function message_sent_for_attendee( $attendee, $message_type ) {
181
-		$attendee_ID = EEM_Attendee::instance()->ensure_is_ID( $attendee );
182
-		return $this->exists( array( array(
180
+	public function message_sent_for_attendee($attendee, $message_type) {
181
+		$attendee_ID = EEM_Attendee::instance()->ensure_is_ID($attendee);
182
+		return $this->exists(array(array(
183 183
 			'Attendee.ATT_ID' => $attendee_ID,
184 184
 			'MSG_message_type' => $message_type,
185
-			'STS_ID' => array( 'IN', $this->stati_indicating_sent() )
186
-		) ) );
185
+			'STS_ID' => array('IN', $this->stati_indicating_sent())
186
+		)));
187 187
 	}
188 188
 
189 189
 
@@ -195,13 +195,13 @@  discard block
 block discarded – undo
195 195
 	 * @param string $message_type the message type slug
196 196
 	 * @return boolean
197 197
 	 */
198
-	public function message_sent_for_registration( $registration, $message_type ) {
199
-		$registrationID = EEM_Registration::instance()->ensure_is_ID( $registration );
200
-		return $this->exists( array( array(
198
+	public function message_sent_for_registration($registration, $message_type) {
199
+		$registrationID = EEM_Registration::instance()->ensure_is_ID($registration);
200
+		return $this->exists(array(array(
201 201
 			'Registration.REG_ID' => $registrationID,
202 202
 			'MSG_message_type' => $message_type,
203
-			'STS_ID' => array( 'IN', $this->stati_indicating_sent() )
204
-		) ) );
203
+			'STS_ID' => array('IN', $this->stati_indicating_sent())
204
+		)));
205 205
 	}
206 206
 
207 207
 
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
 	 * @param string $token
213 213
 	 * @return EE_Message | null
214 214
 	 */
215
-	public function get_one_by_token( $token ) {
216
-		return $this->get_one( array( array(
215
+	public function get_one_by_token($token) {
216
+		return $this->get_one(array(array(
217 217
 			'MSG_token' => $token
218
-		) ) );
218
+		)));
219 219
 	}
220 220
 
221 221
 
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 	 * Returns stati that indicate the message HAS been sent
224 224
 	 * @return array of strings for possible stati
225 225
 	 */
226
-	public function stati_indicating_sent(){
227
-		return apply_filters( 'FHEE__EEM_Message__stati_indicating_sent', array( self::status_sent ) );
226
+	public function stati_indicating_sent() {
227
+		return apply_filters('FHEE__EEM_Message__stati_indicating_sent', array(self::status_sent));
228 228
 	}
229 229
 
230 230
 
@@ -235,13 +235,13 @@  discard block
 block discarded – undo
235 235
 	 * @return array of strings for possible stati.
236 236
 	 */
237 237
 	public function stati_indicating_to_send() {
238
-		return apply_filters( 'FHEE__EEM_Message__stati_indicating_to_send', array( self::status_idle, self::status_resend ) );
238
+		return apply_filters('FHEE__EEM_Message__stati_indicating_to_send', array(self::status_idle, self::status_resend));
239 239
 	}
240 240
 
241 241
 
242 242
 
243 243
 	public function stati_indicating_failed_sending() {
244
-		return apply_filters( 'FHEE__EEM_Message__stati_indicating_failed_sending', array( self::status_failed, self::status_retry ) );
244
+		return apply_filters('FHEE__EEM_Message__stati_indicating_failed_sending', array(self::status_failed, self::status_retry));
245 245
 	}
246 246
 
247 247
 
@@ -281,25 +281,25 @@  discard block
 block discarded – undo
281 281
 			'EVT_ID' => 'Event',
282 282
 		);
283 283
 		$query_params[0] = array();
284
-		EE_Registry::instance()->load_class( 'Request_Handler' );
285
-		foreach ( $expected_vars as $request_key => $model_name ) {
286
-			if ( $request_value = EE_Registry::instance()->REQ->get( $request_key ) ) {
284
+		EE_Registry::instance()->load_class('Request_Handler');
285
+		foreach ($expected_vars as $request_key => $model_name) {
286
+			if ($request_value = EE_Registry::instance()->REQ->get($request_key)) {
287 287
 				//special case
288
-				if ( $request_key === '_REG_ID' ) {
288
+				if ($request_key === '_REG_ID') {
289 289
 					$query_params[0]['AND**filter_by']['OR**filter_by'] = array(
290 290
 						'Registration.REG_ID' => $request_value,
291 291
 						'Attendee.Registration.REG_ID' => $request_value,
292 292
 					);
293 293
 					continue;
294 294
 				}
295
-				if ( $request_key === 'EVT_ID' ) {
295
+				if ($request_key === 'EVT_ID') {
296 296
 					$query_params[0]['AND**filter_by']['OR**filter_by'] = array(
297 297
 						'Registration.EVT_ID' => $request_value,
298 298
 						'Attendee.Registration.EVT_ID' => $request_value,
299 299
 					);
300 300
 					continue;
301 301
 				}
302
-				$query_params[0][ $model_name . '.' . $request_key ] = EE_Registry::instance()->REQ->get( $request_key );
302
+				$query_params[0][$model_name.'.'.$request_key] = EE_Registry::instance()->REQ->get($request_key);
303 303
 			}
304 304
 		}
305 305
 		return $query_params;
Please login to merge, or discard this patch.
core/libraries/messages/EE_Message_Type_Collection_Loader.lib.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @param EE_Message_Type_Collection $message_types
33 33
 	 */
34
-	public function __construct( EE_Message_Type_Collection $message_types ) {
35
-		$this->set_message_type_collection( $message_types );
34
+	public function __construct(EE_Message_Type_Collection $message_types) {
35
+		$this->set_message_type_collection($message_types);
36 36
 	}
37 37
 
38 38
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	/**
50 50
 	 * @param mixed $message_types
51 51
 	 */
52
-	public function set_message_type_collection( EE_Message_Type_Collection $message_types ) {
52
+	public function set_message_type_collection(EE_Message_Type_Collection $message_types) {
53 53
 		$this->_message_type_collection = $message_types;
54 54
 	}
55 55
 
@@ -62,26 +62,26 @@  discard block
 block discarded – undo
62 62
 	 * @param  string $folder
63 63
 	 * @return void
64 64
 	 */
65
-	public function load_message_types_from_folder( $folder = '' ) {
65
+	public function load_message_types_from_folder($folder = '') {
66 66
 		//make sure autoloaders are set (fail-safe)
67 67
 		EED_Messages::set_autoloaders();
68
-		$folder = ! empty( $folder ) ? $folder : EE_LIBRARIES . 'messages' . DS . 'message_type';
69
-		$folder .= $folder[ strlen( $folder ) - 1 ] != DS ? DS : '';
68
+		$folder = ! empty($folder) ? $folder : EE_LIBRARIES.'messages'.DS.'message_type';
69
+		$folder .= $folder[strlen($folder) - 1] != DS ? DS : '';
70 70
 		// get all the files in that folder that end in ".class.php
71 71
 		$filepaths = apply_filters(
72 72
 			'FHEE__EE_messages__get_installed__messagetype_files',
73
-			glob( $folder . '*.class.php' )
73
+			glob($folder.'*.class.php')
74 74
 		);
75
-		if ( empty( $filepaths ) ) {
75
+		if (empty($filepaths)) {
76 76
 			return;
77 77
 		}
78
-		foreach ( (array) $filepaths as $file_path ) {
78
+		foreach ((array) $filepaths as $file_path) {
79 79
 			// extract filename from path
80
-			$file_path = basename( $file_path );
80
+			$file_path = basename($file_path);
81 81
 			// now remove any file extensions
82
-			$message_type_class_name = substr( $file_path, 0, strpos( $file_path, '.' ) );
82
+			$message_type_class_name = substr($file_path, 0, strpos($file_path, '.'));
83 83
 			$message_type = new $message_type_class_name();
84
-			if ( $this->message_type_collection()->has_by_name( $message_type->name ) ) {
84
+			if ($this->message_type_collection()->has_by_name($message_type->name)) {
85 85
 				continue;
86 86
 			}
87 87
 			$this->message_type_collection()->add(
Please login to merge, or discard this patch.
core/libraries/messages/EE_Message_Type_Collection.lib.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 	 * @param mixed  $info
40 40
 	 * @return bool
41 41
 	 */
42
-	public function add( $object, $info = null ) {
43
-		$info = empty( $info ) && $object instanceof $this->interface ? $object->name : $info;
44
-		return parent::add( $object, $info );
42
+	public function add($object, $info = null) {
43
+		$info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
44
+		return parent::add($object, $info);
45 45
 	}
46 46
 
47 47
 
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 * @param mixed  $info
58 58
 	 * @return bool
59 59
 	 */
60
-	public function set_info( $object, $info = null ) {
61
-		$info = empty( $info ) && $object instanceof $this->interface ? $object->name : $info;
62
-		return parent::set_info( $object, $info );
60
+	public function set_info($object, $info = null) {
61
+		$info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
62
+		return parent::set_info($object, $info);
63 63
 	}
64 64
 
65 65
 
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 	 * @param mixed
75 75
 	 * @return null | object
76 76
 	 */
77
-	public function get_by_info( $info ) {
78
-		return parent::get_by_info( $info );
77
+	public function get_by_info($info) {
78
+		return parent::get_by_info($info);
79 79
 	}
80 80
 
81 81
 
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 	 * @param object $object
90 90
 	 * @return bool
91 91
 	 */
92
-	public function has( $object ) {
93
-		return parent::has( $object );
92
+	public function has($object) {
93
+		return parent::has($object);
94 94
 	}
95 95
 
96 96
 
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	 * @param string $message_type_name
105 105
 	 * @return bool
106 106
 	 */
107
-	public function has_by_name( $message_type_name ) {
108
-		return $this->get_by_info( $message_type_name ) instanceof $this->interface ? true : false;
107
+	public function has_by_name($message_type_name) {
108
+		return $this->get_by_info($message_type_name) instanceof $this->interface ? true : false;
109 109
 	}
110 110
 
111 111
 
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 	 * @param $object
120 120
 	 * @return bool
121 121
 	 */
122
-	public function remove( $object ) {
123
-		return parent::remove( $object );
122
+	public function remove($object) {
123
+		return parent::remove($object);
124 124
 	}
125 125
 
126 126
 
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 	 * @param $object
135 135
 	 * @return void
136 136
 	 */
137
-	public function set_current( $object ) {
138
-		parent::set_current( $object );
137
+	public function set_current($object) {
138
+		parent::set_current($object);
139 139
 	}
140 140
 
141 141
 
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 	 * @param $info
150 150
 	 * @return void
151 151
 	 */
152
-	public function set_current_by_info( $info ) {
153
-		parent::set_current_by_info( $info );
152
+	public function set_current_by_info($info) {
153
+		parent::set_current_by_info($info);
154 154
 	}
155 155
 
156 156
 
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
 	 * @return void
165 165
 	 */
166 166
 	public function show_collection_classes() {
167
-		if ( WP_DEBUG ) {
167
+		if (WP_DEBUG) {
168 168
 			$this->rewind();
169
-			while ( $this->valid() ) {
170
-				echo '<h5 style="color:#2EA2CC;">collection class : <span style="color:#E76700">' . $this->getInfo()
169
+			while ($this->valid()) {
170
+				echo '<h5 style="color:#2EA2CC;">collection class : <span style="color:#E76700">'.$this->getInfo()
171 171
 					 . '</span></h5>';
172 172
 				$this->next();
173 173
 			}
Please login to merge, or discard this patch.
core/libraries/messages/EE_Message_Resource_Manager.lib.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
4
-	exit( 'No direct script access allowed' );
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 
7 7
 
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 	 * @param string $messenger_name
113 113
 	 * @return \EE_Messenger
114 114
 	 */
115
-	public function get_messenger( $messenger_name ) {
116
-		return $this->messenger_collection()->get_by_info( $messenger_name );
115
+	public function get_messenger($messenger_name) {
116
+		return $this->messenger_collection()->get_by_info($messenger_name);
117 117
 	}
118 118
 
119 119
 
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 * @param string $message_type_name
123 123
 	 * @return \EE_Message_Type
124 124
 	 */
125
-	public function get_message_type( $message_type_name ) {
126
-		return $this->message_type_collection()->get_by_info( $message_type_name );
125
+	public function get_message_type($message_type_name) {
126
+		return $this->message_type_collection()->get_by_info($message_type_name);
127 127
 	}
128 128
 
129 129
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	public function get_active_messengers_option() {
138 138
 		return apply_filters(
139 139
 			'FHEE__EE_Message_Resource_Manager__get_active_messengers_option',
140
-			get_option( 'ee_active_messengers', array() )
140
+			get_option('ee_active_messengers', array())
141 141
 		);
142 142
 	}
143 143
 
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 	 * @param array $active_messengers Incoming data to save.
150 150
 	 * @return bool FALSE if not updated, TRUE if updated.
151 151
 	 */
152
-	public function update_active_messengers_option( $active_messengers ) {
153
-		return update_option( 'ee_active_messengers', $active_messengers );
152
+	public function update_active_messengers_option($active_messengers) {
153
+		return update_option('ee_active_messengers', $active_messengers);
154 154
 	}
155 155
 
156 156
 
@@ -162,26 +162,26 @@  discard block
 block discarded – undo
162 162
 	protected function _set_active_messengers_and_message_types() {
163 163
 
164 164
 		$active_messengers = $this->get_active_messengers_option();
165
-		$active_messengers = is_array( $active_messengers ) ? $active_messengers : array( $active_messengers );
165
+		$active_messengers = is_array($active_messengers) ? $active_messengers : array($active_messengers);
166 166
 		$not_installed = array();
167
-		foreach ( $active_messengers as $active_messenger => $data ) {
168
-			if ( $this->messenger_collection()->has_by_name( $active_messenger ) ) {
169
-				$this->_active_messengers[ $active_messenger ] = $this->messenger_collection()->get_by_info(
167
+		foreach ($active_messengers as $active_messenger => $data) {
168
+			if ($this->messenger_collection()->has_by_name($active_messenger)) {
169
+				$this->_active_messengers[$active_messenger] = $this->messenger_collection()->get_by_info(
170 170
 					$active_messenger
171 171
 				);
172
-				$this->_active_message_types[ $active_messenger ] = ! empty( $data[ 'settings' ][ $active_messenger . '-message_types' ] )
173
-					? $data[ 'settings' ][ $active_messenger . '-message_types' ]
172
+				$this->_active_message_types[$active_messenger] = ! empty($data['settings'][$active_messenger.'-message_types'])
173
+					? $data['settings'][$active_messenger.'-message_types']
174 174
 					: array();
175 175
 			} else {
176 176
 				$not_installed[] = $active_messenger;
177 177
 			}
178 178
 		}
179
-		if ( ! empty( $not_installed ) ) {
179
+		if ( ! empty($not_installed)) {
180 180
 			EE_Error::add_error(
181 181
 				sprintf(
182
-					__( 'The following messengers are either not installed or are invalid:%1$s %2$s', 'event_espresso' ),
182
+					__('The following messengers are either not installed or are invalid:%1$s %2$s', 'event_espresso'),
183 183
 					'<br />',
184
-					implode( ', ', $not_installed )
184
+					implode(', ', $not_installed)
185 185
 				),
186 186
 				__FILE__, __FUNCTION__, __LINE__
187 187
 			);
@@ -197,11 +197,11 @@  discard block
 block discarded – undo
197 197
 	 * @param  string $messenger name of messenger
198 198
 	 * @return void
199 199
 	 */
200
-	protected function _deactivate_messenger( $messenger ) {
201
-		unset( $this->_active_messengers[ $messenger ] );
202
-		unset( $this->_active_message_types[ $messenger ] );
203
-		$this->_message_template_group_model->deactivate_message_template_groups_for( $messenger );
204
-		$this->update_active_messengers_option( $this->_active_messengers );
200
+	protected function _deactivate_messenger($messenger) {
201
+		unset($this->_active_messengers[$messenger]);
202
+		unset($this->_active_message_types[$messenger]);
203
+		$this->_message_template_group_model->deactivate_message_template_groups_for($messenger);
204
+		$this->update_active_messengers_option($this->_active_messengers);
205 205
 	}
206 206
 
207 207
 
@@ -213,15 +213,15 @@  discard block
 block discarded – undo
213 213
 	 * @param  string $message_type name of message type
214 214
 	 * @return void
215 215
 	 */
216
-	protected function _deactivate_message_type( $message_type ) {
217
-		foreach ( $this->_active_messengers as $messenger => $settings ) {
216
+	protected function _deactivate_message_type($message_type) {
217
+		foreach ($this->_active_messengers as $messenger => $settings) {
218 218
 			unset(
219
-				$this->_active_messengers[ $messenger ][ 'settings' ][ $messenger . '-message_types' ][ $message_type ]
219
+				$this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$message_type]
220 220
 			);
221 221
 		}
222
-		$this->_message_template_group_model->deactivate_message_template_groups_for( '', $message_type );
223
-		unset( $this->_active_message_types[ $message_type ] );
224
-		$this->update_active_messengers_option( $this->_active_messengers );
222
+		$this->_message_template_group_model->deactivate_message_template_groups_for('', $message_type);
223
+		unset($this->_active_message_types[$message_type]);
224
+		$this->update_active_messengers_option($this->_active_messengers);
225 225
 	}
226 226
 
227 227
 
Please login to merge, or discard this patch.