@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * EE_WP_User class |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | * @param array $props_n_values |
23 | 23 | * @return EE_WP_User|mixed |
24 | 24 | */ |
25 | - public static function new_instance( $props_n_values = array() ) { |
|
26 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
27 | - return $has_object ? $has_object : new self( $props_n_values ); |
|
25 | + public static function new_instance($props_n_values = array()) { |
|
26 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
27 | + return $has_object ? $has_object : new self($props_n_values); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | * @param array $props_n_values |
34 | 34 | * @return EE_WP_User |
35 | 35 | */ |
36 | - public static function new_instance_from_db( $props_n_values = array() ) { |
|
37 | - return new self( $props_n_values, TRUE ); |
|
36 | + public static function new_instance_from_db($props_n_values = array()) { |
|
37 | + return new self($props_n_values, TRUE); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * @return WP_User |
43 | 43 | */ |
44 | 44 | public function wp_user_obj() { |
45 | - if( ! $this->_wp_user_obj ) { |
|
46 | - $this->_wp_user_obj = get_user_by('ID', $this->ID() ); |
|
45 | + if ( ! $this->_wp_user_obj) { |
|
46 | + $this->_wp_user_obj = get_user_by('ID', $this->ID()); |
|
47 | 47 | } |
48 | 48 | return $this->_wp_user_obj; |
49 | 49 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $_SERVER['REQUEST_URI'] |
70 | 70 | ) |
71 | 71 | ), |
72 | - get_edit_user_link( $this->ID() ) |
|
72 | + get_edit_user_link($this->ID()) |
|
73 | 73 | ) |
74 | 74 | ); |
75 | 75 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @return string |
88 | 88 | */ |
89 | 89 | public function get_admin_overview_link() { |
90 | - return admin_url( 'users.php' ); |
|
90 | + return admin_url('users.php'); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 |
@@ -421,7 +421,7 @@ |
||
421 | 421 | if ( ! empty( $sending_messenger ) ) { |
422 | 422 | $with_messengers = $message_type->with_messengers(); |
423 | 423 | if ( ! isset( $with_messengers[$message->messenger()] ) |
424 | - || ! in_array( $sending_messenger, $with_messengers[$message->messenger()] ) ) { |
|
424 | + || ! in_array( $sending_messenger, $with_messengers[$message->messenger()] ) ) { |
|
425 | 425 | throw new EE_Error( sprintf( __('The given sending messenger string (%s) does not match a valid sending messenger with the %s. If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.', 'event_espresso'), $sending_messenger, get_class( $message_type ) ) ); |
426 | 426 | } |
427 | 427 | } else { |
@@ -6,8 +6,9 @@ |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage messages |
8 | 8 | */ |
9 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
9 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
10 | 10 | exit('NO direct script access allowed'); |
11 | +} |
|
11 | 12 | |
12 | 13 | /** |
13 | 14 | * |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * Updates all message templates matching the incoming messengers and message types to active status. |
144 | 144 | * |
145 | 145 | * @static |
146 | - * @param array $messenger_names Messenger slug |
|
146 | + * @param string[] $messenger_names Messenger slug |
|
147 | 147 | * @param array $message_type_names Message type slug |
148 | 148 | * @return int count of updated records. |
149 | 149 | */ |
@@ -454,6 +454,7 @@ discard block |
||
454 | 454 | * @param EE_Registration | null $registration The registration object must be included if this |
455 | 455 | * is going to be a registration trigger url. |
456 | 456 | * @param string $sending_messenger The (optional) sending messenger for the url. |
457 | + * @param EE_Registration $registration |
|
457 | 458 | * |
458 | 459 | * @return string |
459 | 460 | * @throws EE_Error |
@@ -1008,8 +1009,8 @@ discard block |
||
1008 | 1009 | /** |
1009 | 1010 | * @param \EE_messenger $messenger |
1010 | 1011 | * @param \EE_message_type $message_type |
1011 | - * @param $GRP_ID |
|
1012 | - * @param $global |
|
1012 | + * @param integer $GRP_ID |
|
1013 | + * @param boolean $global |
|
1013 | 1014 | * @return array|mixed |
1014 | 1015 | */ |
1015 | 1016 | protected static function _create_new_templates( EE_messenger $messenger, EE_message_type $message_type, $GRP_ID, $global ) { |
@@ -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 | /** |
@@ -59,24 +59,24 @@ discard block |
||
59 | 59 | * was not a new generated template but just reactivated (which only happens for global templates that |
60 | 60 | * already exist in the database. |
61 | 61 | */ |
62 | - public static function generate_new_templates( $messenger, $message_types, $GRP_ID = 0, $global = false ) { |
|
62 | + public static function generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false) { |
|
63 | 63 | //make sure message_type is an array. |
64 | 64 | $message_types = (array) $message_types; |
65 | 65 | $templates = array(); |
66 | 66 | |
67 | - if ( empty( $messenger ) ) { |
|
68 | - throw new EE_Error( __('We need a messenger to generate templates!', 'event_espresso') ); |
|
67 | + if (empty($messenger)) { |
|
68 | + throw new EE_Error(__('We need a messenger to generate templates!', 'event_espresso')); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | //if we STILL have empty $message_types then we need to generate an error message b/c we NEED message types to do the template files. |
72 | - if ( empty( $message_types ) ) { |
|
73 | - throw new EE_Error( __('We need at least one message type to generate templates!', 'event_espresso') ); |
|
72 | + if (empty($message_types)) { |
|
73 | + throw new EE_Error(__('We need at least one message type to generate templates!', 'event_espresso')); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | EEH_MSG_Template::_set_autoloader(); |
77 | - foreach ( $message_types as $message_type ) { |
|
77 | + foreach ($message_types as $message_type) { |
|
78 | 78 | //if global then let's attempt to get the GRP_ID for this combo IF GRP_ID is empty. |
79 | - if ( $global && empty( $GRP_ID ) ) { |
|
79 | + if ($global && empty($GRP_ID)) { |
|
80 | 80 | $GRP_ID = EEM_Message_Template_Group::instance()->get_one( |
81 | 81 | array( |
82 | 82 | array( |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | // if this is global template generation. |
92 | 92 | // First let's determine if we already HAVE global templates for this messenger and message_type combination. |
93 | 93 | // If we do then NO generation!! |
94 | - if ( $global && EEH_MSG_Template::already_generated( $messenger, $message_type, $GRP_ID ) ) { |
|
94 | + if ($global && EEH_MSG_Template::already_generated($messenger, $message_type, $GRP_ID)) { |
|
95 | 95 | $templates[] = array( |
96 | 96 | 'GRP_ID' => $GRP_ID, |
97 | 97 | 'MTP_context' => '', |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | //we already have generated templates for this so let's go to the next message type. |
100 | 100 | continue; |
101 | 101 | } |
102 | - $new_message_template_group = EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $global ); |
|
102 | + $new_message_template_group = EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $global); |
|
103 | 103 | |
104 | - if ( ! $new_message_template_group ) { |
|
104 | + if ( ! $new_message_template_group) { |
|
105 | 105 | continue; |
106 | 106 | } |
107 | 107 | $templates[] = $new_message_template_group; |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | * @param int $GRP_ID GRP ID ( if a custom template) (if not provided then we're just doing global template check) |
119 | 119 | * @return bool true = generated, false = hasn't been generated. |
120 | 120 | */ |
121 | - public static function already_generated( $messenger, $message_type, $GRP_ID = 0 ) { |
|
121 | + public static function already_generated($messenger, $message_type, $GRP_ID = 0) { |
|
122 | 122 | EEH_MSG_Template::_set_autoloader(); |
123 | 123 | //what method we use depends on whether we have an GRP_ID or not |
124 | - $count = empty( $GRP_ID ) |
|
124 | + $count = empty($GRP_ID) |
|
125 | 125 | ? EEM_Message_Template::instance()->count( |
126 | 126 | array( |
127 | 127 | array( |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | ) |
132 | 132 | ) |
133 | 133 | ) |
134 | - : EEM_Message_Template::instance()->count( array( array( 'GRP_ID' => $GRP_ID ) ) ); |
|
134 | + : EEM_Message_Template::instance()->count(array(array('GRP_ID' => $GRP_ID))); |
|
135 | 135 | |
136 | 136 | return $count > 0; |
137 | 137 | } |
@@ -147,15 +147,15 @@ discard block |
||
147 | 147 | * @param array $message_type_names Message type slug |
148 | 148 | * @return int count of updated records. |
149 | 149 | */ |
150 | - public static function update_to_active( $messenger_names, $message_type_names ) { |
|
151 | - $messenger_names = is_array( $messenger_names ) ? $messenger_names : array( $messenger_names ); |
|
152 | - $message_type_names = is_array( $message_type_names ) ? $message_type_names : array( $message_type_names ); |
|
150 | + public static function update_to_active($messenger_names, $message_type_names) { |
|
151 | + $messenger_names = is_array($messenger_names) ? $messenger_names : array($messenger_names); |
|
152 | + $message_type_names = is_array($message_type_names) ? $message_type_names : array($message_type_names); |
|
153 | 153 | return EEM_Message_Template_Group::instance()->update( |
154 | - array( 'MTP_is_active' => 1 ), |
|
154 | + array('MTP_is_active' => 1), |
|
155 | 155 | array( |
156 | 156 | array( |
157 | - 'MTP_messenger' => array( 'IN', $messenger_names ), |
|
158 | - 'MTP_message_type' => array( 'IN', $message_type_names ) |
|
157 | + 'MTP_messenger' => array('IN', $messenger_names), |
|
158 | + 'MTP_message_type' => array('IN', $message_type_names) |
|
159 | 159 | ) |
160 | 160 | ) |
161 | 161 | ); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return int count of updated records. |
178 | 178 | */ |
179 | - public static function update_to_inactive( $messenger_names = array(), $message_type_names = array() ) { |
|
179 | + public static function update_to_inactive($messenger_names = array(), $message_type_names = array()) { |
|
180 | 180 | return EEM_Message_Template_Group::instance()->deactivate_message_template_groups_for( |
181 | 181 | $messenger_names, |
182 | 182 | $message_type_names |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | * @param string $type |
194 | 194 | * @return array array consisting of installed messenger objects and installed message type objects. |
195 | 195 | */ |
196 | - public static function get_installed_message_objects( $type = 'all' ) { |
|
196 | + public static function get_installed_message_objects($type = 'all') { |
|
197 | 197 | self::_set_autoloader(); |
198 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
198 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
199 | 199 | return array( |
200 | 200 | 'messenger' => $message_resource_manager->installed_messengers(), |
201 | 201 | 'message_type' => $message_resource_manager->installed_message_types() |
@@ -231,74 +231,74 @@ discard block |
||
231 | 231 | $context = 'admin', |
232 | 232 | $merged = false |
233 | 233 | ) { |
234 | - $messenger_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $messenger ) ) ); |
|
235 | - $mt_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $message_type ) ) ); |
|
234 | + $messenger_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $messenger))); |
|
235 | + $mt_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $message_type))); |
|
236 | 236 | /** @var EE_Message_Resource_Manager $message_resource_manager */ |
237 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
237 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
238 | 238 | //convert slug to object |
239 | - $messenger = $message_resource_manager->get_messenger( $messenger ); |
|
239 | + $messenger = $message_resource_manager->get_messenger($messenger); |
|
240 | 240 | |
241 | 241 | //if messenger isn't a EE_messenger resource then bail. |
242 | - if ( ! $messenger instanceof EE_messenger ) { |
|
242 | + if ( ! $messenger instanceof EE_messenger) { |
|
243 | 243 | return array(); |
244 | 244 | } |
245 | 245 | |
246 | 246 | //validate class for getting our list of shortcodes |
247 | - $classname = 'EE_Messages_' . $messenger_name . '_' . $mt_name . '_Validator'; |
|
248 | - if ( ! class_exists( $classname ) ) { |
|
249 | - $msg[] = __( 'The Validator class was unable to load', 'event_espresso' ); |
|
247 | + $classname = 'EE_Messages_'.$messenger_name.'_'.$mt_name.'_Validator'; |
|
248 | + if ( ! class_exists($classname)) { |
|
249 | + $msg[] = __('The Validator class was unable to load', 'event_espresso'); |
|
250 | 250 | $msg[] = sprintf( |
251 | - __( 'The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', 'event_espresso' ), |
|
251 | + __('The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', 'event_espresso'), |
|
252 | 252 | $classname |
253 | 253 | ); |
254 | - throw new EE_Error( implode( '||', $msg ) ); |
|
254 | + throw new EE_Error(implode('||', $msg)); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** @type EE_Messages_Validator $_VLD */ |
258 | - $_VLD = new $classname( array(), $context ); |
|
258 | + $_VLD = new $classname(array(), $context); |
|
259 | 259 | $valid_shortcodes = $_VLD->get_validators(); |
260 | 260 | |
261 | 261 | //let's make sure we're only getting the shortcode part of the validators |
262 | 262 | $shortcodes = array(); |
263 | - foreach ( $valid_shortcodes as $field => $validators ) { |
|
264 | - $shortcodes[ $field ] = $validators['shortcodes']; |
|
263 | + foreach ($valid_shortcodes as $field => $validators) { |
|
264 | + $shortcodes[$field] = $validators['shortcodes']; |
|
265 | 265 | } |
266 | 266 | $valid_shortcodes = $shortcodes; |
267 | 267 | |
268 | 268 | //if not all fields let's make sure we ONLY include the shortcodes for the specified fields. |
269 | - if ( ! empty( $fields ) ) { |
|
269 | + if ( ! empty($fields)) { |
|
270 | 270 | $specified_shortcodes = array(); |
271 | - foreach ( $fields as $field ) { |
|
272 | - if ( isset( $valid_shortcodes[ $field ] ) ) { |
|
273 | - $specified_shortcodes[ $field ] = $valid_shortcodes[ $field ]; |
|
271 | + foreach ($fields as $field) { |
|
272 | + if (isset($valid_shortcodes[$field])) { |
|
273 | + $specified_shortcodes[$field] = $valid_shortcodes[$field]; |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | $valid_shortcodes = $specified_shortcodes; |
277 | 277 | } |
278 | 278 | |
279 | 279 | //if not merged then let's replace the fields with the localized fields |
280 | - if ( ! $merged ) { |
|
280 | + if ( ! $merged) { |
|
281 | 281 | //let's get all the fields for the set messenger so that we can get the localized label and use that in the returned array. |
282 | 282 | $field_settings = $messenger->get_template_fields(); |
283 | 283 | $localized = array(); |
284 | - foreach ( $valid_shortcodes as $field => $shortcodes ) { |
|
284 | + foreach ($valid_shortcodes as $field => $shortcodes) { |
|
285 | 285 | //get localized field label |
286 | - if ( isset( $field_settings[ $field ] ) ) { |
|
286 | + if (isset($field_settings[$field])) { |
|
287 | 287 | //possible that this is used as a main field. |
288 | - if ( empty( $field_settings[ $field ] ) ) { |
|
289 | - if ( isset( $field_settings['extra'][ $field ] ) ) { |
|
290 | - $_field = $field_settings['extra'][ $field ]['main']['label']; |
|
288 | + if (empty($field_settings[$field])) { |
|
289 | + if (isset($field_settings['extra'][$field])) { |
|
290 | + $_field = $field_settings['extra'][$field]['main']['label']; |
|
291 | 291 | } else { |
292 | 292 | $_field = $field; |
293 | 293 | } |
294 | 294 | } else { |
295 | - $_field = $field_settings[ $field ]['label']; |
|
295 | + $_field = $field_settings[$field]['label']; |
|
296 | 296 | } |
297 | - } else if ( isset( $field_settings['extra'] ) ) { |
|
297 | + } else if (isset($field_settings['extra'])) { |
|
298 | 298 | //loop through extra "main fields" and see if any of their children have our field |
299 | - foreach ( $field_settings['extra'] as $main_field => $fields ) { |
|
300 | - if ( isset( $fields[ $field ] ) ) { |
|
301 | - $_field = $fields[ $field ]['label']; |
|
299 | + foreach ($field_settings['extra'] as $main_field => $fields) { |
|
300 | + if (isset($fields[$field])) { |
|
301 | + $_field = $fields[$field]['label']; |
|
302 | 302 | } else { |
303 | 303 | $_field = $field; |
304 | 304 | } |
@@ -306,22 +306,22 @@ discard block |
||
306 | 306 | } else { |
307 | 307 | $_field = $field; |
308 | 308 | } |
309 | - if ( isset( $_field ) ) { |
|
310 | - $localized[ $_field ] = $shortcodes; |
|
309 | + if (isset($_field)) { |
|
310 | + $localized[$_field] = $shortcodes; |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | $valid_shortcodes = $localized; |
314 | 314 | } |
315 | 315 | |
316 | 316 | //if $merged then let's merge all the shortcodes into one list NOT indexed by field. |
317 | - if ( $merged ) { |
|
317 | + if ($merged) { |
|
318 | 318 | $merged_codes = array(); |
319 | - foreach ( $valid_shortcodes as $field => $shortcode ) { |
|
320 | - foreach ( $shortcode as $code => $label ) { |
|
321 | - if ( isset( $merged_codes[ $code ] ) ) { |
|
319 | + foreach ($valid_shortcodes as $field => $shortcode) { |
|
320 | + foreach ($shortcode as $code => $label) { |
|
321 | + if (isset($merged_codes[$code])) { |
|
322 | 322 | continue; |
323 | 323 | } else { |
324 | - $merged_codes[ $code ] = $label; |
|
324 | + $merged_codes[$code] = $label; |
|
325 | 325 | } |
326 | 326 | } |
327 | 327 | } |
@@ -341,10 +341,10 @@ discard block |
||
341 | 341 | * @throws \EE_Error |
342 | 342 | * @return EE_messenger |
343 | 343 | */ |
344 | - public static function messenger_obj( $messenger ) { |
|
344 | + public static function messenger_obj($messenger) { |
|
345 | 345 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
346 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
347 | - return $Message_Resource_Manager->get_messenger( $messenger ); |
|
346 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
347 | + return $Message_Resource_Manager->get_messenger($messenger); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | |
@@ -357,10 +357,10 @@ discard block |
||
357 | 357 | * @throws \EE_Error |
358 | 358 | * @return EE_message_type |
359 | 359 | */ |
360 | - public static function message_type_obj( $message_type ) { |
|
360 | + public static function message_type_obj($message_type) { |
|
361 | 361 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
362 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
363 | - return $Message_Resource_Manager->get_message_type( $message_type ); |
|
362 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
363 | + return $Message_Resource_Manager->get_message_type($message_type); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | |
@@ -374,11 +374,11 @@ discard block |
||
374 | 374 | * @param string $message_type message type to check for. |
375 | 375 | * @return boolean |
376 | 376 | */ |
377 | - public static function is_mt_active( $message_type ) { |
|
377 | + public static function is_mt_active($message_type) { |
|
378 | 378 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
379 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
379 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
380 | 380 | $active_mts = $Message_Resource_Manager->list_of_active_message_types(); |
381 | - return in_array( $message_type, $active_mts ); |
|
381 | + return in_array($message_type, $active_mts); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | |
@@ -391,10 +391,10 @@ discard block |
||
391 | 391 | * @param string $messenger slug for messenger to check. |
392 | 392 | * @return boolean |
393 | 393 | */ |
394 | - public static function is_messenger_active( $messenger ) { |
|
394 | + public static function is_messenger_active($messenger) { |
|
395 | 395 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
396 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
397 | - $active_messenger = $Message_Resource_Manager->get_active_messenger( $messenger ); |
|
396 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
397 | + $active_messenger = $Message_Resource_Manager->get_active_messenger($messenger); |
|
398 | 398 | return $active_messenger instanceof EE_messenger ? true : false; |
399 | 399 | } |
400 | 400 | |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | public static function get_active_messengers_in_db() { |
413 | 413 | EE_Error::doing_it_wrong( |
414 | 414 | __METHOD__, |
415 | - __( 'Please use EE_Message_Resource_Manager::get_active_messengers_option() instead.', 'event_espresso' ), |
|
415 | + __('Please use EE_Message_Resource_Manager::get_active_messengers_option() instead.', 'event_espresso'), |
|
416 | 416 | '4.9.0' |
417 | 417 | ); |
418 | 418 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
419 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
419 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
420 | 420 | return $Message_Resource_Manager->get_active_messengers_option(); |
421 | 421 | } |
422 | 422 | |
@@ -433,15 +433,15 @@ discard block |
||
433 | 433 | * |
434 | 434 | * @return bool FALSE if not updated, TRUE if updated. |
435 | 435 | */ |
436 | - public static function update_active_messengers_in_db( $data_to_save ) { |
|
436 | + public static function update_active_messengers_in_db($data_to_save) { |
|
437 | 437 | EE_Error::doing_it_wrong( |
438 | 438 | __METHOD__, |
439 | - __( 'Please use EE_Message_Resource_Manager::update_active_messengers_option() instead.', 'event_espresso' ), |
|
439 | + __('Please use EE_Message_Resource_Manager::update_active_messengers_option() instead.', 'event_espresso'), |
|
440 | 440 | '4.9.0' |
441 | 441 | ); |
442 | 442 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
443 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
444 | - return $Message_Resource_Manager->update_active_messengers_option( $data_to_save ); |
|
443 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
444 | + return $Message_Resource_Manager->update_active_messengers_option($data_to_save); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | |
@@ -465,34 +465,34 @@ discard block |
||
465 | 465 | $sending_messenger = '' |
466 | 466 | ) { |
467 | 467 | //first determine if the url can be to the EE_Message object. |
468 | - if ( ! $message_type->always_generate() ) { |
|
469 | - return EEH_MSG_Template::generate_browser_trigger( $message ); |
|
468 | + if ( ! $message_type->always_generate()) { |
|
469 | + return EEH_MSG_Template::generate_browser_trigger($message); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | //if $registration object is not valid then exit early because there's nothing that can be generated. |
473 | - if ( ! $registration instanceof EE_Registration ) { |
|
473 | + if ( ! $registration instanceof EE_Registration) { |
|
474 | 474 | throw new EE_Error( |
475 | - __( 'Incoming value for registration is not a valid EE_Registration object.', 'event_espresso' ) |
|
475 | + __('Incoming value for registration is not a valid EE_Registration object.', 'event_espresso') |
|
476 | 476 | ); |
477 | 477 | } |
478 | 478 | |
479 | 479 | //validate given context |
480 | 480 | $contexts = $message_type->get_contexts(); |
481 | - if ( $message->context() !== '' && ! isset( $contexts[$message->context()] ) ) { |
|
481 | + if ($message->context() !== '' && ! isset($contexts[$message->context()])) { |
|
482 | 482 | throw new EE_Error( |
483 | 483 | sprintf( |
484 | - __( 'The context %s is not a valid context for %s.', 'event_espresso' ), |
|
484 | + __('The context %s is not a valid context for %s.', 'event_espresso'), |
|
485 | 485 | $message->context(), |
486 | - get_class( $message_type ) |
|
486 | + get_class($message_type) |
|
487 | 487 | ) |
488 | 488 | ); |
489 | 489 | } |
490 | 490 | |
491 | 491 | //valid sending messenger but only if sending messenger set. Otherwise generating messenger is used. |
492 | - if ( ! empty( $sending_messenger ) ) { |
|
492 | + if ( ! empty($sending_messenger)) { |
|
493 | 493 | $with_messengers = $message_type->with_messengers(); |
494 | - if ( ! isset( $with_messengers[$message->messenger()] ) |
|
495 | - || ! in_array( $sending_messenger, $with_messengers[$message->messenger()] ) ) { |
|
494 | + if ( ! isset($with_messengers[$message->messenger()]) |
|
495 | + || ! in_array($sending_messenger, $with_messengers[$message->messenger()])) { |
|
496 | 496 | throw new EE_Error( |
497 | 497 | sprintf( |
498 | 498 | __( |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | 'event_espresso' |
501 | 501 | ), |
502 | 502 | $sending_messenger, |
503 | - get_class( $message_type ) |
|
503 | + get_class($message_type) |
|
504 | 504 | ) |
505 | 505 | ); |
506 | 506 | } |
@@ -523,14 +523,14 @@ discard block |
||
523 | 523 | * @param EE_Message $message |
524 | 524 | * @return string. |
525 | 525 | */ |
526 | - public static function generate_browser_trigger( EE_Message $message ) { |
|
526 | + public static function generate_browser_trigger(EE_Message $message) { |
|
527 | 527 | $query_args = array( |
528 | 528 | 'ee' => 'msg_browser_trigger', |
529 | 529 | 'token' => $message->MSG_token() |
530 | 530 | ); |
531 | 531 | return apply_filters( |
532 | 532 | 'FHEE__EEH_MSG_Template__generate_browser_trigger', |
533 | - add_query_arg( $query_args, site_url() ), |
|
533 | + add_query_arg($query_args, site_url()), |
|
534 | 534 | $message |
535 | 535 | ); |
536 | 536 | } |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * @param EE_Message $message |
546 | 546 | * @return string |
547 | 547 | */ |
548 | - public static function generate_error_display_trigger( EE_Message $message ) { |
|
548 | + public static function generate_error_display_trigger(EE_Message $message) { |
|
549 | 549 | return apply_filters( |
550 | 550 | 'FHEE__EEH_MSG_Template__generate_error_display_trigger', |
551 | 551 | add_query_arg( |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | 'GRP_ID' => $message_template_group, |
596 | 596 | 'id' => $data_id |
597 | 597 | ); |
598 | - $url = add_query_arg( $query_args, get_home_url() ); |
|
598 | + $url = add_query_arg($query_args, get_home_url()); |
|
599 | 599 | |
600 | 600 | //made it here so now we can just get the url and filter it. Filtered globally and by message type. |
601 | 601 | $url = apply_filters( |
@@ -623,9 +623,9 @@ discard block |
||
623 | 623 | * @param string $type What action to return. |
624 | 624 | * @return string |
625 | 625 | */ |
626 | - public static function get_message_action_icon( $type ) { |
|
626 | + public static function get_message_action_icon($type) { |
|
627 | 627 | $action_icons = self::get_message_action_icons(); |
628 | - return isset( $action_icons[ $type ] ) ? $action_icons[ $type ] : ''; |
|
628 | + return isset($action_icons[$type]) ? $action_icons[$type] : ''; |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | |
@@ -637,34 +637,34 @@ discard block |
||
637 | 637 | * @return array |
638 | 638 | */ |
639 | 639 | public static function get_message_action_icons() { |
640 | - return apply_filters( 'FHEE__EEH_MSG_Template__message_action_icons', |
|
640 | + return apply_filters('FHEE__EEH_MSG_Template__message_action_icons', |
|
641 | 641 | array( |
642 | 642 | 'view' => array( |
643 | - 'label' => __( 'View Message', 'event_espresso' ), |
|
643 | + 'label' => __('View Message', 'event_espresso'), |
|
644 | 644 | 'css_class' => 'dashicons dashicons-welcome-view-site', |
645 | 645 | ), |
646 | 646 | 'error' => array( |
647 | - 'label' => __( 'View Error Message', 'event_espresso' ), |
|
647 | + 'label' => __('View Error Message', 'event_espresso'), |
|
648 | 648 | 'css_class' => 'dashicons dashicons-info', |
649 | 649 | ), |
650 | 650 | 'see_notifications_for' => array( |
651 | - 'label' => __( 'View Related Messages', 'event_espresso' ), |
|
651 | + 'label' => __('View Related Messages', 'event_espresso'), |
|
652 | 652 | 'css_class' => 'dashicons dashicons-megaphone', |
653 | 653 | ), |
654 | 654 | 'generate_now' => array( |
655 | - 'label' => __( 'Generate the message now.', 'event_espresso' ), |
|
655 | + 'label' => __('Generate the message now.', 'event_espresso'), |
|
656 | 656 | 'css_class' => 'dashicons dashicons-admin-tools', |
657 | 657 | ), |
658 | 658 | 'send_now' => array( |
659 | - 'label' => __( 'Send Immediately', 'event_espresso' ), |
|
659 | + 'label' => __('Send Immediately', 'event_espresso'), |
|
660 | 660 | 'css_class' => 'dashicons dashicons-controls-forward', |
661 | 661 | ), |
662 | 662 | 'queue_for_resending' => array( |
663 | - 'label' => __( 'Queue for Resending', 'event_espresso' ), |
|
663 | + 'label' => __('Queue for Resending', 'event_espresso'), |
|
664 | 664 | 'css_class' => 'dashicons dashicons-controls-repeat', |
665 | 665 | ), |
666 | 666 | 'view_transaction' => array( |
667 | - 'label' => __( 'View related Transaction', 'event_espresso' ), |
|
667 | + 'label' => __('View related Transaction', 'event_espresso'), |
|
668 | 668 | 'css_class' => 'dashicons dashicons-cart', |
669 | 669 | ) |
670 | 670 | ) |
@@ -683,9 +683,9 @@ discard block |
||
683 | 683 | * |
684 | 684 | * @return string |
685 | 685 | */ |
686 | - public static function get_message_action_url( $type, EE_Message $message = null, $query_params = array() ) { |
|
687 | - $action_urls = self::get_message_action_urls( $message, $query_params ); |
|
688 | - return isset( $action_urls[ $type ] ) ? $action_urls[ $type ] : ''; |
|
686 | + public static function get_message_action_url($type, EE_Message $message = null, $query_params = array()) { |
|
687 | + $action_urls = self::get_message_action_urls($message, $query_params); |
|
688 | + return isset($action_urls[$type]) ? $action_urls[$type] : ''; |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | |
@@ -700,15 +700,15 @@ discard block |
||
700 | 700 | * |
701 | 701 | * @return array |
702 | 702 | */ |
703 | - public static function get_message_action_urls( EE_Message $message = null, $query_params = array() ) { |
|
704 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
703 | + public static function get_message_action_urls(EE_Message $message = null, $query_params = array()) { |
|
704 | + EE_Registry::instance()->load_helper('URL'); |
|
705 | 705 | //if $message is not an instance of EE_Message then let's just do a dummy. |
706 | - $message = empty( $message ) ? EE_Message_Factory::create() : $message; |
|
707 | - $action_urls = apply_filters( |
|
706 | + $message = empty($message) ? EE_Message_Factory::create() : $message; |
|
707 | + $action_urls = apply_filters( |
|
708 | 708 | 'FHEE__EEH_MSG_Template__get_message_action_url', |
709 | 709 | array( |
710 | - 'view' => EEH_MSG_Template::generate_browser_trigger( $message ), |
|
711 | - 'error' => EEH_MSG_Template::generate_error_display_trigger( $message ), |
|
710 | + 'view' => EEH_MSG_Template::generate_browser_trigger($message), |
|
711 | + 'error' => EEH_MSG_Template::generate_error_display_trigger($message), |
|
712 | 712 | 'see_notifications_for' => EEH_URL::add_query_args_and_nonce( |
713 | 713 | array_merge( |
714 | 714 | array( |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | ), |
719 | 719 | $query_params |
720 | 720 | ), |
721 | - admin_url( 'admin.php' ) |
|
721 | + admin_url('admin.php') |
|
722 | 722 | ), |
723 | 723 | 'generate_now' => EEH_URL::add_query_args_and_nonce( |
724 | 724 | array( |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | 'action' => 'generate_now', |
727 | 727 | 'MSG_ID' => $message->ID() |
728 | 728 | ), |
729 | - admin_url( 'admin.php' ) |
|
729 | + admin_url('admin.php') |
|
730 | 730 | ), |
731 | 731 | 'send_now' => EEH_URL::add_query_args_and_nonce( |
732 | 732 | array( |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | 'action' => 'send_now', |
735 | 735 | 'MSG_ID' => $message->ID() |
736 | 736 | ), |
737 | - admin_url( 'admin.php' ) |
|
737 | + admin_url('admin.php') |
|
738 | 738 | ), |
739 | 739 | 'queue_for_resending' => EEH_URL::add_query_args_and_nonce( |
740 | 740 | array( |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | 'action' => 'queue_for_resending', |
743 | 743 | 'MSG_ID' => $message->ID() |
744 | 744 | ), |
745 | - admin_url( 'admin.php' ) |
|
745 | + admin_url('admin.php') |
|
746 | 746 | ), |
747 | 747 | ) |
748 | 748 | ); |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | 'action' => 'view_transaction', |
761 | 761 | 'TXN_ID' => $message->TXN_ID() |
762 | 762 | ), |
763 | - admin_url( 'admin.php' ) |
|
763 | + admin_url('admin.php') |
|
764 | 764 | ); |
765 | 765 | } else { |
766 | 766 | $action_urls['view_transaction'] = ''; |
@@ -781,26 +781,26 @@ discard block |
||
781 | 781 | * |
782 | 782 | * @return string |
783 | 783 | */ |
784 | - public static function get_message_action_link( $type, EE_Message $message = null, $query_params = array() ) { |
|
785 | - $url = EEH_MSG_Template::get_message_action_url( $type, $message, $query_params ); |
|
786 | - $icon_css = EEH_MSG_Template::get_message_action_icon( $type ); |
|
787 | - $title = isset( $icon_css['label'] ) ? 'title="' . $icon_css['label'] . '"' : ''; |
|
784 | + public static function get_message_action_link($type, EE_Message $message = null, $query_params = array()) { |
|
785 | + $url = EEH_MSG_Template::get_message_action_url($type, $message, $query_params); |
|
786 | + $icon_css = EEH_MSG_Template::get_message_action_icon($type); |
|
787 | + $title = isset($icon_css['label']) ? 'title="'.$icon_css['label'].'"' : ''; |
|
788 | 788 | |
789 | - if ( empty( $url ) || empty( $icon_css ) || ! isset( $icon_css['css_class'] ) ) { |
|
789 | + if (empty($url) || empty($icon_css) || ! isset($icon_css['css_class'])) { |
|
790 | 790 | return ''; |
791 | 791 | } |
792 | 792 | |
793 | 793 | $icon_css['css_class'] .= esc_attr( |
794 | 794 | apply_filters( |
795 | 795 | 'FHEE__EEH_MSG_Template__get_message_action_link__icon_css_class', |
796 | - ' js-ee-message-action-link ee-message-action-link-' . $type, |
|
796 | + ' js-ee-message-action-link ee-message-action-link-'.$type, |
|
797 | 797 | $type, |
798 | 798 | $message, |
799 | 799 | $query_params |
800 | 800 | ) |
801 | 801 | ); |
802 | 802 | |
803 | - return '<a href="' . $url . '"' . $title . '><span class="' . esc_attr( $icon_css['css_class'] ) . '"></span></a>'; |
|
803 | + return '<a href="'.$url.'"'.$title.'><span class="'.esc_attr($icon_css['css_class']).'"></span></a>'; |
|
804 | 804 | |
805 | 805 | } |
806 | 806 | |
@@ -838,9 +838,9 @@ discard block |
||
838 | 838 | * @param $reg_status |
839 | 839 | * @return string |
840 | 840 | */ |
841 | - public static function convert_reg_status_to_message_type( $reg_status ) { |
|
841 | + public static function convert_reg_status_to_message_type($reg_status) { |
|
842 | 842 | $reg_status_array = self::reg_status_to_message_type_array(); |
843 | - return isset( $reg_status_array[$reg_status] ) ? $reg_status_array[$reg_status] : ''; |
|
843 | + return isset($reg_status_array[$reg_status]) ? $reg_status_array[$reg_status] : ''; |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | |
@@ -874,9 +874,9 @@ discard block |
||
874 | 874 | * @param $payment_status |
875 | 875 | * @return string |
876 | 876 | */ |
877 | - public static function convert_payment_status_to_message_type( $payment_status ) { |
|
877 | + public static function convert_payment_status_to_message_type($payment_status) { |
|
878 | 878 | $payment_status_array = self::payment_status_to_message_type_array(); |
879 | - return isset( $payment_status_array[$payment_status] ) ? $payment_status_array[$payment_status] : ''; |
|
879 | + return isset($payment_status_array[$payment_status]) ? $payment_status_array[$payment_status] : ''; |
|
880 | 880 | } |
881 | 881 | |
882 | 882 | |
@@ -887,32 +887,32 @@ discard block |
||
887 | 887 | * |
888 | 888 | * @return EE_Messages_Template_Pack |
889 | 889 | */ |
890 | - public static function get_template_pack( $template_pack_name ) { |
|
891 | - if ( ! self::$_template_pack_collection instanceof EE_Object_Collection ) { |
|
890 | + public static function get_template_pack($template_pack_name) { |
|
891 | + if ( ! self::$_template_pack_collection instanceof EE_Object_Collection) { |
|
892 | 892 | self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection(); |
893 | 893 | } |
894 | 894 | |
895 | 895 | //first see if in collection already |
896 | - $template_pack = self::$_template_pack_collection->get_by_name( $template_pack_name ); |
|
896 | + $template_pack = self::$_template_pack_collection->get_by_name($template_pack_name); |
|
897 | 897 | |
898 | - if ( $template_pack instanceof EE_Messages_Template_Pack ) { |
|
898 | + if ($template_pack instanceof EE_Messages_Template_Pack) { |
|
899 | 899 | return $template_pack; |
900 | 900 | } |
901 | 901 | |
902 | 902 | //nope...let's get it. |
903 | 903 | //not set yet so let's attempt to get it. |
904 | - $pack_class_name = 'EE_Messages_Template_Pack_' . str_replace( |
|
904 | + $pack_class_name = 'EE_Messages_Template_Pack_'.str_replace( |
|
905 | 905 | ' ', |
906 | 906 | '_', |
907 | 907 | ucwords( |
908 | - str_replace( '_', ' ', $template_pack_name ) |
|
908 | + str_replace('_', ' ', $template_pack_name) |
|
909 | 909 | ) |
910 | 910 | ); |
911 | - if ( ! class_exists( $pack_class_name ) && $template_pack_name !== 'default' ) { |
|
912 | - return self::get_template_pack( 'default' ); |
|
911 | + if ( ! class_exists($pack_class_name) && $template_pack_name !== 'default') { |
|
912 | + return self::get_template_pack('default'); |
|
913 | 913 | } else { |
914 | 914 | $template_pack = new $pack_class_name; |
915 | - self::$_template_pack_collection->add( $template_pack ); |
|
915 | + self::$_template_pack_collection->add($template_pack); |
|
916 | 916 | return $template_pack; |
917 | 917 | } |
918 | 918 | } |
@@ -930,26 +930,26 @@ discard block |
||
930 | 930 | */ |
931 | 931 | public static function get_template_pack_collection() { |
932 | 932 | $new_collection = false; |
933 | - if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection ) { |
|
933 | + if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection) { |
|
934 | 934 | self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection(); |
935 | 935 | $new_collection = true; |
936 | 936 | } |
937 | 937 | |
938 | 938 | //glob the defaults directory for messages |
939 | - $templates = glob( EE_LIBRARIES . 'messages/defaults/*', GLOB_ONLYDIR ); |
|
940 | - foreach( $templates as $template_path ) { |
|
939 | + $templates = glob(EE_LIBRARIES.'messages/defaults/*', GLOB_ONLYDIR); |
|
940 | + foreach ($templates as $template_path) { |
|
941 | 941 | //grab folder name |
942 | - $template = basename( $template_path ); |
|
942 | + $template = basename($template_path); |
|
943 | 943 | |
944 | - if ( ! $new_collection ) { |
|
944 | + if ( ! $new_collection) { |
|
945 | 945 | //already have it? |
946 | - if ( self::$_template_pack_collection->get_by_name( $template ) instanceof EE_Messages_Template_Pack ) { |
|
946 | + if (self::$_template_pack_collection->get_by_name($template) instanceof EE_Messages_Template_Pack) { |
|
947 | 947 | continue; |
948 | 948 | } |
949 | 949 | } |
950 | 950 | |
951 | 951 | //setup classname. |
952 | - $template_pack_class_name = 'EE_Messages_Template_Pack_' . str_replace( |
|
952 | + $template_pack_class_name = 'EE_Messages_Template_Pack_'.str_replace( |
|
953 | 953 | ' ', |
954 | 954 | '_', |
955 | 955 | ucwords( |
@@ -960,20 +960,20 @@ discard block |
||
960 | 960 | ) |
961 | 961 | ) |
962 | 962 | ); |
963 | - if ( ! class_exists( $template_pack_class_name ) ) { |
|
963 | + if ( ! class_exists($template_pack_class_name)) { |
|
964 | 964 | continue; |
965 | 965 | } |
966 | - self::$_template_pack_collection->add( new $template_pack_class_name ); |
|
966 | + self::$_template_pack_collection->add(new $template_pack_class_name); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | /** |
970 | 970 | * Filter for plugins to add in any additional template packs |
971 | 971 | * Note the filter name here is for backward compat, this used to be found in EED_Messages. |
972 | 972 | */ |
973 | - $additional_template_packs = apply_filters( 'FHEE__EED_Messages__get_template_packs__template_packs', array() ); |
|
974 | - foreach ( (array) $additional_template_packs as $template_pack ) { |
|
975 | - if ( ! self::$_template_pack_collection->contains($template_pack ) ) { |
|
976 | - self::$_template_pack_collection->add( $template_pack ); |
|
973 | + $additional_template_packs = apply_filters('FHEE__EED_Messages__get_template_packs__template_packs', array()); |
|
974 | + foreach ((array) $additional_template_packs as $template_pack) { |
|
975 | + if ( ! self::$_template_pack_collection->contains($template_pack)) { |
|
976 | + self::$_template_pack_collection->add($template_pack); |
|
977 | 977 | } |
978 | 978 | } |
979 | 979 | return self::$_template_pack_collection; |
@@ -991,16 +991,16 @@ discard block |
||
991 | 991 | * @return array |
992 | 992 | * @throws \EE_Error |
993 | 993 | */ |
994 | - public static function create_new_templates( $messenger_name, $message_type_name, $GRP_ID = 0, $global = false ) { |
|
994 | + public static function create_new_templates($messenger_name, $message_type_name, $GRP_ID = 0, $global = false) { |
|
995 | 995 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
996 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
997 | - $messenger = $Message_Resource_Manager->valid_messenger( $messenger_name ); |
|
998 | - $message_type = $Message_Resource_Manager->valid_message_type( $message_type_name ); |
|
999 | - if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger( $messenger, $message_type, $global ) ) { |
|
996 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
997 | + $messenger = $Message_Resource_Manager->valid_messenger($messenger_name); |
|
998 | + $message_type = $Message_Resource_Manager->valid_message_type($message_type_name); |
|
999 | + if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger($messenger, $message_type, $global)) { |
|
1000 | 1000 | return array(); |
1001 | 1001 | } |
1002 | 1002 | //whew made it this far! Okay, let's go ahead and create the templates then |
1003 | - return EEH_MSG_Template::_create_new_templates( $messenger, $message_type, $GRP_ID, $global ); |
|
1003 | + return EEH_MSG_Template::_create_new_templates($messenger, $message_type, $GRP_ID, $global); |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | |
@@ -1012,15 +1012,15 @@ discard block |
||
1012 | 1012 | * @param $global |
1013 | 1013 | * @return array|mixed |
1014 | 1014 | */ |
1015 | - protected static function _create_new_templates( EE_messenger $messenger, EE_message_type $message_type, $GRP_ID, $global ) { |
|
1015 | + protected static function _create_new_templates(EE_messenger $messenger, EE_message_type $message_type, $GRP_ID, $global) { |
|
1016 | 1016 | //if we're creating a custom template then we don't need to use the defaults class |
1017 | - if ( ! $global ) { |
|
1018 | - return EEH_MSG_Template::_create_custom_template_group( $messenger, $message_type, $GRP_ID ); |
|
1017 | + if ( ! $global) { |
|
1018 | + return EEH_MSG_Template::_create_custom_template_group($messenger, $message_type, $GRP_ID); |
|
1019 | 1019 | } |
1020 | 1020 | /** @type EE_Messages_Template_Defaults $Message_Template_Defaults */ |
1021 | 1021 | $Message_Template_Defaults = EE_Registry::factory( |
1022 | 1022 | 'EE_Messages_Template_Defaults', |
1023 | - array( $messenger, $message_type, $GRP_ID ) |
|
1023 | + array($messenger, $message_type, $GRP_ID) |
|
1024 | 1024 | ); |
1025 | 1025 | //generate templates |
1026 | 1026 | $success = $Message_Template_Defaults->create_new_templates(); |
@@ -1028,10 +1028,10 @@ discard block |
||
1028 | 1028 | //if creating the template failed. Then we should deactivate the related message_type for the messenger because |
1029 | 1029 | //its not active if it doesn't have a template. Note this is only happening for GLOBAL template creation |
1030 | 1030 | //attempts. |
1031 | - if ( ! $success ) { |
|
1031 | + if ( ! $success) { |
|
1032 | 1032 | /** @var EE_Message_Resource_Manager $message_resource_manager */ |
1033 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1034 | - $message_resource_manager->deactivate_message_type_for_messenger( $message_type->name, $messenger->name ); |
|
1033 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1034 | + $message_resource_manager->deactivate_message_type_for_messenger($message_type->name, $messenger->name); |
|
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | /** |
@@ -1059,11 +1059,11 @@ discard block |
||
1059 | 1059 | * ) |
1060 | 1060 | * @access private |
1061 | 1061 | */ |
1062 | - private static function _create_custom_template_group( EE_messenger $messenger, EE_message_type $message_type, $GRP_ID ) { |
|
1062 | + private static function _create_custom_template_group(EE_messenger $messenger, EE_message_type $message_type, $GRP_ID) { |
|
1063 | 1063 | //defaults |
1064 | - $success = array( 'GRP_ID' => null, 'MTP_context' => '' ); |
|
1064 | + $success = array('GRP_ID' => null, 'MTP_context' => ''); |
|
1065 | 1065 | //get the template group to use as a template from the db. If $GRP_ID is empty then we'll assume the base will be the global template matching the messenger and message type. |
1066 | - $Message_Template_Group = empty( $GRP_ID ) |
|
1066 | + $Message_Template_Group = empty($GRP_ID) |
|
1067 | 1067 | ? EEM_Message_Template_Group::instance()->get_one( |
1068 | 1068 | array( |
1069 | 1069 | array( |
@@ -1073,9 +1073,9 @@ discard block |
||
1073 | 1073 | ) |
1074 | 1074 | ) |
1075 | 1075 | ) |
1076 | - : EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
1076 | + : EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
1077 | 1077 | //if we don't have a mtg at this point then we need to bail. |
1078 | - if ( ! $Message_Template_Group instanceof EE_Message_Template_Group ) { |
|
1078 | + if ( ! $Message_Template_Group instanceof EE_Message_Template_Group) { |
|
1079 | 1079 | EE_Error::add_error( |
1080 | 1080 | sprintf( |
1081 | 1081 | __( |
@@ -1094,42 +1094,42 @@ discard block |
||
1094 | 1094 | $message_templates = $Message_Template_Group->message_templates(); |
1095 | 1095 | //now we have what we need to setup the new template |
1096 | 1096 | $new_mtg = clone $Message_Template_Group; |
1097 | - $new_mtg->set( 'GRP_ID', 0 ); |
|
1098 | - $new_mtg->set( 'MTP_is_global', false ); |
|
1099 | - $template_name = defined( 'DOING_AJAX' ) && ! empty( $_POST[ 'templateName' ] ) |
|
1100 | - ? $_POST[ 'templateName' ] |
|
1097 | + $new_mtg->set('GRP_ID', 0); |
|
1098 | + $new_mtg->set('MTP_is_global', false); |
|
1099 | + $template_name = defined('DOING_AJAX') && ! empty($_POST['templateName']) |
|
1100 | + ? $_POST['templateName'] |
|
1101 | 1101 | : __( |
1102 | 1102 | 'New Custom Template', |
1103 | 1103 | 'event_espresso' |
1104 | 1104 | ); |
1105 | - $template_description = defined( "DOING_AJAX" ) && ! empty( $_POST[ 'templateDescription' ] ) |
|
1106 | - ? $_POST[ 'templateDescription' ] |
|
1105 | + $template_description = defined("DOING_AJAX") && ! empty($_POST['templateDescription']) |
|
1106 | + ? $_POST['templateDescription'] |
|
1107 | 1107 | : sprintf( |
1108 | 1108 | __( |
1109 | 1109 | 'This is a custom template that was created for the %s messenger and %s message type.', |
1110 | 1110 | 'event_espresso' |
1111 | 1111 | ), |
1112 | - $new_mtg->messenger_obj()->label[ 'singular' ], |
|
1113 | - $new_mtg->message_type_obj()->label[ 'singular' ] |
|
1112 | + $new_mtg->messenger_obj()->label['singular'], |
|
1113 | + $new_mtg->message_type_obj()->label['singular'] |
|
1114 | 1114 | ); |
1115 | - $new_mtg->set( 'MTP_name', $template_name ); |
|
1116 | - $new_mtg->set( 'MTP_description', $template_description ); |
|
1115 | + $new_mtg->set('MTP_name', $template_name); |
|
1116 | + $new_mtg->set('MTP_description', $template_description); |
|
1117 | 1117 | //remove ALL relations on this template group so they don't get saved! |
1118 | - $new_mtg->_remove_relations( 'Message_Template' ); |
|
1118 | + $new_mtg->_remove_relations('Message_Template'); |
|
1119 | 1119 | $new_mtg->save(); |
1120 | - $success[ 'GRP_ID' ] = $new_mtg->ID(); |
|
1121 | - $success[ 'template_name' ] = $template_name; |
|
1120 | + $success['GRP_ID'] = $new_mtg->ID(); |
|
1121 | + $success['template_name'] = $template_name; |
|
1122 | 1122 | //add new message templates and add relation to. |
1123 | - foreach ( $message_templates as $message_template ) { |
|
1124 | - if ( ! $message_template instanceof EE_Message_Template ) { |
|
1123 | + foreach ($message_templates as $message_template) { |
|
1124 | + if ( ! $message_template instanceof EE_Message_Template) { |
|
1125 | 1125 | continue; |
1126 | 1126 | } |
1127 | 1127 | $new_message_template = clone $message_template; |
1128 | - $new_message_template->set( 'MTP_ID', 0 ); |
|
1129 | - $new_message_template->set( 'GRP_ID', $new_mtg->ID() ); //relation |
|
1128 | + $new_message_template->set('MTP_ID', 0); |
|
1129 | + $new_message_template->set('GRP_ID', $new_mtg->ID()); //relation |
|
1130 | 1130 | $new_message_template->save(); |
1131 | - if ( empty( $success[ 'MTP_context' ] ) ) { |
|
1132 | - $success[ 'MTP_context' ] = $new_message_template->get( 'MTP_context' ); |
|
1131 | + if (empty($success['MTP_context'])) { |
|
1132 | + $success['MTP_context'] = $new_message_template->get('MTP_context'); |
|
1133 | 1133 | } |
1134 | 1134 | } |
1135 | 1135 | return $success; |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | $global = false |
1152 | 1152 | ) { |
1153 | 1153 | //is given message_type valid for given messenger (if this is not a global save) |
1154 | - if ( $global ) { |
|
1154 | + if ($global) { |
|
1155 | 1155 | return true; |
1156 | 1156 | } |
1157 | 1157 | $active_templates = EEM_Message_Template_Group::instance()->count( |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | ) |
1164 | 1164 | ) |
1165 | 1165 | ); |
1166 | - if ( $active_templates > 0 ) { |
|
1166 | + if ($active_templates > 0) { |
|
1167 | 1167 | return true; |
1168 | 1168 | } |
1169 | 1169 | EE_Error::add_error( |
@@ -1192,24 +1192,24 @@ discard block |
||
1192 | 1192 | * @param string $message_type_name name of EE_message_type |
1193 | 1193 | * @return array |
1194 | 1194 | */ |
1195 | - public static function get_fields( $messenger_name, $message_type_name ) { |
|
1195 | + public static function get_fields($messenger_name, $message_type_name) { |
|
1196 | 1196 | $template_fields = array(); |
1197 | 1197 | /** @type EE_Message_Resource_Manager $Message_Resource_Manager */ |
1198 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1199 | - $messenger = $Message_Resource_Manager->valid_messenger( $messenger_name ); |
|
1200 | - $message_type = $Message_Resource_Manager->valid_message_type( $message_type_name ); |
|
1201 | - if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger( $messenger, $message_type ) ) { |
|
1198 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1199 | + $messenger = $Message_Resource_Manager->valid_messenger($messenger_name); |
|
1200 | + $message_type = $Message_Resource_Manager->valid_message_type($message_type_name); |
|
1201 | + if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger($messenger, $message_type)) { |
|
1202 | 1202 | return array(); |
1203 | 1203 | } |
1204 | 1204 | //okay now let's assemble an array with the messenger template fields added to the message_type contexts. |
1205 | - foreach ( $message_type->get_contexts() as $context => $details ) { |
|
1206 | - foreach ( $messenger->get_template_fields() as $field => $value ) { |
|
1207 | - $template_fields[ $context ][ $field ] = $value; |
|
1205 | + foreach ($message_type->get_contexts() as $context => $details) { |
|
1206 | + foreach ($messenger->get_template_fields() as $field => $value) { |
|
1207 | + $template_fields[$context][$field] = $value; |
|
1208 | 1208 | } |
1209 | 1209 | } |
1210 | - if ( empty( $template_fields ) ) { |
|
1210 | + if (empty($template_fields)) { |
|
1211 | 1211 | EE_Error::add_error( |
1212 | - __( 'Something went wrong and we couldn\'t get any templates assembled', 'event_espresso' ), |
|
1212 | + __('Something went wrong and we couldn\'t get any templates assembled', 'event_espresso'), |
|
1213 | 1213 | __FILE__, |
1214 | 1214 | __FUNCTION__, |
1215 | 1215 | __LINE__ |
@@ -1,6 +1,6 @@ |
||
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 | * Class EE_Line_Item_Filter_Collection |
@@ -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 | /** |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @since 4.9.0 |
13 | 13 | * @author Darren Ethier |
14 | 14 | */ |
15 | -interface EEI_Query_Filter { |
|
15 | +interface EEI_Query_Filter { |
|
16 | 16 | |
17 | 17 | |
18 | 18 | /** |
@@ -1,6 +1,6 @@ |
||
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 | * Class EE_Line_Item_Filter_Collection |
@@ -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 | * Class EE_Line_Item_Filter_Base |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * @param \EEI_Line_Item $line_item |
25 | 25 | * @return \EEI_Line_Item |
26 | 26 | */ |
27 | - public function process( EEI_Line_Item $line_item ) { |
|
27 | + public function process(EEI_Line_Item $line_item) { |
|
28 | 28 | return $line_item; |
29 | 29 | } |
30 | 30 |
@@ -1,6 +1,7 @@ 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 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -717,8 +718,9 @@ discard block |
||
717 | 718 | $wrapper_template = $this->_tmp_pack->get_wrapper( $this->name, $type ); |
718 | 719 | |
719 | 720 | //check file exists and is readable |
720 | - if ( !is_readable( $wrapper_template ) ) |
|
721 | - throw new EE_Error( sprintf( __('Unable to access the template file for the %s messenger main content wrapper. The location being attempted is %s.', 'event_espresso' ), ucwords($this->label['singular']) , $wrapper_template ) ); |
|
721 | + if ( !is_readable( $wrapper_template ) ) { |
|
722 | + throw new EE_Error( sprintf( __('Unable to access the template file for the %s messenger main content wrapper. The location being attempted is %s.', 'event_espresso' ), ucwords($this->label['singular']) , $wrapper_template ) ); |
|
723 | + } |
|
722 | 724 | |
723 | 725 | //require template helper |
724 | 726 | EE_Registry::instance()->load_helper( 'Template' ); |
@@ -788,20 +790,24 @@ discard block |
||
788 | 790 | */ |
789 | 791 | public function get_field_label( $field ) { |
790 | 792 | //first let's see if the field requests is in the top level array. |
791 | - if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) ) |
|
792 | - return $this->_template[$field]['label']; |
|
793 | + if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) ) { |
|
794 | + return $this->_template[$field]['label']; |
|
795 | + } |
|
793 | 796 | |
794 | 797 | //nope so let's look in the extra array to see if it's there HOWEVER if the field exists as a top level index in the extra array then we know the label is in the 'main' index. |
795 | - if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] ) ) |
|
796 | - return $this->_template_fields['extra'][$field]['main']['label']; |
|
798 | + if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] ) ) { |
|
799 | + return $this->_template_fields['extra'][$field]['main']['label']; |
|
800 | + } |
|
797 | 801 | |
798 | 802 | //now it's possible this field may just be existing in any of the extra array items. |
799 | 803 | if ( !empty( $this->_template_fields['extra'] ) && is_array( $this->_template_fields['extra'] ) ) { |
800 | 804 | foreach ( $this->_template_fields['extra'] as $main_field => $subfields ) { |
801 | - if ( !is_array( $subfields ) ) |
|
802 | - continue; |
|
803 | - if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) ) |
|
804 | - return $subfields[$field]['label']; |
|
805 | + if ( !is_array( $subfields ) ) { |
|
806 | + continue; |
|
807 | + } |
|
808 | + if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) ) { |
|
809 | + return $subfields[$field]['label']; |
|
810 | + } |
|
805 | 811 | } |
806 | 812 | } |
807 | 813 |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | /** |
504 | 504 | * @param $message_types |
505 | 505 | * @param array $extra |
506 | - * @return mixed|string |
|
506 | + * @return string |
|
507 | 507 | */ |
508 | 508 | protected function _get_admin_content_events_edit( $message_types, $extra ) { |
509 | 509 | //defaults |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | * All this does is set the existing test settings (in the db) for the messenger |
772 | 772 | * |
773 | 773 | * @access public |
774 | - * @param $settings |
|
774 | + * @param string $settings |
|
775 | 775 | * @return bool success/fail |
776 | 776 | */ |
777 | 777 | public function set_existing_test_settings( $settings ) { |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use \EventEspresso\core\exceptions\SendMessageException; |
3 | 3 | |
4 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
5 | 5 | exit('NO direct script access allowed'); |
6 | 6 | |
7 | 7 | /** |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * @return void |
280 | 280 | */ |
281 | 281 | public function enqueue_scripts_styles() { |
282 | - do_action( 'AHEE__EE_messenger__enqueue_scripts_styles'); |
|
282 | + do_action('AHEE__EE_messenger__enqueue_scripts_styles'); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | |
350 | 350 | $this->_supports_labels->template_variation_description = __('These are different styles to choose from for the selected template structure. Usually these affect things like font style, color, borders etc. In some cases the styles will also make minor layout changes.'); |
351 | 351 | |
352 | - $this->_supports_labels = apply_filters( 'FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this ); |
|
352 | + $this->_supports_labels = apply_filters('FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this); |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | |
@@ -364,10 +364,10 @@ discard block |
||
364 | 364 | * @return stdClass |
365 | 365 | */ |
366 | 366 | public function get_supports_labels() { |
367 | - if ( empty( $this->_supports_labels->template_pack ) || empty( $this->_supports_labels->template_variation) ) { |
|
367 | + if (empty($this->_supports_labels->template_pack) || empty($this->_supports_labels->template_variation)) { |
|
368 | 368 | $this->_set_supports_labels_defaults(); |
369 | 369 | } |
370 | - return apply_filters( 'FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this ); |
|
370 | + return apply_filters('FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | |
@@ -387,10 +387,10 @@ discard block |
||
387 | 387 | * |
388 | 388 | * @return string path or url for the requested variation. |
389 | 389 | */ |
390 | - public function get_variation( EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE ) { |
|
390 | + public function get_variation(EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE) { |
|
391 | 391 | $this->_tmp_pack = $pack; |
392 | - $variation_path = apply_filters( 'EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters ); |
|
393 | - $variation_path = empty( $variation_path ) ? $this->_tmp_pack->get_variation( $this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters ) : $variation_path; |
|
392 | + $variation_path = apply_filters('EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters); |
|
393 | + $variation_path = empty($variation_path) ? $this->_tmp_pack->get_variation($this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters) : $variation_path; |
|
394 | 394 | return $variation_path; |
395 | 395 | |
396 | 396 | } |
@@ -408,13 +408,13 @@ discard block |
||
408 | 408 | * @return array |
409 | 409 | */ |
410 | 410 | public function get_default_message_types() { |
411 | - $class = get_class( $this ); |
|
411 | + $class = get_class($this); |
|
412 | 412 | |
413 | 413 | //messenger specific filter |
414 | - $default_types = apply_filters( 'FHEE__' . $class . '__get_default_message_types__default_types', $this->_default_message_types, $this ); |
|
414 | + $default_types = apply_filters('FHEE__'.$class.'__get_default_message_types__default_types', $this->_default_message_types, $this); |
|
415 | 415 | |
416 | 416 | //all messengers filter |
417 | - $default_types = apply_filters( 'FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this ); |
|
417 | + $default_types = apply_filters('FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this); |
|
418 | 418 | return $default_types; |
419 | 419 | } |
420 | 420 | |
@@ -429,14 +429,14 @@ discard block |
||
429 | 429 | * @return array |
430 | 430 | */ |
431 | 431 | public function get_valid_message_types() { |
432 | - $class = get_class( $this ); |
|
432 | + $class = get_class($this); |
|
433 | 433 | |
434 | 434 | //messenger specific filter |
435 | 435 | //messenger specific filter |
436 | - $valid_types = apply_filters( 'FHEE__' . $class . '__get_valid_message_types__valid_types', $this->_valid_message_types, $this ); |
|
436 | + $valid_types = apply_filters('FHEE__'.$class.'__get_valid_message_types__valid_types', $this->_valid_message_types, $this); |
|
437 | 437 | |
438 | 438 | //all messengers filter |
439 | - $valid_types = apply_filters( 'FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this ); |
|
439 | + $valid_types = apply_filters('FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this); |
|
440 | 440 | return $valid_types; |
441 | 441 | } |
442 | 442 | |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | * @access public |
451 | 451 | * @param array $new_config Whatever is put in here will reset the _validator_config property |
452 | 452 | */ |
453 | - public function set_validator_config( $new_config ) { |
|
453 | + public function set_validator_config($new_config) { |
|
454 | 454 | $this->_validator_config = $new_config; |
455 | 455 | } |
456 | 456 | |
@@ -466,8 +466,8 @@ discard block |
||
466 | 466 | public function get_validator_config() { |
467 | 467 | $class = get_class($this); |
468 | 468 | |
469 | - $config = apply_filters( 'FHEE__' . $class . '__get_validator_config', $this->_validator_config, $this ); |
|
470 | - $config = apply_filters( 'FHEE__EE_messenger__get_validator_config', $config, $this ); |
|
469 | + $config = apply_filters('FHEE__'.$class.'__get_validator_config', $this->_validator_config, $this); |
|
470 | + $config = apply_filters('FHEE__EE_messenger__get_validator_config', $config, $this); |
|
471 | 471 | return $config; |
472 | 472 | } |
473 | 473 | |
@@ -484,8 +484,8 @@ discard block |
||
484 | 484 | * @access public |
485 | 485 | * @return string content for page |
486 | 486 | */ |
487 | - public function get_messenger_admin_page_content( $page, $action = null, $extra = array(), $message_types = array() ) { |
|
488 | - return $this->_get_admin_page_content( $page, $action, $extra, $message_types ); |
|
487 | + public function get_messenger_admin_page_content($page, $action = null, $extra = array(), $message_types = array()) { |
|
488 | + return $this->_get_admin_page_content($page, $action, $extra, $message_types); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | |
@@ -495,20 +495,20 @@ discard block |
||
495 | 495 | * @param array $extra |
496 | 496 | * @return mixed|string |
497 | 497 | */ |
498 | - protected function _get_admin_content_events_edit( $message_types, $extra ) { |
|
498 | + protected function _get_admin_content_events_edit($message_types, $extra) { |
|
499 | 499 | //defaults |
500 | 500 | $template_args = array(); |
501 | 501 | $selector_rows = ''; |
502 | 502 | |
503 | 503 | //we don't need message types here so we're just going to ignore. we do, however, expect the event id here. The event id is needed to provide a link to setup a custom template for this event. |
504 | - $event_id = isset( $extra['event'] ) ? $extra['event'] : NULL; |
|
504 | + $event_id = isset($extra['event']) ? $extra['event'] : NULL; |
|
505 | 505 | |
506 | - $template_wrapper_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_wrapper.template.php'; |
|
507 | - $template_row_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_row.template.php'; |
|
506 | + $template_wrapper_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_wrapper.template.php'; |
|
507 | + $template_row_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_row.template.php'; |
|
508 | 508 | |
509 | 509 | //array of template objects for global and custom (non-trashed) (but remember just for this messenger!) |
510 | 510 | $global_templates = EEM_Message_Template_Group::instance()->get_all( |
511 | - array( array( 'MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true ) ) |
|
511 | + array(array('MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true)) |
|
512 | 512 | ); |
513 | 513 | $templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event( |
514 | 514 | $event_id, |
@@ -517,55 +517,55 @@ discard block |
||
517 | 517 | 'MTP_is_active' => true |
518 | 518 | ) |
519 | 519 | ); |
520 | - $templates_for_event = !empty( $templates_for_event ) ? $templates_for_event : array(); |
|
520 | + $templates_for_event = ! empty($templates_for_event) ? $templates_for_event : array(); |
|
521 | 521 | |
522 | 522 | //so we need to setup the rows for the selectors and we use the global mtpgs (cause those will the active message template groups) |
523 | - foreach ( $global_templates as $mtpgID => $mtpg ) { |
|
524 | - if ( $mtpg instanceof EE_Message_Template_Group ) { |
|
523 | + foreach ($global_templates as $mtpgID => $mtpg) { |
|
524 | + if ($mtpg instanceof EE_Message_Template_Group) { |
|
525 | 525 | //verify this message type is supposed to show on this page |
526 | 526 | $mtp_obj = $mtpg->message_type_obj(); |
527 | - if ( ! $mtp_obj instanceof EE_message_type ) { |
|
527 | + if ( ! $mtp_obj instanceof EE_message_type) { |
|
528 | 528 | continue; |
529 | 529 | } |
530 | - $mtp_obj->admin_registered_pages = (array)$mtp_obj->admin_registered_pages; |
|
531 | - if ( ! in_array( 'events_edit', $mtp_obj->admin_registered_pages ) ) { |
|
530 | + $mtp_obj->admin_registered_pages = (array) $mtp_obj->admin_registered_pages; |
|
531 | + if ( ! in_array('events_edit', $mtp_obj->admin_registered_pages)) { |
|
532 | 532 | continue; |
533 | 533 | } |
534 | 534 | $select_values = array(); |
535 | - $select_values[ $mtpgID ] = __( 'Global', 'event_espresso' ); |
|
536 | - $default_value = array_key_exists( $mtpgID, $templates_for_event ) && ! $mtpg->get( 'MTP_is_override' ) ? $mtpgID : null; |
|
535 | + $select_values[$mtpgID] = __('Global', 'event_espresso'); |
|
536 | + $default_value = array_key_exists($mtpgID, $templates_for_event) && ! $mtpg->get('MTP_is_override') ? $mtpgID : null; |
|
537 | 537 | //if the override has been set for the global template, then that means even if there are custom templates already created we ignore them because of the set override. |
538 | - if ( ! $mtpg->get( 'MTP_is_override' ) ) { |
|
538 | + if ( ! $mtpg->get('MTP_is_override')) { |
|
539 | 539 | //any custom templates for this message type? |
540 | - $custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt( $this->name, $mtpg->message_type() ); |
|
541 | - foreach ( $custom_templates as $cmtpgID => $cmtpg ) { |
|
542 | - $select_values[ $cmtpgID ] = $cmtpg->name(); |
|
543 | - $default_value = array_key_exists( $cmtpgID, $templates_for_event ) ? $cmtpgID : $default_value; |
|
540 | + $custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt($this->name, $mtpg->message_type()); |
|
541 | + foreach ($custom_templates as $cmtpgID => $cmtpg) { |
|
542 | + $select_values[$cmtpgID] = $cmtpg->name(); |
|
543 | + $default_value = array_key_exists($cmtpgID, $templates_for_event) ? $cmtpgID : $default_value; |
|
544 | 544 | } |
545 | 545 | } |
546 | 546 | //if there is no $default_value then we set it as the global |
547 | - $default_value = empty( $default_value ) ? $mtpgID : $default_value; |
|
548 | - $edit_url = EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value ), admin_url( 'admin.php' ) ); |
|
549 | - $create_url = EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_messages', 'action' => 'add_new_message_template', 'GRP_ID' => $default_value ), admin_url( 'admin.php' ) ); |
|
550 | - $st_args[ 'mt_name' ] = ucwords( $mtp_obj->label[ 'singular' ] ); |
|
551 | - $st_args[ 'mt_slug' ] = $mtpg->message_type(); |
|
552 | - $st_args[ 'messenger_slug' ] = $this->name; |
|
553 | - $st_args[ 'selector' ] = EEH_Form_Fields::select_input( 'event_message_templates_relation[' . $mtpgID . ']', $select_values, $default_value, 'data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '"', 'message-template-selector' ); |
|
547 | + $default_value = empty($default_value) ? $mtpgID : $default_value; |
|
548 | + $edit_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value), admin_url('admin.php')); |
|
549 | + $create_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'add_new_message_template', 'GRP_ID' => $default_value), admin_url('admin.php')); |
|
550 | + $st_args['mt_name'] = ucwords($mtp_obj->label['singular']); |
|
551 | + $st_args['mt_slug'] = $mtpg->message_type(); |
|
552 | + $st_args['messenger_slug'] = $this->name; |
|
553 | + $st_args['selector'] = EEH_Form_Fields::select_input('event_message_templates_relation['.$mtpgID.']', $select_values, $default_value, 'data-messenger="'.$this->name.'" data-messagetype="'.$mtpg->message_type().'"', 'message-template-selector'); |
|
554 | 554 | //note that message template group that has override_all_custom set will remove the ability to set a custom message template based off of the global (and that also in turn overrides any other custom templates). |
555 | - $st_args[ 'create_button' ] = $mtpg->get( 'MTP_is_override' ) ? '' : '<a data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $create_url . '" class="button button-small create-mtpg-button">' . __( 'Create New Custom', 'event_espresso' ) . '</a>'; |
|
556 | - $st_args[ 'create_button' ] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'espresso_messages_add_new_message_template' ) ? $st_args[ 'create_button' ] : ''; |
|
557 | - $st_args[ 'edit_button' ] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID ) ? '<a data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $edit_url . '" class="button button-small edit-mtpg-button">' . __( 'Edit', 'event_espresso' ) . '</a>' : ''; |
|
558 | - $selector_rows .= EEH_Template::display_template( $template_row_path, $st_args, true ); |
|
555 | + $st_args['create_button'] = $mtpg->get('MTP_is_override') ? '' : '<a data-messenger="'.$this->name.'" data-messagetype="'.$mtpg->message_type().'" data-grpid="'.$default_value.'" target="_blank" href="'.$create_url.'" class="button button-small create-mtpg-button">'.__('Create New Custom', 'event_espresso').'</a>'; |
|
556 | + $st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messages_add_new_message_template') ? $st_args['create_button'] : ''; |
|
557 | + $st_args['edit_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID) ? '<a data-messagetype="'.$mtpg->message_type().'" data-grpid="'.$default_value.'" target="_blank" href="'.$edit_url.'" class="button button-small edit-mtpg-button">'.__('Edit', 'event_espresso').'</a>' : ''; |
|
558 | + $selector_rows .= EEH_Template::display_template($template_row_path, $st_args, true); |
|
559 | 559 | } |
560 | 560 | } |
561 | 561 | |
562 | 562 | //if no selectors present then get out. |
563 | - if ( empty( $selector_rows ) ) { |
|
563 | + if (empty($selector_rows)) { |
|
564 | 564 | return ''; |
565 | 565 | } |
566 | 566 | |
567 | 567 | $template_args['selector_rows'] = $selector_rows; |
568 | - return EEH_Template::display_template( $template_wrapper_path, $template_args, TRUE ); |
|
568 | + return EEH_Template::display_template($template_wrapper_path, $template_args, TRUE); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | |
@@ -580,8 +580,8 @@ discard block |
||
580 | 580 | * @return array $this->_template_fields |
581 | 581 | */ |
582 | 582 | public function get_template_fields() { |
583 | - $template_fields = apply_filters( 'FHEE__' . get_class($this) . '__get_template_fields', $this->_template_fields, $this ); |
|
584 | - $template_fields = apply_filters( 'FHEE__EE_messenger__get_template_fields', $template_fields, $this ); |
|
583 | + $template_fields = apply_filters('FHEE__'.get_class($this).'__get_template_fields', $this->_template_fields, $this); |
|
584 | + $template_fields = apply_filters('FHEE__EE_messenger__get_template_fields', $template_fields, $this); |
|
585 | 585 | return $template_fields; |
586 | 586 | } |
587 | 587 | |
@@ -595,9 +595,9 @@ discard block |
||
595 | 595 | * @param mixed $value |
596 | 596 | */ |
597 | 597 | protected function _set_template_value($item, $value) { |
598 | - if ( array_key_exists($item, $this->_template_fields) ) { |
|
599 | - $prop = '_' . $item; |
|
600 | - $this->{$prop}= $value; |
|
598 | + if (array_key_exists($item, $this->_template_fields)) { |
|
599 | + $prop = '_'.$item; |
|
600 | + $this->{$prop} = $value; |
|
601 | 601 | } |
602 | 602 | } |
603 | 603 | |
@@ -615,18 +615,18 @@ discard block |
||
615 | 615 | * |
616 | 616 | * @throws SendMessageException |
617 | 617 | */ |
618 | - final public function send_message( $message, EE_message_type $message_type ) { |
|
618 | + final public function send_message($message, EE_message_type $message_type) { |
|
619 | 619 | try { |
620 | - $this->_validate_and_setup( $message ); |
|
620 | + $this->_validate_and_setup($message); |
|
621 | 621 | $this->_incoming_message_type = $message_type; |
622 | 622 | $response = $this->_send_message(); |
623 | - if ( $response instanceof WP_Error ) { |
|
624 | - EE_Error::add_error( $response->get_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
623 | + if ($response instanceof WP_Error) { |
|
624 | + EE_Error::add_error($response->get_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
625 | 625 | $response = false; |
626 | 626 | } |
627 | - } catch ( \Exception $e ) { |
|
627 | + } catch (\Exception $e) { |
|
628 | 628 | //convert to an instance of SendMessageException |
629 | - throw new SendMessageException( $e->getMessage() ); |
|
629 | + throw new SendMessageException($e->getMessage()); |
|
630 | 630 | } |
631 | 631 | return $response; |
632 | 632 | } |
@@ -640,28 +640,28 @@ discard block |
||
640 | 640 | * @param bool $send true we will actually use the _send method (for test sends). FALSE we just return preview |
641 | 641 | * @return string return the message html content |
642 | 642 | */ |
643 | - public function get_preview( EE_Message $message, EE_message_type $message_type, $send = false ) { |
|
644 | - $this->_validate_and_setup( $message ); |
|
643 | + public function get_preview(EE_Message $message, EE_message_type $message_type, $send = false) { |
|
644 | + $this->_validate_and_setup($message); |
|
645 | 645 | |
646 | 646 | $this->_incoming_message_type = $message_type; |
647 | 647 | |
648 | - if ( $send ) { |
|
648 | + if ($send) { |
|
649 | 649 | //are we overriding any existing template fields? |
650 | 650 | $settings = $this->get_existing_test_settings(); |
651 | - if ( ! empty( $settings ) ) { |
|
652 | - foreach ( $settings as $field => $value ) { |
|
653 | - $this->_set_template_value( $field, $value ); |
|
651 | + if ( ! empty($settings)) { |
|
652 | + foreach ($settings as $field => $value) { |
|
653 | + $this->_set_template_value($field, $value); |
|
654 | 654 | } |
655 | 655 | } |
656 | 656 | } |
657 | 657 | |
658 | 658 | //enqueue preview js so that any links/buttons on the page are disabled. |
659 | - if ( ! $send ) { |
|
659 | + if ( ! $send) { |
|
660 | 660 | // the below may seem like duplication. However, typically if a messenger enqueues scripts/styles, |
661 | 661 | // it deregisters all existing wp scripts and styles first. So the second hook ensures our previewer still gets setup. |
662 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_preview_script' ), 10 ); |
|
663 | - add_action( 'wp_enqueue_scripts', array( $this, 'add_preview_script' ), 10 ); |
|
664 | - add_action( 'AHEE__EE_messenger__enqueue_scripts_styles', array( $this, 'add_preview_script' ), 10 ); |
|
662 | + add_action('admin_enqueue_scripts', array($this, 'add_preview_script'), 10); |
|
663 | + add_action('wp_enqueue_scripts', array($this, 'add_preview_script'), 10); |
|
664 | + add_action('AHEE__EE_messenger__enqueue_scripts_styles', array($this, 'add_preview_script'), 10); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | return $send ? $this->_send_message() : $this->_preview(); |
@@ -679,10 +679,10 @@ discard block |
||
679 | 679 | */ |
680 | 680 | public function add_preview_script() { |
681 | 681 | //error message |
682 | - EE_Registry::$i18n_js_strings[ 'links_disabled' ] = __( 'All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup. To test generated links, you must trigger an actual message notification.', 'event_espresso' ); |
|
683 | - wp_register_script( 'ee-messages-preview-js', EE_LIBRARIES_URL . 'messages/messenger/assets/js/ee-messages-preview.js', array( 'jquery' ), EVENT_ESPRESSO_VERSION, true ); |
|
684 | - wp_localize_script( 'ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings ); |
|
685 | - wp_enqueue_script( 'ee-messages-preview-js' ); |
|
682 | + EE_Registry::$i18n_js_strings['links_disabled'] = __('All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup. To test generated links, you must trigger an actual message notification.', 'event_espresso'); |
|
683 | + wp_register_script('ee-messages-preview-js', EE_LIBRARIES_URL.'messages/messenger/assets/js/ee-messages-preview.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
684 | + wp_localize_script('ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings); |
|
685 | + wp_enqueue_script('ee-messages-preview-js'); |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | |
@@ -693,13 +693,13 @@ discard block |
||
693 | 693 | * @param EE_Message $message |
694 | 694 | * @throws EE_Error |
695 | 695 | */ |
696 | - protected function _validate_and_setup( EE_Message $message ) { |
|
696 | + protected function _validate_and_setup(EE_Message $message) { |
|
697 | 697 | $template_pack = $message->get_template_pack(); |
698 | 698 | $variation = $message->get_template_pack_variation(); |
699 | 699 | |
700 | 700 | //verify we have the required template pack value on the $message object. |
701 | - if ( ! $template_pack instanceof EE_Messages_Template_Pack ) { |
|
702 | - throw new EE_Error( __('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso' ) ); |
|
701 | + if ( ! $template_pack instanceof EE_Messages_Template_Pack) { |
|
702 | + throw new EE_Error(__('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso')); |
|
703 | 703 | } |
704 | 704 | |
705 | 705 | $this->_tmp_pack = $template_pack; |
@@ -708,11 +708,11 @@ discard block |
||
708 | 708 | |
709 | 709 | $template_fields = $this->get_template_fields(); |
710 | 710 | |
711 | - foreach ( $template_fields as $template => $value ) { |
|
712 | - if ( $template !== 'extra' ) { |
|
713 | - $column_value = $message->get_field_or_extra_meta( 'MSG_' . $template ); |
|
711 | + foreach ($template_fields as $template => $value) { |
|
712 | + if ($template !== 'extra') { |
|
713 | + $column_value = $message->get_field_or_extra_meta('MSG_'.$template); |
|
714 | 714 | $message_template_value = $column_value ? $column_value : null; |
715 | - $this->_set_template_value( $template, $message_template_value ); |
|
715 | + $this->_set_template_value($template, $message_template_value); |
|
716 | 716 | } |
717 | 717 | } |
718 | 718 | } |
@@ -727,19 +727,19 @@ discard block |
||
727 | 727 | * @return string |
728 | 728 | * @throws \EE_Error |
729 | 729 | */ |
730 | - protected function _get_main_template( $preview = FALSE ) { |
|
730 | + protected function _get_main_template($preview = FALSE) { |
|
731 | 731 | $type = $preview ? 'preview' : 'main'; |
732 | 732 | |
733 | - $wrapper_template = $this->_tmp_pack->get_wrapper( $this->name, $type ); |
|
733 | + $wrapper_template = $this->_tmp_pack->get_wrapper($this->name, $type); |
|
734 | 734 | |
735 | 735 | //check file exists and is readable |
736 | - if ( !is_readable( $wrapper_template ) ) |
|
737 | - throw new EE_Error( sprintf( __('Unable to access the template file for the %s messenger main content wrapper. The location being attempted is %s.', 'event_espresso' ), ucwords($this->label['singular']) , $wrapper_template ) ); |
|
736 | + if ( ! is_readable($wrapper_template)) |
|
737 | + throw new EE_Error(sprintf(__('Unable to access the template file for the %s messenger main content wrapper. The location being attempted is %s.', 'event_espresso'), ucwords($this->label['singular']), $wrapper_template)); |
|
738 | 738 | |
739 | 739 | //add message type to template args |
740 | 740 | $this->_template_args['message_type'] = $this->_incoming_message_type; |
741 | 741 | |
742 | - return EEH_Template::display_template( $wrapper_template, $this->_template_args, TRUE ); |
|
742 | + return EEH_Template::display_template($wrapper_template, $this->_template_args, TRUE); |
|
743 | 743 | } |
744 | 744 | |
745 | 745 | |
@@ -775,9 +775,9 @@ discard block |
||
775 | 775 | */ |
776 | 776 | public function get_existing_test_settings() { |
777 | 777 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
778 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
778 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
779 | 779 | $settings = $Message_Resource_Manager->get_active_messengers_option(); |
780 | - return isset( $settings[ $this->name ]['test_settings'] ) ? $settings[ $this->name ]['test_settings'] : array(); |
|
780 | + return isset($settings[$this->name]['test_settings']) ? $settings[$this->name]['test_settings'] : array(); |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | |
@@ -789,12 +789,12 @@ discard block |
||
789 | 789 | * @param $settings |
790 | 790 | * @return bool success/fail |
791 | 791 | */ |
792 | - public function set_existing_test_settings( $settings ) { |
|
792 | + public function set_existing_test_settings($settings) { |
|
793 | 793 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
794 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
794 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
795 | 795 | $existing = $Message_Resource_Manager->get_active_messengers_option(); |
796 | - $existing[ $this->name ]['test_settings'] = $settings; |
|
797 | - return $Message_Resource_Manager->update_active_messengers_option( $existing ); |
|
796 | + $existing[$this->name]['test_settings'] = $settings; |
|
797 | + return $Message_Resource_Manager->update_active_messengers_option($existing); |
|
798 | 798 | } |
799 | 799 | |
800 | 800 | |
@@ -807,21 +807,21 @@ discard block |
||
807 | 807 | * @param string $field The field to retrieve the label for |
808 | 808 | * @return string The label |
809 | 809 | */ |
810 | - public function get_field_label( $field ) { |
|
810 | + public function get_field_label($field) { |
|
811 | 811 | //first let's see if the field requests is in the top level array. |
812 | - if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) ) |
|
812 | + if (isset($this->_template_fields[$field]) && ! empty($this->_template_fields[$field]['label'])) |
|
813 | 813 | return $this->_template[$field]['label']; |
814 | 814 | |
815 | 815 | //nope so let's look in the extra array to see if it's there HOWEVER if the field exists as a top level index in the extra array then we know the label is in the 'main' index. |
816 | - if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] ) ) |
|
816 | + if (isset($this->_template_fields['extra']) && ! empty($this->_template_fields['extra'][$field]) && ! empty($this->_template_fields['extra'][$field]['main']['label'])) |
|
817 | 817 | return $this->_template_fields['extra'][$field]['main']['label']; |
818 | 818 | |
819 | 819 | //now it's possible this field may just be existing in any of the extra array items. |
820 | - if ( !empty( $this->_template_fields['extra'] ) && is_array( $this->_template_fields['extra'] ) ) { |
|
821 | - foreach ( $this->_template_fields['extra'] as $main_field => $subfields ) { |
|
822 | - if ( !is_array( $subfields ) ) |
|
820 | + if ( ! empty($this->_template_fields['extra']) && is_array($this->_template_fields['extra'])) { |
|
821 | + foreach ($this->_template_fields['extra'] as $main_field => $subfields) { |
|
822 | + if ( ! is_array($subfields)) |
|
823 | 823 | continue; |
824 | - if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) ) |
|
824 | + if (isset($subfields[$field]) && ! empty($subfields[$field]['label'])) |
|
825 | 825 | return $subfields[$field]['label']; |
826 | 826 | } |
827 | 827 | } |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | * |
843 | 843 | * @return void |
844 | 844 | */ |
845 | - public function do_secondary_messenger_hooks( $sending_messenger_name ) { |
|
845 | + public function do_secondary_messenger_hooks($sending_messenger_name) { |
|
846 | 846 | return; |
847 | 847 | } |
848 | 848 |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @return EED_Bot_Trap |
19 | 19 | */ |
20 | 20 | public static function instance() { |
21 | - return parent::get_instance( __CLASS__ ); |
|
21 | + return parent::get_instance(__CLASS__); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | |
@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public static function set_hooks() { |
33 | 33 | if ( |
34 | - apply_filters( 'FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true ) && |
|
34 | + apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) && |
|
35 | 35 | \EE_Registry::instance()->CFG->registration->use_bot_trap |
36 | 36 | ) { |
37 | 37 | \EED_Bot_Trap::set_trap(); |
38 | 38 | // redirect bots to bogus success page |
39 | - \EE_Config::register_route( 'ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success' ); |
|
39 | + \EE_Config::register_route('ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success'); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @return void |
50 | 50 | */ |
51 | 51 | public static function set_trap() { |
52 | - define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS); |
|
52 | + define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__).DS); |
|
53 | 53 | add_action( |
54 | 54 | 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
55 | 55 | array('EED_Bot_Trap', 'generate_bot_trap'), |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | } |
82 | 82 | add_action( |
83 | 83 | 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
84 | - array( 'EED_Bot_Trap', 'bot_trap_settings_form' ), |
|
84 | + array('EED_Bot_Trap', 'bot_trap_settings_form'), |
|
85 | 85 | 10 |
86 | 86 | ); |
87 | 87 | add_filter( |
88 | 88 | 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
89 | - array( 'EED_Bot_Trap', 'update_bot_trap_settings_form' ), |
|
89 | + array('EED_Bot_Trap', 'update_bot_trap_settings_form'), |
|
90 | 90 | 10, 1 |
91 | 91 | ); |
92 | 92 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @param WP $WP |
101 | 101 | * @return void |
102 | 102 | */ |
103 | - public function run( $WP ) {} |
|
103 | + public function run($WP) {} |
|
104 | 104 | |
105 | 105 | |
106 | 106 | |
@@ -111,15 +111,15 @@ discard block |
||
111 | 111 | * @return void |
112 | 112 | */ |
113 | 113 | public static function generate_bot_trap() { |
114 | - $do_not_enter = esc_html__( 'please do not enter anything in this input', 'event_espresso' ); |
|
114 | + $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
|
115 | 115 | $time = microtime(true); |
116 | 116 | $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
117 | - $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
118 | - $html .= '<input type="email" id="tkt-slctr-request-processor-email-' . $time .'" name="tkt-slctr-request-processor-email" value=""/>'; |
|
117 | + $html .= '<label for="tkt-slctr-request-processor-email-'.$time.'">'.$do_not_enter.'</label>'; |
|
118 | + $html .= '<input type="email" id="tkt-slctr-request-processor-email-'.$time.'" name="tkt-slctr-request-processor-email" value=""/>'; |
|
119 | 119 | $html .= '<input type="hidden" name="tkt-slctr-request-processor-token" value="'; |
120 | - if ( EE_Registry::instance()->CFG->registration->use_encryption ) { |
|
121 | - EE_Registry::instance()->load_core( 'EE_Encryption' ); |
|
122 | - $html .= EE_Encryption::instance()->encrypt( $time ); |
|
120 | + if (EE_Registry::instance()->CFG->registration->use_encryption) { |
|
121 | + EE_Registry::instance()->load_core('EE_Encryption'); |
|
122 | + $html .= EE_Encryption::instance()->encrypt($time); |
|
123 | 123 | } else { |
124 | 124 | $html .= $time; |
125 | 125 | } |
@@ -137,38 +137,38 @@ discard block |
||
137 | 137 | * It should receive one argument: a boolean indicating |
138 | 138 | * whether the trap was triggered by suspicious timing or not. |
139 | 139 | */ |
140 | - public static function process_bot_trap( $triggered_trap_callback = array() ) { |
|
140 | + public static function process_bot_trap($triggered_trap_callback = array()) { |
|
141 | 141 | // what's your email address Mr. Bot ? |
142 | - $empty_trap = isset( $_REQUEST[ 'tkt-slctr-request-processor-email' ] ) |
|
143 | - && $_REQUEST[ 'tkt-slctr-request-processor-email' ] === '' |
|
142 | + $empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email']) |
|
143 | + && $_REQUEST['tkt-slctr-request-processor-email'] === '' |
|
144 | 144 | ? true |
145 | 145 | : false; |
146 | 146 | // get encrypted timestamp for when the form was originally displayed |
147 | - $bot_trap_timestamp = isset( $_REQUEST[ 'tkt-slctr-request-processor-token' ] ) |
|
148 | - ? sanitize_text_field( $_REQUEST[ 'tkt-slctr-request-processor-token' ] ) |
|
147 | + $bot_trap_timestamp = isset($_REQUEST['tkt-slctr-request-processor-token']) |
|
148 | + ? sanitize_text_field($_REQUEST['tkt-slctr-request-processor-token']) |
|
149 | 149 | : ''; |
150 | 150 | // decrypt and convert to absolute integer |
151 | - if ( EE_Registry::instance()->CFG->registration->use_encryption ) { |
|
152 | - EE_Registry::instance()->load_core( 'EE_Encryption' ); |
|
153 | - $bot_trap_timestamp = absint( EE_Encryption::instance()->decrypt( $bot_trap_timestamp ) ); |
|
151 | + if (EE_Registry::instance()->CFG->registration->use_encryption) { |
|
152 | + EE_Registry::instance()->load_core('EE_Encryption'); |
|
153 | + $bot_trap_timestamp = absint(EE_Encryption::instance()->decrypt($bot_trap_timestamp)); |
|
154 | 154 | } else { |
155 | - $bot_trap_timestamp = absint( $bot_trap_timestamp ); |
|
155 | + $bot_trap_timestamp = absint($bot_trap_timestamp); |
|
156 | 156 | } |
157 | 157 | // ticket form submitted too impossibly fast ( after now ) or more than an hour later ??? |
158 | - $suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < ( time() - HOUR_IN_SECONDS ) |
|
158 | + $suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < (time() - HOUR_IN_SECONDS) |
|
159 | 159 | ? true |
160 | 160 | : false; |
161 | 161 | // are we human ? |
162 | - if ( $empty_trap && ! $suspicious_timing ) { |
|
162 | + if ($empty_trap && ! $suspicious_timing) { |
|
163 | 163 | do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
164 | 164 | return; |
165 | 165 | } |
166 | 166 | // check the given callback is valid first before executing |
167 | - if ( ! is_callable($triggered_trap_callback ) ) { |
|
167 | + if ( ! is_callable($triggered_trap_callback)) { |
|
168 | 168 | // invalid callback so lets just sub in our default. |
169 | - $triggered_trap_callback = array( 'EED_Bot_Trap', 'triggered_trap_response' ); |
|
169 | + $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
|
170 | 170 | } |
171 | - call_user_func_array($triggered_trap_callback, array( $suspicious_timing ) ); |
|
171 | + call_user_func_array($triggered_trap_callback, array($suspicious_timing)); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -179,15 +179,15 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @param bool $suspicious_timing If true, then the bot trap was triggered due to the suspicious timing test. |
181 | 181 | */ |
182 | - public static function triggered_trap_response( $suspicious_timing ) { |
|
182 | + public static function triggered_trap_response($suspicious_timing) { |
|
183 | 183 | // UH OH... |
184 | 184 | $redirect_url = add_query_arg( |
185 | - array( 'ee' => 'ticket_selection_received' ), |
|
185 | + array('ee' => 'ticket_selection_received'), |
|
186 | 186 | EE_Registry::instance()->CFG->core->reg_page_url() |
187 | 187 | ); |
188 | - if ( $suspicious_timing ) { |
|
188 | + if ($suspicious_timing) { |
|
189 | 189 | $redirect_url = add_query_arg( |
190 | - array( 'ee-notice' => urlencode( esc_html__( 'We\'re sorry, but your ticket selections could not be processed due to a server timing error. Please hit the back button on your browser and try again.', 'event_espresso' ) ) ), |
|
190 | + array('ee-notice' => urlencode(esc_html__('We\'re sorry, but your ticket selections could not be processed due to a server timing error. Please hit the back button on your browser and try again.', 'event_espresso'))), |
|
191 | 191 | $redirect_url |
192 | 192 | ); |
193 | 193 | } |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | * @return void |
219 | 219 | */ |
220 | 220 | public static function display_bot_trap_success() { |
221 | - add_filter( 'FHEE__EED_Single_Page_Checkout__run', '__return_false' ); |
|
222 | - $bot_notice = esc_html__( 'Thank you so much. Your ticket selections have been received for consideration.', 'event_espresso' ); |
|
223 | - $bot_notice = isset( $_REQUEST[ 'ee-notice' ] ) && $_REQUEST[ 'ee-notice' ] !== '' ? sanitize_text_field( stripslashes( $_REQUEST[ 'ee-notice' ] ) ) : $bot_notice; |
|
224 | - EE_Registry::instance()->REQ->add_output( EEH_HTML::div( $bot_notice, '', 'ee-attention' ) ); |
|
221 | + add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false'); |
|
222 | + $bot_notice = esc_html__('Thank you so much. Your ticket selections have been received for consideration.', 'event_espresso'); |
|
223 | + $bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== '' ? sanitize_text_field(stripslashes($_REQUEST['ee-notice'])) : $bot_notice; |
|
224 | + EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention')); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | |
@@ -256,20 +256,20 @@ discard block |
||
256 | 256 | 'html_id' => 'bot_trap_settings', |
257 | 257 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
258 | 258 | 'subsections' => array( |
259 | - 'bot_trap_hdr' => new EE_Form_Section_HTML( EEH_HTML::h2( esc_html__( 'Bot Trap Settings', 'event_espresso' ) ) ), |
|
259 | + 'bot_trap_hdr' => new EE_Form_Section_HTML(EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso'))), |
|
260 | 260 | 'use_bot_trap' => new EE_Yes_No_Input( |
261 | 261 | array( |
262 | - 'html_label_text' => esc_html__( 'Enable Bot Trap', 'event_espresso' ), |
|
263 | - 'html_help_text' => esc_html__( 'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', 'event_espresso' ), |
|
264 | - 'default' => isset( EE_Registry::instance()->CFG->registration->use_bot_trap ) ? EE_Registry::instance()->CFG->registration->use_bot_trap : true, |
|
262 | + 'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'), |
|
263 | + 'html_help_text' => esc_html__('The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', 'event_espresso'), |
|
264 | + 'default' => isset(EE_Registry::instance()->CFG->registration->use_bot_trap) ? EE_Registry::instance()->CFG->registration->use_bot_trap : true, |
|
265 | 265 | 'required' => false |
266 | 266 | ) |
267 | 267 | ), |
268 | 268 | 'use_encryption' => new EE_Yes_No_Input( |
269 | 269 | array( |
270 | - 'html_label_text' => esc_html__( 'Encrypt Bot Trap Data', 'event_espresso' ), |
|
271 | - 'html_help_text' => esc_html__( 'One way to detect spam bots is by looking at how long it takes them to submit a form. They are often inhumanly fast, or will submit forms hours, days, or even weeks after the form was first scraped off the web. The Event Espresso Bot Trap will send a timestamp with the Ticket Selector form when it is submitted. By default, this timestamp is encrypted so that the spam bots can not change it, but encryption may cause issues on some servers due to configuration "conflicts". If you continuously get caught in the bot trap, then try setting this option to "No". This may increase the number of spam submissions you receive, but increases server compatibility.', 'event_espresso' ), |
|
272 | - 'default' => isset( EE_Registry::instance()->CFG->registration->use_encryption ) ? EE_Registry::instance()->CFG->registration->use_encryption : true, |
|
270 | + 'html_label_text' => esc_html__('Encrypt Bot Trap Data', 'event_espresso'), |
|
271 | + 'html_help_text' => esc_html__('One way to detect spam bots is by looking at how long it takes them to submit a form. They are often inhumanly fast, or will submit forms hours, days, or even weeks after the form was first scraped off the web. The Event Espresso Bot Trap will send a timestamp with the Ticket Selector form when it is submitted. By default, this timestamp is encrypted so that the spam bots can not change it, but encryption may cause issues on some servers due to configuration "conflicts". If you continuously get caught in the bot trap, then try setting this option to "No". This may increase the number of spam submissions you receive, but increases server compatibility.', 'event_espresso'), |
|
272 | + 'default' => isset(EE_Registry::instance()->CFG->registration->use_encryption) ? EE_Registry::instance()->CFG->registration->use_encryption : true, |
|
273 | 273 | 'required' => false |
274 | 274 | ) |
275 | 275 | ), |
@@ -287,30 +287,30 @@ discard block |
||
287 | 287 | * @param \EE_Registration_Config $EE_Registration_Config |
288 | 288 | * @return \EE_Registration_Config |
289 | 289 | */ |
290 | - public static function update_bot_trap_settings_form( EE_Registration_Config $EE_Registration_Config ) { |
|
290 | + public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config) { |
|
291 | 291 | try { |
292 | 292 | $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form(); |
293 | 293 | // if not displaying a form, then check for form submission |
294 | - if ( $bot_trap_settings_form->was_submitted() ) { |
|
294 | + if ($bot_trap_settings_form->was_submitted()) { |
|
295 | 295 | // capture form data |
296 | 296 | $bot_trap_settings_form->receive_form_submission(); |
297 | 297 | // validate form data |
298 | - if ( $bot_trap_settings_form->is_valid() ) { |
|
298 | + if ($bot_trap_settings_form->is_valid()) { |
|
299 | 299 | // grab validated data from form |
300 | 300 | $valid_data = $bot_trap_settings_form->valid_data(); |
301 | - if ( isset( $valid_data[ 'use_bot_trap' ], $valid_data[ 'use_encryption' ] ) ) { |
|
302 | - $EE_Registration_Config->use_bot_trap = $valid_data[ 'use_bot_trap' ]; |
|
303 | - $EE_Registration_Config->use_encryption = $valid_data[ 'use_encryption' ]; |
|
301 | + if (isset($valid_data['use_bot_trap'], $valid_data['use_encryption'])) { |
|
302 | + $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap']; |
|
303 | + $EE_Registration_Config->use_encryption = $valid_data['use_encryption']; |
|
304 | 304 | } else { |
305 | - EE_Error::add_error( esc_html__( 'Invalid or missing Bot Trap settings. Please refresh the form and try again.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
305 | + EE_Error::add_error(esc_html__('Invalid or missing Bot Trap settings. Please refresh the form and try again.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
306 | 306 | } |
307 | 307 | } else { |
308 | - if ( $bot_trap_settings_form->submission_error_message() != '' ) { |
|
309 | - EE_Error::add_error( $bot_trap_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
308 | + if ($bot_trap_settings_form->submission_error_message() != '') { |
|
309 | + EE_Error::add_error($bot_trap_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
310 | 310 | } |
311 | 311 | } |
312 | 312 | } |
313 | - } catch ( EE_Error $e ) { |
|
313 | + } catch (EE_Error $e) { |
|
314 | 314 | $e->get_error(); |
315 | 315 | } |
316 | 316 | return $EE_Registration_Config; |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | * @return void |
31 | 31 | */ |
32 | 32 | public static function set_hooks() { |
33 | - if ( |
|
33 | + if ( |
|
34 | 34 | apply_filters( 'FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true ) && |
35 | 35 | \EE_Registry::instance()->CFG->registration->use_bot_trap |
36 | 36 | ) { |
37 | - \EED_Bot_Trap::set_trap(); |
|
37 | + \EED_Bot_Trap::set_trap(); |
|
38 | 38 | // redirect bots to bogus success page |
39 | 39 | \EE_Config::register_route( 'ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success' ); |
40 | 40 | } |
@@ -49,18 +49,18 @@ discard block |
||
49 | 49 | * @return void |
50 | 50 | */ |
51 | 51 | public static function set_trap() { |
52 | - define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS); |
|
53 | - add_action( |
|
54 | - 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
|
55 | - array('EED_Bot_Trap', 'generate_bot_trap'), |
|
56 | - 10, 2 |
|
57 | - ); |
|
58 | - add_action( |
|
59 | - 'EED_Ticket_Selector__process_ticket_selections__before', |
|
60 | - array('EED_Bot_Trap', 'process_bot_trap'), |
|
61 | - 1, 2 |
|
62 | - ); |
|
63 | - } |
|
52 | + define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS); |
|
53 | + add_action( |
|
54 | + 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
|
55 | + array('EED_Bot_Trap', 'generate_bot_trap'), |
|
56 | + 10, 2 |
|
57 | + ); |
|
58 | + add_action( |
|
59 | + 'EED_Ticket_Selector__process_ticket_selections__before', |
|
60 | + array('EED_Bot_Trap', 'process_bot_trap'), |
|
61 | + 1, 2 |
|
62 | + ); |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | 66 | |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | * @return void |
72 | 72 | */ |
73 | 73 | public static function set_hooks_admin() { |
74 | - if ( |
|
75 | - defined('DOING_AJAX') |
|
76 | - && DOING_AJAX |
|
77 | - && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) |
|
78 | - && \EE_Registry::instance()->CFG->registration->use_bot_trap |
|
79 | - ) { |
|
80 | - \EED_Bot_Trap::set_trap(); |
|
81 | - } |
|
82 | - add_action( |
|
74 | + if ( |
|
75 | + defined('DOING_AJAX') |
|
76 | + && DOING_AJAX |
|
77 | + && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) |
|
78 | + && \EE_Registry::instance()->CFG->registration->use_bot_trap |
|
79 | + ) { |
|
80 | + \EED_Bot_Trap::set_trap(); |
|
81 | + } |
|
82 | + add_action( |
|
83 | 83 | 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
84 | 84 | array( 'EED_Bot_Trap', 'bot_trap_settings_form' ), |
85 | 85 | 5 |
@@ -130,23 +130,23 @@ discard block |
||
130 | 130 | |
131 | 131 | |
132 | 132 | /** |
133 | - * process_bot_trap |
|
134 | - * |
|
135 | - * @param array|string $triggered_trap_callback Callback that will be executed for handling the |
|
136 | - * response if the bot trap is triggered. |
|
137 | - * It should receive one argument: a boolean indicating |
|
138 | - * whether the trap was triggered by suspicious timing or not. |
|
133 | + * process_bot_trap |
|
134 | + * |
|
135 | + * @param array|string $triggered_trap_callback Callback that will be executed for handling the |
|
136 | + * response if the bot trap is triggered. |
|
137 | + * It should receive one argument: a boolean indicating |
|
138 | + * whether the trap was triggered by suspicious timing or not. |
|
139 | 139 | */ |
140 | 140 | public static function process_bot_trap( $triggered_trap_callback = array() ) { |
141 | - // what's your email address Mr. Bot ? |
|
141 | + // what's your email address Mr. Bot ? |
|
142 | 142 | $empty_trap = isset( $_REQUEST[ 'tkt-slctr-request-processor-email' ] ) |
143 | - && $_REQUEST[ 'tkt-slctr-request-processor-email' ] === '' |
|
144 | - ? true |
|
145 | - : false; |
|
143 | + && $_REQUEST[ 'tkt-slctr-request-processor-email' ] === '' |
|
144 | + ? true |
|
145 | + : false; |
|
146 | 146 | // get encrypted timestamp for when the form was originally displayed |
147 | 147 | $bot_trap_timestamp = isset( $_REQUEST[ 'tkt-slctr-request-processor-token' ] ) |
148 | - ? sanitize_text_field( $_REQUEST[ 'tkt-slctr-request-processor-token' ] ) |
|
149 | - : ''; |
|
148 | + ? sanitize_text_field( $_REQUEST[ 'tkt-slctr-request-processor-token' ] ) |
|
149 | + : ''; |
|
150 | 150 | // decrypt and convert to absolute integer |
151 | 151 | if ( EE_Registry::instance()->CFG->registration->use_encryption ) { |
152 | 152 | EE_Registry::instance()->load_core( 'EE_Encryption' ); |
@@ -156,17 +156,17 @@ discard block |
||
156 | 156 | } |
157 | 157 | // ticket form submitted too impossibly fast ( after now ) or more than an hour later ??? |
158 | 158 | $suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < ( time() - HOUR_IN_SECONDS ) |
159 | - ? true |
|
160 | - : false; |
|
159 | + ? true |
|
160 | + : false; |
|
161 | 161 | // are we human ? |
162 | 162 | if ( $empty_trap && ! $suspicious_timing ) { |
163 | - do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
|
163 | + do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
|
164 | 164 | return; |
165 | 165 | } |
166 | 166 | // check the given callback is valid first before executing |
167 | 167 | if ( ! is_callable($triggered_trap_callback ) ) { |
168 | 168 | // invalid callback so lets just sub in our default. |
169 | - $triggered_trap_callback = array( 'EED_Bot_Trap', 'triggered_trap_response' ); |
|
169 | + $triggered_trap_callback = array( 'EED_Bot_Trap', 'triggered_trap_response' ); |
|
170 | 170 | } |
171 | 171 | call_user_func_array($triggered_trap_callback, array( $suspicious_timing ) ); |
172 | 172 | } |
@@ -192,21 +192,21 @@ discard block |
||
192 | 192 | ); |
193 | 193 | } |
194 | 194 | $redirect_url = apply_filters('FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', $redirect_url); |
195 | - // if AJAX, return the redirect URL |
|
196 | - if (defined('DOING_AJAX') && DOING_AJAX) { |
|
197 | - echo wp_json_encode( |
|
198 | - array_merge( |
|
199 | - \EE_Error::get_notices(false), |
|
200 | - array( |
|
201 | - 'redirect_url' => $redirect_url |
|
202 | - ) |
|
203 | - ) |
|
204 | - ); |
|
205 | - exit(); |
|
206 | - } |
|
207 | - wp_safe_redirect($redirect_url); |
|
208 | - exit(); |
|
209 | - } |
|
195 | + // if AJAX, return the redirect URL |
|
196 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
197 | + echo wp_json_encode( |
|
198 | + array_merge( |
|
199 | + \EE_Error::get_notices(false), |
|
200 | + array( |
|
201 | + 'redirect_url' => $redirect_url |
|
202 | + ) |
|
203 | + ) |
|
204 | + ); |
|
205 | + exit(); |
|
206 | + } |
|
207 | + wp_safe_redirect($redirect_url); |
|
208 | + exit(); |
|
209 | + } |
|
210 | 210 | |
211 | 211 | |
212 | 212 | |
@@ -237,9 +237,9 @@ discard block |
||
237 | 237 | * @return void |
238 | 238 | */ |
239 | 239 | public static function bot_trap_settings_form() { |
240 | - EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js(); |
|
241 | - echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); |
|
242 | - } |
|
240 | + EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js(); |
|
241 | + echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); |
|
242 | + } |
|
243 | 243 | |
244 | 244 | |
245 | 245 |
@@ -1,43 +1,43 @@ |
||
1 | 1 | <?php //echo '<h1>' . __FILE__ . '</h1>'; ?> |
2 | 2 | <?php global $post; ?> |
3 | 3 | <div class="venue-content"> |
4 | -<?php if ( apply_filters( 'FHEE__content_espresso_venues_details_template__display_entry_meta', TRUE )): ?> |
|
4 | +<?php if (apply_filters('FHEE__content_espresso_venues_details_template__display_entry_meta', TRUE)): ?> |
|
5 | 5 | <div class="entry-meta"> |
6 | - <span class="tags-links"><?php espresso_venue_categories( $post->ID, TRUE, TRUE ); ?></span> |
|
6 | + <span class="tags-links"><?php espresso_venue_categories($post->ID, TRUE, TRUE); ?></span> |
|
7 | 7 | <?php |
8 | - if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) : |
|
8 | + if ( ! post_password_required() && (comments_open() || get_comments_number())) : |
|
9 | 9 | ?> |
10 | - <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'event_espresso' ), __( '1 Comment', 'event_espresso' ), __( '% Comments', 'event_espresso' ) ); ?></span> |
|
10 | + <span class="comments-link"><?php comments_popup_link(__('Leave a comment', 'event_espresso'), __('1 Comment', 'event_espresso'), __('% Comments', 'event_espresso')); ?></span> |
|
11 | 11 | <?php |
12 | 12 | endif; |
13 | 13 | |
14 | - edit_post_link( __( 'Edit', 'event_espresso' ), '<span class="edit-link">', '</span>' ); |
|
14 | + edit_post_link(__('Edit', 'event_espresso'), '<span class="edit-link">', '</span>'); |
|
15 | 15 | ?> |
16 | 16 | </div> |
17 | 17 | <?php endif; ?> |
18 | 18 | |
19 | 19 | <h3 class="event-venues-h3 ee-event-h3"> |
20 | - <?php _e( 'Details', 'event_espresso' ); ?> |
|
20 | + <?php _e('Details', 'event_espresso'); ?> |
|
21 | 21 | </h3> |
22 | 22 | |
23 | - <?php if ( $venue_phone = espresso_venue_phone( $post->ID, FALSE )) : ?> |
|
23 | + <?php if ($venue_phone = espresso_venue_phone($post->ID, FALSE)) : ?> |
|
24 | 24 | <p> |
25 | - <span class="small-text"><strong><?php _e( 'Venue Phone:', 'event_espresso' ); ?> </strong></span><?php echo $venue_phone; ?> |
|
25 | + <span class="small-text"><strong><?php _e('Venue Phone:', 'event_espresso'); ?> </strong></span><?php echo $venue_phone; ?> |
|
26 | 26 | </p> |
27 | 27 | <?php endif; ?> |
28 | - <?php if ( $venue_website = espresso_venue_website( $post->ID, FALSE )) : ?> |
|
28 | + <?php if ($venue_website = espresso_venue_website($post->ID, FALSE)) : ?> |
|
29 | 29 | <p> |
30 | - <span class="small-text"><strong><?php _e( 'Venue Website:', 'event_espresso' ); ?> </strong></span><?php echo $venue_website; ?> |
|
30 | + <span class="small-text"><strong><?php _e('Venue Website:', 'event_espresso'); ?> </strong></span><?php echo $venue_website; ?> |
|
31 | 31 | </p> |
32 | 32 | <?php endif; ?> |
33 | 33 | <?php |
34 | - do_action( 'AHEE__content_espresso_venues_details_template__before_the_content', $post ); |
|
35 | - if ( is_archive() && has_excerpt( $post->ID )) { |
|
34 | + do_action('AHEE__content_espresso_venues_details_template__before_the_content', $post); |
|
35 | + if (is_archive() && has_excerpt($post->ID)) { |
|
36 | 36 | the_excerpt(); |
37 | 37 | } else { |
38 | 38 | the_content(); |
39 | 39 | } |
40 | - do_action( 'AHEE__content_espresso_venues_details_template__after_the_content', $post ); |
|
40 | + do_action('AHEE__content_espresso_venues_details_template__after_the_content', $post); |
|
41 | 41 | ?> |
42 | 42 | </div> |
43 | 43 | <!-- .venue-content --> |