@@ -101,42 +101,42 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return EEM_Message |
103 | 103 | */ |
104 | - protected function __construct( $timezone = null ) { |
|
105 | - $this->singular_item = __('Message','event_espresso'); |
|
106 | - $this->plural_item = __('Messages','event_espresso'); |
|
104 | + protected function __construct($timezone = null) { |
|
105 | + $this->singular_item = __('Message', 'event_espresso'); |
|
106 | + $this->plural_item = __('Messages', 'event_espresso'); |
|
107 | 107 | |
108 | 108 | //used for token generator |
109 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
109 | + EE_Registry::instance()->load_helper('URL'); |
|
110 | 110 | |
111 | 111 | $this->_tables = array( |
112 | - 'Message'=>new EE_Primary_Table('esp_message','MSG_ID') |
|
112 | + 'Message'=>new EE_Primary_Table('esp_message', 'MSG_ID') |
|
113 | 113 | ); |
114 | 114 | |
115 | 115 | $allowed_priority = array( |
116 | - self::priority_high => __( 'high', 'event_espresso' ), |
|
117 | - self::priority_medium => __( 'medium', 'event_espresso' ), |
|
118 | - self::priority_low => __( 'low', 'event_espresso' ) |
|
116 | + self::priority_high => __('high', 'event_espresso'), |
|
117 | + self::priority_medium => __('medium', 'event_espresso'), |
|
118 | + self::priority_low => __('low', 'event_espresso') |
|
119 | 119 | ); |
120 | 120 | |
121 | 121 | $this->_fields = array( |
122 | 122 | 'Message'=>array( |
123 | - 'MSG_ID'=>new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID','event_espresso')), |
|
124 | - 'MSG_token' => new EE_Plain_Text_Field( 'MSG_token', __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', 'event_espresso' ), false, EEH_URL::generate_unique_token() ), |
|
125 | - 'GRP_ID'=>new EE_Foreign_Key_Int_Field( 'GRP_ID', __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso' ), true, 0, 'Message_Template_Group' ), |
|
126 | - 'TXN_ID' => new EE_Foreign_Key_Int_Field( 'TXN_ID', __( 'Foreign key to the related EE_Transaction. This is required to give context for regenerating the specific message', 'event_espresso' ), true, 0, 'Transaction' ), |
|
127 | - 'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', __( 'Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.', 'event_espresso' ), false, 'email' ), |
|
128 | - 'MSG_message_type' => new EE_Plain_Text_Field( 'MSG_message_type', __( 'Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso' ), false, 'receipt' ), |
|
129 | - 'MSG_context' => new EE_Plain_Text_Field( 'MSG_context', __( 'Context', 'event_espresso' ), false ), |
|
130 | - 'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field( 'MSG_recipient_ID', __( 'Recipient ID', 'event_espresso' ), true, null, array( 'Registration', 'Attendee', 'WP_User' ) ), |
|
131 | - 'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field( 'MSG_recipient_type', __( 'Recipient Type', 'event_espresso' ), true, null, array( 'Registration', 'Attendee', 'WP_User' ) ), |
|
132 | - 'MSG_content' => new EE_Maybe_Serialized_Text_Field( 'MSG_content', __( 'Content', 'event_espresso' ), true, '' ), |
|
133 | - 'MSG_to' => new EE_Maybe_Serialized_Text_Field( 'MSG_to', __( 'Address To', 'event_espresso' ), true ), |
|
134 | - 'MSG_from' => new EE_Maybe_Serialized_Text_Field( 'MSG_from', __( 'Address From', 'event_espresso' ), true ), |
|
135 | - 'MSG_subject' => new EE_Maybe_Serialized_Text_Field( 'MSG_subject', __( 'Subject', 'event_espresso' ), true, '' ), |
|
136 | - 'MSG_priority' => new EE_Enum_Integer_Field( 'MSG_priority', __( 'Priority', 'event_espresso' ), false, self::priority_low, $allowed_priority ), |
|
137 | - 'STS_ID' => new EE_Foreign_Key_String_Field( 'STS_ID', __( 'Status', 'event_espresso' ), false, self::status_incomplete, 'Status' ), |
|
138 | - 'MSG_created' => new EE_Datetime_Field( 'MSG_created', __( 'Created', 'event_espresso' ), false, time() ), |
|
139 | - 'MSG_modified' => new EE_Datetime_Field( 'MSG_modified', __( 'Modified', 'event_espresso' ), true, time() ) |
|
123 | + 'MSG_ID'=>new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID', 'event_espresso')), |
|
124 | + 'MSG_token' => new EE_Plain_Text_Field('MSG_token', __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', 'event_espresso'), false, EEH_URL::generate_unique_token()), |
|
125 | + 'GRP_ID'=>new EE_Foreign_Key_Int_Field('GRP_ID', __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso'), true, 0, 'Message_Template_Group'), |
|
126 | + 'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', __('Foreign key to the related EE_Transaction. This is required to give context for regenerating the specific message', 'event_espresso'), true, 0, 'Transaction'), |
|
127 | + 'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', __('Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.', 'event_espresso'), false, 'email'), |
|
128 | + 'MSG_message_type' => new EE_Plain_Text_Field('MSG_message_type', __('Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso'), false, 'receipt'), |
|
129 | + 'MSG_context' => new EE_Plain_Text_Field('MSG_context', __('Context', 'event_espresso'), false), |
|
130 | + 'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field('MSG_recipient_ID', __('Recipient ID', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')), |
|
131 | + 'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field('MSG_recipient_type', __('Recipient Type', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')), |
|
132 | + 'MSG_content' => new EE_Maybe_Serialized_Text_Field('MSG_content', __('Content', 'event_espresso'), true, ''), |
|
133 | + 'MSG_to' => new EE_Maybe_Serialized_Text_Field('MSG_to', __('Address To', 'event_espresso'), true), |
|
134 | + 'MSG_from' => new EE_Maybe_Serialized_Text_Field('MSG_from', __('Address From', 'event_espresso'), true), |
|
135 | + 'MSG_subject' => new EE_Maybe_Serialized_Text_Field('MSG_subject', __('Subject', 'event_espresso'), true, ''), |
|
136 | + 'MSG_priority' => new EE_Enum_Integer_Field('MSG_priority', __('Priority', 'event_espresso'), false, self::priority_low, $allowed_priority), |
|
137 | + 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status', 'event_espresso'), false, self::status_incomplete, 'Status'), |
|
138 | + 'MSG_created' => new EE_Datetime_Field('MSG_created', __('Created', 'event_espresso'), false, time()), |
|
139 | + 'MSG_modified' => new EE_Datetime_Field('MSG_modified', __('Modified', 'event_espresso'), true, time()) |
|
140 | 140 | ) |
141 | 141 | ); |
142 | 142 | $this->_model_relations = array( |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | 'Message_Template_Group' => new EE_Belongs_To_Relation(), |
147 | 147 | 'Transaction' => new EE_Belongs_To_Relation() |
148 | 148 | ); |
149 | - parent::__construct( $timezone ); |
|
149 | + parent::__construct($timezone); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | public function create_default_object() { |
158 | 158 | /** @type EE_Message $message */ |
159 | 159 | $message = parent::create_default_object(); |
160 | - if ( $message instanceof EE_Message ) { |
|
161 | - return EE_Message_Factory::set_messenger_and_message_type( $message ); |
|
160 | + if ($message instanceof EE_Message) { |
|
161 | + return EE_Message_Factory::set_messenger_and_message_type($message); |
|
162 | 162 | } |
163 | 163 | return null; |
164 | 164 | } |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | * @param mixed $cols_n_values |
170 | 170 | * @return \EE_Message |
171 | 171 | */ |
172 | - public function instantiate_class_from_array_or_object( $cols_n_values ) { |
|
172 | + public function instantiate_class_from_array_or_object($cols_n_values) { |
|
173 | 173 | /** @type EE_Message $message */ |
174 | - $message = parent::instantiate_class_from_array_or_object( $cols_n_values ); |
|
175 | - if ( $message instanceof EE_Message ) { |
|
176 | - return EE_Message_Factory::set_messenger_and_message_type( $message ); |
|
174 | + $message = parent::instantiate_class_from_array_or_object($cols_n_values); |
|
175 | + if ($message instanceof EE_Message) { |
|
176 | + return EE_Message_Factory::set_messenger_and_message_type($message); |
|
177 | 177 | } |
178 | 178 | return null; |
179 | 179 | } |
@@ -186,13 +186,13 @@ discard block |
||
186 | 186 | * @param string $message_type the message type slug |
187 | 187 | * @return boolean |
188 | 188 | */ |
189 | - public function message_sent_for_attendee( $attendee, $message_type ) { |
|
190 | - $attendee_ID = EEM_Attendee::instance()->ensure_is_ID( $attendee ); |
|
191 | - return $this->exists( array( array( |
|
189 | + public function message_sent_for_attendee($attendee, $message_type) { |
|
190 | + $attendee_ID = EEM_Attendee::instance()->ensure_is_ID($attendee); |
|
191 | + return $this->exists(array(array( |
|
192 | 192 | 'Attendee.ATT_ID' => $attendee_ID, |
193 | 193 | 'MSG_message_type' => $message_type, |
194 | - 'STS_ID' => array( 'IN', $this->stati_indicating_sent() ) |
|
195 | - ) ) ); |
|
194 | + 'STS_ID' => array('IN', $this->stati_indicating_sent()) |
|
195 | + ))); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
@@ -204,13 +204,13 @@ discard block |
||
204 | 204 | * @param string $message_type the message type slug |
205 | 205 | * @return boolean |
206 | 206 | */ |
207 | - public function message_sent_for_registration( $registration, $message_type ) { |
|
208 | - $registrationID = EEM_Registration::instance()->ensure_is_ID( $registration ); |
|
209 | - return $this->exists( array( array( |
|
207 | + public function message_sent_for_registration($registration, $message_type) { |
|
208 | + $registrationID = EEM_Registration::instance()->ensure_is_ID($registration); |
|
209 | + return $this->exists(array(array( |
|
210 | 210 | 'Registration.REG_ID' => $registrationID, |
211 | 211 | 'MSG_message_type' => $message_type, |
212 | - 'STS_ID' => array( 'IN', $this->stati_indicating_sent() ) |
|
213 | - ) ) ); |
|
212 | + 'STS_ID' => array('IN', $this->stati_indicating_sent()) |
|
213 | + ))); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | |
@@ -221,10 +221,10 @@ discard block |
||
221 | 221 | * @param string $token |
222 | 222 | * @return EE_Message |
223 | 223 | */ |
224 | - public function get_one_by_token( $token ) { |
|
225 | - return $this->get_one( array( array( |
|
224 | + public function get_one_by_token($token) { |
|
225 | + return $this->get_one(array(array( |
|
226 | 226 | 'MSG_token' => $token |
227 | - ) ) ); |
|
227 | + ))); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | * Returns stati that indicate the message HAS been sent |
233 | 233 | * @return array of strings for possible stati |
234 | 234 | */ |
235 | - public function stati_indicating_sent(){ |
|
236 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_sent', array( self::status_sent ) ); |
|
235 | + public function stati_indicating_sent() { |
|
236 | + return apply_filters('FHEE__EEM_Message__stati_indicating_sent', array(self::status_sent)); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @return array of strings for possible stati. |
245 | 245 | */ |
246 | 246 | public function stati_indicating_to_send() { |
247 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_to_send', array( self::status_idle, self::status_resend ) ); |
|
247 | + return apply_filters('FHEE__EEM_Message__stati_indicating_to_send', array(self::status_idle, self::status_resend)); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
@@ -258,10 +258,10 @@ discard block |
||
258 | 258 | self::status_retry, |
259 | 259 | ); |
260 | 260 | //if WP_DEBUG is set, then let's include debug_only fails |
261 | - if ( WP_DEBUG ) { |
|
261 | + if (WP_DEBUG) { |
|
262 | 262 | $failed_stati[] = self::status_debug_only; |
263 | 263 | } |
264 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_failed_sending', $failed_stati ); |
|
264 | + return apply_filters('FHEE__EEM_Message__stati_indicating_failed_sending', $failed_stati); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
@@ -296,11 +296,11 @@ discard block |
||
296 | 296 | // the value, matches the corresponding EEM_Base child reference. |
297 | 297 | $expected_vars = $this->_expected_vars_for_query_inject(); |
298 | 298 | $query_params[0] = array(); |
299 | - foreach ( $expected_vars as $request_key => $model_name ) { |
|
300 | - $request_value = EE_Registry::instance()->REQ->get( $request_key ); |
|
301 | - if ( $request_value ) { |
|
299 | + foreach ($expected_vars as $request_key => $model_name) { |
|
300 | + $request_value = EE_Registry::instance()->REQ->get($request_key); |
|
301 | + if ($request_value) { |
|
302 | 302 | //special case |
303 | - switch ( $request_key ) { |
|
303 | + switch ($request_key) { |
|
304 | 304 | case '_REG_ID' : |
305 | 305 | $query_params[0]['AND**filter_by']['OR**filter_by_REG_ID'] = array( |
306 | 306 | 'Transaction.Registration.REG_ID' => $request_value, |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | ); |
313 | 313 | break; |
314 | 314 | default : |
315 | - $query_params[0]['AND**filter_by'][ 'OR**filter_by_' . $request_key ][ $model_name . '.' . $request_key ] = $request_value; |
|
315 | + $query_params[0]['AND**filter_by']['OR**filter_by_'.$request_key][$model_name.'.'.$request_key] = $request_value; |
|
316 | 316 | break; |
317 | 317 | } |
318 | 318 | } |
@@ -328,53 +328,53 @@ discard block |
||
328 | 328 | $expected_vars = $this->_expected_vars_for_query_inject(); |
329 | 329 | $pretty_label = ''; |
330 | 330 | $label_parts = array(); |
331 | - foreach ( $expected_vars as $request_key => $model_name ) { |
|
332 | - $model = EE_Registry::instance()->load_model( $model_name ); |
|
333 | - if ( $model_field_value = EE_Registry::instance()->REQ->get( $request_key ) ) { |
|
334 | - switch ( $request_key ) { |
|
331 | + foreach ($expected_vars as $request_key => $model_name) { |
|
332 | + $model = EE_Registry::instance()->load_model($model_name); |
|
333 | + if ($model_field_value = EE_Registry::instance()->REQ->get($request_key)) { |
|
334 | + switch ($request_key) { |
|
335 | 335 | case '_REG_ID' : |
336 | 336 | $label_parts[] = sprintf( |
337 | - esc_html__( 'Registration with the ID: %s', 'event_espresso' ), |
|
337 | + esc_html__('Registration with the ID: %s', 'event_espresso'), |
|
338 | 338 | $model_field_value |
339 | 339 | ); |
340 | 340 | break; |
341 | 341 | case 'ATT_ID' : |
342 | 342 | /** @var EE_Attendee $attendee */ |
343 | - $attendee = $model->get_one_by_ID( $model_field_value ); |
|
343 | + $attendee = $model->get_one_by_ID($model_field_value); |
|
344 | 344 | $label_parts[] = $attendee instanceof EE_Attendee |
345 | - ? sprintf( esc_html__( 'Attendee %s', 'event_espresso' ), $attendee->full_name() ) |
|
346 | - : sprintf( esc_html__( 'Attendee ID: %s', 'event_espresso' ), $model_field_value ); |
|
345 | + ? sprintf(esc_html__('Attendee %s', 'event_espresso'), $attendee->full_name()) |
|
346 | + : sprintf(esc_html__('Attendee ID: %s', 'event_espresso'), $model_field_value); |
|
347 | 347 | break; |
348 | 348 | case 'ID' : |
349 | 349 | /** @var EE_WP_User $wpUser */ |
350 | - $wpUser = $model->get_one_by_ID( $model_field_value ); |
|
350 | + $wpUser = $model->get_one_by_ID($model_field_value); |
|
351 | 351 | $label_parts[] = $wpUser instanceof EE_WP_User |
352 | - ? sprintf( esc_html__( 'WP User: %s', 'event_espresso' ), $wpUser->name() ) |
|
353 | - : sprintf( esc_html__( 'WP User ID: %s', 'event_espresso' ), $model_field_value ); |
|
352 | + ? sprintf(esc_html__('WP User: %s', 'event_espresso'), $wpUser->name()) |
|
353 | + : sprintf(esc_html__('WP User ID: %s', 'event_espresso'), $model_field_value); |
|
354 | 354 | break; |
355 | 355 | case 'TXN_ID' : |
356 | 356 | $label_parts[] = sprintf( |
357 | - esc_html__( 'Transaction with the ID: %s', 'event_espresso' ), |
|
357 | + esc_html__('Transaction with the ID: %s', 'event_espresso'), |
|
358 | 358 | $model_field_value |
359 | 359 | ); |
360 | 360 | break; |
361 | 361 | case 'EVT_ID' : |
362 | 362 | /** @var EE_Event $Event */ |
363 | - $Event = $model->get_one_by_ID( $model_field_value ); |
|
363 | + $Event = $model->get_one_by_ID($model_field_value); |
|
364 | 364 | $label_parts[] = $Event instanceof EE_Event |
365 | - ? sprintf( esc_html__( 'for the Event: %s', 'event_espresso' ), $Event->name() ) |
|
366 | - : sprintf( esc_html__( 'for the Event with ID: %s', 'event_espresso' ), $model_field_value ); |
|
365 | + ? sprintf(esc_html__('for the Event: %s', 'event_espresso'), $Event->name()) |
|
366 | + : sprintf(esc_html__('for the Event with ID: %s', 'event_espresso'), $model_field_value); |
|
367 | 367 | break; |
368 | 368 | } |
369 | 369 | } |
370 | 370 | } |
371 | 371 | |
372 | - if ( $label_parts ) { |
|
372 | + if ($label_parts) { |
|
373 | 373 | |
374 | 374 | //prepend to the last element of $label_parts an "and". |
375 | - if ( count( $label_parts ) > 1 ) { |
|
376 | - $label_parts_index_to_prepend = count( $label_parts ) - 1; |
|
377 | - $label_parts[ $label_parts_index_to_prepend ] = 'and' . $label_parts[ $label_parts_index_to_prepend ]; |
|
375 | + if (count($label_parts) > 1) { |
|
376 | + $label_parts_index_to_prepend = count($label_parts) - 1; |
|
377 | + $label_parts[$label_parts_index_to_prepend] = 'and'.$label_parts[$label_parts_index_to_prepend]; |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | $pretty_label .= sprintf( |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | 'A label for the messages returned in a query that are filtered by items in the query. This could be Transaction, Event, Attendee, Registration, or WP_User.', |
384 | 384 | 'event_espresso' |
385 | 385 | ), |
386 | - implode( ', ', $label_parts ) |
|
386 | + implode(', ', $label_parts) |
|
387 | 387 | ); |
388 | 388 | } |
389 | 389 | return $pretty_label; |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | /** |
55 | 55 | * @param \Registrations_Admin_Page $admin_page |
56 | 56 | */ |
57 | - public function __construct( Registrations_Admin_Page $admin_page ){ |
|
58 | - if ( ! empty( $_GET['event_id'] ) ) { |
|
57 | + public function __construct(Registrations_Admin_Page $admin_page) { |
|
58 | + if ( ! empty($_GET['event_id'])) { |
|
59 | 59 | $extra_query_args = array(); |
60 | - foreach ( $admin_page->get_views() as $key => $view_details ) { |
|
61 | - $extra_query_args[$view_details['slug']] = array( 'event_id' => $_GET['event_id'] ); |
|
60 | + foreach ($admin_page->get_views() as $key => $view_details) { |
|
61 | + $extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']); |
|
62 | 62 | } |
63 | - $this->_views = $admin_page->get_list_table_view_RLs( $extra_query_args ); |
|
63 | + $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args); |
|
64 | 64 | } |
65 | 65 | parent::__construct($admin_page); |
66 | 66 | $this->_status = $this->_admin_page->get_registration_status_array(); |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | * @return void |
76 | 76 | */ |
77 | 77 | protected function _setup_data() { |
78 | - $this->_data = $this->_admin_page->get_registrations( $this->_per_page ); |
|
79 | - $this->_all_data_count = $this->_admin_page->get_registrations( $this->_per_page, TRUE, FALSE, FALSE ); |
|
78 | + $this->_data = $this->_admin_page->get_registrations($this->_per_page); |
|
79 | + $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, TRUE, FALSE, FALSE); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -93,30 +93,30 @@ discard block |
||
93 | 93 | 'ajax' => TRUE, |
94 | 94 | 'screen' => $this->_admin_page->get_current_screen()->id |
95 | 95 | ); |
96 | - $ID_column_name = __( 'ID', 'event_espresso' ); |
|
96 | + $ID_column_name = __('ID', 'event_espresso'); |
|
97 | 97 | $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
98 | - $ID_column_name .= __( 'Registrant Name', 'event_espresso' ); |
|
98 | + $ID_column_name .= __('Registrant Name', 'event_espresso'); |
|
99 | 99 | $ID_column_name .= '</span> '; |
100 | - if ( isset( $_GET['event_id'] )) { |
|
100 | + if (isset($_GET['event_id'])) { |
|
101 | 101 | $this->_columns = array( |
102 | 102 | 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
103 | 103 | '_REG_ID' => $ID_column_name, |
104 | - 'ATT_fname' => __( 'Name', 'event_espresso' ), |
|
104 | + 'ATT_fname' => __('Name', 'event_espresso'), |
|
105 | 105 | 'ATT_email' => __('Email', 'event_espresso'), |
106 | - '_REG_date' => __( 'Reg Date', 'event_espresso' ), |
|
107 | - 'PRC_amount' => __( 'TKT Price', 'event_espresso' ), |
|
108 | - '_REG_final_price' => __( 'Final Price', 'event_espresso' ), |
|
109 | - 'TXN_total' => __( 'Total Txn', 'event_espresso' ), |
|
106 | + '_REG_date' => __('Reg Date', 'event_espresso'), |
|
107 | + 'PRC_amount' => __('TKT Price', 'event_espresso'), |
|
108 | + '_REG_final_price' => __('Final Price', 'event_espresso'), |
|
109 | + 'TXN_total' => __('Total Txn', 'event_espresso'), |
|
110 | 110 | 'TXN_paid' => __('Paid', 'event_espresso'), |
111 | - 'actions' => __( 'Actions', 'event_espresso' ) |
|
111 | + 'actions' => __('Actions', 'event_espresso') |
|
112 | 112 | ); |
113 | 113 | $this->_bottom_buttons = array( |
114 | 114 | 'report'=> array( |
115 | 115 | 'route' => 'registrations_report', |
116 | 116 | 'extra_request' => |
117 | 117 | array( |
118 | - 'EVT_ID'=> isset( $this->_req_data['event_id'] ) ? $this->_req_data['event_id'] : null, |
|
119 | - 'return_url' => urlencode( "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" ) |
|
118 | + 'EVT_ID'=> isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
119 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}") |
|
120 | 120 | ) |
121 | 121 | ), |
122 | 122 | ); |
@@ -124,19 +124,19 @@ discard block |
||
124 | 124 | $this->_columns = array( |
125 | 125 | 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
126 | 126 | '_REG_ID' => $ID_column_name, |
127 | - 'ATT_fname' => __( 'Name', 'event_espresso' ), |
|
128 | - '_REG_date' => __( 'TXN Date', 'event_espresso' ), |
|
129 | - 'event_name' => __( 'Event', 'event_espresso' ), |
|
130 | - 'DTT_EVT_start' => __( 'Event Date', 'event_espresso' ), |
|
131 | - '_REG_final_price' => __( 'Price', 'event_espresso' ), |
|
132 | - '_REG_paid' => __( 'Paid', 'event_espresso' ), |
|
133 | - 'actions' => __( 'Actions', 'event_espresso' ) |
|
127 | + 'ATT_fname' => __('Name', 'event_espresso'), |
|
128 | + '_REG_date' => __('TXN Date', 'event_espresso'), |
|
129 | + 'event_name' => __('Event', 'event_espresso'), |
|
130 | + 'DTT_EVT_start' => __('Event Date', 'event_espresso'), |
|
131 | + '_REG_final_price' => __('Price', 'event_espresso'), |
|
132 | + '_REG_paid' => __('Paid', 'event_espresso'), |
|
133 | + 'actions' => __('Actions', 'event_espresso') |
|
134 | 134 | ); |
135 | 135 | $this->_bottom_buttons = array( |
136 | 136 | 'report_all'=> array( |
137 | 137 | 'route' => 'registrations_report', |
138 | 138 | 'extra_request' => array( |
139 | - 'return_url' => urlencode( "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" ) ) |
|
139 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}") ) |
|
140 | 140 | ), |
141 | 141 | ); |
142 | 142 | } |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | $this->_primary_column = '_REG_ID'; |
145 | 145 | |
146 | 146 | $this->_sortable_columns = array( |
147 | - '_REG_date' => array( '_REG_date' => TRUE ), //true means its already sorted |
|
148 | - 'ATT_fname' => array( 'ATT_fname' => FALSE ), |
|
149 | - 'event_name' => array( 'event_name' => FALSE ), |
|
150 | - 'DTT_EVT_start' => array( 'DTT_EVT_start' => FALSE ), |
|
151 | - '_REG_ID' => array( '_REG_ID' => FALSE ), |
|
147 | + '_REG_date' => array('_REG_date' => TRUE), //true means its already sorted |
|
148 | + 'ATT_fname' => array('ATT_fname' => FALSE), |
|
149 | + 'event_name' => array('event_name' => FALSE), |
|
150 | + 'DTT_EVT_start' => array('DTT_EVT_start' => FALSE), |
|
151 | + '_REG_ID' => array('_REG_ID' => FALSE), |
|
152 | 152 | ); |
153 | 153 | |
154 | 154 | $this->_hidden_columns = array(); |
@@ -162,11 +162,11 @@ discard block |
||
162 | 162 | * @param EE_Registration $item the current item |
163 | 163 | * @return string |
164 | 164 | */ |
165 | - protected function _get_row_class( $item ) { |
|
166 | - $class = parent::_get_row_class( $item ); |
|
165 | + protected function _get_row_class($item) { |
|
166 | + $class = parent::_get_row_class($item); |
|
167 | 167 | //add status class |
168 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
169 | - if ( $this->_has_checkbox_column ) { |
|
168 | + $class .= ' ee-status-strip reg-status-'.$item->status_ID(); |
|
169 | + if ($this->_has_checkbox_column) { |
|
170 | 170 | $class .= ' has-checkbox-column'; |
171 | 171 | } |
172 | 172 | return $class; |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | * @param EE_Registration $registration |
181 | 181 | * @throws \EE_Error |
182 | 182 | */ |
183 | - protected function _set_related_details( EE_Registration $registration ) { |
|
183 | + protected function _set_related_details(EE_Registration $registration) { |
|
184 | 184 | |
185 | - $transaction = $registration->get_first_related( 'Transaction' ); |
|
185 | + $transaction = $registration->get_first_related('Transaction'); |
|
186 | 186 | $status = $transaction instanceof EE_Transaction |
187 | 187 | ? $transaction->status_ID() |
188 | 188 | : EEM_Transaction::failed_status_code; |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | 'status' => $status, |
192 | 192 | 'id' => $transaction instanceof EE_Transaction ? $transaction->ID() : 0, |
193 | 193 | 'title_attr' => sprintf( |
194 | - __( 'View Transaction Details (%s)', 'event_espresso' ), |
|
195 | - EEH_Template::pretty_status( $status, false, 'sentence' ) |
|
194 | + __('View Transaction Details (%s)', 'event_espresso'), |
|
195 | + EEH_Template::pretty_status($status, false, 'sentence') |
|
196 | 196 | ) |
197 | 197 | ); |
198 | 198 | |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | 'status' => $status, |
204 | 204 | 'id' => $event instanceof EE_Event ? $event->ID() : 0, |
205 | 205 | 'title_attr' => sprintf( |
206 | - __( 'Edit Event (%s)', 'event_espresso' ), |
|
207 | - EEH_Template::pretty_status( $status, false, 'sentence' ) |
|
206 | + __('Edit Event (%s)', 'event_espresso'), |
|
207 | + EEH_Template::pretty_status($status, false, 'sentence') |
|
208 | 208 | ) |
209 | 209 | ); |
210 | 210 | } |
@@ -221,30 +221,30 @@ discard block |
||
221 | 221 | |
222 | 222 | //todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods. |
223 | 223 | |
224 | - $cur_date = isset( $this->_req_data['month_range'] ) ? $this->_req_data['month_range'] : ''; |
|
225 | - $cur_category = isset( $this->_req_data['EVT_CAT'] ) ? $this->_req_data['EVT_CAT'] : -1; |
|
226 | - $reg_status = isset( $this->_req_data['_reg_status'] ) ? $this->_req_data['_reg_status'] : ''; |
|
224 | + $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
225 | + $cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
226 | + $reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : ''; |
|
227 | 227 | |
228 | - $filters[] = EEH_Form_Fields::generate_registration_months_dropdown( $cur_date, $reg_status, $cur_category ); |
|
229 | - $filters[] = EEH_Form_Fields::generate_event_category_dropdown( $cur_category ); |
|
228 | + $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category); |
|
229 | + $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category); |
|
230 | 230 | |
231 | 231 | $status = array(); |
232 | - $status[] = array( 'id' => 0, 'text' => __('Select Status', 'event_espresso') ); |
|
233 | - foreach ( $this->_status as $key => $value ) { |
|
234 | - $status[] = array( 'id' => $key, 'text' => $value ); |
|
232 | + $status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso')); |
|
233 | + foreach ($this->_status as $key => $value) { |
|
234 | + $status[] = array('id' => $key, 'text' => $value); |
|
235 | 235 | } |
236 | - if ( $this->_view !== 'incomplete' ) { |
|
236 | + if ($this->_view !== 'incomplete') { |
|
237 | 237 | $filters[] = EEH_Form_Fields::select_input( |
238 | 238 | '_reg_status', |
239 | 239 | $status, |
240 | - isset( $this->_req_data['_reg_status'] ) |
|
241 | - ? strtoupper( sanitize_key( $this->_req_data['_reg_status'] )) |
|
240 | + isset($this->_req_data['_reg_status']) |
|
241 | + ? strtoupper(sanitize_key($this->_req_data['_reg_status'])) |
|
242 | 242 | : '' |
243 | 243 | ); |
244 | 244 | } |
245 | 245 | |
246 | - if ( isset( $this->_req_data['event_id'] ) ) { |
|
247 | - $filters[] = EEH_Form_Fields::hidden_input( 'event_id', $this->_req_data['event_id'], 'reg_event_id' ); |
|
246 | + if (isset($this->_req_data['event_id'])) { |
|
247 | + $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id'); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | return $filters; |
@@ -263,9 +263,9 @@ discard block |
||
263 | 263 | $this->_views['all']['count'] = $this->_total_registrations(); |
264 | 264 | $this->_views['month']['count'] = $this->_total_registrations_this_month(); |
265 | 265 | $this->_views['today']['count'] = $this->_total_registrations_today(); |
266 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registrations', 'espresso_registrations_trash_registrations' ) ) { |
|
267 | - $this->_views['incomplete']['count'] = $this->_total_registrations( 'incomplete' ); |
|
268 | - $this->_views['trash']['count'] = $this->_total_registrations( 'trash' ); |
|
266 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', 'espresso_registrations_trash_registrations')) { |
|
267 | + $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete'); |
|
268 | + $this->_views['trash']['count'] = $this->_total_registrations('trash'); |
|
269 | 269 | } |
270 | 270 | } |
271 | 271 | |
@@ -279,23 +279,23 @@ discard block |
||
279 | 279 | * @return int |
280 | 280 | * @throws \EE_Error |
281 | 281 | */ |
282 | - protected function _total_registrations( $view = '' ){ |
|
282 | + protected function _total_registrations($view = '') { |
|
283 | 283 | $_where = array(); |
284 | - $EVT_ID = isset( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : FALSE; |
|
285 | - if( $EVT_ID ) { |
|
284 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : FALSE; |
|
285 | + if ($EVT_ID) { |
|
286 | 286 | $_where['EVT_ID'] = $EVT_ID; |
287 | 287 | } |
288 | - switch ( $view ) { |
|
288 | + switch ($view) { |
|
289 | 289 | case 'trash' : |
290 | - return EEM_Registration::instance()->count_deleted( array( $_where )); |
|
290 | + return EEM_Registration::instance()->count_deleted(array($_where)); |
|
291 | 291 | break; |
292 | 292 | case 'incomplete' : |
293 | 293 | $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
294 | 294 | break; |
295 | 295 | default : |
296 | - $_where['STS_ID'] = array( '!=', EEM_Registration::status_id_incomplete ); |
|
296 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
297 | 297 | } |
298 | - return EEM_Registration::instance()->count( array( $_where )); |
|
298 | + return EEM_Registration::instance()->count(array($_where)); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | |
@@ -307,32 +307,32 @@ discard block |
||
307 | 307 | * @return int |
308 | 308 | * @throws \EE_Error |
309 | 309 | */ |
310 | - protected function _total_registrations_this_month(){ |
|
311 | - $EVT_ID = isset( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : FALSE; |
|
312 | - $_where = $EVT_ID ? array( 'EVT_ID' => $EVT_ID ) : array(); |
|
310 | + protected function _total_registrations_this_month() { |
|
311 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : FALSE; |
|
312 | + $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
313 | 313 | $this_year_r = date('Y', current_time('timestamp')); |
314 | 314 | $time_start = ' 00:00:00'; |
315 | 315 | $time_end = ' 23:59:59'; |
316 | 316 | $this_month_r = date('m', current_time('timestamp')); |
317 | - $days_this_month = date( 't', current_time('timestamp') ); |
|
317 | + $days_this_month = date('t', current_time('timestamp')); |
|
318 | 318 | //setup date query. |
319 | 319 | $beginning_string = EEM_Registration::instance()->convert_datetime_for_query( |
320 | 320 | 'REG_date', |
321 | - $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, |
|
321 | + $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start, |
|
322 | 322 | 'Y-m-d H:i:s' |
323 | 323 | ); |
324 | 324 | $end_string = EEM_Registration::instance()->convert_datetime_for_query( |
325 | 325 | 'REG_date', |
326 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, |
|
326 | + $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end, |
|
327 | 327 | 'Y-m-d H:i:s' |
328 | 328 | ); |
329 | - $_where['REG_date']= array('BETWEEN', |
|
329 | + $_where['REG_date'] = array('BETWEEN', |
|
330 | 330 | array( |
331 | 331 | $beginning_string, |
332 | 332 | $end_string |
333 | 333 | )); |
334 | - $_where['STS_ID'] = array( '!=', EEM_Registration::status_id_incomplete ); |
|
335 | - return EEM_Registration::instance()->count(array( $_where ) ); |
|
334 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
335 | + return EEM_Registration::instance()->count(array($_where)); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -344,20 +344,20 @@ discard block |
||
344 | 344 | * @return int |
345 | 345 | * @throws \EE_Error |
346 | 346 | */ |
347 | - protected function _total_registrations_today(){ |
|
347 | + protected function _total_registrations_today() { |
|
348 | 348 | |
349 | - $EVT_ID = isset( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : FALSE; |
|
350 | - $_where = $EVT_ID ? array( 'EVT_ID' => $EVT_ID ) : array(); |
|
349 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : FALSE; |
|
350 | + $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
351 | 351 | $current_date = date('Y-m-d', current_time('timestamp')); |
352 | 352 | $time_start = ' 00:00:00'; |
353 | 353 | $time_end = ' 23:59:59'; |
354 | - $_where['REG_date']= array('BETWEEN', |
|
354 | + $_where['REG_date'] = array('BETWEEN', |
|
355 | 355 | array( |
356 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $current_date . $time_start, 'Y-m-d H:i:s' ), |
|
357 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $current_date . $time_end, 'Y-m-d H:i:s' ) |
|
356 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $current_date.$time_start, 'Y-m-d H:i:s'), |
|
357 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $current_date.$time_end, 'Y-m-d H:i:s') |
|
358 | 358 | )); |
359 | - $_where['STS_ID'] = array( '!=', EEM_Registration::status_id_incomplete ); |
|
360 | - return EEM_Registration::instance()->count(array( $_where ) ); |
|
359 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
360 | + return EEM_Registration::instance()->count(array($_where)); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | |
@@ -370,12 +370,12 @@ discard block |
||
370 | 370 | * @return string |
371 | 371 | * @throws \EE_Error |
372 | 372 | */ |
373 | - public function column_cb($item){ |
|
373 | + public function column_cb($item) { |
|
374 | 374 | /** checkbox/lock **/ |
375 | - $transaction = $item->get_first_related( 'Transaction' ); |
|
376 | - $payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related( 'Payment' ) : 0; |
|
375 | + $transaction = $item->get_first_related('Transaction'); |
|
376 | + $payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related('Payment') : 0; |
|
377 | 377 | return $payment_count > 0 |
378 | - ? sprintf( '<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID() ) |
|
378 | + ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID()) |
|
379 | 379 | . '<span class="ee-lock-icon"></span>' |
380 | 380 | : sprintf( |
381 | 381 | '<input type="checkbox" name="_REG_ID[]" value="%1$s" />', |
@@ -393,14 +393,14 @@ discard block |
||
393 | 393 | * @return string |
394 | 394 | * @throws \EE_Error |
395 | 395 | */ |
396 | - public function column__REG_ID(EE_Registration $item){ |
|
396 | + public function column__REG_ID(EE_Registration $item) { |
|
397 | 397 | $attendee = $item->attendee(); |
398 | 398 | $content = $item->ID(); |
399 | 399 | $content .= '<div class="show-on-mobile-view-only">'; |
400 | 400 | $content .= '<br>'; |
401 | 401 | $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
402 | - $content .= ' ' . sprintf(__( '(%1$s / %2$s)', 'event_espresso' ), $item->count(), $item->group_size()); |
|
403 | - $content .= '<br>' . sprintf( __( 'Reg Code: %s', 'event_espresso' ), $item->get('REG_code') ); |
|
402 | + $content .= ' '.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
403 | + $content .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
404 | 404 | $content .= '</div>'; |
405 | 405 | return $content; |
406 | 406 | } |
@@ -415,12 +415,12 @@ discard block |
||
415 | 415 | * @return string |
416 | 416 | * @throws \EE_Error |
417 | 417 | */ |
418 | - public function column__REG_date(EE_Registration $item){ |
|
418 | + public function column__REG_date(EE_Registration $item) { |
|
419 | 419 | $this->_set_related_details($item); |
420 | 420 | //Build row actions |
421 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=> $this->_transaction_details['id'] ), TXN_ADMIN_URL ); |
|
422 | - $view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? '<a class="ee-status-color-' . $this->_transaction_details['status'] . '" href="'.$view_lnk_url.'" title="' . esc_attr( $this->_transaction_details['title_attr'] ) . '">' . $item->get_i18n_datetime( 'REG_date' ) . '</a>' : $item->get_i18n_datetime( 'REG_date' ); |
|
423 | - $view_link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $this->_transaction_details['status'], false, 'sentence' ) . '</span>'; |
|
421 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=> $this->_transaction_details['id']), TXN_ADMIN_URL); |
|
422 | + $view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? '<a class="ee-status-color-'.$this->_transaction_details['status'].'" href="'.$view_lnk_url.'" title="'.esc_attr($this->_transaction_details['title_attr']).'">'.$item->get_i18n_datetime('REG_date').'</a>' : $item->get_i18n_datetime('REG_date'); |
|
423 | + $view_link .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence').'</span>'; |
|
424 | 424 | return $view_link; |
425 | 425 | } |
426 | 426 | |
@@ -434,18 +434,18 @@ discard block |
||
434 | 434 | * @return string |
435 | 435 | * @throws \EE_Error |
436 | 436 | */ |
437 | - public function column_event_name(EE_Registration $item){ |
|
438 | - $this->_set_related_details( $item ); |
|
437 | + public function column_event_name(EE_Registration $item) { |
|
438 | + $this->_set_related_details($item); |
|
439 | 439 | // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62 |
440 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$item->event_ID() ), EVENTS_ADMIN_URL ); |
|
440 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$item->event_ID()), EVENTS_ADMIN_URL); |
|
441 | 441 | $event_name = $item->event_name(); |
442 | 442 | $event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso'); |
443 | - $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $item->event_ID() ) ? '<a class="ee-status-color-' . $this->_event_details['status'] . '" href="' . $edit_event_url . '" title="' . esc_attr( $this->_event_details['title_attr'] ) .'">' . wp_trim_words( $event_name, 30, '...' ) . '</a>' : wp_trim_words( $event_name, 30, '...' ) ; |
|
443 | + $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $item->event_ID()) ? '<a class="ee-status-color-'.$this->_event_details['status'].'" href="'.$edit_event_url.'" title="'.esc_attr($this->_event_details['title_attr']).'">'.wp_trim_words($event_name, 30, '...').'</a>' : wp_trim_words($event_name, 30, '...'); |
|
444 | 444 | |
445 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( array( 'event_id'=>$item->event_ID() ), REG_ADMIN_URL ); |
|
446 | - $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="' . sprintf( esc_attr__( 'Filter this list to only show registrations for %s', 'event_espresso' ), $event_name ) .'">' . __( 'View Registrations', 'event_espresso' ) . '</a>'; |
|
445 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id'=>$item->event_ID()), REG_ADMIN_URL); |
|
446 | + $actions['event_filter'] = '<a href="'.$edit_event_url.'" title="'.sprintf(esc_attr__('Filter this list to only show registrations for %s', 'event_espresso'), $event_name).'">'.__('View Registrations', 'event_espresso').'</a>'; |
|
447 | 447 | |
448 | - return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions) ); |
|
448 | + return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions)); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | |
@@ -458,18 +458,18 @@ discard block |
||
458 | 458 | * @return string |
459 | 459 | * @throws \EE_Error |
460 | 460 | */ |
461 | - public function column_DTT_EVT_start(EE_Registration $item){ |
|
461 | + public function column_DTT_EVT_start(EE_Registration $item) { |
|
462 | 462 | $datetime_strings = array(); |
463 | - $ticket = $item->ticket( TRUE ); |
|
464 | - if ( $ticket instanceof EE_Ticket ) { |
|
463 | + $ticket = $item->ticket(TRUE); |
|
464 | + if ($ticket instanceof EE_Ticket) { |
|
465 | 465 | $remove_defaults = array('default_where_conditions' => 'none'); |
466 | 466 | $datetimes = $ticket->datetimes($remove_defaults); |
467 | - foreach($datetimes as $datetime){ |
|
468 | - $datetime_strings[] = $datetime->get_i18n_datetime( 'DTT_EVT_start' ); |
|
467 | + foreach ($datetimes as $datetime) { |
|
468 | + $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
469 | 469 | } |
470 | - return implode("<br />",$datetime_strings); |
|
470 | + return implode("<br />", $datetime_strings); |
|
471 | 471 | } else { |
472 | - return __( 'There is no ticket on this registration', 'event_espresso' ); |
|
472 | + return __('There is no ticket on this registration', 'event_espresso'); |
|
473 | 473 | } |
474 | 474 | } |
475 | 475 | |
@@ -483,45 +483,45 @@ discard block |
||
483 | 483 | * @return string |
484 | 484 | * @throws \EE_Error |
485 | 485 | */ |
486 | - public function column_ATT_fname(EE_Registration $item){ |
|
486 | + public function column_ATT_fname(EE_Registration $item) { |
|
487 | 487 | $attendee = $item->attendee(); |
488 | 488 | |
489 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$item->ID() ), REG_ADMIN_URL ); |
|
489 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_registration', '_REG_ID'=>$item->ID()), REG_ADMIN_URL); |
|
490 | 490 | $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
491 | - $link = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID() ) ? '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">' . $attendee_name . '</a>' : $attendee_name; |
|
491 | + $link = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID()) ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'.$attendee_name.'</a>' : $attendee_name; |
|
492 | 492 | $link .= $item->count() === 1 ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : ''; |
493 | 493 | |
494 | 494 | $t = $item->get_first_related('Transaction'); |
495 | 495 | $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0; |
496 | 496 | |
497 | 497 | //append group count to name |
498 | - $link .= ' ' . sprintf(__( '(%1$s / %2$s)', 'event_espresso' ), $item->count(), $item->group_size()); |
|
498 | + $link .= ' '.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
499 | 499 | |
500 | 500 | //append reg_code |
501 | - $link .= '<br>' . sprintf( __( 'Reg Code: %s', 'event_espresso' ), $item->get('REG_code') ); |
|
501 | + $link .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
502 | 502 | |
503 | 503 | //reg status text for accessibility |
504 | - $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' ) . '</span>'; |
|
504 | + $link .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($item->status_ID(), false, 'sentence').'</span>'; |
|
505 | 505 | |
506 | 506 | //trash/restore/delete actions |
507 | 507 | $actions = array(); |
508 | - if ( $this->_view !== 'trash' && $payment_count === 0 && EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registration', 'espresso_registrations_trash_registrations', $item->ID() ) ) { |
|
509 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'trash_registrations', '_REG_ID'=>$item->ID() ), REG_ADMIN_URL ); |
|
510 | - $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="' . esc_attr__( 'Trash Registration', 'event_espresso' ) . '">' . __( 'Trash', 'event_espresso' ) . '</a>'; |
|
511 | - } elseif ( $this->_view === 'trash' ) { |
|
508 | + if ($this->_view !== 'trash' && $payment_count === 0 && EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', 'espresso_registrations_trash_registrations', $item->ID())) { |
|
509 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'trash_registrations', '_REG_ID'=>$item->ID()), REG_ADMIN_URL); |
|
510 | + $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'.esc_attr__('Trash Registration', 'event_espresso').'">'.__('Trash', 'event_espresso').'</a>'; |
|
511 | + } elseif ($this->_view === 'trash') { |
|
512 | 512 | // restore registration link |
513 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registration', 'espresso_registrations_restore_registrations', $item->ID() ) ) { |
|
514 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'restore_registrations', '_REG_ID'=>$item->ID() ), REG_ADMIN_URL ); |
|
515 | - $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="' . esc_attr__( 'Restore Registration', 'event_espresso' ) . '">' . __( 'Restore', 'event_espresso' ) . '</a>'; |
|
513 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', 'espresso_registrations_restore_registrations', $item->ID())) { |
|
514 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'restore_registrations', '_REG_ID'=>$item->ID()), REG_ADMIN_URL); |
|
515 | + $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'.esc_attr__('Restore Registration', 'event_espresso').'">'.__('Restore', 'event_espresso').'</a>'; |
|
516 | 516 | } |
517 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registration', 'espresso_registrations_ee_delete_registrations', $item->ID() ) ) { |
|
518 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'delete_registrations', '_REG_ID'=>$item->ID() ), REG_ADMIN_URL ); |
|
517 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', 'espresso_registrations_ee_delete_registrations', $item->ID())) { |
|
518 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'delete_registrations', '_REG_ID'=>$item->ID()), REG_ADMIN_URL); |
|
519 | 519 | |
520 | - $actions['delete'] = '<a href="'.$delete_lnk_url.'" title="' . esc_attr__( 'Delete Registration Permanently', 'event_espresso' ). '">' . __( 'Delete', 'event_espresso' ) . '</a>'; |
|
520 | + $actions['delete'] = '<a href="'.$delete_lnk_url.'" title="'.esc_attr__('Delete Registration Permanently', 'event_espresso').'">'.__('Delete', 'event_espresso').'</a>'; |
|
521 | 521 | } |
522 | 522 | } |
523 | 523 | |
524 | - return sprintf('%1$s %2$s', $link, $this->row_actions($actions) ); |
|
524 | + return sprintf('%1$s %2$s', $link, $this->row_actions($actions)); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | * @return string |
535 | 535 | * @throws \EE_Error |
536 | 536 | */ |
537 | - public function column_ATT_email( EE_Registration $item ) { |
|
537 | + public function column_ATT_email(EE_Registration $item) { |
|
538 | 538 | $attendee = $item->get_first_related('Attendee'); |
539 | 539 | return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso') : $attendee->email(); |
540 | 540 | } |
@@ -548,8 +548,8 @@ discard block |
||
548 | 548 | * @param \EE_Registration $item |
549 | 549 | * @return string |
550 | 550 | */ |
551 | - public function column__REG_count(EE_Registration $item){ |
|
552 | - return sprintf(__( '%1$s / %2$s', 'event_espresso' ), $item->count(), $item->group_size()); |
|
551 | + public function column__REG_count(EE_Registration $item) { |
|
552 | + return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size()); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | |
@@ -561,16 +561,16 @@ discard block |
||
561 | 561 | * @param \EE_Registration $item |
562 | 562 | * @return string |
563 | 563 | */ |
564 | - public function column_PRC_amount(EE_Registration $item){ |
|
564 | + public function column_PRC_amount(EE_Registration $item) { |
|
565 | 565 | $ticket = $item->ticket(); |
566 | 566 | |
567 | - $content = isset( $_GET['event_id'] ) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">' . $ticket->name() . '</span><br />' : ''; |
|
567 | + $content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">'.$ticket->name().'</span><br />' : ''; |
|
568 | 568 | |
569 | - if ( $item->final_price() > 0 ) { |
|
570 | - $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
569 | + if ($item->final_price() > 0) { |
|
570 | + $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>'; |
|
571 | 571 | } else { |
572 | 572 | // free event |
573 | - $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">' . __( 'free', 'event_espresso' ) . '</span>'; |
|
573 | + $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">'.__('free', 'event_espresso').'</span>'; |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | return $content; |
@@ -586,11 +586,11 @@ discard block |
||
586 | 586 | * @param \EE_Registration $item |
587 | 587 | * @return string |
588 | 588 | */ |
589 | - public function column__REG_final_price(EE_Registration $item){ |
|
589 | + public function column__REG_final_price(EE_Registration $item) { |
|
590 | 590 | $ticket = $item->ticket(); |
591 | - $content = isset( $_GET['event_id'] ) || ! $ticket instanceof EE_Ticket ? '' : '<span class="TKT_name">' . $ticket->name() . '</span><br />'; |
|
591 | + $content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket ? '' : '<span class="TKT_name">'.$ticket->name().'</span><br />'; |
|
592 | 592 | |
593 | - $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
593 | + $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>'; |
|
594 | 594 | return $content; |
595 | 595 | |
596 | 596 | } |
@@ -604,13 +604,13 @@ discard block |
||
604 | 604 | * @param \EE_Registration $item |
605 | 605 | * @return string |
606 | 606 | */ |
607 | - public function column__REG_paid(EE_Registration $item){ |
|
607 | + public function column__REG_paid(EE_Registration $item) { |
|
608 | 608 | $payment_method = $item->payment_method(); |
609 | - $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __( 'Unknown', 'event_espresso' ); |
|
609 | + $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __('Unknown', 'event_espresso'); |
|
610 | 610 | |
611 | - $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>'; |
|
612 | - if ( $item->paid() > 0 ) { |
|
613 | - $content .= '<br><span class="ee-status-text-small">' . sprintf( __( '...via %s', 'event_espresso' ), $payment_method_name ) . '</span>'; |
|
611 | + $content = '<span class="reg-pad-rght">'.$item->pretty_paid().'</span>'; |
|
612 | + if ($item->paid() > 0) { |
|
613 | + $content .= '<br><span class="ee-status-text-small">'.sprintf(__('...via %s', 'event_espresso'), $payment_method_name).'</span>'; |
|
614 | 614 | } |
615 | 615 | return $content; |
616 | 616 | } |
@@ -625,11 +625,11 @@ discard block |
||
625 | 625 | * @return string |
626 | 626 | * @throws \EE_Error |
627 | 627 | */ |
628 | - public function column_TXN_total(EE_Registration $item){ |
|
629 | - if($item->transaction()){ |
|
630 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->transaction_ID() ), TXN_ADMIN_URL ); |
|
631 | - return EE_Registry::instance()->CAP->current_user_can( 'ee_read_transaction', 'espresso_transactions_view_transaction', $item->transaction_ID() ) ? '<span class="reg-pad-rght"><a class="status-'. $item->transaction()->status_ID() .'" href="'.$view_txn_lnk_url.'" title="' . esc_attr__( 'View Transaction', 'event_espresso' ) . '">' . $item->transaction()->pretty_total() . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>'; |
|
632 | - }else{ |
|
628 | + public function column_TXN_total(EE_Registration $item) { |
|
629 | + if ($item->transaction()) { |
|
630 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$item->transaction_ID()), TXN_ADMIN_URL); |
|
631 | + return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction', $item->transaction_ID()) ? '<span class="reg-pad-rght"><a class="status-'.$item->transaction()->status_ID().'" href="'.$view_txn_lnk_url.'" title="'.esc_attr__('View Transaction', 'event_espresso').'">'.$item->transaction()->pretty_total().'</a></span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_total().'</span>'; |
|
632 | + } else { |
|
633 | 633 | return __("None", "event_espresso"); |
634 | 634 | } |
635 | 635 | } |
@@ -644,15 +644,15 @@ discard block |
||
644 | 644 | * @return string |
645 | 645 | * @throws \EE_Error |
646 | 646 | */ |
647 | - public function column_TXN_paid(EE_Registration $item){ |
|
647 | + public function column_TXN_paid(EE_Registration $item) { |
|
648 | 648 | |
649 | - if ( $item->count() === 1 ) { |
|
649 | + if ($item->count() === 1) { |
|
650 | 650 | $transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance(); |
651 | - if ( $transaction->paid() >= $transaction->total() ) { |
|
651 | + if ($transaction->paid() >= $transaction->total()) { |
|
652 | 652 | return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
653 | 653 | } else { |
654 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->transaction_ID() ), TXN_ADMIN_URL ); |
|
655 | - return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction', $item->transaction_ID() ) ? '<span class="reg-pad-rght"><a class="status-'. $transaction->status_ID() .'" href="'.$view_txn_lnk_url.'" title="' . esc_attr__( 'View Transaction', 'event_espresso' ) . '">' . $item->transaction()->pretty_paid() . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
654 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$item->transaction_ID()), TXN_ADMIN_URL); |
|
655 | + return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction', $item->transaction_ID()) ? '<span class="reg-pad-rght"><a class="status-'.$transaction->status_ID().'" href="'.$view_txn_lnk_url.'" title="'.esc_attr__('View Transaction', 'event_espresso').'">'.$item->transaction()->pretty_paid().'</a><span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>'; |
|
656 | 656 | } |
657 | 657 | } |
658 | 658 | |
@@ -672,44 +672,44 @@ discard block |
||
672 | 672 | */ |
673 | 673 | public function column_actions(EE_Registration $item) { |
674 | 674 | $attendee = $item->attendee(); |
675 | - $this->_set_related_details( $item ); |
|
675 | + $this->_set_related_details($item); |
|
676 | 676 | |
677 | 677 | //Build row actions |
678 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$item->ID() ), REG_ADMIN_URL ); |
|
679 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$item->attendee_ID() ), REG_ADMIN_URL ); |
|
678 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_registration', '_REG_ID'=>$item->ID()), REG_ADMIN_URL); |
|
679 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$item->attendee_ID()), REG_ADMIN_URL); |
|
680 | 680 | |
681 | 681 | // page=attendees&event_admin_reports=resend_email®istration_id=43653465634&event_id=2&form_action=resend_email |
682 | 682 | //$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID ); |
683 | - $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'resend_registration', '_REG_ID'=>$item->ID() ), REG_ADMIN_URL, true ); |
|
683 | + $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'resend_registration', '_REG_ID'=>$item->ID()), REG_ADMIN_URL, true); |
|
684 | 684 | |
685 | 685 | |
686 | 686 | //Build row actions |
687 | - $view_lnk = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID() ) ? ' |
|
687 | + $view_lnk = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID()) ? ' |
|
688 | 688 | <li> |
689 | - <a href="'.$view_lnk_url.'" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '" class="tiny-text"> |
|
689 | + <a href="'.$view_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'" class="tiny-text"> |
|
690 | 690 | <div class="dashicons dashicons-clipboard"></div> |
691 | 691 | </a> |
692 | 692 | </li>' : ''; |
693 | 693 | |
694 | - $edit_lnk = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts', 'espresso_registrations_edit_attendee' ) && $attendee instanceof EE_Attendee ?' |
|
694 | + $edit_lnk = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts', 'espresso_registrations_edit_attendee') && $attendee instanceof EE_Attendee ? ' |
|
695 | 695 | <li> |
696 | - <a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Contact Details', 'event_espresso' ) . '" class="tiny-text"> |
|
696 | + <a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Contact Details', 'event_espresso').'" class="tiny-text"> |
|
697 | 697 | <div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div> |
698 | 698 | </a> |
699 | 699 | </li>' : ''; |
700 | 700 | |
701 | - $resend_reg_lnk = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration', $item->ID() ) ? ' |
|
701 | + $resend_reg_lnk = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration', $item->ID()) ? ' |
|
702 | 702 | <li> |
703 | - <a href="'.$resend_reg_lnk_url.'" title="' . esc_attr__( 'Resend Registration Details', 'event_espresso' ) . '" class="tiny-text"> |
|
703 | + <a href="'.$resend_reg_lnk_url.'" title="'.esc_attr__('Resend Registration Details', 'event_espresso').'" class="tiny-text"> |
|
704 | 704 | <div class="dashicons dashicons-email-alt"></div> |
705 | 705 | </a> |
706 | 706 | </li>' : ''; |
707 | 707 | |
708 | 708 | // page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb |
709 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$this->_transaction_details['id'] ), TXN_ADMIN_URL ); |
|
710 | - $view_txn_lnk = EE_Registry::instance()->CAP->current_user_can( 'ee_read_transaction', 'espresso_transactions_view_transaction', $this->_transaction_details['id'] ) ? ' |
|
709 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$this->_transaction_details['id']), TXN_ADMIN_URL); |
|
710 | + $view_txn_lnk = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction', $this->_transaction_details['id']) ? ' |
|
711 | 711 | <li> |
712 | - <a class="ee-status-color-' . $this->_transaction_details['status'] . ' tiny-text" href="'.$view_txn_lnk_url.'" title="' . $this->_transaction_details['title_attr'] . '"> |
|
712 | + <a class="ee-status-color-' . $this->_transaction_details['status'].' tiny-text" href="'.$view_txn_lnk_url.'" title="'.$this->_transaction_details['title_attr'].'"> |
|
713 | 713 | <div class="dashicons dashicons-cart"></div> |
714 | 714 | </a> |
715 | 715 | </li>' : ''; |
@@ -718,10 +718,10 @@ discard block |
||
718 | 718 | $dl_invoice_lnk = ''; |
719 | 719 | $dl_invoice_lnk_url = $item->invoice_url(); |
720 | 720 | //only show invoice link if message type is active. |
721 | - if ( $attendee instanceof EE_Attendee && $item->is_primary_registrant() && EEH_MSG_Template::is_mt_active( 'invoice' ) ) { |
|
721 | + if ($attendee instanceof EE_Attendee && $item->is_primary_registrant() && EEH_MSG_Template::is_mt_active('invoice')) { |
|
722 | 722 | $dl_invoice_lnk = ' |
723 | 723 | <li> |
724 | - <a title="' . esc_attr__( 'View Transaction Invoice', 'event_espresso' ) . '" target="_blank" href="'.$dl_invoice_lnk_url.'" class="tiny-text"> |
|
724 | + <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso').'" target="_blank" href="'.$dl_invoice_lnk_url.'" class="tiny-text"> |
|
725 | 725 | <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span> |
726 | 726 | </a> |
727 | 727 | </li>'; |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | |
730 | 730 | $filtered_messages_link = ''; |
731 | 731 | //message list table link (filtered by REG_ID |
732 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) { |
|
732 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
733 | 733 | $filtered_messages_link = '<li>' |
734 | 734 | . EEH_MSG_Template::get_message_action_link( |
735 | 735 | 'see_notifications_for', |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | . '</li>'; |
742 | 742 | } |
743 | 743 | |
744 | - return $this->_action_string( $view_lnk . $edit_lnk . $resend_reg_lnk . $view_txn_lnk . $dl_invoice_lnk . $filtered_messages_link, $item, 'ul', 'reg-overview-actions-ul' ); |
|
744 | + return $this->_action_string($view_lnk.$edit_lnk.$resend_reg_lnk.$view_txn_lnk.$dl_invoice_lnk.$filtered_messages_link, $item, 'ul', 'reg-overview-actions-ul'); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | } |
@@ -370,18 +370,18 @@ discard block |
||
370 | 370 | * @return string |
371 | 371 | * @throws \EE_Error |
372 | 372 | */ |
373 | - public function column_cb($item){ |
|
373 | + public function column_cb($item){ |
|
374 | 374 | /** checkbox/lock **/ |
375 | 375 | $transaction = $item->get_first_related( 'Transaction' ); |
376 | 376 | $payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related( 'Payment' ) : 0; |
377 | - return $payment_count > 0 |
|
378 | - ? sprintf( '<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID() ) |
|
379 | - . '<span class="ee-lock-icon"></span>' |
|
380 | - : sprintf( |
|
381 | - '<input type="checkbox" name="_REG_ID[]" value="%1$s" />', |
|
382 | - $item->ID() |
|
383 | - ); |
|
384 | - } |
|
377 | + return $payment_count > 0 |
|
378 | + ? sprintf( '<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID() ) |
|
379 | + . '<span class="ee-lock-icon"></span>' |
|
380 | + : sprintf( |
|
381 | + '<input type="checkbox" name="_REG_ID[]" value="%1$s" />', |
|
382 | + $item->ID() |
|
383 | + ); |
|
384 | + } |
|
385 | 385 | |
386 | 386 | |
387 | 387 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | */ |
418 | 418 | public function column__REG_date(EE_Registration $item){ |
419 | 419 | $this->_set_related_details($item); |
420 | - //Build row actions |
|
420 | + //Build row actions |
|
421 | 421 | $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=> $this->_transaction_details['id'] ), TXN_ADMIN_URL ); |
422 | 422 | $view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? '<a class="ee-status-color-' . $this->_transaction_details['status'] . '" href="'.$view_lnk_url.'" title="' . esc_attr( $this->_transaction_details['title_attr'] ) . '">' . $item->get_i18n_datetime( 'REG_date' ) . '</a>' : $item->get_i18n_datetime( 'REG_date' ); |
423 | 423 | $view_link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $this->_transaction_details['status'], false, 'sentence' ) . '</span>'; |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | } else { |
472 | 472 | return __( 'There is no ticket on this registration', 'event_espresso' ); |
473 | 473 | } |
474 | - } |
|
474 | + } |
|
475 | 475 | |
476 | 476 | |
477 | 477 | |
@@ -494,14 +494,14 @@ discard block |
||
494 | 494 | $t = $item->get_first_related('Transaction'); |
495 | 495 | $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0; |
496 | 496 | |
497 | - //append group count to name |
|
498 | - $link .= ' ' . sprintf(__( '(%1$s / %2$s)', 'event_espresso' ), $item->count(), $item->group_size()); |
|
497 | + //append group count to name |
|
498 | + $link .= ' ' . sprintf(__( '(%1$s / %2$s)', 'event_espresso' ), $item->count(), $item->group_size()); |
|
499 | 499 | |
500 | - //append reg_code |
|
501 | - $link .= '<br>' . sprintf( __( 'Reg Code: %s', 'event_espresso' ), $item->get('REG_code') ); |
|
500 | + //append reg_code |
|
501 | + $link .= '<br>' . sprintf( __( 'Reg Code: %s', 'event_espresso' ), $item->get('REG_code') ); |
|
502 | 502 | |
503 | - //reg status text for accessibility |
|
504 | - $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' ) . '</span>'; |
|
503 | + //reg status text for accessibility |
|
504 | + $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' ) . '</span>'; |
|
505 | 505 | |
506 | 506 | //trash/restore/delete actions |
507 | 507 | $actions = array(); |
@@ -731,14 +731,14 @@ discard block |
||
731 | 731 | //message list table link (filtered by REG_ID |
732 | 732 | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) { |
733 | 733 | $filtered_messages_link = '<li>' |
734 | - . EEH_MSG_Template::get_message_action_link( |
|
734 | + . EEH_MSG_Template::get_message_action_link( |
|
735 | 735 | 'see_notifications_for', |
736 | 736 | null, |
737 | 737 | array( |
738 | 738 | '_REG_ID' => $item->ID() |
739 | 739 | ) |
740 | 740 | ) |
741 | - . '</li>'; |
|
741 | + . '</li>'; |
|
742 | 742 | } |
743 | 743 | |
744 | 744 | return $this->_action_string( $view_lnk . $edit_lnk . $resend_reg_lnk . $view_txn_lnk . $dl_invoice_lnk . $filtered_messages_link, $item, 'ul', 'reg-overview-actions-ul' ); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | * @param bool $add_pound_sign |
28 | 28 | * @return string |
29 | 29 | */ |
30 | - public function get_sub_input_id( $option_value, $add_pound_sign = false ) { |
|
31 | - return $this->_append_chars( $this->_input->html_id( $add_pound_sign ), '-' ) . sanitize_key( $option_value ); |
|
30 | + public function get_sub_input_id($option_value, $add_pound_sign = false) { |
|
31 | + return $this->_append_chars($this->_input->html_id($add_pound_sign), '-').sanitize_key($option_value); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | * @return array |
41 | 41 | * @throws \EE_Error |
42 | 42 | */ |
43 | - public function get_html_input_ids( $add_pound_sign = false ) { |
|
43 | + public function get_html_input_ids($add_pound_sign = false) { |
|
44 | 44 | $html_input_ids = array(); |
45 | - foreach( $this->get_input()->options() as $value => $display ) { |
|
46 | - $html_input_ids[] = $this->get_sub_input_id( $value, $add_pound_sign ); |
|
45 | + foreach ($this->get_input()->options() as $value => $display) { |
|
46 | + $html_input_ids[] = $this->get_sub_input_id($value, $add_pound_sign); |
|
47 | 47 | } |
48 | 48 | return $html_input_ids; |
49 | 49 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @throws \EE_Error |
59 | 59 | */ |
60 | 60 | public function get_input() { |
61 | - if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base ){ |
|
61 | + if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) { |
|
62 | 62 | throw new EE_Error( |
63 | 63 | sprintf( |
64 | 64 | __( |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * Class EE_Radio_Button_Display_Strategy |
4 | 4 | * displays a set of radio buttons |
@@ -15,33 +15,33 @@ discard block |
||
15 | 15 | * @throws EE_Error |
16 | 16 | * @return string of html to display the field |
17 | 17 | */ |
18 | - public function display(){ |
|
18 | + public function display() { |
|
19 | 19 | $input = $this->get_input(); |
20 | 20 | $input->set_label_sizes(); |
21 | 21 | $label_size_class = $input->get_label_size_class(); |
22 | 22 | $html = ''; |
23 | - foreach( $input->options() as $value => $display_text ){ |
|
24 | - $value = $input->get_normalization_strategy()->unnormalize( $value ); |
|
23 | + foreach ($input->options() as $value => $display_text) { |
|
24 | + $value = $input->get_normalization_strategy()->unnormalize($value); |
|
25 | 25 | |
26 | - $html_id = $this->get_sub_input_id( $value ); |
|
27 | - $html .= EEH_HTML::nl( 0, 'radio' ); |
|
28 | - $html .= '<label for="' . $html_id . '"'; |
|
29 | - $html .= ' id="' . $html_id . '-lbl"'; |
|
30 | - $html .= ' class="ee-radio-label-after' . $label_size_class . '">'; |
|
31 | - $html .= EEH_HTML::nl( 1, 'radio' ); |
|
32 | - $html .= '<input id="' . $html_id . '"'; |
|
33 | - $html .= ' name="' . $input->html_name() . '"'; |
|
34 | - $html .= ' class="' . $input->html_class() . '"'; |
|
35 | - $html .= ' style="' . $input->html_style() . '"'; |
|
26 | + $html_id = $this->get_sub_input_id($value); |
|
27 | + $html .= EEH_HTML::nl(0, 'radio'); |
|
28 | + $html .= '<label for="'.$html_id.'"'; |
|
29 | + $html .= ' id="'.$html_id.'-lbl"'; |
|
30 | + $html .= ' class="ee-radio-label-after'.$label_size_class.'">'; |
|
31 | + $html .= EEH_HTML::nl(1, 'radio'); |
|
32 | + $html .= '<input id="'.$html_id.'"'; |
|
33 | + $html .= ' name="'.$input->html_name().'"'; |
|
34 | + $html .= ' class="'.$input->html_class().'"'; |
|
35 | + $html .= ' style="'.$input->html_style().'"'; |
|
36 | 36 | $html .= ' type="radio"'; |
37 | - $html .= ' value="' . esc_attr( $value ) . '"'; |
|
37 | + $html .= ' value="'.esc_attr($value).'"'; |
|
38 | 38 | $html .= $input->raw_value() === $value ? ' checked="checked"' : ''; |
39 | 39 | $html .= '> '; |
40 | 40 | $html .= $display_text; |
41 | - $html .= EEH_HTML::nl( -1, 'radio' ) . '</label>'; |
|
41 | + $html .= EEH_HTML::nl( -1, 'radio' ).'</label>'; |
|
42 | 42 | |
43 | 43 | } |
44 | - $html .= EEH_HTML::div( '', '', 'clear-float' ); |
|
44 | + $html .= EEH_HTML::div('', '', 'clear-float'); |
|
45 | 45 | $html .= EEH_HTML::divx(); |
46 | 46 | return $html; |
47 | 47 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @param EE_Message_Resource_Manager $message_resource_manager |
37 | 37 | */ |
38 | - public function __construct( EE_Message_Resource_Manager $message_resource_manager ) { |
|
38 | + public function __construct(EE_Message_Resource_Manager $message_resource_manager) { |
|
39 | 39 | $this->_message_resource_manager = $message_resource_manager; |
40 | 40 | $this->_init_queue_and_generator(); |
41 | 41 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * - $_generator = holds the messages generator |
51 | 51 | */ |
52 | 52 | protected function _init_queue_and_generator() { |
53 | - $this->_generator = EE_Registry::factory( 'EE_Messages_Generator' ); |
|
53 | + $this->_generator = EE_Registry::factory('EE_Messages_Generator'); |
|
54 | 54 | $this->_queue = $this->_generator->generation_queue(); |
55 | 55 | } |
56 | 56 | |
@@ -75,13 +75,13 @@ discard block |
||
75 | 75 | * @return bool|EE_Messages_Queue return false if nothing generated. This returns a new EE_Message_Queue with |
76 | 76 | * generated messages. |
77 | 77 | */ |
78 | - public function batch_generate_from_queue( $messages = array(), $clear_queue = false ) { |
|
79 | - if ( $this->_build_queue_for_generation( $messages, $clear_queue ) ) { |
|
78 | + public function batch_generate_from_queue($messages = array(), $clear_queue = false) { |
|
79 | + if ($this->_build_queue_for_generation($messages, $clear_queue)) { |
|
80 | 80 | $new_queue = $this->_generator->generate(); |
81 | - if ( $new_queue instanceof EE_Messages_Queue ) { |
|
81 | + if ($new_queue instanceof EE_Messages_Queue) { |
|
82 | 82 | //unlock queue |
83 | 83 | $this->_queue->unlock_queue(); |
84 | - $this->_queue->initiate_request_by_priority( 'send' ); |
|
84 | + $this->_queue->initiate_request_by_priority('send'); |
|
85 | 85 | return $new_queue; |
86 | 86 | } |
87 | 87 | } |
@@ -102,24 +102,24 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @return bool true means queue prepped, false means there was a lock so no generation please. |
104 | 104 | */ |
105 | - protected function _build_queue_for_generation( $messages = array(), $clear_queue = false ) { |
|
105 | + protected function _build_queue_for_generation($messages = array(), $clear_queue = false) { |
|
106 | 106 | |
107 | - if ( $clear_queue ) { |
|
107 | + if ($clear_queue) { |
|
108 | 108 | $this->_init_queue_and_generator(); |
109 | 109 | } |
110 | 110 | |
111 | - if ( $messages ) { |
|
111 | + if ($messages) { |
|
112 | 112 | //if generation is locked then get out now because that means processing is already happening. |
113 | - if ( $this->_queue->is_locked() ) { |
|
113 | + if ($this->_queue->is_locked()) { |
|
114 | 114 | return false; |
115 | 115 | } |
116 | 116 | |
117 | 117 | $this->_queue->lock_queue(); |
118 | - $messages = is_array( $messages ) ? $messages : array( $messages ); |
|
119 | - foreach ( $messages as $message ) { |
|
120 | - if ( $message instanceof EE_Message ) { |
|
118 | + $messages = is_array($messages) ? $messages : array($messages); |
|
119 | + foreach ($messages as $message) { |
|
120 | + if ($message instanceof EE_Message) { |
|
121 | 121 | $data = $message->all_extra_meta_array(); |
122 | - $this->_queue->add( $message, $data ); |
|
122 | + $this->_queue->add($message, $data); |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | return true; |
@@ -137,22 +137,22 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @return bool true means queue prepped, false means there was a lock so no queue prepped. |
139 | 139 | */ |
140 | - protected function _build_queue_for_sending( $messages, $clear_queue = false ) { |
|
140 | + protected function _build_queue_for_sending($messages, $clear_queue = false) { |
|
141 | 141 | //if sending is locked then get out now because that means processing is already happening. |
142 | - if ( $this->_queue->is_locked( EE_Messages_Queue::action_sending ) ) { |
|
142 | + if ($this->_queue->is_locked(EE_Messages_Queue::action_sending)) { |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | |
146 | - $this->_queue->lock_queue( EE_Messages_Queue::action_sending ); |
|
146 | + $this->_queue->lock_queue(EE_Messages_Queue::action_sending); |
|
147 | 147 | |
148 | - if ( $clear_queue ) { |
|
148 | + if ($clear_queue) { |
|
149 | 149 | $this->_init_queue_and_generator(); |
150 | 150 | } |
151 | 151 | |
152 | - $messages = is_array( $messages ) ? $messages : array( $messages ); |
|
152 | + $messages = is_array($messages) ? $messages : array($messages); |
|
153 | 153 | |
154 | - foreach ( $messages as $message ) { |
|
155 | - $this->_queue->add( $message ); |
|
154 | + foreach ($messages as $message) { |
|
155 | + $this->_queue->add($message); |
|
156 | 156 | } |
157 | 157 | return true; |
158 | 158 | } |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @return EE_Messages_Queue |
170 | 170 | */ |
171 | - public function batch_send_from_queue( $messages = array(), $clear_queue = false ) { |
|
171 | + public function batch_send_from_queue($messages = array(), $clear_queue = false) { |
|
172 | 172 | |
173 | - if ( $messages && $this->_build_queue_for_sending( $messages, $clear_queue ) ) { |
|
173 | + if ($messages && $this->_build_queue_for_sending($messages, $clear_queue)) { |
|
174 | 174 | $this->_queue->execute(); |
175 | - $this->_queue->unlock_queue( EE_Messages_Queue::action_sending ); |
|
175 | + $this->_queue->unlock_queue(EE_Messages_Queue::action_sending); |
|
176 | 176 | } else { |
177 | 177 | //get messages to send and execute. |
178 | 178 | $this->_queue->get_to_send_batch_and_send(); |
@@ -195,10 +195,10 @@ discard block |
||
195 | 195 | * @param EE_Message_To_Generate[] $messages_to_generate |
196 | 196 | * @return EE_Messages_Queue |
197 | 197 | */ |
198 | - public function generate_and_return( $messages_to_generate ) { |
|
198 | + public function generate_and_return($messages_to_generate) { |
|
199 | 199 | $this->_init_queue_and_generator(); |
200 | - $this->_queue_for_generation_loop( $messages_to_generate ); |
|
201 | - return $this->_generator->generate( false ); |
|
200 | + $this->_queue_for_generation_loop($messages_to_generate); |
|
201 | + return $this->_generator->generate(false); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -209,8 +209,8 @@ discard block |
||
209 | 209 | * @param bool $persist Indicate whether to instruct the generator to persist the generated queue (true) or not (false). |
210 | 210 | * @return EE_Messages_Queue |
211 | 211 | */ |
212 | - public function generate_queue( $persist = true ) { |
|
213 | - return $this->_generator->generate( $persist ); |
|
212 | + public function generate_queue($persist = true) { |
|
213 | + return $this->_generator->generate($persist); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | * @param bool $test_send Whether this item is for a test send or not. |
224 | 224 | * @return EE_Messages_Queue |
225 | 225 | */ |
226 | - public function queue_for_generation( EE_Message_To_Generate $message_to_generate, $test_send = false ) { |
|
227 | - if ( $message_to_generate->valid() ) { |
|
228 | - $this->_generator->create_and_add_message_to_queue( $message_to_generate, $test_send ); |
|
226 | + public function queue_for_generation(EE_Message_To_Generate $message_to_generate, $test_send = false) { |
|
227 | + if ($message_to_generate->valid()) { |
|
228 | + $this->_generator->create_and_add_message_to_queue($message_to_generate, $test_send); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @param EE_Message_To_Generate[] $messages_to_generate |
243 | 243 | */ |
244 | - public function batch_queue_for_generation_and_persist( $messages_to_generate ) { |
|
244 | + public function batch_queue_for_generation_and_persist($messages_to_generate) { |
|
245 | 245 | $this->_init_queue_and_generator(); |
246 | - $this->_queue_for_generation_loop( $messages_to_generate ); |
|
246 | + $this->_queue_for_generation_loop($messages_to_generate); |
|
247 | 247 | $this->_queue->save(); |
248 | 248 | } |
249 | 249 | |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @param EE_Message_To_Generate[] $messages_to_generate |
261 | 261 | */ |
262 | - public function batch_queue_for_generation_no_persist( $messages_to_generate ) { |
|
262 | + public function batch_queue_for_generation_no_persist($messages_to_generate) { |
|
263 | 263 | $this->_init_queue_and_generator(); |
264 | - $this->_queue_for_generation_loop( $messages_to_generate ); |
|
264 | + $this->_queue_for_generation_loop($messages_to_generate); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
@@ -273,15 +273,15 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @param EE_Message_To_Generate[] $messages_to_generate |
275 | 275 | */ |
276 | - protected function _queue_for_generation_loop( $messages_to_generate ) { |
|
276 | + protected function _queue_for_generation_loop($messages_to_generate) { |
|
277 | 277 | //make sure is in an array. |
278 | - if ( ! is_array( $messages_to_generate ) ) { |
|
279 | - $messages_to_generate = array( $messages_to_generate ); |
|
278 | + if ( ! is_array($messages_to_generate)) { |
|
279 | + $messages_to_generate = array($messages_to_generate); |
|
280 | 280 | } |
281 | 281 | |
282 | - foreach ( $messages_to_generate as $message_to_generate ) { |
|
283 | - if ( $message_to_generate instanceof EE_Message_To_Generate && $message_to_generate->valid() ) { |
|
284 | - $this->queue_for_generation( $message_to_generate ); |
|
282 | + foreach ($messages_to_generate as $message_to_generate) { |
|
283 | + if ($message_to_generate instanceof EE_Message_To_Generate && $message_to_generate->valid()) { |
|
284 | + $this->queue_for_generation($message_to_generate); |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 | } |
@@ -296,10 +296,10 @@ discard block |
||
296 | 296 | * @param EE_Message_To_Generate[] |
297 | 297 | * @return EE_Messages_Queue |
298 | 298 | */ |
299 | - public function generate_and_queue_for_sending( $messages_to_generate ) { |
|
299 | + public function generate_and_queue_for_sending($messages_to_generate) { |
|
300 | 300 | $this->_init_queue_and_generator(); |
301 | - $this->_queue_for_generation_loop( $messages_to_generate ); |
|
302 | - return $this->_generator->generate( true ); |
|
301 | + $this->_queue_for_generation_loop($messages_to_generate); |
|
302 | + return $this->_generator->generate(true); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | |
@@ -313,10 +313,10 @@ discard block |
||
313 | 313 | * @param bool $test_send Whether this is a test send or not. |
314 | 314 | * @return EE_Messages_Queue | bool false if unable to generate otherwise the generated queue. |
315 | 315 | */ |
316 | - public function generate_for_preview( EE_Message_To_Generate $message_to_generate, $test_send = false ) { |
|
317 | - if ( ! $message_to_generate->valid() ) { |
|
316 | + public function generate_for_preview(EE_Message_To_Generate $message_to_generate, $test_send = false) { |
|
317 | + if ( ! $message_to_generate->valid()) { |
|
318 | 318 | EE_Error::add_error( |
319 | - __( 'Unable to generate preview because of invalid data', 'event_espresso' ), |
|
319 | + __('Unable to generate preview because of invalid data', 'event_espresso'), |
|
320 | 320 | __FILE__, |
321 | 321 | __FUNCTION__, |
322 | 322 | __LINE__ |
@@ -324,14 +324,14 @@ discard block |
||
324 | 324 | return false; |
325 | 325 | } |
326 | 326 | //just make sure preview is set on the $message_to_generate (in case client forgot) |
327 | - $message_to_generate->set_preview( true ); |
|
327 | + $message_to_generate->set_preview(true); |
|
328 | 328 | $this->_init_queue_and_generator(); |
329 | - $this->queue_for_generation( $message_to_generate, $test_send ); |
|
330 | - $generated_queue = $this->_generator->generate( false ); |
|
331 | - if ( $generated_queue->execute( false ) ) { |
|
329 | + $this->queue_for_generation($message_to_generate, $test_send); |
|
330 | + $generated_queue = $this->_generator->generate(false); |
|
331 | + if ($generated_queue->execute(false)) { |
|
332 | 332 | //the first queue item should be the preview |
333 | 333 | $generated_queue->get_message_repository()->rewind(); |
334 | - if ( ! $generated_queue->get_message_repository()->valid() ) { |
|
334 | + if ( ! $generated_queue->get_message_repository()->valid()) { |
|
335 | 335 | return $generated_queue; |
336 | 336 | } |
337 | 337 | return $generated_queue->get_message_repository()->is_test_send() ? true : $generated_queue; |
@@ -348,15 +348,15 @@ discard block |
||
348 | 348 | * @param EE_Message_To_Generate $message_to_generate |
349 | 349 | * @return bool true or false for success. |
350 | 350 | */ |
351 | - public function queue_for_sending( EE_Message_To_Generate $message_to_generate ) { |
|
352 | - if ( ! $message_to_generate->valid() ) { |
|
351 | + public function queue_for_sending(EE_Message_To_Generate $message_to_generate) { |
|
352 | + if ( ! $message_to_generate->valid()) { |
|
353 | 353 | return false; |
354 | 354 | } |
355 | 355 | $this->_init_queue_and_generator(); |
356 | 356 | $message = $message_to_generate->get_EE_Message(); |
357 | - $this->_queue->add( $message ); |
|
358 | - if ( $message->send_now() ) { |
|
359 | - $this->_queue->execute( false ); |
|
357 | + $this->_queue->add($message); |
|
358 | + if ($message->send_now()) { |
|
359 | + $this->_queue->execute(false); |
|
360 | 360 | } else { |
361 | 361 | $this->_queue->save(); |
362 | 362 | } |
@@ -369,12 +369,12 @@ discard block |
||
369 | 369 | * @param EE_Message_To_Generate $message_to_generate |
370 | 370 | * @return EE_Messages_Queue | null |
371 | 371 | */ |
372 | - public function generate_and_send_now( EE_Message_To_Generate $message_to_generate ) { |
|
373 | - if ( ! $message_to_generate->valid() ) { |
|
372 | + public function generate_and_send_now(EE_Message_To_Generate $message_to_generate) { |
|
373 | + if ( ! $message_to_generate->valid()) { |
|
374 | 374 | return null; |
375 | 375 | } |
376 | 376 | // is there supposed to be a sending messenger for this message? |
377 | - if ( $message_to_generate instanceof EEI_Has_Sending_Messenger ) { |
|
377 | + if ($message_to_generate instanceof EEI_Has_Sending_Messenger) { |
|
378 | 378 | // make sure it's valid, but if it's not, |
379 | 379 | // then set the value of $sending_messenger to an EE_Error object |
380 | 380 | // so that downstream code can easily see that things went wrong. |
@@ -390,14 +390,14 @@ discard block |
||
390 | 390 | $sending_messenger = null; |
391 | 391 | } |
392 | 392 | |
393 | - if ( $message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_idle ) { |
|
393 | + if ($message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_idle) { |
|
394 | 394 | $this->_init_queue_and_generator(); |
395 | - $this->_queue->add( $message_to_generate->get_EE_Message() ); |
|
396 | - $this->_queue->execute( false, $sending_messenger ); |
|
395 | + $this->_queue->add($message_to_generate->get_EE_Message()); |
|
396 | + $this->_queue->execute(false, $sending_messenger); |
|
397 | 397 | return $this->_queue; |
398 | - } elseif ( $message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_incomplete ) { |
|
399 | - $generated_queue = $this->generate_and_return( array( $message_to_generate ) ); |
|
400 | - $generated_queue->execute( false, $sending_messenger ); |
|
398 | + } elseif ($message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_incomplete) { |
|
399 | + $generated_queue = $this->generate_and_return(array($message_to_generate)); |
|
400 | + $generated_queue->execute(false, $sending_messenger); |
|
401 | 401 | return $generated_queue; |
402 | 402 | } |
403 | 403 | return null; |
@@ -414,13 +414,13 @@ discard block |
||
414 | 414 | * @param mixed $data The data being used for generation. |
415 | 415 | * @param bool $persist Whether to persist the queued messages to the db or not. |
416 | 416 | */ |
417 | - public function generate_for_all_active_messengers( $message_type, $data, $persist = true ) { |
|
418 | - $messages_to_generate = $this->setup_mtgs_for_all_active_messengers( $message_type, $data ); |
|
419 | - if ( $persist ) { |
|
420 | - $this->batch_queue_for_generation_and_persist( $messages_to_generate ); |
|
417 | + public function generate_for_all_active_messengers($message_type, $data, $persist = true) { |
|
418 | + $messages_to_generate = $this->setup_mtgs_for_all_active_messengers($message_type, $data); |
|
419 | + if ($persist) { |
|
420 | + $this->batch_queue_for_generation_and_persist($messages_to_generate); |
|
421 | 421 | $this->_queue->initiate_request_by_priority(); |
422 | 422 | } else { |
423 | - $this->batch_queue_for_generation_no_persist( $messages_to_generate ); |
|
423 | + $this->batch_queue_for_generation_no_persist($messages_to_generate); |
|
424 | 424 | } |
425 | 425 | } |
426 | 426 | |
@@ -435,11 +435,11 @@ discard block |
||
435 | 435 | * |
436 | 436 | * @return EE_Message_To_Generate[] |
437 | 437 | */ |
438 | - public function setup_mtgs_for_all_active_messengers( $message_type, $data ) { |
|
438 | + public function setup_mtgs_for_all_active_messengers($message_type, $data) { |
|
439 | 439 | $messages_to_generate = array(); |
440 | - foreach ( $this->_message_resource_manager->active_messengers() as $messenger_slug => $messenger_object ) { |
|
441 | - $message_to_generate = new EE_Message_To_Generate( $messenger_slug, $message_type, $data ); |
|
442 | - if ( $message_to_generate->valid() ) { |
|
440 | + foreach ($this->_message_resource_manager->active_messengers() as $messenger_slug => $messenger_object) { |
|
441 | + $message_to_generate = new EE_Message_To_Generate($messenger_slug, $message_type, $data); |
|
442 | + if ($message_to_generate->valid()) { |
|
443 | 443 | $messages_to_generate[] = $message_to_generate; |
444 | 444 | } |
445 | 445 | } |
@@ -454,23 +454,23 @@ discard block |
||
454 | 454 | * and send. |
455 | 455 | * @param array $message_ids |
456 | 456 | */ |
457 | - public function setup_messages_from_ids_and_send( $message_ids ) { |
|
457 | + public function setup_messages_from_ids_and_send($message_ids) { |
|
458 | 458 | $this->_init_queue_and_generator(); |
459 | - $messages = EEM_Message::instance()->get_all( array( |
|
459 | + $messages = EEM_Message::instance()->get_all(array( |
|
460 | 460 | array( |
461 | - 'MSG_ID' => array( 'IN', $message_ids ), |
|
462 | - 'STS_ID' => array( 'IN', EEM_Message::instance()->stati_indicating_sent() ) |
|
461 | + 'MSG_ID' => array('IN', $message_ids), |
|
462 | + 'STS_ID' => array('IN', EEM_Message::instance()->stati_indicating_sent()) |
|
463 | 463 | ) |
464 | 464 | )); |
465 | 465 | //set the Messages to resend. |
466 | - foreach ( $messages as $message ) { |
|
467 | - if ( $message instanceof EE_Message ) { |
|
468 | - $message->set_STS_ID( EEM_Message::status_resend ); |
|
469 | - $this->_queue->add( $message ); |
|
466 | + foreach ($messages as $message) { |
|
467 | + if ($message instanceof EE_Message) { |
|
468 | + $message->set_STS_ID(EEM_Message::status_resend); |
|
469 | + $this->_queue->add($message); |
|
470 | 470 | } |
471 | 471 | } |
472 | 472 | |
473 | - $this->_queue->initiate_request_by_priority( 'send' ); |
|
473 | + $this->_queue->initiate_request_by_priority('send'); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | |
@@ -484,23 +484,23 @@ discard block |
||
484 | 484 | * |
485 | 485 | * @return EE_Message_To_Generate[] |
486 | 486 | */ |
487 | - public function setup_messages_to_generate_from_registration_ids_in_request( $registration_ids_key = '_REG_ID' ) { |
|
488 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
489 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
487 | + public function setup_messages_to_generate_from_registration_ids_in_request($registration_ids_key = '_REG_ID') { |
|
488 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
489 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
490 | 490 | $regs_to_send = array(); |
491 | - $regIDs = EE_Registry::instance()->REQ->get( $registration_ids_key ); |
|
492 | - if ( empty( $regIDs ) ) { |
|
493 | - EE_Error::add_error( __('Something went wrong because we\'re missing the registration ID', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
491 | + $regIDs = EE_Registry::instance()->REQ->get($registration_ids_key); |
|
492 | + if (empty($regIDs)) { |
|
493 | + EE_Error::add_error(__('Something went wrong because we\'re missing the registration ID', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
494 | 494 | return false; |
495 | 495 | } |
496 | 496 | |
497 | 497 | //make sure is an array |
498 | - $regIDs = is_array( $regIDs ) ? $regIDs : array( $regIDs ); |
|
498 | + $regIDs = is_array($regIDs) ? $regIDs : array($regIDs); |
|
499 | 499 | |
500 | - foreach( $regIDs as $regID ) { |
|
501 | - $reg = EEM_Registration::instance()->get_one_by_ID( $regID ); |
|
502 | - if ( ! $reg instanceof EE_Registration ) { |
|
503 | - EE_Error::add_error( sprintf( __('Unable to retrieve a registration object for the given reg id (%s)', 'event_espresso'), $regID ) ); |
|
500 | + foreach ($regIDs as $regID) { |
|
501 | + $reg = EEM_Registration::instance()->get_one_by_ID($regID); |
|
502 | + if ( ! $reg instanceof EE_Registration) { |
|
503 | + EE_Error::add_error(sprintf(__('Unable to retrieve a registration object for the given reg id (%s)', 'event_espresso'), $regID)); |
|
504 | 504 | return false; |
505 | 505 | } |
506 | 506 | $regs_to_send[$reg->transaction_ID()][$reg->status_ID()][] = $reg; |
@@ -508,11 +508,11 @@ discard block |
||
508 | 508 | |
509 | 509 | $messages_to_generate = array(); |
510 | 510 | |
511 | - foreach ( $regs_to_send as $status_group ) { |
|
512 | - foreach ( $status_group as $status_id => $registrations ) { |
|
511 | + foreach ($regs_to_send as $status_group) { |
|
512 | + foreach ($status_group as $status_id => $registrations) { |
|
513 | 513 | $messages_to_generate = $messages_to_generate + $this->setup_mtgs_for_all_active_messengers( |
514 | - EEH_MSG_Template::convert_reg_status_to_message_type( $status_id ), |
|
515 | - array( $registrations, $status_id ) |
|
514 | + EEH_MSG_Template::convert_reg_status_to_message_type($status_id), |
|
515 | + array($registrations, $status_id) |
|
516 | 516 | ); |
517 | 517 | } |
518 | 518 | } |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | * @param EE_Messages_Queue $queue |
26 | 26 | * @param string $custom_subject Used if a custom subject is desired for the generated aggregate EE_Message object |
27 | 27 | */ |
28 | - public function __construct( $messenger_name, $message_type_name, EE_Messages_Queue $queue, $custom_subject = '' ) { |
|
28 | + public function __construct($messenger_name, $message_type_name, EE_Messages_Queue $queue, $custom_subject = '') { |
|
29 | 29 | $this->queue = $queue; |
30 | - parent::__construct( $messenger_name, $message_type_name, array(), '', false, EEM_Message::status_idle ); |
|
31 | - if ( $this->valid() ) { |
|
32 | - $this->_message->set_content( $this->_get_content() ); |
|
33 | - $this->_message->set_subject( $this->_get_subject( $custom_subject ) ); |
|
30 | + parent::__construct($messenger_name, $message_type_name, array(), '', false, EEM_Message::status_idle); |
|
31 | + if ($this->valid()) { |
|
32 | + $this->_message->set_content($this->_get_content()); |
|
33 | + $this->_message->set_subject($this->_get_subject($custom_subject)); |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | protected function _get_content() { |
45 | 45 | $content = ''; |
46 | 46 | $this->queue->get_message_repository()->rewind(); |
47 | - while ( $this->queue->get_message_repository()->valid() ) { |
|
47 | + while ($this->queue->get_message_repository()->valid()) { |
|
48 | 48 | $content .= $this->queue->get_message_repository()->current()->content(); |
49 | 49 | $this->queue->get_message_repository()->next(); |
50 | 50 | } |
@@ -58,15 +58,15 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @return string |
60 | 60 | */ |
61 | - protected function _get_subject( $custom_subject = '' ) { |
|
62 | - if ( ! empty( $custom_subject ) ) { |
|
61 | + protected function _get_subject($custom_subject = '') { |
|
62 | + if ( ! empty($custom_subject)) { |
|
63 | 63 | return $custom_subject; |
64 | 64 | } |
65 | 65 | $this->queue->get_message_repository()->rewind(); |
66 | 66 | $count_of_items = $this->queue->get_message_repository()->count(); |
67 | 67 | |
68 | 68 | //if $count of items in queue == 1, then let's just return the subject for that item. |
69 | - if ( $count_of_items === 1 ) { |
|
69 | + if ($count_of_items === 1) { |
|
70 | 70 | return $this->queue->get_message_repository()->current()->subject(); |
71 | 71 | } |
72 | 72 |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param \EE_Message_Repository $message_repository |
73 | 73 | */ |
74 | - public function __construct( EE_Message_Repository $message_repository ) { |
|
75 | - $this->_batch_count = apply_filters( 'FHEE__EE_Messages_Queue___batch_count', 50 ); |
|
74 | + public function __construct(EE_Message_Repository $message_repository) { |
|
75 | + $this->_batch_count = apply_filters('FHEE__EE_Messages_Queue___batch_count', 50); |
|
76 | 76 | $this->_rate_limit = $this->get_rate_limit(); |
77 | 77 | $this->_message_repository = $message_repository; |
78 | 78 | } |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | * use the messenger send method but typically is based on preview data. |
92 | 92 | * @return bool Whether the message was successfully added to the repository or not. |
93 | 93 | */ |
94 | - public function add( EE_Message $message, $data = array(), $preview = false, $test_send = false ) { |
|
94 | + public function add(EE_Message $message, $data = array(), $preview = false, $test_send = false) { |
|
95 | 95 | $data['preview'] = $preview; |
96 | 96 | $data['test_send'] = $test_send; |
97 | - return $this->_message_repository->add( $message, $data ); |
|
97 | + return $this->_message_repository->add($message, $data); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | * @param bool $persist This flag indicates whether to attempt to delete the object from the db as well. |
107 | 107 | * @return bool |
108 | 108 | */ |
109 | - public function remove( EE_Message $message, $persist = false ) { |
|
110 | - if ( $persist && $this->_message_repository->current() !== $message ) { |
|
109 | + public function remove(EE_Message $message, $persist = false) { |
|
110 | + if ($persist && $this->_message_repository->current() !== $message) { |
|
111 | 111 | //get pointer on right message |
112 | - if ( $this->_message_repository->has( $message ) ) { |
|
112 | + if ($this->_message_repository->has($message)) { |
|
113 | 113 | $this->_message_repository->rewind(); |
114 | - while( $this->_message_repository->valid() ) { |
|
115 | - if ( $this->_message_repository->current() === $message ) { |
|
114 | + while ($this->_message_repository->valid()) { |
|
115 | + if ($this->_message_repository->current() === $message) { |
|
116 | 116 | break; |
117 | 117 | } |
118 | 118 | $this->_message_repository->next(); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | return false; |
122 | 122 | } |
123 | 123 | } |
124 | - return $persist ? $this->_message_repository->delete() : $this->_message_repository->remove( $message ); |
|
124 | + return $persist ? $this->_message_repository->delete() : $this->_message_repository->remove($message); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
@@ -161,29 +161,29 @@ discard block |
||
161 | 161 | * @return bool true if successfully retrieved batch, false no batch ready. |
162 | 162 | */ |
163 | 163 | public function get_batch_to_generate() { |
164 | - if ( $this->is_locked( EE_Messages_Queue::action_generating ) ) { |
|
164 | + if ($this->is_locked(EE_Messages_Queue::action_generating)) { |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | 168 | //lock batch generation to prevent race conditions. |
169 | - $this->lock_queue( EE_Messages_Queue::action_generating ); |
|
169 | + $this->lock_queue(EE_Messages_Queue::action_generating); |
|
170 | 170 | |
171 | 171 | $query_args = array( |
172 | 172 | // key 0 = where conditions |
173 | - 0 => array( 'STS_ID' => EEM_Message::status_incomplete ), |
|
173 | + 0 => array('STS_ID' => EEM_Message::status_incomplete), |
|
174 | 174 | 'order_by' => $this->_get_priority_orderby(), |
175 | 175 | 'limit' => $this->_batch_count |
176 | 176 | ); |
177 | - $messages = EEM_Message::instance()->get_all( $query_args ); |
|
177 | + $messages = EEM_Message::instance()->get_all($query_args); |
|
178 | 178 | |
179 | - if ( ! $messages ) { |
|
179 | + if ( ! $messages) { |
|
180 | 180 | return false; //nothing to generate |
181 | 181 | } |
182 | 182 | |
183 | - foreach ( $messages as $message ) { |
|
184 | - if ( $message instanceof EE_Message ) { |
|
183 | + foreach ($messages as $message) { |
|
184 | + if ($message instanceof EE_Message) { |
|
185 | 185 | $data = $message->all_extra_meta_array(); |
186 | - $this->add( $message, $data ); |
|
186 | + $this->add($message, $data); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | return true; |
@@ -206,34 +206,34 @@ discard block |
||
206 | 206 | * to assist with notifying user. |
207 | 207 | */ |
208 | 208 | public function get_to_send_batch_and_send() { |
209 | - if ( $this->is_locked( EE_Messages_Queue::action_sending ) || $this->_rate_limit < 1 ) { |
|
209 | + if ($this->is_locked(EE_Messages_Queue::action_sending) || $this->_rate_limit < 1) { |
|
210 | 210 | return false; |
211 | 211 | } |
212 | 212 | |
213 | - $this->lock_queue( EE_Messages_Queue::action_sending ); |
|
213 | + $this->lock_queue(EE_Messages_Queue::action_sending); |
|
214 | 214 | |
215 | 215 | $batch = $this->_batch_count < $this->_rate_limit ? $this->_batch_count : $this->_rate_limit; |
216 | 216 | |
217 | 217 | $query_args = array( |
218 | 218 | // key 0 = where conditions |
219 | - 0 => array( 'STS_ID' => array( 'IN', EEM_Message::instance()->stati_indicating_to_send() ) ), |
|
219 | + 0 => array('STS_ID' => array('IN', EEM_Message::instance()->stati_indicating_to_send())), |
|
220 | 220 | 'order_by' => $this->_get_priority_orderby(), |
221 | 221 | 'limit' => $batch |
222 | 222 | ); |
223 | 223 | |
224 | - $messages_to_send = EEM_Message::instance()->get_all( $query_args ); |
|
224 | + $messages_to_send = EEM_Message::instance()->get_all($query_args); |
|
225 | 225 | |
226 | 226 | |
227 | 227 | //any to send? |
228 | - if ( ! $messages_to_send ) { |
|
229 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
228 | + if ( ! $messages_to_send) { |
|
229 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
230 | 230 | return false; |
231 | 231 | } |
232 | 232 | |
233 | 233 | //add to queue. |
234 | - foreach ( $messages_to_send as $message ) { |
|
235 | - if ( $message instanceof EE_Message ) { |
|
236 | - $this->add( $message ); |
|
234 | + foreach ($messages_to_send as $message) { |
|
235 | + if ($message instanceof EE_Message) { |
|
236 | + $this->add($message); |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $this->execute(); |
242 | 242 | |
243 | 243 | //release lock |
244 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
244 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
245 | 245 | return true; |
246 | 246 | } |
247 | 247 | |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @param string $type The type of queue being locked. |
255 | 255 | */ |
256 | - public function lock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
257 | - set_transient( $this->_get_lock_key( $type ), 1, $this->_get_lock_expiry( $type ) ); |
|
256 | + public function lock_queue($type = EE_Messages_Queue::action_generating) { |
|
257 | + set_transient($this->_get_lock_key($type), 1, $this->_get_lock_expiry($type)); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @param string $type The type of queue being unlocked. |
267 | 267 | */ |
268 | - public function unlock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
269 | - delete_transient( $this->_get_lock_key( $type ) ); |
|
268 | + public function unlock_queue($type = EE_Messages_Queue::action_generating) { |
|
269 | + delete_transient($this->_get_lock_key($type)); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | * @param string $type The type of lock. |
278 | 278 | * @return string |
279 | 279 | */ |
280 | - protected function _get_lock_key( $type = EE_Messages_Queue::action_generating ) { |
|
281 | - return '_ee_lock_' . $type; |
|
280 | + protected function _get_lock_key($type = EE_Messages_Queue::action_generating) { |
|
281 | + return '_ee_lock_'.$type; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | * @param string $type The type of lock |
290 | 290 | * @return int time to expiry in seconds. |
291 | 291 | */ |
292 | - protected function _get_lock_expiry( $type = EE_Messages_Queue::action_generating ) { |
|
293 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type ); |
|
292 | + protected function _get_lock_expiry($type = EE_Messages_Queue::action_generating) { |
|
293 | + return (int) apply_filters('FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * @return int |
309 | 309 | */ |
310 | 310 | protected function _get_rate_limit_expiry() { |
311 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS ); |
|
311 | + return (int) apply_filters('FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @return int |
320 | 320 | */ |
321 | 321 | protected function _default_rate_limit() { |
322 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue___rate_limit', 200 ); |
|
322 | + return (int) apply_filters('FHEE__EE_Messages_Queue___rate_limit', 200); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -345,11 +345,11 @@ discard block |
||
345 | 345 | * @param string $type The type of lock being checked for. |
346 | 346 | * @return bool |
347 | 347 | */ |
348 | - public function is_locked( $type = EE_Messages_Queue::action_generating ) { |
|
348 | + public function is_locked($type = EE_Messages_Queue::action_generating) { |
|
349 | 349 | return filter_var( |
350 | 350 | apply_filters( |
351 | 351 | 'FHEE__EE_Messages_Queue__is_locked', |
352 | - get_transient( $this->_get_lock_key( $type ) ), |
|
352 | + get_transient($this->_get_lock_key($type)), |
|
353 | 353 | $this |
354 | 354 | ), |
355 | 355 | FILTER_VALIDATE_BOOLEAN |
@@ -368,9 +368,9 @@ discard block |
||
368 | 368 | * @return int |
369 | 369 | */ |
370 | 370 | public function get_rate_limit() { |
371 | - if ( ! $rate_limit = get_transient( $this->_get_rate_limit_key() ) ) { |
|
371 | + if ( ! $rate_limit = get_transient($this->_get_rate_limit_key())) { |
|
372 | 372 | $rate_limit = $this->_default_rate_limit(); |
373 | - set_transient( $this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key() ); |
|
373 | + set_transient($this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key()); |
|
374 | 374 | } |
375 | 375 | return $rate_limit; |
376 | 376 | } |
@@ -382,12 +382,12 @@ discard block |
||
382 | 382 | * This updates existing rate limit with the new limit which is the old minus the batch. |
383 | 383 | * @param int $batch_completed This sets the new rate limit based on the given batch that was completed. |
384 | 384 | */ |
385 | - public function set_rate_limit( $batch_completed ) { |
|
385 | + public function set_rate_limit($batch_completed) { |
|
386 | 386 | //first get the most up to date rate limit (in case its expired and reset) |
387 | 387 | $rate_limit = $this->get_rate_limit(); |
388 | 388 | $new_limit = $rate_limit - $batch_completed; |
389 | 389 | //updating the transient option directly to avoid resetting the expiry. |
390 | - update_option( '_transient_' . $this->_get_rate_limit_key(), $new_limit ); |
|
390 | + update_option('_transient_'.$this->_get_rate_limit_key(), $new_limit); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | * @param string $task This indicates what type of request is going to be initiated. |
401 | 401 | * @param int $priority This indicates the priority that triggers initiating the request. |
402 | 402 | */ |
403 | - public function initiate_request_by_priority( $task = 'generate', $priority = EEM_Message::priority_high ) { |
|
403 | + public function initiate_request_by_priority($task = 'generate', $priority = EEM_Message::priority_high) { |
|
404 | 404 | //determine what status is matched with the priority as part of the trigger conditions. |
405 | 405 | $status = $task == 'generate' |
406 | 406 | ? EEM_Message::status_incomplete |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | // always make sure we save because either this will get executed immediately on a separate request |
409 | 409 | // or remains in the queue for the regularly scheduled queue batch. |
410 | 410 | $this->save(); |
411 | - if ( $this->_message_repository->count_by_priority_and_status( $priority, $status ) ) { |
|
412 | - EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( $task ); |
|
411 | + if ($this->_message_repository->count_by_priority_and_status($priority, $status)) { |
|
412 | + EE_Messages_Scheduler::initiate_scheduled_non_blocking_request($task); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
@@ -434,53 +434,53 @@ discard block |
||
434 | 434 | * Also, if the messenger is an request type messenger (or a preview), |
435 | 435 | * its entirely possible that the messenger will exit before |
436 | 436 | */ |
437 | - public function execute( $save = true, $sending_messenger = null, $by_priority = false ) { |
|
437 | + public function execute($save = true, $sending_messenger = null, $by_priority = false) { |
|
438 | 438 | $messages_sent = 0; |
439 | 439 | $this->_did_hook = array(); |
440 | 440 | $this->_message_repository->rewind(); |
441 | 441 | |
442 | - while ( $this->_message_repository->valid() ) { |
|
442 | + while ($this->_message_repository->valid()) { |
|
443 | 443 | $error_messages = array(); |
444 | 444 | /** @type EE_Message $message */ |
445 | 445 | $message = $this->_message_repository->current(); |
446 | 446 | //if the message in the queue has a sent status, then skip |
447 | - if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_sent() ) ) { |
|
447 | + if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_sent())) { |
|
448 | 448 | $this->_message_repository->next(); |
449 | 449 | continue; |
450 | 450 | } |
451 | 451 | //if $by_priority is set and does not match then continue; |
452 | - if ( $by_priority && $by_priority != $message->priority() ) { |
|
452 | + if ($by_priority && $by_priority != $message->priority()) { |
|
453 | 453 | $this->_message_repository->next(); |
454 | 454 | continue; |
455 | 455 | } |
456 | 456 | //error checking |
457 | - if ( ! $message->valid_messenger() ) { |
|
457 | + if ( ! $message->valid_messenger()) { |
|
458 | 458 | $error_messages[] = sprintf( |
459 | - __( 'The %s messenger is not active at time of sending.', 'event_espresso' ), |
|
459 | + __('The %s messenger is not active at time of sending.', 'event_espresso'), |
|
460 | 460 | $message->messenger() |
461 | 461 | ); |
462 | 462 | } |
463 | - if ( ! $message->valid_message_type() ) { |
|
463 | + if ( ! $message->valid_message_type()) { |
|
464 | 464 | $error_messages[] = sprintf( |
465 | - __( 'The %s message type is not active at the time of sending.', 'event_espresso' ), |
|
465 | + __('The %s message type is not active at the time of sending.', 'event_espresso'), |
|
466 | 466 | $message->message_type() |
467 | 467 | ); |
468 | 468 | } |
469 | 469 | // if there was supposed to be a sending messenger for this message, but it was invalid/inactive, |
470 | 470 | // then it will instead be an EE_Error object, so let's check for that |
471 | - if ( $sending_messenger instanceof EE_Error ) { |
|
471 | + if ($sending_messenger instanceof EE_Error) { |
|
472 | 472 | $error_messages[] = $sending_messenger->getMessage(); |
473 | 473 | } |
474 | 474 | // if there are no errors, then let's process the message |
475 | - if ( empty( $error_messages ) && $this->_process_message( $message, $sending_messenger ) ) { |
|
475 | + if (empty($error_messages) && $this->_process_message($message, $sending_messenger)) { |
|
476 | 476 | $messages_sent++; |
477 | 477 | } |
478 | - $this->_set_error_message( $message, $error_messages ); |
|
478 | + $this->_set_error_message($message, $error_messages); |
|
479 | 479 | //add modified time |
480 | - $message->set_modified( time() ); |
|
480 | + $message->set_modified(time()); |
|
481 | 481 | $this->_message_repository->next(); |
482 | 482 | } |
483 | - if ( $save ) { |
|
483 | + if ($save) { |
|
484 | 484 | $this->save(); |
485 | 485 | } |
486 | 486 | return $messages_sent; |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | * @param mixed $sending_messenger (optional) |
496 | 496 | * @return bool |
497 | 497 | */ |
498 | - protected function _process_message( EE_Message $message, $sending_messenger = null ) { |
|
498 | + protected function _process_message(EE_Message $message, $sending_messenger = null) { |
|
499 | 499 | // these *should* have been validated in the execute() method above |
500 | 500 | $messenger = $message->messenger_object(); |
501 | 501 | $message_type = $message->message_type_object(); |
@@ -505,20 +505,20 @@ discard block |
||
505 | 505 | && $messenger instanceof EE_messenger |
506 | 506 | && $sending_messenger->name != $messenger->name |
507 | 507 | ) { |
508 | - $messenger->do_secondary_messenger_hooks( $sending_messenger->name ); |
|
508 | + $messenger->do_secondary_messenger_hooks($sending_messenger->name); |
|
509 | 509 | $messenger = $sending_messenger; |
510 | 510 | } |
511 | 511 | // send using messenger, but double check objects |
512 | - if ( $messenger instanceof EE_messenger && $message_type instanceof EE_message_type ) { |
|
512 | + if ($messenger instanceof EE_messenger && $message_type instanceof EE_message_type) { |
|
513 | 513 | //set hook for message type (but only if not using another messenger to send). |
514 | - if ( ! isset( $this->_did_hook[ $message_type->name ] ) ) { |
|
515 | - $message_type->do_messenger_hooks( $messenger ); |
|
516 | - $this->_did_hook[ $message_type->name ] = 1; |
|
514 | + if ( ! isset($this->_did_hook[$message_type->name])) { |
|
515 | + $message_type->do_messenger_hooks($messenger); |
|
516 | + $this->_did_hook[$message_type->name] = 1; |
|
517 | 517 | } |
518 | 518 | //if preview then use preview method |
519 | 519 | return $this->_message_repository->is_preview() |
520 | - ? $this->_do_preview( $message, $messenger, $message_type, $this->_message_repository->is_test_send() ) |
|
521 | - : $this->_do_send( $message, $messenger, $message_type ); |
|
520 | + ? $this->_do_preview($message, $messenger, $message_type, $this->_message_repository->is_test_send()) |
|
521 | + : $this->_do_send($message, $messenger, $message_type); |
|
522 | 522 | } |
523 | 523 | return false; |
524 | 524 | } |
@@ -536,12 +536,12 @@ discard block |
||
536 | 536 | * @param array $status Stati to check for in queue |
537 | 537 | * @return int Count of EE_Message's matching the given status. |
538 | 538 | */ |
539 | - public function count_STS_in_queue( $status ) { |
|
539 | + public function count_STS_in_queue($status) { |
|
540 | 540 | $count = 0; |
541 | - $status = is_array( $status ) ? $status : array( $status ); |
|
541 | + $status = is_array($status) ? $status : array($status); |
|
542 | 542 | $this->_message_repository->rewind(); |
543 | - foreach( $this->_message_repository as $message ) { |
|
544 | - if ( in_array( $message->STS_ID(), $status ) ) { |
|
543 | + foreach ($this->_message_repository as $message) { |
|
544 | + if (in_array($message->STS_ID(), $status)) { |
|
545 | 545 | $count++; |
546 | 546 | } |
547 | 547 | } |
@@ -558,15 +558,15 @@ discard block |
||
558 | 558 | * @param $test_send |
559 | 559 | * @return bool true means all went well, false means, not so much. |
560 | 560 | */ |
561 | - protected function _do_preview( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send ) { |
|
562 | - if ( $preview = $messenger->get_preview( $message, $message_type, $test_send ) ) { |
|
563 | - if ( ! $test_send ) { |
|
564 | - $message->set_content( $preview ); |
|
561 | + protected function _do_preview(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send) { |
|
562 | + if ($preview = $messenger->get_preview($message, $message_type, $test_send)) { |
|
563 | + if ( ! $test_send) { |
|
564 | + $message->set_content($preview); |
|
565 | 565 | } |
566 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
566 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
567 | 567 | return true; |
568 | 568 | } else { |
569 | - $message->set_STS_ID( EEM_Message::status_failed ); |
|
569 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
570 | 570 | return false; |
571 | 571 | } |
572 | 572 | } |
@@ -582,12 +582,12 @@ discard block |
||
582 | 582 | * @param EE_message_type $message_type |
583 | 583 | * @return bool true means all went well, false means, not so much. |
584 | 584 | */ |
585 | - protected function _do_send( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type ) { |
|
586 | - if ( $messenger->send_message( $message, $message_type ) ) { |
|
587 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
585 | + protected function _do_send(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type) { |
|
586 | + if ($messenger->send_message($message, $message_type)) { |
|
587 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
588 | 588 | return true; |
589 | 589 | } else { |
590 | - $message->set_STS_ID( EEM_Message::status_retry ); |
|
590 | + $message->set_STS_ID(EEM_Message::status_retry); |
|
591 | 591 | return false; |
592 | 592 | } |
593 | 593 | } |
@@ -601,21 +601,21 @@ discard block |
||
601 | 601 | * @param EE_Message $message |
602 | 602 | * @param array $error_messages the response from the messenger. |
603 | 603 | */ |
604 | - protected function _set_error_message( EE_Message $message, $error_messages ) { |
|
604 | + protected function _set_error_message(EE_Message $message, $error_messages) { |
|
605 | 605 | $error_messages = (array) $error_messages; |
606 | - if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending() ) ) { |
|
606 | + if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending())) { |
|
607 | 607 | $notices = EE_Error::has_notices(); |
608 | - $error_messages[] = __( 'Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso' ); |
|
609 | - if ( $notices === 1 ) { |
|
608 | + $error_messages[] = __('Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso'); |
|
609 | + if ($notices === 1) { |
|
610 | 610 | $notices = EE_Error::get_vanilla_notices(); |
611 | - $notices['errors'] = isset( $notices['errors'] ) ? $notices['errors'] : array(); |
|
612 | - $error_messages[] = implode( "\n", $notices['errors'] ); |
|
611 | + $notices['errors'] = isset($notices['errors']) ? $notices['errors'] : array(); |
|
612 | + $error_messages[] = implode("\n", $notices['errors']); |
|
613 | 613 | } |
614 | 614 | } |
615 | - if ( count( $error_messages ) > 0 ) { |
|
616 | - $msg = __( 'Message was not executed successfully.', 'event_espresso' ); |
|
617 | - $msg = $msg . "\n" . implode( "\n", $error_messages ); |
|
618 | - $message->set_error_message( $msg ); |
|
615 | + if (count($error_messages) > 0) { |
|
616 | + $msg = __('Message was not executed successfully.', 'event_espresso'); |
|
617 | + $msg = $msg."\n".implode("\n", $error_messages); |
|
618 | + $message->set_error_message($msg); |
|
619 | 619 | } |
620 | 620 | } |
621 | 621 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * @return void |
290 | 290 | */ |
291 | 291 | public function enqueue_scripts_styles() { |
292 | - do_action( 'AHEE__EE_messenger__enqueue_scripts_styles'); |
|
292 | + do_action('AHEE__EE_messenger__enqueue_scripts_styles'); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | |
360 | 360 | $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.'); |
361 | 361 | |
362 | - $this->_supports_labels = apply_filters( 'FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this ); |
|
362 | + $this->_supports_labels = apply_filters('FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | |
@@ -374,10 +374,10 @@ discard block |
||
374 | 374 | * @return stdClass |
375 | 375 | */ |
376 | 376 | public function get_supports_labels() { |
377 | - if ( empty( $this->_supports_labels->template_pack ) || empty( $this->_supports_labels->template_variation) ) { |
|
377 | + if (empty($this->_supports_labels->template_pack) || empty($this->_supports_labels->template_variation)) { |
|
378 | 378 | $this->_set_supports_labels_defaults(); |
379 | 379 | } |
380 | - return apply_filters( 'FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this ); |
|
380 | + return apply_filters('FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | |
@@ -397,10 +397,10 @@ discard block |
||
397 | 397 | * |
398 | 398 | * @return string path or url for the requested variation. |
399 | 399 | */ |
400 | - public function get_variation( EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE ) { |
|
400 | + public function get_variation(EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE) { |
|
401 | 401 | $this->_tmp_pack = $pack; |
402 | - $variation_path = apply_filters( 'EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters ); |
|
403 | - $variation_path = empty( $variation_path ) ? $this->_tmp_pack->get_variation( $this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters ) : $variation_path; |
|
402 | + $variation_path = apply_filters('EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters); |
|
403 | + $variation_path = empty($variation_path) ? $this->_tmp_pack->get_variation($this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters) : $variation_path; |
|
404 | 404 | return $variation_path; |
405 | 405 | |
406 | 406 | } |
@@ -418,13 +418,13 @@ discard block |
||
418 | 418 | * @return array |
419 | 419 | */ |
420 | 420 | public function get_default_message_types() { |
421 | - $class = get_class( $this ); |
|
421 | + $class = get_class($this); |
|
422 | 422 | |
423 | 423 | //messenger specific filter |
424 | - $default_types = apply_filters( 'FHEE__' . $class . '__get_default_message_types__default_types', $this->_default_message_types, $this ); |
|
424 | + $default_types = apply_filters('FHEE__'.$class.'__get_default_message_types__default_types', $this->_default_message_types, $this); |
|
425 | 425 | |
426 | 426 | //all messengers filter |
427 | - $default_types = apply_filters( 'FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this ); |
|
427 | + $default_types = apply_filters('FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this); |
|
428 | 428 | return $default_types; |
429 | 429 | } |
430 | 430 | |
@@ -439,14 +439,14 @@ discard block |
||
439 | 439 | * @return array |
440 | 440 | */ |
441 | 441 | public function get_valid_message_types() { |
442 | - $class = get_class( $this ); |
|
442 | + $class = get_class($this); |
|
443 | 443 | |
444 | 444 | //messenger specific filter |
445 | 445 | //messenger specific filter |
446 | - $valid_types = apply_filters( 'FHEE__' . $class . '__get_valid_message_types__valid_types', $this->_valid_message_types, $this ); |
|
446 | + $valid_types = apply_filters('FHEE__'.$class.'__get_valid_message_types__valid_types', $this->_valid_message_types, $this); |
|
447 | 447 | |
448 | 448 | //all messengers filter |
449 | - $valid_types = apply_filters( 'FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this ); |
|
449 | + $valid_types = apply_filters('FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this); |
|
450 | 450 | return $valid_types; |
451 | 451 | } |
452 | 452 | |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @access public |
461 | 461 | * @param array $new_config Whatever is put in here will reset the _validator_config property |
462 | 462 | */ |
463 | - public function set_validator_config( $new_config ) { |
|
463 | + public function set_validator_config($new_config) { |
|
464 | 464 | $this->_validator_config = $new_config; |
465 | 465 | } |
466 | 466 | |
@@ -476,8 +476,8 @@ discard block |
||
476 | 476 | public function get_validator_config() { |
477 | 477 | $class = get_class($this); |
478 | 478 | |
479 | - $config = apply_filters( 'FHEE__' . $class . '__get_validator_config', $this->_validator_config, $this ); |
|
480 | - $config = apply_filters( 'FHEE__EE_messenger__get_validator_config', $config, $this ); |
|
479 | + $config = apply_filters('FHEE__'.$class.'__get_validator_config', $this->_validator_config, $this); |
|
480 | + $config = apply_filters('FHEE__EE_messenger__get_validator_config', $config, $this); |
|
481 | 481 | return $config; |
482 | 482 | } |
483 | 483 | |
@@ -494,8 +494,8 @@ discard block |
||
494 | 494 | * @access public |
495 | 495 | * @return string content for page |
496 | 496 | */ |
497 | - public function get_messenger_admin_page_content( $page, $action = null, $extra = array(), $message_types = array() ) { |
|
498 | - return $this->_get_admin_page_content( $page, $action, $extra, $message_types ); |
|
497 | + public function get_messenger_admin_page_content($page, $action = null, $extra = array(), $message_types = array()) { |
|
498 | + return $this->_get_admin_page_content($page, $action, $extra, $message_types); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | |
@@ -505,20 +505,20 @@ discard block |
||
505 | 505 | * @param array $extra |
506 | 506 | * @return mixed|string |
507 | 507 | */ |
508 | - protected function _get_admin_content_events_edit( $message_types, $extra ) { |
|
508 | + protected function _get_admin_content_events_edit($message_types, $extra) { |
|
509 | 509 | //defaults |
510 | 510 | $template_args = array(); |
511 | 511 | $selector_rows = ''; |
512 | 512 | |
513 | 513 | //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. |
514 | - $event_id = isset( $extra['event'] ) ? $extra['event'] : NULL; |
|
514 | + $event_id = isset($extra['event']) ? $extra['event'] : NULL; |
|
515 | 515 | |
516 | - $template_wrapper_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_wrapper.template.php'; |
|
517 | - $template_row_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_row.template.php'; |
|
516 | + $template_wrapper_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_wrapper.template.php'; |
|
517 | + $template_row_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_row.template.php'; |
|
518 | 518 | |
519 | 519 | //array of template objects for global and custom (non-trashed) (but remember just for this messenger!) |
520 | 520 | $global_templates = EEM_Message_Template_Group::instance()->get_all( |
521 | - array( array( 'MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true ) ) |
|
521 | + array(array('MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true)) |
|
522 | 522 | ); |
523 | 523 | $templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event( |
524 | 524 | $event_id, |
@@ -527,55 +527,55 @@ discard block |
||
527 | 527 | 'MTP_is_active' => true |
528 | 528 | ) |
529 | 529 | ); |
530 | - $templates_for_event = !empty( $templates_for_event ) ? $templates_for_event : array(); |
|
530 | + $templates_for_event = ! empty($templates_for_event) ? $templates_for_event : array(); |
|
531 | 531 | |
532 | 532 | //so we need to setup the rows for the selectors and we use the global mtpgs (cause those will the active message template groups) |
533 | - foreach ( $global_templates as $mtpgID => $mtpg ) { |
|
534 | - if ( $mtpg instanceof EE_Message_Template_Group ) { |
|
533 | + foreach ($global_templates as $mtpgID => $mtpg) { |
|
534 | + if ($mtpg instanceof EE_Message_Template_Group) { |
|
535 | 535 | //verify this message type is supposed to show on this page |
536 | 536 | $mtp_obj = $mtpg->message_type_obj(); |
537 | - if ( ! $mtp_obj instanceof EE_message_type ) { |
|
537 | + if ( ! $mtp_obj instanceof EE_message_type) { |
|
538 | 538 | continue; |
539 | 539 | } |
540 | - $mtp_obj->admin_registered_pages = (array)$mtp_obj->admin_registered_pages; |
|
541 | - if ( ! in_array( 'events_edit', $mtp_obj->admin_registered_pages ) ) { |
|
540 | + $mtp_obj->admin_registered_pages = (array) $mtp_obj->admin_registered_pages; |
|
541 | + if ( ! in_array('events_edit', $mtp_obj->admin_registered_pages)) { |
|
542 | 542 | continue; |
543 | 543 | } |
544 | 544 | $select_values = array(); |
545 | - $select_values[ $mtpgID ] = __( 'Global', 'event_espresso' ); |
|
546 | - $default_value = array_key_exists( $mtpgID, $templates_for_event ) && ! $mtpg->get( 'MTP_is_override' ) ? $mtpgID : null; |
|
545 | + $select_values[$mtpgID] = __('Global', 'event_espresso'); |
|
546 | + $default_value = array_key_exists($mtpgID, $templates_for_event) && ! $mtpg->get('MTP_is_override') ? $mtpgID : null; |
|
547 | 547 | //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. |
548 | - if ( ! $mtpg->get( 'MTP_is_override' ) ) { |
|
548 | + if ( ! $mtpg->get('MTP_is_override')) { |
|
549 | 549 | //any custom templates for this message type? |
550 | - $custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt( $this->name, $mtpg->message_type() ); |
|
551 | - foreach ( $custom_templates as $cmtpgID => $cmtpg ) { |
|
552 | - $select_values[ $cmtpgID ] = $cmtpg->name(); |
|
553 | - $default_value = array_key_exists( $cmtpgID, $templates_for_event ) ? $cmtpgID : $default_value; |
|
550 | + $custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt($this->name, $mtpg->message_type()); |
|
551 | + foreach ($custom_templates as $cmtpgID => $cmtpg) { |
|
552 | + $select_values[$cmtpgID] = $cmtpg->name(); |
|
553 | + $default_value = array_key_exists($cmtpgID, $templates_for_event) ? $cmtpgID : $default_value; |
|
554 | 554 | } |
555 | 555 | } |
556 | 556 | //if there is no $default_value then we set it as the global |
557 | - $default_value = empty( $default_value ) ? $mtpgID : $default_value; |
|
558 | - $edit_url = EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value ), admin_url( 'admin.php' ) ); |
|
559 | - $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' ) ); |
|
560 | - $st_args[ 'mt_name' ] = ucwords( $mtp_obj->label[ 'singular' ] ); |
|
561 | - $st_args[ 'mt_slug' ] = $mtpg->message_type(); |
|
562 | - $st_args[ 'messenger_slug' ] = $this->name; |
|
563 | - $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' ); |
|
557 | + $default_value = empty($default_value) ? $mtpgID : $default_value; |
|
558 | + $edit_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value), admin_url('admin.php')); |
|
559 | + $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')); |
|
560 | + $st_args['mt_name'] = ucwords($mtp_obj->label['singular']); |
|
561 | + $st_args['mt_slug'] = $mtpg->message_type(); |
|
562 | + $st_args['messenger_slug'] = $this->name; |
|
563 | + $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'); |
|
564 | 564 | //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). |
565 | - $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>'; |
|
566 | - $st_args[ 'create_button' ] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'espresso_messages_add_new_message_template' ) ? $st_args[ 'create_button' ] : ''; |
|
567 | - $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>' : ''; |
|
568 | - $selector_rows .= EEH_Template::display_template( $template_row_path, $st_args, true ); |
|
565 | + $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>'; |
|
566 | + $st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messages_add_new_message_template') ? $st_args['create_button'] : ''; |
|
567 | + $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>' : ''; |
|
568 | + $selector_rows .= EEH_Template::display_template($template_row_path, $st_args, true); |
|
569 | 569 | } |
570 | 570 | } |
571 | 571 | |
572 | 572 | //if no selectors present then get out. |
573 | - if ( empty( $selector_rows ) ) { |
|
573 | + if (empty($selector_rows)) { |
|
574 | 574 | return ''; |
575 | 575 | } |
576 | 576 | |
577 | 577 | $template_args['selector_rows'] = $selector_rows; |
578 | - return EEH_Template::display_template( $template_wrapper_path, $template_args, TRUE ); |
|
578 | + return EEH_Template::display_template($template_wrapper_path, $template_args, TRUE); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | |
@@ -590,8 +590,8 @@ discard block |
||
590 | 590 | * @return array $this->_template_fields |
591 | 591 | */ |
592 | 592 | public function get_template_fields() { |
593 | - $template_fields = apply_filters( 'FHEE__' . get_class($this) . '__get_template_fields', $this->_template_fields, $this ); |
|
594 | - $template_fields = apply_filters( 'FHEE__EE_messenger__get_template_fields', $template_fields, $this ); |
|
593 | + $template_fields = apply_filters('FHEE__'.get_class($this).'__get_template_fields', $this->_template_fields, $this); |
|
594 | + $template_fields = apply_filters('FHEE__EE_messenger__get_template_fields', $template_fields, $this); |
|
595 | 595 | return $template_fields; |
596 | 596 | } |
597 | 597 | |
@@ -605,9 +605,9 @@ discard block |
||
605 | 605 | * @param mixed $value |
606 | 606 | */ |
607 | 607 | protected function _set_template_value($item, $value) { |
608 | - if ( array_key_exists($item, $this->_template_fields) ) { |
|
609 | - $prop = '_' . $item; |
|
610 | - $this->{$prop}= $value; |
|
608 | + if (array_key_exists($item, $this->_template_fields)) { |
|
609 | + $prop = '_'.$item; |
|
610 | + $this->{$prop} = $value; |
|
611 | 611 | } |
612 | 612 | } |
613 | 613 | |
@@ -618,8 +618,8 @@ discard block |
||
618 | 618 | * @return bool Very important that all messengers return bool for successful send or not. Error messages can be |
619 | 619 | * added to EE_Error. |
620 | 620 | */ |
621 | - public function send_message( $message, EE_message_type $message_type ) { |
|
622 | - $this->_validate_and_setup( $message ); |
|
621 | + public function send_message($message, EE_message_type $message_type) { |
|
622 | + $this->_validate_and_setup($message); |
|
623 | 623 | $this->_incoming_message_type = $message_type; |
624 | 624 | return $this->_send_message(); |
625 | 625 | } |
@@ -633,28 +633,28 @@ discard block |
||
633 | 633 | * @param bool $send true we will actually use the _send method (for test sends). FALSE we just return preview |
634 | 634 | * @return string return the message html content |
635 | 635 | */ |
636 | - public function get_preview( EE_Message $message, EE_message_type $message_type, $send = false ) { |
|
637 | - $this->_validate_and_setup( $message ); |
|
636 | + public function get_preview(EE_Message $message, EE_message_type $message_type, $send = false) { |
|
637 | + $this->_validate_and_setup($message); |
|
638 | 638 | |
639 | 639 | $this->_incoming_message_type = $message_type; |
640 | 640 | |
641 | - if ( $send ) { |
|
641 | + if ($send) { |
|
642 | 642 | //are we overriding any existing template fields? |
643 | 643 | $settings = $this->get_existing_test_settings(); |
644 | - if ( ! empty( $settings ) ) { |
|
645 | - foreach ( $settings as $field => $value ) { |
|
646 | - $this->_set_template_value( $field, $value ); |
|
644 | + if ( ! empty($settings)) { |
|
645 | + foreach ($settings as $field => $value) { |
|
646 | + $this->_set_template_value($field, $value); |
|
647 | 647 | } |
648 | 648 | } |
649 | 649 | } |
650 | 650 | |
651 | 651 | //enqueue preview js so that any links/buttons on the page are disabled. |
652 | - if ( ! $send ) { |
|
652 | + if ( ! $send) { |
|
653 | 653 | // the below may seem like duplication. However, typically if a messenger enqueues scripts/styles, |
654 | 654 | // it deregisters all existing wp scripts and styles first. So the second hook ensures our previewer still gets setup. |
655 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_preview_script' ), 10 ); |
|
656 | - add_action( 'wp_enqueue_scripts', array( $this, 'add_preview_script' ), 10 ); |
|
657 | - add_action( 'AHEE__EE_messenger__enqueue_scripts_styles', array( $this, 'add_preview_script' ), 10 ); |
|
655 | + add_action('admin_enqueue_scripts', array($this, 'add_preview_script'), 10); |
|
656 | + add_action('wp_enqueue_scripts', array($this, 'add_preview_script'), 10); |
|
657 | + add_action('AHEE__EE_messenger__enqueue_scripts_styles', array($this, 'add_preview_script'), 10); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | return $send ? $this->_send_message() : $this->_preview(); |
@@ -672,10 +672,10 @@ discard block |
||
672 | 672 | */ |
673 | 673 | public function add_preview_script() { |
674 | 674 | //error message |
675 | - 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' ); |
|
676 | - wp_register_script( 'ee-messages-preview-js', EE_LIBRARIES_URL . 'messages/messenger/assets/js/ee-messages-preview.js', array( 'jquery' ), EVENT_ESPRESSO_VERSION, true ); |
|
677 | - wp_localize_script( 'ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings ); |
|
678 | - wp_enqueue_script( 'ee-messages-preview-js' ); |
|
675 | + 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'); |
|
676 | + wp_register_script('ee-messages-preview-js', EE_LIBRARIES_URL.'messages/messenger/assets/js/ee-messages-preview.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
677 | + wp_localize_script('ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings); |
|
678 | + wp_enqueue_script('ee-messages-preview-js'); |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | |
@@ -686,13 +686,13 @@ discard block |
||
686 | 686 | * @param EE_Message $message |
687 | 687 | * @throws EE_Error |
688 | 688 | */ |
689 | - protected function _validate_and_setup( EE_Message $message ) { |
|
689 | + protected function _validate_and_setup(EE_Message $message) { |
|
690 | 690 | $template_pack = $message->get_template_pack(); |
691 | 691 | $variation = $message->get_template_pack_variation(); |
692 | 692 | |
693 | 693 | //verify we have the required template pack value on the $message object. |
694 | - if ( ! $template_pack instanceof EE_Messages_Template_Pack ) { |
|
695 | - throw new EE_Error( __('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso' ) ); |
|
694 | + if ( ! $template_pack instanceof EE_Messages_Template_Pack) { |
|
695 | + throw new EE_Error(__('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso')); |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | $this->_tmp_pack = $template_pack; |
@@ -701,11 +701,11 @@ discard block |
||
701 | 701 | |
702 | 702 | $template_fields = $this->get_template_fields(); |
703 | 703 | |
704 | - foreach ( $template_fields as $template => $value ) { |
|
705 | - if ( $template !== 'extra' ) { |
|
706 | - $column_value = $message->get_field_or_extra_meta( 'MSG_' . $template ); |
|
704 | + foreach ($template_fields as $template => $value) { |
|
705 | + if ($template !== 'extra') { |
|
706 | + $column_value = $message->get_field_or_extra_meta('MSG_'.$template); |
|
707 | 707 | $message_template_value = $column_value ? $column_value : null; |
708 | - $this->_set_template_value( $template, $message_template_value ); |
|
708 | + $this->_set_template_value($template, $message_template_value); |
|
709 | 709 | } |
710 | 710 | } |
711 | 711 | } |
@@ -720,19 +720,19 @@ discard block |
||
720 | 720 | * @return string |
721 | 721 | * @throws \EE_Error |
722 | 722 | */ |
723 | - protected function _get_main_template( $preview = FALSE ) { |
|
723 | + protected function _get_main_template($preview = FALSE) { |
|
724 | 724 | $type = $preview ? 'preview' : 'main'; |
725 | 725 | |
726 | - $wrapper_template = $this->_tmp_pack->get_wrapper( $this->name, $type ); |
|
726 | + $wrapper_template = $this->_tmp_pack->get_wrapper($this->name, $type); |
|
727 | 727 | |
728 | 728 | //check file exists and is readable |
729 | - if ( !is_readable( $wrapper_template ) ) |
|
730 | - 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 ) ); |
|
729 | + if ( ! is_readable($wrapper_template)) |
|
730 | + 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)); |
|
731 | 731 | |
732 | 732 | //add message type to template args |
733 | 733 | $this->_template_args['message_type'] = $this->_incoming_message_type; |
734 | 734 | |
735 | - return EEH_Template::display_template( $wrapper_template, $this->_template_args, TRUE ); |
|
735 | + return EEH_Template::display_template($wrapper_template, $this->_template_args, TRUE); |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | |
@@ -768,9 +768,9 @@ discard block |
||
768 | 768 | */ |
769 | 769 | public function get_existing_test_settings() { |
770 | 770 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
771 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
771 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
772 | 772 | $settings = $Message_Resource_Manager->get_active_messengers_option(); |
773 | - return isset( $settings[ $this->name ]['test_settings'] ) ? $settings[ $this->name ]['test_settings'] : array(); |
|
773 | + return isset($settings[$this->name]['test_settings']) ? $settings[$this->name]['test_settings'] : array(); |
|
774 | 774 | } |
775 | 775 | |
776 | 776 | |
@@ -782,12 +782,12 @@ discard block |
||
782 | 782 | * @param $settings |
783 | 783 | * @return bool success/fail |
784 | 784 | */ |
785 | - public function set_existing_test_settings( $settings ) { |
|
785 | + public function set_existing_test_settings($settings) { |
|
786 | 786 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
787 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
787 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
788 | 788 | $existing = $Message_Resource_Manager->get_active_messengers_option(); |
789 | - $existing[ $this->name ]['test_settings'] = $settings; |
|
790 | - return $Message_Resource_Manager->update_active_messengers_option( $existing ); |
|
789 | + $existing[$this->name]['test_settings'] = $settings; |
|
790 | + return $Message_Resource_Manager->update_active_messengers_option($existing); |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | |
@@ -800,21 +800,21 @@ discard block |
||
800 | 800 | * @param string $field The field to retrieve the label for |
801 | 801 | * @return string The label |
802 | 802 | */ |
803 | - public function get_field_label( $field ) { |
|
803 | + public function get_field_label($field) { |
|
804 | 804 | //first let's see if the field requests is in the top level array. |
805 | - if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) ) |
|
805 | + if (isset($this->_template_fields[$field]) && ! empty($this->_template_fields[$field]['label'])) |
|
806 | 806 | return $this->_template[$field]['label']; |
807 | 807 | |
808 | 808 | //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. |
809 | - if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] ) ) |
|
809 | + if (isset($this->_template_fields['extra']) && ! empty($this->_template_fields['extra'][$field]) && ! empty($this->_template_fields['extra'][$field]['main']['label'])) |
|
810 | 810 | return $this->_template_fields['extra'][$field]['main']['label']; |
811 | 811 | |
812 | 812 | //now it's possible this field may just be existing in any of the extra array items. |
813 | - if ( !empty( $this->_template_fields['extra'] ) && is_array( $this->_template_fields['extra'] ) ) { |
|
814 | - foreach ( $this->_template_fields['extra'] as $main_field => $subfields ) { |
|
815 | - if ( !is_array( $subfields ) ) |
|
813 | + if ( ! empty($this->_template_fields['extra']) && is_array($this->_template_fields['extra'])) { |
|
814 | + foreach ($this->_template_fields['extra'] as $main_field => $subfields) { |
|
815 | + if ( ! is_array($subfields)) |
|
816 | 816 | continue; |
817 | - if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) ) |
|
817 | + if (isset($subfields[$field]) && ! empty($subfields[$field]['label'])) |
|
818 | 818 | return $subfields[$field]['label']; |
819 | 819 | } |
820 | 820 | } |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | * |
836 | 836 | * @return void |
837 | 837 | */ |
838 | - public function do_secondary_messenger_hooks( $sending_messenger_name ) { |
|
838 | + public function do_secondary_messenger_hooks($sending_messenger_name) { |
|
839 | 839 | return; |
840 | 840 | } |
841 | 841 |
@@ -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 | /** |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | * @param $context |
120 | 120 | * @throws \EE_Error |
121 | 121 | */ |
122 | - public function __construct( $fields, $context ) { |
|
122 | + public function __construct($fields, $context) { |
|
123 | 123 | //check that _m_name and _mt_name have been set by child class otherwise we get out. |
124 | - if ( empty($this->_m_name ) || empty( $this->_mt_name) ) |
|
124 | + if (empty($this->_m_name) || empty($this->_mt_name)) |
|
125 | 125 | throw new EE_Error( |
126 | 126 | __( |
127 | 127 | 'EE_Messages_Validator child classes MUST set the $_m_name and $_mt_name property. Check that the child class is doing this', |
@@ -167,14 +167,14 @@ discard block |
||
167 | 167 | */ |
168 | 168 | private function _load_objects() { |
169 | 169 | //load messenger |
170 | - $messenger = ucwords( str_replace( '_', ' ', $this->_m_name ) ); |
|
171 | - $messenger = str_replace( ' ', '_', $messenger ); |
|
172 | - $messenger = 'EE_' . $messenger . '_messenger'; |
|
170 | + $messenger = ucwords(str_replace('_', ' ', $this->_m_name)); |
|
171 | + $messenger = str_replace(' ', '_', $messenger); |
|
172 | + $messenger = 'EE_'.$messenger.'_messenger'; |
|
173 | 173 | |
174 | - if ( ! class_exists( $messenger ) ) { |
|
174 | + if ( ! class_exists($messenger)) { |
|
175 | 175 | throw new EE_Error( |
176 | 176 | sprintf( |
177 | - __( 'There is no messenger class for the given string (%s)', 'event_espresso' ), |
|
177 | + __('There is no messenger class for the given string (%s)', 'event_espresso'), |
|
178 | 178 | $this->_m_name |
179 | 179 | ) |
180 | 180 | ); |
@@ -183,14 +183,14 @@ discard block |
||
183 | 183 | $this->_messenger = new $messenger(); |
184 | 184 | |
185 | 185 | //load message type |
186 | - $message_type = ucwords( str_replace( '_', ' ', $this->_mt_name ) ); |
|
187 | - $message_type = str_replace( ' ', '_', $message_type ); |
|
188 | - $message_type = 'EE_' . $message_type . '_message_type'; |
|
186 | + $message_type = ucwords(str_replace('_', ' ', $this->_mt_name)); |
|
187 | + $message_type = str_replace(' ', '_', $message_type); |
|
188 | + $message_type = 'EE_'.$message_type.'_message_type'; |
|
189 | 189 | |
190 | - if ( !class_exists( $message_type ) ) { |
|
190 | + if ( ! class_exists($message_type)) { |
|
191 | 191 | throw new EE_Error( |
192 | 192 | sprintf( |
193 | - __( 'There is no message type class for the given string (%s)', 'event_espresso' ), |
|
193 | + __('There is no message type class for the given string (%s)', 'event_espresso'), |
|
194 | 194 | $this->_mt_name |
195 | 195 | ) |
196 | 196 | ); |
@@ -227,25 +227,25 @@ discard block |
||
227 | 227 | $shortcode_groups = $mt_codes; |
228 | 228 | $groups_per_field = array(); |
229 | 229 | |
230 | - foreach ( $msgr_validator as $field => $config ) { |
|
231 | - if ( empty($config) || !isset($config['shortcodes']) ) |
|
232 | - continue; //Nothing to see here. |
|
233 | - $groups_per_field[$field] = array_intersect( $config['shortcodes'], $mt_codes ); |
|
234 | - $shortcode_groups = array_merge( $config[ 'shortcodes'], $shortcode_groups ); |
|
230 | + foreach ($msgr_validator as $field => $config) { |
|
231 | + if (empty($config) || ! isset($config['shortcodes'])) |
|
232 | + continue; //Nothing to see here. |
|
233 | + $groups_per_field[$field] = array_intersect($config['shortcodes'], $mt_codes); |
|
234 | + $shortcode_groups = array_merge($config['shortcodes'], $shortcode_groups); |
|
235 | 235 | } |
236 | 236 | |
237 | - $shortcode_groups = array_unique( $shortcode_groups); |
|
237 | + $shortcode_groups = array_unique($shortcode_groups); |
|
238 | 238 | |
239 | 239 | // okay now we've got our groups. |
240 | 240 | // Let's get the codes from the objects into an array indexed by group for easy retrieval later. |
241 | 241 | $codes_from_objs = array(); |
242 | 242 | |
243 | - foreach ( $shortcode_groups as $group ) { |
|
244 | - $ref = ucwords( str_replace('_', ' ', $group ) ); |
|
245 | - $ref = str_replace( ' ', '_', $ref ); |
|
246 | - $classname = 'EE_' . $ref . '_Shortcodes'; |
|
247 | - if ( class_exists( $classname ) ) { |
|
248 | - $a = new ReflectionClass( $classname ); |
|
243 | + foreach ($shortcode_groups as $group) { |
|
244 | + $ref = ucwords(str_replace('_', ' ', $group)); |
|
245 | + $ref = str_replace(' ', '_', $ref); |
|
246 | + $classname = 'EE_'.$ref.'_Shortcodes'; |
|
247 | + if (class_exists($classname)) { |
|
248 | + $a = new ReflectionClass($classname); |
|
249 | 249 | $obj = $a->newInstance(); |
250 | 250 | $codes_from_objs[$group] = $obj->get_shortcodes(); |
251 | 251 | } |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | |
255 | 255 | //let's just replace the $mt shortcode group indexes with the actual shortcodes (unique) |
256 | 256 | $final_mt_codes = array(); |
257 | - foreach ( $mt_codes as $group ) { |
|
258 | - $final_mt_codes = array_merge( $final_mt_codes, $codes_from_objs[$group] ); |
|
257 | + foreach ($mt_codes as $group) { |
|
258 | + $final_mt_codes = array_merge($final_mt_codes, $codes_from_objs[$group]); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | $mt_codes = $final_mt_codes; |
@@ -263,60 +263,60 @@ discard block |
||
263 | 263 | |
264 | 264 | // k now in this next loop we're going to loop through $msgr_validator again |
265 | 265 | // and setup the _validators property from the data we've setup so far. |
266 | - foreach ( $msgr_validator as $field => $config ) { |
|
266 | + foreach ($msgr_validator as $field => $config) { |
|
267 | 267 | //if required shortcode is not in our list of codes for the given field, then we skip this field. |
268 | 268 | $required = isset($config['required']) |
269 | 269 | ? array_intersect($config['required'], array_keys($mt_codes)) |
270 | 270 | : true; |
271 | - if ( empty($required) ) |
|
271 | + if (empty($required)) |
|
272 | 272 | continue; |
273 | 273 | |
274 | 274 | //If we have an override then we use it to indicate the codes we want. |
275 | - if ( isset( $this->_valid_shortcodes_modifier[$context][$field] ) ) { |
|
276 | - $this->_validators[ $field ][ 'shortcodes' ] = $this->_reassemble_valid_shortcodes_from_group( |
|
277 | - $this->_valid_shortcodes_modifier[ $context ][ $field ], |
|
275 | + if (isset($this->_valid_shortcodes_modifier[$context][$field])) { |
|
276 | + $this->_validators[$field]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group( |
|
277 | + $this->_valid_shortcodes_modifier[$context][$field], |
|
278 | 278 | $codes_from_objs |
279 | 279 | ); |
280 | 280 | } |
281 | 281 | |
282 | 282 | //if we have specific shortcodes for a field then we need to use them |
283 | - else if ( isset( $groups_per_field[$field] ) ) { |
|
284 | - $this->_validators[ $field ][ 'shortcodes' ] = $this->_reassemble_valid_shortcodes_from_group( |
|
285 | - $groups_per_field[ $field ], |
|
283 | + else if (isset($groups_per_field[$field])) { |
|
284 | + $this->_validators[$field]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group( |
|
285 | + $groups_per_field[$field], |
|
286 | 286 | $codes_from_objs |
287 | 287 | ); |
288 | 288 | } |
289 | 289 | |
290 | 290 | //if empty config then we're assuming we're just going to use the shortcodes from the message type context |
291 | - else if ( empty( $config ) ) { |
|
291 | + else if (empty($config)) { |
|
292 | 292 | $this->_validators[$field]['shortcodes'] = $mt_codes; |
293 | 293 | } |
294 | 294 | |
295 | 295 | //if we have specific shortcodes then we need to use them |
296 | - else if ( isset($config['specific_shortcodes'] ) ) { |
|
296 | + else if (isset($config['specific_shortcodes'])) { |
|
297 | 297 | $this->_validators[$field]['shortcodes'] = $config['specific_shortcodes']; |
298 | 298 | } |
299 | 299 | |
300 | 300 | //otherwise the shortcodes are what is set by the messenger for that field |
301 | 301 | else { |
302 | - foreach ( $config['shortcodes'] as $group ) { |
|
302 | + foreach ($config['shortcodes'] as $group) { |
|
303 | 303 | $this->_validators[$field]['shortcodes'] = isset($this->_validators[$field]['shortcodes']) |
304 | - ? array_merge( $this->_validators[$field]['shortcodes'], $codes_from_objs[$group] ) |
|
304 | + ? array_merge($this->_validators[$field]['shortcodes'], $codes_from_objs[$group]) |
|
305 | 305 | : $codes_from_objs[$group]; |
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
309 | 309 | //now let's just make sure that any excluded specific shortcodes are removed. |
310 | 310 | $specific_excludes = $this->get_specific_shortcode_excludes(); |
311 | - if ( isset( $specific_excludes[$field] ) ) { |
|
312 | - foreach( $specific_excludes[$field] as $sex ) { |
|
313 | - if ( isset( $this->_validators[$field]['shortcodes'][$sex] ) ) |
|
314 | - unset( $this->_validators[$field]['shortcodes'][$sex] ); |
|
311 | + if (isset($specific_excludes[$field])) { |
|
312 | + foreach ($specific_excludes[$field] as $sex) { |
|
313 | + if (isset($this->_validators[$field]['shortcodes'][$sex])) |
|
314 | + unset($this->_validators[$field]['shortcodes'][$sex]); |
|
315 | 315 | } |
316 | 316 | } |
317 | 317 | |
318 | 318 | //hey! don't forget to include the type if present! |
319 | - $this->_validators[$field]['type'] = isset( $config['type'] ) ? $config['type'] : NULL; |
|
319 | + $this->_validators[$field]['type'] = isset($config['type']) ? $config['type'] : NULL; |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | public function get_specific_shortcode_excludes() { |
345 | 345 | //specific validator filter |
346 | 346 | $shortcode_excludes = apply_filters( |
347 | - 'FHEE__' . get_class( $this ) . '__get_specific_shortcode_excludes;', |
|
347 | + 'FHEE__'.get_class($this).'__get_specific_shortcode_excludes;', |
|
348 | 348 | $this->_specific_shortcode_excludes, |
349 | 349 | $this->_context |
350 | 350 | ); |
@@ -372,20 +372,20 @@ discard block |
||
372 | 372 | //some defaults |
373 | 373 | $template_fields = $this->_messenger->get_template_fields(); |
374 | 374 | //loop through the fields and check! |
375 | - foreach ( $this->_fields as $field => $value ) { |
|
375 | + foreach ($this->_fields as $field => $value) { |
|
376 | 376 | $this->_errors[$field] = array(); |
377 | 377 | $err_msg = ''; |
378 | 378 | $field_label = ''; |
379 | 379 | //if field is not present in the _validators array then we continue |
380 | - if ( !isset( $this->_validators[$field] ) ) { |
|
381 | - unset( $this->_errors[$field] ); |
|
380 | + if ( ! isset($this->_validators[$field])) { |
|
381 | + unset($this->_errors[$field]); |
|
382 | 382 | continue; |
383 | 383 | } |
384 | 384 | |
385 | 385 | //get the translated field label! |
386 | 386 | //first check if it's in the main fields list |
387 | - if ( isset( $template_fields[$field] ) ) { |
|
388 | - if ( empty( $template_fields[$field] ) ) |
|
387 | + if (isset($template_fields[$field])) { |
|
388 | + if (empty($template_fields[$field])) |
|
389 | 389 | $field_label = $field; //most likely the field is found in the 'extra' array. |
390 | 390 | else |
391 | 391 | $field_label = $template_fields[$field]['label']; |
@@ -393,16 +393,16 @@ discard block |
||
393 | 393 | |
394 | 394 | // if field label is empty OR is equal to the current field |
395 | 395 | // then we need to loop through the 'extra' fields in the template_fields config (if present) |
396 | - if ( isset( $template_fields['extra'] ) && ( empty($field_label) ) || $field_label == $field ) { |
|
397 | - foreach( $template_fields['extra'] as $main_field => $secondary_field ) { |
|
398 | - foreach ( $secondary_field as $name => $values ) { |
|
399 | - if ( $name == $field ) { |
|
396 | + if (isset($template_fields['extra']) && (empty($field_label)) || $field_label == $field) { |
|
397 | + foreach ($template_fields['extra'] as $main_field => $secondary_field) { |
|
398 | + foreach ($secondary_field as $name => $values) { |
|
399 | + if ($name == $field) { |
|
400 | 400 | $field_label = $values['label']; |
401 | 401 | } |
402 | 402 | |
403 | 403 | // if we've got a 'main' secondary field, let's see if that matches what field we're on |
404 | 404 | // which means it contains the label for this field. |
405 | - if ( $name == 'main' && $main_field == $field_label ) |
|
405 | + if ($name == 'main' && $main_field == $field_label) |
|
406 | 406 | $field_label = $values['label']; |
407 | 407 | } |
408 | 408 | } |
@@ -410,27 +410,27 @@ discard block |
||
410 | 410 | |
411 | 411 | //field is present. Let's validate shortcodes first (but only if shortcodes present). |
412 | 412 | if ( |
413 | - isset( $this->_validators[ $field ][ 'shortcodes' ] ) |
|
414 | - && ! empty( $this->_validators[ $field ][ 'shortcodes' ] ) |
|
413 | + isset($this->_validators[$field]['shortcodes']) |
|
414 | + && ! empty($this->_validators[$field]['shortcodes']) |
|
415 | 415 | ) { |
416 | - $invalid_shortcodes = $this->_invalid_shortcodes( $value, $this->_validators[$field]['shortcodes'] ); |
|
416 | + $invalid_shortcodes = $this->_invalid_shortcodes($value, $this->_validators[$field]['shortcodes']); |
|
417 | 417 | // if true then that means there is a returned error message |
418 | 418 | // that we'll need to add to the _errors array for this field. |
419 | - if ( $invalid_shortcodes ) { |
|
419 | + if ($invalid_shortcodes) { |
|
420 | 420 | $v_s = array_keys($this->_validators[$field]['shortcodes']); |
421 | 421 | $err_msg = sprintf( |
422 | 422 | __( |
423 | 423 | '%3$sThe following shortcodes were found in the "%1$s" field that ARE not valid: %2$s%4$s', |
424 | 424 | 'event_espresso' |
425 | 425 | ), |
426 | - '<strong>' . $field_label . '</strong>', |
|
426 | + '<strong>'.$field_label.'</strong>', |
|
427 | 427 | $invalid_shortcodes, |
428 | 428 | '<p>', |
429 | 429 | '</p >' |
430 | 430 | ); |
431 | 431 | $err_msg .= sprintf( |
432 | - __( '%2$sValid shortcodes for this field are: %1$s%3$s', 'event_espresso' ), |
|
433 | - implode( ', ', $v_s ), |
|
432 | + __('%2$sValid shortcodes for this field are: %1$s%3$s', 'event_espresso'), |
|
433 | + implode(', ', $v_s), |
|
434 | 434 | '<strong>', |
435 | 435 | '</strong>' |
436 | 436 | ); |
@@ -438,10 +438,10 @@ discard block |
||
438 | 438 | } |
439 | 439 | |
440 | 440 | //if there's a "type" to be validated then let's do that too. |
441 | - if ( isset( $this->_validators[$field]['type'] ) && !empty( $this->_validators[$field]['type'] ) ) { |
|
442 | - switch ( $this->_validators[$field]['type'] ) { |
|
441 | + if (isset($this->_validators[$field]['type']) && ! empty($this->_validators[$field]['type'])) { |
|
442 | + switch ($this->_validators[$field]['type']) { |
|
443 | 443 | case 'number' : |
444 | - if ( !is_numeric($value) ) |
|
444 | + if ( ! is_numeric($value)) |
|
445 | 445 | $err_msg .= sprintf( |
446 | 446 | __( |
447 | 447 | '%3$sThe %1$s field is supposed to be a number. The value given (%2$s) is not. Please double-check and make sure the field contains a number%4$s', |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | break; |
456 | 456 | case 'email' : |
457 | 457 | $valid_email = $this->_validate_email($value); |
458 | - if ( !$valid_email ) |
|
458 | + if ( ! $valid_email) |
|
459 | 459 | $err_msg .= htmlentities( |
460 | 460 | sprintf( |
461 | 461 | __( |
@@ -472,23 +472,23 @@ discard block |
||
472 | 472 | } |
473 | 473 | |
474 | 474 | //if $err_msg isn't empty let's setup the _errors array for this field. |
475 | - if ( !empty($err_msg ) ) { |
|
475 | + if ( ! empty($err_msg)) { |
|
476 | 476 | $this->_errors[$field]['msg'] = $err_msg; |
477 | 477 | } else { |
478 | - unset( $this->_errors[$field] ); |
|
478 | + unset($this->_errors[$field]); |
|
479 | 479 | } |
480 | 480 | } |
481 | 481 | |
482 | 482 | // if we have ANY errors, then we want to make sure we return the values |
483 | 483 | // for ALL the fields so the user doesn't have to retype them all. |
484 | - if ( !empty( $this->_errors ) ) { |
|
485 | - foreach ( $this->_fields as $field => $value ) { |
|
484 | + if ( ! empty($this->_errors)) { |
|
485 | + foreach ($this->_fields as $field => $value) { |
|
486 | 486 | $this->_errors[$field]['value'] = stripslashes($value); |
487 | 487 | } |
488 | 488 | } |
489 | 489 | |
490 | 490 | //return any errors or just TRUE if everything validates |
491 | - return empty( $this->_errors ) ? TRUE : $this->_errors; |
|
491 | + return empty($this->_errors) ? TRUE : $this->_errors; |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | |
@@ -501,10 +501,10 @@ discard block |
||
501 | 501 | * @param array $codes_from_objs All the codes available. |
502 | 502 | * @return array an array of actual shortcodes (that will be used for validation). |
503 | 503 | */ |
504 | - private function _reassemble_valid_shortcodes_from_group( $groups, $codes_from_objs ) { |
|
504 | + private function _reassemble_valid_shortcodes_from_group($groups, $codes_from_objs) { |
|
505 | 505 | $shortcodes = array(); |
506 | - foreach ( $groups as $group ) { |
|
507 | - $shortcodes = array_merge( $shortcodes, $codes_from_objs[$group] ); |
|
506 | + foreach ($groups as $group) { |
|
507 | + $shortcodes = array_merge($shortcodes, $codes_from_objs[$group]); |
|
508 | 508 | } |
509 | 509 | return $shortcodes; |
510 | 510 | } |
@@ -523,29 +523,29 @@ discard block |
||
523 | 523 | */ |
524 | 524 | protected function _invalid_shortcodes($value, $valid_shortcodes) { |
525 | 525 | //first we need to go through the string and get the shortcodes in the string |
526 | - preg_match_all( '/(\[.+?\])/', $value, $matches ); |
|
526 | + preg_match_all('/(\[.+?\])/', $value, $matches); |
|
527 | 527 | $incoming_shortcodes = (array) $matches[0]; |
528 | 528 | |
529 | 529 | //get a diff of the shortcodes in the string vs the valid shortcodes |
530 | - $diff = array_diff( $incoming_shortcodes, array_keys($valid_shortcodes) ); |
|
530 | + $diff = array_diff($incoming_shortcodes, array_keys($valid_shortcodes)); |
|
531 | 531 | |
532 | 532 | //we need to account for custom codes so let's loop through the diff and remove any of those type of codes |
533 | - foreach ( $diff as $ind => $code ) { |
|
534 | - if ( preg_match('/(\[[A-Za-z0-9\_]+_\*)/', $code ) ) { |
|
533 | + foreach ($diff as $ind => $code) { |
|
534 | + if (preg_match('/(\[[A-Za-z0-9\_]+_\*)/', $code)) { |
|
535 | 535 | //strip the shortcode so we just have the BASE string (i.e. [ANSWER_*] ) |
536 | 536 | $dynamic_sc = preg_replace('/(_\*+.+)/', '_*]', $code); |
537 | 537 | //does this exist in the $valid_shortcodes? If so then unset. |
538 | - if ( isset( $valid_shortcodes[$dynamic_sc] ) ) { |
|
539 | - unset( $diff[$ind] ); |
|
538 | + if (isset($valid_shortcodes[$dynamic_sc])) { |
|
539 | + unset($diff[$ind]); |
|
540 | 540 | } |
541 | 541 | } |
542 | 542 | } |
543 | 543 | |
544 | - if ( empty( $diff ) ) return FALSE; //there is no diff, we have no invalid shortcodes, so return |
|
544 | + if (empty($diff)) return FALSE; //there is no diff, we have no invalid shortcodes, so return |
|
545 | 545 | |
546 | 546 | //made it here? then let's assemble the error message |
547 | - $invalid_shortcodes = implode( '</strong>,<strong>', $diff ); |
|
548 | - $invalid_shortcodes = '<strong>' . $invalid_shortcodes . '</strong>'; |
|
547 | + $invalid_shortcodes = implode('</strong>,<strong>', $diff); |
|
548 | + $invalid_shortcodes = '<strong>'.$invalid_shortcodes.'</strong>'; |
|
549 | 549 | return $invalid_shortcodes; |
550 | 550 | } |
551 | 551 | |
@@ -557,13 +557,13 @@ discard block |
||
557 | 557 | * @param string $value incoming value to validate |
558 | 558 | * @return bool true if the string validates, false if it doesn't |
559 | 559 | */ |
560 | - protected function _validate_email( $value ) { |
|
560 | + protected function _validate_email($value) { |
|
561 | 561 | $validate = TRUE; |
562 | 562 | $or_val = $value; |
563 | 563 | |
564 | 564 | // empty strings will validate because this is how a message template |
565 | 565 | // for a particular context can be "turned off" (if there is no email then no message) |
566 | - if ( empty( $value ) ) |
|
566 | + if (empty($value)) |
|
567 | 567 | return $validate; |
568 | 568 | |
569 | 569 | // first determine if there ARE any shortcodes. |
@@ -581,19 +581,19 @@ discard block |
||
581 | 581 | // its possible that this message is being "turned off" for a particular context |
582 | 582 | |
583 | 583 | |
584 | - if ( !empty($or_val) && empty($value) ) |
|
584 | + if ( ! empty($or_val) && empty($value)) |
|
585 | 585 | return $validate; |
586 | 586 | |
587 | 587 | //trim any commas from beginning and end of string ( after whitespace trimmed ); |
588 | - $value = trim( trim($value), ',' ); |
|
588 | + $value = trim(trim($value), ','); |
|
589 | 589 | |
590 | 590 | |
591 | 591 | //next we need to split up the string if its comma delimited. |
592 | 592 | $emails = explode(',', $value); |
593 | 593 | $empty = FALSE; //used to indicate that there is an empty comma. |
594 | 594 | //now let's loop through the emails and do our checks |
595 | - foreach ( $emails as $email ) { |
|
596 | - if ( empty($email) ) { |
|
595 | + foreach ($emails as $email) { |
|
596 | + if (empty($email)) { |
|
597 | 597 | $empty = TRUE; |
598 | 598 | continue; |
599 | 599 | } |
@@ -601,20 +601,20 @@ discard block |
||
601 | 601 | //trim whitespace |
602 | 602 | $email = trim($email); |
603 | 603 | //either its of type "[email protected]", or its of type "fname lname <[email protected]>" |
604 | - if(is_email($email)){ |
|
604 | + if (is_email($email)) { |
|
605 | 605 | continue; |
606 | - }else{ |
|
606 | + } else { |
|
607 | 607 | $matches = array(); |
608 | - $validate = preg_match( '/(.*)<(.+)>/', $email, $matches ) ? TRUE : FALSE; |
|
609 | - if( $validate && is_email($matches[2])){ |
|
608 | + $validate = preg_match('/(.*)<(.+)>/', $email, $matches) ? TRUE : FALSE; |
|
609 | + if ($validate && is_email($matches[2])) { |
|
610 | 610 | continue; |
611 | - }else{ |
|
611 | + } else { |
|
612 | 612 | return false; |
613 | 613 | } |
614 | 614 | } |
615 | 615 | } |
616 | 616 | |
617 | - $validate = $empty && !$has_shortcodes ? FALSE : $validate; |
|
617 | + $validate = $empty && ! $has_shortcodes ? FALSE : $validate; |
|
618 | 618 | |
619 | 619 | return $validate; |
620 | 620 | |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | * @throws Exception |
631 | 631 | * @return mixed |
632 | 632 | */ |
633 | - public function __get( $property ) { |
|
633 | + public function __get($property) { |
|
634 | 634 | $expected_properties_map = array( |
635 | 635 | /** |
636 | 636 | * @deprecated 4.9.0 |
@@ -642,15 +642,15 @@ discard block |
||
642 | 642 | '_MSGTYP' => '_message_type' |
643 | 643 | ); |
644 | 644 | |
645 | - if ( isset( $expected_properties_map[ $property ] ) ) { |
|
646 | - return $this->{$expected_properties_map[ $property ]}; |
|
645 | + if (isset($expected_properties_map[$property])) { |
|
646 | + return $this->{$expected_properties_map[$property]}; |
|
647 | 647 | } |
648 | 648 | |
649 | 649 | throw new Exception( |
650 | 650 | sprintf( |
651 | - __( 'The property %1$s being requested on %2$s does not exist', 'event_espresso' ), |
|
651 | + __('The property %1$s being requested on %2$s does not exist', 'event_espresso'), |
|
652 | 652 | $property, |
653 | - get_class( $this ) |
|
653 | + get_class($this) |
|
654 | 654 | ) |
655 | 655 | ); |
656 | 656 | } |