@@ -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 | /** |
@@ -46,20 +46,20 @@ discard block |
||
46 | 46 | * @throws \EE_Error |
47 | 47 | * @return array|bool array of data required for the redirect to the correct edit page or FALSE if encountering problems. |
48 | 48 | */ |
49 | - public static function generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = FALSE) { |
|
49 | + public static function generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = FALSE) { |
|
50 | 50 | |
51 | 51 | //make sure message_type is an array. |
52 | 52 | $message_types = (array) $message_types; |
53 | 53 | $templates = array(); |
54 | 54 | $success = TRUE; |
55 | 55 | |
56 | - if ( empty($messenger) ) { |
|
57 | - throw new EE_Error( __('We need a messenger to generate templates!', 'event_espresso') ); |
|
56 | + if (empty($messenger)) { |
|
57 | + throw new EE_Error(__('We need a messenger to generate templates!', 'event_espresso')); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | //if we STILL have empty $message_types then we need to generate an error message b/c we NEED message types to do the template files. |
61 | - if ( empty($message_types) ) { |
|
62 | - throw new EE_Error( __('We need at least one message type to generate templates!', 'event_espresso') ); |
|
61 | + if (empty($message_types)) { |
|
62 | + throw new EE_Error(__('We need at least one message type to generate templates!', 'event_espresso')); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | self::_set_autoloader(); |
@@ -67,25 +67,25 @@ discard block |
||
67 | 67 | |
68 | 68 | $MSG = new EE_messages(); |
69 | 69 | |
70 | - foreach ( $message_types as $message_type ) { |
|
70 | + foreach ($message_types as $message_type) { |
|
71 | 71 | //if global then let's attempt to get the GRP_ID for this combo IF GRP_ID is empty. |
72 | - if ( $global && empty( $GRP_ID ) ) { |
|
73 | - $GRP_ID = EEM_Message_Template_Group::instance()->get_one( array( array( 'MTP_messenger' => $messenger, 'MTP_message_type' => $message_type, 'MTP_is_global' => TRUE ) ) ); |
|
72 | + if ($global && empty($GRP_ID)) { |
|
73 | + $GRP_ID = EEM_Message_Template_Group::instance()->get_one(array(array('MTP_messenger' => $messenger, 'MTP_message_type' => $message_type, 'MTP_is_global' => TRUE))); |
|
74 | 74 | $GRP_ID = $GRP_ID instanceof EE_Message_Template_Group ? $GRP_ID->ID() : 0; |
75 | 75 | } |
76 | 76 | //if this is global template generation. First let's determine if we already HAVE global templates for this messenger and message_type combination. If we do then NO generation!! |
77 | - if ( $global && self::already_generated($messenger, $message_type, $GRP_ID ) ) { |
|
77 | + if ($global && self::already_generated($messenger, $message_type, $GRP_ID)) { |
|
78 | 78 | $templates = TRUE; |
79 | 79 | continue; //get out we've already got generated templates for this. |
80 | 80 | } |
81 | 81 | |
82 | 82 | $new_message_template_group = $MSG->create_new_templates($messenger, $message_type, $GRP_ID, $global); |
83 | 83 | |
84 | - if ( !$new_message_template_group ) { |
|
84 | + if ( ! $new_message_template_group) { |
|
85 | 85 | $success = FALSE; |
86 | 86 | continue; |
87 | 87 | } |
88 | - if ( $templates === TRUE ) $templates = array(); |
|
88 | + if ($templates === TRUE) $templates = array(); |
|
89 | 89 | $templates[] = $new_message_template_group; |
90 | 90 | } |
91 | 91 | |
@@ -101,18 +101,18 @@ discard block |
||
101 | 101 | * @param bool $update_to_active if true then we also toggle the template to active. |
102 | 102 | * @return bool true = generated, false = hasn't been generated. |
103 | 103 | */ |
104 | - public static function already_generated( $messenger, $message_type, $GRP_ID = 0, $update_to_active = TRUE ) { |
|
104 | + public static function already_generated($messenger, $message_type, $GRP_ID = 0, $update_to_active = TRUE) { |
|
105 | 105 | self::_set_autoloader(); |
106 | 106 | $MTP = EEM_Message_Template::instance(); |
107 | 107 | |
108 | 108 | //what method we use depends on whether we have an GRP_ID or not |
109 | - $count = empty( $GRP_ID ) ? EEM_Message_Template::instance()->count( array( array( 'Message_Template_Group.MTP_messenger' => $messenger, 'Message_Template_Group.MTP_message_type' => $message_type, 'Message_Template_Group.MTP_is_global' => TRUE ) ) ) : $MTP->count( array( array( 'GRP_ID' => $GRP_ID ) ) ); |
|
109 | + $count = empty($GRP_ID) ? EEM_Message_Template::instance()->count(array(array('Message_Template_Group.MTP_messenger' => $messenger, 'Message_Template_Group.MTP_message_type' => $message_type, 'Message_Template_Group.MTP_is_global' => TRUE))) : $MTP->count(array(array('GRP_ID' => $GRP_ID))); |
|
110 | 110 | |
111 | - if ( $update_to_active ) { |
|
112 | - self::update_to_active( $messenger, $message_type ); |
|
111 | + if ($update_to_active) { |
|
112 | + self::update_to_active($messenger, $message_type); |
|
113 | 113 | } |
114 | 114 | |
115 | - return ( $count > 0 ) ? TRUE : FALSE; |
|
115 | + return ($count > 0) ? TRUE : FALSE; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * @static |
127 | 127 | * @return int count of updated records. |
128 | 128 | */ |
129 | - public static function update_to_active( $messenger, $message_type ) { |
|
130 | - return EEM_Message_Template_Group::instance()->update( array('MTP_is_active' => 1), array(array('MTP_messenger' => $messenger, 'MTP_message_type' => $message_type )) ); |
|
129 | + public static function update_to_active($messenger, $message_type) { |
|
130 | + return EEM_Message_Template_Group::instance()->update(array('MTP_is_active' => 1), array(array('MTP_messenger' => $messenger, 'MTP_message_type' => $message_type))); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -140,18 +140,18 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return int count of updated records. |
142 | 142 | */ |
143 | - public static function update_to_inactive( $messenger = '', $message_type = '' ) { |
|
143 | + public static function update_to_inactive($messenger = '', $message_type = '') { |
|
144 | 144 | $query_args = array(); |
145 | - if ( empty( $messenger ) && empty( $message_type ) ) |
|
145 | + if (empty($messenger) && empty($message_type)) |
|
146 | 146 | return 0; |
147 | - if ( ! empty( $messenger ) ) { |
|
147 | + if ( ! empty($messenger)) { |
|
148 | 148 | $query_args[0]['MTP_messenger'] = $messenger; |
149 | 149 | } |
150 | 150 | |
151 | - if ( ! empty( $message_type ) ) { |
|
151 | + if ( ! empty($message_type)) { |
|
152 | 152 | $query_args[0]['MTP_message_type'] = $message_type; |
153 | 153 | } |
154 | - return EEM_Message_Template_Group::instance()->update( array( 'MTP_is_active' => FALSE ), $query_args ); |
|
154 | + return EEM_Message_Template_Group::instance()->update(array('MTP_is_active' => FALSE), $query_args); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | |
@@ -189,39 +189,39 @@ discard block |
||
189 | 189 | * OR |
190 | 190 | * FALSE if no shortcodes found. |
191 | 191 | */ |
192 | - public static function get_shortcodes( $message_type, $messenger, $fields = array(), $context = 'admin', $merged = FALSE ) { |
|
192 | + public static function get_shortcodes($message_type, $messenger, $fields = array(), $context = 'admin', $merged = FALSE) { |
|
193 | 193 | |
194 | - $messenger_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $messenger ) ) ); |
|
195 | - $mt_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $message_type ) ) ); |
|
194 | + $messenger_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $messenger))); |
|
195 | + $mt_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $message_type))); |
|
196 | 196 | |
197 | 197 | //convert slug to object |
198 | - $messenger = self::messenger_obj( $messenger ); |
|
198 | + $messenger = self::messenger_obj($messenger); |
|
199 | 199 | |
200 | 200 | //validate class for getting our list of shortcodes |
201 | - $classname = 'EE_Messages_' . $messenger_name . '_' . $mt_name . '_Validator'; |
|
202 | - if ( !class_exists( $classname ) ) { |
|
203 | - $msg[] = __( 'The Validator class was unable to load', 'event_espresso'); |
|
204 | - $msg[] = sprintf( __('The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', 'event_espresso'), $classname ); |
|
205 | - throw new EE_Error( implode( '||', $msg ) ); |
|
201 | + $classname = 'EE_Messages_'.$messenger_name.'_'.$mt_name.'_Validator'; |
|
202 | + if ( ! class_exists($classname)) { |
|
203 | + $msg[] = __('The Validator class was unable to load', 'event_espresso'); |
|
204 | + $msg[] = sprintf(__('The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', 'event_espresso'), $classname); |
|
205 | + throw new EE_Error(implode('||', $msg)); |
|
206 | 206 | } |
207 | 207 | |
208 | - $a = new ReflectionClass( $classname ); |
|
209 | - $_VLD = $a->newInstance( array(), $context ); |
|
208 | + $a = new ReflectionClass($classname); |
|
209 | + $_VLD = $a->newInstance(array(), $context); |
|
210 | 210 | $valid_shortcodes = $_VLD->get_validators(); |
211 | 211 | |
212 | 212 | //let's make sure we're only getting the shortcode part of the validators |
213 | 213 | $shortcodes = array(); |
214 | - foreach( $valid_shortcodes as $field => $validators ) { |
|
214 | + foreach ($valid_shortcodes as $field => $validators) { |
|
215 | 215 | $shortcodes[$field] = $validators['shortcodes']; |
216 | 216 | $fields[] = $field; |
217 | 217 | } |
218 | 218 | $valid_shortcodes = $shortcodes; |
219 | 219 | |
220 | 220 | //if not all fields let's make sure we ONLY include the shortcodes for the specified fields. |
221 | - if ( ! empty( $fields ) ) { |
|
221 | + if ( ! empty($fields)) { |
|
222 | 222 | $specified_shortcodes = array(); |
223 | - foreach ( $fields as $field ) { |
|
224 | - if ( isset( $valid_shortcodes[$field] ) ) |
|
223 | + foreach ($fields as $field) { |
|
224 | + if (isset($valid_shortcodes[$field])) |
|
225 | 225 | $specified_shortcodes[$field] = $valid_shortcodes[$field]; |
226 | 226 | } |
227 | 227 | $valid_shortcodes = $specified_shortcodes; |
@@ -229,16 +229,16 @@ discard block |
||
229 | 229 | |
230 | 230 | |
231 | 231 | //if not merged then let's replace the fields with the localized fields |
232 | - if ( ! $merged ) { |
|
232 | + if ( ! $merged) { |
|
233 | 233 | //let's get all the fields for the set messenger so that we can get the localized label and use that in the returned array. |
234 | 234 | $field_settings = $messenger->get_template_fields(); |
235 | 235 | $localized = array(); |
236 | - foreach ( $valid_shortcodes as $field => $shortcodes ) { |
|
236 | + foreach ($valid_shortcodes as $field => $shortcodes) { |
|
237 | 237 | //get localized field label |
238 | - if ( isset( $field_settings[$field] ) ) { |
|
238 | + if (isset($field_settings[$field])) { |
|
239 | 239 | //possible that this is used as a main field. |
240 | - if ( empty( $field_settings[$field] ) ) { |
|
241 | - if ( isset( $field_settings['extra'][$field] ) ) { |
|
240 | + if (empty($field_settings[$field])) { |
|
241 | + if (isset($field_settings['extra'][$field])) { |
|
242 | 242 | $_field = $field_settings['extra'][$field]['main']['label']; |
243 | 243 | } else { |
244 | 244 | $_field = $field; |
@@ -246,10 +246,10 @@ discard block |
||
246 | 246 | } else { |
247 | 247 | $_field = $field_settings[$field]['label']; |
248 | 248 | } |
249 | - } else if ( isset( $field_settings['extra'] ) ) { |
|
249 | + } else if (isset($field_settings['extra'])) { |
|
250 | 250 | //loop through extra "main fields" and see if any of their children have our field |
251 | - foreach ( $field_settings['extra'] as $main_field => $fields ) { |
|
252 | - if ( isset( $fields[$field] ) ) |
|
251 | + foreach ($field_settings['extra'] as $main_field => $fields) { |
|
252 | + if (isset($fields[$field])) |
|
253 | 253 | $_field = $fields[$field]['label']; |
254 | 254 | else |
255 | 255 | $_field = $field; |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | } else { |
258 | 258 | $_field = $field; |
259 | 259 | } |
260 | - if ( isset( $_field )) { |
|
261 | - $localized[ $_field ] = $shortcodes; |
|
260 | + if (isset($_field)) { |
|
261 | + $localized[$_field] = $shortcodes; |
|
262 | 262 | } |
263 | 263 | } |
264 | 264 | $valid_shortcodes = $localized; |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | |
267 | 267 | |
268 | 268 | //if $merged then let's merge all the shortcodes into one list NOT indexed by field. |
269 | - if ( $merged ) { |
|
269 | + if ($merged) { |
|
270 | 270 | $merged_codes = array(); |
271 | - foreach ( $valid_shortcodes as $field => $shortcode ) { |
|
272 | - foreach ( $shortcode as $code => $label ) { |
|
273 | - if ( isset( $merged_codes[$code] ) ) |
|
271 | + foreach ($valid_shortcodes as $field => $shortcode) { |
|
272 | + foreach ($shortcode as $code => $label) { |
|
273 | + if (isset($merged_codes[$code])) |
|
274 | 274 | continue; |
275 | 275 | else |
276 | 276 | $merged_codes[$code] = $label; |
@@ -292,15 +292,15 @@ discard block |
||
292 | 292 | * @throws \EE_Error |
293 | 293 | * @return EE_messenger |
294 | 294 | */ |
295 | - public static function messenger_obj( $messenger ) { |
|
296 | - $ref = ucwords( str_replace( '_', ' ', $messenger ) ); |
|
297 | - $ref = str_replace( ' ', '_', $ref ); |
|
298 | - $classname = 'EE_' . $ref . '_messenger'; |
|
295 | + public static function messenger_obj($messenger) { |
|
296 | + $ref = ucwords(str_replace('_', ' ', $messenger)); |
|
297 | + $ref = str_replace(' ', '_', $ref); |
|
298 | + $classname = 'EE_'.$ref.'_messenger'; |
|
299 | 299 | |
300 | - if ( !class_exists($classname) ) { |
|
300 | + if ( ! class_exists($classname)) { |
|
301 | 301 | $msg[] = __('Messenger class loading fail.', 'event_espresso'); |
302 | - $msg[] = sprintf( __('The class name checked was "%s". Please check the spelling and case of this reference and make sure it matches the appropriate messenger file name (minus the extension) in the "/core/messages/messenger/" directory', 'event_espresso'), $classname ); |
|
303 | - throw new EE_Error( implode( '||', $msg ) ); |
|
302 | + $msg[] = sprintf(__('The class name checked was "%s". Please check the spelling and case of this reference and make sure it matches the appropriate messenger file name (minus the extension) in the "/core/messages/messenger/" directory', 'event_espresso'), $classname); |
|
303 | + throw new EE_Error(implode('||', $msg)); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | //made it here so let's instantiate the object and return it. |
@@ -318,15 +318,15 @@ discard block |
||
318 | 318 | * @throws \EE_Error |
319 | 319 | * @return EE_message_type |
320 | 320 | */ |
321 | - public static function message_type_obj( $message_type ) { |
|
322 | - $ref = ucwords( str_replace( '_', ' ', $message_type ) ); |
|
323 | - $ref = str_replace( ' ', '_', $ref ); |
|
324 | - $classname = 'EE_' . $ref . '_message_type'; |
|
321 | + public static function message_type_obj($message_type) { |
|
322 | + $ref = ucwords(str_replace('_', ' ', $message_type)); |
|
323 | + $ref = str_replace(' ', '_', $ref); |
|
324 | + $classname = 'EE_'.$ref.'_message_type'; |
|
325 | 325 | |
326 | - if ( !class_exists($classname) ) { |
|
326 | + if ( ! class_exists($classname)) { |
|
327 | 327 | $msg[] = __('Message Type class loading fail.', 'event_espresso'); |
328 | - $msg[] = sprintf( __('The class name checked was "%s". Please check the spelling and case of this reference and make sure it matches the appropriate message type file name (minus the extension) in the "/core/messages/message_type/" directory', 'event_espresso'), $classname ); |
|
329 | - throw new EE_Error( implode( '||', $msg ) ); |
|
328 | + $msg[] = sprintf(__('The class name checked was "%s". Please check the spelling and case of this reference and make sure it matches the appropriate message type file name (minus the extension) in the "/core/messages/message_type/" directory', 'event_espresso'), $classname); |
|
329 | + throw new EE_Error(implode('||', $msg)); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | //made it here so let's instantiate the object and return it. |
@@ -345,10 +345,10 @@ discard block |
||
345 | 345 | * @param string $message_type message type to check for. |
346 | 346 | * @return boolean |
347 | 347 | */ |
348 | - public static function is_mt_active( $message_type ) { |
|
348 | + public static function is_mt_active($message_type) { |
|
349 | 349 | self::_set_autoloader(); |
350 | - $active_mts = EE_Registry::instance()->load_lib( 'messages' )->get_active_message_types(); |
|
351 | - return in_array( $message_type, $active_mts ); |
|
350 | + $active_mts = EE_Registry::instance()->load_lib('messages')->get_active_message_types(); |
|
351 | + return in_array($message_type, $active_mts); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | |
@@ -361,10 +361,10 @@ discard block |
||
361 | 361 | * @param string $messenger slug for messenger to check. |
362 | 362 | * @return boolean |
363 | 363 | */ |
364 | - public static function is_messenger_active( $messenger ) { |
|
364 | + public static function is_messenger_active($messenger) { |
|
365 | 365 | self::_set_autoloader(); |
366 | 366 | $active_messengers = EE_Registry::instance()->load_lib('messages')->get_active_messengers(); |
367 | - return isset( $active_messengers[ $messenger ] ); |
|
367 | + return isset($active_messengers[$messenger]); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @return array |
379 | 379 | */ |
380 | 380 | public static function get_active_messengers_in_db() { |
381 | - return apply_filters( 'FHEE__EEH_MSG_Template__get_active_messengers_in_db', get_option( 'ee_active_messengers', array() ) ); |
|
381 | + return apply_filters('FHEE__EEH_MSG_Template__get_active_messengers_in_db', get_option('ee_active_messengers', array())); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | |
@@ -393,8 +393,8 @@ discard block |
||
393 | 393 | * |
394 | 394 | * @return bool FALSE if not updated, TRUE if updated. |
395 | 395 | */ |
396 | - public static function update_active_messengers_in_db( $data_to_save ) { |
|
397 | - return update_option( 'ee_active_messengers', $data_to_save ); |
|
396 | + public static function update_active_messengers_in_db($data_to_save) { |
|
397 | + return update_option('ee_active_messengers', $data_to_save); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | * |
414 | 414 | * @return string The generated url. |
415 | 415 | */ |
416 | - public static function generate_url_trigger( $sending_messenger, $generating_messenger, $context, $message_type, EE_Registration $registration, $message_template_group, $data_id ) { |
|
416 | + public static function generate_url_trigger($sending_messenger, $generating_messenger, $context, $message_type, EE_Registration $registration, $message_template_group, $data_id) { |
|
417 | 417 | $query_args = array( |
418 | 418 | 'ee' => 'msg_url_trigger', |
419 | 419 | 'snd_msgr' => $sending_messenger, |
@@ -424,10 +424,10 @@ discard block |
||
424 | 424 | 'GRP_ID' => $message_template_group, |
425 | 425 | 'id' => $data_id |
426 | 426 | ); |
427 | - $url = add_query_arg( $query_args, get_site_url() ); |
|
427 | + $url = add_query_arg($query_args, get_site_url()); |
|
428 | 428 | |
429 | 429 | //made it here so now we can just get the url and filter it. Filtered globally and by message type. |
430 | - $url = apply_filters( 'FHEE__EEH_MSG_Template__generate_url_trigger', $url, $sending_messenger, $generating_messenger, $context, $message_type, $registration, $message_template_group, $data_id ); |
|
430 | + $url = apply_filters('FHEE__EEH_MSG_Template__generate_url_trigger', $url, $sending_messenger, $generating_messenger, $context, $message_type, $registration, $message_template_group, $data_id); |
|
431 | 431 | |
432 | 432 | return $url; |
433 | 433 | } |
@@ -1,7 +1,8 @@ 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 | 7 | /** |
7 | 8 | * Event Espresso |
@@ -85,7 +86,9 @@ discard block |
||
85 | 86 | $success = FALSE; |
86 | 87 | continue; |
87 | 88 | } |
88 | - if ( $templates === TRUE ) $templates = array(); |
|
89 | + if ( $templates === TRUE ) { |
|
90 | + $templates = array(); |
|
91 | + } |
|
89 | 92 | $templates[] = $new_message_template_group; |
90 | 93 | } |
91 | 94 | |
@@ -142,8 +145,9 @@ discard block |
||
142 | 145 | */ |
143 | 146 | public static function update_to_inactive( $messenger = '', $message_type = '' ) { |
144 | 147 | $query_args = array(); |
145 | - if ( empty( $messenger ) && empty( $message_type ) ) |
|
146 | - return 0; |
|
148 | + if ( empty( $messenger ) && empty( $message_type ) ) { |
|
149 | + return 0; |
|
150 | + } |
|
147 | 151 | if ( ! empty( $messenger ) ) { |
148 | 152 | $query_args[0]['MTP_messenger'] = $messenger; |
149 | 153 | } |
@@ -221,8 +225,9 @@ discard block |
||
221 | 225 | if ( ! empty( $fields ) ) { |
222 | 226 | $specified_shortcodes = array(); |
223 | 227 | foreach ( $fields as $field ) { |
224 | - if ( isset( $valid_shortcodes[$field] ) ) |
|
225 | - $specified_shortcodes[$field] = $valid_shortcodes[$field]; |
|
228 | + if ( isset( $valid_shortcodes[$field] ) ) { |
|
229 | + $specified_shortcodes[$field] = $valid_shortcodes[$field]; |
|
230 | + } |
|
226 | 231 | } |
227 | 232 | $valid_shortcodes = $specified_shortcodes; |
228 | 233 | } |
@@ -249,10 +254,11 @@ discard block |
||
249 | 254 | } else if ( isset( $field_settings['extra'] ) ) { |
250 | 255 | //loop through extra "main fields" and see if any of their children have our field |
251 | 256 | foreach ( $field_settings['extra'] as $main_field => $fields ) { |
252 | - if ( isset( $fields[$field] ) ) |
|
253 | - $_field = $fields[$field]['label']; |
|
254 | - else |
|
255 | - $_field = $field; |
|
257 | + if ( isset( $fields[$field] ) ) { |
|
258 | + $_field = $fields[$field]['label']; |
|
259 | + } else { |
|
260 | + $_field = $field; |
|
261 | + } |
|
256 | 262 | } |
257 | 263 | } else { |
258 | 264 | $_field = $field; |
@@ -270,10 +276,11 @@ discard block |
||
270 | 276 | $merged_codes = array(); |
271 | 277 | foreach ( $valid_shortcodes as $field => $shortcode ) { |
272 | 278 | foreach ( $shortcode as $code => $label ) { |
273 | - if ( isset( $merged_codes[$code] ) ) |
|
274 | - continue; |
|
275 | - else |
|
276 | - $merged_codes[$code] = $label; |
|
279 | + if ( isset( $merged_codes[$code] ) ) { |
|
280 | + continue; |
|
281 | + } else { |
|
282 | + $merged_codes[$code] = $label; |
|
283 | + } |
|
277 | 284 | } |
278 | 285 | } |
279 | 286 | $valid_shortcodes = $merged_codes; |
@@ -8,18 +8,18 @@ |
||
8 | 8 | */ |
9 | 9 | if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
10 | 10 | /** |
11 | - * |
|
12 | - * Money helper class. |
|
13 | - * This class has helper methods that help with money related conversions and calculations. |
|
14 | - * |
|
15 | - * @since %VER% |
|
16 | - * |
|
17 | - * @package Event Espresso |
|
18 | - * @subpackage helpers |
|
19 | - * @author Darren Ethier |
|
20 | - * |
|
21 | - * ------------------------------------------------------------------------ |
|
22 | - */ |
|
11 | + * |
|
12 | + * Money helper class. |
|
13 | + * This class has helper methods that help with money related conversions and calculations. |
|
14 | + * |
|
15 | + * @since %VER% |
|
16 | + * |
|
17 | + * @package Event Espresso |
|
18 | + * @subpackage helpers |
|
19 | + * @author Darren Ethier |
|
20 | + * |
|
21 | + * ------------------------------------------------------------------------ |
|
22 | + */ |
|
23 | 23 | class EEH_Money extends EEH_Base { |
24 | 24 | |
25 | 25 |
@@ -5,7 +5,9 @@ |
||
5 | 5 | * @subpackage plugin api, messages |
6 | 6 | * @since 4.5.0 |
7 | 7 | */ |
8 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | + exit('No direct script access allowed'); |
|
10 | +} |
|
9 | 11 | |
10 | 12 | /** |
11 | 13 | * Use this to register or deregister a new message template pack variation for the EE messages system. |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * ------------------------------------------------------------------------ |
22 | 22 | */ |
23 | -class EEH_Money extends EEH_Base { |
|
23 | +class EEH_Money extends EEH_Base { |
|
24 | 24 | |
25 | 25 | |
26 | 26 | /** |
@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | * @param int|string $incoming_value |
30 | 30 | * @return float |
31 | 31 | */ |
32 | - public static function convert_to_float_from_localized_money( $incoming_value ) { |
|
32 | + public static function convert_to_float_from_localized_money($incoming_value) { |
|
33 | 33 | //remove thousands separator |
34 | - $money_value = str_replace( EE_Registry::instance()->CFG->currency->thsnds, '', $incoming_value ); |
|
34 | + $money_value = str_replace(EE_Registry::instance()->CFG->currency->thsnds, '', $incoming_value); |
|
35 | 35 | |
36 | 36 | //replace decimal place with standard decimal. |
37 | - $money_value = str_replace( EE_Registry::instance()->CFG->currency->dec_mrk, '.', $money_value ); |
|
37 | + $money_value = str_replace(EE_Registry::instance()->CFG->currency->dec_mrk, '.', $money_value); |
|
38 | 38 | |
39 | 39 | //float it! and round to three decimal places |
40 | - $money_value = round ( (float) $money_value, 3 ); |
|
40 | + $money_value = round((float) $money_value, 3); |
|
41 | 41 | return $money_value; |
42 | 42 | } |
43 | 43 | |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | * @throws \EE_Error |
58 | 58 | */ |
59 | 59 | |
60 | - public static function compare_floats( $float1, $float2, $operator='=' ) { |
|
60 | + public static function compare_floats($float1, $float2, $operator = '=') { |
|
61 | 61 | // Check numbers to 5 digits of precision |
62 | 62 | $epsilon = 0.00001; |
63 | 63 | |
64 | - $float1 = (float)$float1; |
|
65 | - $float2 = (float)$float2; |
|
64 | + $float1 = (float) $float1; |
|
65 | + $float2 = (float) $float2; |
|
66 | 66 | |
67 | 67 | switch ($operator) { |
68 | 68 | // equal |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | } |
117 | 117 | break; |
118 | 118 | default: |
119 | - throw new EE_Error(__( "Unknown operator '" . $operator . "' in EEH_Money::compare_floats()", 'event_espresso' ) ); |
|
119 | + throw new EE_Error(__("Unknown operator '".$operator."' in EEH_Money::compare_floats()", 'event_espresso')); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | return false; |
@@ -131,21 +131,21 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return string |
133 | 133 | */ |
134 | - public static function get_format_for_jqplot( $CNT_ISO = '') { |
|
134 | + public static function get_format_for_jqplot($CNT_ISO = '') { |
|
135 | 135 | //default format |
136 | 136 | $format = 'f'; |
137 | 137 | //if CNT_ISO passed lets try to get currency settings for it. |
138 | - $currency_config = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : null; |
|
138 | + $currency_config = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null; |
|
139 | 139 | //default currency settings for site if not set |
140 | - if ( ! $currency_config instanceof EE_Currency_Config ) { |
|
140 | + if ( ! $currency_config instanceof EE_Currency_Config) { |
|
141 | 141 | $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
142 | 142 | } |
143 | 143 | |
144 | 144 | //first get the decimal place and number of places |
145 | - $format = "%'." . $currency_config->dec_plc . $format; |
|
145 | + $format = "%'.".$currency_config->dec_plc.$format; |
|
146 | 146 | |
147 | 147 | //currency symbol on right side. |
148 | - $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
|
148 | + $format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign; |
|
149 | 149 | return $format; |
150 | 150 | } |
151 | 151 | |
@@ -160,27 +160,27 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @return string |
162 | 162 | */ |
163 | - public static function get_format_for_google_charts( $CNT_ISO = '' ) { |
|
163 | + public static function get_format_for_google_charts($CNT_ISO = '') { |
|
164 | 164 | //if CNT_ISO passed lets try to get currency settings for it. |
165 | - $currency_config = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : null; |
|
165 | + $currency_config = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null; |
|
166 | 166 | //default currency settings for site if not set |
167 | - if ( ! $currency_config instanceof EE_Currency_Config ) { |
|
167 | + if ( ! $currency_config instanceof EE_Currency_Config) { |
|
168 | 168 | $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
169 | 169 | } |
170 | 170 | |
171 | - $decimal_places_placeholder = str_pad( '', $currency_config->dec_plc, '0' ); |
|
171 | + $decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0'); |
|
172 | 172 | |
173 | 173 | //first get the decimal place and number of places |
174 | - $format = '#,##0.' . $decimal_places_placeholder; |
|
174 | + $format = '#,##0.'.$decimal_places_placeholder; |
|
175 | 175 | |
176 | 176 | //currency symbol on right side. |
177 | - $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
|
177 | + $format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign; |
|
178 | 178 | $formatterObject = array( |
179 | 179 | 'decimalSymbol' => $currency_config->dec_mrk, |
180 | 180 | 'groupingSymbol' => $currency_config->thsnds, |
181 | 181 | 'fractionDigits' => $currency_config->dec_plc, |
182 | 182 | ); |
183 | - if ( $currency_config->sign_b4 ) { |
|
183 | + if ($currency_config->sign_b4) { |
|
184 | 184 | $formatterObject['prefix'] = $currency_config->sign; |
185 | 185 | } else { |
186 | 186 | $formatterObject['suffix'] = $currency_config->sign; |
@@ -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 | /** |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param INT $GRP_ID The message template grp_id for the specific template being parsed. |
84 | 84 | * @return string The parsed template string |
85 | 85 | */ |
86 | - public function parse_message_template( $template, EE_Messages_Addressee $data, $valid_shortcodes, EE_message_type $message_type, EE_messenger $messenger, $context, $GRP_ID ) { |
|
86 | + public function parse_message_template($template, EE_Messages_Addressee $data, $valid_shortcodes, EE_message_type $message_type, EE_messenger $messenger, $context, $GRP_ID) { |
|
87 | 87 | $extra_data = array( |
88 | 88 | 'messenger' => $messenger, |
89 | 89 | 'message_type' => $message_type, |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | 'GRP_ID' => $GRP_ID |
92 | 92 | ); |
93 | 93 | |
94 | - $this->_init_data( $template, $data, $valid_shortcodes, $extra_data ); |
|
94 | + $this->_init_data($template, $data, $valid_shortcodes, $extra_data); |
|
95 | 95 | |
96 | 96 | |
97 | 97 | $this->_template = is_array($template) ? $template['main'] : $template; |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | |
105 | - public function parse_attendee_list_template( $template, EE_Registration $registration, $valid_shortcodes, $extra_data = array() ) { |
|
105 | + public function parse_attendee_list_template($template, EE_Registration $registration, $valid_shortcodes, $extra_data = array()) { |
|
106 | 106 | |
107 | - $this->_init_data( $template, $registration, $valid_shortcodes, $extra_data ); |
|
107 | + $this->_init_data($template, $registration, $valid_shortcodes, $extra_data); |
|
108 | 108 | |
109 | 109 | $this->_template = is_array($template) ? $template['attendee_list'] : $template; |
110 | 110 | |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | return $parsed; |
113 | 113 | } |
114 | 114 | |
115 | - public function parse_event_list_template( $template, EE_Event $event, $valid_shortcodes, $extra_data = array() ) { |
|
116 | - $this->_init_data( $template, $event, $valid_shortcodes, $extra_data ); |
|
115 | + public function parse_event_list_template($template, EE_Event $event, $valid_shortcodes, $extra_data = array()) { |
|
116 | + $this->_init_data($template, $event, $valid_shortcodes, $extra_data); |
|
117 | 117 | |
118 | 118 | $this->_template = is_array($template) ? $template['event_list'] : $template; |
119 | 119 | |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | |
125 | - public function parse_ticket_list_template( $template, EE_Ticket $ticket, $valid_shortcodes, $extra_data = array() ) { |
|
126 | - $this->_init_data( $template, $ticket, $valid_shortcodes, $extra_data ); |
|
125 | + public function parse_ticket_list_template($template, EE_Ticket $ticket, $valid_shortcodes, $extra_data = array()) { |
|
126 | + $this->_init_data($template, $ticket, $valid_shortcodes, $extra_data); |
|
127 | 127 | |
128 | 128 | $this->_template = is_array($template) ? $template['ticket_list'] : $template; |
129 | 129 | |
@@ -133,26 +133,26 @@ discard block |
||
133 | 133 | |
134 | 134 | |
135 | 135 | |
136 | - public function parse_line_item_list_template( $template, EE_Line_Item $line_item, $valid_shortcodes, $extra_data = array() ) { |
|
137 | - $this->_init_data( $template, $line_item, $valid_shortcodes, $extra_data ); |
|
138 | - $this->_template = is_array( $template ) ? $template['ticket_line_item_no_pms'] : $template; |
|
136 | + public function parse_line_item_list_template($template, EE_Line_Item $line_item, $valid_shortcodes, $extra_data = array()) { |
|
137 | + $this->_init_data($template, $line_item, $valid_shortcodes, $extra_data); |
|
138 | + $this->_template = is_array($template) ? $template['ticket_line_item_no_pms'] : $template; |
|
139 | 139 | |
140 | 140 | $parsed = $this->_parse_message_template(); |
141 | 141 | return $parsed; |
142 | 142 | } |
143 | 143 | |
144 | 144 | |
145 | - public function parse_payment_list_template( $template, EE_Payment $payment_item, $valid_shortcodes, $extra_data = array() ) { |
|
146 | - $this->_init_data( $template, $payment_item, $valid_shortcodes, $extra_data ); |
|
147 | - $this->_template = is_array( $template ) ? $template['payment_list'] : $template; |
|
145 | + public function parse_payment_list_template($template, EE_Payment $payment_item, $valid_shortcodes, $extra_data = array()) { |
|
146 | + $this->_init_data($template, $payment_item, $valid_shortcodes, $extra_data); |
|
147 | + $this->_template = is_array($template) ? $template['payment_list'] : $template; |
|
148 | 148 | |
149 | 149 | $parsed = $this->_parse_message_template(); |
150 | 150 | return $parsed; |
151 | 151 | } |
152 | 152 | |
153 | 153 | |
154 | - public function parse_datetime_list_template( $template, EE_Datetime $datetime, $valid_shortcodes, $extra_data = array() ) { |
|
155 | - $this->_init_data( $template, $datetime, $valid_shortcodes, $extra_data ); |
|
154 | + public function parse_datetime_list_template($template, EE_Datetime $datetime, $valid_shortcodes, $extra_data = array()) { |
|
155 | + $this->_init_data($template, $datetime, $valid_shortcodes, $extra_data); |
|
156 | 156 | |
157 | 157 | $this->_template = is_array($template) ? $template['datetime_list'] : $template; |
158 | 158 | |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | |
164 | - public function parse_question_list_template( $template, EE_Answer $answer, $valid_shortcodes, $extra_data = array() ) { |
|
165 | - $this->_init_data( $template, $answer, $valid_shortcodes, $extra_data ); |
|
164 | + public function parse_question_list_template($template, EE_Answer $answer, $valid_shortcodes, $extra_data = array()) { |
|
165 | + $this->_init_data($template, $answer, $valid_shortcodes, $extra_data); |
|
166 | 166 | |
167 | 167 | $this->_template = is_array($template) ? $template['question_list'] : $template; |
168 | 168 | |
@@ -171,13 +171,13 @@ discard block |
||
171 | 171 | } |
172 | 172 | |
173 | 173 | |
174 | - private function _init_data( $template, $data, $valid_shortcodes, $extra_data = array() ) { |
|
174 | + private function _init_data($template, $data, $valid_shortcodes, $extra_data = array()) { |
|
175 | 175 | $this->_reset_props(); |
176 | 176 | $this->_data['template'] = $template; |
177 | 177 | $this->_data['data'] = $data; |
178 | 178 | $this->_data['extra_data'] = $extra_data; |
179 | 179 | |
180 | - $this->_set_shortcodes( $valid_shortcodes ); |
|
180 | + $this->_set_shortcodes($valid_shortcodes); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | |
198 | 198 | //now let's get a list of shortcodes that are found in the given template |
199 | - $possible_shortcodes = preg_match_all( '/(\[.+?\])/', $this->_template, $matches ); |
|
199 | + $possible_shortcodes = preg_match_all('/(\[.+?\])/', $this->_template, $matches); |
|
200 | 200 | $shortcodes = (array) $matches[0]; //this should be an array of shortcodes in the template string. |
201 | 201 | |
202 | 202 | $matched_code = array(); |
@@ -221,31 +221,31 @@ discard block |
||
221 | 221 | '[PAYMENT_LIST_*]' |
222 | 222 | ); |
223 | 223 | |
224 | - $list_type_shortcodes = apply_filters( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', $list_type_shortcodes ); |
|
224 | + $list_type_shortcodes = apply_filters('FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', $list_type_shortcodes); |
|
225 | 225 | |
226 | 226 | //now lets go ahead and loop through our parsers for each shortcode and setup the values |
227 | - foreach ( $shortcodes as $shortcode ) { |
|
227 | + foreach ($shortcodes as $shortcode) { |
|
228 | 228 | |
229 | - foreach ( $this->_shortcode_objs as $sc_obj ) { |
|
229 | + foreach ($this->_shortcode_objs as $sc_obj) { |
|
230 | 230 | $data_send = ''; |
231 | 231 | |
232 | 232 | //we need to setup any dynamic shortcodes so that they work with the array_key_exists |
233 | - $sc = preg_match_all( '/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches ); |
|
234 | - $sc_to_verify = !empty($matches[0] ) ? $matches[0][0] . ']' : $shortcode; |
|
233 | + $sc = preg_match_all('/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches); |
|
234 | + $sc_to_verify = ! empty($matches[0]) ? $matches[0][0].']' : $shortcode; |
|
235 | 235 | |
236 | - if ( !array_key_exists( $sc_to_verify, $sc_obj->get_shortcodes() ) ) { |
|
236 | + if ( ! array_key_exists($sc_to_verify, $sc_obj->get_shortcodes())) { |
|
237 | 237 | continue; //the given shortcode isn't in this object |
238 | 238 | } |
239 | 239 | |
240 | 240 | //if this isn't a "list" type shortcode then we'll send along the data vanilla instead of in an array. |
241 | - if ( ! in_array( $sc_to_verify, $list_type_shortcodes ) ) { |
|
242 | - $data_send = !is_object($this->_data) && isset($this->_data['data']) ? $this->_data['data'] : $this->_data; |
|
241 | + if ( ! in_array($sc_to_verify, $list_type_shortcodes)) { |
|
242 | + $data_send = ! is_object($this->_data) && isset($this->_data['data']) ? $this->_data['data'] : $this->_data; |
|
243 | 243 | } else { |
244 | 244 | $data_send = $this->_data; |
245 | 245 | } |
246 | 246 | |
247 | 247 | |
248 | - $parsed = $sc_obj->parser( $shortcode, $data_send, $this->_data['extra_data'] ); |
|
248 | + $parsed = $sc_obj->parser($shortcode, $data_send, $this->_data['extra_data']); |
|
249 | 249 | |
250 | 250 | $matched_code[] = $shortcode; |
251 | 251 | $sc_values[] = $parsed; |
@@ -267,13 +267,13 @@ discard block |
||
267 | 267 | * @param array $valid_shortcodes an array of strings corresponding to EE_Shortcode Library objects |
268 | 268 | * @return void |
269 | 269 | */ |
270 | - private function _set_shortcodes( $valid_shortcodes ) { |
|
271 | - foreach ( $valid_shortcodes as $shortcode_ref ) { |
|
272 | - $ref = ucwords( str_replace('_', ' ', $shortcode_ref ) ); |
|
273 | - $ref = str_replace( ' ', '_', $ref ); |
|
274 | - $classname = 'EE_' . $ref . '_Shortcodes'; |
|
275 | - if ( class_exists( $classname ) ) { |
|
276 | - $a = new ReflectionClass( $classname ); |
|
270 | + private function _set_shortcodes($valid_shortcodes) { |
|
271 | + foreach ($valid_shortcodes as $shortcode_ref) { |
|
272 | + $ref = ucwords(str_replace('_', ' ', $shortcode_ref)); |
|
273 | + $ref = str_replace(' ', '_', $ref); |
|
274 | + $classname = 'EE_'.$ref.'_Shortcodes'; |
|
275 | + if (class_exists($classname)) { |
|
276 | + $a = new ReflectionClass($classname); |
|
277 | 277 | $this->_shortcode_objs[] = $a->newInstance(); |
278 | 278 | } |
279 | 279 | } |
@@ -6,8 +6,9 @@ |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage messages |
8 | 8 | */ |
9 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
9 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
10 | 10 | exit('NO direct script access allowed'); |
11 | +} |
|
11 | 12 | |
12 | 13 | /** |
13 | 14 | * |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | |
30 | 30 | |
31 | -require_once( EE_HELPERS . 'EEH_Base.helper.php' ); |
|
31 | +require_once(EE_HELPERS.'EEH_Base.helper.php'); |
|
32 | 32 | class EEH_Sideloader extends EEH_Base { |
33 | 33 | |
34 | 34 | private $_upload_to; |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | * @access public |
44 | 44 | * @param array $init array fo initializing the sideloader if keys match the properties. |
45 | 45 | */ |
46 | - public function __construct( $init = array() ) { |
|
47 | - $this->_init( $init ); |
|
46 | + public function __construct($init = array()) { |
|
47 | + $this->_init($init); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
@@ -55,24 +55,24 @@ discard block |
||
55 | 55 | * @param array $init array on init (keys match properties others ignored) |
56 | 56 | * @return void |
57 | 57 | */ |
58 | - private function _init( $init ) { |
|
58 | + private function _init($init) { |
|
59 | 59 | $defaults = array( |
60 | 60 | '_upload_to' => $this->_get_wp_uploads_dir(), |
61 | 61 | '_upload_from' => '', |
62 | 62 | '_permissions' => 0644, |
63 | - '_new_file_name' => 'EE_Sideloader_' . uniqid() . '.default' |
|
63 | + '_new_file_name' => 'EE_Sideloader_'.uniqid().'.default' |
|
64 | 64 | ); |
65 | 65 | |
66 | - $props = array_merge( $defaults, $init ); |
|
66 | + $props = array_merge($defaults, $init); |
|
67 | 67 | |
68 | - foreach ( $props as $key => $val ) { |
|
69 | - if ( EEH_Class_Tools::has_property( $this, $key ) ) { |
|
68 | + foreach ($props as $key => $val) { |
|
69 | + if (EEH_Class_Tools::has_property($this, $key)) { |
|
70 | 70 | $this->$key = $val; |
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | 74 | //make sure we include the required wp file for needed functions |
75 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
75 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
@@ -80,16 +80,16 @@ discard block |
||
80 | 80 | private function _get_wp_uploads_dir() {} |
81 | 81 | |
82 | 82 | //setters |
83 | - public function set_upload_to( $upload_to_folder ) { |
|
83 | + public function set_upload_to($upload_to_folder) { |
|
84 | 84 | $this->_upload_to = $upload_to_folder; |
85 | 85 | } |
86 | - public function set_upload_from( $upload_from_folder ) { |
|
86 | + public function set_upload_from($upload_from_folder) { |
|
87 | 87 | $this->_upload_from_folder = $upload_from_folder; |
88 | 88 | } |
89 | - public function set_permissions( $permissions ) { |
|
89 | + public function set_permissions($permissions) { |
|
90 | 90 | $this->_permissions = $permissions; |
91 | 91 | } |
92 | - public function set_new_file_name( $new_file_name ) { |
|
92 | + public function set_new_file_name($new_file_name) { |
|
93 | 93 | $this->_new_file_name = $new_file_name; |
94 | 94 | } |
95 | 95 | |
@@ -111,34 +111,34 @@ discard block |
||
111 | 111 | //upload methods |
112 | 112 | public function sideload() { |
113 | 113 | //setup temp dir |
114 | - $temp_file = wp_tempnam( $this->_upload_from ); |
|
114 | + $temp_file = wp_tempnam($this->_upload_from); |
|
115 | 115 | |
116 | - if ( !$temp_file ) { |
|
117 | - EE_Error::add_error( __('Something went wrong with the upload. Unable to create a tmp file for the uploaded file on the server', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
116 | + if ( ! $temp_file) { |
|
117 | + EE_Error::add_error(__('Something went wrong with the upload. Unable to create a tmp file for the uploaded file on the server', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
121 | - do_action( 'AHEE__EEH_Sideloader__sideload__before', $this, $temp_file ); |
|
121 | + do_action('AHEE__EEH_Sideloader__sideload__before', $this, $temp_file); |
|
122 | 122 | |
123 | - $wp_remote_args = apply_filters( 'FHEE__EEH_Sideloader__sideload__wp_remote_args', array( 'timeout' => 500, 'stream' => true, 'filename' => $temp_file ), $this, $temp_file ); |
|
123 | + $wp_remote_args = apply_filters('FHEE__EEH_Sideloader__sideload__wp_remote_args', array('timeout' => 500, 'stream' => true, 'filename' => $temp_file), $this, $temp_file); |
|
124 | 124 | |
125 | - $response = wp_safe_remote_get( $this->_upload_from, $wp_remote_args ); |
|
125 | + $response = wp_safe_remote_get($this->_upload_from, $wp_remote_args); |
|
126 | 126 | |
127 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { |
|
128 | - unlink( $temp_file ); |
|
129 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
130 | - EE_Error::add_error( sprintf( __('Unable to upload the file. Either the path given to upload from is incorrect, or something else happened. Here is the response returned:<br />%s<br />Here is the path given: %s', 'event_espresso'), var_export( $response, true ), $this->_upload_from ), __FILE__, __FUNCTION__, __LINE__ ); |
|
127 | + if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) { |
|
128 | + unlink($temp_file); |
|
129 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
130 | + EE_Error::add_error(sprintf(__('Unable to upload the file. Either the path given to upload from is incorrect, or something else happened. Here is the response returned:<br />%s<br />Here is the path given: %s', 'event_espresso'), var_export($response, true), $this->_upload_from), __FILE__, __FUNCTION__, __LINE__); |
|
131 | 131 | } |
132 | 132 | return false; |
133 | 133 | } |
134 | 134 | |
135 | 135 | //possible md5 check |
136 | - $content_md5 = wp_remote_retrieve_header( $response, 'content-md5' ); |
|
137 | - if ( $content_md5 ) { |
|
138 | - $md5_check = verify_file_md5( $temp_file, $content_md5 ); |
|
139 | - if ( is_wp_error( $md5_check ) ) { |
|
140 | - unlink( $temp_file ); |
|
141 | - EE_Error::add_error( $md5_check->get_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
136 | + $content_md5 = wp_remote_retrieve_header($response, 'content-md5'); |
|
137 | + if ($content_md5) { |
|
138 | + $md5_check = verify_file_md5($temp_file, $content_md5); |
|
139 | + if (is_wp_error($md5_check)) { |
|
140 | + unlink($temp_file); |
|
141 | + EE_Error::add_error($md5_check->get_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
142 | 142 | return false; |
143 | 143 | } |
144 | 144 | } |
@@ -146,24 +146,24 @@ discard block |
||
146 | 146 | $file = $temp_file; |
147 | 147 | |
148 | 148 | //now we have the file, let's get it in the right directory with the right name. |
149 | - $path = apply_filters( 'FHEE__EEH_Sideloader__sideload__new_path', $this->_upload_to . $this->_new_file_name, $this ); |
|
149 | + $path = apply_filters('FHEE__EEH_Sideloader__sideload__new_path', $this->_upload_to.$this->_new_file_name, $this); |
|
150 | 150 | |
151 | 151 | //move file in |
152 | - if ( false === @ rename( $file, $path ) ) { |
|
153 | - unlink( $temp_file ); |
|
154 | - EE_Error::add_error( sprintf( __('Unable to move the file to new location (possible permissions errors). This is the path the class attempted to move the file to: %s', 'event_espresso' ), $path ), __FILE__, __FUNCTION__, __LINE__ ); |
|
152 | + if (false === @ rename($file, $path)) { |
|
153 | + unlink($temp_file); |
|
154 | + EE_Error::add_error(sprintf(__('Unable to move the file to new location (possible permissions errors). This is the path the class attempted to move the file to: %s', 'event_espresso'), $path), __FILE__, __FUNCTION__, __LINE__); |
|
155 | 155 | return false; |
156 | 156 | } |
157 | 157 | |
158 | 158 | //set permissions |
159 | - $permissions = apply_filters( 'FHEE__EEH_Sideloader__sideload__permissions_applied', $this->_permissions, $this ); |
|
160 | - chmod( $path, $permissions ); |
|
159 | + $permissions = apply_filters('FHEE__EEH_Sideloader__sideload__permissions_applied', $this->_permissions, $this); |
|
160 | + chmod($path, $permissions); |
|
161 | 161 | |
162 | 162 | //that's it. let's allow for actions after file uploaded. |
163 | - do_action( 'AHEE__EE_Sideloader__sideload_after', $this, $path ); |
|
163 | + do_action('AHEE__EE_Sideloader__sideload_after', $this, $path); |
|
164 | 164 | |
165 | 165 | //unlink tempfile |
166 | - @unlink( $temp_file ); |
|
166 | + @unlink($temp_file); |
|
167 | 167 | return true; |
168 | 168 | } |
169 | 169 |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -98,8 +99,9 @@ discard block |
||
98 | 99 | * @param array $nav_tabs tab array for nav tabs |
99 | 100 | */ |
100 | 101 | public static function display_admin_nav_tabs($nav_tabs = array()) { |
101 | - if ( empty($nav_tabs) ) |
|
102 | - throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) ); |
|
102 | + if ( empty($nav_tabs) ) { |
|
103 | + throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) ); |
|
104 | + } |
|
103 | 105 | |
104 | 106 | $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
105 | 107 | foreach ( $nav_tabs as $slug => $tab ) { |
@@ -165,8 +167,10 @@ discard block |
||
165 | 167 | * @return string a html snippet of of all the formatted link elements. |
166 | 168 | */ |
167 | 169 | public static function tab_text_links( $item_array, $container_class = '', $sep = '|', $default = '' ) { |
168 | - if ( !is_array($item_array) || empty( $item_array ) ) |
|
169 | - return false; //get out we don't have even the basic thing we need! |
|
170 | + if ( !is_array($item_array) || empty( $item_array ) ) { |
|
171 | + return false; |
|
172 | + } |
|
173 | + //get out we don't have even the basic thing we need! |
|
170 | 174 | |
171 | 175 | |
172 | 176 | $defaults = array( |
@@ -184,8 +188,9 @@ discard block |
||
184 | 188 | $item = wp_parse_args( $item, $defaults ); |
185 | 189 | $item['class'] = !empty($default) && $default == $item['slug'] ? 'item_display ' . $item['class'] : $item['class']; |
186 | 190 | $list .= self::_text_link_item($item); |
187 | - if ( !empty($sep) && $ci != count($item_array) ) |
|
188 | - $list .= self::_text_link_item($sep); |
|
191 | + if ( !empty($sep) && $ci != count($item_array) ) { |
|
192 | + $list .= self::_text_link_item($sep); |
|
193 | + } |
|
189 | 194 | $ci++; |
190 | 195 | } |
191 | 196 |
@@ -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 | /** |
@@ -46,22 +46,22 @@ discard block |
||
46 | 46 | * @return string the assembled html string containing the tabbed content for display. |
47 | 47 | * @throws \EE_Error |
48 | 48 | */ |
49 | - public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE ) { |
|
49 | + public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE) { |
|
50 | 50 | |
51 | 51 | //first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston |
52 | - if ( !empty( $tabs_names) && ( count( (array) $tabs_names) != count( (array) $tabs_content) ) ) { |
|
53 | - throw new EE_Error( __('The count for $tabs_names and $tabs_content does not match.', 'event_espresso') ); |
|
52 | + if ( ! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) { |
|
53 | + throw new EE_Error(__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | //make sure we've got incoming data setup properly |
57 | - $tabs = !empty( $tabs_names ) ? (array) $tabs_names : array_keys( (array) $tabs_contents ); |
|
58 | - $tabs_content = !empty( $tabs_names ) ? array_combine( (array) $tabs_names, (array) $tabs_content ) : $tabs_contents; |
|
57 | + $tabs = ! empty($tabs_names) ? (array) $tabs_names : array_keys((array) $tabs_contents); |
|
58 | + $tabs_content = ! empty($tabs_names) ? array_combine((array) $tabs_names, (array) $tabs_content) : $tabs_contents; |
|
59 | 59 | |
60 | - $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
|
60 | + $all_tabs = '<h2 class="nav-tab-wrapper">'."\n"; |
|
61 | 61 | $all_tabs_content = ''; |
62 | 62 | |
63 | 63 | $index = 0; |
64 | - foreach ( $tabs as $tab ) { |
|
64 | + foreach ($tabs as $tab) { |
|
65 | 65 | $active = $index === 0 ? true : false; |
66 | 66 | $all_tabs .= self::tab($tab, $active); |
67 | 67 | $all_tabs_content .= self::tab_content($tab, $tabs_content[$tab], $active); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $tab_container_class = $small_tabs ? 'ee-nav-tabs ee-nav-tabs-small' : 'ee-nav-tabs'; |
80 | 80 | |
81 | - return '<div class="'. $tab_container_class . '">' . "\n\t" . $all_tabs . $all_tabs_content . "\n" . '</div>'; |
|
81 | + return '<div class="'.$tab_container_class.'">'."\n\t".$all_tabs.$all_tabs_content."\n".'</div>'; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | * @throws \EE_Error |
103 | 103 | */ |
104 | 104 | public static function display_admin_nav_tabs($nav_tabs = array()) { |
105 | - if ( empty($nav_tabs) ) |
|
106 | - throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) ); |
|
105 | + if (empty($nav_tabs)) |
|
106 | + throw new EE_Error(__('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso')); |
|
107 | 107 | |
108 | - $all_tabs = '<h2 class="nav-tab-wrapper">' . "\n"; |
|
109 | - foreach ( $nav_tabs as $slug => $tab ) { |
|
108 | + $all_tabs = '<h2 class="nav-tab-wrapper">'."\n"; |
|
109 | + foreach ($nav_tabs as $slug => $tab) { |
|
110 | 110 | $all_tabs .= self::tab($slug, false, $tab['link_text'], $tab['url'], $tab['css_class']); |
111 | 111 | } |
112 | 112 | $all_tabs .= '</h2>'; |
@@ -122,13 +122,13 @@ discard block |
||
122 | 122 | * @param bool|string $css If string given then the generated tab will include that as the class. |
123 | 123 | * @return string html for tab |
124 | 124 | */ |
125 | - private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE ) { |
|
125 | + private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE) { |
|
126 | 126 | $name = str_replace(' ', '-', $name); |
127 | 127 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
128 | - $class = $css ? $class . ' ' . $css : $class; |
|
129 | - $nice_name = $nice_name ? $nice_name : ucwords( preg_replace('/(-|_)/', ' ', $name) ); |
|
130 | - $url = $url ? $url : '#' . $name; |
|
131 | - $tab = '<a class="' . $class . '" rel="ee-tab-' . $name . '" href="' . $url . '">' . $nice_name . '</a>' . "\n\t"; |
|
128 | + $class = $css ? $class.' '.$css : $class; |
|
129 | + $nice_name = $nice_name ? $nice_name : ucwords(preg_replace('/(-|_)/', ' ', $name)); |
|
130 | + $url = $url ? $url : '#'.$name; |
|
131 | + $tab = '<a class="'.$class.'" rel="ee-tab-'.$name.'" href="'.$url.'">'.$nice_name.'</a>'."\n\t"; |
|
132 | 132 | return $tab; |
133 | 133 | } |
134 | 134 | |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | */ |
145 | 145 | private static function tab_content($name, $tab_content, $active = false) { |
146 | 146 | $class = $active ? 'nav-tab-content' : 'nav-tab-content hidden'; |
147 | - $name = str_replace( ' ', '-', $name); |
|
148 | - $content = "\t" . '<div class="'. $class . '" id="ee-tab-' . $name . '">' . "\n"; |
|
149 | - $content .= "\t" . $tab_content . "\n"; |
|
147 | + $name = str_replace(' ', '-', $name); |
|
148 | + $content = "\t".'<div class="'.$class.'" id="ee-tab-'.$name.'">'."\n"; |
|
149 | + $content .= "\t".$tab_content."\n"; |
|
150 | 150 | $content .= '<div style="clear:both"></div></div>'; |
151 | 151 | return $content; |
152 | 152 | } |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | * @param string $default You can include a string for the item that will receive the "item_display" class for the js. |
173 | 173 | * @return string a html snippet of of all the formatted link elements. |
174 | 174 | */ |
175 | - public static function tab_text_links( $item_array, $container_class = '', $sep = '|', $default = '' ) { |
|
176 | - $item_array = apply_filters( 'FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class ); |
|
177 | - if ( !is_array($item_array) || empty( $item_array ) ) |
|
175 | + public static function tab_text_links($item_array, $container_class = '', $sep = '|', $default = '') { |
|
176 | + $item_array = apply_filters('FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class); |
|
177 | + if ( ! is_array($item_array) || empty($item_array)) |
|
178 | 178 | return false; //get out we don't have even the basic thing we need! |
179 | 179 | |
180 | 180 | |
@@ -185,15 +185,15 @@ discard block |
||
185 | 185 | 'title' => esc_attr__('Link for Item', 'event_espresso'), |
186 | 186 | 'slug' => 'item_slug' |
187 | 187 | ); |
188 | - $container_class = !empty($container_class) ? 'ee-text-links ' . $container_class : 'ee-text-links'; |
|
189 | - $list = '<ul class="' . $container_class . '">'; |
|
188 | + $container_class = ! empty($container_class) ? 'ee-text-links '.$container_class : 'ee-text-links'; |
|
189 | + $list = '<ul class="'.$container_class.'">'; |
|
190 | 190 | |
191 | 191 | $ci = 1; |
192 | - foreach ( $item_array as $item ) { |
|
193 | - $item = wp_parse_args( $item, $defaults ); |
|
194 | - $item['class'] = !empty($default) && $default == $item['slug'] ? 'item_display ' . $item['class'] : $item['class']; |
|
192 | + foreach ($item_array as $item) { |
|
193 | + $item = wp_parse_args($item, $defaults); |
|
194 | + $item['class'] = ! empty($default) && $default == $item['slug'] ? 'item_display '.$item['class'] : $item['class']; |
|
195 | 195 | $list .= self::_text_link_item($item); |
196 | - if ( !empty($sep) && $ci != count($item_array) ) |
|
196 | + if ( ! empty($sep) && $ci != count($item_array)) |
|
197 | 197 | $list .= self::_text_link_item($sep); |
198 | 198 | $ci++; |
199 | 199 | } |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | |
205 | 205 | |
206 | 206 | |
207 | - private static function _text_link_item( $item ) { |
|
207 | + private static function _text_link_item($item) { |
|
208 | 208 | //if this isn't an array then we're doing a separator |
209 | - if ( !is_array( $item ) ) { |
|
209 | + if ( ! is_array($item)) { |
|
210 | 210 | $label = $item; |
211 | 211 | $class = 'ee-text-link-sep'; |
212 | 212 | $href = ''; |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | extract($item); |
216 | 216 | } |
217 | 217 | |
218 | - $class = $class != 'ee-text-link-sep' ? 'class="ee-text-link-li ' . $class . '"' : 'class="ee-text-link-sep"'; |
|
218 | + $class = $class != 'ee-text-link-sep' ? 'class="ee-text-link-li '.$class.'"' : 'class="ee-text-link-sep"'; |
|
219 | 219 | |
220 | - $content = '<li ' . $class . '>'; |
|
221 | - $content .= !empty($href) ? '<a class="ee-text-link" href="#' . $href . '" title="' . $title . '">' : ''; |
|
220 | + $content = '<li '.$class.'>'; |
|
221 | + $content .= ! empty($href) ? '<a class="ee-text-link" href="#'.$href.'" title="'.$title.'">' : ''; |
|
222 | 222 | $content .= $label; |
223 | - $content .= !empty($href) ? '</a>' : ''; |
|
223 | + $content .= ! empty($href) ? '</a>' : ''; |
|
224 | 224 | $content .= '</li>'; |
225 | 225 | return $content; |
226 | 226 | } |
@@ -160,8 +160,9 @@ discard block |
||
160 | 160 | // first use WP locate_template to check for template in the current theme folder |
161 | 161 | $template_path = locate_template( $templates ); |
162 | 162 | |
163 | - if ( $check_if_custom && !empty( $template_path ) ) |
|
164 | - return TRUE; |
|
163 | + if ( $check_if_custom && !empty( $template_path ) ) { |
|
164 | + return TRUE; |
|
165 | + } |
|
165 | 166 | |
166 | 167 | // not in the theme |
167 | 168 | if ( empty( $template_path )) { |
@@ -364,11 +365,11 @@ discard block |
||
364 | 365 | if( $mny->sign_b4 ){ |
365 | 366 | if( $amount >= 0 ){ |
366 | 367 | $amount_formatted = $mny->sign . $amount_formatted; |
367 | - }else{ |
|
368 | + } else{ |
|
368 | 369 | $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
369 | 370 | } |
370 | 371 | |
371 | - }else{ |
|
372 | + } else{ |
|
372 | 373 | $amount_formatted = $amount_formatted . $mny->sign; |
373 | 374 | } |
374 | 375 | |
@@ -432,11 +433,13 @@ discard block |
||
432 | 433 | */ |
433 | 434 | public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
434 | 435 | |
435 | - if ( ! $page ) |
|
436 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
436 | + if ( ! $page ) { |
|
437 | + $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
438 | + } |
|
437 | 439 | |
438 | - if ( ! $action ) |
|
439 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
440 | + if ( ! $action ) { |
|
441 | + $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
442 | + } |
|
440 | 443 | |
441 | 444 | $action = empty($action) ? 'default' : $action; |
442 | 445 | |
@@ -510,8 +513,9 @@ discard block |
||
510 | 513 | * @return string html structure for status. |
511 | 514 | */ |
512 | 515 | public static function status_legend( $status_array, $active_status = '' ) { |
513 | - if ( !is_array( $status_array ) ) |
|
514 | - throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
516 | + if ( !is_array( $status_array ) ) { |
|
517 | + throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
518 | + } |
|
515 | 519 | |
516 | 520 | $setup_array = array(); |
517 | 521 | foreach ( $status_array as $item => $status ) { |
@@ -572,8 +576,7 @@ discard block |
||
572 | 576 | </tbody> |
573 | 577 | </table> |
574 | 578 | <?php |
575 | - } |
|
576 | - else { |
|
579 | + } else { |
|
577 | 580 | ?> |
578 | 581 | <ul> |
579 | 582 | <?php |
@@ -583,8 +586,7 @@ discard block |
||
583 | 586 | </ul> |
584 | 587 | <?php |
585 | 588 | } |
586 | - } |
|
587 | - else { |
|
589 | + } else { |
|
588 | 590 | //simple value |
589 | 591 | echo $data; |
590 | 592 | } |
@@ -664,8 +666,9 @@ discard block |
||
664 | 666 | |
665 | 667 | $total_pages = ceil( $total_items / $per_page ); |
666 | 668 | |
667 | - if ( $total_pages <= 1 ) |
|
668 | - return ''; |
|
669 | + if ( $total_pages <= 1 ) { |
|
670 | + return ''; |
|
671 | + } |
|
669 | 672 | |
670 | 673 | $item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single']; |
671 | 674 |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * |
283 | 283 | * given two paths, this determines if there is a common base path between the two |
284 | 284 | * |
285 | - * @param array $paths |
|
285 | + * @param string[] $paths |
|
286 | 286 | * @return string |
287 | 287 | */ |
288 | 288 | protected static function _find_common_base_path( $paths ) { |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @param bool|string $template_path server path to the file to be loaded, including file name and extension |
310 | 310 | * @param array $template_args an array of arguments to be extracted for use in the template |
311 | 311 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
312 | - * @return mixed string |
|
312 | + * @return string string |
|
313 | 313 | */ |
314 | 314 | public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
315 | 315 | //require the template validator for verifying variables are set according to how the template requires |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | return array(); |
100 | 100 | } |
101 | 101 | if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) { |
102 | - unset( $espresso_themes[ $key ] ); |
|
102 | + unset( $espresso_themes[ $key ] ); |
|
103 | 103 | } |
104 | 104 | EEH_Template::$_espresso_themes = array(); |
105 | 105 | foreach ( $espresso_themes as $espresso_theme ) { |
@@ -709,9 +709,9 @@ discard block |
||
709 | 709 | ); |
710 | 710 | |
711 | 711 | if ( empty( $items_label ) |
712 | - || ! is_array( $items_label ) |
|
713 | - || ! isset( $items_label['single'] ) |
|
714 | - || ! isset( $items_label['plural'] ) ) { |
|
712 | + || ! is_array( $items_label ) |
|
713 | + || ! isset( $items_label['single'] ) |
|
714 | + || ! isset( $items_label['plural'] ) ) { |
|
715 | 715 | $items_label = array( |
716 | 716 | 'single' => __( '1 item', 'event_espresso' ), |
717 | 717 | 'plural' => __( '%s items', 'event_espresso' ) |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | |
17 | 17 | |
18 | -if ( ! function_exists( 'espresso_get_template_part' )) { |
|
18 | +if ( ! function_exists('espresso_get_template_part')) { |
|
19 | 19 | /** |
20 | 20 | * espresso_get_template_part |
21 | 21 | * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | * @param string $name The name of the specialised template. |
26 | 26 | * @return string the html output for the formatted money value |
27 | 27 | */ |
28 | - function espresso_get_template_part( $slug = NULL, $name = NULL ) { |
|
29 | - EEH_Template::get_template_part( $slug, $name ); |
|
28 | + function espresso_get_template_part($slug = NULL, $name = NULL) { |
|
29 | + EEH_Template::get_template_part($slug, $name); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | 34 | |
35 | -if ( ! function_exists( 'espresso_get_object_css_class' )) { |
|
35 | +if ( ! function_exists('espresso_get_object_css_class')) { |
|
36 | 36 | /** |
37 | 37 | * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
38 | 38 | * |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * @param string $suffix added to the end of the generated class |
43 | 43 | * @return string |
44 | 44 | */ |
45 | - function espresso_get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
46 | - return EEH_Template::get_object_css_class( $object, $prefix, $suffix ); |
|
45 | + function espresso_get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
46 | + return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return boolean |
71 | 71 | */ |
72 | 72 | public static function is_espresso_theme() { |
73 | - return wp_get_theme()->get( 'TextDomain' ) == 'event_espresso' ? TRUE : FALSE; |
|
73 | + return wp_get_theme()->get('TextDomain') == 'event_espresso' ? TRUE : FALSE; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * @return void |
80 | 80 | */ |
81 | 81 | public static function load_espresso_theme_functions() { |
82 | - if ( ! defined( 'EE_THEME_FUNCTIONS_LOADED' )) { |
|
83 | - if ( is_readable( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' )) { |
|
84 | - require_once( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' ); |
|
82 | + if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
83 | + if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) { |
|
84 | + require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php'); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | * @return array |
94 | 94 | */ |
95 | 95 | public static function get_espresso_themes() { |
96 | - if ( empty( EEH_Template::$_espresso_themes )) { |
|
97 | - $espresso_themes = glob( EE_PUBLIC . '*', GLOB_ONLYDIR ); |
|
98 | - if ( empty( $espresso_themes ) ) { |
|
96 | + if (empty(EEH_Template::$_espresso_themes)) { |
|
97 | + $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR); |
|
98 | + if (empty($espresso_themes)) { |
|
99 | 99 | return array(); |
100 | 100 | } |
101 | - if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) { |
|
102 | - unset( $espresso_themes[ $key ] ); |
|
101 | + if (($key = array_search('global_assets', $espresso_themes)) !== FALSE) { |
|
102 | + unset($espresso_themes[$key]); |
|
103 | 103 | } |
104 | 104 | EEH_Template::$_espresso_themes = array(); |
105 | - foreach ( $espresso_themes as $espresso_theme ) { |
|
106 | - EEH_Template::$_espresso_themes[ basename( $espresso_theme ) ] = $espresso_theme; |
|
105 | + foreach ($espresso_themes as $espresso_theme) { |
|
106 | + EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | return EEH_Template::$_espresso_themes; |
@@ -122,16 +122,16 @@ discard block |
||
122 | 122 | * @param bool $return_string |
123 | 123 | * @return string the html output for the formatted money value |
124 | 124 | */ |
125 | - public static function get_template_part( $slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE ) { |
|
126 | - do_action( "get_template_part_{$slug}-{$name}", $slug, $name ); |
|
125 | + public static function get_template_part($slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE) { |
|
126 | + do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
127 | 127 | $templates = array(); |
128 | 128 | $name = (string) $name; |
129 | - if ( $name != '' ) { |
|
129 | + if ($name != '') { |
|
130 | 130 | $templates[] = "{$slug}-{$name}.php"; |
131 | 131 | } |
132 | 132 | // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
133 | - if ( apply_filters( "FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE )) { |
|
134 | - EEH_Template::locate_template( $templates, $template_args, TRUE, $return_string ); |
|
133 | + if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE)) { |
|
134 | + EEH_Template::locate_template($templates, $template_args, TRUE, $return_string); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
@@ -182,26 +182,26 @@ discard block |
||
182 | 182 | * Used in places where you don't actually load the template, you just want to know if there's a custom version of it. |
183 | 183 | * @return mixed |
184 | 184 | */ |
185 | - public static function locate_template( $templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE ) { |
|
185 | + public static function locate_template($templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE) { |
|
186 | 186 | // first use WP locate_template to check for template in the current theme folder |
187 | - $template_path = locate_template( $templates ); |
|
187 | + $template_path = locate_template($templates); |
|
188 | 188 | |
189 | - if ( $check_if_custom && !empty( $template_path ) ) |
|
189 | + if ($check_if_custom && ! empty($template_path)) |
|
190 | 190 | return TRUE; |
191 | 191 | |
192 | 192 | // not in the theme |
193 | - if ( empty( $template_path )) { |
|
193 | + if (empty($template_path)) { |
|
194 | 194 | // not even a template to look for ? |
195 | - if ( empty( $templates )) { |
|
195 | + if (empty($templates)) { |
|
196 | 196 | // get post_type |
197 | - $post_type = EE_Registry::instance()->REQ->get( 'post_type' ); |
|
197 | + $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
198 | 198 | // get array of EE Custom Post Types |
199 | 199 | $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
200 | 200 | // build template name based on request |
201 | - if ( isset( $EE_CPTs[ $post_type ] )) { |
|
202 | - $archive_or_single = is_archive() ? 'archive' : ''; |
|
203 | - $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
204 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
201 | + if (isset($EE_CPTs[$post_type])) { |
|
202 | + $archive_or_single = is_archive() ? 'archive' : ''; |
|
203 | + $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
204 | + $templates = $archive_or_single.'-'.$post_type.'.php'; |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | // currently active EE template theme |
@@ -210,80 +210,80 @@ discard block |
||
210 | 210 | // array of paths to folders that may contain templates |
211 | 211 | $template_folder_paths = array( |
212 | 212 | // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
213 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
213 | + EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme, |
|
214 | 214 | // then in the root of the /wp-content/uploads/espresso/templates/ folder |
215 | 215 | EVENT_ESPRESSO_TEMPLATE_DIR |
216 | 216 | ); |
217 | 217 | |
218 | 218 | //add core plugin folders for checking only if we're not $check_if_custom |
219 | - if ( ! $check_if_custom ) { |
|
219 | + if ( ! $check_if_custom) { |
|
220 | 220 | $core_paths = array( |
221 | 221 | // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
222 | - EE_PUBLIC . $current_theme, |
|
222 | + EE_PUBLIC.$current_theme, |
|
223 | 223 | // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
224 | - EE_TEMPLATES . $current_theme, |
|
224 | + EE_TEMPLATES.$current_theme, |
|
225 | 225 | // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
226 | 226 | EE_PLUGIN_DIR_PATH |
227 | 227 | ); |
228 | - $template_folder_paths = array_merge( $template_folder_paths, $core_paths ); |
|
228 | + $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | // now filter that array |
232 | - $template_folder_paths = apply_filters( 'FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths ); |
|
233 | - $templates = is_array( $templates ) ? $templates : array( $templates ); |
|
234 | - $template_folder_paths = is_array( $template_folder_paths ) ? $template_folder_paths : array( $template_folder_paths ); |
|
232 | + $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths); |
|
233 | + $templates = is_array($templates) ? $templates : array($templates); |
|
234 | + $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
235 | 235 | // array to hold all possible template paths |
236 | 236 | $full_template_paths = array(); |
237 | 237 | |
238 | 238 | EE_Registry::instance()->load_helper('File'); |
239 | 239 | // loop through $templates |
240 | - foreach ( $templates as $template ) { |
|
240 | + foreach ($templates as $template) { |
|
241 | 241 | // normalize directory separators |
242 | - $template = EEH_File::standardise_directory_separators( $template ); |
|
243 | - $file_name = basename( $template ); |
|
244 | - $template_path_minus_file_name = substr( $template, 0, ( strlen( $file_name ) * -1 ) ); |
|
242 | + $template = EEH_File::standardise_directory_separators($template); |
|
243 | + $file_name = basename($template); |
|
244 | + $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
245 | 245 | // while looping through all template folder paths |
246 | - foreach ( $template_folder_paths as $template_folder_path ) { |
|
246 | + foreach ($template_folder_paths as $template_folder_path) { |
|
247 | 247 | // normalize directory separators |
248 | - $template_folder_path = EEH_File::standardise_directory_separators( $template_folder_path ); |
|
248 | + $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
249 | 249 | // determine if any common base path exists between the two paths |
250 | 250 | $common_base_path = EEH_Template::_find_common_base_path( |
251 | - array( $template_folder_path, $template_path_minus_file_name ) |
|
251 | + array($template_folder_path, $template_path_minus_file_name) |
|
252 | 252 | ); |
253 | - if ( $common_base_path !== '' ) { |
|
253 | + if ($common_base_path !== '') { |
|
254 | 254 | // both paths have a common base, so just tack the filename onto our search path |
255 | - $resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $file_name; |
|
255 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name; |
|
256 | 256 | } else { |
257 | 257 | // no common base path, so let's just concatenate |
258 | - $resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $template; |
|
258 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template; |
|
259 | 259 | } |
260 | 260 | // build up our template locations array by adding our resolved paths |
261 | 261 | $full_template_paths[] = $resolved_path; |
262 | 262 | } |
263 | 263 | // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
264 | - array_unshift( $full_template_paths, $template ); |
|
264 | + array_unshift($full_template_paths, $template); |
|
265 | 265 | // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
266 | - array_unshift( $full_template_paths, get_stylesheet_directory() . DS . $file_name ); |
|
266 | + array_unshift($full_template_paths, get_stylesheet_directory().DS.$file_name); |
|
267 | 267 | } |
268 | 268 | // filter final array of full template paths |
269 | - $full_template_paths = apply_filters( 'FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths, $file_name ); |
|
269 | + $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths, $file_name); |
|
270 | 270 | // now loop through our final array of template location paths and check each location |
271 | - foreach ( (array)$full_template_paths as $full_template_path ) { |
|
272 | - if ( is_readable( $full_template_path )) { |
|
273 | - $template_path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $full_template_path ); |
|
271 | + foreach ((array) $full_template_paths as $full_template_path) { |
|
272 | + if (is_readable($full_template_path)) { |
|
273 | + $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
274 | 274 | break; |
275 | 275 | } |
276 | 276 | } |
277 | 277 | } |
278 | 278 | // if we got it and you want to see it... |
279 | - if ( $template_path && $load && ! $check_if_custom ) { |
|
280 | - if ( $return_string ) { |
|
281 | - return EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
279 | + if ($template_path && $load && ! $check_if_custom) { |
|
280 | + if ($return_string) { |
|
281 | + return EEH_Template::display_template($template_path, $template_args, TRUE); |
|
282 | 282 | } else { |
283 | - EEH_Template::display_template( $template_path, $template_args, FALSE ); |
|
283 | + EEH_Template::display_template($template_path, $template_args, FALSE); |
|
284 | 284 | } |
285 | 285 | } |
286 | - return $check_if_custom && ! empty( $template_path ) ? TRUE : $template_path; |
|
286 | + return $check_if_custom && ! empty($template_path) ? TRUE : $template_path; |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | |
@@ -296,21 +296,21 @@ discard block |
||
296 | 296 | * @param array $paths |
297 | 297 | * @return string |
298 | 298 | */ |
299 | - protected static function _find_common_base_path( $paths ) { |
|
299 | + protected static function _find_common_base_path($paths) { |
|
300 | 300 | $last_offset = 0; |
301 | 301 | $common_base_path = ''; |
302 | - while ( ( $index = strpos( $paths[ 0 ], DS, $last_offset ) ) !== false ) { |
|
302 | + while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
303 | 303 | $dir_length = $index - $last_offset + 1; |
304 | - $directory = substr( $paths[ 0 ], $last_offset, $dir_length ); |
|
305 | - foreach ( $paths as $path ) { |
|
306 | - if ( substr( $path, $last_offset, $dir_length ) != $directory ) { |
|
304 | + $directory = substr($paths[0], $last_offset, $dir_length); |
|
305 | + foreach ($paths as $path) { |
|
306 | + if (substr($path, $last_offset, $dir_length) != $directory) { |
|
307 | 307 | return $common_base_path; |
308 | 308 | } |
309 | 309 | } |
310 | 310 | $common_base_path .= $directory; |
311 | 311 | $last_offset = $index + 1; |
312 | 312 | } |
313 | - return substr( $common_base_path, 0, -1 ); |
|
313 | + return substr($common_base_path, 0, -1); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | |
@@ -322,9 +322,9 @@ discard block |
||
322 | 322 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
323 | 323 | * @return mixed string |
324 | 324 | */ |
325 | - public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
|
325 | + public static function display_template($template_path = FALSE, $template_args = array(), $return_string = FALSE) { |
|
326 | 326 | //require the template validator for verifying variables are set according to how the template requires |
327 | - EE_Registry::instance()->load_helper( 'Template_Validator' ); |
|
327 | + EE_Registry::instance()->load_helper('Template_Validator'); |
|
328 | 328 | |
329 | 329 | /** |
330 | 330 | * These two filters are intended for last minute changes to templates being loaded and/or template arg |
@@ -335,26 +335,26 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @since 4.6.0 |
337 | 337 | */ |
338 | - $template_path = apply_filters( 'FHEE__EEH_Template__display_template__template_path', $template_path ); |
|
339 | - $template_args = apply_filters( 'FHEE__EEH_Template__display_template__template_args', $template_args ); |
|
338 | + $template_path = apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
339 | + $template_args = apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
340 | 340 | |
341 | 341 | // you gimme nuttin - YOU GET NUTTIN !! |
342 | - if ( ! $template_path || ! is_readable( $template_path )) { |
|
342 | + if ( ! $template_path || ! is_readable($template_path)) { |
|
343 | 343 | return ''; |
344 | 344 | } |
345 | 345 | // if $template_args are not in an array, then make it so |
346 | - if ( ! is_array( $template_args ) && ! is_object( $template_args )) { |
|
347 | - $template_args = array( $template_args ); |
|
346 | + if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
347 | + $template_args = array($template_args); |
|
348 | 348 | } |
349 | - extract( (array) $template_args); |
|
349 | + extract((array) $template_args); |
|
350 | 350 | |
351 | - if ( $return_string ) { |
|
351 | + if ($return_string) { |
|
352 | 352 | // because we want to return a string, we are going to capture the output |
353 | 353 | ob_start(); |
354 | - include( $template_path ); |
|
354 | + include($template_path); |
|
355 | 355 | return ob_get_clean(); |
356 | 356 | } else { |
357 | - include( $template_path ); |
|
357 | + include($template_path); |
|
358 | 358 | } |
359 | 359 | return ''; |
360 | 360 | } |
@@ -372,27 +372,27 @@ discard block |
||
372 | 372 | * @param string $suffix added to the end of the generated class |
373 | 373 | * @return string |
374 | 374 | */ |
375 | - public static function get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
375 | + public static function get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
376 | 376 | // in the beginning... |
377 | - $prefix = ! empty( $prefix ) ? rtrim( $prefix, '-' ) . '-' : ''; |
|
377 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : ''; |
|
378 | 378 | // da muddle |
379 | 379 | $class = ''; |
380 | 380 | // the end |
381 | - $suffix = ! empty( $suffix ) ? '-' . ltrim( $suffix, '-' ) : ''; |
|
381 | + $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : ''; |
|
382 | 382 | // is the passed object an EE object ? |
383 | - if ( $object instanceof EE_Base_Class ) { |
|
383 | + if ($object instanceof EE_Base_Class) { |
|
384 | 384 | // grab the exact type of object |
385 | - $obj_class = get_class( $object ); |
|
385 | + $obj_class = get_class($object); |
|
386 | 386 | // depending on the type of object... |
387 | - switch ( $obj_class ) { |
|
387 | + switch ($obj_class) { |
|
388 | 388 | // no specifics just yet... |
389 | 389 | default : |
390 | - $class = strtolower( str_replace( '_', '-', $obj_class )); |
|
391 | - $class .= method_exists( $obj_class, 'name' ) ? '-' . sanitize_title( $object->name() ) : ''; |
|
390 | + $class = strtolower(str_replace('_', '-', $obj_class)); |
|
391 | + $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : ''; |
|
392 | 392 | |
393 | 393 | } |
394 | 394 | } |
395 | - return $prefix . $class . $suffix; |
|
395 | + return $prefix.$class.$suffix; |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | |
@@ -408,50 +408,50 @@ discard block |
||
408 | 408 | * @param string $cur_code_span_class |
409 | 409 | * @return string the html output for the formatted money value |
410 | 410 | */ |
411 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ) { |
|
411 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code') { |
|
412 | 412 | // ensure amount was received |
413 | - if ( is_null( $amount ) ) { |
|
414 | - $msg = __( 'In order to format currency, an amount needs to be passed.', 'event_espresso' ); |
|
415 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
413 | + if (is_null($amount)) { |
|
414 | + $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
415 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
416 | 416 | return ''; |
417 | 417 | } |
418 | 418 | //ensure amount is float |
419 | 419 | $amount = (float) $amount; |
420 | 420 | // filter raw amount (allows 0.00 to be changed to "free" for example) |
421 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount', $amount, $return_raw ); |
|
421 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
422 | 422 | // still a number or was amount converted to a string like "free" ? |
423 | - if ( is_float( $amount_formatted )) { |
|
423 | + if (is_float($amount_formatted)) { |
|
424 | 424 | // was a country ISO code passed ? if so generate currency config object for that country |
425 | - $mny = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : NULL; |
|
425 | + $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : NULL; |
|
426 | 426 | // verify results |
427 | - if ( ! $mny instanceof EE_Currency_Config ) { |
|
427 | + if ( ! $mny instanceof EE_Currency_Config) { |
|
428 | 428 | // set default config country currency settings |
429 | 429 | $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
430 | 430 | } |
431 | 431 | // format float |
432 | - $amount_formatted = number_format( $amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds ); |
|
432 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
433 | 433 | // add formatting ? |
434 | - if ( ! $return_raw ) { |
|
434 | + if ( ! $return_raw) { |
|
435 | 435 | // add currency sign |
436 | - if( $mny->sign_b4 ){ |
|
437 | - if( $amount >= 0 ){ |
|
438 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
439 | - }else{ |
|
440 | - $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
|
436 | + if ($mny->sign_b4) { |
|
437 | + if ($amount >= 0) { |
|
438 | + $amount_formatted = $mny->sign.$amount_formatted; |
|
439 | + } else { |
|
440 | + $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted); |
|
441 | 441 | } |
442 | 442 | |
443 | - }else{ |
|
444 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
443 | + } else { |
|
444 | + $amount_formatted = $amount_formatted.$mny->sign; |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | // add currency code ? |
448 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
448 | + $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted; |
|
449 | 449 | } |
450 | 450 | // filter results |
451 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw ); |
|
451 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw); |
|
452 | 452 | } |
453 | 453 | // clean up vars |
454 | - unset( $mny ); |
|
454 | + unset($mny); |
|
455 | 455 | // return formatted currency amount |
456 | 456 | return $amount_formatted; |
457 | 457 | } |
@@ -466,11 +466,11 @@ discard block |
||
466 | 466 | * @param string $schema 'UPPER', 'lower', or 'Sentence' |
467 | 467 | * @return string The localized label for the status id. |
468 | 468 | */ |
469 | - public static function pretty_status( $status_id, $plural = FALSE, $schema = 'upper' ) { |
|
469 | + public static function pretty_status($status_id, $plural = FALSE, $schema = 'upper') { |
|
470 | 470 | /** @type EEM_Status $EEM_Status */ |
471 | - $EEM_Status = EE_Registry::instance()->load_model( 'Status' ); |
|
472 | - $status = $EEM_Status->localized_status( array( $status_id => __( 'unknown', 'event_espresso' )), $plural, $schema ); |
|
473 | - return $status[ $status_id ]; |
|
471 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
472 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, $schema); |
|
473 | + return $status[$status_id]; |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | |
@@ -483,9 +483,9 @@ discard block |
||
483 | 483 | * @param string $icon |
484 | 484 | * @return string the html output for the button |
485 | 485 | */ |
486 | - public static function get_button_or_link( $url, $label, $class = 'button-primary', $icon = '' ) { |
|
487 | - $label = ! empty( $icon ) ? '<span class="' . $icon . '"></span>' . $label : $label; |
|
488 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '">' . $label . '</a>'; |
|
486 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '') { |
|
487 | + $label = ! empty($icon) ? '<span class="'.$icon.'"></span>'.$label : $label; |
|
488 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'">'.$label.'</a>'; |
|
489 | 489 | return $button; |
490 | 490 | } |
491 | 491 | |
@@ -502,21 +502,21 @@ discard block |
||
502 | 502 | * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
503 | 503 | * @return string generated link |
504 | 504 | */ |
505 | - public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
|
505 | + public static function get_help_tab_link($help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE) { |
|
506 | 506 | |
507 | - if ( ! $page ) |
|
508 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
507 | + if ( ! $page) |
|
508 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
509 | 509 | |
510 | - if ( ! $action ) |
|
511 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
510 | + if ( ! $action) |
|
511 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
512 | 512 | |
513 | 513 | $action = empty($action) ? 'default' : $action; |
514 | 514 | |
515 | 515 | |
516 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
517 | - $icon = !$icon_style ? ' dashicons-editor-help' : $icon_style; |
|
518 | - $help_text = !$help_text ? '' : $help_text; |
|
519 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
516 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
517 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
518 | + $help_text = ! $help_text ? '' : $help_text; |
|
519 | + return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso').'" > '.$help_text.' </a>'; |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | |
@@ -528,31 +528,31 @@ discard block |
||
528 | 528 | * @param EE_Help_Tour |
529 | 529 | * @return string html |
530 | 530 | */ |
531 | - public static function help_tour_stops_generator( EE_Help_Tour $tour ) { |
|
531 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) { |
|
532 | 532 | $id = $tour->get_slug(); |
533 | 533 | $stops = $tour->get_stops(); |
534 | 534 | |
535 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
535 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
536 | 536 | |
537 | - foreach ( $stops as $stop ) { |
|
538 | - $data_id = !empty( $stop['id'] ) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
539 | - $data_class = empty( $data_id ) && !empty( $stop['class'] ) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
537 | + foreach ($stops as $stop) { |
|
538 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
539 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
540 | 540 | |
541 | 541 | //if container is set to modal then let's make sure we set the options accordingly |
542 | - if ( empty( $data_id ) && empty( $data_class ) ) { |
|
542 | + if (empty($data_id) && empty($data_class)) { |
|
543 | 543 | $stop['options']['modal'] = true; |
544 | 544 | $stop['options']['expose'] = true; |
545 | 545 | } |
546 | 546 | |
547 | - $custom_class = !empty( $stop['custom_class'] ) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
548 | - $button_text = !empty( $stop['button_text'] ) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
547 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
548 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
549 | 549 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
550 | 550 | |
551 | 551 | //options |
552 | - if ( isset( $stop['options'] ) && is_array( $stop['options'] ) ) { |
|
552 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
553 | 553 | $options = ' data-options="'; |
554 | - foreach ( $stop['options'] as $option => $value ) { |
|
555 | - $options .= $option . ':' . $value . ';'; |
|
554 | + foreach ($stop['options'] as $option => $value) { |
|
555 | + $options .= $option.':'.$value.';'; |
|
556 | 556 | } |
557 | 557 | $options .= '"'; |
558 | 558 | } else { |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | } |
561 | 561 | |
562 | 562 | //let's put all together |
563 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
563 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | $content .= '</ol>'; |
@@ -581,31 +581,31 @@ discard block |
||
581 | 581 | * @throws EE_Error |
582 | 582 | * @return string html structure for status. |
583 | 583 | */ |
584 | - public static function status_legend( $status_array, $active_status = '' ) { |
|
585 | - if ( !is_array( $status_array ) ) |
|
586 | - throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
584 | + public static function status_legend($status_array, $active_status = '') { |
|
585 | + if ( ! is_array($status_array)) |
|
586 | + throw new EE_Error(__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso')); |
|
587 | 587 | |
588 | 588 | $setup_array = array(); |
589 | - foreach ( $status_array as $item => $status ) { |
|
589 | + foreach ($status_array as $item => $status) { |
|
590 | 590 | $setup_array[$item] = array( |
591 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
592 | - 'desc' => EEH_Template::pretty_status( $status, FALSE, 'sentence' ), |
|
591 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
592 | + 'desc' => EEH_Template::pretty_status($status, FALSE, 'sentence'), |
|
593 | 593 | 'status' => $status |
594 | 594 | ); |
595 | 595 | } |
596 | 596 | |
597 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
598 | - $content .= '<h3>' . __('Status Legend', 'event_espresso') . '</h3>' . "\n"; |
|
599 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
600 | - foreach ( $setup_array as $item => $details ) { |
|
597 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
598 | + $content .= '<h3>'.__('Status Legend', 'event_espresso').'</h3>'."\n"; |
|
599 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
600 | + foreach ($setup_array as $item => $details) { |
|
601 | 601 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
602 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
603 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
604 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
605 | - $content .= '</dt>' . "\n"; |
|
602 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
603 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
604 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
605 | + $content .= '</dt>'."\n"; |
|
606 | 606 | } |
607 | - $content .= '</dl>' . "\n"; |
|
608 | - $content .= '</div>' . "\n"; |
|
607 | + $content .= '</dl>'."\n"; |
|
608 | + $content .= '</div>'."\n"; |
|
609 | 609 | return $content; |
610 | 610 | } |
611 | 611 | |
@@ -618,8 +618,8 @@ discard block |
||
618 | 618 | * @return string |
619 | 619 | */ |
620 | 620 | public static function layout_array_as_table($data) { |
621 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class ) { |
|
622 | - $data = (array)$data; |
|
621 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
622 | + $data = (array) $data; |
|
623 | 623 | } |
624 | 624 | EE_Registry::instance()->load_helper('Array'); |
625 | 625 | ob_start(); |
@@ -633,10 +633,10 @@ discard block |
||
633 | 633 | ?> |
634 | 634 | <tr> |
635 | 635 | <td> |
636 | - <?php echo $data_key;?> |
|
636 | + <?php echo $data_key; ?> |
|
637 | 637 | </td> |
638 | 638 | <td> |
639 | - <?php echo self::layout_array_as_table($data_values);?> |
|
639 | + <?php echo self::layout_array_as_table($data_values); ?> |
|
640 | 640 | </td> |
641 | 641 | </tr> |
642 | 642 | <?php |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | <ul> |
651 | 651 | <?php |
652 | 652 | foreach ($data as $datum) { |
653 | - echo "<li>"; echo self::layout_array_as_table($datum);echo "</li>"; |
|
653 | + echo "<li>"; echo self::layout_array_as_table($datum); echo "</li>"; |
|
654 | 654 | }?> |
655 | 655 | </ul> |
656 | 656 | <?php |
@@ -680,8 +680,8 @@ discard block |
||
680 | 680 | * |
681 | 681 | * @return string |
682 | 682 | */ |
683 | - public static function paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
684 | - echo self::get_paging_html( $total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label ); |
|
683 | + public static function paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
684 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label); |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | |
@@ -705,13 +705,13 @@ discard block |
||
705 | 705 | * ) |
706 | 706 | * @return string |
707 | 707 | */ |
708 | - public static function get_paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
708 | + public static function get_paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
709 | 709 | $page_links = array(); |
710 | 710 | $disable_first = $disable_last = ''; |
711 | 711 | $total_items = (int) $total_items; |
712 | 712 | $per_page = (int) $per_page; |
713 | 713 | $current = (int) $current; |
714 | - $paged_arg_name = empty( $paged_arg_name ) ? 'paged' : sanitize_key( $paged_arg_name ); |
|
714 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
715 | 715 | |
716 | 716 | //filter items_label |
717 | 717 | $items_label = apply_filters( |
@@ -719,68 +719,68 @@ discard block |
||
719 | 719 | $items_label |
720 | 720 | ); |
721 | 721 | |
722 | - if ( empty( $items_label ) |
|
723 | - || ! is_array( $items_label ) |
|
724 | - || ! isset( $items_label['single'] ) |
|
725 | - || ! isset( $items_label['plural'] ) ) { |
|
722 | + if (empty($items_label) |
|
723 | + || ! is_array($items_label) |
|
724 | + || ! isset($items_label['single']) |
|
725 | + || ! isset($items_label['plural'])) { |
|
726 | 726 | $items_label = array( |
727 | - 'single' => __( '1 item', 'event_espresso' ), |
|
728 | - 'plural' => __( '%s items', 'event_espresso' ) |
|
727 | + 'single' => __('1 item', 'event_espresso'), |
|
728 | + 'plural' => __('%s items', 'event_espresso') |
|
729 | 729 | ); |
730 | 730 | } else { |
731 | 731 | $items_label = array( |
732 | - 'single' => '1 ' . esc_html( $items_label['single'] ), |
|
733 | - 'plural' => '%s ' . esc_html( $items_label['plural'] ) |
|
732 | + 'single' => '1 '.esc_html($items_label['single']), |
|
733 | + 'plural' => '%s '.esc_html($items_label['plural']) |
|
734 | 734 | ); |
735 | 735 | } |
736 | 736 | |
737 | - $total_pages = ceil( $total_items / $per_page ); |
|
737 | + $total_pages = ceil($total_items / $per_page); |
|
738 | 738 | |
739 | - if ( $total_pages <= 1 ) |
|
739 | + if ($total_pages <= 1) |
|
740 | 740 | return ''; |
741 | 741 | |
742 | - $item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single']; |
|
742 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
743 | 743 | |
744 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
744 | + $output = '<span class="displaying-num">'.$item_label.'</span>'; |
|
745 | 745 | |
746 | - if ( $current === 1 ) { |
|
746 | + if ($current === 1) { |
|
747 | 747 | $disable_first = ' disabled'; |
748 | 748 | } |
749 | - if ( $current == $total_pages ) { |
|
749 | + if ($current == $total_pages) { |
|
750 | 750 | $disable_last = ' disabled'; |
751 | 751 | } |
752 | 752 | |
753 | - $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>", |
|
754 | - 'first-page' . $disable_first, |
|
755 | - esc_attr__( 'Go to the first page' ), |
|
756 | - esc_url( remove_query_arg( $paged_arg_name, $url ) ), |
|
753 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
754 | + 'first-page'.$disable_first, |
|
755 | + esc_attr__('Go to the first page'), |
|
756 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
757 | 757 | '«' |
758 | 758 | ); |
759 | 759 | |
760 | 760 | $page_links[] = sprintf( |
761 | 761 | '<a class="%s" title="%s" href="%s">%s</a>', |
762 | - 'prev-page' . $disable_first, |
|
763 | - esc_attr__( 'Go to the previous page' ), |
|
764 | - esc_url( add_query_arg( $paged_arg_name, max( 1, $current-1 ), $url ) ), |
|
762 | + 'prev-page'.$disable_first, |
|
763 | + esc_attr__('Go to the previous page'), |
|
764 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
765 | 765 | '‹' |
766 | 766 | ); |
767 | 767 | |
768 | - if ( ! $show_num_field ) { |
|
768 | + if ( ! $show_num_field) { |
|
769 | 769 | $html_current_page = $current; |
770 | 770 | } else { |
771 | - $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
772 | - esc_attr__( 'Current page' ), |
|
771 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
772 | + esc_attr__('Current page'), |
|
773 | 773 | $current, |
774 | - strlen( $total_pages ) |
|
774 | + strlen($total_pages) |
|
775 | 775 | ); |
776 | 776 | } |
777 | 777 | |
778 | 778 | $html_total_pages = sprintf( |
779 | 779 | '<span class="total-pages">%s</span>', |
780 | - number_format_i18n( $total_pages ) |
|
780 | + number_format_i18n($total_pages) |
|
781 | 781 | ); |
782 | 782 | $page_links[] = sprintf( |
783 | - _x( '%3$s%1$s of %2$s%4$s', 'paging' ), |
|
783 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
784 | 784 | $html_current_page, |
785 | 785 | $html_total_pages, |
786 | 786 | '<span class="paging-input">', |
@@ -789,29 +789,29 @@ discard block |
||
789 | 789 | |
790 | 790 | $page_links[] = sprintf( |
791 | 791 | '<a class="%s" title="%s" href="%s">%s</a>', |
792 | - 'next-page' . $disable_last, |
|
793 | - esc_attr__( 'Go to the next page' ), |
|
794 | - esc_url( add_query_arg( $paged_arg_name, min( $total_pages, $current+1 ), $url ) ), |
|
792 | + 'next-page'.$disable_last, |
|
793 | + esc_attr__('Go to the next page'), |
|
794 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
795 | 795 | '›' |
796 | 796 | ); |
797 | 797 | |
798 | 798 | $page_links[] = sprintf( |
799 | 799 | '<a class="%s" title="%s" href="%s">%s</a>', |
800 | - 'last-page' . $disable_last, |
|
801 | - esc_attr__( 'Go to the last page' ), |
|
802 | - esc_url( add_query_arg( $paged_arg_name, $total_pages, $url ) ), |
|
800 | + 'last-page'.$disable_last, |
|
801 | + esc_attr__('Go to the last page'), |
|
802 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
803 | 803 | '»' |
804 | 804 | ); |
805 | 805 | |
806 | - $output .= "\n" . '<span class="pagination-links">' . join( "\n", $page_links ) . '</span>'; |
|
806 | + $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>'; |
|
807 | 807 | // set page class |
808 | - if ( $total_pages ) { |
|
808 | + if ($total_pages) { |
|
809 | 809 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
810 | 810 | } else { |
811 | 811 | $page_class = ' no-pages'; |
812 | 812 | } |
813 | 813 | |
814 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
814 | + return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>'; |
|
815 | 815 | } |
816 | 816 | |
817 | 817 | |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | //add_filter( 'FHEE__EEH_Template__format_currency__amount', 'convert_zero_to_free', 10, 2 ); |
828 | 828 | |
829 | 829 | |
830 | -if ( ! function_exists( 'espresso_pagination' ) ) { |
|
830 | +if ( ! function_exists('espresso_pagination')) { |
|
831 | 831 | /** |
832 | 832 | * espresso_pagination |
833 | 833 | * |
@@ -839,21 +839,21 @@ discard block |
||
839 | 839 | $big = 999999999; // need an unlikely integer |
840 | 840 | $pagination = paginate_links( |
841 | 841 | array( |
842 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
842 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
843 | 843 | 'format' => '?paged=%#%', |
844 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
844 | + 'current' => max(1, get_query_var('paged')), |
|
845 | 845 | 'total' => $wp_query->max_num_pages, |
846 | 846 | 'show_all' => true, |
847 | 847 | 'end_size' => 10, |
848 | 848 | 'mid_size' => 6, |
849 | 849 | 'prev_next' => true, |
850 | - 'prev_text' => __( '‹ PREV', 'event_espresso' ), |
|
851 | - 'next_text' => __( 'NEXT ›', 'event_espresso' ), |
|
850 | + 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
851 | + 'next_text' => __('NEXT ›', 'event_espresso'), |
|
852 | 852 | 'type' => 'plain', |
853 | 853 | 'add_args' => false, |
854 | 854 | 'add_fragment' => '' |
855 | 855 | ) |
856 | 856 | ); |
857 | - echo ! empty( $pagination ) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
857 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : ''; |
|
858 | 858 | } |
859 | 859 | } |
860 | 860 | \ No newline at end of file |
@@ -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 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param mixed $info |
26 | 26 | * @return bool |
27 | 27 | */ |
28 | - public function add( $object, $info = null ); |
|
28 | + public function add($object, $info = null); |
|
29 | 29 | |
30 | 30 | |
31 | 31 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param mixed $info |
40 | 40 | * @return bool |
41 | 41 | */ |
42 | - public function set_info( $object, $info = null ); |
|
42 | + public function set_info($object, $info = null); |
|
43 | 43 | |
44 | 44 | |
45 | 45 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param mixed |
53 | 53 | * @return null | object |
54 | 54 | */ |
55 | - public function get_by_info( $info ); |
|
55 | + public function get_by_info($info); |
|
56 | 56 | |
57 | 57 | |
58 | 58 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param object $object |
66 | 66 | * @return bool |
67 | 67 | */ |
68 | - public function has( $object ); |
|
68 | + public function has($object); |
|
69 | 69 | |
70 | 70 | |
71 | 71 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param $object |
79 | 79 | * @return void |
80 | 80 | */ |
81 | - public function remove( $object ); |
|
81 | + public function remove($object); |
|
82 | 82 | |
83 | 83 | |
84 | 84 |
@@ -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 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @return bool | int |
31 | 31 | * @throws \EE_Error |
32 | 32 | */ |
33 | - public function persist( $persistence_callback = '', $persistence_arguments = array() ); |
|
33 | + public function persist($persistence_callback = '', $persistence_arguments = array()); |
|
34 | 34 | |
35 | 35 | |
36 | 36 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param string $persistence_callback name of method found on object that can be used for persisting it |
44 | 44 | * @return bool | int |
45 | 45 | */ |
46 | - public function persist_all( $persistence_callback = '' ); |
|
46 | + public function persist_all($persistence_callback = ''); |
|
47 | 47 | |
48 | 48 | } |
49 | 49 | // End of file EEI_Repository.interface.php |
@@ -3,13 +3,13 @@ |
||
3 | 3 | exit( 'No direct script access allowed' ); |
4 | 4 | } |
5 | 5 | /** |
6 | - * Class EEI_Line_Item |
|
7 | - * |
|
8 | - * @package Event Espresso |
|
9 | - * @subpackage core |
|
10 | - * @author Mike Nelson / Brent Christensen |
|
11 | - * |
|
12 | - */ |
|
6 | + * Class EEI_Line_Item |
|
7 | + * |
|
8 | + * @package Event Espresso |
|
9 | + * @subpackage core |
|
10 | + * @author Mike Nelson / Brent Christensen |
|
11 | + * |
|
12 | + */ |
|
13 | 13 | interface EEI_Line_Item { |
14 | 14 | |
15 | 15 | /** |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * Class EEI_Line_Item |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param mixed $field_value |
19 | 19 | * @param bool $use_default |
20 | 20 | */ |
21 | - public function set( $field_name, $field_value, $use_default = false ); |
|
21 | + public function set($field_name, $field_value, $use_default = false); |
|
22 | 22 | |
23 | 23 | |
24 | 24 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * Sets quantity |
57 | 57 | * @param int $quantity |
58 | 58 | */ |
59 | - function set_quantity( $quantity ); |
|
59 | + function set_quantity($quantity); |
|
60 | 60 | |
61 | 61 | |
62 | 62 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param int $txn_id if none is provided, assumes $this->TXN_ID() |
116 | 116 | * @return int count of items saved |
117 | 117 | */ |
118 | - function save_this_and_descendants_to_txn( $txn_id = null ); |
|
118 | + function save_this_and_descendants_to_txn($txn_id = null); |
|
119 | 119 | |
120 | 120 | |
121 | 121 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @param bool $set_order |
143 | 143 | * @return bool true for success, false for fail |
144 | 144 | */ |
145 | - function add_child_line_item( EEI_Line_Item $line_item, $set_order = true ); |
|
145 | + function add_child_line_item(EEI_Line_Item $line_item, $set_order = true); |
|
146 | 146 | |
147 | 147 | |
148 | 148 | |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | * @param float $total |
198 | 198 | * @return boolean |
199 | 199 | */ |
200 | - function set_total( $total ); |
|
200 | + function set_total($total); |
|
201 | 201 | |
202 | 202 | /** |
203 | 203 | * Sets unit_price |
204 | 204 | * @param float $unit_price |
205 | 205 | * @return boolean |
206 | 206 | */ |
207 | - function set_unit_price( $unit_price ); |
|
207 | + function set_unit_price($unit_price); |
|
208 | 208 | |
209 | 209 | /** |
210 | 210 | * If this line item has been saved to the DB, deletes its child with LIN_code == $code. If this line |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @param bool $stop_search_once_found |
216 | 216 | * @return int count of items deleted (or simply removed from the line item's cache, if not has not been saved to the DB yet) |
217 | 217 | */ |
218 | - function delete_child_line_item( $code, $stop_search_once_found = true ); |
|
218 | + function delete_child_line_item($code, $stop_search_once_found = true); |
|
219 | 219 | |
220 | 220 | /** |
221 | 221 | * Forgets the cached model of the given relation Name. So the next time we request it, |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @param boolean $allow_persist |
239 | 239 | * @return boolean |
240 | 240 | */ |
241 | - function set_allow_persist( $allow_persist ); |
|
241 | + function set_allow_persist($allow_persist); |
|
242 | 242 | |
243 | 243 | |
244 | 244 | } |