@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * Please use GetPaid_Notification_Email_Sender |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /* |
| 12 | 12 | |-------------------------------------------------------------------------- |
@@ -17,19 +17,19 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * Generates the email header. |
| 19 | 19 | */ |
| 20 | -function wpinv_email_header( $email_heading ) { |
|
| 21 | - wpinv_get_template( 'emails/wpinv-email-header.php', compact( 'email_heading' ) ); |
|
| 20 | +function wpinv_email_header($email_heading) { |
|
| 21 | + wpinv_get_template('emails/wpinv-email-header.php', compact('email_heading')); |
|
| 22 | 22 | } |
| 23 | -add_action( 'wpinv_email_header', 'wpinv_email_header' ); |
|
| 23 | +add_action('wpinv_email_header', 'wpinv_email_header'); |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * Generates the email footer. |
| 28 | 28 | */ |
| 29 | 29 | function wpinv_email_footer() { |
| 30 | - wpinv_get_template( 'emails/wpinv-email-footer.php' ); |
|
| 30 | + wpinv_get_template('emails/wpinv-email-footer.php'); |
|
| 31 | 31 | } |
| 32 | -add_action( 'wpinv_email_footer', 'wpinv_email_footer' ); |
|
| 32 | +add_action('wpinv_email_footer', 'wpinv_email_footer'); |
|
| 33 | 33 | |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -39,13 +39,13 @@ discard block |
||
| 39 | 39 | * @param string $email_type |
| 40 | 40 | * @param bool $sent_to_admin |
| 41 | 41 | */ |
| 42 | -function wpinv_email_invoice_details( $invoice, $email_type, $sent_to_admin ) { |
|
| 42 | +function wpinv_email_invoice_details($invoice, $email_type, $sent_to_admin) { |
|
| 43 | 43 | |
| 44 | - $args = compact( 'invoice', 'email_type', 'sent_to_admin' ); |
|
| 45 | - wpinv_get_template( 'emails/invoice-details.php', $args ); |
|
| 44 | + $args = compact('invoice', 'email_type', 'sent_to_admin'); |
|
| 45 | + wpinv_get_template('emails/invoice-details.php', $args); |
|
| 46 | 46 | |
| 47 | 47 | } |
| 48 | -add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 ); |
|
| 48 | +add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3); |
|
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * Display line items in emails. |
@@ -54,17 +54,17 @@ discard block |
||
| 54 | 54 | * @param string $email_type |
| 55 | 55 | * @param bool $sent_to_admin |
| 56 | 56 | */ |
| 57 | -function wpinv_email_invoice_items( $invoice, $email_type, $sent_to_admin ) { |
|
| 57 | +function wpinv_email_invoice_items($invoice, $email_type, $sent_to_admin) { |
|
| 58 | 58 | |
| 59 | 59 | // Prepare line items. |
| 60 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
| 61 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
| 60 | + $columns = getpaid_invoice_item_columns($invoice); |
|
| 61 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
| 62 | 62 | |
| 63 | 63 | // Load the template. |
| 64 | - wpinv_get_template( 'emails/invoice-items.php', compact( 'invoice', 'columns', 'email_type', 'sent_to_admin' ) ); |
|
| 64 | + wpinv_get_template('emails/invoice-items.php', compact('invoice', 'columns', 'email_type', 'sent_to_admin')); |
|
| 65 | 65 | |
| 66 | 66 | } |
| 67 | -add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 ); |
|
| 67 | +add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3); |
|
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -74,13 +74,13 @@ discard block |
||
| 74 | 74 | * @param string $email_type |
| 75 | 75 | * @param bool $sent_to_admin |
| 76 | 76 | */ |
| 77 | -function wpinv_email_billing_details( $invoice, $email_type, $sent_to_admin ) { |
|
| 77 | +function wpinv_email_billing_details($invoice, $email_type, $sent_to_admin) { |
|
| 78 | 78 | |
| 79 | - $args = compact( 'invoice', 'email_type', 'sent_to_admin' ); |
|
| 80 | - wpinv_get_template( 'emails/wpinv-email-billing-details.php', $args ); |
|
| 79 | + $args = compact('invoice', 'email_type', 'sent_to_admin'); |
|
| 80 | + wpinv_get_template('emails/wpinv-email-billing-details.php', $args); |
|
| 81 | 81 | |
| 82 | 82 | } |
| 83 | -add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 ); |
|
| 83 | +add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3); |
|
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * Returns email css. |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | function getpaid_get_email_css() { |
| 90 | 90 | |
| 91 | - $css = wpinv_get_template_html( 'emails/wpinv-email-styles.php' ); |
|
| 92 | - return apply_filters( 'wpinv_email_styles', $css ); |
|
| 91 | + $css = wpinv_get_template_html('emails/wpinv-email-styles.php'); |
|
| 92 | + return apply_filters('wpinv_email_styles', $css); |
|
| 93 | 93 | |
| 94 | 94 | } |
| 95 | 95 | |
@@ -100,26 +100,26 @@ discard block |
||
| 100 | 100 | * @return string |
| 101 | 101 | * |
| 102 | 102 | */ |
| 103 | -function wpinv_email_style_body( $content ) { |
|
| 103 | +function wpinv_email_style_body($content) { |
|
| 104 | 104 | |
| 105 | - if ( ! class_exists( 'DOMDocument' ) ) { |
|
| 105 | + if (!class_exists('DOMDocument')) { |
|
| 106 | 106 | return $content; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | $css = getpaid_get_email_css(); |
| 110 | 110 | |
| 111 | 111 | // include css inliner |
| 112 | - if ( ! class_exists( 'Emogrifier' ) ) { |
|
| 113 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
| 112 | + if (!class_exists('Emogrifier')) { |
|
| 113 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | // Inline the css. |
| 117 | 117 | try { |
| 118 | - $emogrifier = new Emogrifier( $content, $css ); |
|
| 118 | + $emogrifier = new Emogrifier($content, $css); |
|
| 119 | 119 | $_content = $emogrifier->emogrify(); |
| 120 | 120 | $content = $_content; |
| 121 | - } catch ( Exception $e ) { |
|
| 122 | - wpinv_error_log( $e->getMessage(), 'emogrifier' ); |
|
| 121 | + } catch (Exception $e) { |
|
| 122 | + wpinv_error_log($e->getMessage(), 'emogrifier'); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | return $content; |
@@ -128,37 +128,37 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | // Backwards compatibility. |
| 130 | 130 | function wpinv_init_transactional_emails() { |
| 131 | - foreach ( apply_filters( 'wpinv_email_actions', array() ) as $action ) { |
|
| 132 | - add_action( $action, 'wpinv_send_transactional_email', 10, 10 ); |
|
| 131 | + foreach (apply_filters('wpinv_email_actions', array()) as $action) { |
|
| 132 | + add_action($action, 'wpinv_send_transactional_email', 10, 10); |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | -add_action( 'init', 'wpinv_init_transactional_emails' ); |
|
| 135 | +add_action('init', 'wpinv_init_transactional_emails'); |
|
| 136 | 136 | |
| 137 | 137 | function wpinv_send_transactional_email() { |
| 138 | 138 | $args = func_get_args(); |
| 139 | 139 | $function = current_filter() . '_notification'; |
| 140 | - do_action_ref_array( $function, $args ); |
|
| 140 | + do_action_ref_array($function, $args); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | function wpinv_mail_get_from_address() { |
| 144 | - $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from', get_option( 'admin_email' ) ) ); |
|
| 145 | - return sanitize_email( $from_address ); |
|
| 144 | + $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from', get_option('admin_email'))); |
|
| 145 | + return sanitize_email($from_address); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | function wpinv_mail_get_from_name() { |
| 149 | - $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name', get_bloginfo( 'name', 'display' ) ) ); |
|
| 150 | - return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES ); |
|
| 149 | + $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name', get_bloginfo('name', 'display'))); |
|
| 150 | + return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | -function wpinv_mail_admin_bcc_active( $mail_type = '' ) { |
|
| 154 | - $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) ); |
|
| 155 | - return ( $active ? true : false ); |
|
| 153 | +function wpinv_mail_admin_bcc_active($mail_type = '') { |
|
| 154 | + $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc')); |
|
| 155 | + return ($active ? true : false); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | -function wpinv_mail_get_content_type( $content_type = 'text/html', $email_type = 'html' ) { |
|
| 159 | - $email_type = apply_filters( 'wpinv_mail_content_type', $email_type ); |
|
| 158 | +function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') { |
|
| 159 | + $email_type = apply_filters('wpinv_mail_content_type', $email_type); |
|
| 160 | 160 | |
| 161 | - switch ( $email_type ) { |
|
| 161 | + switch ($email_type) { |
|
| 162 | 162 | case 'html' : |
| 163 | 163 | $content_type = 'text/html'; |
| 164 | 164 | break; |
@@ -183,11 +183,11 @@ discard block |
||
| 183 | 183 | * @param array $attachments Any files to attach to the email. |
| 184 | 184 | * @param string|array $cc An email or array of extra emails to send a copy of the email to. |
| 185 | 185 | */ |
| 186 | -function wpinv_mail_send( $to, $subject, $message, $deprecated, $attachments = array(), $cc = array() ) { |
|
| 186 | +function wpinv_mail_send($to, $subject, $message, $deprecated, $attachments = array(), $cc = array()) { |
|
| 187 | 187 | |
| 188 | 188 | $mailer = new GetPaid_Notification_Email_Sender(); |
| 189 | - $message = wpinv_email_style_body( $message ); |
|
| 190 | - $to = array_merge( wpinv_parse_list( $to ), wpinv_parse_list( $cc ) ); |
|
| 189 | + $message = wpinv_email_style_body($message); |
|
| 190 | + $to = array_merge(wpinv_parse_list($to), wpinv_parse_list($cc)); |
|
| 191 | 191 | |
| 192 | 192 | return $mailer->send( |
| 193 | 193 | $to, |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | * @return array |
| 205 | 205 | */ |
| 206 | 206 | function wpinv_get_emails() { |
| 207 | - return apply_filters( 'wpinv_get_emails', wpinv_get_data( 'email-settings' ) ); |
|
| 207 | + return apply_filters('wpinv_get_emails', wpinv_get_data('email-settings')); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -213,172 +213,172 @@ discard block |
||
| 213 | 213 | * @param array $settings |
| 214 | 214 | * @return array |
| 215 | 215 | */ |
| 216 | -function wpinv_settings_emails( $settings = array() ) { |
|
| 217 | - $settings = array_merge( $settings, wpinv_get_emails() ); |
|
| 218 | - return apply_filters( 'wpinv_settings_get_emails', $settings ); |
|
| 216 | +function wpinv_settings_emails($settings = array()) { |
|
| 217 | + $settings = array_merge($settings, wpinv_get_emails()); |
|
| 218 | + return apply_filters('wpinv_settings_get_emails', $settings); |
|
| 219 | 219 | } |
| 220 | -add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 ); |
|
| 220 | +add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1); |
|
| 221 | 221 | |
| 222 | 222 | /** |
| 223 | 223 | * Filter email section names. |
| 224 | 224 | * |
| 225 | 225 | */ |
| 226 | -function wpinv_settings_sections_emails( $settings ) { |
|
| 227 | - foreach ( wpinv_get_emails() as $key => $email) { |
|
| 228 | - $settings[$key] = ! empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : strip_tags( $key ); |
|
| 226 | +function wpinv_settings_sections_emails($settings) { |
|
| 227 | + foreach (wpinv_get_emails() as $key => $email) { |
|
| 228 | + $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : strip_tags($key); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | return $settings; |
| 232 | 232 | } |
| 233 | -add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 ); |
|
| 233 | +add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1); |
|
| 234 | 234 | |
| 235 | -function wpinv_email_is_enabled( $email_type ) { |
|
| 235 | +function wpinv_email_is_enabled($email_type) { |
|
| 236 | 236 | $emails = wpinv_get_emails(); |
| 237 | - $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false; |
|
| 237 | + $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false; |
|
| 238 | 238 | |
| 239 | - return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type ); |
|
| 239 | + return apply_filters('wpinv_email_is_enabled', $enabled, $email_type); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | -function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 243 | - switch ( $email_type ) { |
|
| 242 | +function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 243 | + switch ($email_type) { |
|
| 244 | 244 | case 'new_invoice': |
| 245 | 245 | case 'cancelled_invoice': |
| 246 | 246 | case 'failed_invoice': |
| 247 | 247 | $recipient = wpinv_get_admin_email(); |
| 248 | 248 | break; |
| 249 | 249 | default: |
| 250 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
| 251 | - $recipient = !empty( $invoice ) ? $invoice->get_email() : ''; |
|
| 250 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
| 251 | + $recipient = !empty($invoice) ? $invoice->get_email() : ''; |
|
| 252 | 252 | break; |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice ); |
|
| 255 | + return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | /** |
| 259 | 259 | * Returns invoice CC recipients |
| 260 | 260 | */ |
| 261 | -function wpinv_email_get_cc_recipients( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 262 | - switch ( $email_type ) { |
|
| 261 | +function wpinv_email_get_cc_recipients($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 262 | + switch ($email_type) { |
|
| 263 | 263 | case 'new_invoice': |
| 264 | 264 | case 'cancelled_invoice': |
| 265 | 265 | case 'failed_invoice': |
| 266 | 266 | return array(); |
| 267 | 267 | break; |
| 268 | 268 | default: |
| 269 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
| 270 | - $recipient = empty( $invoice ) ? '' : get_post_meta( $invoice->ID, 'wpinv_email_cc', true ); |
|
| 271 | - if ( empty( $recipient ) ) { |
|
| 269 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
| 270 | + $recipient = empty($invoice) ? '' : get_post_meta($invoice->ID, 'wpinv_email_cc', true); |
|
| 271 | + if (empty($recipient)) { |
|
| 272 | 272 | return array(); |
| 273 | 273 | } |
| 274 | - return array_filter( array_map( 'trim', explode( ',', $recipient ) ) ); |
|
| 274 | + return array_filter(array_map('trim', explode(',', $recipient))); |
|
| 275 | 275 | break; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | -function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 281 | - $subject = wpinv_get_option( 'email_' . $email_type . '_subject' ); |
|
| 282 | - $subject = __( $subject, 'invoicing' ); |
|
| 280 | +function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 281 | + $subject = wpinv_get_option('email_' . $email_type . '_subject'); |
|
| 282 | + $subject = __($subject, 'invoicing'); |
|
| 283 | 283 | |
| 284 | - $subject = wpinv_email_format_text( $subject, $invoice ); |
|
| 284 | + $subject = wpinv_email_format_text($subject, $invoice); |
|
| 285 | 285 | |
| 286 | - return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice ); |
|
| 286 | + return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | -function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 290 | - $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' ); |
|
| 291 | - $email_heading = __( $email_heading, 'invoicing' ); |
|
| 289 | +function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 290 | + $email_heading = wpinv_get_option('email_' . $email_type . '_heading'); |
|
| 291 | + $email_heading = __($email_heading, 'invoicing'); |
|
| 292 | 292 | |
| 293 | - $email_heading = wpinv_email_format_text( $email_heading, $invoice ); |
|
| 293 | + $email_heading = wpinv_email_format_text($email_heading, $invoice); |
|
| 294 | 294 | |
| 295 | - return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice ); |
|
| 295 | + return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | -function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 299 | - $content = wpinv_get_option( 'email_' . $email_type . '_body' ); |
|
| 300 | - $content = __( $content, 'invoicing' ); |
|
| 298 | +function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 299 | + $content = wpinv_get_option('email_' . $email_type . '_body'); |
|
| 300 | + $content = __($content, 'invoicing'); |
|
| 301 | 301 | |
| 302 | - $content = wpinv_email_format_text( $content, $invoice ); |
|
| 302 | + $content = wpinv_email_format_text($content, $invoice); |
|
| 303 | 303 | |
| 304 | - return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice ); |
|
| 304 | + return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | -function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 307 | +function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 308 | 308 | $from_name = wpinv_mail_get_from_address(); |
| 309 | 309 | $from_email = wpinv_mail_get_from_address(); |
| 310 | 310 | |
| 311 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
| 311 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
| 312 | 312 | |
| 313 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
| 314 | - $headers .= "Reply-To: ". $from_email . "\r\n"; |
|
| 313 | + $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n"; |
|
| 314 | + $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
| 315 | 315 | $headers .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n"; |
| 316 | 316 | |
| 317 | - return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice ); |
|
| 317 | + return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | -function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 320 | +function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 321 | 321 | $attachments = array(); |
| 322 | 322 | |
| 323 | - return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice ); |
|
| 323 | + return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | /** |
| 327 | 327 | * Searches for and replaces certain placeholders in an email. |
| 328 | 328 | */ |
| 329 | -function wpinv_email_format_text( $content, $invoice ) { |
|
| 329 | +function wpinv_email_format_text($content, $invoice) { |
|
| 330 | 330 | |
| 331 | 331 | $replace_array = array( |
| 332 | 332 | '{site_title}' => wpinv_get_blogname(), |
| 333 | - '{date}' => getpaid_format_date( current_time( 'mysql' ) ), |
|
| 333 | + '{date}' => getpaid_format_date(current_time('mysql')), |
|
| 334 | 334 | ); |
| 335 | 335 | |
| 336 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 336 | + $invoice = new WPInv_Invoice($invoice); |
|
| 337 | 337 | |
| 338 | - if ( $invoice->get_id() ) { |
|
| 338 | + if ($invoice->get_id()) { |
|
| 339 | 339 | |
| 340 | 340 | $replace_array = array_merge( |
| 341 | 341 | $replace_array, |
| 342 | 342 | array( |
| 343 | - '{name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
| 344 | - '{full_name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
| 345 | - '{first_name}' => sanitize_text_field( $invoice->get_first_name() ), |
|
| 346 | - '{last_name}' => sanitize_text_field( $invoice->get_last_name() ), |
|
| 347 | - '{email}' => sanitize_email( $invoice->get_email() ), |
|
| 348 | - '{invoice_number}' => sanitize_text_field( $invoice->get_number() ), |
|
| 349 | - '{invoice_total}' => sanitize_text_field( wpinv_price( $invoice->get_total( true ), $invoice->get_currency() ) ), |
|
| 350 | - '{invoice_link}' => esc_url( $invoice->get_view_url() ), |
|
| 351 | - '{invoice_pay_link}'=> esc_url( $invoice->get_checkout_payment_url() ), |
|
| 352 | - '{invoice_date}' => date( get_option( 'date_format' ), strtotime( $invoice->get_date_created(), current_time( 'timestamp' ) ) ), |
|
| 353 | - '{invoice_due_date}'=> date( get_option( 'date_format' ), strtotime( $invoice->get_due_date(), current_time( 'timestamp' ) ) ), |
|
| 354 | - '{invoice_quote}' => sanitize_text_field( $invoice->get_invoice_quote_type() ), |
|
| 355 | - '{invoice_label}' => sanitize_text_field( ucfirst( $invoice->get_invoice_quote_type() ) ), |
|
| 356 | - '{is_was}' => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ), |
|
| 343 | + '{name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
| 344 | + '{full_name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
| 345 | + '{first_name}' => sanitize_text_field($invoice->get_first_name()), |
|
| 346 | + '{last_name}' => sanitize_text_field($invoice->get_last_name()), |
|
| 347 | + '{email}' => sanitize_email($invoice->get_email()), |
|
| 348 | + '{invoice_number}' => sanitize_text_field($invoice->get_number()), |
|
| 349 | + '{invoice_total}' => sanitize_text_field(wpinv_price($invoice->get_total(true), $invoice->get_currency())), |
|
| 350 | + '{invoice_link}' => esc_url($invoice->get_view_url()), |
|
| 351 | + '{invoice_pay_link}'=> esc_url($invoice->get_checkout_payment_url()), |
|
| 352 | + '{invoice_date}' => date(get_option('date_format'), strtotime($invoice->get_date_created(), current_time('timestamp'))), |
|
| 353 | + '{invoice_due_date}'=> date(get_option('date_format'), strtotime($invoice->get_due_date(), current_time('timestamp'))), |
|
| 354 | + '{invoice_quote}' => sanitize_text_field($invoice->get_invoice_quote_type()), |
|
| 355 | + '{invoice_label}' => sanitize_text_field(ucfirst($invoice->get_invoice_quote_type())), |
|
| 356 | + '{is_was}' => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'), |
|
| 357 | 357 | ) |
| 358 | 358 | ); |
| 359 | 359 | |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | // Let third party plugins filter the arra. |
| 363 | - $replace_array = apply_filters( 'wpinv_email_format_text', $replace_array, $content, $invoice ); |
|
| 363 | + $replace_array = apply_filters('wpinv_email_format_text', $replace_array, $content, $invoice); |
|
| 364 | 364 | |
| 365 | - foreach ( $replace_array as $key => $value ) { |
|
| 366 | - $content = str_replace( $key, $value, $content ); |
|
| 365 | + foreach ($replace_array as $key => $value) { |
|
| 366 | + $content = str_replace($key, $value, $content); |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - return apply_filters( 'wpinv_email_content_replace', $content ); |
|
| 369 | + return apply_filters('wpinv_email_content_replace', $content); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | |
| 373 | -function wpinv_email_wrap_message( $message ) { |
|
| 373 | +function wpinv_email_wrap_message($message) { |
|
| 374 | 374 | // Buffer |
| 375 | 375 | ob_start(); |
| 376 | 376 | |
| 377 | - do_action( 'wpinv_email_header' ); |
|
| 377 | + do_action('wpinv_email_header'); |
|
| 378 | 378 | |
| 379 | - echo wpautop( wptexturize( $message ) ); |
|
| 379 | + echo wpautop(wptexturize($message)); |
|
| 380 | 380 | |
| 381 | - do_action( 'wpinv_email_footer' ); |
|
| 381 | + do_action('wpinv_email_footer'); |
|
| 382 | 382 | |
| 383 | 383 | // Get contents |
| 384 | 384 | $message = ob_get_clean(); |
@@ -386,21 +386,21 @@ discard block |
||
| 386 | 386 | return $message; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | -function wpinv_add_notes_to_invoice_email( $invoice, $email_type ) { |
|
| 390 | - if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->get_id(), true ) ) { |
|
| 391 | - $date_format = get_option( 'date_format' ); |
|
| 392 | - $time_format = get_option( 'time_format' ); |
|
| 389 | +function wpinv_add_notes_to_invoice_email($invoice, $email_type) { |
|
| 390 | + if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->get_id(), true)) { |
|
| 391 | + $date_format = get_option('date_format'); |
|
| 392 | + $time_format = get_option('time_format'); |
|
| 393 | 393 | ?> |
| 394 | 394 | <div id="wpinv-email-notes"> |
| 395 | - <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3> |
|
| 395 | + <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3> |
|
| 396 | 396 | <ol class="wpinv-notes-lists"> |
| 397 | 397 | <?php |
| 398 | - foreach ( $invoice_notes as $note ) { |
|
| 399 | - $note_time = strtotime( $note->comment_date ); |
|
| 398 | + foreach ($invoice_notes as $note) { |
|
| 399 | + $note_time = strtotime($note->comment_date); |
|
| 400 | 400 | ?> |
| 401 | 401 | <li class="comment wpinv-note"> |
| 402 | - <p class="wpinv-note-date meta"><?php printf( __( '%2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( $date_format, $note_time ), date_i18n( $time_format, $note_time ), $note_time ); ?></p> |
|
| 403 | - <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div> |
|
| 402 | + <p class="wpinv-note-date meta"><?php printf(__('%2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n($date_format, $note_time), date_i18n($time_format, $note_time), $note_time); ?></p> |
|
| 403 | + <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div> |
|
| 404 | 404 | </li> |
| 405 | 405 | <?php |
| 406 | 406 | } |
@@ -409,4 +409,4 @@ discard block |
||
| 409 | 409 | <?php |
| 410 | 410 | } |
| 411 | 411 | } |
| 412 | -add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 ); |
|
| 412 | +add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3); |
|
@@ -7,15 +7,15 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | function wpinv_get_default_country() { |
| 16 | - $country = wpinv_get_option( 'default_country', 'UK' ); |
|
| 16 | + $country = wpinv_get_option('default_country', 'UK'); |
|
| 17 | 17 | |
| 18 | - return apply_filters( 'wpinv_default_country', $country ); |
|
| 18 | + return apply_filters('wpinv_default_country', $country); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return string |
| 25 | 25 | */ |
| 26 | -function getpaid_get_ip_country( $ip_address = '' ) { |
|
| 27 | - $country = GetPaid_Geolocation::geolocate_ip( $ip_address, true ); |
|
| 26 | +function getpaid_get_ip_country($ip_address = '') { |
|
| 27 | + $country = GetPaid_Geolocation::geolocate_ip($ip_address, true); |
|
| 28 | 28 | return $country['country']; |
| 29 | 29 | } |
| 30 | 30 | |
@@ -34,59 +34,59 @@ discard block |
||
| 34 | 34 | * @param string $country The country code to sanitize |
| 35 | 35 | * @return array |
| 36 | 36 | */ |
| 37 | -function wpinv_sanitize_country( $country ) { |
|
| 37 | +function wpinv_sanitize_country($country) { |
|
| 38 | 38 | |
| 39 | 39 | // Enure the country is specified |
| 40 | - if ( empty( $country ) ) { |
|
| 40 | + if (empty($country)) { |
|
| 41 | 41 | $country = wpinv_get_default_country(); |
| 42 | 42 | } |
| 43 | - return trim( wpinv_utf8_strtoupper( $country ) ); |
|
| 43 | + return trim(wpinv_utf8_strtoupper($country)); |
|
| 44 | 44 | |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | -function wpinv_is_base_country( $country ) { |
|
| 47 | +function wpinv_is_base_country($country) { |
|
| 48 | 48 | $base_country = wpinv_get_default_country(); |
| 49 | 49 | |
| 50 | - if ( $base_country === 'UK' ) { |
|
| 50 | + if ($base_country === 'UK') { |
|
| 51 | 51 | $base_country = 'GB'; |
| 52 | 52 | } |
| 53 | - if ( $country == 'UK' ) { |
|
| 53 | + if ($country == 'UK') { |
|
| 54 | 54 | $country = 'GB'; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - return ( $country && $country === $base_country ) ? true : false; |
|
| 57 | + return ($country && $country === $base_country) ? true : false; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | -function wpinv_country_name( $country_code = '' ) { |
|
| 60 | +function wpinv_country_name($country_code = '') { |
|
| 61 | 61 | $countries = wpinv_get_country_list(); |
| 62 | 62 | $country_code = $country_code == 'UK' ? 'GB' : $country_code; |
| 63 | - $country = isset( $countries[$country_code] ) ? $countries[$country_code] : $country_code; |
|
| 63 | + $country = isset($countries[$country_code]) ? $countries[$country_code] : $country_code; |
|
| 64 | 64 | |
| 65 | - return apply_filters( 'wpinv_country_name', $country, $country_code ); |
|
| 65 | + return apply_filters('wpinv_country_name', $country, $country_code); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | function wpinv_get_default_state() { |
| 69 | - $state = wpinv_get_option( 'default_state', '' ); |
|
| 69 | + $state = wpinv_get_option('default_state', ''); |
|
| 70 | 70 | |
| 71 | - return apply_filters( 'wpinv_default_state', $state ); |
|
| 71 | + return apply_filters('wpinv_default_state', $state); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | -function wpinv_state_name( $state_code = '', $country_code = '' ) { |
|
| 74 | +function wpinv_state_name($state_code = '', $country_code = '') { |
|
| 75 | 75 | $state = $state_code; |
| 76 | 76 | |
| 77 | - if ( !empty( $country_code ) ) { |
|
| 78 | - $states = wpinv_get_country_states( $country_code ); |
|
| 77 | + if (!empty($country_code)) { |
|
| 78 | + $states = wpinv_get_country_states($country_code); |
|
| 79 | 79 | |
| 80 | - $state = !empty( $states ) && isset( $states[$state_code] ) ? $states[$state_code] : $state; |
|
| 80 | + $state = !empty($states) && isset($states[$state_code]) ? $states[$state_code] : $state; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - return apply_filters( 'wpinv_state_name', $state, $state_code, $country_code ); |
|
| 83 | + return apply_filters('wpinv_state_name', $state, $state_code, $country_code); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | function wpinv_store_address() { |
| 87 | - $address = wpinv_get_option( 'store_address', '' ); |
|
| 87 | + $address = wpinv_get_option('store_address', ''); |
|
| 88 | 88 | |
| 89 | - return apply_filters( 'wpinv_store_address', $address ); |
|
| 89 | + return apply_filters('wpinv_store_address', $address); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -94,24 +94,24 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @param WPInv_Invoice $invoice |
| 96 | 96 | */ |
| 97 | -function getpaid_maybe_add_default_address( &$invoice ) { |
|
| 97 | +function getpaid_maybe_add_default_address(&$invoice) { |
|
| 98 | 98 | |
| 99 | 99 | $user_id = $invoice->get_user_id(); |
| 100 | 100 | |
| 101 | 101 | // Abort if the invoice belongs to no one. |
| 102 | - if ( empty( $user_id ) ) { |
|
| 102 | + if (empty($user_id)) { |
|
| 103 | 103 | return; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | // Fill in defaults whenever necessary. |
| 107 | - foreach ( wpinv_get_user_address( $user_id ) as $key => $value ) { |
|
| 107 | + foreach (wpinv_get_user_address($user_id) as $key => $value) { |
|
| 108 | 108 | |
| 109 | - if ( is_callable( $invoice, "get_$key" ) ) { |
|
| 110 | - $current = call_user_func( array( $invoice, "get_$key" ) ); |
|
| 109 | + if (is_callable($invoice, "get_$key")) { |
|
| 110 | + $current = call_user_func(array($invoice, "get_$key")); |
|
| 111 | 111 | |
| 112 | - if ( empty( $current ) ) { |
|
| 112 | + if (empty($current)) { |
|
| 113 | 113 | $method = "set_$key"; |
| 114 | - $invoice->$method( $value ); |
|
| 114 | + $invoice->$method($value); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | } |
@@ -130,21 +130,21 @@ discard block |
||
| 130 | 130 | $address_fields = apply_filters( |
| 131 | 131 | 'getpaid_user_address_fields', |
| 132 | 132 | array( |
| 133 | - 'first_name' => __( 'First Name', 'invoicing' ), |
|
| 134 | - 'last_name' => __( 'Last Name', 'invoicing' ), |
|
| 135 | - 'country' => __( 'Country', 'invoicing' ), |
|
| 136 | - 'state' => __( 'State', 'invoicing' ), |
|
| 137 | - 'city' => __( 'City', 'invoicing' ), |
|
| 138 | - 'zip' => __( 'Zip/Postal Code', 'invoicing' ), |
|
| 139 | - 'address' => __( 'Address', 'invoicing' ), |
|
| 140 | - 'phone' => __( 'Phone Number', 'invoicing' ), |
|
| 141 | - 'company' => __( 'Company', 'invoicing' ), |
|
| 142 | - 'vat_number' => __( 'VAT Number', 'invoicing' ), |
|
| 133 | + 'first_name' => __('First Name', 'invoicing'), |
|
| 134 | + 'last_name' => __('Last Name', 'invoicing'), |
|
| 135 | + 'country' => __('Country', 'invoicing'), |
|
| 136 | + 'state' => __('State', 'invoicing'), |
|
| 137 | + 'city' => __('City', 'invoicing'), |
|
| 138 | + 'zip' => __('Zip/Postal Code', 'invoicing'), |
|
| 139 | + 'address' => __('Address', 'invoicing'), |
|
| 140 | + 'phone' => __('Phone Number', 'invoicing'), |
|
| 141 | + 'company' => __('Company', 'invoicing'), |
|
| 142 | + 'vat_number' => __('VAT Number', 'invoicing'), |
|
| 143 | 143 | ) |
| 144 | 144 | ); |
| 145 | 145 | |
| 146 | - if ( ! wpinv_use_taxes() && isset( $address_fields['vat_number'] ) ) { |
|
| 147 | - unset( $address_fields['vat_number'] ); |
|
| 146 | + if (!wpinv_use_taxes() && isset($address_fields['vat_number'])) { |
|
| 147 | + unset($address_fields['vat_number']); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | return $address_fields; |
@@ -155,8 +155,8 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @return bool |
| 157 | 157 | */ |
| 158 | -function getpaid_is_address_field_whitelisted( $key ) { |
|
| 159 | - return array_key_exists( $key, getpaid_user_address_fields() ); |
|
| 158 | +function getpaid_is_address_field_whitelisted($key) { |
|
| 159 | + return array_key_exists($key, getpaid_user_address_fields()); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -166,24 +166,24 @@ discard block |
||
| 166 | 166 | * |
| 167 | 167 | * @param WPInv_Invoice $invoice |
| 168 | 168 | */ |
| 169 | -function getpaid_save_invoice_user_address( $invoice ) { |
|
| 169 | +function getpaid_save_invoice_user_address($invoice) { |
|
| 170 | 170 | |
| 171 | 171 | // Retrieve the invoice. |
| 172 | - $invoice = wpinv_get_invoice( $invoice ); |
|
| 172 | + $invoice = wpinv_get_invoice($invoice); |
|
| 173 | 173 | |
| 174 | 174 | // Abort if it does not exist. |
| 175 | - if ( empty( $invoice ) ) { |
|
| 175 | + if (empty($invoice)) { |
|
| 176 | 176 | return; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
| 179 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
| 180 | 180 | |
| 181 | - if ( is_callable( array( $invoice, "get_$field" ) ) ) { |
|
| 182 | - $value = call_user_func( array( $invoice, "get_$field" ) ); |
|
| 181 | + if (is_callable(array($invoice, "get_$field"))) { |
|
| 182 | + $value = call_user_func(array($invoice, "get_$field")); |
|
| 183 | 183 | |
| 184 | 184 | // Only save if it is not empty. |
| 185 | - if ( ! empty( $value ) ) { |
|
| 186 | - update_user_meta( $invoice->get_user_id(), '_wpinv_' . $field, $value ); |
|
| 185 | + if (!empty($value)) { |
|
| 186 | + update_user_meta($invoice->get_user_id(), '_wpinv_' . $field, $value); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | } |
@@ -191,8 +191,8 @@ discard block |
||
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | } |
| 194 | -add_action( 'getpaid_new_invoice', 'getpaid_save_invoice_user_address' ); |
|
| 195 | -add_action( 'getpaid_update_invoice', 'getpaid_save_invoice_user_address' ); |
|
| 194 | +add_action('getpaid_new_invoice', 'getpaid_save_invoice_user_address'); |
|
| 195 | +add_action('getpaid_update_invoice', 'getpaid_save_invoice_user_address'); |
|
| 196 | 196 | |
| 197 | 197 | /** |
| 198 | 198 | * Retrieves a saved user address. |
@@ -201,14 +201,14 @@ discard block |
||
| 201 | 201 | * @param bool $with_default Whether or not we should use the default country and state. |
| 202 | 202 | * @return array |
| 203 | 203 | */ |
| 204 | -function wpinv_get_user_address( $user_id = 0, $with_default = true ) { |
|
| 204 | +function wpinv_get_user_address($user_id = 0, $with_default = true) { |
|
| 205 | 205 | |
| 206 | 206 | // Prepare the user id. |
| 207 | - $user_id = empty( $user_id ) ? get_current_user_id() : $user_id; |
|
| 208 | - $user_info = get_userdata( $user_id ); |
|
| 207 | + $user_id = empty($user_id) ? get_current_user_id() : $user_id; |
|
| 208 | + $user_info = get_userdata($user_id); |
|
| 209 | 209 | |
| 210 | 210 | // Abort if non exists. |
| 211 | - if ( empty( $user_info ) ) { |
|
| 211 | + if (empty($user_info)) { |
|
| 212 | 212 | return array(); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -218,11 +218,11 @@ discard block |
||
| 218 | 218 | 'email' => $user_info->user_email, |
| 219 | 219 | ); |
| 220 | 220 | |
| 221 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
| 222 | - $address[$field] = getpaid_get_user_address_field( $user_id, $field ); |
|
| 221 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
| 222 | + $address[$field] = getpaid_get_user_address_field($user_id, $field); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - if ( ! $with_default ) { |
|
| 225 | + if (!$with_default) { |
|
| 226 | 226 | return $address; |
| 227 | 227 | } |
| 228 | 228 | |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | 'country' => wpinv_get_default_country(), |
| 234 | 234 | ); |
| 235 | 235 | |
| 236 | - return getpaid_array_merge_if_empty( $address, $defaults ); |
|
| 236 | + return getpaid_array_merge_if_empty($address, $defaults); |
|
| 237 | 237 | |
| 238 | 238 | } |
| 239 | 239 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | * @param string $field The field to use. |
| 245 | 245 | * @return string|null |
| 246 | 246 | */ |
| 247 | -function getpaid_get_user_address_field( $user_id, $field ) { |
|
| 247 | +function getpaid_get_user_address_field($user_id, $field) { |
|
| 248 | 248 | |
| 249 | 249 | $prefixes = array( |
| 250 | 250 | '_wpinv_', |
@@ -252,15 +252,15 @@ discard block |
||
| 252 | 252 | '' |
| 253 | 253 | ); |
| 254 | 254 | |
| 255 | - foreach ( $prefixes as $prefix ) { |
|
| 255 | + foreach ($prefixes as $prefix) { |
|
| 256 | 256 | |
| 257 | 257 | // Meta table. |
| 258 | - $value = get_user_meta( $user_id, $prefix . $field, true ); |
|
| 258 | + $value = get_user_meta($user_id, $prefix . $field, true); |
|
| 259 | 259 | |
| 260 | 260 | // UWP table. |
| 261 | - $value = ( empty( $value ) && function_exists( 'uwp_get_usermeta' ) ) ? uwp_get_usermeta( $user_id, $prefix . $field ) : $value; |
|
| 261 | + $value = (empty($value) && function_exists('uwp_get_usermeta')) ? uwp_get_usermeta($user_id, $prefix . $field) : $value; |
|
| 262 | 262 | |
| 263 | - if ( ! empty( $value ) ) { |
|
| 263 | + if (!empty($value)) { |
|
| 264 | 264 | return $value; |
| 265 | 265 | } |
| 266 | 266 | |
@@ -277,16 +277,16 @@ discard block |
||
| 277 | 277 | * @param string $return What to return. |
| 278 | 278 | * @return array |
| 279 | 279 | */ |
| 280 | -function wpinv_get_continents( $return = 'all' ) { |
|
| 280 | +function wpinv_get_continents($return = 'all') { |
|
| 281 | 281 | |
| 282 | - $continents = wpinv_get_data( 'continents' ); |
|
| 282 | + $continents = wpinv_get_data('continents'); |
|
| 283 | 283 | |
| 284 | - switch( $return ) { |
|
| 284 | + switch ($return) { |
|
| 285 | 285 | case 'name' : |
| 286 | - return wp_list_pluck( $continents, 'name' ); |
|
| 286 | + return wp_list_pluck($continents, 'name'); |
|
| 287 | 287 | break; |
| 288 | 288 | case 'countries' : |
| 289 | - return wp_list_pluck( $continents, 'countries' ); |
|
| 289 | + return wp_list_pluck($continents, 'countries'); |
|
| 290 | 290 | break; |
| 291 | 291 | default : |
| 292 | 292 | return $continents; |
@@ -302,12 +302,12 @@ discard block |
||
| 302 | 302 | * @param string $country Country code. If no code is specified, defaults to the default country. |
| 303 | 303 | * @return string |
| 304 | 304 | */ |
| 305 | -function wpinv_get_continent_code_for_country( $country = false ) { |
|
| 305 | +function wpinv_get_continent_code_for_country($country = false) { |
|
| 306 | 306 | |
| 307 | - $country = wpinv_sanitize_country( $country ); |
|
| 307 | + $country = wpinv_sanitize_country($country); |
|
| 308 | 308 | |
| 309 | - foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) { |
|
| 310 | - if ( false !== array_search( $country, $countries, true ) ) { |
|
| 309 | + foreach (wpinv_get_continents('countries') as $continent_code => $countries) { |
|
| 310 | + if (false !== array_search($country, $countries, true)) { |
|
| 311 | 311 | return $continent_code; |
| 312 | 312 | } |
| 313 | 313 | } |
@@ -323,13 +323,13 @@ discard block |
||
| 323 | 323 | * @param string $country Country code. If no code is specified, defaults to the default country. |
| 324 | 324 | * @return array |
| 325 | 325 | */ |
| 326 | -function wpinv_get_country_calling_code( $country = null) { |
|
| 326 | +function wpinv_get_country_calling_code($country = null) { |
|
| 327 | 327 | |
| 328 | - $country = wpinv_sanitize_country( $country ); |
|
| 329 | - $codes = wpinv_get_data( 'phone-codes' ); |
|
| 330 | - $code = isset( $codes[ $country ] ) ? $codes[ $country ] : ''; |
|
| 328 | + $country = wpinv_sanitize_country($country); |
|
| 329 | + $codes = wpinv_get_data('phone-codes'); |
|
| 330 | + $code = isset($codes[$country]) ? $codes[$country] : ''; |
|
| 331 | 331 | |
| 332 | - if ( is_array( $code ) ) { |
|
| 332 | + if (is_array($code)) { |
|
| 333 | 333 | return $code[0]; |
| 334 | 334 | } |
| 335 | 335 | return $code; |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | * @param bool $first_empty Whether or not the first item in the list should be empty |
| 343 | 343 | * @return array |
| 344 | 344 | */ |
| 345 | -function wpinv_get_country_list( $first_empty = false ) { |
|
| 346 | - return wpinv_maybe_add_empty_option( apply_filters( 'wpinv_countries', wpinv_get_data( 'countries' ) ), $first_empty ); |
|
| 345 | +function wpinv_get_country_list($first_empty = false) { |
|
| 346 | + return wpinv_maybe_add_empty_option(apply_filters('wpinv_countries', wpinv_get_data('countries')), $first_empty); |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | /** |
@@ -353,22 +353,22 @@ discard block |
||
| 353 | 353 | * @param bool $first_empty Whether or not the first item in the list should be empty |
| 354 | 354 | * @return array |
| 355 | 355 | */ |
| 356 | -function wpinv_get_country_states( $country = null, $first_empty = false ) { |
|
| 356 | +function wpinv_get_country_states($country = null, $first_empty = false) { |
|
| 357 | 357 | |
| 358 | 358 | // Prepare the country. |
| 359 | - $country = wpinv_sanitize_country( $country ); |
|
| 359 | + $country = wpinv_sanitize_country($country); |
|
| 360 | 360 | |
| 361 | 361 | // Fetch all states. |
| 362 | - $all_states = wpinv_get_data( 'states' ); |
|
| 362 | + $all_states = wpinv_get_data('states'); |
|
| 363 | 363 | |
| 364 | 364 | // Fetch the specified country's states. |
| 365 | - $states = isset( $all_states[ $country ] ) ? $all_states[ $country ] : array() ; |
|
| 366 | - $states = apply_filters( "wpinv_{$country}_states", $states ); |
|
| 367 | - $states = apply_filters( 'wpinv_country_states', $states, $country ); |
|
| 365 | + $states = isset($all_states[$country]) ? $all_states[$country] : array(); |
|
| 366 | + $states = apply_filters("wpinv_{$country}_states", $states); |
|
| 367 | + $states = apply_filters('wpinv_country_states', $states, $country); |
|
| 368 | 368 | |
| 369 | - asort( $states ); |
|
| 369 | + asort($states); |
|
| 370 | 370 | |
| 371 | - return wpinv_maybe_add_empty_option( $states, $first_empty ); |
|
| 371 | + return wpinv_maybe_add_empty_option($states, $first_empty); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | /** |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | * @return array |
| 379 | 379 | */ |
| 380 | 380 | function wpinv_get_us_states_list() { |
| 381 | - return apply_filters( 'wpinv_usa_states', wpinv_get_country_states( 'US' ) ); |
|
| 381 | + return apply_filters('wpinv_usa_states', wpinv_get_country_states('US')); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | /** |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | * @return array |
| 389 | 389 | */ |
| 390 | 390 | function wpinv_get_canada_states_list() { |
| 391 | - return apply_filters( 'wpinv_canada_provinces', wpinv_get_country_states( 'CA' ) ); |
|
| 391 | + return apply_filters('wpinv_canada_provinces', wpinv_get_country_states('CA')); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | /** |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | * @return array |
| 399 | 399 | */ |
| 400 | 400 | function wpinv_get_australia_states_list() { |
| 401 | - return apply_filters( 'wpinv_australia_states', wpinv_get_country_states( 'AU' ) ); |
|
| 401 | + return apply_filters('wpinv_australia_states', wpinv_get_country_states('AU')); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | /** |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | * @return array |
| 409 | 409 | */ |
| 410 | 410 | function wpinv_get_bangladesh_states_list() { |
| 411 | - return apply_filters( 'wpinv_bangladesh_states', wpinv_get_country_states( 'BD' ) ); |
|
| 411 | + return apply_filters('wpinv_bangladesh_states', wpinv_get_country_states('BD')); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | /** |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | * @return array |
| 419 | 419 | */ |
| 420 | 420 | function wpinv_get_brazil_states_list() { |
| 421 | - return apply_filters( 'wpinv_brazil_states', wpinv_get_country_states( 'BR' ) ); |
|
| 421 | + return apply_filters('wpinv_brazil_states', wpinv_get_country_states('BR')); |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | /** |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | * @return array |
| 429 | 429 | */ |
| 430 | 430 | function wpinv_get_bulgaria_states_list() { |
| 431 | - return apply_filters( 'wpinv_bulgaria_states', wpinv_get_country_states( 'BG' ) ); |
|
| 431 | + return apply_filters('wpinv_bulgaria_states', wpinv_get_country_states('BG')); |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | /** |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | * @return array |
| 439 | 439 | */ |
| 440 | 440 | function wpinv_get_hong_kong_states_list() { |
| 441 | - return apply_filters( 'wpinv_hong_kong_states', wpinv_get_country_states( 'HK' ) ); |
|
| 441 | + return apply_filters('wpinv_hong_kong_states', wpinv_get_country_states('HK')); |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | /** |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | * @return array |
| 449 | 449 | */ |
| 450 | 450 | function wpinv_get_hungary_states_list() { |
| 451 | - return apply_filters( 'wpinv_hungary_states', wpinv_get_country_states( 'HU' ) ); |
|
| 451 | + return apply_filters('wpinv_hungary_states', wpinv_get_country_states('HU')); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | /** |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | * @return array |
| 459 | 459 | */ |
| 460 | 460 | function wpinv_get_japan_states_list() { |
| 461 | - return apply_filters( 'wpinv_japan_states', wpinv_get_country_states( 'JP' ) ); |
|
| 461 | + return apply_filters('wpinv_japan_states', wpinv_get_country_states('JP')); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | /** |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | * @return array |
| 469 | 469 | */ |
| 470 | 470 | function wpinv_get_china_states_list() { |
| 471 | - return apply_filters( 'wpinv_china_states', wpinv_get_country_states( 'CN' ) ); |
|
| 471 | + return apply_filters('wpinv_china_states', wpinv_get_country_states('CN')); |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | /** |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | * @return array |
| 479 | 479 | */ |
| 480 | 480 | function wpinv_get_new_zealand_states_list() { |
| 481 | - return apply_filters( 'wpinv_new_zealand_states', wpinv_get_country_states( 'NZ' ) ); |
|
| 481 | + return apply_filters('wpinv_new_zealand_states', wpinv_get_country_states('NZ')); |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | /** |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | * @return array |
| 489 | 489 | */ |
| 490 | 490 | function wpinv_get_peru_states_list() { |
| 491 | - return apply_filters( 'wpinv_peru_states', wpinv_get_country_states( 'PE' ) ); |
|
| 491 | + return apply_filters('wpinv_peru_states', wpinv_get_country_states('PE')); |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | /** |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | * @return array |
| 499 | 499 | */ |
| 500 | 500 | function wpinv_get_indonesia_states_list() { |
| 501 | - return apply_filters( 'wpinv_indonesia_states', wpinv_get_country_states( 'ID' ) ); |
|
| 501 | + return apply_filters('wpinv_indonesia_states', wpinv_get_country_states('ID')); |
|
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | /** |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | * @return array |
| 509 | 509 | */ |
| 510 | 510 | function wpinv_get_india_states_list() { |
| 511 | - return apply_filters( 'wpinv_india_states', wpinv_get_country_states( 'IN' ) ); |
|
| 511 | + return apply_filters('wpinv_india_states', wpinv_get_country_states('IN')); |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | /** |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | * @return array |
| 519 | 519 | */ |
| 520 | 520 | function wpinv_get_iran_states_list() { |
| 521 | - return apply_filters( 'wpinv_iran_states', wpinv_get_country_states( 'IR' ) ); |
|
| 521 | + return apply_filters('wpinv_iran_states', wpinv_get_country_states('IR')); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | /** |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | * @return array |
| 529 | 529 | */ |
| 530 | 530 | function wpinv_get_italy_states_list() { |
| 531 | - return apply_filters( 'wpinv_italy_states', wpinv_get_country_states( 'IT' ) ); |
|
| 531 | + return apply_filters('wpinv_italy_states', wpinv_get_country_states('IT')); |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | /** |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | * @return array |
| 539 | 539 | */ |
| 540 | 540 | function wpinv_get_malaysia_states_list() { |
| 541 | - return apply_filters( 'wpinv_malaysia_states', wpinv_get_country_states( 'MY' ) ); |
|
| 541 | + return apply_filters('wpinv_malaysia_states', wpinv_get_country_states('MY')); |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | /** |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | * @return array |
| 549 | 549 | */ |
| 550 | 550 | function wpinv_get_mexico_states_list() { |
| 551 | - return apply_filters( 'wpinv_mexico_states', wpinv_get_country_states( 'MX' ) ); |
|
| 551 | + return apply_filters('wpinv_mexico_states', wpinv_get_country_states('MX')); |
|
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | /** |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | * @return array |
| 559 | 559 | */ |
| 560 | 560 | function wpinv_get_nepal_states_list() { |
| 561 | - return apply_filters( 'wpinv_nepal_states', wpinv_get_country_states( 'NP' ) ); |
|
| 561 | + return apply_filters('wpinv_nepal_states', wpinv_get_country_states('NP')); |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | /** |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | * @return array |
| 569 | 569 | */ |
| 570 | 570 | function wpinv_get_south_africa_states_list() { |
| 571 | - return apply_filters( 'wpinv_south_africa_states', wpinv_get_country_states( 'ZA' ) ); |
|
| 571 | + return apply_filters('wpinv_south_africa_states', wpinv_get_country_states('ZA')); |
|
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | /** |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | * @return array |
| 579 | 579 | */ |
| 580 | 580 | function wpinv_get_thailand_states_list() { |
| 581 | - return apply_filters( 'wpinv_thailand_states', wpinv_get_country_states( 'TH' ) ); |
|
| 581 | + return apply_filters('wpinv_thailand_states', wpinv_get_country_states('TH')); |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | /** |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | * @return array |
| 589 | 589 | */ |
| 590 | 590 | function wpinv_get_turkey_states_list() { |
| 591 | - return apply_filters( 'wpinv_turkey_states', wpinv_get_country_states( 'TR' ) ); |
|
| 591 | + return apply_filters('wpinv_turkey_states', wpinv_get_country_states('TR')); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | /** |
@@ -598,28 +598,28 @@ discard block |
||
| 598 | 598 | * @return array |
| 599 | 599 | */ |
| 600 | 600 | function wpinv_get_spain_states_list() { |
| 601 | - return apply_filters( 'wpinv_spain_states', wpinv_get_country_states( 'ES' ) ); |
|
| 601 | + return apply_filters('wpinv_spain_states', wpinv_get_country_states('ES')); |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | function wpinv_get_states_field() { |
| 605 | - if( empty( $_POST['country'] ) ) { |
|
| 605 | + if (empty($_POST['country'])) { |
|
| 606 | 606 | $_POST['country'] = wpinv_get_default_country(); |
| 607 | 607 | } |
| 608 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
| 608 | + $states = wpinv_get_country_states(sanitize_text_field($_POST['country'])); |
|
| 609 | 609 | |
| 610 | - if( !empty( $states ) ) { |
|
| 611 | - $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
| 610 | + if (!empty($states)) { |
|
| 611 | + $sanitized_field_name = sanitize_text_field($_POST['field_name']); |
|
| 612 | 612 | |
| 613 | 613 | $args = array( |
| 614 | 614 | 'name' => $sanitized_field_name, |
| 615 | 615 | 'id' => $sanitized_field_name, |
| 616 | 616 | 'class' => $sanitized_field_name . 'custom-select wpinv-select wpi_select2', |
| 617 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
| 617 | + 'options' => array_merge(array('' => ''), $states), |
|
| 618 | 618 | 'show_option_all' => false, |
| 619 | 619 | 'show_option_none' => false |
| 620 | 620 | ); |
| 621 | 621 | |
| 622 | - $response = wpinv_html_select( $args ); |
|
| 622 | + $response = wpinv_html_select($args); |
|
| 623 | 623 | |
| 624 | 624 | } else { |
| 625 | 625 | $response = 'nostates'; |
@@ -628,10 +628,10 @@ discard block |
||
| 628 | 628 | return $response; |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | -function wpinv_default_billing_country( $country = '', $user_id = 0 ) { |
|
| 632 | - $country = !empty( $country ) ? $country : wpinv_get_default_country(); |
|
| 631 | +function wpinv_default_billing_country($country = '', $user_id = 0) { |
|
| 632 | + $country = !empty($country) ? $country : wpinv_get_default_country(); |
|
| 633 | 633 | |
| 634 | - return apply_filters( 'wpinv_default_billing_country', $country, $user_id ); |
|
| 634 | + return apply_filters('wpinv_default_billing_country', $country, $user_id); |
|
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | /** |
@@ -643,7 +643,7 @@ discard block |
||
| 643 | 643 | */ |
| 644 | 644 | function wpinv_get_address_formats() { |
| 645 | 645 | |
| 646 | - return apply_filters( 'wpinv_localisation_address_formats', |
|
| 646 | + return apply_filters('wpinv_localisation_address_formats', |
|
| 647 | 647 | array( |
| 648 | 648 | 'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}", |
| 649 | 649 | 'AU' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}", |
@@ -692,9 +692,9 @@ discard block |
||
| 692 | 692 | * @see `wpinv_get_invoice_address_replacements` |
| 693 | 693 | * @return string |
| 694 | 694 | */ |
| 695 | -function wpinv_get_full_address_format( $country = false) { |
|
| 695 | +function wpinv_get_full_address_format($country = false) { |
|
| 696 | 696 | |
| 697 | - if( empty( $country ) ) { |
|
| 697 | + if (empty($country)) { |
|
| 698 | 698 | $country = wpinv_get_default_country(); |
| 699 | 699 | } |
| 700 | 700 | |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | $formats = wpinv_get_address_formats(); |
| 703 | 703 | |
| 704 | 704 | // Get format for the specified country. |
| 705 | - $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default']; |
|
| 705 | + $format = ($country && isset($formats[$country])) ? $formats[$country] : $formats['default']; |
|
| 706 | 706 | |
| 707 | 707 | /** |
| 708 | 708 | * Filters the address format to use on Invoices. |
@@ -714,7 +714,7 @@ discard block |
||
| 714 | 714 | * @param string $format The address format to use. |
| 715 | 715 | * @param string $country The country who's address format is being retrieved. |
| 716 | 716 | */ |
| 717 | - return apply_filters( 'wpinv_get_full_address_format', $format, $country ); |
|
| 717 | + return apply_filters('wpinv_get_full_address_format', $format, $country); |
|
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | /** |
@@ -725,7 +725,7 @@ discard block |
||
| 725 | 725 | * @param array $billing_details customer's billing details |
| 726 | 726 | * @return array |
| 727 | 727 | */ |
| 728 | -function wpinv_get_invoice_address_replacements( $billing_details ) { |
|
| 728 | +function wpinv_get_invoice_address_replacements($billing_details) { |
|
| 729 | 729 | |
| 730 | 730 | $default_args = array( |
| 731 | 731 | 'address' => '', |
@@ -738,22 +738,22 @@ discard block |
||
| 738 | 738 | 'company' => '', |
| 739 | 739 | ); |
| 740 | 740 | |
| 741 | - $args = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' ); |
|
| 741 | + $args = map_deep(wp_parse_args($billing_details, $default_args), 'trim'); |
|
| 742 | 742 | $state = $args['state']; |
| 743 | 743 | $country = $args['country']; |
| 744 | 744 | |
| 745 | 745 | // Handle full country name. |
| 746 | - $full_country = empty( $country ) ? $country : wpinv_country_name( $country ); |
|
| 746 | + $full_country = empty($country) ? $country : wpinv_country_name($country); |
|
| 747 | 747 | |
| 748 | 748 | // Handle full state name. |
| 749 | - $full_state = ( $country && $state ) ? wpinv_state_name( $state, $country ) : $state; |
|
| 749 | + $full_state = ($country && $state) ? wpinv_state_name($state, $country) : $state; |
|
| 750 | 750 | |
| 751 | 751 | $args['postcode'] = $args['zip']; |
| 752 | 752 | $args['name'] = $args['first_name'] . ' ' . $args['last_name']; |
| 753 | 753 | $args['state'] = $full_state; |
| 754 | 754 | $args['state_code'] = $state; |
| 755 | 755 | $args['country'] = $full_country; |
| 756 | - $args['country_code']= $country; |
|
| 756 | + $args['country_code'] = $country; |
|
| 757 | 757 | |
| 758 | 758 | /** |
| 759 | 759 | * Filters the address format replacements to use on Invoices. |
@@ -764,14 +764,14 @@ discard block |
||
| 764 | 764 | * @param array $replacements The address replacements to use. |
| 765 | 765 | * @param array $billing_details The billing details to use. |
| 766 | 766 | */ |
| 767 | - $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details ); |
|
| 767 | + $replacements = apply_filters('wpinv_get_invoice_address_replacements', $args, $billing_details); |
|
| 768 | 768 | |
| 769 | 769 | $return = array(); |
| 770 | 770 | |
| 771 | - foreach( $replacements as $key => $value ) { |
|
| 772 | - $value = is_scalar( $value ) ? trim( sanitize_text_field( $value ) ) : ''; |
|
| 771 | + foreach ($replacements as $key => $value) { |
|
| 772 | + $value = is_scalar($value) ? trim(sanitize_text_field($value)) : ''; |
|
| 773 | 773 | $return['{{' . $key . '}}'] = $value; |
| 774 | - $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper( $value ); |
|
| 774 | + $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper($value); |
|
| 775 | 775 | } |
| 776 | 776 | |
| 777 | 777 | return $return; |
@@ -785,6 +785,6 @@ discard block |
||
| 785 | 785 | * @since 1.0.14 |
| 786 | 786 | * @return string |
| 787 | 787 | */ |
| 788 | -function wpinv_trim_formatted_address_line( $line ) { |
|
| 789 | - return trim( $line, ', ' ); |
|
| 788 | +function wpinv_trim_formatted_address_line($line) { |
|
| 789 | + return trim($line, ', '); |
|
| 790 | 790 | } |
| 791 | 791 | \ No newline at end of file |