Completed
Branch BUG-7514-7935-7936-price-order (518ae6)
by
unknown
13:10 queued 44s
created
core/libraries/payment_methods/EE_Onsite_Gateway.lib.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *
25 25
  * ------------------------------------------------------------------------
26 26
  */
27
-abstract class EE_Onsite_Gateway extends EE_Gateway{
27
+abstract class EE_Onsite_Gateway extends EE_Gateway {
28 28
 
29 29
 	/**
30 30
 	 * @return EE_Onsite_Gateway
@@ -53,5 +53,5 @@  discard block
 block discarded – undo
53 53
 	 * } unless a child class specifies these array keys are NOT present
54 54
 	 * @return EE_Payment updated
55 55
 	 */
56
-	public abstract function do_direct_payment($payment,$billing_info = null);
56
+	public abstract function do_direct_payment($payment, $billing_info = null);
57 57
 }
Please login to merge, or discard this patch.
core/libraries/payment_methods/EE_Payment_Method_Manager.lib.php 2 patches
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  *
4 6
  * Class EE_Payment_Method_Manager
@@ -139,7 +141,7 @@  discard block
 block discarded – undo
139 141
 		if(isset($this->_payment_method_types[$payment_method_name])){
140 142
 			require_once($this->_payment_method_types[$payment_method_name]);
141 143
 			return true;
142
-		}else{
144
+		} else{
143 145
 			return false;
144 146
 		}
145 147
 	}
@@ -159,7 +161,7 @@  discard block
 block discarded – undo
159 161
 				$payment_methods[] = $this->payment_method_class_from_type($classname);
160 162
 			}
161 163
 			return $payment_methods;
162
-		}else{
164
+		} else{
163 165
 			return array_keys($this->_payment_method_types);
164 166
 		}
165 167
 	}
@@ -242,7 +244,7 @@  discard block
 block discarded – undo
242 244
 				}
243 245
 			}
244 246
 
245
-		}else{
247
+		} else{
246 248
 			$payment_method->set_active();
247 249
 			$payment_method->save();
248 250
 		}
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 */
31 31
 	public static function instance() {
32 32
 		// check if class object is instantiated, and instantiated properly
33
-		if ( self::$_instance === NULL  or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Payment_Method_Manager )) {
33
+		if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Payment_Method_Manager)) {
34 34
 			self::$_instance = new self();
35 35
 		}
36 36
 		EE_Registry::instance()->load_lib('PMT_Base');
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 * Resets the instance and returns a new one
42 42
 	 * @return EE_Payment_Method_Manager
43 43
 	 */
44
-	public static function reset(){
44
+	public static function reset() {
45 45
 		self::$_instance = NULL;
46 46
 		return self::instance();
47 47
 	}
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 	 * or just re-use the PMTs we found last time we checked during this request (if
53 53
 	 * we have not yet checked during this request, then we need to check anyways)
54 54
 	 */
55
-	public function maybe_register_payment_methods( $force_recheck = FALSE ){
56
-		if( ! $this->_payment_method_types || $force_recheck ){
55
+	public function maybe_register_payment_methods($force_recheck = FALSE) {
56
+		if ( ! $this->_payment_method_types || $force_recheck) {
57 57
 			$this->_register_payment_methods();
58 58
 			//if in admin lets ensure caps are set.
59
-			if ( is_admin() ) {
60
-				add_filter( 'FHEE__EE_Capabilities__init_caps_map__caps', array( $this, 'add_payment_method_caps' ) );
59
+			if (is_admin()) {
60
+				add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array($this, 'add_payment_method_caps'));
61 61
 				EE_Registry::instance()->CAP->init_caps();
62 62
 			}
63 63
 		}
@@ -70,19 +70,19 @@  discard block
 block discarded – undo
70 70
 	 */
71 71
 	protected function _register_payment_methods() {
72 72
 		// grab list of installed modules
73
-		$pm_to_register = glob( EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR );
73
+		$pm_to_register = glob(EE_PAYMENT_METHODS.'*', GLOB_ONLYDIR);
74 74
 		// filter list of modules to register
75
-		$pm_to_register = apply_filters( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', $pm_to_register );
75
+		$pm_to_register = apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', $pm_to_register);
76 76
 
77 77
 		// loop through folders
78
-		foreach ( $pm_to_register as $pm_path ) {
79
-				$this->register_payment_method( $pm_path );
78
+		foreach ($pm_to_register as $pm_path) {
79
+				$this->register_payment_method($pm_path);
80 80
 		}
81
-		do_action( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods' );
81
+		do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods');
82 82
 		// filter list of installed modules
83 83
 		//keep them organized alphabetically by the payment method type's name
84
-		ksort( $this->_payment_method_types );
85
-		return apply_filters( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', $this->_payment_method_types );
84
+		ksort($this->_payment_method_types);
85
+		return apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', $this->_payment_method_types);
86 86
 	}
87 87
 
88 88
 
@@ -94,35 +94,35 @@  discard block
 block discarded – undo
94 94
 	 * @param string $payment_method_path - full path up to and including payment method folder
95 95
 	 * @return boolean
96 96
 	 */
97
-	public function register_payment_method( $payment_method_path = '' ) {
98
-		do_action( 'AHEE__EE_Payment_Method_Manager__register_payment_method__begin',$payment_method_path );
97
+	public function register_payment_method($payment_method_path = '') {
98
+		do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path);
99 99
 		$module_ext = '.pm.php';
100 100
 		// make all separators match
101
-		$payment_method_path = rtrim( str_replace( '/\\', DS, $payment_method_path ), DS );
101
+		$payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS);
102 102
 		// grab and sanitize module name
103
-		$module_dir = basename( $payment_method_path );
103
+		$module_dir = basename($payment_method_path);
104 104
 		// create classname from module directory name
105
-		$module = str_replace( ' ', '_', str_replace( '_', ' ', $module_dir ));
105
+		$module = str_replace(' ', '_', str_replace('_', ' ', $module_dir));
106 106
 		// add class prefix
107
-		$module_class = 'EE_PMT_' . $module;
107
+		$module_class = 'EE_PMT_'.$module;
108 108
 		// does the module exist ?
109
-		if ( ! is_readable( $payment_method_path . DS . $module_class . $module_ext )) {
110
-			$msg = sprintf( __( 'The requested %s payment method file could not be found or is not readable due to file permissions.', 'event_espresso' ), $module );
111
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
109
+		if ( ! is_readable($payment_method_path.DS.$module_class.$module_ext)) {
110
+			$msg = sprintf(__('The requested %s payment method file could not be found or is not readable due to file permissions.', 'event_espresso'), $module);
111
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
112 112
 			return FALSE;
113 113
 		}
114
-		if ( WP_DEBUG === TRUE ) { EEH_Debug_Tools::instance()->start_timer(); }
114
+		if (WP_DEBUG === TRUE) { EEH_Debug_Tools::instance()->start_timer(); }
115 115
 		// load the module class file
116
-		require_once( $payment_method_path . DS . $module_class . $module_ext );
117
-		if ( WP_DEBUG === TRUE ) { EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class"); }
116
+		require_once($payment_method_path.DS.$module_class.$module_ext);
117
+		if (WP_DEBUG === TRUE) { EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class"); }
118 118
 		// verify that class exists
119
-		if ( ! class_exists( $module_class )) {
120
-			$msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class );
121
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
119
+		if ( ! class_exists($module_class)) {
120
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
121
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
122 122
 			return FALSE;
123 123
 		}
124 124
 		// add to array of registered modules
125
-		$this->_payment_method_types[ $module ] = $payment_method_path . DS . $module_class . $module_ext;
125
+		$this->_payment_method_types[$module] = $payment_method_path.DS.$module_class.$module_ext;
126 126
 		return TRUE;
127 127
 	}
128 128
 	/**
@@ -131,15 +131,15 @@  discard block
 block discarded – undo
131 131
 	 * @param boolean $force_recheck whether to force re-checking for new payment method types
132 132
 	 * @return boolean
133 133
 	 */
134
-	public function payment_method_type_exists($payment_method_name, $force_recheck = FALSE){
135
-		if ( ! is_array( $this->_payment_method_types ) || ! isset( $this->_payment_method_types[$payment_method_name] )
136
-				|| $force_recheck ) {
134
+	public function payment_method_type_exists($payment_method_name, $force_recheck = FALSE) {
135
+		if ( ! is_array($this->_payment_method_types) || ! isset($this->_payment_method_types[$payment_method_name])
136
+				|| $force_recheck) {
137 137
 			$this->maybe_register_payment_methods($force_recheck);
138 138
 		}
139
-		if(isset($this->_payment_method_types[$payment_method_name])){
139
+		if (isset($this->_payment_method_types[$payment_method_name])) {
140 140
 			require_once($this->_payment_method_types[$payment_method_name]);
141 141
 			return true;
142
-		}else{
142
+		} else {
143 143
 			return false;
144 144
 		}
145 145
 	}
@@ -150,16 +150,16 @@  discard block
 block discarded – undo
150 150
 	 * @param boolean $force_recheck whether to force re-checking for new payment method types
151 151
 	 * @return array
152 152
 	 */
153
-	public function payment_method_type_names($with_prefixes = FALSE, $force_recheck = FALSE ){
153
+	public function payment_method_type_names($with_prefixes = FALSE, $force_recheck = FALSE) {
154 154
 		$this->maybe_register_payment_methods($force_recheck);
155
-		if($with_prefixes){
155
+		if ($with_prefixes) {
156 156
 			$classnames = array_keys($this->_payment_method_types);
157 157
 			$payment_methods = array();
158
-			foreach($classnames as $classname){
158
+			foreach ($classnames as $classname) {
159 159
 				$payment_methods[] = $this->payment_method_class_from_type($classname);
160 160
 			}
161 161
 			return $payment_methods;
162
-		}else{
162
+		} else {
163 163
 			return array_keys($this->_payment_method_types);
164 164
 		}
165 165
 	}
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
 	 * @param boolean $force_recheck whether to force re-checking for new payment method types
170 170
 	 * @return EE_PMT_Base[]
171 171
 	 */
172
-	public function payment_method_types( $force_recheck = FALSE ){
172
+	public function payment_method_types($force_recheck = FALSE) {
173 173
 		$this->maybe_register_payment_methods($force_recheck);
174 174
 		$pmt_objs = array();
175
-		foreach($this->payment_method_type_names(true) as $classname){
175
+		foreach ($this->payment_method_type_names(true) as $classname) {
176 176
 			$pmt_objs[] = new $classname;
177 177
 		}
178 178
 		return $pmt_objs;
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 	 * @param string $classname
185 185
 	 * @return string
186 186
 	 */
187
-	public function payment_method_type_sans_class_prefix($classname){
188
-		$pmt_name = str_replace("EE_PMT_","",$classname);
187
+	public function payment_method_type_sans_class_prefix($classname) {
188
+		$pmt_name = str_replace("EE_PMT_", "", $classname);
189 189
 		return $pmt_name;
190 190
 	}
191 191
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	 * @param string $type
195 195
 	 * @return string
196 196
 	 */
197
-	public function payment_method_class_from_type($type){
197
+	public function payment_method_class_from_type($type) {
198 198
 		$this->maybe_register_payment_methods();
199 199
 		return "EE_PMT_".$type;
200 200
 	}
@@ -205,51 +205,51 @@  discard block
 block discarded – undo
205 205
 	 * @param string $payment_method_type the PMT_type; for EE_PMT_Invoice this would be 'Invoice'
206 206
 	 * @return EE_Payment_Method
207 207
 	 */
208
-	public function activate_a_payment_method_of_type( $payment_method_type ){
208
+	public function activate_a_payment_method_of_type($payment_method_type) {
209 209
 		$payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type);
210
-		if( ! $payment_method){
210
+		if ( ! $payment_method) {
211 211
 			global $current_user;
212 212
 			$pm_type_class = $this->payment_method_class_from_type($payment_method_type);
213
-			if(class_exists($pm_type_class)){
213
+			if (class_exists($pm_type_class)) {
214 214
 				/** @var $pm_type_obj EE_PMT_Base */
215 215
 				$pm_type_obj = new $pm_type_class;
216 216
 				$payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name());
217
-				if( ! $payment_method){
217
+				if ( ! $payment_method) {
218 218
 					$payment_method = EE_Payment_Method::new_instance(array(
219 219
 						'PMD_type'=>$pm_type_obj->system_name(),
220 220
 						'PMD_name'=>$pm_type_obj->pretty_name(),
221 221
 						'PMD_admin_name'=>$pm_type_obj->pretty_name(),
222
-						'PMD_slug'=>$pm_type_obj->system_name(),//automatically converted to slug
222
+						'PMD_slug'=>$pm_type_obj->system_name(), //automatically converted to slug
223 223
 						'PMD_wp_user'=>$current_user->ID,
224 224
 					));
225 225
 				}
226 226
 				$payment_method->set_active();
227
-				$payment_method->set_description( $pm_type_obj->default_description() );
227
+				$payment_method->set_description($pm_type_obj->default_description());
228 228
 				//handles the goofy case where someone activates the invoice gateway which is also
229 229
 				$payment_method->set_type($pm_type_obj->system_name());
230
-				if( ! $payment_method->button_url() ){
231
-					$payment_method->set_button_url( $pm_type_obj->default_button_url() );
230
+				if ( ! $payment_method->button_url()) {
231
+					$payment_method->set_button_url($pm_type_obj->default_button_url());
232 232
 				}
233 233
 				$payment_method->save();
234
-				foreach($payment_method->get_all_usable_currencies() as $currency_obj){
234
+				foreach ($payment_method->get_all_usable_currencies() as $currency_obj) {
235 235
 					$payment_method->_add_relation_to($currency_obj, 'Currency');
236 236
 				}
237 237
 				//now add setup its default extra meta properties
238 238
 				$extra_metas = $payment_method->type_obj()->settings_form()->extra_meta_inputs();
239
-				foreach( $extra_metas as $meta_name => $input ){
240
-					$payment_method->update_extra_meta($meta_name, $input->raw_value() );
239
+				foreach ($extra_metas as $meta_name => $input) {
240
+					$payment_method->update_extra_meta($meta_name, $input->raw_value());
241 241
 				}
242 242
 			}
243 243
 
244
-		}else{
244
+		} else {
245 245
 			$payment_method->set_active();
246 246
 			$payment_method->save();
247 247
 		}
248
-		if( $payment_method->type() == 'Invoice' ){
249
-			$messages = EE_Registry::instance()->load_lib( 'messages' );
250
-			$messages->ensure_message_type_is_active( 'invoice', 'html' );
251
-			$messages->ensure_messenger_is_active( 'pdf' );
252
-			EE_Error::add_attention( sprintf( __( 'Note, when the invoice payment method is activated, the invoice message type, html messenger, and pdf messenger are activated as well for the %1$smessages system%2$s.', 'event_espresso' ), '<a href="' . admin_url( 'admin.php?page=espresso_messages') . '">', '</a>' ) );
248
+		if ($payment_method->type() == 'Invoice') {
249
+			$messages = EE_Registry::instance()->load_lib('messages');
250
+			$messages->ensure_message_type_is_active('invoice', 'html');
251
+			$messages->ensure_messenger_is_active('pdf');
252
+			EE_Error::add_attention(sprintf(__('Note, when the invoice payment method is activated, the invoice message type, html messenger, and pdf messenger are activated as well for the %1$smessages system%2$s.', 'event_espresso'), '<a href="'.admin_url('admin.php?page=espresso_messages').'">', '</a>'));
253 253
 		}
254 254
 		return $payment_method;
255 255
 	}
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
 	 *
265 265
 	 * @return int count of rows updated.
266 266
 	 */
267
-	public function deactivate_payment_method( $payment_method_slug ) {
268
-		$count_updated = EEM_Payment_Method::instance()->update(array('PMD_scope'=>array()),array(array('PMD_slug'=>$payment_method_slug)));
267
+	public function deactivate_payment_method($payment_method_slug) {
268
+		$count_updated = EEM_Payment_Method::instance()->update(array('PMD_scope'=>array()), array(array('PMD_slug'=>$payment_method_slug)));
269 269
 		return $count_updated;
270 270
 	}
271 271
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 *
279 279
 	 * @param array $caps capabilities being filtered
280 280
 	 */
281
-	public function add_payment_method_caps( $caps ) {
281
+	public function add_payment_method_caps($caps) {
282 282
 		/* add dynamic caps from payment methods
283 283
 		 * at the time of writing, october 20 2014, these are the caps added:
284 284
 		 * ee_payment_method_admin_only
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 		 * their related capability automatically added too, so long as they are
294 294
 		 * registered properly using EE_Register_Payment_Method::register()
295 295
 		 */
296
-		foreach( $this->payment_method_types() as $payment_method_type_obj ){
296
+		foreach ($this->payment_method_types() as $payment_method_type_obj) {
297 297
 			$caps['administrator'][] = $payment_method_type_obj->cap_name();
298 298
 		}
299 299
 		return $caps;
Please login to merge, or discard this patch.
libraries/payment_methods/templates/payment_details_content.template.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,10 +2,10 @@
 block discarded – undo
2 2
 if (!defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('No direct script access allowed');
4 4
 /**
5
- * payment_details_content
6
- * @var EE_Payment $payment
7
- * @var EE_Payment_Method $payment_method
8
- */
5
+	 * payment_details_content
6
+	 * @var EE_Payment $payment
7
+	 * @var EE_Payment_Method $payment_method
8
+	 */
9 9
 $gateway_response = $payment->gateway_response();
10 10
 if ( ! empty( $gateway_response )) {
11 11
 	echo '<span class="error payment-problem">' . $gateway_response . '</span>';
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION'))
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('No direct script access allowed');
4 4
 /**
5 5
  * payment_details_content
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @var EE_Payment_Method $payment_method
8 8
  */
9 9
 $gateway_response = $payment->gateway_response();
10
-if ( ! empty( $gateway_response )) {
11
-	echo '<span class="error payment-problem">' . $gateway_response . '</span>';
10
+if ( ! empty($gateway_response)) {
11
+	echo '<span class="error payment-problem">'.$gateway_response.'</span>';
12 12
 }
13 13
 // End of file payment_details_content.template.php
14 14
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION'))
2
+if (!defined('EVENT_ESPRESSO_VERSION')) {
3 3
 	exit('No direct script access allowed');
4
+}
4 5
 /**
5 6
  * payment_details_content
6 7
  * @var EE_Payment $payment
Please login to merge, or discard this patch.
core/libraries/plugin_api/EEI_Plugin_API.lib.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @param array  $setup_args  an array of key value pairs of info for registering the component
35 35
 	 * @return void
36 36
 	 */
37
-	public static function register( $ID = NULL, $setup_args = array() );
37
+	public static function register($ID = NULL, $setup_args = array());
38 38
 
39 39
 
40 40
 
@@ -45,5 +45,5 @@  discard block
 block discarded – undo
45 45
 	 * @param string $ID a unique name or ID for the component being registered
46 46
 	 * @return void
47 47
 	 */
48
-	public static function deregister( $ID = NULL );
48
+	public static function deregister($ID = NULL);
49 49
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@
 block discarded – undo
5 5
  * @subpackage helpers
6 6
  * @since           4.3.0
7 7
  */
8
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
8
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
+	exit('No direct script access allowed');
10
+}
9 11
 
10 12
 /**
11 13
  * This interface is used to define the common methods shared by all "plugin api" classes.
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Admin_Page.lib.php 3 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -18,30 +18,30 @@  discard block
 block discarded – undo
18 18
 class EE_Register_Admin_Page implements EEI_Plugin_API {
19 19
 
20 20
 
21
-    /**
22
-     * Holds registered EE_Admin_Pages
23
-     * @var array
24
-     */
25
-    protected static $_ee_admin_page_registry = array();
21
+	/**
22
+	 * Holds registered EE_Admin_Pages
23
+	 * @var array
24
+	 */
25
+	protected static $_ee_admin_page_registry = array();
26 26
 
27 27
 
28 28
 
29 29
 
30
-    /**
31
-     * The purpose of this method is to provide an easy way for addons to register their admin pages (using the EE Admin Page loader system).
32
-     *
33
-     * @since 4.3.0
34
-     *
30
+	/**
31
+	 * The purpose of this method is to provide an easy way for addons to register their admin pages (using the EE Admin Page loader system).
32
+	 *
33
+	 * @since 4.3.0
34
+	 *
35 35
 	 * @param  string $page_basename 	This string represents the basename of the Admin Page init.
36 36
 	 *                                                        		The init file must use this basename in its name and class (i.e. {page_basename}_Admin_Page_Init.core.php).
37
-     * @param  array  $config  {              An array of configuration options that will be used in different circumstances
37
+	 * @param  array  $config  {              An array of configuration options that will be used in different circumstances
38 38
 	 *
39 39
 	 *		@type  string $page_path             This is the path where the registered admin pages reside ( used to setup autoloaders).
40 40
 	 *
41 41
 	 * 	}
42
-     * @return void
43
-     */
44
-    public static function register( $page_basename = NULL, $config = array() ) {
42
+	 * @return void
43
+	 */
44
+	public static function register( $page_basename = NULL, $config = array() ) {
45 45
 
46 46
 		// check that an admin_page has not already been registered with that name
47 47
 		if ( isset(self::$_ee_admin_page_registry[ $page_basename ] )) {
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		}
60 60
 
61 61
 		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_Admin__loaded' )) {
62
-            EE_Error::doing_it_wrong(
62
+			EE_Error::doing_it_wrong(
63 63
 				__METHOD__,
64 64
 				sprintf(
65 65
 					__('An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time.  Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.','event_espresso'),
@@ -67,36 +67,36 @@  discard block
 block discarded – undo
67 67
 				),
68 68
 				'4.3'
69 69
 			);
70
-        }
70
+		}
71 71
 
72
-        //add incoming stuff to our registry property
73
-        self::$_ee_admin_page_registry[ $page_basename ] = array(
74
-            'page_path' => $config['page_path'],
75
-            'config' => $config
76
-            );
72
+		//add incoming stuff to our registry property
73
+		self::$_ee_admin_page_registry[ $page_basename ] = array(
74
+			'page_path' => $config['page_path'],
75
+			'config' => $config
76
+			);
77 77
 
78
-       //add filters
78
+	   //add filters
79 79
 
80
-       add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array( 'EE_Register_Admin_Page', 'set_page_basename' ), 10 );
81
-       add_filter('FHEE__EEH_Autoloader__load_admin_core', array( 'EE_Register_Admin_Page', 'set_page_path' ), 10 );
80
+	   add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array( 'EE_Register_Admin_Page', 'set_page_basename' ), 10 );
81
+	   add_filter('FHEE__EEH_Autoloader__load_admin_core', array( 'EE_Register_Admin_Page', 'set_page_path' ), 10 );
82 82
 
83
-    }
83
+	}
84 84
 
85 85
 
86 86
 
87
-    /**
88
-     * This deregisters a EE_Admin page that is already registered.  Note, this MUST be loaded after the
89
-     * page being deregistered is loaded.
90
-     *
91
-     * @since    4.3.0
92
-     *
93
-     * @param  string $page_basename Use whatever string was used to register the admin page.
94
-     * @return  void
95
-     */
96
-    public static function deregister( $page_basename = NULL ) {
97
-    	if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) )
98
-    		unset( self::$_ee_admin_page_registry[$page_basename] );
99
-    }
87
+	/**
88
+	 * This deregisters a EE_Admin page that is already registered.  Note, this MUST be loaded after the
89
+	 * page being deregistered is loaded.
90
+	 *
91
+	 * @since    4.3.0
92
+	 *
93
+	 * @param  string $page_basename Use whatever string was used to register the admin page.
94
+	 * @return  void
95
+	 */
96
+	public static function deregister( $page_basename = NULL ) {
97
+		if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) )
98
+			unset( self::$_ee_admin_page_registry[$page_basename] );
99
+	}
100 100
 
101 101
 
102 102
 
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 				$installed_refs[ $basename ] = $args['page_path'];
113 113
 			}
114 114
 		}
115
-        return $installed_refs;
116
-    }
115
+		return $installed_refs;
116
+	}
117 117
 
118 118
 
119 119
 
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 	 * @return mixed
125 125
 	 */
126 126
 	public static function set_page_path( $paths ) {
127
-        foreach ( self::$_ee_admin_page_registry as $basename => $args ) {
128
-            $paths[ $basename ] = $args['page_path'];
129
-        }
130
-        return $paths;
131
-    }
127
+		foreach ( self::$_ee_admin_page_registry as $basename => $args ) {
128
+			$paths[ $basename ] = $args['page_path'];
129
+		}
130
+		return $paths;
131
+	}
132 132
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -41,28 +41,28 @@  discard block
 block discarded – undo
41 41
 	 * 	}
42 42
      * @return void
43 43
      */
44
-    public static function register( $page_basename = NULL, $config = array() ) {
44
+    public static function register($page_basename = NULL, $config = array()) {
45 45
 
46 46
 		// check that an admin_page has not already been registered with that name
47
-		if ( isset(self::$_ee_admin_page_registry[ $page_basename ] )) {
48
-			throw new EE_Error( sprintf( __( 'An Admin Page with the name "%s" has already been registered and each Admin Page requires a unique name.', 'event_espresso' ), $page_basename ));
47
+		if (isset(self::$_ee_admin_page_registry[$page_basename])) {
48
+			throw new EE_Error(sprintf(__('An Admin Page with the name "%s" has already been registered and each Admin Page requires a unique name.', 'event_espresso'), $page_basename));
49 49
 		}
50 50
 
51 51
 		// required fields MUST be present, so let's make sure they are.
52
-		if ( empty( $page_basename ) || ! is_array( $config ) || empty( $config['page_path'] )) {
53
-			throw new EE_Error( __( 'In order to register an Admin Page with EE_Register_Admin_Page::register(), you must include the "page_basename" (the class name of the page), and an array containing the following keys: "page_path" (the path where the registered admin pages reside)', 'event_espresso' ));
52
+		if (empty($page_basename) || ! is_array($config) || empty($config['page_path'])) {
53
+			throw new EE_Error(__('In order to register an Admin Page with EE_Register_Admin_Page::register(), you must include the "page_basename" (the class name of the page), and an array containing the following keys: "page_path" (the path where the registered admin pages reside)', 'event_espresso'));
54 54
 		}
55 55
 
56 56
 		//make sure we don't register twice
57
-		if( isset( self::$_ee_admin_page_registry[ $page_basename ] ) ){
57
+		if (isset(self::$_ee_admin_page_registry[$page_basename])) {
58 58
 			return;
59 59
 		}
60 60
 
61
-		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_Admin__loaded' )) {
61
+		if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
62 62
             EE_Error::doing_it_wrong(
63 63
 				__METHOD__,
64 64
 				sprintf(
65
-					__('An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time.  Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.','event_espresso'),
65
+					__('An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time.  Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.', 'event_espresso'),
66 66
 					$page_basename
67 67
 				),
68 68
 				'4.3'
@@ -70,15 +70,15 @@  discard block
 block discarded – undo
70 70
         }
71 71
 
72 72
         //add incoming stuff to our registry property
73
-        self::$_ee_admin_page_registry[ $page_basename ] = array(
73
+        self::$_ee_admin_page_registry[$page_basename] = array(
74 74
             'page_path' => $config['page_path'],
75 75
             'config' => $config
76 76
             );
77 77
 
78 78
        //add filters
79 79
 
80
-       add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array( 'EE_Register_Admin_Page', 'set_page_basename' ), 10 );
81
-       add_filter('FHEE__EEH_Autoloader__load_admin_core', array( 'EE_Register_Admin_Page', 'set_page_path' ), 10 );
80
+       add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array('EE_Register_Admin_Page', 'set_page_basename'), 10);
81
+       add_filter('FHEE__EEH_Autoloader__load_admin_core', array('EE_Register_Admin_Page', 'set_page_path'), 10);
82 82
 
83 83
     }
84 84
 
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
      * @param  string $page_basename Use whatever string was used to register the admin page.
94 94
      * @return  void
95 95
      */
96
-    public static function deregister( $page_basename = NULL ) {
97
-    	if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) )
98
-    		unset( self::$_ee_admin_page_registry[$page_basename] );
96
+    public static function deregister($page_basename = NULL) {
97
+    	if ( ! empty(self::$_ee_admin_page_registry[$page_basename]))
98
+    		unset(self::$_ee_admin_page_registry[$page_basename]);
99 99
     }
100 100
 
101 101
 
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
 	 * @param $installed_refs
107 107
 	 * @return mixed
108 108
 	 */
109
-	public static function set_page_basename( $installed_refs ) {
110
-		if ( ! empty( self::$_ee_admin_page_registry )) {
111
-			foreach ( self::$_ee_admin_page_registry as $basename => $args ) {
112
-				$installed_refs[ $basename ] = $args['page_path'];
109
+	public static function set_page_basename($installed_refs) {
110
+		if ( ! empty(self::$_ee_admin_page_registry)) {
111
+			foreach (self::$_ee_admin_page_registry as $basename => $args) {
112
+				$installed_refs[$basename] = $args['page_path'];
113 113
 			}
114 114
 		}
115 115
         return $installed_refs;
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
 	 * @param $paths
124 124
 	 * @return mixed
125 125
 	 */
126
-	public static function set_page_path( $paths ) {
127
-        foreach ( self::$_ee_admin_page_registry as $basename => $args ) {
128
-            $paths[ $basename ] = $args['page_path'];
126
+	public static function set_page_path($paths) {
127
+        foreach (self::$_ee_admin_page_registry as $basename => $args) {
128
+            $paths[$basename] = $args['page_path'];
129 129
         }
130 130
         return $paths;
131 131
     }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@  discard block
 block discarded – undo
5 5
  * @subpackage helpers
6 6
  * @since           4.3.0
7 7
  */
8
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
8
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
+	exit('No direct script access allowed');
10
+}
9 11
 
10 12
 /**
11 13
  * Use this to register or deregister an EE Admin Page.
@@ -94,8 +96,9 @@  discard block
 block discarded – undo
94 96
      * @return  void
95 97
      */
96 98
     public static function deregister( $page_basename = NULL ) {
97
-    	if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) )
98
-    		unset( self::$_ee_admin_page_registry[$page_basename] );
99
+    	if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) ) {
100
+    	    		unset( self::$_ee_admin_page_registry[$page_basename] );
101
+    	}
99 102
     }
100 103
 
101 104
 
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_CPT.lib.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -66,33 +66,33 @@  discard block
 block discarded – undo
66 66
 	 * @throws  EE_Error
67 67
 	 * @return void
68 68
 	 */
69
-	public static function register( $cpt_ref = NULL, $setup_args = array() ) {
69
+	public static function register($cpt_ref = NULL, $setup_args = array()) {
70 70
 
71 71
 		//check for requred params
72
-		if ( empty( $cpt_ref ) ) {
72
+		if (empty($cpt_ref)) {
73 73
 			throw new EE_Error(
74
-				__('In order to register custom post types and custom taxonomies, you must include a value to reference what had been registered', 'event_espresso' )
74
+				__('In order to register custom post types and custom taxonomies, you must include a value to reference what had been registered', 'event_espresso')
75 75
 				);
76 76
 		}
77 77
 
78
-		if ( ! is_array( $setup_args ) || ( empty( $setup_args['cpts'] ) && empty( $setup_args['cts'] ) ) ) {
78
+		if ( ! is_array($setup_args) || (empty($setup_args['cpts']) && empty($setup_args['cts']))) {
79 79
 			throw new EE_Error(
80
-				__( 'In order to register custom post types or custom taxonomies, you must include an array containing either an array of custom post types to register (key "cpts"), an array of custom taxonomies ("cts") or both.', 'event_espresso' )
80
+				__('In order to register custom post types or custom taxonomies, you must include an array containing either an array of custom post types to register (key "cpts"), an array of custom taxonomies ("cts") or both.', 'event_espresso')
81 81
 				);
82 82
 		}
83 83
 
84 84
 		//make sure we don't register twice
85
-		if( isset( self::$_registry[ $cpt_ref ] ) ){
85
+		if (isset(self::$_registry[$cpt_ref])) {
86 86
 			return;
87 87
 		}
88 88
 
89 89
 		//make sure cpt ref is unique.
90
-		if ( isset( self::$_registry[$cpt_ref] ) ) {
91
-			$cpt_ref = uniqid() . '_' . $cpt_ref;
90
+		if (isset(self::$_registry[$cpt_ref])) {
91
+			$cpt_ref = uniqid().'_'.$cpt_ref;
92 92
 		}
93 93
 
94 94
 		//make sure this was called in the right place!
95
-		if ( did_action( 'AHEE__EE_System__load_CPTs_and_session__complete' ) ) {
95
+		if (did_action('AHEE__EE_System__load_CPTs_and_session__complete')) {
96 96
 			EE_Error::doing_it_wrong(
97 97
 				__METHOD__,
98 98
 				sprintf(
@@ -105,17 +105,17 @@  discard block
 block discarded – undo
105 105
 
106 106
 		//validate incoming args
107 107
 		$validated = array(
108
-			'cpts' => isset( $setup_args['cpts'] ) ? (array) $setup_args['cpts'] : array(),
109
-			'cts' => isset( $setup_args['cts'] ) ? (array) $setup_args['cts'] : array(),
110
-			'default_terms' => isset( $setup_args['default_terms'] ) ? (array) $setup_args['default_terms'] : array()
108
+			'cpts' => isset($setup_args['cpts']) ? (array) $setup_args['cpts'] : array(),
109
+			'cts' => isset($setup_args['cts']) ? (array) $setup_args['cts'] : array(),
110
+			'default_terms' => isset($setup_args['default_terms']) ? (array) $setup_args['default_terms'] : array()
111 111
 			);
112 112
 
113 113
 		self::$_registry[$cpt_ref] = $validated;
114 114
 
115 115
 		//hook into to cpt system
116
-		add_filter( 'FHEE__EE_Register_CPTs__get_CPTs__cpts', array( __CLASS__, 'filter_cpts' ), 5 );
117
-		add_filter( 'FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array( __CLASS__, 'filter_cts' ), 5 );
118
-		add_action( 'AHEE__EE_Register_CPTs__construct_end', array( __CLASS__, 'default_terms'), 5 );
116
+		add_filter('FHEE__EE_Register_CPTs__get_CPTs__cpts', array(__CLASS__, 'filter_cpts'), 5);
117
+		add_filter('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array(__CLASS__, 'filter_cts'), 5);
118
+		add_action('AHEE__EE_Register_CPTs__construct_end', array(__CLASS__, 'default_terms'), 5);
119 119
 	}
120 120
 
121 121
 
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @return array new array of cpts and their registration information
131 131
 	 */
132
-	public static function filter_cpts( $cpts ) {
133
-		foreach( self::$_registry as  $registries ) {
134
-			foreach ( $registries['cpts'] as $cpt_name => $cpt_settings ) {
132
+	public static function filter_cpts($cpts) {
133
+		foreach (self::$_registry as  $registries) {
134
+			foreach ($registries['cpts'] as $cpt_name => $cpt_settings) {
135 135
 				$cpts[$cpt_name] = $cpt_settings;
136 136
 			}
137 137
 		}
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return array new array of cts and their registration information.
150 150
 	 */
151
-	public static function filter_cts( $cts ) {
152
-		foreach( self::$_registry as $registries ) {
153
-			foreach( $registries['cts'] as $ct_name => $ct_settings ) {
151
+	public static function filter_cts($cts) {
152
+		foreach (self::$_registry as $registries) {
153
+			foreach ($registries['cts'] as $ct_name => $ct_settings) {
154 154
 				$cts[$ct_name] = $ct_settings;
155 155
 			}
156 156
 		}
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @return void
169 169
 	 */
170
-	public static function default_terms( EE_Register_CPTs $cpt_class ) {
171
-		foreach( self::$_registry as $registries ) {
172
-			foreach( $registries['default_terms'] as $taxonomy => $terms ) {
173
-				foreach ( $terms as $term => $cpts ) {
174
-					$cpt_class->set_default_term( $taxonomy, $term, $cpts );
170
+	public static function default_terms(EE_Register_CPTs $cpt_class) {
171
+		foreach (self::$_registry as $registries) {
172
+			foreach ($registries['default_terms'] as $taxonomy => $terms) {
173
+				foreach ($terms as $term => $cpts) {
174
+					$cpt_class->set_default_term($taxonomy, $term, $cpts);
175 175
 				}
176 176
 			}
177 177
 		}
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @return void
190 190
 	 */
191
-	public static function deregister( $cpt_ref = null ) {
192
-		if ( !empty( self::$_registry[$cpt_ref] ) ) {
193
-			unset( self::$_registry[$cpt_ref] );
191
+	public static function deregister($cpt_ref = null) {
192
+		if ( ! empty(self::$_registry[$cpt_ref])) {
193
+			unset(self::$_registry[$cpt_ref]);
194 194
 		}
195 195
 	}
196 196
 } //end class EE_Register_CPT
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@
 block discarded – undo
5 5
  * @subpackage plugin api, custom post type, custom taxonomy
6 6
  * @since           4.5.0
7 7
  */
8
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
8
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
+	exit('No direct script access allowed');
10
+}
9 11
 
10 12
 /**
11 13
  * Use this to register or deregister a new custom post type or custom taxonomy for the EE CPT system.
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Config.lib.php 3 patches
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@  discard block
 block discarded – undo
5 5
  * @subpackage helpers
6 6
  * @since           4.3.0
7 7
  */
8
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
8
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
+	exit('No direct script access allowed');
10
+}
9 11
 
10 12
 /**
11 13
  * Use this to register or deregister a new config with the EE_Registry::instance->CFG property.
@@ -111,7 +113,8 @@  discard block
 block discarded – undo
111 113
 	 * @param mixed $config_class_name
112 114
 	 */
113 115
 	public static function deregister( $config_class_name = NULL ) {
114
-		if ( ! empty( self::$_ee_config_registry[ $config_class_name ] ))
115
-    			unset( self::$_ee_config_registry[ $config_class_name ] );
116
+		if ( ! empty( self::$_ee_config_registry[ $config_class_name ] )) {
117
+		    			unset( self::$_ee_config_registry[ $config_class_name ] );
118
+		}
116 119
 	}
117 120
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -42,24 +42,24 @@  discard block
 block discarded – undo
42 42
 	 *                       		}
43 43
 	 * @return void
44 44
 	 */
45
-	public static function register( $config_class = NULL, $setup_args = array() ) {
45
+	public static function register($config_class = NULL, $setup_args = array()) {
46 46
 
47
-		$setup_args['config_name'] = isset( $setup_args['config_name'] ) && ! empty( $setup_args['config_name'] ) ? $setup_args['config_name'] : $config_class;
48
-		$setup_args['config_section'] = isset( $setup_args['config_section'] ) && ! empty( $setup_args['config_section'] ) ? $setup_args['config_section'] : 'addons';
47
+		$setup_args['config_name'] = isset($setup_args['config_name']) && ! empty($setup_args['config_name']) ? $setup_args['config_name'] : $config_class;
48
+		$setup_args['config_section'] = isset($setup_args['config_section']) && ! empty($setup_args['config_section']) ? $setup_args['config_section'] : 'addons';
49 49
 
50 50
 		//required fields MUST be present, so let's make sure they are.
51
-		if ( empty( $config_class ) || ! is_array( $setup_args ) || empty( $setup_args['config_name'] )) {
52
-			throw new EE_Error( __( 'In order to register a Config Class with EE_Register_Config::register(), you must include a "config_class" (the actual class name for this config class). As well, you can supply an array containing the following keys: "config_section" the main section of the config object the settings will be saved under (by default the new config will be registered under EE_Config::instance()->modules or EE_Config::instance()->addons depending on what type of class is calling this), "config_name" (by default the new config will be registered to EE_Config::instance()->{config_section}->{config_class}, but supplying a "config_name" will set the property name that this variable is accessible by. ie: EE_Config::instance()->{config_section}->{config_name})', 'event_espresso' ));
51
+		if (empty($config_class) || ! is_array($setup_args) || empty($setup_args['config_name'])) {
52
+			throw new EE_Error(__('In order to register a Config Class with EE_Register_Config::register(), you must include a "config_class" (the actual class name for this config class). As well, you can supply an array containing the following keys: "config_section" the main section of the config object the settings will be saved under (by default the new config will be registered under EE_Config::instance()->modules or EE_Config::instance()->addons depending on what type of class is calling this), "config_name" (by default the new config will be registered to EE_Config::instance()->{config_section}->{config_class}, but supplying a "config_name" will set the property name that this variable is accessible by. ie: EE_Config::instance()->{config_section}->{config_name})', 'event_espresso'));
53 53
 		}
54 54
 
55 55
 		//make sure we don't register twice
56
-		if( isset( self::$_ee_config_registry[ $config_class ] ) ){
56
+		if (isset(self::$_ee_config_registry[$config_class])) {
57 57
 			return;
58 58
 		}
59 59
 
60 60
 
61 61
 		//first find out if this happened too late.
62
-		if ( did_action( 'AHEE__EE_System__load_core_configuration__begin' ) ) {
62
+		if (did_action('AHEE__EE_System__load_core_configuration__begin')) {
63 63
 			EE_Error::doing_it_wrong(
64 64
 				__METHOD__,
65 65
 				sprintf(
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
 		}
72 72
 
73 73
 		//add incoming stuff to our registry property
74
-		self::$_ee_config_registry[ $config_class ] = array(
74
+		self::$_ee_config_registry[$config_class] = array(
75 75
 			'section' => $setup_args['config_section'],
76 76
 			'name' => $setup_args['config_name']
77 77
 		);
78 78
 
79
-		add_filter( 'AHEE__EE_Config___load_core_config__end', array( 'EE_Register_Config', 'set_config' ), 10 );
79
+		add_filter('AHEE__EE_Config___load_core_config__end', array('EE_Register_Config', 'set_config'), 10);
80 80
 	}
81 81
 
82 82
 
@@ -90,18 +90,18 @@  discard block
 block discarded – undo
90 90
 	 * @param \EE_Config $EE_Config
91 91
 	 * @return \StdClass
92 92
 	 */
93
-	public static function set_config( EE_Config $EE_Config ) {
94
-		foreach ( self::$_ee_config_registry as $config_class => $settings ) {
93
+	public static function set_config(EE_Config $EE_Config) {
94
+		foreach (self::$_ee_config_registry as $config_class => $settings) {
95 95
 			//first some validation of our incoming class_name.  We'll throw an error early if its' not registered correctly
96
-			if ( ! class_exists( $config_class ) ) {
96
+			if ( ! class_exists($config_class)) {
97 97
 				throw new EE_Error(
98 98
 					sprintf(
99
-						__( 'The "%s" config class can not be registered with EE_Config because it does not exist.  Verify that an autoloader has been set for this class', 'event_espresso' ),
99
+						__('The "%s" config class can not be registered with EE_Config because it does not exist.  Verify that an autoloader has been set for this class', 'event_espresso'),
100 100
 						$config_class
101 101
 					)
102 102
 				 );
103 103
 			}
104
-			$EE_Config->get_config( $settings['section'], $settings['name'], $config_class );
104
+			$EE_Config->get_config($settings['section'], $settings['name'], $config_class);
105 105
 		}
106 106
 	}
107 107
 
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 	/**
112 112
 	 * @param mixed $config_class_name
113 113
 	 */
114
-	public static function deregister( $config_class_name = NULL ) {
115
-		if ( ! empty( self::$_ee_config_registry[ $config_class_name ] ))
116
-    			unset( self::$_ee_config_registry[ $config_class_name ] );
114
+	public static function deregister($config_class_name = NULL) {
115
+		if ( ! empty(self::$_ee_config_registry[$config_class_name]))
116
+    			unset(self::$_ee_config_registry[$config_class_name]);
117 117
 	}
118 118
 }
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -113,6 +113,6 @@
 block discarded – undo
113 113
 	 */
114 114
 	public static function deregister( $config_class_name = NULL ) {
115 115
 		if ( ! empty( self::$_ee_config_registry[ $config_class_name ] ))
116
-    			unset( self::$_ee_config_registry[ $config_class_name ] );
116
+				unset( self::$_ee_config_registry[ $config_class_name ] );
117 117
 	}
118 118
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Data_Migration_Scripts.lib.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -45,32 +45,32 @@  discard block
 block discarded – undo
45 45
 	 * @throws EE_Error
46 46
 	 * @return void
47 47
 	 */
48
-	public static function register( $dms_id = NULL, $setup_args = array()  ) {
48
+	public static function register($dms_id = NULL, $setup_args = array()) {
49 49
 
50 50
 		//required fields MUST be present, so let's make sure they are.
51
-		if ( empty( $dms_id ) || ! is_array( $setup_args ) || empty( $setup_args['dms_paths'] )) {
52
-			throw new EE_Error( __( 'In order to register Data Migration Scripts with EE_Register_Data_Migration_Scripts::register(), you must include a "dms_id" (a unique identifier for this set of data migration scripts), and  an array containing the following keys: "dms_paths" (an array of full server paths to folders that contain data migration scripts)', 'event_espresso' ));
51
+		if (empty($dms_id) || ! is_array($setup_args) || empty($setup_args['dms_paths'])) {
52
+			throw new EE_Error(__('In order to register Data Migration Scripts with EE_Register_Data_Migration_Scripts::register(), you must include a "dms_id" (a unique identifier for this set of data migration scripts), and  an array containing the following keys: "dms_paths" (an array of full server paths to folders that contain data migration scripts)', 'event_espresso'));
53 53
 		}
54 54
 
55 55
 		//make sure we don't register twice
56
-		if( isset( self::$_settings[ $dms_id ] ) ){
56
+		if (isset(self::$_settings[$dms_id])) {
57 57
 			return;
58 58
 		}
59 59
 
60 60
 		//make sure this was called in the right place!
61
-		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_System___detect_if_activation_or_upgrade__begin' )) {
61
+		if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')) {
62 62
 			EE_Error::doing_it_wrong(
63 63
 				__METHOD__,
64
-					__( 'An attempt to register Data Migration Scripts has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register Data Migration Scripts.','event_espresso'),
64
+					__('An attempt to register Data Migration Scripts has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register Data Migration Scripts.', 'event_espresso'),
65 65
 				'4.3.0'
66 66
 			);
67 67
 		}
68 68
 		//setup $_settings array from incoming values.
69
-		self::$_settings[ $dms_id ] = array(
70
-			'dms_paths' =>isset( $setup_args['dms_paths'] ) ? (array)$setup_args['dms_paths'] : array()
69
+		self::$_settings[$dms_id] = array(
70
+			'dms_paths' =>isset($setup_args['dms_paths']) ? (array) $setup_args['dms_paths'] : array()
71 71
 		);
72 72
 		// setup DMS
73
-		add_filter( 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', array( 'EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders' ));
73
+		add_filter('FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', array('EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders'));
74 74
 	}
75 75
 
76 76
 
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 	 * @param array $dms_paths
81 81
 	 * @return array
82 82
 	 */
83
-	public static function add_data_migration_script_folders( $dms_paths = array() ){
84
-		foreach( self::$_settings as $settings ) {
85
-			$dms_paths = array_merge( $dms_paths, $settings['dms_paths'] );
83
+	public static function add_data_migration_script_folders($dms_paths = array()) {
84
+		foreach (self::$_settings as $settings) {
85
+			$dms_paths = array_merge($dms_paths, $settings['dms_paths']);
86 86
 		}
87 87
 		return $dms_paths;
88 88
 	}
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 	 * @param mixed $dms_id  unique identifier for the set of Data Migration Scripts that were previously registered
98 98
 	 * @return void
99 99
 	 */
100
-	public static function deregister( $dms_id = NULL ) {
101
-		if ( isset( self::$_settings[ $dms_id ] )) {
102
-			unset( self::$_settings[ $dms_id ] );
100
+	public static function deregister($dms_id = NULL) {
101
+		if (isset(self::$_settings[$dms_id])) {
102
+			unset(self::$_settings[$dms_id]);
103 103
 		}
104 104
 	}
105 105
 
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Message_Type.lib.php 3 patches
Indentation   +217 added lines, -217 removed lines patch added patch discarded remove patch
@@ -18,58 +18,58 @@  discard block
 block discarded – undo
18 18
 class EE_Register_Message_Type implements EEI_Plugin_API {
19 19
 
20 20
 
21
-    /**
22
-     * Holds values for registered message types
23
-     * @var array
24
-     */
25
-    protected static $_ee_message_type_registry = array();
26
-
27
-
28
-    /**
29
-     * Method for registering new message types in the EE_messages system.
30
-     *
31
-     * Note:  All message types must have the following files in order to work:
32
-     *
33
-     * - Template files for default templates getting setup.  See /core/libraries/messages/defaults/default/ for examples (note that template files match a specific naming schema).  These templates will need to be registered with the default template pack.
34
-     * - EE_Messages_Validator extended class(es).  See /core/libraries/messages/validators/email/
35
-     *      for examples.  Note for any new message types, there will need to be a validator for each
36
-     *      messenger combo this message type can activate with.
37
-     * - And of course the main EE_{Message_Type_Name}_message_type class that defines the new
38
-     *      message type and its properties.
39
-     *
40
-     * @since   4.3.0
41
-     *
21
+	/**
22
+	 * Holds values for registered message types
23
+	 * @var array
24
+	 */
25
+	protected static $_ee_message_type_registry = array();
26
+
27
+
28
+	/**
29
+	 * Method for registering new message types in the EE_messages system.
30
+	 *
31
+	 * Note:  All message types must have the following files in order to work:
32
+	 *
33
+	 * - Template files for default templates getting setup.  See /core/libraries/messages/defaults/default/ for examples (note that template files match a specific naming schema).  These templates will need to be registered with the default template pack.
34
+	 * - EE_Messages_Validator extended class(es).  See /core/libraries/messages/validators/email/
35
+	 *      for examples.  Note for any new message types, there will need to be a validator for each
36
+	 *      messenger combo this message type can activate with.
37
+	 * - And of course the main EE_{Message_Type_Name}_message_type class that defines the new
38
+	 *      message type and its properties.
39
+	 *
40
+	 * @since   4.3.0
41
+	 *
42 42
 	 * 	@param string $mt_name                               Whatever is defined for the $name property of
43 43
 	 *                                                                          the message type you are registering (eg.
44 44
 	 *                                                                          declined_registration). Required.
45
-     * @param  array  $setup_args  {
46
-     *        An array of arguments provided for registering the message type.
47
-     *
48
-     *        @type string $mtfilename                          The filename of the message type being
49
-     *                                                                          registered.  This will be the main
50
-     *                                                                          EE_{Messagetype_Name}_message_type class. (
51
-     *                                                                          eg. EE_Declined_Registration_message_type.
52
-     *                                                                          class.php). Required.
53
-     *        @type array $autoloadpaths                       An array of paths to add to the messages
54
-     *                                                                          autoloader for the new message type. Required.
55
-     *        @type array $messengers_to_activate_with An array of messengers that this message
56
-     *                                                                          type should activate with. Each value in the
57
-     *                                                                          array should match the name property of a
58
-     *                                                                          EE_messenger. Optional.
59
-     *        @type array $messengers_to_validate_with An array of messengers that this message type is valid for.  Each
60
-     *                                                                          value in the array should match the name property of an
61
-     *                                                                          EE_messenger. Optional.
62
-     *        @type bool $force_activation                   This simply is a way of indicating that this message type MUST be *
63
-     *                                                                          activated when the plugin is activated/reactivated (default false)
64
-     *
65
-     * }
66
-     * @return void
67
-     */
68
-    public static function register( $mt_name = NULL, $setup_args = array() ) {
69
-
70
-        //required fields MUST be present, so let's make sure they are.
71
-        if ( ! isset( $mt_name ) || ! is_array( $setup_args ) || empty( $setup_args['mtfilename'] ) || empty( $setup_args['autoloadpaths'] ) )
72
-            throw new EE_Error(
45
+	 * @param  array  $setup_args  {
46
+	 *        An array of arguments provided for registering the message type.
47
+	 *
48
+	 *        @type string $mtfilename                          The filename of the message type being
49
+	 *                                                                          registered.  This will be the main
50
+	 *                                                                          EE_{Messagetype_Name}_message_type class. (
51
+	 *                                                                          eg. EE_Declined_Registration_message_type.
52
+	 *                                                                          class.php). Required.
53
+	 *        @type array $autoloadpaths                       An array of paths to add to the messages
54
+	 *                                                                          autoloader for the new message type. Required.
55
+	 *        @type array $messengers_to_activate_with An array of messengers that this message
56
+	 *                                                                          type should activate with. Each value in the
57
+	 *                                                                          array should match the name property of a
58
+	 *                                                                          EE_messenger. Optional.
59
+	 *        @type array $messengers_to_validate_with An array of messengers that this message type is valid for.  Each
60
+	 *                                                                          value in the array should match the name property of an
61
+	 *                                                                          EE_messenger. Optional.
62
+	 *        @type bool $force_activation                   This simply is a way of indicating that this message type MUST be *
63
+	 *                                                                          activated when the plugin is activated/reactivated (default false)
64
+	 *
65
+	 * }
66
+	 * @return void
67
+	 */
68
+	public static function register( $mt_name = NULL, $setup_args = array() ) {
69
+
70
+		//required fields MUST be present, so let's make sure they are.
71
+		if ( ! isset( $mt_name ) || ! is_array( $setup_args ) || empty( $setup_args['mtfilename'] ) || empty( $setup_args['autoloadpaths'] ) )
72
+			throw new EE_Error(
73 73
 				__( 'In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', 'event_espresso' )
74 74
 			);
75 75
 
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 			return;
79 79
 		}
80 80
 
81
-        //make sure this was called in the right place!
82
-        if ( ! did_action( 'EE_Brewing_Regular___messages_caf' ) || did_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' )) {
83
-            EE_Error::doing_it_wrong(
81
+		//make sure this was called in the right place!
82
+		if ( ! did_action( 'EE_Brewing_Regular___messages_caf' ) || did_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' )) {
83
+			EE_Error::doing_it_wrong(
84 84
 				__METHOD__,
85 85
 				sprintf(
86 86
 					__('A message type named "%s" has been attempted to be registered with the EE Messages System.  It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.','event_espresso'),
@@ -88,15 +88,15 @@  discard block
 block discarded – undo
88 88
 				),
89 89
 				'4.3.0'
90 90
 			);
91
-        }
91
+		}
92 92
 
93 93
 	//setup $__ee_message_type_registry array from incoming values.
94 94
 	self::$_ee_message_type_registry[ $mt_name ] = array(
95 95
 		'mtfilename' => (string) $setup_args['mtfilename'],
96 96
 		'autoloadpaths' => (array) $setup_args['autoloadpaths'],
97 97
 		'messengers_to_activate_with' => ! empty( $setup_args['messengers_to_activate_with'] ) ? (array) $setup_args['messengers_to_activate_with'] : array(),
98
-                        'messengers_to_validate_with' => ! empty( $setup_args['messengers_to_validate_with'] ) ? (array) $setup_args['messengers_to_validate_with'] : array(),
99
-                        'force_activation' => ! empty( $setup_args['force_activation'] ) ? (bool) $setup_args['force_activation'] : array()
98
+						'messengers_to_validate_with' => ! empty( $setup_args['messengers_to_validate_with'] ) ? (array) $setup_args['messengers_to_validate_with'] : array(),
99
+						'force_activation' => ! empty( $setup_args['force_activation'] ) ? (bool) $setup_args['force_activation'] : array()
100 100
 	);
101 101
 
102 102
 	//add filters
@@ -107,166 +107,166 @@  discard block
 block discarded – undo
107 107
 
108 108
 	//actions
109 109
 	add_action( 'AHEE__EE_Addon__initialize_default_data__begin', array( 'EE_Register_Message_Type', 'set_defaults' ) );
110
-    }
111
-
112
-
113
-
114
-    /**
115
-     * This just ensures that when an addon registers a message type that on initial activation/reactivation the defaults the addon sets are taken care of.
116
-     */
117
-    public static function set_defaults() {
118
-    	//only set defaults if we're not in EE_Maintenance mode
119
-    	EE_Registry::instance()->load_helper('Activation');
120
-    	EEH_Activation::generate_default_message_templates();
121
-
122
-            //for any message types with force activation, let's ensure they are activated
123
-            foreach ( self::$_ee_message_type_registry as $mtname => $settings ) {
124
-                if ( $settings['force_activation'] ) {
125
-                    $MSG = new EE_Messages();
126
-                    foreach ( $settings['messengers_to_activate_with'] as $messenger ) {
127
-                        $MSG->ensure_message_type_is_active( $mtname, $messenger );
128
-                    }
129
-                }
130
-            }
131
-    }
132
-
133
-
134
-
135
-    /**
136
-     * This deregisters a message type that was previously registered with a specific mtname.
137
-     *
138
-     * @since    4.3.0
139
-     *
140
-     * @param string  $mt_name the name for the message type that was previously registered
141
-     * @return void
142
-     */
143
-    public static function deregister( $mt_name = NULL ) {
144
-    	if ( !empty( self::$_ee_message_type_registry[$mt_name] ) ) {
145
-                        //let's make sure that we remove any place this message type was made active
146
-                        EE_Registry::instance()->load_helper( 'MSG_Template' );
147
-                        $active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
148
-                        foreach( $active_messengers as $messenger => $settings ) {
149
-                            if ( !empty( $settings['settings'][$messenger . '-message_types'][$mt_name] ) ) {
150
-                                unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt_name] );
151
-                            }
152
-                        }
153
-                        EEH_MSG_Template::update_to_inactive( '', $mt_name );
154
-                        EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
155
-    		unset( self::$_ee_message_type_registry[$mt_name] );
156
-        }
157
-    }
158
-
159
-
160
-
161
-    /**
162
-     * callback for FHEE__EE_messages__get_installed__messagetype_files filter.
163
-     *
164
-     * @since   4.3.0
165
-     *
166
-     * @param  array  $messagetype_files The current array of message type file names
167
-     * @return  array                                 Array of message type file names
168
-     */
169
-    public static function register_messagetype_files( $messagetype_files ) {
170
-        if ( empty( self::$_ee_message_type_registry ) )
171
-            return $messagetype_files;
172
-
173
-        foreach ( self::$_ee_message_type_registry as $mt_reg ) {
174
-            if ( empty( $mt_reg['mtfilename' ] ) )
175
-                continue;
176
-            $messagetype_files[] = $mt_reg['mtfilename'];
177
-        }
178
-
179
-        return $messagetype_files;
180
-    }
181
-
182
-
183
-
184
-
185
-
186
-    /**
187
-     * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter.
188
-     *
189
-     * @since    4.3.0
190
-     *
191
-     * @param array $paths array of paths to be checked by EE_messages autoloader.
192
-     * @return array
193
-     */
194
-    public static function register_msgs_autoload_paths( $paths  ) {
195
-
196
-        if ( ! empty( self::$_ee_message_type_registry ) ) {
197
-            foreach ( self::$_ee_message_type_registry as $mt_reg ) {
198
-                if ( empty( $mt_reg['autoloadpaths'] ) )
199
-                    continue;
200
-                $paths = array_merge( $paths, $mt_reg['autoloadpaths'] );
201
-            }
202
-        }
203
-
204
-        return $paths;
205
-    }
206
-
207
-
208
-
209
-
210
-
211
-    /**
212
-     * callback for FHEE__EE_messenger__get_default_message_types__default_types filter.
213
-     *
214
-     * @since   4.3.0
215
-     *
216
-     *
217
-     * @param  array                $default_types array of message types activated with messenger (
218
-     *                                                               corresponds to the $name property of message type)
219
-     * @param  EE_messenger $messenger      The EE_messenger the filter is called from.
220
-     * @return  array
221
-     */
222
-    public static function register_messengers_to_activate_mt_with( $default_types, EE_messenger $messenger ) {
223
-        if ( empty( self::$_ee_message_type_registry ) )
224
-            return $default_types;
225
-
226
-        foreach ( self::$_ee_message_type_registry as $mt_name => $mt_reg ) {
227
-            if ( empty( $mt_reg['messengers_to_activate_with'] ) || empty( $mt_reg['mtfilename'] ) )
228
-                continue;
229
-
230
-            //loop through each of the messengers and if it matches the loaded class then we add this message type to the
231
-            foreach ( $mt_reg['messengers_to_activate_with'] as $msgr ) {
232
-                if ( $messenger->name == $msgr ) {
233
-                    $default_types[] = $mt_name;
234
-                }
235
-            }
236
-        }
237
-
238
-        return $default_types;
239
-    }
240
-
241
-
242
-
243
-     /**
244
-     * callback for FHEE__EE_messenger__get_valid_message_types__default_types filter.
245
-     *
246
-     * @since   4.3.0
247
-     *
248
-     *
249
-     * @param  array                $valid_types     array of message types valid with messenger (
250
-     *                                                               corresponds to the $name property of message type)
251
-     * @param  EE_messenger $messenger      The EE_messenger the filter is called from.
252
-     * @return  array
253
-     */
254
-    public static function register_messengers_to_validate_mt_with( $valid_types, EE_messenger $messenger ) {
255
-        if ( empty( self::$_ee_message_type_registry ) )
256
-            return $valid_types;
257
-
258
-        foreach ( self::$_ee_message_type_registry as $mt_name => $mt_reg ) {
259
-            if ( empty( $mt_reg['messengers_to_validate_with'] ) || empty( $mt_reg['mtfilename'] ) )
260
-                continue;
261
-
262
-            //loop through each of the messengers and if it matches the loaded class then we add this message type to the
263
-            foreach ( $mt_reg['messengers_to_validate_with'] as $msgr ) {
264
-                if ( $messenger->name == $msgr ) {
265
-                    $valid_types[] = $mt_name;
266
-                }
267
-            }
268
-        }
269
-
270
-        return $valid_types;
271
-    }
110
+	}
111
+
112
+
113
+
114
+	/**
115
+	 * This just ensures that when an addon registers a message type that on initial activation/reactivation the defaults the addon sets are taken care of.
116
+	 */
117
+	public static function set_defaults() {
118
+		//only set defaults if we're not in EE_Maintenance mode
119
+		EE_Registry::instance()->load_helper('Activation');
120
+		EEH_Activation::generate_default_message_templates();
121
+
122
+			//for any message types with force activation, let's ensure they are activated
123
+			foreach ( self::$_ee_message_type_registry as $mtname => $settings ) {
124
+				if ( $settings['force_activation'] ) {
125
+					$MSG = new EE_Messages();
126
+					foreach ( $settings['messengers_to_activate_with'] as $messenger ) {
127
+						$MSG->ensure_message_type_is_active( $mtname, $messenger );
128
+					}
129
+				}
130
+			}
131
+	}
132
+
133
+
134
+
135
+	/**
136
+	 * This deregisters a message type that was previously registered with a specific mtname.
137
+	 *
138
+	 * @since    4.3.0
139
+	 *
140
+	 * @param string  $mt_name the name for the message type that was previously registered
141
+	 * @return void
142
+	 */
143
+	public static function deregister( $mt_name = NULL ) {
144
+		if ( !empty( self::$_ee_message_type_registry[$mt_name] ) ) {
145
+						//let's make sure that we remove any place this message type was made active
146
+						EE_Registry::instance()->load_helper( 'MSG_Template' );
147
+						$active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
148
+						foreach( $active_messengers as $messenger => $settings ) {
149
+							if ( !empty( $settings['settings'][$messenger . '-message_types'][$mt_name] ) ) {
150
+								unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt_name] );
151
+							}
152
+						}
153
+						EEH_MSG_Template::update_to_inactive( '', $mt_name );
154
+						EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
155
+			unset( self::$_ee_message_type_registry[$mt_name] );
156
+		}
157
+	}
158
+
159
+
160
+
161
+	/**
162
+	 * callback for FHEE__EE_messages__get_installed__messagetype_files filter.
163
+	 *
164
+	 * @since   4.3.0
165
+	 *
166
+	 * @param  array  $messagetype_files The current array of message type file names
167
+	 * @return  array                                 Array of message type file names
168
+	 */
169
+	public static function register_messagetype_files( $messagetype_files ) {
170
+		if ( empty( self::$_ee_message_type_registry ) )
171
+			return $messagetype_files;
172
+
173
+		foreach ( self::$_ee_message_type_registry as $mt_reg ) {
174
+			if ( empty( $mt_reg['mtfilename' ] ) )
175
+				continue;
176
+			$messagetype_files[] = $mt_reg['mtfilename'];
177
+		}
178
+
179
+		return $messagetype_files;
180
+	}
181
+
182
+
183
+
184
+
185
+
186
+	/**
187
+	 * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter.
188
+	 *
189
+	 * @since    4.3.0
190
+	 *
191
+	 * @param array $paths array of paths to be checked by EE_messages autoloader.
192
+	 * @return array
193
+	 */
194
+	public static function register_msgs_autoload_paths( $paths  ) {
195
+
196
+		if ( ! empty( self::$_ee_message_type_registry ) ) {
197
+			foreach ( self::$_ee_message_type_registry as $mt_reg ) {
198
+				if ( empty( $mt_reg['autoloadpaths'] ) )
199
+					continue;
200
+				$paths = array_merge( $paths, $mt_reg['autoloadpaths'] );
201
+			}
202
+		}
203
+
204
+		return $paths;
205
+	}
206
+
207
+
208
+
209
+
210
+
211
+	/**
212
+	 * callback for FHEE__EE_messenger__get_default_message_types__default_types filter.
213
+	 *
214
+	 * @since   4.3.0
215
+	 *
216
+	 *
217
+	 * @param  array                $default_types array of message types activated with messenger (
218
+	 *                                                               corresponds to the $name property of message type)
219
+	 * @param  EE_messenger $messenger      The EE_messenger the filter is called from.
220
+	 * @return  array
221
+	 */
222
+	public static function register_messengers_to_activate_mt_with( $default_types, EE_messenger $messenger ) {
223
+		if ( empty( self::$_ee_message_type_registry ) )
224
+			return $default_types;
225
+
226
+		foreach ( self::$_ee_message_type_registry as $mt_name => $mt_reg ) {
227
+			if ( empty( $mt_reg['messengers_to_activate_with'] ) || empty( $mt_reg['mtfilename'] ) )
228
+				continue;
229
+
230
+			//loop through each of the messengers and if it matches the loaded class then we add this message type to the
231
+			foreach ( $mt_reg['messengers_to_activate_with'] as $msgr ) {
232
+				if ( $messenger->name == $msgr ) {
233
+					$default_types[] = $mt_name;
234
+				}
235
+			}
236
+		}
237
+
238
+		return $default_types;
239
+	}
240
+
241
+
242
+
243
+	 /**
244
+	  * callback for FHEE__EE_messenger__get_valid_message_types__default_types filter.
245
+	  *
246
+	  * @since   4.3.0
247
+	  *
248
+	  *
249
+	  * @param  array                $valid_types     array of message types valid with messenger (
250
+	  *                                                               corresponds to the $name property of message type)
251
+	  * @param  EE_messenger $messenger      The EE_messenger the filter is called from.
252
+	  * @return  array
253
+	  */
254
+	public static function register_messengers_to_validate_mt_with( $valid_types, EE_messenger $messenger ) {
255
+		if ( empty( self::$_ee_message_type_registry ) )
256
+			return $valid_types;
257
+
258
+		foreach ( self::$_ee_message_type_registry as $mt_name => $mt_reg ) {
259
+			if ( empty( $mt_reg['messengers_to_validate_with'] ) || empty( $mt_reg['mtfilename'] ) )
260
+				continue;
261
+
262
+			//loop through each of the messengers and if it matches the loaded class then we add this message type to the
263
+			foreach ( $mt_reg['messengers_to_validate_with'] as $msgr ) {
264
+				if ( $messenger->name == $msgr ) {
265
+					$valid_types[] = $mt_name;
266
+				}
267
+			}
268
+		}
269
+
270
+		return $valid_types;
271
+	}
272 272
 }
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -65,25 +65,25 @@  discard block
 block discarded – undo
65 65
      * }
66 66
      * @return void
67 67
      */
68
-    public static function register( $mt_name = NULL, $setup_args = array() ) {
68
+    public static function register($mt_name = NULL, $setup_args = array()) {
69 69
 
70 70
         //required fields MUST be present, so let's make sure they are.
71
-        if ( ! isset( $mt_name ) || ! is_array( $setup_args ) || empty( $setup_args['mtfilename'] ) || empty( $setup_args['autoloadpaths'] ) )
71
+        if ( ! isset($mt_name) || ! is_array($setup_args) || empty($setup_args['mtfilename']) || empty($setup_args['autoloadpaths']))
72 72
             throw new EE_Error(
73
-				__( 'In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', 'event_espresso' )
73
+				__('In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', 'event_espresso')
74 74
 			);
75 75
 
76 76
 		//make sure we don't register twice
77
-		if( isset( self::$_ee_message_type_registry[ $mt_name ] ) ){
77
+		if (isset(self::$_ee_message_type_registry[$mt_name])) {
78 78
 			return;
79 79
 		}
80 80
 
81 81
         //make sure this was called in the right place!
82
-        if ( ! did_action( 'EE_Brewing_Regular___messages_caf' ) || did_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' )) {
82
+        if ( ! did_action('EE_Brewing_Regular___messages_caf') || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')) {
83 83
             EE_Error::doing_it_wrong(
84 84
 				__METHOD__,
85 85
 				sprintf(
86
-					__('A message type named "%s" has been attempted to be registered with the EE Messages System.  It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.','event_espresso'),
86
+					__('A message type named "%s" has been attempted to be registered with the EE Messages System.  It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.', 'event_espresso'),
87 87
 					$mt_name
88 88
 				),
89 89
 				'4.3.0'
@@ -91,22 +91,22 @@  discard block
 block discarded – undo
91 91
         }
92 92
 
93 93
 	//setup $__ee_message_type_registry array from incoming values.
94
-	self::$_ee_message_type_registry[ $mt_name ] = array(
94
+	self::$_ee_message_type_registry[$mt_name] = array(
95 95
 		'mtfilename' => (string) $setup_args['mtfilename'],
96 96
 		'autoloadpaths' => (array) $setup_args['autoloadpaths'],
97
-		'messengers_to_activate_with' => ! empty( $setup_args['messengers_to_activate_with'] ) ? (array) $setup_args['messengers_to_activate_with'] : array(),
98
-                        'messengers_to_validate_with' => ! empty( $setup_args['messengers_to_validate_with'] ) ? (array) $setup_args['messengers_to_validate_with'] : array(),
99
-                        'force_activation' => ! empty( $setup_args['force_activation'] ) ? (bool) $setup_args['force_activation'] : array()
97
+		'messengers_to_activate_with' => ! empty($setup_args['messengers_to_activate_with']) ? (array) $setup_args['messengers_to_activate_with'] : array(),
98
+                        'messengers_to_validate_with' => ! empty($setup_args['messengers_to_validate_with']) ? (array) $setup_args['messengers_to_validate_with'] : array(),
99
+                        'force_activation' => ! empty($setup_args['force_activation']) ? (bool) $setup_args['force_activation'] : array()
100 100
 	);
101 101
 
102 102
 	//add filters
103
-	add_filter( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array( 'EE_Register_Message_Type', 'register_msgs_autoload_paths'), 10 );
104
-	add_filter('FHEE__EE_messages__get_installed__messagetype_files', array( 'EE_Register_Message_Type', 'register_messagetype_files'), 10, 1 );
105
-	add_filter( 'FHEE__EE_messenger__get_default_message_types__default_types', array( 'EE_Register_Message_Type', 'register_messengers_to_activate_mt_with'), 10, 2 );
106
-	add_filter( 'FHEE__EE_messenger__get_valid_message_types__valid_types', array( 'EE_Register_Message_Type', 'register_messengers_to_validate_mt_with'), 10, 2 );
103
+	add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array('EE_Register_Message_Type', 'register_msgs_autoload_paths'), 10);
104
+	add_filter('FHEE__EE_messages__get_installed__messagetype_files', array('EE_Register_Message_Type', 'register_messagetype_files'), 10, 1);
105
+	add_filter('FHEE__EE_messenger__get_default_message_types__default_types', array('EE_Register_Message_Type', 'register_messengers_to_activate_mt_with'), 10, 2);
106
+	add_filter('FHEE__EE_messenger__get_valid_message_types__valid_types', array('EE_Register_Message_Type', 'register_messengers_to_validate_mt_with'), 10, 2);
107 107
 
108 108
 	//actions
109
-	add_action( 'AHEE__EE_Addon__initialize_default_data__begin', array( 'EE_Register_Message_Type', 'set_defaults' ) );
109
+	add_action('AHEE__EE_Addon__initialize_default_data__begin', array('EE_Register_Message_Type', 'set_defaults'));
110 110
     }
111 111
 
112 112
 
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
     	EEH_Activation::generate_default_message_templates();
121 121
 
122 122
             //for any message types with force activation, let's ensure they are activated
123
-            foreach ( self::$_ee_message_type_registry as $mtname => $settings ) {
124
-                if ( $settings['force_activation'] ) {
123
+            foreach (self::$_ee_message_type_registry as $mtname => $settings) {
124
+                if ($settings['force_activation']) {
125 125
                     $MSG = new EE_Messages();
126
-                    foreach ( $settings['messengers_to_activate_with'] as $messenger ) {
127
-                        $MSG->ensure_message_type_is_active( $mtname, $messenger );
126
+                    foreach ($settings['messengers_to_activate_with'] as $messenger) {
127
+                        $MSG->ensure_message_type_is_active($mtname, $messenger);
128 128
                     }
129 129
                 }
130 130
             }
@@ -140,19 +140,19 @@  discard block
 block discarded – undo
140 140
      * @param string  $mt_name the name for the message type that was previously registered
141 141
      * @return void
142 142
      */
143
-    public static function deregister( $mt_name = NULL ) {
144
-    	if ( !empty( self::$_ee_message_type_registry[$mt_name] ) ) {
143
+    public static function deregister($mt_name = NULL) {
144
+    	if ( ! empty(self::$_ee_message_type_registry[$mt_name])) {
145 145
                         //let's make sure that we remove any place this message type was made active
146
-                        EE_Registry::instance()->load_helper( 'MSG_Template' );
146
+                        EE_Registry::instance()->load_helper('MSG_Template');
147 147
                         $active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
148
-                        foreach( $active_messengers as $messenger => $settings ) {
149
-                            if ( !empty( $settings['settings'][$messenger . '-message_types'][$mt_name] ) ) {
150
-                                unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt_name] );
148
+                        foreach ($active_messengers as $messenger => $settings) {
149
+                            if ( ! empty($settings['settings'][$messenger.'-message_types'][$mt_name])) {
150
+                                unset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt_name]);
151 151
                             }
152 152
                         }
153
-                        EEH_MSG_Template::update_to_inactive( '', $mt_name );
154
-                        EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
155
-    		unset( self::$_ee_message_type_registry[$mt_name] );
153
+                        EEH_MSG_Template::update_to_inactive('', $mt_name);
154
+                        EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
155
+    		unset(self::$_ee_message_type_registry[$mt_name]);
156 156
         }
157 157
     }
158 158
 
@@ -166,12 +166,12 @@  discard block
 block discarded – undo
166 166
      * @param  array  $messagetype_files The current array of message type file names
167 167
      * @return  array                                 Array of message type file names
168 168
      */
169
-    public static function register_messagetype_files( $messagetype_files ) {
170
-        if ( empty( self::$_ee_message_type_registry ) )
169
+    public static function register_messagetype_files($messagetype_files) {
170
+        if (empty(self::$_ee_message_type_registry))
171 171
             return $messagetype_files;
172 172
 
173
-        foreach ( self::$_ee_message_type_registry as $mt_reg ) {
174
-            if ( empty( $mt_reg['mtfilename' ] ) )
173
+        foreach (self::$_ee_message_type_registry as $mt_reg) {
174
+            if (empty($mt_reg['mtfilename']))
175 175
                 continue;
176 176
             $messagetype_files[] = $mt_reg['mtfilename'];
177 177
         }
@@ -191,13 +191,13 @@  discard block
 block discarded – undo
191 191
      * @param array $paths array of paths to be checked by EE_messages autoloader.
192 192
      * @return array
193 193
      */
194
-    public static function register_msgs_autoload_paths( $paths  ) {
194
+    public static function register_msgs_autoload_paths($paths) {
195 195
 
196
-        if ( ! empty( self::$_ee_message_type_registry ) ) {
197
-            foreach ( self::$_ee_message_type_registry as $mt_reg ) {
198
-                if ( empty( $mt_reg['autoloadpaths'] ) )
196
+        if ( ! empty(self::$_ee_message_type_registry)) {
197
+            foreach (self::$_ee_message_type_registry as $mt_reg) {
198
+                if (empty($mt_reg['autoloadpaths']))
199 199
                     continue;
200
-                $paths = array_merge( $paths, $mt_reg['autoloadpaths'] );
200
+                $paths = array_merge($paths, $mt_reg['autoloadpaths']);
201 201
             }
202 202
         }
203 203
 
@@ -219,17 +219,17 @@  discard block
 block discarded – undo
219 219
      * @param  EE_messenger $messenger      The EE_messenger the filter is called from.
220 220
      * @return  array
221 221
      */
222
-    public static function register_messengers_to_activate_mt_with( $default_types, EE_messenger $messenger ) {
223
-        if ( empty( self::$_ee_message_type_registry ) )
222
+    public static function register_messengers_to_activate_mt_with($default_types, EE_messenger $messenger) {
223
+        if (empty(self::$_ee_message_type_registry))
224 224
             return $default_types;
225 225
 
226
-        foreach ( self::$_ee_message_type_registry as $mt_name => $mt_reg ) {
227
-            if ( empty( $mt_reg['messengers_to_activate_with'] ) || empty( $mt_reg['mtfilename'] ) )
226
+        foreach (self::$_ee_message_type_registry as $mt_name => $mt_reg) {
227
+            if (empty($mt_reg['messengers_to_activate_with']) || empty($mt_reg['mtfilename']))
228 228
                 continue;
229 229
 
230 230
             //loop through each of the messengers and if it matches the loaded class then we add this message type to the
231
-            foreach ( $mt_reg['messengers_to_activate_with'] as $msgr ) {
232
-                if ( $messenger->name == $msgr ) {
231
+            foreach ($mt_reg['messengers_to_activate_with'] as $msgr) {
232
+                if ($messenger->name == $msgr) {
233 233
                     $default_types[] = $mt_name;
234 234
                 }
235 235
             }
@@ -251,17 +251,17 @@  discard block
 block discarded – undo
251 251
      * @param  EE_messenger $messenger      The EE_messenger the filter is called from.
252 252
      * @return  array
253 253
      */
254
-    public static function register_messengers_to_validate_mt_with( $valid_types, EE_messenger $messenger ) {
255
-        if ( empty( self::$_ee_message_type_registry ) )
254
+    public static function register_messengers_to_validate_mt_with($valid_types, EE_messenger $messenger) {
255
+        if (empty(self::$_ee_message_type_registry))
256 256
             return $valid_types;
257 257
 
258
-        foreach ( self::$_ee_message_type_registry as $mt_name => $mt_reg ) {
259
-            if ( empty( $mt_reg['messengers_to_validate_with'] ) || empty( $mt_reg['mtfilename'] ) )
258
+        foreach (self::$_ee_message_type_registry as $mt_name => $mt_reg) {
259
+            if (empty($mt_reg['messengers_to_validate_with']) || empty($mt_reg['mtfilename']))
260 260
                 continue;
261 261
 
262 262
             //loop through each of the messengers and if it matches the loaded class then we add this message type to the
263
-            foreach ( $mt_reg['messengers_to_validate_with'] as $msgr ) {
264
-                if ( $messenger->name == $msgr ) {
263
+            foreach ($mt_reg['messengers_to_validate_with'] as $msgr) {
264
+                if ($messenger->name == $msgr) {
265 265
                     $valid_types[] = $mt_name;
266 266
                 }
267 267
             }
Please login to merge, or discard this patch.
Braces   +27 added lines, -17 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@  discard block
 block discarded – undo
5 5
  * @subpackage plugin api, messages
6 6
  * @since           4.3.0
7 7
  */
8
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
8
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
+	exit('No direct script access allowed');
10
+}
9 11
 
10 12
 /**
11 13
  * Use this to register or deregister a new message type for the EE messages system.
@@ -68,10 +70,11 @@  discard block
 block discarded – undo
68 70
     public static function register( $mt_name = NULL, $setup_args = array() ) {
69 71
 
70 72
         //required fields MUST be present, so let's make sure they are.
71
-        if ( ! isset( $mt_name ) || ! is_array( $setup_args ) || empty( $setup_args['mtfilename'] ) || empty( $setup_args['autoloadpaths'] ) )
72
-            throw new EE_Error(
73
+        if ( ! isset( $mt_name ) || ! is_array( $setup_args ) || empty( $setup_args['mtfilename'] ) || empty( $setup_args['autoloadpaths'] ) ) {
74
+                    throw new EE_Error(
73 75
 				__( 'In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', 'event_espresso' )
74 76
 			);
77
+        }
75 78
 
76 79
 		//make sure we don't register twice
77 80
 		if( isset( self::$_ee_message_type_registry[ $mt_name ] ) ){
@@ -167,12 +170,14 @@  discard block
 block discarded – undo
167 170
      * @return  array                                 Array of message type file names
168 171
      */
169 172
     public static function register_messagetype_files( $messagetype_files ) {
170
-        if ( empty( self::$_ee_message_type_registry ) )
171
-            return $messagetype_files;
173
+        if ( empty( self::$_ee_message_type_registry ) ) {
174
+                    return $messagetype_files;
175
+        }
172 176
 
173 177
         foreach ( self::$_ee_message_type_registry as $mt_reg ) {
174
-            if ( empty( $mt_reg['mtfilename' ] ) )
175
-                continue;
178
+            if ( empty( $mt_reg['mtfilename' ] ) ) {
179
+                            continue;
180
+            }
176 181
             $messagetype_files[] = $mt_reg['mtfilename'];
177 182
         }
178 183
 
@@ -195,8 +200,9 @@  discard block
 block discarded – undo
195 200
 
196 201
         if ( ! empty( self::$_ee_message_type_registry ) ) {
197 202
             foreach ( self::$_ee_message_type_registry as $mt_reg ) {
198
-                if ( empty( $mt_reg['autoloadpaths'] ) )
199
-                    continue;
203
+                if ( empty( $mt_reg['autoloadpaths'] ) ) {
204
+                                    continue;
205
+                }
200 206
                 $paths = array_merge( $paths, $mt_reg['autoloadpaths'] );
201 207
             }
202 208
         }
@@ -220,12 +226,14 @@  discard block
 block discarded – undo
220 226
      * @return  array
221 227
      */
222 228
     public static function register_messengers_to_activate_mt_with( $default_types, EE_messenger $messenger ) {
223
-        if ( empty( self::$_ee_message_type_registry ) )
224
-            return $default_types;
229
+        if ( empty( self::$_ee_message_type_registry ) ) {
230
+                    return $default_types;
231
+        }
225 232
 
226 233
         foreach ( self::$_ee_message_type_registry as $mt_name => $mt_reg ) {
227
-            if ( empty( $mt_reg['messengers_to_activate_with'] ) || empty( $mt_reg['mtfilename'] ) )
228
-                continue;
234
+            if ( empty( $mt_reg['messengers_to_activate_with'] ) || empty( $mt_reg['mtfilename'] ) ) {
235
+                            continue;
236
+            }
229 237
 
230 238
             //loop through each of the messengers and if it matches the loaded class then we add this message type to the
231 239
             foreach ( $mt_reg['messengers_to_activate_with'] as $msgr ) {
@@ -252,12 +260,14 @@  discard block
 block discarded – undo
252 260
      * @return  array
253 261
      */
254 262
     public static function register_messengers_to_validate_mt_with( $valid_types, EE_messenger $messenger ) {
255
-        if ( empty( self::$_ee_message_type_registry ) )
256
-            return $valid_types;
263
+        if ( empty( self::$_ee_message_type_registry ) ) {
264
+                    return $valid_types;
265
+        }
257 266
 
258 267
         foreach ( self::$_ee_message_type_registry as $mt_name => $mt_reg ) {
259
-            if ( empty( $mt_reg['messengers_to_validate_with'] ) || empty( $mt_reg['mtfilename'] ) )
260
-                continue;
268
+            if ( empty( $mt_reg['messengers_to_validate_with'] ) || empty( $mt_reg['mtfilename'] ) ) {
269
+                            continue;
270
+            }
261 271
 
262 272
             //loop through each of the messengers and if it matches the loaded class then we add this message type to the
263 273
             foreach ( $mt_reg['messengers_to_validate_with'] as $msgr ) {
Please login to merge, or discard this patch.