@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | } |
6 | 6 | |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @author Brent Christensen |
15 | 15 | * |
16 | 16 | */ |
17 | -class EE_DMS_4_9_0_Answers_With_No_Registration extends EE_Data_Migration_Script_Stage{ |
|
17 | +class EE_DMS_4_9_0_Answers_With_No_Registration extends EE_Data_Migration_Script_Stage { |
|
18 | 18 | |
19 | 19 | |
20 | 20 | |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * @return EE_DMS_4_9_0_Answers_With_No_Registration |
25 | 25 | */ |
26 | 26 | public function __construct() { |
27 | - $this->_pretty_name = __( 'Answer Cleanup', 'event_espresso' ); |
|
27 | + $this->_pretty_name = __('Answer Cleanup', 'event_espresso'); |
|
28 | 28 | parent::__construct(); |
29 | 29 | } |
30 | 30 | |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | protected function _migration_step($num_items_to_migrate = 50) { |
49 | 49 | global $wpdb; |
50 | 50 | $wpdb->delete( |
51 | - $wpdb->prefix . 'esp_answer', |
|
52 | - array( 'REG_ID' => 0 ), |
|
53 | - array( '%d' ) |
|
51 | + $wpdb->prefix.'esp_answer', |
|
52 | + array('REG_ID' => 0), |
|
53 | + array('%d') |
|
54 | 54 | ); |
55 | 55 | $this->set_completed(); |
56 | 56 | return 1; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @return EED_Core_Rest_Api |
28 | 28 | */ |
29 | 29 | public static function instance() { |
30 | - return parent::get_instance( __CLASS__ ); |
|
30 | + return parent::get_instance(__CLASS__); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | |
58 | 58 | |
59 | 59 | public static function set_hooks_both() { |
60 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'register_routes' ), 10 ); |
|
61 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'set_hooks_rest_api' ), 5 ); |
|
62 | - add_filter( 'rest_route_data', array( 'EED_Core_Rest_Api', 'hide_old_endpoints' ), 10, 2 ); |
|
63 | - add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) ); |
|
60 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10); |
|
61 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5); |
|
62 | + add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2); |
|
63 | + add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
64 | 64 | EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change(); |
65 | 65 | } |
66 | 66 | |
@@ -74,16 +74,16 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | protected static function _set_hooks_for_changes() { |
77 | - $folder_contents = EEH_File::get_contents_of_folders( array( EE_LIBRARIES . 'rest_api' . DS . 'changes' ), false ); |
|
78 | - foreach( $folder_contents as $classname_in_namespace => $filepath ) { |
|
77 | + $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false); |
|
78 | + foreach ($folder_contents as $classname_in_namespace => $filepath) { |
|
79 | 79 | //ignore the base parent class |
80 | - if( $classname_in_namespace === 'Changes_In_Base' ) { |
|
80 | + if ($classname_in_namespace === 'Changes_In_Base') { |
|
81 | 81 | continue; |
82 | 82 | } |
83 | - $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
84 | - if ( class_exists( $full_classname )) { |
|
83 | + $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace; |
|
84 | + if (class_exists($full_classname)) { |
|
85 | 85 | $instance_of_class = new $full_classname; |
86 | - if ( $instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base ) { |
|
86 | + if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
|
87 | 87 | $instance_of_class->set_hooks(); |
88 | 88 | } |
89 | 89 | } |
@@ -96,16 +96,16 @@ discard block |
||
96 | 96 | * so we actually prefer to only do it when an EE plugin is activated or upgraded |
97 | 97 | */ |
98 | 98 | public static function register_routes() { |
99 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
100 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
101 | - foreach( $routes as $route ) { |
|
99 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
100 | + foreach ($relative_urls as $endpoint => $routes) { |
|
101 | + foreach ($routes as $route) { |
|
102 | 102 | register_rest_route( |
103 | 103 | $namespace, |
104 | 104 | $endpoint, |
105 | 105 | array( |
106 | - 'callback' => $route[ 'callback' ], |
|
107 | - 'methods' => $route[ 'methods' ], |
|
108 | - 'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(), |
|
106 | + 'callback' => $route['callback'], |
|
107 | + 'methods' => $route['methods'], |
|
108 | + 'args' => isset($route['args']) ? $route['args'] : array(), |
|
109 | 109 | ) |
110 | 110 | ); |
111 | 111 | } |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | * next time the WP API is used |
120 | 120 | */ |
121 | 121 | public static function invalidate_cached_route_data_on_version_change() { |
122 | - if( EE_System::instance()->detect_req_type() != EE_System::req_type_normal ) { |
|
122 | + if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) { |
|
123 | 123 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
124 | 124 | } |
125 | - foreach( EE_Registry::instance()->addons as $addon ){ |
|
126 | - if( $addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal ) { |
|
125 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
126 | + if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) { |
|
127 | 127 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
128 | 128 | } |
129 | 129 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public static function invalidate_cached_route_data() { |
136 | 136 | //delete the saved EE REST API routes |
137 | - delete_option( EED_Core_Rest_Api::saved_routes_option_names ); |
|
137 | + delete_option(EED_Core_Rest_Api::saved_routes_option_names); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | * } |
147 | 147 | */ |
148 | 148 | public static function get_ee_route_data() { |
149 | - $ee_routes = get_option( self::saved_routes_option_names, null ); |
|
150 | - if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){ |
|
149 | + $ee_routes = get_option(self::saved_routes_option_names, null); |
|
150 | + if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
151 | 151 | self::save_ee_routes(); |
152 | - $ee_routes = get_option( self::saved_routes_option_names, array() ); |
|
152 | + $ee_routes = get_option(self::saved_routes_option_names, array()); |
|
153 | 153 | } |
154 | 154 | return $ee_routes; |
155 | 155 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @return void |
161 | 161 | */ |
162 | 162 | public static function save_ee_routes() { |
163 | - if( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
163 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
164 | 164 | $instance = self::instance(); |
165 | 165 | $routes = apply_filters( |
166 | 166 | 'EED_Core_Rest_Api__save_ee_routes__routes', |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $instance->_register_rpc_routes() |
172 | 172 | ) |
173 | 173 | ); |
174 | - update_option( self::saved_routes_option_names, $routes, true ); |
|
174 | + update_option(self::saved_routes_option_names, $routes, true); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @return array @see get_ee_route_data |
181 | 181 | */ |
182 | 182 | protected function _register_model_routes() { |
183 | - EE_Registry::instance()->load_helper( 'Inflector' ); |
|
183 | + EE_Registry::instance()->load_helper('Inflector'); |
|
184 | 184 | $models_to_register = apply_filters( |
185 | 185 | 'FHEE__EED_Core_REST_API___register_model_routes', |
186 | 186 | EE_Registry::instance()->non_abstract_db_models |
@@ -189,23 +189,23 @@ discard block |
||
189 | 189 | unset($models_to_register['Extra_Meta']); |
190 | 190 | unset($models_to_register['Extra_Join']); |
191 | 191 | $model_routes = array( ); |
192 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
192 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
193 | 193 | |
194 | - foreach ( $models_to_register as $model_name => $model_classname ) { |
|
194 | + foreach ($models_to_register as $model_name => $model_classname) { |
|
195 | 195 | //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
196 | - $ee_namespace = self::ee_api_namespace . $version; |
|
197 | - $plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name ); |
|
198 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)' ; |
|
199 | - $model_routes[ $ee_namespace ][ $plural_model_route ] = array( |
|
196 | + $ee_namespace = self::ee_api_namespace.$version; |
|
197 | + $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
198 | + $singular_model_route = $plural_model_route.'/(?P<id>\d+)'; |
|
199 | + $model_routes[$ee_namespace][$plural_model_route] = array( |
|
200 | 200 | array( |
201 | 201 | 'callback' => array( |
202 | 202 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
203 | 203 | 'handle_request_get_all' ), |
204 | 204 | 'methods' => WP_REST_Server::READABLE, |
205 | 205 | 'hidden_endpoint' => $hidden_endpoint, |
206 | - 'args' => $this->_get_read_query_params( $model_name ), |
|
206 | + 'args' => $this->_get_read_query_params($model_name), |
|
207 | 207 | '_links' => array( |
208 | - 'self' => rest_url( $ee_namespace . $singular_model_route ), |
|
208 | + 'self' => rest_url($ee_namespace.$singular_model_route), |
|
209 | 209 | ) |
210 | 210 | ), |
211 | 211 | // array( |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | // 'hidden_endpoint' => $hidden_endpoint |
217 | 217 | // ) |
218 | 218 | ); |
219 | - $model_routes[ $ee_namespace ][ $singular_model_route ] = array( |
|
219 | + $model_routes[$ee_namespace][$singular_model_route] = array( |
|
220 | 220 | array( |
221 | 221 | 'callback' => array( |
222 | 222 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | 'include' => array( |
228 | 228 | 'required' => false, |
229 | 229 | 'default' => '*', |
230 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ), |
|
230 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'), |
|
231 | 231 | ), |
232 | 232 | ) |
233 | 233 | ), |
@@ -240,20 +240,20 @@ discard block |
||
240 | 240 | // ), |
241 | 241 | ); |
242 | 242 | //@todo: also handle DELETE for a single item |
243 | - $model = EE_Registry::instance()->load_model( $model_classname ); |
|
244 | - foreach ( $model->relation_settings() as $relation_name => $relation_obj ) { |
|
243 | + $model = EE_Registry::instance()->load_model($model_classname); |
|
244 | + foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
245 | 245 | $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
246 | 246 | $relation_name, |
247 | 247 | $relation_obj |
248 | 248 | ); |
249 | - $model_routes[ $ee_namespace ][ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array( |
|
249 | + $model_routes[$ee_namespace][$singular_model_route.'/'.$related_model_name_endpoint_part] = array( |
|
250 | 250 | array( |
251 | 251 | 'callback' => array( |
252 | 252 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
253 | 253 | 'handle_request_get_related' ), |
254 | 254 | 'methods' => WP_REST_Server::READABLE, |
255 | 255 | 'hidden_endpoint' => $hidden_endpoint, |
256 | - 'args' => $this->_get_read_query_params( $relation_name ), |
|
256 | + 'args' => $this->_get_read_query_params($relation_name), |
|
257 | 257 | ), |
258 | 258 | // array( |
259 | 259 | // 'callback' => array( |
@@ -277,11 +277,11 @@ discard block |
||
277 | 277 | */ |
278 | 278 | protected function _register_rpc_routes() { |
279 | 279 | $routes = array(); |
280 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
281 | - $ee_namespace = self::ee_api_namespace . $version; |
|
280 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
281 | + $ee_namespace = self::ee_api_namespace.$version; |
|
282 | 282 | $this_versions_routes = array(); |
283 | 283 | //checkin endpoint |
284 | - $this_versions_routes[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] = array( |
|
284 | + $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array( |
|
285 | 285 | array( |
286 | 286 | 'callback' => array( |
287 | 287 | 'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin', |
@@ -292,12 +292,12 @@ discard block |
||
292 | 292 | 'force' => array( |
293 | 293 | 'required' => false, |
294 | 294 | 'default' => false, |
295 | - 'description' => __( 'Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso' ) |
|
295 | + 'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso') |
|
296 | 296 | ) |
297 | 297 | ) |
298 | 298 | ) |
299 | 299 | ); |
300 | - $routes[ $ee_namespace ] = apply_filters( |
|
300 | + $routes[$ee_namespace] = apply_filters( |
|
301 | 301 | 'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes', |
302 | 302 | $this_versions_routes, |
303 | 303 | $version, |
@@ -312,47 +312,47 @@ discard block |
||
312 | 312 | * @param string $model_name eg 'Event' or 'Venue' |
313 | 313 | * @return array describing the args acceptable when querying this model |
314 | 314 | */ |
315 | - protected function _get_read_query_params( $model_name ) { |
|
316 | - $model = EE_Registry::instance()->load_model( $model_name ); |
|
315 | + protected function _get_read_query_params($model_name) { |
|
316 | + $model = EE_Registry::instance()->load_model($model_name); |
|
317 | 317 | $default_orderby = array(); |
318 | - foreach( $model->get_combined_primary_key_fields() as $key_field ) { |
|
319 | - $default_orderby[ $key_field->get_name() ] = 'ASC'; |
|
318 | + foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
319 | + $default_orderby[$key_field->get_name()] = 'ASC'; |
|
320 | 320 | } |
321 | 321 | return array( |
322 | 322 | 'where' => array( |
323 | 323 | 'required' => false, |
324 | 324 | 'default' => array(), |
325 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#where for documentation', 'event_espresso' ), |
|
325 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#where for documentation', 'event_espresso'), |
|
326 | 326 | ), |
327 | 327 | 'limit' => array( |
328 | 328 | 'required' => false, |
329 | 329 | 'default' => 50, |
330 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#limit for documentation', 'event_espresso' ) |
|
330 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#limit for documentation', 'event_espresso') |
|
331 | 331 | ), |
332 | 332 | 'order_by' => array( |
333 | 333 | 'required' => false, |
334 | 334 | 'default' => $default_orderby, |
335 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#order_by for documentation', 'event_espresso' ) |
|
335 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#order_by for documentation', 'event_espresso') |
|
336 | 336 | ), |
337 | 337 | 'group_by' => array( |
338 | 338 | 'required' => false, |
339 | 339 | 'default' => null, |
340 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#group_by for documentation', 'event_espresso' ) |
|
340 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#group_by for documentation', 'event_espresso') |
|
341 | 341 | ), |
342 | 342 | 'having' => array( |
343 | 343 | 'required' => false, |
344 | 344 | 'default' => null, |
345 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#having for documentation', 'event_espresso' ) |
|
345 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#having for documentation', 'event_espresso') |
|
346 | 346 | ), |
347 | 347 | 'caps' => array( |
348 | 348 | 'required' => false, |
349 | 349 | 'default' => EEM_Base::caps_read, |
350 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#caps for documentation', 'event_espresso' ) |
|
350 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#caps for documentation', 'event_espresso') |
|
351 | 351 | ), |
352 | 352 | 'include' => array( |
353 | 353 | 'required' => false, |
354 | 354 | 'default' => '*', |
355 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ), |
|
355 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'), |
|
356 | 356 | ), |
357 | 357 | ); |
358 | 358 | } |
@@ -363,8 +363,8 @@ discard block |
||
363 | 363 | */ |
364 | 364 | protected function _register_config_routes() { |
365 | 365 | $config_routes = array(); |
366 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
367 | - $config_routes[ self::ee_api_namespace . $version ][ 'config' ] = array( |
|
366 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
367 | + $config_routes[self::ee_api_namespace.$version]['config'] = array( |
|
368 | 368 | array( |
369 | 369 | 'callback' => array( |
370 | 370 | 'EventEspresso\core\libraries\rest_api\controllers\config\Read', |
@@ -383,8 +383,8 @@ discard block |
||
383 | 383 | */ |
384 | 384 | protected function _register_meta_routes() { |
385 | 385 | $meta_routes = array(); |
386 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
387 | - $meta_routes[ self::ee_api_namespace . $version ][ '/resources' ] = array( |
|
386 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
387 | + $meta_routes[self::ee_api_namespace.$version]['/resources'] = array( |
|
388 | 388 | array( |
389 | 389 | 'callback' => array( |
390 | 390 | 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', |
@@ -405,13 +405,13 @@ discard block |
||
405 | 405 | * @param array $route_data |
406 | 406 | * @return array |
407 | 407 | */ |
408 | - public static function hide_old_endpoints( $route_data ) { |
|
409 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
410 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
411 | - foreach( $routes as $route ) { |
|
412 | - if( $route[ 'hidden_endpoint' ] ) { |
|
413 | - $full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' ); |
|
414 | - unset( $route_data[ $full_route ] ); |
|
408 | + public static function hide_old_endpoints($route_data) { |
|
409 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
410 | + foreach ($relative_urls as $endpoint => $routes) { |
|
411 | + foreach ($routes as $route) { |
|
412 | + if ($route['hidden_endpoint']) { |
|
413 | + $full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/'); |
|
414 | + unset($route_data[$full_route]); |
|
415 | 415 | } |
416 | 416 | } |
417 | 417 | } |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | */ |
449 | 449 | public static function latest_rest_api_version() { |
450 | 450 | $versions_served = \EED_Core_Rest_Api::versions_served(); |
451 | - return end( array_keys( $versions_served ) ); |
|
451 | + return end(array_keys($versions_served)); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | /** |
@@ -462,32 +462,32 @@ discard block |
||
462 | 462 | public static function versions_served() { |
463 | 463 | $versions_served = array(); |
464 | 464 | $possibly_served_versions = EED_Core_Rest_Api::version_compatibilities(); |
465 | - $lowest_compatible_version = end( $possibly_served_versions); |
|
466 | - reset( $possibly_served_versions ); |
|
467 | - $versions_served_historically = array_keys( $possibly_served_versions ); |
|
468 | - $latest_version = end( $versions_served_historically ); |
|
469 | - reset( $versions_served_historically ); |
|
465 | + $lowest_compatible_version = end($possibly_served_versions); |
|
466 | + reset($possibly_served_versions); |
|
467 | + $versions_served_historically = array_keys($possibly_served_versions); |
|
468 | + $latest_version = end($versions_served_historically); |
|
469 | + reset($versions_served_historically); |
|
470 | 470 | //for each version of core we have ever served: |
471 | - foreach ( $versions_served_historically as $key_versioned_endpoint ) { |
|
471 | + foreach ($versions_served_historically as $key_versioned_endpoint) { |
|
472 | 472 | //if it's not above the current core version, and it's compatible with the current version of core |
473 | - if( $key_versioned_endpoint == $latest_version ) { |
|
473 | + if ($key_versioned_endpoint == $latest_version) { |
|
474 | 474 | //don't hide the latest version in the index |
475 | - $versions_served[ $key_versioned_endpoint ] = false; |
|
476 | - } else if( |
|
475 | + $versions_served[$key_versioned_endpoint] = false; |
|
476 | + } else if ( |
|
477 | 477 | $key_versioned_endpoint < EED_Core_Rest_Api::core_version() |
478 | 478 | && $key_versioned_endpoint >= $lowest_compatible_version |
479 | 479 | ) { |
480 | 480 | //include, but hide, previous versions which are still supported |
481 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
482 | - } elseif( |
|
481 | + $versions_served[$key_versioned_endpoint] = true; |
|
482 | + } elseif ( |
|
483 | 483 | apply_filters( |
484 | 484 | 'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions', |
485 | 485 | false, |
486 | 486 | $possibly_served_versions |
487 | 487 | ) |
488 | - ){ |
|
488 | + ) { |
|
489 | 489 | //if a version is no longer supported, don't include it in index or list of versions served |
490 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
490 | + $versions_served[$key_versioned_endpoint] = true; |
|
491 | 491 | } |
492 | 492 | } |
493 | 493 | return $versions_served; |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | * @return string |
501 | 501 | */ |
502 | 502 | public static function core_version() { |
503 | - return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) ); |
|
503 | + return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | * @param WP $WP |
513 | 513 | * @return void |
514 | 514 | */ |
515 | - public function run( $WP ) { |
|
515 | + public function run($WP) { |
|
516 | 516 | |
517 | 517 | } |
518 | 518 |
@@ -1,5 +1,5 @@ discard block |
||
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 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | class Event_Categories_Admin_List_Table extends EE_Admin_List_Table { |
33 | 33 | |
34 | - public function __construct( $admin_page ) { |
|
34 | + public function __construct($admin_page) { |
|
35 | 35 | parent::__construct($admin_page); |
36 | 36 | } |
37 | 37 | |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | |
40 | 40 | |
41 | 41 | protected function _setup_data() { |
42 | - $this->_data = $this->_admin_page->get_categories( $this->_per_page, $this->_current_page); |
|
43 | - $this->_all_data_count = EEM_Term_Taxonomy::instance()->count( array( array( 'taxonomy' => 'espresso_event_categories' ) ) ); |
|
42 | + $this->_data = $this->_admin_page->get_categories($this->_per_page, $this->_current_page); |
|
43 | + $this->_all_data_count = EEM_Term_Taxonomy::instance()->count(array(array('taxonomy' => 'espresso_event_categories'))); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | |
50 | 50 | protected function _set_properties() { |
51 | 51 | $this->_wp_list_args = array( |
52 | - 'singular' => __('event category', 'event_espresso' ), |
|
53 | - 'plural' => __('event categories', 'event_espresso' ), |
|
52 | + 'singular' => __('event category', 'event_espresso'), |
|
53 | + 'plural' => __('event categories', 'event_espresso'), |
|
54 | 54 | 'ajax' => TRUE, //for now, |
55 | 55 | 'screen' => $this->_admin_page->get_current_screen()->id |
56 | 56 | ); |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | ); |
65 | 65 | |
66 | 66 | $this->_sortable_columns = array( |
67 | - 'id' => array( 'Term.term_id' => true ), |
|
68 | - 'name' => array( 'Term.slug' => false ), |
|
69 | - 'count' => array( 'term_count' => false ) |
|
67 | + 'id' => array('Term.term_id' => true), |
|
68 | + 'name' => array('Term.slug' => false), |
|
69 | + 'count' => array('term_count' => false) |
|
70 | 70 | ); |
71 | 71 | |
72 | 72 | $this->_primary_column = 'id'; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | |
100 | 100 | public function column_cb($item) { |
101 | - return sprintf( '<input type="checkbox" name="EVT_CAT_ID[]" value="%s" />', $item->get('term_id') ); |
|
101 | + return sprintf('<input type="checkbox" name="EVT_CAT_ID[]" value="%s" />', $item->get('term_id')); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | public function column_id($item) { |
109 | 109 | $content = $item->get('term_id'); |
110 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->get_first_related('Term')->get('name') . '</span>'; |
|
110 | + $content .= ' <span class="show-on-mobile-view-only">'.$item->get_first_related('Term')->get('name').'</span>'; |
|
111 | 111 | return $content; |
112 | 112 | } |
113 | 113 | |
@@ -127,17 +127,17 @@ discard block |
||
127 | 127 | 'EVT_CAT_ID' => $item->get('term_id') |
128 | 128 | ); |
129 | 129 | |
130 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( $edit_query_args, EVENTS_ADMIN_URL ); |
|
131 | - $delete_link = EE_Admin_Page::add_query_args_and_nonce( $delete_query_args, EVENTS_ADMIN_URL ); |
|
130 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
131 | + $delete_link = EE_Admin_Page::add_query_args_and_nonce($delete_query_args, EVENTS_ADMIN_URL); |
|
132 | 132 | |
133 | 133 | $actions = array( |
134 | - 'edit' => '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Category', 'event_espresso') . '">' . __('Edit', 'event_espresso') . '</a>' |
|
134 | + 'edit' => '<a href="'.$edit_link.'" title="'.esc_attr__('Edit Category', 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>' |
|
135 | 135 | ); |
136 | 136 | |
137 | 137 | |
138 | - $actions['delete'] = '<a href="' . $delete_link . '" title="' . esc_attr__('Delete Category', 'event_espresso') . '">' . __('Delete', 'event_espresso') . '</a>'; |
|
138 | + $actions['delete'] = '<a href="'.$delete_link.'" title="'.esc_attr__('Delete Category', 'event_espresso').'">'.__('Delete', 'event_espresso').'</a>'; |
|
139 | 139 | |
140 | - $content = '<strong><a class="row-title" href="' . $edit_link . '">' . $item->get_first_related('Term')->get('name') . '</a></strong>'; |
|
140 | + $content = '<strong><a class="row-title" href="'.$edit_link.'">'.$item->get_first_related('Term')->get('name').'</a></strong>'; |
|
141 | 141 | $content .= $this->row_actions($actions); |
142 | 142 | return $content; |
143 | 143 | } |
@@ -146,20 +146,20 @@ discard block |
||
146 | 146 | |
147 | 147 | |
148 | 148 | public function column_shortcode($item) { |
149 | - $content = '[ESPRESSO_EVENTS category_slug=' . $item->get_first_related('Term')->get('slug') . ']'; |
|
149 | + $content = '[ESPRESSO_EVENTS category_slug='.$item->get_first_related('Term')->get('slug').']'; |
|
150 | 150 | return $content; |
151 | 151 | } |
152 | 152 | |
153 | 153 | |
154 | 154 | |
155 | 155 | |
156 | - public function column_count( $item ) { |
|
156 | + public function column_count($item) { |
|
157 | 157 | $e_args = array( |
158 | 158 | 'action' => 'default', |
159 | 159 | 'EVT_CAT' => $item->get_first_related('Term')->ID() |
160 | 160 | ); |
161 | - $e_link = EE_Admin_Page::add_query_args_and_nonce( $e_args, EVENTS_ADMIN_URL ); |
|
162 | - $content = '<a href="' . $e_link . '">' . $item->get('term_count') . '</a>'; |
|
161 | + $e_link = EE_Admin_Page::add_query_args_and_nonce($e_args, EVENTS_ADMIN_URL); |
|
162 | + $content = '<a href="'.$e_link.'">'.$item->get('term_count').'</a>'; |
|
163 | 163 | return $content; |
164 | 164 | } |
165 | 165 | } |
@@ -92,42 +92,42 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return EEM_Message |
94 | 94 | */ |
95 | - protected function __construct( $timezone = null ) { |
|
96 | - $this->singular_item = __('Message','event_espresso'); |
|
97 | - $this->plural_item = __('Messages','event_espresso'); |
|
95 | + protected function __construct($timezone = null) { |
|
96 | + $this->singular_item = __('Message', 'event_espresso'); |
|
97 | + $this->plural_item = __('Messages', 'event_espresso'); |
|
98 | 98 | |
99 | 99 | //used for token generator |
100 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
100 | + EE_Registry::instance()->load_helper('URL'); |
|
101 | 101 | |
102 | 102 | $this->_tables = array( |
103 | - 'Message'=>new EE_Primary_Table('esp_message','MSG_ID') |
|
103 | + 'Message'=>new EE_Primary_Table('esp_message', 'MSG_ID') |
|
104 | 104 | ); |
105 | 105 | |
106 | 106 | $allowed_priority = array( |
107 | - self::priority_high => __( 'high', 'event_espresso' ), |
|
108 | - self::priority_medium => __( 'medium', 'event_espresso' ), |
|
109 | - self::priority_low => __( 'low', 'event_espresso' ) |
|
107 | + self::priority_high => __('high', 'event_espresso'), |
|
108 | + self::priority_medium => __('medium', 'event_espresso'), |
|
109 | + self::priority_low => __('low', 'event_espresso') |
|
110 | 110 | ); |
111 | 111 | |
112 | 112 | $this->_fields = array( |
113 | 113 | 'Message'=>array( |
114 | - 'MSG_ID'=>new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID','event_espresso')), |
|
115 | - 'MSG_token' => new EE_Plain_Text_Field( 'MSG_token', __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', 'event_espresso' ), false, EEH_URL::generate_unique_token() ), |
|
116 | - 'GRP_ID'=>new EE_Foreign_Key_Int_Field( 'GRP_ID', __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso' ), true, 0, 'Message_Template_Group' ), |
|
117 | - 'TXN_ID' => new EE_Foreign_Key_Int_Field( 'TXN_ID', __( 'Foreign key to the related EE_Transaction. This is required to give context for regenerating the specific message', 'event_espresso' ), true, 0, 'Transaction' ), |
|
118 | - 'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', __( 'Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.', 'event_espresso' ), false, 'email' ), |
|
119 | - 'MSG_message_type' => new EE_Plain_Text_Field( 'MSG_message_type', __( 'Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso' ), false, 'receipt' ), |
|
120 | - 'MSG_context' => new EE_Plain_Text_Field( 'MSG_context', __( 'Context', 'event_espresso' ), false ), |
|
121 | - 'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field( 'MSG_recipient_ID', __( 'Recipient ID', 'event_espresso' ), true, null, array( 'Registration', 'Attendee', 'WP_User' ) ), |
|
122 | - 'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field( 'MSG_recipient_type', __( 'Recipient Type', 'event_espresso' ), true, null, array( 'Registration', 'Attendee', 'WP_User' ) ), |
|
123 | - 'MSG_content' => new EE_Maybe_Serialized_Text_Field( 'MSG_content', __( 'Content', 'event_espresso' ), true, '' ), |
|
124 | - 'MSG_to' => new EE_Maybe_Serialized_Text_Field( 'MSG_to', __( 'Address To', 'event_espresso' ), true ), |
|
125 | - 'MSG_from' => new EE_Maybe_Serialized_Text_Field( 'MSG_from', __( 'Address From', 'event_espresso' ), true ), |
|
126 | - 'MSG_subject' => new EE_Maybe_Serialized_Text_Field( 'MSG_subject', __( 'Subject', 'event_espresso' ), true, '' ), |
|
127 | - 'MSG_priority' => new EE_Enum_Integer_Field( 'MSG_priority', __( 'Priority', 'event_espresso' ), false, self::priority_low, $allowed_priority ), |
|
128 | - 'STS_ID' => new EE_Foreign_Key_String_Field( 'STS_ID', __( 'Status', 'event_espresso' ), false, self::status_incomplete, 'Status' ), |
|
129 | - 'MSG_created' => new EE_Datetime_Field( 'MSG_created', __( 'Created', 'event_espresso' ), false, time() ), |
|
130 | - 'MSG_modified' => new EE_Datetime_Field( 'MSG_modified', __( 'Modified', 'event_espresso' ), true, time() ) |
|
114 | + 'MSG_ID'=>new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID', 'event_espresso')), |
|
115 | + 'MSG_token' => new EE_Plain_Text_Field('MSG_token', __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', 'event_espresso'), false, EEH_URL::generate_unique_token()), |
|
116 | + 'GRP_ID'=>new EE_Foreign_Key_Int_Field('GRP_ID', __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso'), true, 0, 'Message_Template_Group'), |
|
117 | + 'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', __('Foreign key to the related EE_Transaction. This is required to give context for regenerating the specific message', 'event_espresso'), true, 0, 'Transaction'), |
|
118 | + 'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', __('Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.', 'event_espresso'), false, 'email'), |
|
119 | + 'MSG_message_type' => new EE_Plain_Text_Field('MSG_message_type', __('Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso'), false, 'receipt'), |
|
120 | + 'MSG_context' => new EE_Plain_Text_Field('MSG_context', __('Context', 'event_espresso'), false), |
|
121 | + 'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field('MSG_recipient_ID', __('Recipient ID', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')), |
|
122 | + 'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field('MSG_recipient_type', __('Recipient Type', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')), |
|
123 | + 'MSG_content' => new EE_Maybe_Serialized_Text_Field('MSG_content', __('Content', 'event_espresso'), true, ''), |
|
124 | + 'MSG_to' => new EE_Maybe_Serialized_Text_Field('MSG_to', __('Address To', 'event_espresso'), true), |
|
125 | + 'MSG_from' => new EE_Maybe_Serialized_Text_Field('MSG_from', __('Address From', 'event_espresso'), true), |
|
126 | + 'MSG_subject' => new EE_Maybe_Serialized_Text_Field('MSG_subject', __('Subject', 'event_espresso'), true, ''), |
|
127 | + 'MSG_priority' => new EE_Enum_Integer_Field('MSG_priority', __('Priority', 'event_espresso'), false, self::priority_low, $allowed_priority), |
|
128 | + 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status', 'event_espresso'), false, self::status_incomplete, 'Status'), |
|
129 | + 'MSG_created' => new EE_Datetime_Field('MSG_created', __('Created', 'event_espresso'), false, time()), |
|
130 | + 'MSG_modified' => new EE_Datetime_Field('MSG_modified', __('Modified', 'event_espresso'), true, time()) |
|
131 | 131 | ) |
132 | 132 | ); |
133 | 133 | $this->_model_relations = array( |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | 'Message_Template_Group' => new EE_Belongs_To_Relation(), |
138 | 138 | 'Transaction' => new EE_Belongs_To_Relation() |
139 | 139 | ); |
140 | - parent::__construct( $timezone ); |
|
140 | + parent::__construct($timezone); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | public function create_default_object() { |
149 | 149 | /** @type EE_Message $message */ |
150 | 150 | $message = parent::create_default_object(); |
151 | - if ( $message instanceof EE_Message ) { |
|
152 | - return EE_Message_Factory::set_messenger_and_message_type( $message ); |
|
151 | + if ($message instanceof EE_Message) { |
|
152 | + return EE_Message_Factory::set_messenger_and_message_type($message); |
|
153 | 153 | } |
154 | 154 | return null; |
155 | 155 | } |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | * @param mixed $cols_n_values |
161 | 161 | * @return \EE_Message |
162 | 162 | */ |
163 | - public function instantiate_class_from_array_or_object( $cols_n_values ) { |
|
163 | + public function instantiate_class_from_array_or_object($cols_n_values) { |
|
164 | 164 | /** @type EE_Message $message */ |
165 | - $message = parent::instantiate_class_from_array_or_object( $cols_n_values ); |
|
166 | - if ( $message instanceof EE_Message ) { |
|
167 | - return EE_Message_Factory::set_messenger_and_message_type( $message ); |
|
165 | + $message = parent::instantiate_class_from_array_or_object($cols_n_values); |
|
166 | + if ($message instanceof EE_Message) { |
|
167 | + return EE_Message_Factory::set_messenger_and_message_type($message); |
|
168 | 168 | } |
169 | 169 | return null; |
170 | 170 | } |
@@ -177,13 +177,13 @@ discard block |
||
177 | 177 | * @param string $message_type the message type slug |
178 | 178 | * @return boolean |
179 | 179 | */ |
180 | - public function message_sent_for_attendee( $attendee, $message_type ) { |
|
181 | - $attendee_ID = EEM_Attendee::instance()->ensure_is_ID( $attendee ); |
|
182 | - return $this->exists( array( array( |
|
180 | + public function message_sent_for_attendee($attendee, $message_type) { |
|
181 | + $attendee_ID = EEM_Attendee::instance()->ensure_is_ID($attendee); |
|
182 | + return $this->exists(array(array( |
|
183 | 183 | 'Attendee.ATT_ID' => $attendee_ID, |
184 | 184 | 'MSG_message_type' => $message_type, |
185 | - 'STS_ID' => array( 'IN', $this->stati_indicating_sent() ) |
|
186 | - ) ) ); |
|
185 | + 'STS_ID' => array('IN', $this->stati_indicating_sent()) |
|
186 | + ))); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | |
@@ -195,13 +195,13 @@ discard block |
||
195 | 195 | * @param string $message_type the message type slug |
196 | 196 | * @return boolean |
197 | 197 | */ |
198 | - public function message_sent_for_registration( $registration, $message_type ) { |
|
199 | - $registrationID = EEM_Registration::instance()->ensure_is_ID( $registration ); |
|
200 | - return $this->exists( array( array( |
|
198 | + public function message_sent_for_registration($registration, $message_type) { |
|
199 | + $registrationID = EEM_Registration::instance()->ensure_is_ID($registration); |
|
200 | + return $this->exists(array(array( |
|
201 | 201 | 'Registration.REG_ID' => $registrationID, |
202 | 202 | 'MSG_message_type' => $message_type, |
203 | - 'STS_ID' => array( 'IN', $this->stati_indicating_sent() ) |
|
204 | - ) ) ); |
|
203 | + 'STS_ID' => array('IN', $this->stati_indicating_sent()) |
|
204 | + ))); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | * @param string $token |
213 | 213 | * @return EE_Message |
214 | 214 | */ |
215 | - public function get_one_by_token( $token ) { |
|
216 | - return $this->get_one( array( array( |
|
215 | + public function get_one_by_token($token) { |
|
216 | + return $this->get_one(array(array( |
|
217 | 217 | 'MSG_token' => $token |
218 | - ) ) ); |
|
218 | + ))); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | * Returns stati that indicate the message HAS been sent |
224 | 224 | * @return array of strings for possible stati |
225 | 225 | */ |
226 | - public function stati_indicating_sent(){ |
|
227 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_sent', array( self::status_sent ) ); |
|
226 | + public function stati_indicating_sent() { |
|
227 | + return apply_filters('FHEE__EEM_Message__stati_indicating_sent', array(self::status_sent)); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | |
@@ -235,13 +235,13 @@ discard block |
||
235 | 235 | * @return array of strings for possible stati. |
236 | 236 | */ |
237 | 237 | public function stati_indicating_to_send() { |
238 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_to_send', array( self::status_idle, self::status_resend ) ); |
|
238 | + return apply_filters('FHEE__EEM_Message__stati_indicating_to_send', array(self::status_idle, self::status_resend)); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | |
242 | 242 | |
243 | 243 | public function stati_indicating_failed_sending() { |
244 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_failed_sending', array( self::status_failed, self::status_retry ) ); |
|
244 | + return apply_filters('FHEE__EEM_Message__stati_indicating_failed_sending', array(self::status_failed, self::status_retry)); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | |
@@ -275,11 +275,11 @@ discard block |
||
275 | 275 | // the value, matches the corresponding EEM_Base child reference. |
276 | 276 | $expected_vars = $this->_expected_vars_for_query_inject(); |
277 | 277 | $query_params[0] = array(); |
278 | - foreach ( $expected_vars as $request_key => $model_name ) { |
|
279 | - $request_value = EE_Registry::instance()->REQ->get( $request_key ); |
|
280 | - if ( $request_value ) { |
|
278 | + foreach ($expected_vars as $request_key => $model_name) { |
|
279 | + $request_value = EE_Registry::instance()->REQ->get($request_key); |
|
280 | + if ($request_value) { |
|
281 | 281 | //special case |
282 | - switch ( $request_key ) { |
|
282 | + switch ($request_key) { |
|
283 | 283 | case '_REG_ID' : |
284 | 284 | $query_params[0]['AND**filter_by']['OR**filter_by_REG_ID'] = array( |
285 | 285 | 'Transaction.Registration.REG_ID' => $request_value, |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | ); |
292 | 292 | break; |
293 | 293 | default : |
294 | - $query_params[0]['AND**filter_by'][ 'OR**filter_by_' . $request_key ][ $model_name . '.' . $request_key ] = $request_value; |
|
294 | + $query_params[0]['AND**filter_by']['OR**filter_by_'.$request_key][$model_name.'.'.$request_key] = $request_value; |
|
295 | 295 | break; |
296 | 296 | } |
297 | 297 | } |
@@ -307,53 +307,53 @@ discard block |
||
307 | 307 | $expected_vars = $this->_expected_vars_for_query_inject(); |
308 | 308 | $pretty_label = ''; |
309 | 309 | $label_parts = array(); |
310 | - foreach ( $expected_vars as $request_key => $model_name ) { |
|
311 | - $model = EE_Registry::instance()->load_model( $model_name ); |
|
312 | - if ( $model_field_value = EE_Registry::instance()->REQ->get( $request_key ) ) { |
|
313 | - switch ( $request_key ) { |
|
310 | + foreach ($expected_vars as $request_key => $model_name) { |
|
311 | + $model = EE_Registry::instance()->load_model($model_name); |
|
312 | + if ($model_field_value = EE_Registry::instance()->REQ->get($request_key)) { |
|
313 | + switch ($request_key) { |
|
314 | 314 | case '_REG_ID' : |
315 | 315 | $label_parts[] = sprintf( |
316 | - esc_html__( 'Registration with the ID: %s', 'event_espresso' ), |
|
316 | + esc_html__('Registration with the ID: %s', 'event_espresso'), |
|
317 | 317 | $model_field_value |
318 | 318 | ); |
319 | 319 | break; |
320 | 320 | case 'ATT_ID' : |
321 | 321 | /** @var EE_Attendee $attendee */ |
322 | - $attendee = $model->get_one_by_ID( $model_field_value ); |
|
322 | + $attendee = $model->get_one_by_ID($model_field_value); |
|
323 | 323 | $label_parts[] = $attendee instanceof EE_Attendee |
324 | - ? sprintf( esc_html__( 'Attendee %s', 'event_espresso' ), $attendee->full_name() ) |
|
325 | - : sprintf( esc_html__( 'Attendee ID: %s', 'event_espresso' ), $model_field_value ); |
|
324 | + ? sprintf(esc_html__('Attendee %s', 'event_espresso'), $attendee->full_name()) |
|
325 | + : sprintf(esc_html__('Attendee ID: %s', 'event_espresso'), $model_field_value); |
|
326 | 326 | break; |
327 | 327 | case 'ID' : |
328 | 328 | /** @var EE_WP_User $wpUser */ |
329 | - $wpUser = $model->get_one_by_ID( $model_field_value ); |
|
329 | + $wpUser = $model->get_one_by_ID($model_field_value); |
|
330 | 330 | $label_parts[] = $wpUser instanceof EE_WP_User |
331 | - ? sprintf( esc_html__( 'WP User: %s', 'event_espresso' ), $wpUser->name() ) |
|
332 | - : sprintf( esc_html__( 'WP User ID: %s', 'event_espresso' ), $model_field_value ); |
|
331 | + ? sprintf(esc_html__('WP User: %s', 'event_espresso'), $wpUser->name()) |
|
332 | + : sprintf(esc_html__('WP User ID: %s', 'event_espresso'), $model_field_value); |
|
333 | 333 | break; |
334 | 334 | case 'TXN_ID' : |
335 | 335 | $label_parts[] = sprintf( |
336 | - esc_html__( 'Transaction with the ID: %s', 'event_espresso' ), |
|
336 | + esc_html__('Transaction with the ID: %s', 'event_espresso'), |
|
337 | 337 | $model_field_value |
338 | 338 | ); |
339 | 339 | break; |
340 | 340 | case 'EVT_ID' : |
341 | 341 | /** @var EE_Event $Event */ |
342 | - $Event = $model->get_one_by_ID( $model_field_value ); |
|
342 | + $Event = $model->get_one_by_ID($model_field_value); |
|
343 | 343 | $label_parts[] = $Event instanceof EE_Event |
344 | - ? sprintf( esc_html__( 'for the Event: %s', 'event_espresso' ), $Event->name() ) |
|
345 | - : sprintf( esc_html__( 'for the Event with ID: %s', 'event_espresso' ), $model_field_value ); |
|
344 | + ? sprintf(esc_html__('for the Event: %s', 'event_espresso'), $Event->name()) |
|
345 | + : sprintf(esc_html__('for the Event with ID: %s', 'event_espresso'), $model_field_value); |
|
346 | 346 | break; |
347 | 347 | } |
348 | 348 | } |
349 | 349 | } |
350 | 350 | |
351 | - if ( $label_parts ) { |
|
351 | + if ($label_parts) { |
|
352 | 352 | |
353 | 353 | //prepend to the last element of $label_parts an "and". |
354 | - if ( count( $label_parts ) > 1 ) { |
|
355 | - $label_parts_index_to_prepend = count( $label_parts ) - 1; |
|
356 | - $label_parts[ $label_parts_index_to_prepend ] = 'and' . $label_parts[ $label_parts_index_to_prepend ]; |
|
354 | + if (count($label_parts) > 1) { |
|
355 | + $label_parts_index_to_prepend = count($label_parts) - 1; |
|
356 | + $label_parts[$label_parts_index_to_prepend] = 'and'.$label_parts[$label_parts_index_to_prepend]; |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | $pretty_label .= sprintf( |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | 'A label for the messages returned in a query that are filtered by items in the query. This could be Transaction, Event, Attendee, Registration, or WP_User.', |
363 | 363 | 'event_espresso' |
364 | 364 | ), |
365 | - implode( ', ', $label_parts ) |
|
365 | + implode(', ', $label_parts) |
|
366 | 366 | ); |
367 | 367 | } |
368 | 368 | return $pretty_label; |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param \EE_Message_Repository $message_repository |
73 | 73 | */ |
74 | - public function __construct( EE_Message_Repository $message_repository ) { |
|
75 | - $this->_batch_count = apply_filters( 'FHEE__EE_Messages_Queue___batch_count', 50 ); |
|
74 | + public function __construct(EE_Message_Repository $message_repository) { |
|
75 | + $this->_batch_count = apply_filters('FHEE__EE_Messages_Queue___batch_count', 50); |
|
76 | 76 | $this->_rate_limit = $this->get_rate_limit(); |
77 | 77 | $this->_queue = $message_repository; |
78 | 78 | } |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | * use the messenger send method but typically is based on preview data. |
92 | 92 | * @return bool Whether the message was successfully added to the repository or not. |
93 | 93 | */ |
94 | - public function add( EE_Message $message, $data = array(), $preview = false, $test_send = false ) { |
|
94 | + public function add(EE_Message $message, $data = array(), $preview = false, $test_send = false) { |
|
95 | 95 | $data['preview'] = $preview; |
96 | 96 | $data['test_send'] = $test_send; |
97 | - return $this->_queue->add( $message, $data ); |
|
97 | + return $this->_queue->add($message, $data); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | * @param bool $persist This flag indicates whether to attempt to delete the object from the db as well. |
107 | 107 | * @return bool |
108 | 108 | */ |
109 | - public function remove( EE_Message $message, $persist = false ) { |
|
110 | - if ( $persist && $this->_queue->current() !== $message ) { |
|
109 | + public function remove(EE_Message $message, $persist = false) { |
|
110 | + if ($persist && $this->_queue->current() !== $message) { |
|
111 | 111 | //get pointer on right message |
112 | - if ( $this->_queue->has( $message ) ) { |
|
112 | + if ($this->_queue->has($message)) { |
|
113 | 113 | $this->_queue->rewind(); |
114 | - while( $this->_queue->valid() ) { |
|
115 | - if ( $this->_queue->current() === $message ) { |
|
114 | + while ($this->_queue->valid()) { |
|
115 | + if ($this->_queue->current() === $message) { |
|
116 | 116 | break; |
117 | 117 | } |
118 | 118 | $this->_queue->next(); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | return false; |
122 | 122 | } |
123 | 123 | } |
124 | - return $persist ? $this->_queue->delete() : $this->_queue->remove( $message ); |
|
124 | + return $persist ? $this->_queue->delete() : $this->_queue->remove($message); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
@@ -161,29 +161,29 @@ discard block |
||
161 | 161 | * @return bool true if successfully retrieved batch, false no batch ready. |
162 | 162 | */ |
163 | 163 | public function get_batch_to_generate() { |
164 | - if ( $this->is_locked( EE_Messages_Queue::action_generating ) ) { |
|
164 | + if ($this->is_locked(EE_Messages_Queue::action_generating)) { |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | 168 | //lock batch generation to prevent race conditions. |
169 | - $this->lock_queue( EE_Messages_Queue::action_generating ); |
|
169 | + $this->lock_queue(EE_Messages_Queue::action_generating); |
|
170 | 170 | |
171 | 171 | $query_args = array( |
172 | 172 | // key 0 = where conditions |
173 | - 0 => array( 'STS_ID' => EEM_Message::status_incomplete ), |
|
173 | + 0 => array('STS_ID' => EEM_Message::status_incomplete), |
|
174 | 174 | 'order_by' => $this->_get_priority_orderby(), |
175 | 175 | 'limit' => $this->_batch_count |
176 | 176 | ); |
177 | - $messages = EEM_Message::instance()->get_all( $query_args ); |
|
177 | + $messages = EEM_Message::instance()->get_all($query_args); |
|
178 | 178 | |
179 | - if ( ! $messages ) { |
|
179 | + if ( ! $messages) { |
|
180 | 180 | return false; //nothing to generate |
181 | 181 | } |
182 | 182 | |
183 | - foreach ( $messages as $message ) { |
|
184 | - if ( $message instanceof EE_Message ) { |
|
183 | + foreach ($messages as $message) { |
|
184 | + if ($message instanceof EE_Message) { |
|
185 | 185 | $data = $message->all_extra_meta_array(); |
186 | - $this->add( $message, $data ); |
|
186 | + $this->add($message, $data); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | return true; |
@@ -206,34 +206,34 @@ discard block |
||
206 | 206 | * to assist with notifying user. |
207 | 207 | */ |
208 | 208 | public function get_to_send_batch_and_send() { |
209 | - if ( $this->is_locked( EE_Messages_Queue::action_sending ) || $this->_rate_limit < 1 ) { |
|
209 | + if ($this->is_locked(EE_Messages_Queue::action_sending) || $this->_rate_limit < 1) { |
|
210 | 210 | return false; |
211 | 211 | } |
212 | 212 | |
213 | - $this->lock_queue( EE_Messages_Queue::action_sending ); |
|
213 | + $this->lock_queue(EE_Messages_Queue::action_sending); |
|
214 | 214 | |
215 | 215 | $batch = $this->_batch_count < $this->_rate_limit ? $this->_batch_count : $this->_rate_limit; |
216 | 216 | |
217 | 217 | $query_args = array( |
218 | 218 | // key 0 = where conditions |
219 | - 0 => array( 'STS_ID' => array( 'IN', EEM_Message::instance()->stati_indicating_to_send() ) ), |
|
219 | + 0 => array('STS_ID' => array('IN', EEM_Message::instance()->stati_indicating_to_send())), |
|
220 | 220 | 'order_by' => $this->_get_priority_orderby(), |
221 | 221 | 'limit' => $batch |
222 | 222 | ); |
223 | 223 | |
224 | - $messages_to_send = EEM_Message::instance()->get_all( $query_args ); |
|
224 | + $messages_to_send = EEM_Message::instance()->get_all($query_args); |
|
225 | 225 | |
226 | 226 | |
227 | 227 | //any to send? |
228 | - if ( ! $messages_to_send ) { |
|
229 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
228 | + if ( ! $messages_to_send) { |
|
229 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
230 | 230 | return false; |
231 | 231 | } |
232 | 232 | |
233 | 233 | //add to queue. |
234 | - foreach ( $messages_to_send as $message ) { |
|
235 | - if ( $message instanceof EE_Message ) { |
|
236 | - $this->add( $message ); |
|
234 | + foreach ($messages_to_send as $message) { |
|
235 | + if ($message instanceof EE_Message) { |
|
236 | + $this->add($message); |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $this->execute(); |
242 | 242 | |
243 | 243 | //release lock |
244 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
244 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
245 | 245 | return true; |
246 | 246 | } |
247 | 247 | |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @param string $type The type of queue being locked. |
255 | 255 | */ |
256 | - public function lock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
257 | - set_transient( $this->_get_lock_key( $type ), 1, $this->_get_lock_expiry( $type ) ); |
|
256 | + public function lock_queue($type = EE_Messages_Queue::action_generating) { |
|
257 | + set_transient($this->_get_lock_key($type), 1, $this->_get_lock_expiry($type)); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @param string $type The type of queue being unlocked. |
267 | 267 | */ |
268 | - public function unlock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
269 | - delete_transient( $this->_get_lock_key( $type ) ); |
|
268 | + public function unlock_queue($type = EE_Messages_Queue::action_generating) { |
|
269 | + delete_transient($this->_get_lock_key($type)); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | * @param string $type The type of lock. |
278 | 278 | * @return string |
279 | 279 | */ |
280 | - protected function _get_lock_key( $type = EE_Messages_Queue::action_generating ) { |
|
281 | - return '_ee_lock_' . $type; |
|
280 | + protected function _get_lock_key($type = EE_Messages_Queue::action_generating) { |
|
281 | + return '_ee_lock_'.$type; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | * @param string $type The type of lock |
290 | 290 | * @return int time to expiry in seconds. |
291 | 291 | */ |
292 | - protected function _get_lock_expiry( $type = EE_Messages_Queue::action_generating ) { |
|
293 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type ); |
|
292 | + protected function _get_lock_expiry($type = EE_Messages_Queue::action_generating) { |
|
293 | + return (int) apply_filters('FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * @return int |
309 | 309 | */ |
310 | 310 | protected function _get_rate_limit_expiry() { |
311 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS ); |
|
311 | + return (int) apply_filters('FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @return int |
320 | 320 | */ |
321 | 321 | protected function _default_rate_limit() { |
322 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue___rate_limit', 200 ); |
|
322 | + return (int) apply_filters('FHEE__EE_Messages_Queue___rate_limit', 200); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -345,8 +345,8 @@ discard block |
||
345 | 345 | * @param string $type The type of lock being checked for. |
346 | 346 | * @return bool |
347 | 347 | */ |
348 | - public function is_locked( $type = EE_Messages_Queue::action_generating ) { |
|
349 | - return (bool) get_transient( $this->_get_lock_key( $type ) ); |
|
348 | + public function is_locked($type = EE_Messages_Queue::action_generating) { |
|
349 | + return (bool) get_transient($this->_get_lock_key($type)); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | |
@@ -361,9 +361,9 @@ discard block |
||
361 | 361 | * @return int |
362 | 362 | */ |
363 | 363 | public function get_rate_limit() { |
364 | - if ( ! $rate_limit = get_transient( $this->_get_rate_limit_key() ) ) { |
|
364 | + if ( ! $rate_limit = get_transient($this->_get_rate_limit_key())) { |
|
365 | 365 | $rate_limit = $this->_default_rate_limit(); |
366 | - set_transient( $this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key() ); |
|
366 | + set_transient($this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key()); |
|
367 | 367 | } |
368 | 368 | return $rate_limit; |
369 | 369 | } |
@@ -375,12 +375,12 @@ discard block |
||
375 | 375 | * This updates existing rate limit with the new limit which is the old minus the batch. |
376 | 376 | * @param int $batch_completed This sets the new rate limit based on the given batch that was completed. |
377 | 377 | */ |
378 | - public function set_rate_limit( $batch_completed ) { |
|
378 | + public function set_rate_limit($batch_completed) { |
|
379 | 379 | //first get the most up to date rate limit (in case its expired and reset) |
380 | 380 | $rate_limit = $this->get_rate_limit(); |
381 | 381 | $new_limit = $rate_limit - $batch_completed; |
382 | 382 | //updating the transient option directly to avoid resetting the expiry. |
383 | - update_option( '_transient_' . $this->_get_rate_limit_key(), $new_limit ); |
|
383 | + update_option('_transient_'.$this->_get_rate_limit_key(), $new_limit); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * @param string $task This indicates what type of request is going to be initiated. |
394 | 394 | * @param int $priority This indicates the priority that triggers initiating the request. |
395 | 395 | */ |
396 | - public function initiate_request_by_priority( $task = 'generate', $priority = EEM_Message::priority_high ) { |
|
396 | + public function initiate_request_by_priority($task = 'generate', $priority = EEM_Message::priority_high) { |
|
397 | 397 | //determine what status is matched with the priority as part of the trigger conditions. |
398 | 398 | $status = $task == 'generate' |
399 | 399 | ? EEM_Message::status_incomplete |
@@ -401,8 +401,8 @@ discard block |
||
401 | 401 | // always make sure we save because either this will get executed immediately on a separate request |
402 | 402 | // or remains in the queue for the regularly scheduled queue batch. |
403 | 403 | $this->save(); |
404 | - if ( $this->_queue->count_by_priority_and_status( $priority, $status ) ) { |
|
405 | - EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( $task ); |
|
404 | + if ($this->_queue->count_by_priority_and_status($priority, $status)) { |
|
405 | + EE_Messages_Scheduler::initiate_scheduled_non_blocking_request($task); |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
@@ -427,50 +427,50 @@ discard block |
||
427 | 427 | * Also, if the messenger is an request type messenger (or a preview), |
428 | 428 | * its entirely possible that the messenger will exit before |
429 | 429 | */ |
430 | - public function execute( $save = true, $sending_messenger = null, $by_priority = false ) { |
|
430 | + public function execute($save = true, $sending_messenger = null, $by_priority = false) { |
|
431 | 431 | $messages_sent = 0; |
432 | 432 | $this->_did_hook = array(); |
433 | 433 | $this->_queue->rewind(); |
434 | - while ( $this->_queue->valid() ) { |
|
434 | + while ($this->_queue->valid()) { |
|
435 | 435 | $error_messages = array(); |
436 | 436 | /** @type EE_Message $message */ |
437 | 437 | $message = $this->_queue->current(); |
438 | 438 | //if the message in the queue has a sent status, then skip |
439 | - if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_sent() ) ) { |
|
439 | + if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_sent())) { |
|
440 | 440 | continue; |
441 | 441 | } |
442 | 442 | //if $by_priority is set and does not match then continue; |
443 | - if ( $by_priority && $by_priority != $message->priority() ) { |
|
443 | + if ($by_priority && $by_priority != $message->priority()) { |
|
444 | 444 | continue; |
445 | 445 | } |
446 | 446 | //error checking |
447 | - if ( ! $message->valid_messenger() ) { |
|
447 | + if ( ! $message->valid_messenger()) { |
|
448 | 448 | $error_messages[] = sprintf( |
449 | - __( 'The %s messenger is not active at time of sending.', 'event_espresso' ), |
|
449 | + __('The %s messenger is not active at time of sending.', 'event_espresso'), |
|
450 | 450 | $message->messenger() |
451 | 451 | ); |
452 | 452 | } |
453 | - if ( ! $message->valid_message_type() ) { |
|
453 | + if ( ! $message->valid_message_type()) { |
|
454 | 454 | $error_messages[] = sprintf( |
455 | - __( 'The %s message type is not active at the time of sending.', 'event_espresso' ), |
|
455 | + __('The %s message type is not active at the time of sending.', 'event_espresso'), |
|
456 | 456 | $message->message_type() |
457 | 457 | ); |
458 | 458 | } |
459 | 459 | // if there was supposed to be a sending messenger for this message, but it was invalid/inactive, |
460 | 460 | // then it will instead be an EE_Error object, so let's check for that |
461 | - if ( $sending_messenger instanceof EE_Error ) { |
|
461 | + if ($sending_messenger instanceof EE_Error) { |
|
462 | 462 | $error_messages[] = $sending_messenger->getMessage(); |
463 | 463 | } |
464 | 464 | // if there are no errors, then let's process the message |
465 | - if ( empty( $error_messages ) && $this->_process_message( $message, $sending_messenger ) ) { |
|
465 | + if (empty($error_messages) && $this->_process_message($message, $sending_messenger)) { |
|
466 | 466 | $messages_sent++; |
467 | 467 | } |
468 | - $this->_set_error_message( $message, $error_messages ); |
|
468 | + $this->_set_error_message($message, $error_messages); |
|
469 | 469 | //add modified time |
470 | - $message->set_modified( time() ); |
|
470 | + $message->set_modified(time()); |
|
471 | 471 | $this->_queue->next(); |
472 | 472 | } |
473 | - if ( $save ) { |
|
473 | + if ($save) { |
|
474 | 474 | $this->save(); |
475 | 475 | } |
476 | 476 | return $messages_sent; |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | * @param mixed $sending_messenger (optional) |
486 | 486 | * @return bool |
487 | 487 | */ |
488 | - protected function _process_message( EE_Message $message, $sending_messenger = null ) { |
|
488 | + protected function _process_message(EE_Message $message, $sending_messenger = null) { |
|
489 | 489 | // these *should* have been validated in the execute() method above |
490 | 490 | $messenger = $message->messenger_object(); |
491 | 491 | $message_type = $message->message_type_object(); |
@@ -495,20 +495,20 @@ discard block |
||
495 | 495 | && $messenger instanceof EE_messenger |
496 | 496 | && $sending_messenger->name != $messenger->name |
497 | 497 | ) { |
498 | - $messenger->do_secondary_messenger_hooks( $sending_messenger->name ); |
|
498 | + $messenger->do_secondary_messenger_hooks($sending_messenger->name); |
|
499 | 499 | $messenger = $sending_messenger; |
500 | 500 | } |
501 | 501 | // send using messenger, but double check objects |
502 | - if ( $messenger instanceof EE_messenger && $message_type instanceof EE_message_type ) { |
|
502 | + if ($messenger instanceof EE_messenger && $message_type instanceof EE_message_type) { |
|
503 | 503 | //set hook for message type (but only if not using another messenger to send). |
504 | - if ( ! isset( $this->_did_hook[ $message_type->name ] ) ) { |
|
505 | - $message_type->do_messenger_hooks( $messenger ); |
|
506 | - $this->_did_hook[ $message_type->name ] = 1; |
|
504 | + if ( ! isset($this->_did_hook[$message_type->name])) { |
|
505 | + $message_type->do_messenger_hooks($messenger); |
|
506 | + $this->_did_hook[$message_type->name] = 1; |
|
507 | 507 | } |
508 | 508 | //if preview then use preview method |
509 | 509 | return $this->_queue->is_preview() |
510 | - ? $this->_do_preview( $message, $messenger, $message_type, $this->_queue->is_test_send() ) |
|
511 | - : $this->_do_send( $message, $messenger, $message_type ); |
|
510 | + ? $this->_do_preview($message, $messenger, $message_type, $this->_queue->is_test_send()) |
|
511 | + : $this->_do_send($message, $messenger, $message_type); |
|
512 | 512 | } |
513 | 513 | return false; |
514 | 514 | } |
@@ -526,12 +526,12 @@ discard block |
||
526 | 526 | * @param array $status Stati to check for in queue |
527 | 527 | * @return int Count of EE_Message's matching the given status. |
528 | 528 | */ |
529 | - public function count_STS_in_queue( $status ) { |
|
529 | + public function count_STS_in_queue($status) { |
|
530 | 530 | $count = 0; |
531 | - $status = is_array( $status ) ? $status : array( $status ); |
|
531 | + $status = is_array($status) ? $status : array($status); |
|
532 | 532 | $this->_queue->rewind(); |
533 | - foreach( $this->_queue as $message ) { |
|
534 | - if ( in_array( $message->STS_ID(), $status ) ) { |
|
533 | + foreach ($this->_queue as $message) { |
|
534 | + if (in_array($message->STS_ID(), $status)) { |
|
535 | 535 | $count++; |
536 | 536 | } |
537 | 537 | } |
@@ -548,15 +548,15 @@ discard block |
||
548 | 548 | * @param $test_send |
549 | 549 | * @return bool true means all went well, false means, not so much. |
550 | 550 | */ |
551 | - protected function _do_preview( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send ) { |
|
552 | - if ( $preview = $messenger->get_preview( $message, $message_type, $test_send ) ) { |
|
553 | - if ( ! $test_send ) { |
|
554 | - $message->set_content( $preview ); |
|
551 | + protected function _do_preview(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send) { |
|
552 | + if ($preview = $messenger->get_preview($message, $message_type, $test_send)) { |
|
553 | + if ( ! $test_send) { |
|
554 | + $message->set_content($preview); |
|
555 | 555 | } |
556 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
556 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
557 | 557 | return true; |
558 | 558 | } else { |
559 | - $message->set_STS_ID( EEM_Message::status_failed ); |
|
559 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
560 | 560 | return false; |
561 | 561 | } |
562 | 562 | } |
@@ -572,12 +572,12 @@ discard block |
||
572 | 572 | * @param EE_message_type $message_type |
573 | 573 | * @return bool true means all went well, false means, not so much. |
574 | 574 | */ |
575 | - protected function _do_send( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type ) { |
|
576 | - if ( $messenger->send_message( $message, $message_type ) ) { |
|
577 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
575 | + protected function _do_send(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type) { |
|
576 | + if ($messenger->send_message($message, $message_type)) { |
|
577 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
578 | 578 | return true; |
579 | 579 | } else { |
580 | - $message->set_STS_ID( EEM_Message::status_retry ); |
|
580 | + $message->set_STS_ID(EEM_Message::status_retry); |
|
581 | 581 | return false; |
582 | 582 | } |
583 | 583 | } |
@@ -591,21 +591,21 @@ discard block |
||
591 | 591 | * @param EE_Message $message |
592 | 592 | * @param array $error_messages the response from the messenger. |
593 | 593 | */ |
594 | - protected function _set_error_message( EE_Message $message, $error_messages ) { |
|
594 | + protected function _set_error_message(EE_Message $message, $error_messages) { |
|
595 | 595 | $error_messages = (array) $error_messages; |
596 | - if ( $message->STS_ID() === EEM_Message::status_failed || $message->STS_ID() === EEM_Message::status_retry ) { |
|
596 | + if ($message->STS_ID() === EEM_Message::status_failed || $message->STS_ID() === EEM_Message::status_retry) { |
|
597 | 597 | $notices = EE_Error::has_notices(); |
598 | - $error_messages[] = __( 'Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso' ); |
|
599 | - if ( $notices === 1 ) { |
|
598 | + $error_messages[] = __('Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso'); |
|
599 | + if ($notices === 1) { |
|
600 | 600 | $notices = EE_Error::get_vanilla_notices(); |
601 | - $notices['errors'] = isset( $notices['errors'] ) ? $notices['errors'] : array(); |
|
602 | - $error_messages[] = implode( "\n", $notices['errors'] ); |
|
601 | + $notices['errors'] = isset($notices['errors']) ? $notices['errors'] : array(); |
|
602 | + $error_messages[] = implode("\n", $notices['errors']); |
|
603 | 603 | } |
604 | 604 | } |
605 | - if ( count( $error_messages ) > 0 ) { |
|
606 | - $msg = __( 'Message was not executed successfully.', 'event_espresso' ); |
|
607 | - $msg = $msg . "\n" . implode( "\n", $error_messages ); |
|
608 | - $message->set_error_message( $msg ); |
|
605 | + if (count($error_messages) > 0) { |
|
606 | + $msg = __('Message was not executed successfully.', 'event_espresso'); |
|
607 | + $msg = $msg."\n".implode("\n", $error_messages); |
|
608 | + $message->set_error_message($msg); |
|
609 | 609 | } |
610 | 610 | } |
611 | 611 |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @return EED_Module |
70 | 70 | */ |
71 | 71 | public static function instance() { |
72 | - return parent::get_instance( __CLASS__ ); |
|
72 | + return parent::get_instance(__CLASS__); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public static function set_hooks() { |
86 | 86 | //actions |
87 | - add_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', array( 'EED_Messages', 'payment' ), 10, 2 ); |
|
88 | - add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array( 'EED_Messages', 'maybe_registration' ), 10, 2 ); |
|
87 | + add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2); |
|
88 | + add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array('EED_Messages', 'maybe_registration'), 10, 2); |
|
89 | 89 | //filters |
90 | - add_filter( 'FHEE__EE_Registration__receipt_url__receipt_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
91 | - add_filter( 'FHEE__EE_Registration__invoice_url__invoice_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
90 | + add_filter('FHEE__EE_Registration__receipt_url__receipt_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
91 | + add_filter('FHEE__EE_Registration__invoice_url__invoice_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
92 | 92 | //register routes |
93 | 93 | self::_register_routes(); |
94 | 94 | } |
@@ -101,16 +101,16 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public static function set_hooks_admin() { |
103 | 103 | //actions |
104 | - add_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', array( 'EED_Messages', 'payment' ), 10, 2 ); |
|
105 | - add_action( 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', array( 'EED_Messages', 'payment_reminder' ), 10 ); |
|
106 | - add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array( 'EED_Messages', 'maybe_registration' ), 10, 3 ); |
|
107 | - add_action( 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', array( 'EED_Messages', 'send_newsletter_message' ), 10, 2 ); |
|
108 | - add_action( 'AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', array( 'EED_Messages', 'cancelled_registration' ), 10 ); |
|
109 | - add_action( 'AHEE__EE_Admin_Page___process_admin_payment_notification', array( 'EED_Messages', 'process_admin_payment' ), 10, 1 ); |
|
104 | + add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2); |
|
105 | + add_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', array('EED_Messages', 'payment_reminder'), 10); |
|
106 | + add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array('EED_Messages', 'maybe_registration'), 10, 3); |
|
107 | + add_action('AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', array('EED_Messages', 'send_newsletter_message'), 10, 2); |
|
108 | + add_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', array('EED_Messages', 'cancelled_registration'), 10); |
|
109 | + add_action('AHEE__EE_Admin_Page___process_admin_payment_notification', array('EED_Messages', 'process_admin_payment'), 10, 1); |
|
110 | 110 | //filters |
111 | - add_filter( 'FHEE__EE_Admin_Page___process_resend_registration__success', array( 'EED_Messages', 'process_resend' ), 10, 2 ); |
|
112 | - add_filter( 'FHEE__EE_Registration__receipt_url__receipt_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
113 | - add_filter( 'FHEE__EE_Registration__invoice_url__invoice_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 ); |
|
111 | + add_filter('FHEE__EE_Admin_Page___process_resend_registration__success', array('EED_Messages', 'process_resend'), 10, 2); |
|
112 | + add_filter('FHEE__EE_Registration__receipt_url__receipt_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
113 | + add_filter('FHEE__EE_Registration__invoice_url__invoice_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | * @return void |
125 | 125 | */ |
126 | 126 | protected static function _register_routes() { |
127 | - EE_Config::register_route( 'msg_url_trigger', 'Messages', 'run' ); |
|
128 | - EE_Config::register_route( 'msg_cron_trigger', 'Messages', 'run_cron' ); |
|
129 | - EE_Config::register_route( 'msg_browser_trigger', 'Messages', 'browser_trigger' ); |
|
130 | - EE_Config::register_route( 'msg_browser_error_trigger', 'Messages', 'browser_error_trigger' ); |
|
131 | - do_action( 'AHEE__EED_Messages___register_routes' ); |
|
127 | + EE_Config::register_route('msg_url_trigger', 'Messages', 'run'); |
|
128 | + EE_Config::register_route('msg_cron_trigger', 'Messages', 'run_cron'); |
|
129 | + EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger'); |
|
130 | + EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger'); |
|
131 | + do_action('AHEE__EED_Messages___register_routes'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
@@ -139,18 +139,18 @@ discard block |
||
139 | 139 | * @since 4.9.0 |
140 | 140 | * @param WP $WP |
141 | 141 | */ |
142 | - public function browser_trigger( $WP ) { |
|
142 | + public function browser_trigger($WP) { |
|
143 | 143 | //ensure controller is loaded |
144 | 144 | self::_load_controller(); |
145 | - $token = EE_Registry::instance()->REQ->get( 'token' ); |
|
145 | + $token = EE_Registry::instance()->REQ->get('token'); |
|
146 | 146 | try { |
147 | - $mtg = new EE_Message_Generated_From_Token( $token, 'html', self::$_message_resource_manager ); |
|
148 | - self::$_MSG_PROCESSOR->generate_and_send_now( $mtg ); |
|
149 | - } catch( EE_Error $e ) { |
|
150 | - $error_msg = __( 'Please note that a system message failed to send due to a technical issue.', 'event_espresso' ); |
|
147 | + $mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager); |
|
148 | + self::$_MSG_PROCESSOR->generate_and_send_now($mtg); |
|
149 | + } catch (EE_Error $e) { |
|
150 | + $error_msg = __('Please note that a system message failed to send due to a technical issue.', 'event_espresso'); |
|
151 | 151 | // add specific message for developers if WP_DEBUG in on |
152 | - $error_msg .= '||' . $e->getMessage(); |
|
153 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
152 | + $error_msg .= '||'.$e->getMessage(); |
|
153 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
@@ -166,20 +166,20 @@ discard block |
||
166 | 166 | * @since 4.9.0 |
167 | 167 | * @param $WP |
168 | 168 | */ |
169 | - public function browser_error_trigger( $WP ) { |
|
170 | - $token = EE_Registry::instance()->REQ->get( 'token' ); |
|
171 | - if ( $token ) { |
|
172 | - $message = EEM_Message::instance()->get_one_by_token( $token ); |
|
173 | - if ( $message instanceof EE_Message ) { |
|
174 | - header( 'HTTP/1.1 200 OK' ); |
|
175 | - $error_msg = nl2br( $message->error_message() ); |
|
169 | + public function browser_error_trigger($WP) { |
|
170 | + $token = EE_Registry::instance()->REQ->get('token'); |
|
171 | + if ($token) { |
|
172 | + $message = EEM_Message::instance()->get_one_by_token($token); |
|
173 | + if ($message instanceof EE_Message) { |
|
174 | + header('HTTP/1.1 200 OK'); |
|
175 | + $error_msg = nl2br($message->error_message()); |
|
176 | 176 | ?> |
177 | 177 | <!DOCTYPE html> |
178 | 178 | <html> |
179 | 179 | <head></head> |
180 | 180 | <body> |
181 | - <?php echo empty( $error_msg ) |
|
182 | - ? esc_html__( 'Unfortunately, we were unable to capture the error message for this message.', 'event_espresso' ) |
|
181 | + <?php echo empty($error_msg) |
|
182 | + ? esc_html__('Unfortunately, we were unable to capture the error message for this message.', 'event_espresso') |
|
183 | 183 | : wp_kses( |
184 | 184 | $error_msg, |
185 | 185 | array( |
@@ -214,19 +214,19 @@ discard block |
||
214 | 214 | * @throws EE_Error |
215 | 215 | * @return void |
216 | 216 | */ |
217 | - public function run( $WP ) { |
|
217 | + public function run($WP) { |
|
218 | 218 | //ensure controller is loaded |
219 | 219 | self::_load_controller(); |
220 | 220 | // attempt to process message |
221 | 221 | try { |
222 | 222 | /** @type EE_Message_To_Generate_From_Request $message_to_generate */ |
223 | - $message_to_generate = EE_Registry::instance()->load_lib( 'Message_To_Generate_From_Request' ); |
|
224 | - self::$_MSG_PROCESSOR->generate_and_send_now( $message_to_generate ); |
|
225 | - } catch ( EE_Error $e ) { |
|
226 | - $error_msg = __( 'Please note that a system message failed to send due to a technical issue.', 'event_espresso' ); |
|
223 | + $message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
224 | + self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate); |
|
225 | + } catch (EE_Error $e) { |
|
226 | + $error_msg = __('Please note that a system message failed to send due to a technical issue.', 'event_espresso'); |
|
227 | 227 | // add specific message for developers if WP_DEBUG in on |
228 | - $error_msg .= '||' . $e->getMessage(); |
|
229 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
228 | + $error_msg .= '||'.$e->getMessage(); |
|
229 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
@@ -235,30 +235,30 @@ discard block |
||
235 | 235 | * This is triggered by the 'msg_cron_trigger' route. |
236 | 236 | * @param WP $WP |
237 | 237 | */ |
238 | - public function run_cron( $WP ) { |
|
238 | + public function run_cron($WP) { |
|
239 | 239 | self::_load_controller(); |
240 | 240 | //get required vars |
241 | - $cron_type = EE_Registry::instance()->REQ->get( 'type' ); |
|
242 | - $nonce = EE_Registry::instance()->REQ->get( '_nonce' ); |
|
243 | - header( 'HTTP/1.1 200 OK' ); |
|
241 | + $cron_type = EE_Registry::instance()->REQ->get('type'); |
|
242 | + $nonce = EE_Registry::instance()->REQ->get('_nonce'); |
|
243 | + header('HTTP/1.1 200 OK'); |
|
244 | 244 | |
245 | 245 | //now let's verify nonce, if not valid exit immediately |
246 | - if ( ! wp_verify_nonce( $nonce, 'EE_Messages_Scheduler_' . $cron_type ) ) { |
|
246 | + if ( ! wp_verify_nonce($nonce, 'EE_Messages_Scheduler_'.$cron_type)) { |
|
247 | 247 | /** |
248 | 248 | * trigger error so this gets in the error logs. This is important because it happens on a non-user request. |
249 | 249 | */ |
250 | - trigger_error( esc_attr__( 'Invalid Nonce', 'event_espresso' ) ); |
|
250 | + trigger_error(esc_attr__('Invalid Nonce', 'event_espresso')); |
|
251 | 251 | } |
252 | 252 | |
253 | - $method = 'batch_' . $cron_type . '_from_queue'; |
|
254 | - if ( method_exists( self::$_MSG_PROCESSOR, $method ) ) { |
|
253 | + $method = 'batch_'.$cron_type.'_from_queue'; |
|
254 | + if (method_exists(self::$_MSG_PROCESSOR, $method)) { |
|
255 | 255 | self::$_MSG_PROCESSOR->$method(); |
256 | 256 | } else { |
257 | 257 | //no matching task |
258 | 258 | /** |
259 | 259 | * trigger error so this gets in the error logs. This is important because it happens on a non user request. |
260 | 260 | */ |
261 | - trigger_error( esc_attr( sprintf( __( 'There is no task corresponding to this route %s', 'event_espresso' ), $cron_type ) ) ); |
|
261 | + trigger_error(esc_attr(sprintf(__('There is no task corresponding to this route %s', 'event_espresso'), $cron_type))); |
|
262 | 262 | } |
263 | 263 | exit(); |
264 | 264 | } |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return EE_Messages_Template_Pack |
278 | 278 | */ |
279 | - public static function get_template_pack( $template_pack_name ) { |
|
280 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
281 | - return EEH_MSG_Template::get_template_pack( $template_pack_name ); |
|
279 | + public static function get_template_pack($template_pack_name) { |
|
280 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
281 | + return EEH_MSG_Template::get_template_pack($template_pack_name); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -292,14 +292,14 @@ discard block |
||
292 | 292 | * @return EE_Messages_Template_Pack[] |
293 | 293 | */ |
294 | 294 | public static function get_template_packs() { |
295 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
295 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
296 | 296 | |
297 | 297 | //for backward compat, let's make sure this returns in the same format as originally. |
298 | 298 | $template_pack_collection = EEH_MSG_Template::get_template_pack_collection(); |
299 | 299 | $template_pack_collection->rewind(); |
300 | 300 | $template_packs = array(); |
301 | - while ( $template_pack_collection->valid() ) { |
|
302 | - $template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current(); |
|
301 | + while ($template_pack_collection->valid()) { |
|
302 | + $template_packs[$template_pack_collection->current()->dbref] = $template_pack_collection->current(); |
|
303 | 303 | $template_pack_collection->next(); |
304 | 304 | } |
305 | 305 | return $template_packs; |
@@ -315,15 +315,15 @@ discard block |
||
315 | 315 | * @return void |
316 | 316 | */ |
317 | 317 | public static function set_autoloaders() { |
318 | - if ( empty( self::$_MSG_PATHS ) ) { |
|
318 | + if (empty(self::$_MSG_PATHS)) { |
|
319 | 319 | self::_set_messages_paths(); |
320 | - EE_Registry::instance()->load_helper( 'Autoloader' ); |
|
321 | - foreach ( self::$_MSG_PATHS as $path ) { |
|
322 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $path ); |
|
320 | + EE_Registry::instance()->load_helper('Autoloader'); |
|
321 | + foreach (self::$_MSG_PATHS as $path) { |
|
322 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path); |
|
323 | 323 | } |
324 | 324 | // add aliases |
325 | - EEH_Autoloader::add_alias( 'EE_messages', 'EE_messages' ); |
|
326 | - EEH_Autoloader::add_alias( 'EE_messenger', 'EE_messenger' ); |
|
325 | + EEH_Autoloader::add_alias('EE_messages', 'EE_messages'); |
|
326 | + EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger'); |
|
327 | 327 | } |
328 | 328 | } |
329 | 329 | |
@@ -351,10 +351,10 @@ discard block |
||
351 | 351 | 'shortcodes', |
352 | 352 | ); |
353 | 353 | $paths = array(); |
354 | - foreach ( $dir_ref as $index => $dir ) { |
|
355 | - $paths[ $index ] = EE_LIBRARIES . $dir; |
|
354 | + foreach ($dir_ref as $index => $dir) { |
|
355 | + $paths[$index] = EE_LIBRARIES.$dir; |
|
356 | 356 | } |
357 | - self::$_MSG_PATHS = apply_filters( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths ); |
|
357 | + self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | |
@@ -365,12 +365,12 @@ discard block |
||
365 | 365 | * @return void |
366 | 366 | */ |
367 | 367 | protected static function _load_controller() { |
368 | - if ( ! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor ) { |
|
369 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
368 | + if ( ! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) { |
|
369 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
370 | 370 | self::set_autoloaders(); |
371 | - self::$_EEMSG = EE_Registry::instance()->load_lib( 'messages' ); |
|
372 | - self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib( 'Messages_Processor' ); |
|
373 | - self::$_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
371 | + self::$_EEMSG = EE_Registry::instance()->load_lib('messages'); |
|
372 | + self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
373 | + self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
@@ -379,10 +379,10 @@ discard block |
||
379 | 379 | /** |
380 | 380 | * @param EE_Transaction $transaction |
381 | 381 | */ |
382 | - public static function payment_reminder( EE_Transaction $transaction ) { |
|
382 | + public static function payment_reminder(EE_Transaction $transaction) { |
|
383 | 383 | self::_load_controller(); |
384 | - $data = array( $transaction, null ); |
|
385 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'payment_reminder', $data ); |
|
384 | + $data = array($transaction, null); |
|
385 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -393,14 +393,14 @@ discard block |
||
393 | 393 | * @param EE_Payment object |
394 | 394 | * @return void |
395 | 395 | */ |
396 | - public static function payment( EE_Transaction $transaction, EE_Payment $payment ) { |
|
396 | + public static function payment(EE_Transaction $transaction, EE_Payment $payment) { |
|
397 | 397 | self::_load_controller(); |
398 | - $data = array( $transaction, $payment ); |
|
399 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
400 | - $message_type = EEH_MSG_Template::convert_payment_status_to_message_type( $payment->STS_ID() ); |
|
398 | + $data = array($transaction, $payment); |
|
399 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
400 | + $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
401 | 401 | //if payment amount is less than 0 then switch to payment_refund message type. |
402 | 402 | $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
403 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( $message_type, $data ); |
|
403 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -408,10 +408,10 @@ discard block |
||
408 | 408 | /** |
409 | 409 | * @param EE_Transaction $transaction |
410 | 410 | */ |
411 | - public static function cancelled_registration( EE_Transaction $transaction ) { |
|
411 | + public static function cancelled_registration(EE_Transaction $transaction) { |
|
412 | 412 | self::_load_controller(); |
413 | - $data = array( $transaction, null ); |
|
414 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'cancelled_registration', $data ); |
|
413 | + $data = array($transaction, null); |
|
414 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | |
@@ -424,14 +424,14 @@ discard block |
||
424 | 424 | * @param array $extra_details |
425 | 425 | * @return void |
426 | 426 | */ |
427 | - public static function maybe_registration( EE_Registration $registration, $extra_details = array() ) { |
|
427 | + public static function maybe_registration(EE_Registration $registration, $extra_details = array()) { |
|
428 | 428 | |
429 | - if ( ! self::_verify_registration_notification_send( $registration, $extra_details ) ) { |
|
429 | + if ( ! self::_verify_registration_notification_send($registration, $extra_details)) { |
|
430 | 430 | //no messages please |
431 | 431 | return; |
432 | 432 | } |
433 | 433 | |
434 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
434 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
435 | 435 | |
436 | 436 | //get all registrations so we make sure we send messages for the right status. |
437 | 437 | $all_registrations = $registration->transaction()->registrations(); |
@@ -442,22 +442,22 @@ discard block |
||
442 | 442 | $mtgs = array(); |
443 | 443 | |
444 | 444 | //loop through registrations and trigger messages once per status. |
445 | - foreach ( $all_registrations as $reg ) { |
|
445 | + foreach ($all_registrations as $reg) { |
|
446 | 446 | |
447 | 447 | //already triggered? |
448 | - if ( in_array( $reg->status_ID(), $statuses_sent ) ) { |
|
448 | + if (in_array($reg->status_ID(), $statuses_sent)) { |
|
449 | 449 | continue; |
450 | 450 | } |
451 | 451 | |
452 | - $message_type = EEH_MSG_Template::convert_reg_status_to_message_type( $reg->status_ID() ); |
|
453 | - $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( $message_type, array( $registration->transaction(), null, $reg->status_ID() ) ); |
|
452 | + $message_type = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID()); |
|
453 | + $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers($message_type, array($registration->transaction(), null, $reg->status_ID())); |
|
454 | 454 | $statuses_sent[] = $reg->status_ID(); |
455 | 455 | } |
456 | 456 | |
457 | - $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( 'registration_summary', array( $registration->transaction(), null ) ); |
|
457 | + $mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers('registration_summary', array($registration->transaction(), null)); |
|
458 | 458 | |
459 | 459 | //batch queue and initiate request |
460 | - self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist( $mtgs ); |
|
460 | + self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs); |
|
461 | 461 | self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
462 | 462 | } |
463 | 463 | |
@@ -472,39 +472,39 @@ discard block |
||
472 | 472 | * |
473 | 473 | * @return bool true = send away, false = nope halt the presses. |
474 | 474 | */ |
475 | - protected static function _verify_registration_notification_send( EE_Registration $registration, $extra_details = array() ) { |
|
475 | + protected static function _verify_registration_notification_send(EE_Registration $registration, $extra_details = array()) { |
|
476 | 476 | //self::log( |
477 | 477 | // __CLASS__, __FUNCTION__, __LINE__, |
478 | 478 | // $registration->transaction(), |
479 | 479 | // array( '$extra_details' => $extra_details ) |
480 | 480 | //); |
481 | 481 | // currently only using this to send messages for the primary registrant |
482 | - if ( ! $registration->is_primary_registrant() ) { |
|
482 | + if ( ! $registration->is_primary_registrant()) { |
|
483 | 483 | return false; |
484 | 484 | } |
485 | 485 | // first we check if we're in admin and not doing front ajax |
486 | - if ( is_admin() && ! EE_FRONT_AJAX ) { |
|
486 | + if (is_admin() && ! EE_FRONT_AJAX) { |
|
487 | 487 | //make sure appropriate admin params are set for sending messages |
488 | - if ( empty( $_REQUEST['txn_reg_status_change']['send_notifications'] ) || ! absint( $_REQUEST['txn_reg_status_change']['send_notifications'] ) ) { |
|
488 | + if (empty($_REQUEST['txn_reg_status_change']['send_notifications']) || ! absint($_REQUEST['txn_reg_status_change']['send_notifications'])) { |
|
489 | 489 | //no messages sent please. |
490 | 490 | return false; |
491 | 491 | } |
492 | 492 | } else { |
493 | 493 | // frontend request (either regular or via AJAX) |
494 | 494 | // TXN is NOT finalized ? |
495 | - if ( ! isset( $extra_details['finalized'] ) || $extra_details['finalized'] === false ) { |
|
495 | + if ( ! isset($extra_details['finalized']) || $extra_details['finalized'] === false) { |
|
496 | 496 | return false; |
497 | 497 | } |
498 | 498 | // return visit but nothing changed ??? |
499 | 499 | if ( |
500 | - isset( $extra_details['revisit'], $extra_details['status_updates'] ) && |
|
500 | + isset($extra_details['revisit'], $extra_details['status_updates']) && |
|
501 | 501 | $extra_details['revisit'] && ! $extra_details['status_updates'] |
502 | 502 | ) { |
503 | 503 | return false; |
504 | 504 | } |
505 | 505 | // NOT sending messages && reg status is something other than "Not-Approved" |
506 | 506 | if ( |
507 | - ! apply_filters( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', false ) && |
|
507 | + ! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) && |
|
508 | 508 | $registration->status_ID() !== EEM_Registration::status_id_not_approved |
509 | 509 | ) { |
510 | 510 | return false; |
@@ -526,10 +526,10 @@ discard block |
||
526 | 526 | * |
527 | 527 | * @return array |
528 | 528 | */ |
529 | - protected static function _get_reg_status_array( $reg_status = '' ) { |
|
530 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
531 | - return EEH_MSG_Template::convert_reg_status_to_message_type( $reg_status ) |
|
532 | - ? EEH_MSG_Template::convert_reg_status_to_message_type( $reg_status ) |
|
529 | + protected static function _get_reg_status_array($reg_status = '') { |
|
530 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
531 | + return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
532 | + ? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
533 | 533 | : EEH_MSG_Template::reg_status_to_message_type_array(); |
534 | 534 | } |
535 | 535 | |
@@ -545,10 +545,10 @@ discard block |
||
545 | 545 | * |
546 | 546 | * @return string|bool The payment message type slug matching the status or false if no match. |
547 | 547 | */ |
548 | - protected static function _get_payment_message_type( $payment_status ) { |
|
549 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
550 | - return EEH_MSG_Template::convert_payment_status_to_message_type( $payment_status ) |
|
551 | - ? EEH_MSG_Template::convert_payment_status_to_message_type( $payment_status ) |
|
548 | + protected static function _get_payment_message_type($payment_status) { |
|
549 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
550 | + return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
551 | + ? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
552 | 552 | : false; |
553 | 553 | } |
554 | 554 | |
@@ -562,33 +562,33 @@ discard block |
||
562 | 562 | * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages |
563 | 563 | * @return bool success/fail |
564 | 564 | */ |
565 | - public static function process_resend( $req_data ) { |
|
565 | + public static function process_resend($req_data) { |
|
566 | 566 | self::_load_controller(); |
567 | 567 | |
568 | 568 | //if $msgID in this request then skip to the new resend_message |
569 | - if ( EE_Registry::instance()->REQ->get( 'MSG_ID' ) ) { |
|
569 | + if (EE_Registry::instance()->REQ->get('MSG_ID')) { |
|
570 | 570 | return self::resend_message(); |
571 | 571 | } |
572 | 572 | |
573 | 573 | //make sure any incoming request data is set on the REQ so that it gets picked up later. |
574 | 574 | $req_data = (array) $req_data; |
575 | - foreach( $req_data as $request_key => $request_value ) { |
|
576 | - EE_Registry::instance()->REQ->set( $request_key, $request_value ); |
|
575 | + foreach ($req_data as $request_key => $request_value) { |
|
576 | + EE_Registry::instance()->REQ->set($request_key, $request_value); |
|
577 | 577 | } |
578 | 578 | |
579 | - if ( ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request() ) { |
|
579 | + if ( ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request()) { |
|
580 | 580 | return false; |
581 | 581 | } |
582 | 582 | |
583 | 583 | try { |
584 | - self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist( $messages_to_send ); |
|
584 | + self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send); |
|
585 | 585 | self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
586 | - } catch( EE_Error $e ) { |
|
587 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
586 | + } catch (EE_Error $e) { |
|
587 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
588 | 588 | return false; |
589 | 589 | } |
590 | 590 | EE_Error::add_success( |
591 | - __( 'Messages have been successfully queued for generation and sending.', 'event_espresso' ) |
|
591 | + __('Messages have been successfully queued for generation and sending.', 'event_espresso') |
|
592 | 592 | ); |
593 | 593 | return true; //everything got queued. |
594 | 594 | } |
@@ -601,17 +601,17 @@ discard block |
||
601 | 601 | public static function resend_message() { |
602 | 602 | self::_load_controller(); |
603 | 603 | |
604 | - $msgID = EE_Registry::instance()->REQ->get( 'MSG_ID' ); |
|
605 | - if ( ! $msgID ) { |
|
606 | - EE_Error::add_error( __( 'Something went wrong because there is no "MSG_ID" value in the request', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
604 | + $msgID = EE_Registry::instance()->REQ->get('MSG_ID'); |
|
605 | + if ( ! $msgID) { |
|
606 | + EE_Error::add_error(__('Something went wrong because there is no "MSG_ID" value in the request', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
607 | 607 | return false; |
608 | 608 | } |
609 | 609 | |
610 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send( (array) $msgID ); |
|
610 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array) $msgID); |
|
611 | 611 | |
612 | 612 | //setup success message. |
613 | - $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_resend ); |
|
614 | - EE_Error::add_success( sprintf( |
|
613 | + $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
614 | + EE_Error::add_success(sprintf( |
|
615 | 615 | _n( |
616 | 616 | 'There was %d message queued for resending.', |
617 | 617 | 'There were %d messages queued for resending.', |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | 'event_espresso' |
620 | 620 | ), |
621 | 621 | $count_ready_for_resend |
622 | - ) ); |
|
622 | + )); |
|
623 | 623 | return true; |
624 | 624 | } |
625 | 625 | |
@@ -632,13 +632,13 @@ discard block |
||
632 | 632 | * @param EE_Payment $payment EE_payment object |
633 | 633 | * @return bool success/fail |
634 | 634 | */ |
635 | - public static function process_admin_payment( EE_Payment $payment ) { |
|
636 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
635 | + public static function process_admin_payment(EE_Payment $payment) { |
|
636 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
637 | 637 | //we need to get the transaction object |
638 | 638 | $transaction = $payment->transaction(); |
639 | - if ( $transaction instanceof EE_Transaction ) { |
|
640 | - $data = array( $transaction, $payment ); |
|
641 | - $message_type = EEH_MSG_Template::convert_payment_status_to_message_type( $payment->STS_ID() ); |
|
639 | + if ($transaction instanceof EE_Transaction) { |
|
640 | + $data = array($transaction, $payment); |
|
641 | + $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
642 | 642 | |
643 | 643 | //if payment amount is less than 0 then switch to payment_refund message type. |
644 | 644 | $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
@@ -648,17 +648,17 @@ discard block |
||
648 | 648 | |
649 | 649 | self::_load_controller(); |
650 | 650 | |
651 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( $message_type, $data ); |
|
651 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
652 | 652 | |
653 | 653 | //get count of queued for generation |
654 | - $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete ); |
|
654 | + $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
655 | 655 | |
656 | - if ( $count_to_generate > 0 ) { |
|
657 | - add_filter( 'FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true' ); |
|
656 | + if ($count_to_generate > 0) { |
|
657 | + add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
658 | 658 | return true; |
659 | 659 | } else { |
660 | - $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::instance()->stati_indicating_failed_sending() ); |
|
661 | - EE_Error::add_error( sprintf( |
|
660 | + $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::instance()->stati_indicating_failed_sending()); |
|
661 | + EE_Error::add_error(sprintf( |
|
662 | 662 | _n( |
663 | 663 | 'The payment notification generation failed.', |
664 | 664 | '%d payment notifications failed being sent.', |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | 'event_espresso' |
667 | 667 | ), |
668 | 668 | $count_failed |
669 | - ), __FILE__, __FUNCTION__, __LINE__ ); |
|
669 | + ), __FILE__, __FUNCTION__, __LINE__); |
|
670 | 670 | return false; |
671 | 671 | } |
672 | 672 | } else { |
@@ -689,11 +689,11 @@ discard block |
||
689 | 689 | * @param int $grp_id a specific message template group id. |
690 | 690 | * @return void |
691 | 691 | */ |
692 | - public static function send_newsletter_message( $contacts, $grp_id ) { |
|
692 | + public static function send_newsletter_message($contacts, $grp_id) { |
|
693 | 693 | //make sure mtp is id and set it in the EE_Request Handler later messages setup. |
694 | - EE_Registry::instance()->REQ->set( 'GRP_ID', (int) $grp_id ); |
|
694 | + EE_Registry::instance()->REQ->set('GRP_ID', (int) $grp_id); |
|
695 | 695 | self::_load_controller(); |
696 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'newsletter', $contacts ); |
|
696 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $contacts); |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | |
@@ -708,10 +708,10 @@ discard block |
||
708 | 708 | * @param string $message_type |
709 | 709 | * @return string |
710 | 710 | */ |
711 | - public static function registration_message_trigger_url( $registration_message_trigger_url, EE_Registration $registration, $messenger = 'html', $message_type = 'invoice' ) { |
|
712 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
711 | + public static function registration_message_trigger_url($registration_message_trigger_url, EE_Registration $registration, $messenger = 'html', $message_type = 'invoice') { |
|
712 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
713 | 713 | // whitelist $messenger |
714 | - switch ( $messenger ) { |
|
714 | + switch ($messenger) { |
|
715 | 715 | case 'pdf' : |
716 | 716 | $sending_messenger = 'pdf'; |
717 | 717 | $generating_messenger = 'html'; |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | break; |
724 | 724 | } |
725 | 725 | // whitelist $message_type |
726 | - switch ( $message_type ) { |
|
726 | + switch ($message_type) { |
|
727 | 727 | case 'receipt' : |
728 | 728 | $message_type = 'receipt'; |
729 | 729 | break; |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | break; |
734 | 734 | } |
735 | 735 | // verify that both the messenger AND the message type are active |
736 | - if ( EEH_MSG_Template::is_messenger_active( $sending_messenger ) && EEH_MSG_Template::is_mt_active( $message_type ) ) { |
|
736 | + if (EEH_MSG_Template::is_messenger_active($sending_messenger) && EEH_MSG_Template::is_mt_active($message_type)) { |
|
737 | 737 | //need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?) |
738 | 738 | $template_query_params = array( |
739 | 739 | 'MTP_is_active' => true, |
@@ -742,16 +742,16 @@ discard block |
||
742 | 742 | 'Event.EVT_ID' => $registration->event_ID() |
743 | 743 | ); |
744 | 744 | //get the message template group. |
745 | - $msg_template_group = EEM_Message_Template_Group::instance()->get_one( array( $template_query_params ) ); |
|
745 | + $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
|
746 | 746 | //if we don't have an EE_Message_Template_Group then return |
747 | - if ( ! $msg_template_group instanceof EE_Message_Template_Group ) { |
|
747 | + if ( ! $msg_template_group instanceof EE_Message_Template_Group) { |
|
748 | 748 | // remove EVT_ID from query params so that global templates get picked up |
749 | - unset( $template_query_params['Event.EVT_ID'] ); |
|
749 | + unset($template_query_params['Event.EVT_ID']); |
|
750 | 750 | //get global template as the fallback |
751 | - $msg_template_group = EEM_Message_Template_Group::instance()->get_one( array( $template_query_params ) ); |
|
751 | + $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params)); |
|
752 | 752 | } |
753 | 753 | //if we don't have an EE_Message_Template_Group then return |
754 | - if ( ! $msg_template_group instanceof EE_Message_Template_Group ) { |
|
754 | + if ( ! $msg_template_group instanceof EE_Message_Template_Group) { |
|
755 | 755 | return ''; |
756 | 756 | } |
757 | 757 | // generate the URL |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
781 | 781 | * @return string The body of the message. |
782 | 782 | */ |
783 | - public static function preview_message( $type, $context, $messenger, $send = false ) { |
|
783 | + public static function preview_message($type, $context, $messenger, $send = false) { |
|
784 | 784 | self::_load_controller(); |
785 | 785 | $mtg = new EE_Message_To_Generate( |
786 | 786 | $messenger, |
@@ -789,8 +789,8 @@ discard block |
||
789 | 789 | $context, |
790 | 790 | true |
791 | 791 | ); |
792 | - $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview( $mtg ); |
|
793 | - if ( $generated_preview_queue instanceof EE_Messages_Queue ) { |
|
792 | + $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($mtg); |
|
793 | + if ($generated_preview_queue instanceof EE_Messages_Queue) { |
|
794 | 794 | return $generated_preview_queue->get_queue()->current()->content(); |
795 | 795 | } else { |
796 | 796 | return $generated_preview_queue; |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | * |
818 | 818 | * @return bool success or fail. |
819 | 819 | */ |
820 | - public static function send_message_with_messenger_only( $messenger, $message_type, EE_Messages_Queue $queue, $custom_subject = '' ) { |
|
820 | + public static function send_message_with_messenger_only($messenger, $message_type, EE_Messages_Queue $queue, $custom_subject = '') { |
|
821 | 821 | self::_load_controller(); |
822 | 822 | /** @type EE_Message_To_Generate_From_Queue $message_to_generate */ |
823 | 823 | $message_to_generate = EE_Registry::instance()->load_lib( |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | $custom_subject, |
830 | 830 | ) |
831 | 831 | ); |
832 | - return self::$_MSG_PROCESSOR->queue_for_sending( $message_to_generate ); |
|
832 | + return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate); |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | |
@@ -842,22 +842,22 @@ discard block |
||
842 | 842 | * @param array $message_ids An array of message ids |
843 | 843 | * @return bool | EE_Messages_Queue false if nothing was generated, EE_Messages_Queue containing generated messages. |
844 | 844 | */ |
845 | - public static function generate_now( $message_ids ) { |
|
845 | + public static function generate_now($message_ids) { |
|
846 | 846 | self::_load_controller(); |
847 | 847 | $messages = EEM_Message::instance()->get_all( |
848 | 848 | array( |
849 | 849 | 0 => array( |
850 | - 'MSG_ID' => array( 'IN', $message_ids ), |
|
850 | + 'MSG_ID' => array('IN', $message_ids), |
|
851 | 851 | 'STS_ID' => EEM_Message::status_incomplete, |
852 | 852 | ) |
853 | 853 | ) |
854 | 854 | ); |
855 | 855 | |
856 | - $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue( $messages ); |
|
856 | + $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages); |
|
857 | 857 | |
858 | - if ( ! $generated_queue instanceof EE_Messages_Queue ) { |
|
858 | + if ( ! $generated_queue instanceof EE_Messages_Queue) { |
|
859 | 859 | EE_Error::add_error( |
860 | - __( 'The messages were not generated. This is usually because there is already a batch being generated on a separate request. You can wait a minute or two and try again.', 'event_espresso' ), |
|
860 | + __('The messages were not generated. This is usually because there is already a batch being generated on a separate request. You can wait a minute or two and try again.', 'event_espresso'), |
|
861 | 861 | __FILE__, __FUNCTION__, __LINE__ |
862 | 862 | ); |
863 | 863 | } |
@@ -876,28 +876,28 @@ discard block |
||
876 | 876 | * |
877 | 877 | * @return bool | EE_Messages_Queue false if no messages sent. |
878 | 878 | */ |
879 | - public static function send_now( $message_ids ) { |
|
879 | + public static function send_now($message_ids) { |
|
880 | 880 | self::_load_controller(); |
881 | 881 | $messages = EEM_Message::instance()->get_all( |
882 | 882 | array( |
883 | 883 | 0 => array( |
884 | - 'MSG_ID' => array( 'IN', $message_ids ), |
|
885 | - 'STS_ID' => array( 'IN', array( EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry ) ) |
|
884 | + 'MSG_ID' => array('IN', $message_ids), |
|
885 | + 'STS_ID' => array('IN', array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry)) |
|
886 | 886 | ) |
887 | 887 | ) |
888 | 888 | ); |
889 | 889 | |
890 | - $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue( $messages ); |
|
890 | + $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages); |
|
891 | 891 | |
892 | - if ( ! $sent_queue instanceof EE_Messages_Queue ) { |
|
892 | + if ( ! $sent_queue instanceof EE_Messages_Queue) { |
|
893 | 893 | EE_Error::add_error( |
894 | - __( 'The messages were not sent. This is usually because there is already a batch being sent on a separate request. You can wait a minute or two and try again.', 'event_espresso' ), |
|
894 | + __('The messages were not sent. This is usually because there is already a batch being sent on a separate request. You can wait a minute or two and try again.', 'event_espresso'), |
|
895 | 895 | __FILE__, __FUNCTION__, __LINE__ |
896 | 896 | ); |
897 | 897 | } else { |
898 | 898 | //can count how many sent by using the messages in the queue |
899 | - $sent_count = $sent_queue->count_STS_in_queue( EEM_Message::instance()->stati_indicating_sent() ); |
|
900 | - if ( $sent_count > 0 ) { |
|
899 | + $sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent()); |
|
900 | + if ($sent_count > 0) { |
|
901 | 901 | EE_Error::add_success( |
902 | 902 | sprintf( |
903 | 903 | _n( |
@@ -912,8 +912,8 @@ discard block |
||
912 | 912 | } else { |
913 | 913 | EE_Error::overwrite_errors(); |
914 | 914 | EE_Error::add_error( |
915 | - __( 'No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error. |
|
916 | - If there was an error, you can look at the messages in the message activity list table for any error messages.', 'event_espresso' ), |
|
915 | + __('No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error. |
|
916 | + If there was an error, you can look at the messages in the message activity list table for any error messages.', 'event_espresso'), |
|
917 | 917 | __FILE__, __FUNCTION__, __LINE__ |
918 | 918 | ); |
919 | 919 | } |
@@ -934,13 +934,13 @@ discard block |
||
934 | 934 | * |
935 | 935 | * @return bool true means messages were successfully queued for resending, false means none were queued for resending. |
936 | 936 | */ |
937 | - public static function queue_for_resending( $message_ids ) { |
|
937 | + public static function queue_for_resending($message_ids) { |
|
938 | 938 | self::_load_controller(); |
939 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send( $message_ids ); |
|
939 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids); |
|
940 | 940 | |
941 | 941 | //get queue and count |
942 | - $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_resend ); |
|
943 | - if ( $queue_count > 0 ) { |
|
942 | + $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
943 | + if ($queue_count > 0) { |
|
944 | 944 | EE_Error::add_success( |
945 | 945 | sprintf( |
946 | 946 | _n( |
@@ -954,7 +954,7 @@ discard block |
||
954 | 954 | ); |
955 | 955 | } else { |
956 | 956 | EE_Error::add_error( |
957 | - __( 'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', 'event_espresso' ), |
|
957 | + __('No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', 'event_espresso'), |
|
958 | 958 | __FILE__, __FUNCTION__, __LINE__ |
959 | 959 | ); |
960 | 960 | } |
@@ -976,17 +976,17 @@ discard block |
||
976 | 976 | * @param array $info |
977 | 977 | * @param bool $display_request |
978 | 978 | */ |
979 | - protected static function log( $class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false ) { |
|
980 | - EE_Registry::instance()->load_helper( 'Debug_Tools' ); |
|
981 | - if ( WP_DEBUG && false ) { |
|
982 | - if ( $transaction instanceof EE_Transaction ) { |
|
979 | + protected static function log($class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false) { |
|
980 | + EE_Registry::instance()->load_helper('Debug_Tools'); |
|
981 | + if (WP_DEBUG && false) { |
|
982 | + if ($transaction instanceof EE_Transaction) { |
|
983 | 983 | // don't serialize objects |
984 | - $info = EEH_Debug_Tools::strip_objects( $info ); |
|
984 | + $info = EEH_Debug_Tools::strip_objects($info); |
|
985 | 985 | $info['TXN_status'] = $transaction->status_ID(); |
986 | 986 | $info['TXN_reg_steps'] = $transaction->reg_steps(); |
987 | - if ( $transaction->ID() ) { |
|
988 | - $index = 'EE_Transaction: ' . $transaction->ID(); |
|
989 | - EEH_Debug_Tools::log( $class, $func, $line, $info, $display_request, $index ); |
|
987 | + if ($transaction->ID()) { |
|
988 | + $index = 'EE_Transaction: '.$transaction->ID(); |
|
989 | + EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index); |
|
990 | 990 | } |
991 | 991 | } |
992 | 992 | } |
@@ -23,18 +23,18 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function __construct() { |
25 | 25 | //register tasks (and make sure only registered once). |
26 | - if ( ! has_action( 'FHEE__EEH_Activation__get_cron_tasks', array( $this, 'register_scheduled_tasks' ) ) ) { |
|
27 | - add_action( 'FHEE__EEH_Activation__get_cron_tasks', array( $this, 'register_scheduled_tasks' ), 10 ); |
|
26 | + if ( ! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) { |
|
27 | + add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | //register callbacks for scheduled events (but make sure they are set only once). |
31 | - if ( ! has_action( 'AHEE__EE_Messages_Scheduler__generation', array( 'EE_Messages_Scheduler', 'batch_generation' ) ) ) { |
|
32 | - add_action( 'AHEE__EE_Messages_Scheduler__generation', array( 'EE_Messages_Scheduler', 'batch_generation') ); |
|
33 | - add_action( 'AHEE__EE_Messages_Scheduler__sending', array( 'EE_Messages_Scheduler', 'batch_sending' ) ); |
|
31 | + if ( ! has_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation'))) { |
|
32 | + add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation')); |
|
33 | + add_action('AHEE__EE_Messages_Scheduler__sending', array('EE_Messages_Scheduler', 'batch_sending')); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | //add custom schedules |
37 | - add_filter( 'cron_schedules', array( $this, 'custom_schedules' ) ); |
|
37 | + add_filter('cron_schedules', array($this, 'custom_schedules')); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | * Add custom schedules for wp_cron |
45 | 45 | * @param $schedules |
46 | 46 | */ |
47 | - public function custom_schedules( $schedules ) { |
|
47 | + public function custom_schedules($schedules) { |
|
48 | 48 | $schedules['ee_message_cron'] = array( |
49 | 49 | 'interval' => self::message_cron_schedule, |
50 | - 'display' => __( 'This is the cron time interval for EE Message schedules (defaults to once every 10 minutes)', 'event_espresso' ) |
|
50 | + 'display' => __('This is the cron time interval for EE Message schedules (defaults to once every 10 minutes)', 'event_espresso') |
|
51 | 51 | ); |
52 | 52 | return $schedules; |
53 | 53 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param array $tasks already existing scheduled tasks |
59 | 59 | * @return array |
60 | 60 | */ |
61 | - public function register_scheduled_tasks( $tasks ) { |
|
61 | + public function register_scheduled_tasks($tasks) { |
|
62 | 62 | $tasks['AHEE__EE_Messages_Scheduler__generation'] = 'ee_message_cron'; |
63 | 63 | $tasks['AHEE__EE_Messages_Scheduler__sending'] = 'ee_message_cron'; |
64 | 64 | return $tasks; |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | * Note: The EED_Messages module has the handlers for these requests. |
71 | 71 | * @param string $task The task the request is being generated for. |
72 | 72 | */ |
73 | - public static function initiate_scheduled_non_blocking_request( $task ) { |
|
73 | + public static function initiate_scheduled_non_blocking_request($task) { |
|
74 | 74 | //create nonce (this ensures that only valid requests are accepted) |
75 | - $nonce = wp_create_nonce( 'EE_Messages_Scheduler_' . $task ); |
|
75 | + $nonce = wp_create_nonce('EE_Messages_Scheduler_'.$task); |
|
76 | 76 | $request_url = add_query_arg( |
77 | 77 | array( |
78 | 78 | 'ee' => 'msg_cron_trigger', |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | ); |
84 | 84 | $request_args = array( |
85 | 85 | 'timeout' => 300, |
86 | - 'blocking' => ( defined( 'DOING_CRON' ) && DOING_CRON ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? true : false, |
|
86 | + 'blocking' => (defined('DOING_CRON') && DOING_CRON) || (defined('DOING_AJAX') && DOING_AJAX) ? true : false, |
|
87 | 87 | 'sslverify' => false, |
88 | 88 | 'redirection' => 10, |
89 | 89 | ); |
90 | - $response = wp_remote_get( $request_url, $request_args ); |
|
91 | - if ( is_wp_error( $response ) ) { |
|
92 | - trigger_error( $response->get_error_message() ); |
|
90 | + $response = wp_remote_get($request_url, $request_args); |
|
91 | + if (is_wp_error($response)) { |
|
92 | + trigger_error($response->get_error_message()); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * Callback for scheduled AHEE__EE_Messages_Scheduler__generation wp cron event |
102 | 102 | */ |
103 | 103 | public static function batch_generation() { |
104 | - EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( 'generate' ); |
|
104 | + EE_Messages_Scheduler::initiate_scheduled_non_blocking_request('generate'); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * Callback for scheduled AHEE__EE_Messages_Scheduler__sending |
112 | 112 | */ |
113 | 113 | public static function batch_sending() { |
114 | - EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( 'send' ); |
|
114 | + EE_Messages_Scheduler::initiate_scheduled_non_blocking_request('send'); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | } //end EE_Messages_Scheduler |
118 | 118 | \ No newline at end of file |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | |
@@ -134,14 +134,14 @@ discard block |
||
134 | 134 | * @return EE_Messenger_Collection |
135 | 135 | */ |
136 | 136 | protected function _initialize_collections() { |
137 | - if ( $this->_initialized ) { |
|
137 | + if ($this->_initialized) { |
|
138 | 138 | return; |
139 | 139 | } |
140 | 140 | $this->_initialized = true; |
141 | 141 | $this->_messenger_collection_loader->load_messengers_from_folder(); |
142 | 142 | $this->_message_type_collection_loader->load_message_types_from_folder(); |
143 | 143 | $this->_set_active_messengers_and_message_types(); |
144 | - $this->get_has_activated_messengers_option( true ); |
|
144 | + $this->get_has_activated_messengers_option(true); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | * @param string $messenger_name |
171 | 171 | * @return \EE_messenger |
172 | 172 | */ |
173 | - public function get_messenger( $messenger_name ) { |
|
174 | - return $this->messenger_collection()->get_by_info( $messenger_name ); |
|
173 | + public function get_messenger($messenger_name) { |
|
174 | + return $this->messenger_collection()->get_by_info($messenger_name); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | * @param string $messenger |
183 | 183 | * @return EE_messenger | null |
184 | 184 | */ |
185 | - public function get_active_messenger( $messenger ) { |
|
185 | + public function get_active_messenger($messenger) { |
|
186 | 186 | $this->_initialize_collections(); |
187 | - return ! empty( $this->_active_messengers[ $messenger ] ) ? $this->_active_messengers[ $messenger ] : null; |
|
187 | + return ! empty($this->_active_messengers[$messenger]) ? $this->_active_messengers[$messenger] : null; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | |
@@ -193,11 +193,11 @@ discard block |
||
193 | 193 | * @return \EE_messenger[] |
194 | 194 | */ |
195 | 195 | public function installed_messengers() { |
196 | - if ( empty( $this->_installed_messengers ) ) { |
|
196 | + if (empty($this->_installed_messengers)) { |
|
197 | 197 | $this->_installed_messengers = array(); |
198 | 198 | $this->messenger_collection()->rewind(); |
199 | - while ( $this->messenger_collection()->valid() ) { |
|
200 | - $this->_installed_messengers[ $this->messenger_collection()->current()->name ] = $this->messenger_collection()->current(); |
|
199 | + while ($this->messenger_collection()->valid()) { |
|
200 | + $this->_installed_messengers[$this->messenger_collection()->current()->name] = $this->messenger_collection()->current(); |
|
201 | 201 | $this->messenger_collection()->next(); |
202 | 202 | } |
203 | 203 | } |
@@ -211,14 +211,14 @@ discard block |
||
211 | 211 | * @return \EE_messenger |
212 | 212 | * @throws \EE_Error |
213 | 213 | */ |
214 | - public function valid_messenger( $messenger_name ) { |
|
215 | - $messenger = $this->get_messenger( $messenger_name ); |
|
216 | - if ( $messenger instanceof EE_messenger ) { |
|
214 | + public function valid_messenger($messenger_name) { |
|
215 | + $messenger = $this->get_messenger($messenger_name); |
|
216 | + if ($messenger instanceof EE_messenger) { |
|
217 | 217 | return $messenger; |
218 | 218 | } |
219 | 219 | throw new EE_Error( |
220 | 220 | sprintf( |
221 | - __( 'The "%1$s" messenger is either invalid or not installed', 'event_espresso' ), |
|
221 | + __('The "%1$s" messenger is either invalid or not installed', 'event_espresso'), |
|
222 | 222 | $messenger_name |
223 | 223 | ) |
224 | 224 | ); |
@@ -250,8 +250,8 @@ discard block |
||
250 | 250 | * @param string $message_type_name |
251 | 251 | * @return \EE_message_type |
252 | 252 | */ |
253 | - public function get_message_type( $message_type_name ) { |
|
254 | - return $this->message_type_collection()->get_by_info( $message_type_name ); |
|
253 | + public function get_message_type($message_type_name) { |
|
254 | + return $this->message_type_collection()->get_by_info($message_type_name); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | |
@@ -263,9 +263,9 @@ discard block |
||
263 | 263 | * @param string $message_type_name |
264 | 264 | * @return \EE_message_type|null |
265 | 265 | */ |
266 | - public function get_active_message_type_for_messenger( $messenger_name, $message_type_name ) { |
|
267 | - return $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) |
|
268 | - ? $this->get_message_type( $message_type_name ) |
|
266 | + public function get_active_message_type_for_messenger($messenger_name, $message_type_name) { |
|
267 | + return $this->is_message_type_active_for_messenger($messenger_name, $message_type_name) |
|
268 | + ? $this->get_message_type($message_type_name) |
|
269 | 269 | : null; |
270 | 270 | } |
271 | 271 | |
@@ -279,9 +279,9 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @return bool |
281 | 281 | */ |
282 | - public function is_message_type_active_for_messenger( $messenger_name, $message_type_name ) { |
|
282 | + public function is_message_type_active_for_messenger($messenger_name, $message_type_name) { |
|
283 | 283 | $this->_initialize_collections(); |
284 | - return ! empty( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ] ); |
|
284 | + return ! empty($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | * @param string $messenger_name the name of the messenger to check if active. |
293 | 293 | * @return bool |
294 | 294 | */ |
295 | - public function is_messenger_active( $messenger_name ) { |
|
295 | + public function is_messenger_active($messenger_name) { |
|
296 | 296 | $this->_initialize_collections(); |
297 | - return ! empty( $this->_active_message_types[ $messenger_name ] ); |
|
297 | + return ! empty($this->_active_message_types[$messenger_name]); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | |
@@ -305,11 +305,11 @@ discard block |
||
305 | 305 | * @param string $message_type_name The slug of the message type getting the settings for. |
306 | 306 | * @return array |
307 | 307 | */ |
308 | - public function get_message_type_settings_for_messenger( $messenger_name, $message_type_name ) { |
|
308 | + public function get_message_type_settings_for_messenger($messenger_name, $message_type_name) { |
|
309 | 309 | $settings = array(); |
310 | - if ( $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
311 | - $settings = isset( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ]['settings'] ) |
|
312 | - ? $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ]['settings'] |
|
310 | + if ($this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
311 | + $settings = isset($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]['settings']) |
|
312 | + ? $this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]['settings'] |
|
313 | 313 | : array(); |
314 | 314 | } |
315 | 315 | return $settings; |
@@ -324,11 +324,11 @@ discard block |
||
324 | 324 | * @param string $messenger_name |
325 | 325 | * @return bool |
326 | 326 | */ |
327 | - public function messenger_has_active_message_types( $messenger_name ) { |
|
327 | + public function messenger_has_active_message_types($messenger_name) { |
|
328 | 328 | $this->_initialize_collections(); |
329 | 329 | return |
330 | - ! empty( $this->_active_message_types[ $messenger_name ] ) |
|
331 | - && ! empty( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ] ); |
|
330 | + ! empty($this->_active_message_types[$messenger_name]) |
|
331 | + && ! empty($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types']); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | |
@@ -341,15 +341,15 @@ discard block |
||
341 | 341 | * @param string $messenger_name The messenger being checked |
342 | 342 | * @return EE_message_type[] (or empty array if none present) |
343 | 343 | */ |
344 | - public function get_active_message_types_for_messenger( $messenger_name ) { |
|
344 | + public function get_active_message_types_for_messenger($messenger_name) { |
|
345 | 345 | $message_types = array(); |
346 | - if ( ! $this->messenger_has_active_message_types( $messenger_name ) ) { |
|
346 | + if ( ! $this->messenger_has_active_message_types($messenger_name)) { |
|
347 | 347 | return $message_types; |
348 | 348 | } |
349 | 349 | $installed_message_types = $this->installed_message_types(); |
350 | - foreach ( $installed_message_types as $message_type_name => $message_type ) { |
|
351 | - if ( $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
352 | - $message_types[ $message_type_name ] = $message_type; |
|
350 | + foreach ($installed_message_types as $message_type_name => $message_type) { |
|
351 | + if ($this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
352 | + $message_types[$message_type_name] = $message_type; |
|
353 | 353 | } |
354 | 354 | } |
355 | 355 | return $message_types; |
@@ -367,12 +367,12 @@ discard block |
||
367 | 367 | public function list_of_active_message_types() { |
368 | 368 | $active_message_type_names = array(); |
369 | 369 | $this->_initialize_collections(); |
370 | - foreach ( $this->_active_message_types as $messenger => $messenger_settings ) { |
|
371 | - if ( ! isset( $messenger_settings['settings'][ $messenger . '-message_types' ] ) ) { |
|
370 | + foreach ($this->_active_message_types as $messenger => $messenger_settings) { |
|
371 | + if ( ! isset($messenger_settings['settings'][$messenger.'-message_types'])) { |
|
372 | 372 | continue; |
373 | 373 | } |
374 | - foreach ( $messenger_settings['settings'][ $messenger . '-message_types' ] as $message_type_name => $message_type_config ) { |
|
375 | - if ( ! in_array( $message_type_name, $active_message_type_names ) ) { |
|
374 | + foreach ($messenger_settings['settings'][$messenger.'-message_types'] as $message_type_name => $message_type_config) { |
|
375 | + if ( ! in_array($message_type_name, $active_message_type_names)) { |
|
376 | 376 | $active_message_type_names[] = $message_type_name; |
377 | 377 | } |
378 | 378 | } |
@@ -392,9 +392,9 @@ discard block |
||
392 | 392 | $active_message_types = array(); |
393 | 393 | $installed_message_types = $this->installed_message_types(); |
394 | 394 | $active_message_type_names = $this->list_of_active_message_types(); |
395 | - foreach ( $active_message_type_names as $active_message_type_name ) { |
|
396 | - if ( isset( $installed_message_types[ $active_message_type_name ] ) ) { |
|
397 | - $active_message_types[ $active_message_type_name ] = $installed_message_types[ $active_message_type_name ]; |
|
395 | + foreach ($active_message_type_names as $active_message_type_name) { |
|
396 | + if (isset($installed_message_types[$active_message_type_name])) { |
|
397 | + $active_message_types[$active_message_type_name] = $installed_message_types[$active_message_type_name]; |
|
398 | 398 | } |
399 | 399 | } |
400 | 400 | return $active_message_types; |
@@ -406,10 +406,10 @@ discard block |
||
406 | 406 | * @return \EE_message_type[] |
407 | 407 | */ |
408 | 408 | public function installed_message_types() { |
409 | - if ( empty( $this->_installed_message_types ) ) { |
|
409 | + if (empty($this->_installed_message_types)) { |
|
410 | 410 | $this->message_type_collection()->rewind(); |
411 | - while ( $this->message_type_collection()->valid() ) { |
|
412 | - $this->_installed_message_types[ $this->message_type_collection()->current()->name ] = $this->message_type_collection()->current(); |
|
411 | + while ($this->message_type_collection()->valid()) { |
|
412 | + $this->_installed_message_types[$this->message_type_collection()->current()->name] = $this->message_type_collection()->current(); |
|
413 | 413 | $this->message_type_collection()->next(); |
414 | 414 | } |
415 | 415 | } |
@@ -422,14 +422,14 @@ discard block |
||
422 | 422 | * @return \EE_message_type |
423 | 423 | * @throws \EE_Error |
424 | 424 | */ |
425 | - public function valid_message_type( $message_type_name ) { |
|
426 | - $message_type = $this->get_message_type( $message_type_name ); |
|
427 | - if ( $message_type instanceof EE_message_type ) { |
|
425 | + public function valid_message_type($message_type_name) { |
|
426 | + $message_type = $this->get_message_type($message_type_name); |
|
427 | + if ($message_type instanceof EE_message_type) { |
|
428 | 428 | return $message_type; |
429 | 429 | } |
430 | 430 | throw new EE_Error( |
431 | 431 | sprintf( |
432 | - __( 'The "%1$s" message type is either invalid or not installed', 'event_espresso' ), |
|
432 | + __('The "%1$s" message type is either invalid or not installed', 'event_espresso'), |
|
433 | 433 | $message_type_name |
434 | 434 | ) |
435 | 435 | ); |
@@ -445,9 +445,9 @@ discard block |
||
445 | 445 | * @return boolean |
446 | 446 | * @throws \EE_Error |
447 | 447 | */ |
448 | - public function valid_message_type_for_messenger( EE_messenger $messenger, $message_type_name ) { |
|
448 | + public function valid_message_type_for_messenger(EE_messenger $messenger, $message_type_name) { |
|
449 | 449 | $valid_message_types = $messenger->get_valid_message_types(); |
450 | - if ( ! in_array( $message_type_name, $valid_message_types ) ) { |
|
450 | + if ( ! in_array($message_type_name, $valid_message_types)) { |
|
451 | 451 | throw new EE_Error( |
452 | 452 | sprintf( |
453 | 453 | __( |
@@ -474,9 +474,9 @@ discard block |
||
474 | 474 | * |
475 | 475 | * @return array |
476 | 476 | */ |
477 | - public function get_active_messengers_option( $reset = false) { |
|
478 | - if ( $reset ) { |
|
479 | - $this->_active_message_types = get_option( 'ee_active_messengers', array() ); |
|
477 | + public function get_active_messengers_option($reset = false) { |
|
478 | + if ($reset) { |
|
479 | + $this->_active_message_types = get_option('ee_active_messengers', array()); |
|
480 | 480 | } |
481 | 481 | return $this->_active_message_types; |
482 | 482 | } |
@@ -490,11 +490,11 @@ discard block |
||
490 | 490 | * representing this data is used. |
491 | 491 | * @return bool FALSE if not updated, TRUE if updated. |
492 | 492 | */ |
493 | - public function update_active_messengers_option( $active_messenger_settings = array() ) { |
|
494 | - $active_messenger_settings = empty( $active_messenger_settings ) ? $this->_active_message_types : $active_messenger_settings; |
|
493 | + public function update_active_messengers_option($active_messenger_settings = array()) { |
|
494 | + $active_messenger_settings = empty($active_messenger_settings) ? $this->_active_message_types : $active_messenger_settings; |
|
495 | 495 | //make sure _active_message_types is updated (this is the internal cache for the settings). |
496 | 496 | $this->_active_message_types = $active_messenger_settings; |
497 | - return update_option( 'ee_active_messengers', $active_messenger_settings ); |
|
497 | + return update_option('ee_active_messengers', $active_messenger_settings); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | |
@@ -509,9 +509,9 @@ discard block |
||
509 | 509 | * |
510 | 510 | * @return array |
511 | 511 | */ |
512 | - public function get_has_activated_messengers_option( $reset = false ) { |
|
513 | - if ( $reset ) { |
|
514 | - $this->_has_activated_messengers_and_message_types = get_option( 'ee_has_activated_messenger', array() ); |
|
512 | + public function get_has_activated_messengers_option($reset = false) { |
|
513 | + if ($reset) { |
|
514 | + $this->_has_activated_messengers_and_message_types = get_option('ee_has_activated_messenger', array()); |
|
515 | 515 | } |
516 | 516 | return $this->_has_activated_messengers_and_message_types; |
517 | 517 | } |
@@ -526,11 +526,11 @@ discard block |
||
526 | 526 | * |
527 | 527 | * @return bool FALSE if not updated, TRUE if updated. |
528 | 528 | */ |
529 | - public function update_has_activated_messengers_option( $has_activated_messengers = array() ) { |
|
530 | - $has_activated_messengers = empty( $has_activated_messengers ) |
|
529 | + public function update_has_activated_messengers_option($has_activated_messengers = array()) { |
|
530 | + $has_activated_messengers = empty($has_activated_messengers) |
|
531 | 531 | ? $this->_has_activated_messengers_and_message_types |
532 | 532 | : $has_activated_messengers; |
533 | - return update_option( 'ee_has_activated_messenger', $has_activated_messengers ); |
|
533 | + return update_option('ee_has_activated_messenger', $has_activated_messengers); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | |
@@ -552,8 +552,8 @@ discard block |
||
552 | 552 | //echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() \n"; |
553 | 553 | // list of activated messengers as set via the admin |
554 | 554 | // note calling `get_active_messengers_options` also initializes the _active_message_types property. |
555 | - $this->get_active_messengers_option( true ); |
|
556 | - $this->ensure_messengers_are_active( array(), false, true ); |
|
555 | + $this->get_active_messengers_option(true); |
|
556 | + $this->ensure_messengers_are_active(array(), false, true); |
|
557 | 557 | $this->update_active_messengers_option(); |
558 | 558 | $this->update_has_activated_messengers_option(); |
559 | 559 | } |
@@ -571,11 +571,11 @@ discard block |
||
571 | 571 | * @param bool $update_option Whether to update the option in the db or not. |
572 | 572 | * @return boolean true if either already active or successfully activated. |
573 | 573 | */ |
574 | - public function ensure_messenger_is_active( $messenger_name, $update_option = true ) { |
|
575 | - if ( ! isset( $this->_active_messengers[ $messenger_name ] ) ) { |
|
574 | + public function ensure_messenger_is_active($messenger_name, $update_option = true) { |
|
575 | + if ( ! isset($this->_active_messengers[$messenger_name])) { |
|
576 | 576 | try { |
577 | - $this->activate_messenger( $messenger_name, array(), $update_option ); |
|
578 | - } catch( EE_Error $e ) { |
|
577 | + $this->activate_messenger($messenger_name, array(), $update_option); |
|
578 | + } catch (EE_Error $e) { |
|
579 | 579 | EE_Error::add_error( |
580 | 580 | $e->getMessage(), |
581 | 581 | __FILE__, |
@@ -602,25 +602,25 @@ discard block |
||
602 | 602 | * and a messenger is indicated as active, but is NOT installed, then it will automatically be |
603 | 603 | * deactivated. |
604 | 604 | */ |
605 | - public function ensure_messengers_are_active( $messenger_names = array(), $update_option = true, $verify = false ) { |
|
606 | - $messenger_names = empty( $messenger_names ) ? array_keys( $this->_active_message_types ) : $messenger_names; |
|
605 | + public function ensure_messengers_are_active($messenger_names = array(), $update_option = true, $verify = false) { |
|
606 | + $messenger_names = empty($messenger_names) ? array_keys($this->_active_message_types) : $messenger_names; |
|
607 | 607 | |
608 | 608 | $not_installed = array(); |
609 | - foreach( $messenger_names as $messenger_name ) { |
|
610 | - if ( $verify && ! $this->messenger_collection()->has_by_name( $messenger_name ) ) { |
|
609 | + foreach ($messenger_names as $messenger_name) { |
|
610 | + if ($verify && ! $this->messenger_collection()->has_by_name($messenger_name)) { |
|
611 | 611 | $not_installed[] = $messenger_name; |
612 | - $this->deactivate_messenger( $messenger_name ); |
|
612 | + $this->deactivate_messenger($messenger_name); |
|
613 | 613 | continue; |
614 | 614 | } |
615 | - $this->ensure_messenger_is_active( $messenger_name, $update_option ); |
|
615 | + $this->ensure_messenger_is_active($messenger_name, $update_option); |
|
616 | 616 | } |
617 | 617 | |
618 | - if ( ! empty( $not_installed_messenger ) ) { |
|
618 | + if ( ! empty($not_installed_messenger)) { |
|
619 | 619 | EE_Error::add_error( |
620 | 620 | sprintf( |
621 | - __( 'The following messengers are either not installed or are invalid:%1$s %2$s', 'event_espresso' ), |
|
621 | + __('The following messengers are either not installed or are invalid:%1$s %2$s', 'event_espresso'), |
|
622 | 622 | '<br />', |
623 | - implode( ', ', $not_installed_messenger ) |
|
623 | + implode(', ', $not_installed_messenger) |
|
624 | 624 | ), |
625 | 625 | __FILE__, __FUNCTION__, __LINE__ |
626 | 626 | ); |
@@ -639,18 +639,18 @@ discard block |
||
639 | 639 | * @return bool Returns true if already is active or if was activated successfully. |
640 | 640 | * @throws \EE_Error |
641 | 641 | */ |
642 | - public function ensure_message_type_is_active( $message_type_name, $messenger_name, $update_option = true ) { |
|
642 | + public function ensure_message_type_is_active($message_type_name, $messenger_name, $update_option = true) { |
|
643 | 643 | // grab the messenger to work with. |
644 | - $messenger = $this->valid_messenger( $messenger_name ); |
|
645 | - if ( $this->valid_message_type_for_messenger( $messenger, $message_type_name ) ) { |
|
644 | + $messenger = $this->valid_messenger($messenger_name); |
|
645 | + if ($this->valid_message_type_for_messenger($messenger, $message_type_name)) { |
|
646 | 646 | //ensure messenger is active (that's an inherent coupling between active message types and the |
647 | 647 | //messenger they are being activated for. |
648 | 648 | try { |
649 | - if ( ! $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
649 | + if ( ! $this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
650 | 650 | //all is good so let's just get it active |
651 | - $this->activate_messenger( $messenger_name, array( $message_type_name ), $update_option ); |
|
651 | + $this->activate_messenger($messenger_name, array($message_type_name), $update_option); |
|
652 | 652 | } |
653 | - } catch( EE_Error $e ) { |
|
653 | + } catch (EE_Error $e) { |
|
654 | 654 | EE_Error::add_error( |
655 | 655 | $e->getMessage(), |
656 | 656 | __FILE__, |
@@ -674,14 +674,14 @@ discard block |
||
674 | 674 | * @param string $messenger_name The name of the messenger that the message types are to be activated on. |
675 | 675 | * @param bool $update_option Whether to persist the activation to the database or not (default true). |
676 | 676 | */ |
677 | - public function ensure_message_types_are_active( $message_type_names, $messenger_name, $update_option = true ) { |
|
677 | + public function ensure_message_types_are_active($message_type_names, $messenger_name, $update_option = true) { |
|
678 | 678 | $message_type_names = (array) $message_type_names; |
679 | - foreach ( $message_type_names as $message_type_name ) { |
|
679 | + foreach ($message_type_names as $message_type_name) { |
|
680 | 680 | // note, intentionally not updating option here because we're in a loop. |
681 | 681 | // We'll follow the instructions of the incoming $update_option argument after the loop. |
682 | - $this->ensure_message_type_is_active( $message_type_name, $messenger_name, false ); |
|
682 | + $this->ensure_message_type_is_active($message_type_name, $messenger_name, false); |
|
683 | 683 | } |
684 | - if ( $update_option ) { |
|
684 | + if ($update_option) { |
|
685 | 685 | $this->update_active_messengers_option(); |
686 | 686 | $this->update_has_activated_messengers_option(); |
687 | 687 | } |
@@ -708,24 +708,24 @@ discard block |
||
708 | 708 | ) { |
709 | 709 | $templates = array(); |
710 | 710 | // grab the messenger to work with. |
711 | - $messenger = $this->messenger_collection()->get_by_info( $messenger_name ); |
|
711 | + $messenger = $this->messenger_collection()->get_by_info($messenger_name); |
|
712 | 712 | // it's inactive. Activate it. |
713 | - if ( $messenger instanceof EE_messenger ) { |
|
714 | - $this->_active_messengers[ $messenger->name ] = $messenger; |
|
713 | + if ($messenger instanceof EE_messenger) { |
|
714 | + $this->_active_messengers[$messenger->name] = $messenger; |
|
715 | 715 | //activate incoming message types set to be activated with messenger. |
716 | - $message_type_names = $this->_activate_message_types( $messenger, $message_type_names ); |
|
716 | + $message_type_names = $this->_activate_message_types($messenger, $message_type_names); |
|
717 | 717 | // setup any initial settings for the messenger if necessary. |
718 | - $this->add_settings_for_messenger( $messenger->name ); |
|
719 | - if ( $update_active_messengers_option ) { |
|
718 | + $this->add_settings_for_messenger($messenger->name); |
|
719 | + if ($update_active_messengers_option) { |
|
720 | 720 | $this->update_active_messengers_option(); |
721 | 721 | $this->update_has_activated_messengers_option(); |
722 | 722 | } |
723 | 723 | //generate new templates if necessary and ensure all related templates that are already in the database are |
724 | 724 | //marked active. Note, this will also deactivate a message type for a messenger if the template |
725 | 725 | //cannot be successfully created during its attempt (only happens for global template attempts). |
726 | - if ( ! empty( $message_type_names ) ) { |
|
727 | - $templates = EEH_MSG_Template::generate_new_templates( $messenger->name, $message_type_names, 0, true ); |
|
728 | - EEH_MSG_Template::update_to_active( array( $messenger->name ), $message_type_names ); |
|
726 | + if ( ! empty($message_type_names)) { |
|
727 | + $templates = EEH_MSG_Template::generate_new_templates($messenger->name, $message_type_names, 0, true); |
|
728 | + EEH_MSG_Template::update_to_active(array($messenger->name), $message_type_names); |
|
729 | 729 | } |
730 | 730 | } |
731 | 731 | return $templates; |
@@ -744,29 +744,29 @@ discard block |
||
744 | 744 | * |
745 | 745 | * @return array |
746 | 746 | */ |
747 | - protected function _activate_message_types( EE_messenger $messenger, $message_type_names = array() ) { |
|
747 | + protected function _activate_message_types(EE_messenger $messenger, $message_type_names = array()) { |
|
748 | 748 | //If $message_type_names is empty, AND $this->_active_message_types is empty, then that means |
749 | 749 | //things have never been initialized (which should happen on EEH_Activation::generate_message_templates). |
750 | 750 | //So ONLY then do we need to actually grab defaults and cycle through them. Otherwise we |
751 | 751 | //only override _active_message_types when an explicit array of $message_type_names has been provided. |
752 | - $message_type_names = empty( $message_type_names ) && ! isset( $this->_active_message_types[ $messenger->name ] ) |
|
752 | + $message_type_names = empty($message_type_names) && ! isset($this->_active_message_types[$messenger->name]) |
|
753 | 753 | ? $messenger->get_default_message_types() |
754 | 754 | : (array) $message_type_names; |
755 | 755 | |
756 | 756 | //now we ALWAYS need to make sure that the messenger is active for the message types we're activating! |
757 | - if ( ! isset( $this->_active_message_types[ $messenger->name ] ) ) { |
|
758 | - $this->_active_message_types[ $messenger->name ]['settings'] = array(); |
|
757 | + if ( ! isset($this->_active_message_types[$messenger->name])) { |
|
758 | + $this->_active_message_types[$messenger->name]['settings'] = array(); |
|
759 | 759 | } |
760 | 760 | |
761 | - if ( $message_type_names ) { |
|
761 | + if ($message_type_names) { |
|
762 | 762 | // cycle thru message types |
763 | - foreach ( $message_type_names as $message_type_name ) { |
|
763 | + foreach ($message_type_names as $message_type_name) { |
|
764 | 764 | //only register the message type as active IF it isn't already active! |
765 | 765 | //and if its actually installed. |
766 | 766 | if ( |
767 | - ! $this->is_message_type_active_for_messenger( $messenger->name, $message_type_name ) |
|
767 | + ! $this->is_message_type_active_for_messenger($messenger->name, $message_type_name) |
|
768 | 768 | ) { |
769 | - $this->add_settings_for_message_type( $messenger->name, $message_type_name ); |
|
769 | + $this->add_settings_for_message_type($messenger->name, $message_type_name); |
|
770 | 770 | $this->_set_messenger_has_activated_message_type( |
771 | 771 | $messenger, |
772 | 772 | $message_type_name |
@@ -789,24 +789,24 @@ discard block |
||
789 | 789 | * @param string $message_type_name The name of the message type adding the settings for |
790 | 790 | * @param array $new_settings Any new settings being set for the message type and messenger |
791 | 791 | */ |
792 | - public function add_settings_for_message_type( $messenger_name, $message_type_name, $new_settings = array() ) { |
|
792 | + public function add_settings_for_message_type($messenger_name, $message_type_name, $new_settings = array()) { |
|
793 | 793 | // get installed message type from collection |
794 | - $message_type = $this->message_type_collection()->get_by_info( $message_type_name ); |
|
795 | - $existing_settings = $this->get_message_type_settings_for_messenger( $messenger_name, $message_type_name ); |
|
794 | + $message_type = $this->message_type_collection()->get_by_info($message_type_name); |
|
795 | + $existing_settings = $this->get_message_type_settings_for_messenger($messenger_name, $message_type_name); |
|
796 | 796 | //we need to setup any initial settings for message types |
797 | - if ( $message_type instanceof EE_message_type ) { |
|
797 | + if ($message_type instanceof EE_message_type) { |
|
798 | 798 | $default_settings = $message_type->get_admin_settings_fields(); |
799 | - foreach ( $default_settings as $field => $values ) { |
|
800 | - if ( isset( $new_settings[ $field ] ) ) { |
|
801 | - $existing_settings[ $field ] = $new_settings[ $field ]; |
|
799 | + foreach ($default_settings as $field => $values) { |
|
800 | + if (isset($new_settings[$field])) { |
|
801 | + $existing_settings[$field] = $new_settings[$field]; |
|
802 | 802 | continue; |
803 | 803 | } |
804 | - if ( ! isset( $existing_settings[ $field ] ) ) { |
|
805 | - $existing_settings[ $field ] = $values['default']; |
|
804 | + if ( ! isset($existing_settings[$field])) { |
|
805 | + $existing_settings[$field] = $values['default']; |
|
806 | 806 | } |
807 | 807 | } |
808 | 808 | } |
809 | - $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ]['settings'] = $existing_settings; |
|
809 | + $this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]['settings'] = $existing_settings; |
|
810 | 810 | } |
811 | 811 | |
812 | 812 | |
@@ -819,14 +819,14 @@ discard block |
||
819 | 819 | * @param \EE_messenger $messenger |
820 | 820 | * @param string $message_type_name |
821 | 821 | */ |
822 | - protected function _set_messenger_has_activated_message_type( EE_messenger $messenger, $message_type_name ) { |
|
822 | + protected function _set_messenger_has_activated_message_type(EE_messenger $messenger, $message_type_name) { |
|
823 | 823 | // make sure this messenger has a record in the has_activated array |
824 | - if ( ! isset( $this->_has_activated_messengers_and_message_types[ $messenger->name ] ) ) { |
|
825 | - $this->_has_activated_messengers_and_message_types[ $messenger->name ] = array(); |
|
824 | + if ( ! isset($this->_has_activated_messengers_and_message_types[$messenger->name])) { |
|
825 | + $this->_has_activated_messengers_and_message_types[$messenger->name] = array(); |
|
826 | 826 | } |
827 | 827 | // check if message type has already been added |
828 | - if ( ! in_array( $message_type_name, $this->_has_activated_messengers_and_message_types[ $messenger->name ] ) ) { |
|
829 | - $this->_has_activated_messengers_and_message_types[ $messenger->name ][] = $message_type_name; |
|
828 | + if ( ! in_array($message_type_name, $this->_has_activated_messengers_and_message_types[$messenger->name])) { |
|
829 | + $this->_has_activated_messengers_and_message_types[$messenger->name][] = $message_type_name; |
|
830 | 830 | } |
831 | 831 | } |
832 | 832 | |
@@ -841,20 +841,20 @@ discard block |
||
841 | 841 | * @param string $messenger_name The name of the messenger the settings is being added for. |
842 | 842 | * @param array $new_settings An array of settings to update the existing settings. |
843 | 843 | */ |
844 | - public function add_settings_for_messenger( $messenger_name, $new_settings = array() ) { |
|
845 | - $messenger = $this->get_messenger( $messenger_name ); |
|
846 | - if ( $messenger instanceof EE_messenger ) { |
|
844 | + public function add_settings_for_messenger($messenger_name, $new_settings = array()) { |
|
845 | + $messenger = $this->get_messenger($messenger_name); |
|
846 | + if ($messenger instanceof EE_messenger) { |
|
847 | 847 | $msgr_settings = $messenger->get_admin_settings_fields(); |
848 | - if ( ! empty( $msgr_settings ) ) { |
|
849 | - foreach ( $msgr_settings as $field => $value ) { |
|
848 | + if ( ! empty($msgr_settings)) { |
|
849 | + foreach ($msgr_settings as $field => $value) { |
|
850 | 850 | //is there a new setting for this? |
851 | - if ( isset( $new_settings[ $field ] ) ) { |
|
852 | - $this->_active_message_types[ $messenger->name ]['settings'][ $field ] = $new_settings[ $field ]; |
|
851 | + if (isset($new_settings[$field])) { |
|
852 | + $this->_active_message_types[$messenger->name]['settings'][$field] = $new_settings[$field]; |
|
853 | 853 | continue; |
854 | 854 | } |
855 | 855 | //only set the default if it isn't already set. |
856 | - if ( ! isset( $this->_active_message_types[ $messenger->name ]['settings'][ $field ] ) ) { |
|
857 | - $this->_active_message_types[ $messenger->name ]['settings'][ $field ] = $value; |
|
856 | + if ( ! isset($this->_active_message_types[$messenger->name]['settings'][$field])) { |
|
857 | + $this->_active_message_types[$messenger->name]['settings'][$field] = $value; |
|
858 | 858 | } |
859 | 859 | } |
860 | 860 | } |
@@ -869,13 +869,13 @@ discard block |
||
869 | 869 | * @param string|EE_messenger $messenger_name name of messenger |
870 | 870 | * @return void |
871 | 871 | */ |
872 | - public function deactivate_messenger( $messenger_name ) { |
|
873 | - if ( $messenger_name instanceof EE_messenger ) { |
|
872 | + public function deactivate_messenger($messenger_name) { |
|
873 | + if ($messenger_name instanceof EE_messenger) { |
|
874 | 874 | $messenger_name = $messenger_name->name; |
875 | 875 | } |
876 | - unset( $this->_active_messengers[ $messenger_name ] ); |
|
877 | - unset( $this->_active_message_types[ $messenger_name ] ); |
|
878 | - $this->_message_template_group_model->deactivate_message_template_groups_for( $messenger_name ); |
|
876 | + unset($this->_active_messengers[$messenger_name]); |
|
877 | + unset($this->_active_message_types[$messenger_name]); |
|
878 | + $this->_message_template_group_model->deactivate_message_template_groups_for($messenger_name); |
|
879 | 879 | $this->update_active_messengers_option(); |
880 | 880 | } |
881 | 881 | |
@@ -885,16 +885,16 @@ discard block |
||
885 | 885 | * |
886 | 886 | * @param string $message_type_name name of message type being deactivated |
887 | 887 | */ |
888 | - public function deactivate_message_type( $message_type_name ) { |
|
889 | - if ( $message_type_name instanceof EE_message_type ) { |
|
888 | + public function deactivate_message_type($message_type_name) { |
|
889 | + if ($message_type_name instanceof EE_message_type) { |
|
890 | 890 | $message_type_name = $message_type_name->name; |
891 | 891 | } |
892 | - foreach ( $this->_active_message_types as $messenger => $settings ) { |
|
892 | + foreach ($this->_active_message_types as $messenger => $settings) { |
|
893 | 893 | unset( |
894 | - $this->_active_message_types[ $messenger ]['settings'][ $messenger . '-message_types' ][ $message_type_name ] |
|
894 | + $this->_active_message_types[$messenger]['settings'][$messenger.'-message_types'][$message_type_name] |
|
895 | 895 | ); |
896 | 896 | } |
897 | - $this->_message_template_group_model->deactivate_message_template_groups_for( '', $message_type_name ); |
|
897 | + $this->_message_template_group_model->deactivate_message_template_groups_for('', $message_type_name); |
|
898 | 898 | $this->update_active_messengers_option(); |
899 | 899 | } |
900 | 900 | |
@@ -908,11 +908,11 @@ discard block |
||
908 | 908 | * @param string $message_type_name Name of message type being deactivated. |
909 | 909 | * @param string $messenger_name Name of messenger the message type is being deactivated for. |
910 | 910 | */ |
911 | - public function deactivate_message_type_for_messenger( $message_type_name, $messenger_name ) { |
|
912 | - if ( $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
913 | - unset( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ] ); |
|
911 | + public function deactivate_message_type_for_messenger($message_type_name, $messenger_name) { |
|
912 | + if ($this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
913 | + unset($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]); |
|
914 | 914 | } |
915 | - $this->_message_template_group_model->deactivate_message_template_groups_for( array( $messenger_name ), array( $message_type_name ) ); |
|
915 | + $this->_message_template_group_model->deactivate_message_template_groups_for(array($messenger_name), array($message_type_name)); |
|
916 | 916 | $this->update_active_messengers_option(); |
917 | 917 | } |
918 | 918 | |
@@ -929,12 +929,12 @@ discard block |
||
929 | 929 | * |
930 | 930 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
931 | 931 | */ |
932 | - public function is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) { |
|
932 | + public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) { |
|
933 | 933 | //get the $messengers the message type says it can be used with. |
934 | - foreach ( $message_type->with_messengers() as $generating_messenger => $secondary_messengers ) { |
|
934 | + foreach ($message_type->with_messengers() as $generating_messenger => $secondary_messengers) { |
|
935 | 935 | if ( |
936 | 936 | $messenger->name === $generating_messenger |
937 | - && $this->is_message_type_active_for_messenger( $messenger->name, $message_type->name ) |
|
937 | + && $this->is_message_type_active_for_messenger($messenger->name, $message_type->name) |
|
938 | 938 | ) { |
939 | 939 | return true; |
940 | 940 | } |
@@ -971,25 +971,25 @@ discard block |
||
971 | 971 | * or all contexts indexed by message type. |
972 | 972 | * @return array |
973 | 973 | */ |
974 | - public function get_all_contexts( $slugs_only = true ) { |
|
974 | + public function get_all_contexts($slugs_only = true) { |
|
975 | 975 | $key = $slugs_only ? 'slugs' : 'all'; |
976 | 976 | // check if contexts has been setup yet. |
977 | - if ( empty( $this->_contexts[ $key ] ) ) { |
|
977 | + if (empty($this->_contexts[$key])) { |
|
978 | 978 | // So let's get all active message type objects and loop through to get all unique contexts |
979 | - foreach ( $this->get_active_message_type_objects() as $message_type ) { |
|
980 | - if ( $message_type instanceof EE_message_type ) { |
|
979 | + foreach ($this->get_active_message_type_objects() as $message_type) { |
|
980 | + if ($message_type instanceof EE_message_type) { |
|
981 | 981 | $message_type_contexts = $message_type->get_contexts(); |
982 | - if ( $slugs_only ) { |
|
983 | - foreach ( $message_type_contexts as $context => $context_details ) { |
|
984 | - $this->_contexts[ $key ][ $context ] = $context_details[ 'label' ]; |
|
982 | + if ($slugs_only) { |
|
983 | + foreach ($message_type_contexts as $context => $context_details) { |
|
984 | + $this->_contexts[$key][$context] = $context_details['label']; |
|
985 | 985 | } |
986 | 986 | } else { |
987 | - $this->_contexts[ $key ][ $message_type->name ] = $message_type_contexts; |
|
987 | + $this->_contexts[$key][$message_type->name] = $message_type_contexts; |
|
988 | 988 | } |
989 | 989 | } |
990 | 990 | } |
991 | 991 | } |
992 | - return ! empty( $this->_contexts[ $key ] ) ? $this->_contexts[ $key ] : array(); |
|
992 | + return ! empty($this->_contexts[$key]) ? $this->_contexts[$key] : array(); |
|
993 | 993 | } |
994 | 994 | |
995 | 995 | |
@@ -1008,9 +1008,9 @@ discard block |
||
1008 | 1008 | $installed_message_types = $this->installed_message_types(); |
1009 | 1009 | $all_message_types_valid = true; |
1010 | 1010 | //loop through list of active message types and verify they are installed. |
1011 | - foreach( $list_of_active_message_type_names as $message_type_name ) { |
|
1012 | - if ( ! isset( $installed_message_types[$message_type_name] ) ) { |
|
1013 | - $this->deactivate_message_type( $message_type_name ); |
|
1011 | + foreach ($list_of_active_message_type_names as $message_type_name) { |
|
1012 | + if ( ! isset($installed_message_types[$message_type_name])) { |
|
1013 | + $this->deactivate_message_type($message_type_name); |
|
1014 | 1014 | $all_message_types_valid = false; |
1015 | 1015 | } |
1016 | 1016 | } |
@@ -1029,10 +1029,10 @@ discard block |
||
1029 | 1029 | * @param $messenger_name |
1030 | 1030 | * @return bool |
1031 | 1031 | */ |
1032 | - public function has_message_type_been_activated_for_messenger( $message_type_name, $messenger_name ) { |
|
1032 | + public function has_message_type_been_activated_for_messenger($message_type_name, $messenger_name) { |
|
1033 | 1033 | $has_activated = $this->get_has_activated_messengers_option(); |
1034 | - return isset( $has_activated[ $messenger_name ] ) |
|
1035 | - && in_array( $message_type_name, $has_activated[ $messenger_name ] ); |
|
1034 | + return isset($has_activated[$messenger_name]) |
|
1035 | + && in_array($message_type_name, $has_activated[$messenger_name]); |
|
1036 | 1036 | } |
1037 | 1037 | } |
1038 | 1038 | // End of file EE_Message_Resource_Manager.lib.php |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * This file contains the EE_Register_Message_Type class that implements EEI_Plugin_API |
|
4 | - * @package Event Espresso |
|
5 | - * @subpackage plugin api, messages |
|
6 | - * @since 4.3.0 |
|
7 | - */ |
|
3 | + * This file contains the EE_Register_Message_Type class that implements EEI_Plugin_API |
|
4 | + * @package Event Espresso |
|
5 | + * @subpackage plugin api, messages |
|
6 | + * @since 4.3.0 |
|
7 | + */ |
|
8 | 8 | if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
9 | 9 | |
10 | 10 | /** |
@@ -251,14 +251,14 @@ discard block |
||
251 | 251 | |
252 | 252 | |
253 | 253 | /** |
254 | - * callback for FHEE__EE_messenger__get_valid_message_types__default_types filter. |
|
255 | - * |
|
256 | - * @since 4.3.0 |
|
257 | - * @param array $valid_types array of message types valid with messenger ( |
|
258 | - * corresponds to the $name property of message type) |
|
259 | - * @param EE_messenger $messenger The EE_messenger the filter is called from. |
|
260 | - * @return array |
|
261 | - */ |
|
254 | + * callback for FHEE__EE_messenger__get_valid_message_types__default_types filter. |
|
255 | + * |
|
256 | + * @since 4.3.0 |
|
257 | + * @param array $valid_types array of message types valid with messenger ( |
|
258 | + * corresponds to the $name property of message type) |
|
259 | + * @param EE_messenger $messenger The EE_messenger the filter is called from. |
|
260 | + * @return array |
|
261 | + */ |
|
262 | 262 | public static function register_messengers_to_validate_mt_with( $valid_types, EE_messenger $messenger ) { |
263 | 263 | if ( empty( self::$_ee_message_type_registry ) ) { |
264 | 264 | return $valid_types; |
@@ -50,79 +50,79 @@ discard block |
||
50 | 50 | * @throws \EE_Error |
51 | 51 | * } |
52 | 52 | */ |
53 | - public static function register( $mt_name = NULL, $setup_args = array() ) { |
|
53 | + public static function register($mt_name = NULL, $setup_args = array()) { |
|
54 | 54 | //required fields MUST be present, so let's make sure they are. |
55 | 55 | if ( |
56 | - ! isset( $mt_name ) |
|
57 | - || ! is_array( $setup_args ) |
|
58 | - || empty( $setup_args['mtfilename'] ) || empty( $setup_args['autoloadpaths'] ) |
|
59 | - ){ |
|
56 | + ! isset($mt_name) |
|
57 | + || ! is_array($setup_args) |
|
58 | + || empty($setup_args['mtfilename']) || empty($setup_args['autoloadpaths']) |
|
59 | + ) { |
|
60 | 60 | throw new EE_Error( |
61 | - __( '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' ) |
|
61 | + __('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') |
|
62 | 62 | ); |
63 | 63 | } |
64 | 64 | |
65 | 65 | //make sure we don't register twice |
66 | - if( isset( self::$_ee_message_type_registry[ $mt_name ] ) ){ |
|
66 | + if (isset(self::$_ee_message_type_registry[$mt_name])) { |
|
67 | 67 | return; |
68 | 68 | } |
69 | 69 | |
70 | 70 | //make sure this was called in the right place! |
71 | 71 | if ( |
72 | - ! did_action( 'EE_Brewing_Regular___messages_caf' ) |
|
73 | - || did_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' ) |
|
72 | + ! did_action('EE_Brewing_Regular___messages_caf') |
|
73 | + || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
|
74 | 74 | ) { |
75 | 75 | EE_Error::doing_it_wrong( |
76 | 76 | __METHOD__, |
77 | 77 | sprintf( |
78 | - __('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'), |
|
78 | + __('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'), |
|
79 | 79 | $mt_name |
80 | 80 | ), |
81 | 81 | '4.3.0' |
82 | 82 | ); |
83 | 83 | } |
84 | 84 | //setup $__ee_message_type_registry array from incoming values. |
85 | - self::$_ee_message_type_registry[ $mt_name ] = array( |
|
85 | + self::$_ee_message_type_registry[$mt_name] = array( |
|
86 | 86 | 'mtfilename' => (string) $setup_args['mtfilename'], |
87 | 87 | 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
88 | - 'messengers_to_activate_with' => ! empty( $setup_args['messengers_to_activate_with'] ) |
|
88 | + 'messengers_to_activate_with' => ! empty($setup_args['messengers_to_activate_with']) |
|
89 | 89 | ? (array) $setup_args['messengers_to_activate_with'] |
90 | 90 | : array(), |
91 | - 'messengers_to_validate_with' => ! empty( $setup_args['messengers_to_validate_with'] ) |
|
91 | + 'messengers_to_validate_with' => ! empty($setup_args['messengers_to_validate_with']) |
|
92 | 92 | ? (array) $setup_args['messengers_to_validate_with'] |
93 | 93 | : array(), |
94 | - 'force_activation' => ! empty( $setup_args['force_activation'] ) |
|
94 | + 'force_activation' => ! empty($setup_args['force_activation']) |
|
95 | 95 | ? (bool) $setup_args['force_activation'] |
96 | 96 | : array() |
97 | 97 | ); |
98 | 98 | //add filters |
99 | 99 | add_filter( |
100 | 100 | 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
101 | - array( 'EE_Register_Message_Type', 'register_msgs_autoload_paths' ), |
|
101 | + array('EE_Register_Message_Type', 'register_msgs_autoload_paths'), |
|
102 | 102 | 10 |
103 | 103 | ); |
104 | 104 | add_filter( |
105 | 105 | 'FHEE__EE_messages__get_installed__messagetype_files', |
106 | - array( 'EE_Register_Message_Type', 'register_messagetype_files' ), |
|
106 | + array('EE_Register_Message_Type', 'register_messagetype_files'), |
|
107 | 107 | 10, |
108 | 108 | 1 |
109 | 109 | ); |
110 | 110 | add_filter( |
111 | 111 | 'FHEE__EE_messenger__get_default_message_types__default_types', |
112 | - array( 'EE_Register_Message_Type', 'register_messengers_to_activate_mt_with' ), |
|
112 | + array('EE_Register_Message_Type', 'register_messengers_to_activate_mt_with'), |
|
113 | 113 | 10, |
114 | 114 | 2 |
115 | 115 | ); |
116 | 116 | add_filter( |
117 | 117 | 'FHEE__EE_messenger__get_valid_message_types__valid_types', |
118 | - array( 'EE_Register_Message_Type', 'register_messengers_to_validate_mt_with' ), |
|
118 | + array('EE_Register_Message_Type', 'register_messengers_to_validate_mt_with'), |
|
119 | 119 | 10, |
120 | 120 | 2 |
121 | 121 | ); |
122 | 122 | //actions |
123 | 123 | add_action( |
124 | 124 | 'AHEE__EE_Addon__initialize_default_data__begin', |
125 | - array( 'EE_Register_Message_Type', 'set_defaults' ) |
|
125 | + array('EE_Register_Message_Type', 'set_defaults') |
|
126 | 126 | ); |
127 | 127 | } |
128 | 128 | |
@@ -133,15 +133,15 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public static function set_defaults() { |
135 | 135 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
136 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
136 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
137 | 137 | |
138 | 138 | //for any message types with force activation, let's ensure they are activated |
139 | - foreach ( self::$_ee_message_type_registry as $message_type_name => $settings ) { |
|
140 | - if ( $settings['force_activation'] ) { |
|
141 | - foreach ( $settings['messengers_to_activate_with'] as $messenger ) { |
|
139 | + foreach (self::$_ee_message_type_registry as $message_type_name => $settings) { |
|
140 | + if ($settings['force_activation']) { |
|
141 | + foreach ($settings['messengers_to_activate_with'] as $messenger) { |
|
142 | 142 | //DO not force activation if this message type has already been activated in the system |
143 | - if ( ! $message_resource_manager->has_message_type_been_activated_for_messenger( $message_type_name, $messenger ) ) { |
|
144 | - $message_resource_manager->ensure_message_type_is_active( $message_type_name, $messenger ); |
|
143 | + if ( ! $message_resource_manager->has_message_type_been_activated_for_messenger($message_type_name, $messenger)) { |
|
144 | + $message_resource_manager->ensure_message_type_is_active($message_type_name, $messenger); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | } |
@@ -158,13 +158,13 @@ discard block |
||
158 | 158 | * @param string $message_type_name the name for the message type that was previously registered |
159 | 159 | * @return void |
160 | 160 | */ |
161 | - public static function deregister( $message_type_name = null ) { |
|
162 | - if ( ! empty( self::$_ee_message_type_registry[ $message_type_name ] ) ) { |
|
161 | + public static function deregister($message_type_name = null) { |
|
162 | + if ( ! empty(self::$_ee_message_type_registry[$message_type_name])) { |
|
163 | 163 | //let's make sure that we remove any place this message type was made active |
164 | 164 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
165 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
166 | - $Message_Resource_Manager->deactivate_message_type( $message_type_name ); |
|
167 | - unset( self::$_ee_message_type_registry[ $message_type_name ] ); |
|
165 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
166 | + $Message_Resource_Manager->deactivate_message_type($message_type_name); |
|
167 | + unset(self::$_ee_message_type_registry[$message_type_name]); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
@@ -178,12 +178,12 @@ discard block |
||
178 | 178 | * @param array $messagetype_files The current array of message type file names |
179 | 179 | * @return array Array of message type file names |
180 | 180 | */ |
181 | - public static function register_messagetype_files( $messagetype_files ) { |
|
182 | - if ( empty( self::$_ee_message_type_registry ) ) { |
|
181 | + public static function register_messagetype_files($messagetype_files) { |
|
182 | + if (empty(self::$_ee_message_type_registry)) { |
|
183 | 183 | return $messagetype_files; |
184 | 184 | } |
185 | - foreach ( self::$_ee_message_type_registry as $mt_reg ) { |
|
186 | - if ( empty( $mt_reg['mtfilename' ] ) ) { |
|
185 | + foreach (self::$_ee_message_type_registry as $mt_reg) { |
|
186 | + if (empty($mt_reg['mtfilename'])) { |
|
187 | 187 | continue; |
188 | 188 | } |
189 | 189 | $messagetype_files[] = $mt_reg['mtfilename']; |
@@ -203,13 +203,13 @@ discard block |
||
203 | 203 | * @param array $paths array of paths to be checked by EE_messages autoloader. |
204 | 204 | * @return array |
205 | 205 | */ |
206 | - public static function register_msgs_autoload_paths( $paths ) { |
|
207 | - if ( ! empty( self::$_ee_message_type_registry ) ) { |
|
208 | - foreach ( self::$_ee_message_type_registry as $mt_reg ) { |
|
209 | - if ( empty( $mt_reg['autoloadpaths'] ) ) { |
|
206 | + public static function register_msgs_autoload_paths($paths) { |
|
207 | + if ( ! empty(self::$_ee_message_type_registry)) { |
|
208 | + foreach (self::$_ee_message_type_registry as $mt_reg) { |
|
209 | + if (empty($mt_reg['autoloadpaths'])) { |
|
210 | 210 | continue; |
211 | 211 | } |
212 | - $paths = array_merge( $paths, $mt_reg['autoloadpaths'] ); |
|
212 | + $paths = array_merge($paths, $mt_reg['autoloadpaths']); |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 | return $paths; |
@@ -228,18 +228,18 @@ discard block |
||
228 | 228 | * @param EE_messenger $messenger The EE_messenger the filter is called from. |
229 | 229 | * @return array |
230 | 230 | */ |
231 | - public static function register_messengers_to_activate_mt_with( $default_types, EE_messenger $messenger ) { |
|
232 | - if ( empty( self::$_ee_message_type_registry ) ) { |
|
231 | + public static function register_messengers_to_activate_mt_with($default_types, EE_messenger $messenger) { |
|
232 | + if (empty(self::$_ee_message_type_registry)) { |
|
233 | 233 | return $default_types; |
234 | 234 | } |
235 | - foreach ( self::$_ee_message_type_registry as $message_type_name => $mt_reg ) { |
|
236 | - if ( empty( $mt_reg['messengers_to_activate_with'] ) || empty( $mt_reg['mtfilename'] ) ) { |
|
235 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
236 | + if (empty($mt_reg['messengers_to_activate_with']) || empty($mt_reg['mtfilename'])) { |
|
237 | 237 | continue; |
238 | 238 | } |
239 | 239 | // loop through each of the messengers and if it matches the loaded class |
240 | 240 | // then we add this message type to the |
241 | - foreach ( $mt_reg['messengers_to_activate_with'] as $msgr ) { |
|
242 | - if ( $messenger->name == $msgr ) { |
|
241 | + foreach ($mt_reg['messengers_to_activate_with'] as $msgr) { |
|
242 | + if ($messenger->name == $msgr) { |
|
243 | 243 | $default_types[] = $message_type_name; |
244 | 244 | } |
245 | 245 | } |
@@ -259,18 +259,18 @@ discard block |
||
259 | 259 | * @param EE_messenger $messenger The EE_messenger the filter is called from. |
260 | 260 | * @return array |
261 | 261 | */ |
262 | - public static function register_messengers_to_validate_mt_with( $valid_types, EE_messenger $messenger ) { |
|
263 | - if ( empty( self::$_ee_message_type_registry ) ) { |
|
262 | + public static function register_messengers_to_validate_mt_with($valid_types, EE_messenger $messenger) { |
|
263 | + if (empty(self::$_ee_message_type_registry)) { |
|
264 | 264 | return $valid_types; |
265 | 265 | } |
266 | - foreach ( self::$_ee_message_type_registry as $message_type_name => $mt_reg ) { |
|
267 | - if ( empty( $mt_reg['messengers_to_validate_with'] ) || empty( $mt_reg['mtfilename'] ) ) { |
|
266 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
267 | + if (empty($mt_reg['messengers_to_validate_with']) || empty($mt_reg['mtfilename'])) { |
|
268 | 268 | continue; |
269 | 269 | } |
270 | 270 | // loop through each of the messengers and if it matches the loaded class |
271 | 271 | // then we add this message type to the |
272 | - foreach ( $mt_reg['messengers_to_validate_with'] as $msgr ) { |
|
273 | - if ( $messenger->name == $msgr ) { |
|
272 | + foreach ($mt_reg['messengers_to_validate_with'] as $msgr) { |
|
273 | + if ($messenger->name == $msgr) { |
|
274 | 274 | $valid_types[] = $message_type_name; |
275 | 275 | } |
276 | 276 | } |