@@ -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 | |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | * @param mixed $info |
| 40 | 40 | * @return bool |
| 41 | 41 | */ |
| 42 | - public function add( $object, $info = null ) { |
|
| 43 | - $info = empty( $info ) && $object instanceof $this->interface ? $object->name : $info; |
|
| 44 | - return parent::add( $object, $info ); |
|
| 42 | + public function add($object, $info = null) { |
|
| 43 | + $info = empty($info) && $object instanceof $this->interface ? $object->name : $info; |
|
| 44 | + return parent::add($object, $info); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | * @param mixed $info |
| 58 | 58 | * @return bool |
| 59 | 59 | */ |
| 60 | - public function set_info( $object, $info = null ) { |
|
| 61 | - $info = empty( $info ) && $object instanceof $this->interface ? $object->name : $info; |
|
| 62 | - return parent::set_info( $object, $info ); |
|
| 60 | + public function set_info($object, $info = null) { |
|
| 61 | + $info = empty($info) && $object instanceof $this->interface ? $object->name : $info; |
|
| 62 | + return parent::set_info($object, $info); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | * @param mixed |
| 75 | 75 | * @return null | object |
| 76 | 76 | */ |
| 77 | - public function get_by_info( $info ) { |
|
| 78 | - return parent::get_by_info( $info ); |
|
| 77 | + public function get_by_info($info) { |
|
| 78 | + return parent::get_by_info($info); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | * @param object $object |
| 90 | 90 | * @return bool |
| 91 | 91 | */ |
| 92 | - public function has( $object ) { |
|
| 93 | - return parent::has( $object ); |
|
| 92 | + public function has($object) { |
|
| 93 | + return parent::has($object); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | * @param string $messenger_name |
| 105 | 105 | * @return bool |
| 106 | 106 | */ |
| 107 | - public function has_by_name( $messenger_name ) { |
|
| 108 | - return $this->get_by_info( $messenger_name ) instanceof $this->interface ? true : false; |
|
| 107 | + public function has_by_name($messenger_name) { |
|
| 108 | + return $this->get_by_info($messenger_name) instanceof $this->interface ? true : false; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | * @param $object |
| 120 | 120 | * @return bool |
| 121 | 121 | */ |
| 122 | - public function remove( $object ) { |
|
| 123 | - return parent::remove( $object ); |
|
| 122 | + public function remove($object) { |
|
| 123 | + return parent::remove($object); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
@@ -148,8 +148,8 @@ discard block |
||
| 148 | 148 | * @param $object |
| 149 | 149 | * @return void |
| 150 | 150 | */ |
| 151 | - public function set_current( $object ) { |
|
| 152 | - parent::set_current( $object ); |
|
| 151 | + public function set_current($object) { |
|
| 152 | + parent::set_current($object); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | * @param $info |
| 164 | 164 | * @return void |
| 165 | 165 | */ |
| 166 | - public function set_current_by_info( $info ) { |
|
| 167 | - parent::set_current_by_info( $info ); |
|
| 166 | + public function set_current_by_info($info) { |
|
| 167 | + parent::set_current_by_info($info); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | |
@@ -178,10 +178,10 @@ discard block |
||
| 178 | 178 | * @return void |
| 179 | 179 | */ |
| 180 | 180 | public function show_collection_classes() { |
| 181 | - if ( WP_DEBUG ) { |
|
| 181 | + if (WP_DEBUG) { |
|
| 182 | 182 | $this->rewind(); |
| 183 | - while ( $this->valid() ) { |
|
| 184 | - echo '<h5 style="color:#2EA2CC;">' . __CLASS__ . ' class : . <span style="color:#E76700">' . $this->getInfo() . '</span></h5>'; |
|
| 183 | + while ($this->valid()) { |
|
| 184 | + echo '<h5 style="color:#2EA2CC;">'.__CLASS__.' class : . <span style="color:#E76700">'.$this->getInfo().'</span></h5>'; |
|
| 185 | 185 | $this->next(); |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -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 | |
@@ -143,8 +143,8 @@ discard block |
||
| 143 | 143 | * @param string $messenger_name |
| 144 | 144 | * @return \EE_Messenger |
| 145 | 145 | */ |
| 146 | - public function get_messenger( $messenger_name ) { |
|
| 147 | - return $this->messenger_collection()->get_by_info( $messenger_name ); |
|
| 146 | + public function get_messenger($messenger_name) { |
|
| 147 | + return $this->messenger_collection()->get_by_info($messenger_name); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | |
@@ -155,8 +155,8 @@ discard block |
||
| 155 | 155 | * @param string $messenger |
| 156 | 156 | * @return EE_Messenger | null |
| 157 | 157 | */ |
| 158 | - public function get_active_messenger( $messenger ) { |
|
| 159 | - return ! empty( $this->_active_messengers[ $messenger ] ) ? $this->_active_messengers[ $messenger ] : null; |
|
| 158 | + public function get_active_messenger($messenger) { |
|
| 159 | + return ! empty($this->_active_messengers[$messenger]) ? $this->_active_messengers[$messenger] : null; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | |
@@ -165,11 +165,11 @@ discard block |
||
| 165 | 165 | * @return \EE_Messenger[] |
| 166 | 166 | */ |
| 167 | 167 | public function installed_messengers() { |
| 168 | - if ( empty( $this->_installed_messengers ) ) { |
|
| 168 | + if (empty($this->_installed_messengers)) { |
|
| 169 | 169 | $this->_installed_messengers = array(); |
| 170 | 170 | $this->messenger_collection()->rewind(); |
| 171 | - while ( $this->messenger_collection()->valid() ) { |
|
| 172 | - $this->_installed_messengers[ $this->messenger_collection()->current()->name ] = $this->messenger_collection()->current(); |
|
| 171 | + while ($this->messenger_collection()->valid()) { |
|
| 172 | + $this->_installed_messengers[$this->messenger_collection()->current()->name] = $this->messenger_collection()->current(); |
|
| 173 | 173 | $this->messenger_collection()->next(); |
| 174 | 174 | } |
| 175 | 175 | } |
@@ -183,14 +183,14 @@ discard block |
||
| 183 | 183 | * @return \EE_Messenger |
| 184 | 184 | * @throws \EE_Error |
| 185 | 185 | */ |
| 186 | - public function valid_messenger( $messenger_name ) { |
|
| 187 | - $messenger = $this->get_messenger( $messenger_name ); |
|
| 188 | - if ( $messenger instanceof EE_Messenger ) { |
|
| 186 | + public function valid_messenger($messenger_name) { |
|
| 187 | + $messenger = $this->get_messenger($messenger_name); |
|
| 188 | + if ($messenger instanceof EE_Messenger) { |
|
| 189 | 189 | return $messenger; |
| 190 | 190 | } |
| 191 | 191 | throw new EE_Error( |
| 192 | 192 | sprintf( |
| 193 | - __( 'The "%1$s" messenger is either invalid or not installed', 'event_espresso' ), |
|
| 193 | + __('The "%1$s" messenger is either invalid or not installed', 'event_espresso'), |
|
| 194 | 194 | $messenger_name |
| 195 | 195 | ) |
| 196 | 196 | ); |
@@ -220,8 +220,8 @@ discard block |
||
| 220 | 220 | * @param string $message_type_name |
| 221 | 221 | * @return \EE_Message_Type |
| 222 | 222 | */ |
| 223 | - public function get_message_type( $message_type_name ) { |
|
| 224 | - return $this->message_type_collection()->get_by_info( $message_type_name ); |
|
| 223 | + public function get_message_type($message_type_name) { |
|
| 224 | + return $this->message_type_collection()->get_by_info($message_type_name); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | |
@@ -233,9 +233,9 @@ discard block |
||
| 233 | 233 | * @param string $message_type_name |
| 234 | 234 | * @return \EE_Message_Type|null |
| 235 | 235 | */ |
| 236 | - public function get_active_message_type_for_messenger( $messenger_name, $message_type_name ) { |
|
| 237 | - return ! empty( $this->_active_message_types[ $messenger_name ][ $message_type_name ] ) |
|
| 238 | - ? $this->get_message_type( $message_type_name ) |
|
| 236 | + public function get_active_message_type_for_messenger($messenger_name, $message_type_name) { |
|
| 237 | + return ! empty($this->_active_message_types[$messenger_name][$message_type_name]) |
|
| 238 | + ? $this->get_message_type($message_type_name) |
|
| 239 | 239 | : null; |
| 240 | 240 | } |
| 241 | 241 | |
@@ -249,16 +249,16 @@ discard block |
||
| 249 | 249 | * @param string $messenger_name The messenger being checked |
| 250 | 250 | * @return EE_message_type[] (or empty array if none present) |
| 251 | 251 | */ |
| 252 | - public function get_active_message_types_for_messenger( $messenger_name ) { |
|
| 253 | - if ( empty( $this->_active_message_types[ $messenger_name ] ) ) { |
|
| 252 | + public function get_active_message_types_for_messenger($messenger_name) { |
|
| 253 | + if (empty($this->_active_message_types[$messenger_name])) { |
|
| 254 | 254 | return array(); |
| 255 | 255 | } |
| 256 | 256 | $message_types = array(); |
| 257 | - $active_message_types = $this->_active_message_types[ $messenger_name ]; |
|
| 257 | + $active_message_types = $this->_active_message_types[$messenger_name]; |
|
| 258 | 258 | $installed_message_types = $this->installed_message_types(); |
| 259 | - foreach ( $active_message_types as $message_type_name => $settings ) { |
|
| 260 | - if ( ! empty( $installed_message_types[ $message_type_name ] ) ) { |
|
| 261 | - $message_types[] = $installed_message_types[ $message_type_name ]; |
|
| 259 | + foreach ($active_message_types as $message_type_name => $settings) { |
|
| 260 | + if ( ! empty($installed_message_types[$message_type_name])) { |
|
| 261 | + $message_types[] = $installed_message_types[$message_type_name]; |
|
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | return $message_types; |
@@ -275,9 +275,9 @@ discard block |
||
| 275 | 275 | */ |
| 276 | 276 | public function list_of_active_message_types() { |
| 277 | 277 | $message_types = array(); |
| 278 | - foreach ( $this->_active_message_types as $messenger => $message_type_data ) { |
|
| 279 | - foreach ( $message_type_data as $message_type => $config ) { |
|
| 280 | - if ( ! in_array( $message_type, $message_types ) ) { |
|
| 278 | + foreach ($this->_active_message_types as $messenger => $message_type_data) { |
|
| 279 | + foreach ($message_type_data as $message_type => $config) { |
|
| 280 | + if ( ! in_array($message_type, $message_types)) { |
|
| 281 | 281 | $message_types[] = $message_type; |
| 282 | 282 | } |
| 283 | 283 | } |
@@ -296,10 +296,10 @@ discard block |
||
| 296 | 296 | public function get_active_message_type_objects() { |
| 297 | 297 | $message_types = array(); |
| 298 | 298 | $installed_message_types = $this->installed_message_types(); |
| 299 | - foreach ( $this->_active_message_types as $messenger => $message_type_data ) { |
|
| 300 | - foreach ( $message_type_data as $message_type => $config ) { |
|
| 301 | - if ( ! isset( $message_type, $message_types ) ) { |
|
| 302 | - $message_types[ $message_type ] = $installed_message_types[ $message_type ]; |
|
| 299 | + foreach ($this->_active_message_types as $messenger => $message_type_data) { |
|
| 300 | + foreach ($message_type_data as $message_type => $config) { |
|
| 301 | + if ( ! isset($message_type, $message_types)) { |
|
| 302 | + $message_types[$message_type] = $installed_message_types[$message_type]; |
|
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | 305 | } |
@@ -312,10 +312,10 @@ discard block |
||
| 312 | 312 | * @return \EE_Message_Type[] |
| 313 | 313 | */ |
| 314 | 314 | public function installed_message_types() { |
| 315 | - if ( empty( $this->_installed_message_types ) ) { |
|
| 315 | + if (empty($this->_installed_message_types)) { |
|
| 316 | 316 | $this->message_type_collection()->rewind(); |
| 317 | - while ( $this->message_type_collection()->valid() ) { |
|
| 318 | - $this->_installed_message_types[ $this->message_type_collection()->current()->name ] = $this->message_type_collection()->current(); |
|
| 317 | + while ($this->message_type_collection()->valid()) { |
|
| 318 | + $this->_installed_message_types[$this->message_type_collection()->current()->name] = $this->message_type_collection()->current(); |
|
| 319 | 319 | $this->message_type_collection()->next(); |
| 320 | 320 | } |
| 321 | 321 | } |
@@ -328,14 +328,14 @@ discard block |
||
| 328 | 328 | * @return \EE_message_type |
| 329 | 329 | * @throws \EE_Error |
| 330 | 330 | */ |
| 331 | - public function valid_message_type( $message_type_name ) { |
|
| 332 | - $message_type = $this->get_message_type( $message_type_name ); |
|
| 333 | - if ( $message_type instanceof EE_message_type ) { |
|
| 331 | + public function valid_message_type($message_type_name) { |
|
| 332 | + $message_type = $this->get_message_type($message_type_name); |
|
| 333 | + if ($message_type instanceof EE_message_type) { |
|
| 334 | 334 | return $message_type; |
| 335 | 335 | } |
| 336 | 336 | throw new EE_Error( |
| 337 | 337 | sprintf( |
| 338 | - __( 'The "%1$s" message type is either invalid or not installed', 'event_espresso' ), |
|
| 338 | + __('The "%1$s" message type is either invalid or not installed', 'event_espresso'), |
|
| 339 | 339 | $message_type_name |
| 340 | 340 | ) |
| 341 | 341 | ); |
@@ -351,9 +351,9 @@ discard block |
||
| 351 | 351 | * @return array |
| 352 | 352 | * @throws \EE_Error |
| 353 | 353 | */ |
| 354 | - public function valid_message_type_for_messenger( EE_Messenger $messenger, $message_type_name ) { |
|
| 354 | + public function valid_message_type_for_messenger(EE_Messenger $messenger, $message_type_name) { |
|
| 355 | 355 | $valid_message_types = $messenger->get_valid_message_types(); |
| 356 | - if ( ! in_array( $message_type_name, $valid_message_types ) ) { |
|
| 356 | + if ( ! in_array($message_type_name, $valid_message_types)) { |
|
| 357 | 357 | throw new EE_Error( |
| 358 | 358 | sprintf( |
| 359 | 359 | __( |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | * @return array |
| 378 | 378 | */ |
| 379 | 379 | public function get_active_messengers_option() { |
| 380 | - return get_option( 'ee_active_messengers', array() ); |
|
| 380 | + return get_option('ee_active_messengers', array()); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | |
@@ -388,8 +388,8 @@ discard block |
||
| 388 | 388 | * @param array $active_messengers Incoming data to save. |
| 389 | 389 | * @return bool FALSE if not updated, TRUE if updated. |
| 390 | 390 | */ |
| 391 | - public function update_active_messengers_option( $active_messengers ) { |
|
| 392 | - return update_option( 'ee_active_messengers', $active_messengers ); |
|
| 391 | + public function update_active_messengers_option($active_messengers) { |
|
| 392 | + return update_option('ee_active_messengers', $active_messengers); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | * @return array |
| 402 | 402 | */ |
| 403 | 403 | public function get_has_activated_messengers_option() { |
| 404 | - get_option( 'ee_has_activated_messenger', array() ); |
|
| 404 | + get_option('ee_has_activated_messenger', array()); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | |
@@ -412,8 +412,8 @@ discard block |
||
| 412 | 412 | * @param array $has_activated_messengers Incoming data to save. |
| 413 | 413 | * @return bool FALSE if not updated, TRUE if updated. |
| 414 | 414 | */ |
| 415 | - public function update_has_activated_messengers_option( $has_activated_messengers ) { |
|
| 416 | - return update_option( 'ee_has_activated_messenger', $has_activated_messengers ); |
|
| 415 | + public function update_has_activated_messengers_option($has_activated_messengers) { |
|
| 416 | + return update_option('ee_has_activated_messenger', $has_activated_messengers); |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | |
@@ -434,12 +434,12 @@ discard block |
||
| 434 | 434 | protected function _set_active_messengers_and_message_types() { |
| 435 | 435 | // list of activated messengers as set via the admin |
| 436 | 436 | $active_messengers = $this->get_active_messengers_option(); |
| 437 | - $active_messengers = is_array( $active_messengers ) ? $active_messengers : array( $active_messengers ); |
|
| 437 | + $active_messengers = is_array($active_messengers) ? $active_messengers : array($active_messengers); |
|
| 438 | 438 | $not_installed = array(); |
| 439 | - foreach ( $active_messengers as $active_messenger => $data ) { |
|
| 439 | + foreach ($active_messengers as $active_messenger => $data) { |
|
| 440 | 440 | // check if supposedly active messenger is actually installed by looking in our collection |
| 441 | - if ( $this->messenger_collection()->has_by_name( $active_messenger ) ) { |
|
| 442 | - $this->activate_messenger( $active_messenger, array(), false ); |
|
| 441 | + if ($this->messenger_collection()->has_by_name($active_messenger)) { |
|
| 442 | + $this->activate_messenger($active_messenger, array(), false); |
|
| 443 | 443 | // grab installed messenger object |
| 444 | 444 | //$this->_active_messengers[ $active_messenger ] = $this->messenger_collection()->get_by_info( |
| 445 | 445 | // $active_messenger |
@@ -450,15 +450,15 @@ discard block |
||
| 450 | 450 | // : array(); |
| 451 | 451 | } else { |
| 452 | 452 | $not_installed[] = $active_messenger; |
| 453 | - $this->_deactivate_messenger( $active_messenger ); |
|
| 453 | + $this->_deactivate_messenger($active_messenger); |
|
| 454 | 454 | } |
| 455 | 455 | } |
| 456 | - if ( ! empty( $not_installed ) ) { |
|
| 456 | + if ( ! empty($not_installed)) { |
|
| 457 | 457 | EE_Error::add_error( |
| 458 | 458 | sprintf( |
| 459 | - __( 'The following messengers are either not installed or are invalid:%1$s %2$s', 'event_espresso' ), |
|
| 459 | + __('The following messengers are either not installed or are invalid:%1$s %2$s', 'event_espresso'), |
|
| 460 | 460 | '<br />', |
| 461 | - implode( ', ', $not_installed ) |
|
| 461 | + implode(', ', $not_installed) |
|
| 462 | 462 | ), |
| 463 | 463 | __FILE__, __FUNCTION__, __LINE__ |
| 464 | 464 | ); |
@@ -474,9 +474,9 @@ discard block |
||
| 474 | 474 | * @param string $messenger_name |
| 475 | 475 | * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
| 476 | 476 | */ |
| 477 | - public function ensure_messenger_is_active( $messenger_name ) { |
|
| 478 | - if ( ! isset( $this->_active_messengers[ $messenger_name ] ) ) { |
|
| 479 | - $this->activate_messenger( $messenger_name ); |
|
| 477 | + public function ensure_messenger_is_active($messenger_name) { |
|
| 478 | + if ( ! isset($this->_active_messengers[$messenger_name])) { |
|
| 479 | + $this->activate_messenger($messenger_name); |
|
| 480 | 480 | return false; |
| 481 | 481 | } |
| 482 | 482 | return true; |
@@ -493,13 +493,13 @@ discard block |
||
| 493 | 493 | * @return array |
| 494 | 494 | * @throws \EE_Error |
| 495 | 495 | */ |
| 496 | - public function ensure_message_type_is_active( $message_type, $messenger_name ) { |
|
| 496 | + public function ensure_message_type_is_active($message_type, $messenger_name) { |
|
| 497 | 497 | // grab the messenger to work with. |
| 498 | - $messenger = $this->valid_messenger( $messenger_name ); |
|
| 499 | - if ( $this->valid_message_type_for_messenger( $messenger, $message_type ) ) { |
|
| 498 | + $messenger = $this->valid_messenger($messenger_name); |
|
| 499 | + if ($this->valid_message_type_for_messenger($messenger, $message_type)) { |
|
| 500 | 500 | //all is good so let's just get it active |
| 501 | - $this->_activate_message_types( $messenger, array( $message_type ) ); |
|
| 502 | - $this->update_active_messengers_option( $this->_active_message_types ); |
|
| 501 | + $this->_activate_message_types($messenger, array($message_type)); |
|
| 502 | + $this->update_active_messengers_option($this->_active_message_types); |
|
| 503 | 503 | } |
| 504 | 504 | return $this->active_message_types(); |
| 505 | 505 | } |
@@ -524,17 +524,17 @@ discard block |
||
| 524 | 524 | ) { |
| 525 | 525 | $templates = array(); |
| 526 | 526 | // grab the messenger to work with. |
| 527 | - $messenger = $this->messenger_collection()->get_by_info( $messenger_name ); |
|
| 527 | + $messenger = $this->messenger_collection()->get_by_info($messenger_name); |
|
| 528 | 528 | // it's inactive. Activate it. |
| 529 | - if ( $messenger instanceof EE_Messenger ) { |
|
| 530 | - $this->_active_messengers[ $messenger->name ] = $messenger; |
|
| 531 | - $message_type_names = $this->_activate_message_types( $messenger, $message_type_names ); |
|
| 532 | - if ( $update_active_messengers_option ) { |
|
| 533 | - $this->update_active_messengers_option( $this->_active_message_types ); |
|
| 529 | + if ($messenger instanceof EE_Messenger) { |
|
| 530 | + $this->_active_messengers[$messenger->name] = $messenger; |
|
| 531 | + $message_type_names = $this->_activate_message_types($messenger, $message_type_names); |
|
| 532 | + if ($update_active_messengers_option) { |
|
| 533 | + $this->update_active_messengers_option($this->_active_message_types); |
|
| 534 | 534 | } |
| 535 | 535 | // might need to generate new templates |
| 536 | - if ( ! empty( $message_type_names ) ) { |
|
| 537 | - $templates = EEH_MSG_Template::generate_new_templates( $messenger->name, $message_type_names, 0, true ); |
|
| 536 | + if ( ! empty($message_type_names)) { |
|
| 537 | + $templates = EEH_MSG_Template::generate_new_templates($messenger->name, $message_type_names, 0, true); |
|
| 538 | 538 | } |
| 539 | 539 | } |
| 540 | 540 | return $templates; |
@@ -549,16 +549,16 @@ discard block |
||
| 549 | 549 | * |
| 550 | 550 | * @return array |
| 551 | 551 | */ |
| 552 | - protected function _activate_message_types( EE_Messenger $messenger, $message_type_names = array() ) { |
|
| 552 | + protected function _activate_message_types(EE_Messenger $messenger, $message_type_names = array()) { |
|
| 553 | 553 | // get has_active so we can be sure its kept up to date. |
| 554 | 554 | $has_activated = $this->get_has_activated_messengers_option(); |
| 555 | 555 | // use incoming list of message types or if that's empty, then get defaults |
| 556 | - $message_type_names = ! empty( $message_type_names ) |
|
| 556 | + $message_type_names = ! empty($message_type_names) |
|
| 557 | 557 | ? $message_type_names |
| 558 | 558 | : $messenger->get_default_message_types(); |
| 559 | 559 | // cycle thru message types |
| 560 | - foreach ( $message_type_names as $message_type_name ) { |
|
| 561 | - $this->_add_settings_for_message_type( $messenger, $message_type_name ); |
|
| 560 | + foreach ($message_type_names as $message_type_name) { |
|
| 561 | + $this->_add_settings_for_message_type($messenger, $message_type_name); |
|
| 562 | 562 | $has_activated = $this->_set_messenger_has_activated_message_type( |
| 563 | 563 | $messenger, |
| 564 | 564 | $has_activated, |
@@ -566,8 +566,8 @@ discard block |
||
| 566 | 566 | ); |
| 567 | 567 | } |
| 568 | 568 | // setup any initial settings for the messenger |
| 569 | - $this->_add_settings_for_messenger( $messenger ); |
|
| 570 | - $this->update_has_activated_messengers_option( $has_activated ); |
|
| 569 | + $this->_add_settings_for_messenger($messenger); |
|
| 570 | + $this->update_has_activated_messengers_option($has_activated); |
|
| 571 | 571 | return $message_type_names; |
| 572 | 572 | } |
| 573 | 573 | |
@@ -580,18 +580,18 @@ discard block |
||
| 580 | 580 | * @param \EE_Messenger $messenger |
| 581 | 581 | * @param string $message_type_name |
| 582 | 582 | */ |
| 583 | - protected function _add_settings_for_message_type( EE_Messenger $messenger, $message_type_name ) { |
|
| 583 | + protected function _add_settings_for_message_type(EE_Messenger $messenger, $message_type_name) { |
|
| 584 | 584 | $settings = array(); |
| 585 | 585 | // get installed message type from collection |
| 586 | - $message_type = $this->message_type_collection()->get_by_info( $message_type_name ); |
|
| 586 | + $message_type = $this->message_type_collection()->get_by_info($message_type_name); |
|
| 587 | 587 | //we need to setup any initial settings for message types |
| 588 | - if ( $message_type instanceof EE_Message_Type ) { |
|
| 588 | + if ($message_type instanceof EE_Message_Type) { |
|
| 589 | 589 | $settings_fields = $message_type->get_admin_settings_fields(); |
| 590 | - foreach ( $settings_fields as $field => $values ) { |
|
| 591 | - $settings[ $field ] = $values[ 'default' ]; |
|
| 590 | + foreach ($settings_fields as $field => $values) { |
|
| 591 | + $settings[$field] = $values['default']; |
|
| 592 | 592 | } |
| 593 | 593 | } |
| 594 | - $this->_active_message_types[ $messenger->name ][ 'settings' ][ $messenger->name . '-message_types' ][ $message_type_name ][ 'settings' ] = $settings; |
|
| 594 | + $this->_active_message_types[$messenger->name]['settings'][$messenger->name.'-message_types'][$message_type_name]['settings'] = $settings; |
|
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | |
@@ -605,14 +605,14 @@ discard block |
||
| 605 | 605 | * @param string $message_type_name |
| 606 | 606 | * @return array |
| 607 | 607 | */ |
| 608 | - protected function _set_messenger_has_activated_message_type( EE_Messenger $messenger, $has_activated, $message_type_name ) { |
|
| 608 | + protected function _set_messenger_has_activated_message_type(EE_Messenger $messenger, $has_activated, $message_type_name) { |
|
| 609 | 609 | // make sure this messenger has a record in the has_activated array |
| 610 | - if ( ! isset( $has_activated[ $messenger->name ] ) ) { |
|
| 611 | - $has_activated[ $messenger->name ] = array(); |
|
| 610 | + if ( ! isset($has_activated[$messenger->name])) { |
|
| 611 | + $has_activated[$messenger->name] = array(); |
|
| 612 | 612 | } |
| 613 | 613 | // check if message type has already been added |
| 614 | - if ( ! in_array( $message_type_name, $has_activated[ $messenger->name ] ) ) { |
|
| 615 | - $has_activated[ $messenger->name ][] = $message_type_name; |
|
| 614 | + if ( ! in_array($message_type_name, $has_activated[$messenger->name])) { |
|
| 615 | + $has_activated[$messenger->name][] = $message_type_name; |
|
| 616 | 616 | } |
| 617 | 617 | return $has_activated; |
| 618 | 618 | } |
@@ -625,11 +625,11 @@ discard block |
||
| 625 | 625 | * @access protected |
| 626 | 626 | * @param \EE_Messenger $messenger |
| 627 | 627 | */ |
| 628 | - protected function _add_settings_for_messenger( EE_Messenger $messenger ) { |
|
| 628 | + protected function _add_settings_for_messenger(EE_Messenger $messenger) { |
|
| 629 | 629 | $msgr_settings = $messenger->get_admin_settings_fields(); |
| 630 | - if ( ! empty( $msgr_settings ) ) { |
|
| 631 | - foreach ( $msgr_settings as $field => $value ) { |
|
| 632 | - $this->_active_message_types[ $messenger->name ][ 'settings' ][ $field ] = $value; |
|
| 630 | + if ( ! empty($msgr_settings)) { |
|
| 631 | + foreach ($msgr_settings as $field => $value) { |
|
| 632 | + $this->_active_message_types[$messenger->name]['settings'][$field] = $value; |
|
| 633 | 633 | } |
| 634 | 634 | } |
| 635 | 635 | } |
@@ -643,11 +643,11 @@ discard block |
||
| 643 | 643 | * @param string $messenger name of messenger |
| 644 | 644 | * @return void |
| 645 | 645 | */ |
| 646 | - protected function _deactivate_messenger( $messenger ) { |
|
| 647 | - unset( $this->_active_messengers[ $messenger ] ); |
|
| 648 | - unset( $this->_active_message_types[ $messenger ] ); |
|
| 649 | - $this->_message_template_group_model->deactivate_message_template_groups_for( $messenger ); |
|
| 650 | - $this->update_active_messengers_option( $this->_active_message_types ); |
|
| 646 | + protected function _deactivate_messenger($messenger) { |
|
| 647 | + unset($this->_active_messengers[$messenger]); |
|
| 648 | + unset($this->_active_message_types[$messenger]); |
|
| 649 | + $this->_message_template_group_model->deactivate_message_template_groups_for($messenger); |
|
| 650 | + $this->update_active_messengers_option($this->_active_message_types); |
|
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | |
@@ -656,14 +656,14 @@ discard block |
||
| 656 | 656 | * |
| 657 | 657 | * @param string $message_type_name name of message type being deactivated |
| 658 | 658 | */ |
| 659 | - protected function _deactivate_message_type( $message_type_name ) { |
|
| 660 | - foreach ( $this->_active_message_types as $messenger => $settings ) { |
|
| 659 | + protected function _deactivate_message_type($message_type_name) { |
|
| 660 | + foreach ($this->_active_message_types as $messenger => $settings) { |
|
| 661 | 661 | unset( |
| 662 | - $this->_active_message_types[ $messenger ][ 'settings' ][ $messenger . '-message_types' ][ $message_type_name ] |
|
| 662 | + $this->_active_message_types[$messenger]['settings'][$messenger.'-message_types'][$message_type_name] |
|
| 663 | 663 | ); |
| 664 | 664 | } |
| 665 | - $this->_message_template_group_model->deactivate_message_template_groups_for( '', $message_type_name ); |
|
| 666 | - $this->update_active_messengers_option( $this->_active_message_types ); |
|
| 665 | + $this->_message_template_group_model->deactivate_message_template_groups_for('', $message_type_name); |
|
| 666 | + $this->update_active_messengers_option($this->_active_message_types); |
|
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | |
@@ -677,12 +677,12 @@ discard block |
||
| 677 | 677 | * |
| 678 | 678 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
| 679 | 679 | */ |
| 680 | - public function is_generating_messenger_and_active( EE_Messenger $messenger, EE_message_type $message_type ) { |
|
| 680 | + public function is_generating_messenger_and_active(EE_Messenger $messenger, EE_message_type $message_type) { |
|
| 681 | 681 | //get the $messengers the message type says it can be used with. |
| 682 | - foreach ( $message_type->with_messengers() as $generating_messenger => $secondary_messengers ) { |
|
| 682 | + foreach ($message_type->with_messengers() as $generating_messenger => $secondary_messengers) { |
|
| 683 | 683 | if ( |
| 684 | 684 | $messenger->name == $generating_messenger |
| 685 | - && isset( $this->_active_message_types[ $generating_messenger ][ $message_type->name ] ) |
|
| 685 | + && isset($this->_active_message_types[$generating_messenger][$message_type->name]) |
|
| 686 | 686 | ) { |
| 687 | 687 | return true; |
| 688 | 688 | } |
@@ -721,25 +721,25 @@ discard block |
||
| 721 | 721 | * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by message type. |
| 722 | 722 | * @return array |
| 723 | 723 | */ |
| 724 | - public function get_all_contexts( $slugs_only = true ) { |
|
| 724 | + public function get_all_contexts($slugs_only = true) { |
|
| 725 | 725 | $key = $slugs_only ? 'slugs' : 'all'; |
| 726 | 726 | // check if contexts has been setup yet. |
| 727 | - if ( empty( $this->_contexts[ $key ] ) ) { |
|
| 727 | + if (empty($this->_contexts[$key])) { |
|
| 728 | 728 | // So let's get all active message type objects and loop through to get all unique contexts |
| 729 | - foreach ( $this->get_active_message_type_objects() as $message_type ) { |
|
| 730 | - if ( $message_type instanceof EE_message_type ) { |
|
| 729 | + foreach ($this->get_active_message_type_objects() as $message_type) { |
|
| 730 | + if ($message_type instanceof EE_message_type) { |
|
| 731 | 731 | $message_type_contexts = $message_type->get_contexts(); |
| 732 | - if ( $slugs_only ) { |
|
| 733 | - foreach ( $message_type_contexts as $context => $context_details ) { |
|
| 734 | - $this->_contexts[ $key ][ $context ] = $context_details[ 'label' ]; |
|
| 732 | + if ($slugs_only) { |
|
| 733 | + foreach ($message_type_contexts as $context => $context_details) { |
|
| 734 | + $this->_contexts[$key][$context] = $context_details['label']; |
|
| 735 | 735 | } |
| 736 | 736 | } else { |
| 737 | - $this->_contexts[ $key ][ $message_type->name ] = $message_type_contexts; |
|
| 737 | + $this->_contexts[$key][$message_type->name] = $message_type_contexts; |
|
| 738 | 738 | } |
| 739 | 739 | } |
| 740 | 740 | } |
| 741 | 741 | } |
| 742 | - return ! empty( $this->_contexts[ $key ] ) ? $this->_contexts[ $key ] : array(); |
|
| 742 | + return ! empty($this->_contexts[$key]) ? $this->_contexts[$key] : array(); |
|
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | |