@@ -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,11 +88,11 @@ 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 | -add_action( 'init', function() { |
|
| 95 | +add_action('init', function() { |
|
| 96 | 96 | echo getpaid_get_email_css(); |
| 97 | 97 | exit; |
| 98 | 98 | }); |
@@ -103,26 +103,26 @@ discard block |
||
| 103 | 103 | * @return string |
| 104 | 104 | * |
| 105 | 105 | */ |
| 106 | -function wpinv_email_style_body( $content ) { |
|
| 106 | +function wpinv_email_style_body($content) { |
|
| 107 | 107 | |
| 108 | - if ( ! class_exists( 'DOMDocument' ) ) { |
|
| 108 | + if (!class_exists('DOMDocument')) { |
|
| 109 | 109 | return $content; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | $css = getpaid_get_email_css(); |
| 113 | 113 | |
| 114 | 114 | // include css inliner |
| 115 | - if ( ! class_exists( 'Emogrifier' ) ) { |
|
| 116 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
| 115 | + if (!class_exists('Emogrifier')) { |
|
| 116 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // Inline the css. |
| 120 | 120 | try { |
| 121 | - $emogrifier = new Emogrifier( $content, $css ); |
|
| 121 | + $emogrifier = new Emogrifier($content, $css); |
|
| 122 | 122 | $_content = $emogrifier->emogrify(); |
| 123 | 123 | $content = $_content; |
| 124 | - } catch ( Exception $e ) { |
|
| 125 | - wpinv_error_log( $e->getMessage(), 'emogrifier' ); |
|
| 124 | + } catch (Exception $e) { |
|
| 125 | + wpinv_error_log($e->getMessage(), 'emogrifier'); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | return $content; |
@@ -131,37 +131,37 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | // Backwards compatibility. |
| 133 | 133 | function wpinv_init_transactional_emails() { |
| 134 | - foreach ( apply_filters( 'wpinv_email_actions', array() ) as $action ) { |
|
| 135 | - add_action( $action, 'wpinv_send_transactional_email', 10, 10 ); |
|
| 134 | + foreach (apply_filters('wpinv_email_actions', array()) as $action) { |
|
| 135 | + add_action($action, 'wpinv_send_transactional_email', 10, 10); |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | -add_action( 'init', 'wpinv_init_transactional_emails' ); |
|
| 138 | +add_action('init', 'wpinv_init_transactional_emails'); |
|
| 139 | 139 | |
| 140 | 140 | function wpinv_send_transactional_email() { |
| 141 | 141 | $args = func_get_args(); |
| 142 | 142 | $function = current_filter() . '_notification'; |
| 143 | - do_action_ref_array( $function, $args ); |
|
| 143 | + do_action_ref_array($function, $args); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | function wpinv_mail_get_from_address() { |
| 147 | - $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from', get_option( 'admin_email' ) ) ); |
|
| 148 | - return sanitize_email( $from_address ); |
|
| 147 | + $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from', get_option('admin_email'))); |
|
| 148 | + return sanitize_email($from_address); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | function wpinv_mail_get_from_name() { |
| 152 | - $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name', get_bloginfo( 'name', 'display' ) ) ); |
|
| 153 | - return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES ); |
|
| 152 | + $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name', get_bloginfo('name', 'display'))); |
|
| 153 | + return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | -function wpinv_mail_admin_bcc_active( $mail_type = '' ) { |
|
| 157 | - $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) ); |
|
| 158 | - return ( $active ? true : false ); |
|
| 156 | +function wpinv_mail_admin_bcc_active($mail_type = '') { |
|
| 157 | + $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc')); |
|
| 158 | + return ($active ? true : false); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | -function wpinv_mail_get_content_type( $content_type = 'text/html', $email_type = 'html' ) { |
|
| 162 | - $email_type = apply_filters( 'wpinv_mail_content_type', $email_type ); |
|
| 161 | +function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') { |
|
| 162 | + $email_type = apply_filters('wpinv_mail_content_type', $email_type); |
|
| 163 | 163 | |
| 164 | - switch ( $email_type ) { |
|
| 164 | + switch ($email_type) { |
|
| 165 | 165 | case 'html' : |
| 166 | 166 | $content_type = 'text/html'; |
| 167 | 167 | break; |
@@ -186,11 +186,11 @@ discard block |
||
| 186 | 186 | * @param array $attachments Any files to attach to the email. |
| 187 | 187 | * @param string|array $cc An email or array of extra emails to send a copy of the email to. |
| 188 | 188 | */ |
| 189 | -function wpinv_mail_send( $to, $subject, $message, $deprecated, $attachments = array(), $cc = array() ) { |
|
| 189 | +function wpinv_mail_send($to, $subject, $message, $deprecated, $attachments = array(), $cc = array()) { |
|
| 190 | 190 | |
| 191 | 191 | $mailer = new GetPaid_Notification_Email_Sender(); |
| 192 | - $message = wpinv_email_style_body( $message ); |
|
| 193 | - $to = array_merge( wpinv_parse_list( $to ), wpinv_parse_list( $cc ) ); |
|
| 192 | + $message = wpinv_email_style_body($message); |
|
| 193 | + $to = array_merge(wpinv_parse_list($to), wpinv_parse_list($cc)); |
|
| 194 | 194 | |
| 195 | 195 | return $mailer->send( |
| 196 | 196 | $to, |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | * @return array |
| 208 | 208 | */ |
| 209 | 209 | function wpinv_get_emails() { |
| 210 | - return apply_filters( 'wpinv_get_emails', wpinv_get_data( 'email-settings' ) ); |
|
| 210 | + return apply_filters('wpinv_get_emails', wpinv_get_data('email-settings')); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -216,172 +216,172 @@ discard block |
||
| 216 | 216 | * @param array $settings |
| 217 | 217 | * @return array |
| 218 | 218 | */ |
| 219 | -function wpinv_settings_emails( $settings = array() ) { |
|
| 220 | - $settings = array_merge( $settings, wpinv_get_emails() ); |
|
| 221 | - return apply_filters( 'wpinv_settings_get_emails', $settings ); |
|
| 219 | +function wpinv_settings_emails($settings = array()) { |
|
| 220 | + $settings = array_merge($settings, wpinv_get_emails()); |
|
| 221 | + return apply_filters('wpinv_settings_get_emails', $settings); |
|
| 222 | 222 | } |
| 223 | -add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 ); |
|
| 223 | +add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1); |
|
| 224 | 224 | |
| 225 | 225 | /** |
| 226 | 226 | * Filter email section names. |
| 227 | 227 | * |
| 228 | 228 | */ |
| 229 | -function wpinv_settings_sections_emails( $settings ) { |
|
| 230 | - foreach ( wpinv_get_emails() as $key => $email) { |
|
| 231 | - $settings[$key] = ! empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : strip_tags( $key ); |
|
| 229 | +function wpinv_settings_sections_emails($settings) { |
|
| 230 | + foreach (wpinv_get_emails() as $key => $email) { |
|
| 231 | + $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : strip_tags($key); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | return $settings; |
| 235 | 235 | } |
| 236 | -add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 ); |
|
| 236 | +add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1); |
|
| 237 | 237 | |
| 238 | -function wpinv_email_is_enabled( $email_type ) { |
|
| 238 | +function wpinv_email_is_enabled($email_type) { |
|
| 239 | 239 | $emails = wpinv_get_emails(); |
| 240 | - $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false; |
|
| 240 | + $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false; |
|
| 241 | 241 | |
| 242 | - return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type ); |
|
| 242 | + return apply_filters('wpinv_email_is_enabled', $enabled, $email_type); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | -function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 246 | - switch ( $email_type ) { |
|
| 245 | +function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 246 | + switch ($email_type) { |
|
| 247 | 247 | case 'new_invoice': |
| 248 | 248 | case 'cancelled_invoice': |
| 249 | 249 | case 'failed_invoice': |
| 250 | 250 | $recipient = wpinv_get_admin_email(); |
| 251 | 251 | break; |
| 252 | 252 | default: |
| 253 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
| 254 | - $recipient = !empty( $invoice ) ? $invoice->get_email() : ''; |
|
| 253 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
| 254 | + $recipient = !empty($invoice) ? $invoice->get_email() : ''; |
|
| 255 | 255 | break; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice ); |
|
| 258 | + return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** |
| 262 | 262 | * Returns invoice CC recipients |
| 263 | 263 | */ |
| 264 | -function wpinv_email_get_cc_recipients( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 265 | - switch ( $email_type ) { |
|
| 264 | +function wpinv_email_get_cc_recipients($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 265 | + switch ($email_type) { |
|
| 266 | 266 | case 'new_invoice': |
| 267 | 267 | case 'cancelled_invoice': |
| 268 | 268 | case 'failed_invoice': |
| 269 | 269 | return array(); |
| 270 | 270 | break; |
| 271 | 271 | default: |
| 272 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
| 273 | - $recipient = empty( $invoice ) ? '' : get_post_meta( $invoice->ID, 'wpinv_email_cc', true ); |
|
| 274 | - if ( empty( $recipient ) ) { |
|
| 272 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
| 273 | + $recipient = empty($invoice) ? '' : get_post_meta($invoice->ID, 'wpinv_email_cc', true); |
|
| 274 | + if (empty($recipient)) { |
|
| 275 | 275 | return array(); |
| 276 | 276 | } |
| 277 | - return array_filter( array_map( 'trim', explode( ',', $recipient ) ) ); |
|
| 277 | + return array_filter(array_map('trim', explode(',', $recipient))); |
|
| 278 | 278 | break; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | -function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 284 | - $subject = wpinv_get_option( 'email_' . $email_type . '_subject' ); |
|
| 285 | - $subject = __( $subject, 'invoicing' ); |
|
| 283 | +function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 284 | + $subject = wpinv_get_option('email_' . $email_type . '_subject'); |
|
| 285 | + $subject = __($subject, 'invoicing'); |
|
| 286 | 286 | |
| 287 | - $subject = wpinv_email_format_text( $subject, $invoice ); |
|
| 287 | + $subject = wpinv_email_format_text($subject, $invoice); |
|
| 288 | 288 | |
| 289 | - return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice ); |
|
| 289 | + return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | -function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 293 | - $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' ); |
|
| 294 | - $email_heading = __( $email_heading, 'invoicing' ); |
|
| 292 | +function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 293 | + $email_heading = wpinv_get_option('email_' . $email_type . '_heading'); |
|
| 294 | + $email_heading = __($email_heading, 'invoicing'); |
|
| 295 | 295 | |
| 296 | - $email_heading = wpinv_email_format_text( $email_heading, $invoice ); |
|
| 296 | + $email_heading = wpinv_email_format_text($email_heading, $invoice); |
|
| 297 | 297 | |
| 298 | - return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice ); |
|
| 298 | + return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | -function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 302 | - $content = wpinv_get_option( 'email_' . $email_type . '_body' ); |
|
| 303 | - $content = __( $content, 'invoicing' ); |
|
| 301 | +function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 302 | + $content = wpinv_get_option('email_' . $email_type . '_body'); |
|
| 303 | + $content = __($content, 'invoicing'); |
|
| 304 | 304 | |
| 305 | - $content = wpinv_email_format_text( $content, $invoice ); |
|
| 305 | + $content = wpinv_email_format_text($content, $invoice); |
|
| 306 | 306 | |
| 307 | - return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice ); |
|
| 307 | + return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | -function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 310 | +function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 311 | 311 | $from_name = wpinv_mail_get_from_address(); |
| 312 | 312 | $from_email = wpinv_mail_get_from_address(); |
| 313 | 313 | |
| 314 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
| 314 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
| 315 | 315 | |
| 316 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
| 317 | - $headers .= "Reply-To: ". $from_email . "\r\n"; |
|
| 316 | + $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n"; |
|
| 317 | + $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
| 318 | 318 | $headers .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n"; |
| 319 | 319 | |
| 320 | - return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice ); |
|
| 320 | + return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | -function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 323 | +function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 324 | 324 | $attachments = array(); |
| 325 | 325 | |
| 326 | - return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice ); |
|
| 326 | + return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | /** |
| 330 | 330 | * Searches for and replaces certain placeholders in an email. |
| 331 | 331 | */ |
| 332 | -function wpinv_email_format_text( $content, $invoice ) { |
|
| 332 | +function wpinv_email_format_text($content, $invoice) { |
|
| 333 | 333 | |
| 334 | 334 | $replace_array = array( |
| 335 | 335 | '{site_title}' => wpinv_get_blogname(), |
| 336 | - '{date}' => getpaid_format_date( current_time( 'mysql' ) ), |
|
| 336 | + '{date}' => getpaid_format_date(current_time('mysql')), |
|
| 337 | 337 | ); |
| 338 | 338 | |
| 339 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 339 | + $invoice = new WPInv_Invoice($invoice); |
|
| 340 | 340 | |
| 341 | - if ( $invoice->get_id() ) { |
|
| 341 | + if ($invoice->get_id()) { |
|
| 342 | 342 | |
| 343 | 343 | $replace_array = array_merge( |
| 344 | 344 | $replace_array, |
| 345 | 345 | array( |
| 346 | - '{name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
| 347 | - '{full_name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
| 348 | - '{first_name}' => sanitize_text_field( $invoice->get_first_name() ), |
|
| 349 | - '{last_name}' => sanitize_text_field( $invoice->get_last_name() ), |
|
| 350 | - '{email}' => sanitize_email( $invoice->get_email() ), |
|
| 351 | - '{invoice_number}' => sanitize_text_field( $invoice->get_number() ), |
|
| 352 | - '{invoice_total}' => sanitize_text_field( wpinv_price( $invoice->get_total( true ), $invoice->get_currency() ) ), |
|
| 353 | - '{invoice_link}' => esc_url( $invoice->get_view_url() ), |
|
| 354 | - '{invoice_pay_link}'=> esc_url( $invoice->get_checkout_payment_url() ), |
|
| 355 | - '{invoice_date}' => date( get_option( 'date_format' ), strtotime( $invoice->get_date_created(), current_time( 'timestamp' ) ) ), |
|
| 356 | - '{invoice_due_date}'=> date( get_option( 'date_format' ), strtotime( $invoice->get_due_date(), current_time( 'timestamp' ) ) ), |
|
| 357 | - '{invoice_quote}' => sanitize_text_field( $invoice->get_invoice_quote_type() ), |
|
| 358 | - '{invoice_label}' => sanitize_text_field( ucfirst( $invoice->get_invoice_quote_type() ) ), |
|
| 359 | - '{is_was}' => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ), |
|
| 346 | + '{name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
| 347 | + '{full_name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
| 348 | + '{first_name}' => sanitize_text_field($invoice->get_first_name()), |
|
| 349 | + '{last_name}' => sanitize_text_field($invoice->get_last_name()), |
|
| 350 | + '{email}' => sanitize_email($invoice->get_email()), |
|
| 351 | + '{invoice_number}' => sanitize_text_field($invoice->get_number()), |
|
| 352 | + '{invoice_total}' => sanitize_text_field(wpinv_price($invoice->get_total(true), $invoice->get_currency())), |
|
| 353 | + '{invoice_link}' => esc_url($invoice->get_view_url()), |
|
| 354 | + '{invoice_pay_link}'=> esc_url($invoice->get_checkout_payment_url()), |
|
| 355 | + '{invoice_date}' => date(get_option('date_format'), strtotime($invoice->get_date_created(), current_time('timestamp'))), |
|
| 356 | + '{invoice_due_date}'=> date(get_option('date_format'), strtotime($invoice->get_due_date(), current_time('timestamp'))), |
|
| 357 | + '{invoice_quote}' => sanitize_text_field($invoice->get_invoice_quote_type()), |
|
| 358 | + '{invoice_label}' => sanitize_text_field(ucfirst($invoice->get_invoice_quote_type())), |
|
| 359 | + '{is_was}' => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'), |
|
| 360 | 360 | ) |
| 361 | 361 | ); |
| 362 | 362 | |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | // Let third party plugins filter the arra. |
| 366 | - $replace_array = apply_filters( 'wpinv_email_format_text', $replace_array, $content, $invoice ); |
|
| 366 | + $replace_array = apply_filters('wpinv_email_format_text', $replace_array, $content, $invoice); |
|
| 367 | 367 | |
| 368 | - foreach ( $replace_array as $key => $value ) { |
|
| 369 | - $content = str_replace( $key, $value, $content ); |
|
| 368 | + foreach ($replace_array as $key => $value) { |
|
| 369 | + $content = str_replace($key, $value, $content); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - return apply_filters( 'wpinv_email_content_replace', $content ); |
|
| 372 | + return apply_filters('wpinv_email_content_replace', $content); |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | |
| 376 | -function wpinv_email_wrap_message( $message ) { |
|
| 376 | +function wpinv_email_wrap_message($message) { |
|
| 377 | 377 | // Buffer |
| 378 | 378 | ob_start(); |
| 379 | 379 | |
| 380 | - do_action( 'wpinv_email_header' ); |
|
| 380 | + do_action('wpinv_email_header'); |
|
| 381 | 381 | |
| 382 | - echo wpautop( wptexturize( $message ) ); |
|
| 382 | + echo wpautop(wptexturize($message)); |
|
| 383 | 383 | |
| 384 | - do_action( 'wpinv_email_footer' ); |
|
| 384 | + do_action('wpinv_email_footer'); |
|
| 385 | 385 | |
| 386 | 386 | // Get contents |
| 387 | 387 | $message = ob_get_clean(); |
@@ -389,21 +389,21 @@ discard block |
||
| 389 | 389 | return $message; |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | -function wpinv_add_notes_to_invoice_email( $invoice, $email_type ) { |
|
| 393 | - if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->get_id(), true ) ) { |
|
| 394 | - $date_format = get_option( 'date_format' ); |
|
| 395 | - $time_format = get_option( 'time_format' ); |
|
| 392 | +function wpinv_add_notes_to_invoice_email($invoice, $email_type) { |
|
| 393 | + if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->get_id(), true)) { |
|
| 394 | + $date_format = get_option('date_format'); |
|
| 395 | + $time_format = get_option('time_format'); |
|
| 396 | 396 | ?> |
| 397 | 397 | <div id="wpinv-email-notes"> |
| 398 | - <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3> |
|
| 398 | + <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3> |
|
| 399 | 399 | <ol class="wpinv-notes-lists"> |
| 400 | 400 | <?php |
| 401 | - foreach ( $invoice_notes as $note ) { |
|
| 402 | - $note_time = strtotime( $note->comment_date ); |
|
| 401 | + foreach ($invoice_notes as $note) { |
|
| 402 | + $note_time = strtotime($note->comment_date); |
|
| 403 | 403 | ?> |
| 404 | 404 | <li class="comment wpinv-note"> |
| 405 | - <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> |
|
| 406 | - <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div> |
|
| 405 | + <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> |
|
| 406 | + <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div> |
|
| 407 | 407 | </li> |
| 408 | 408 | <?php |
| 409 | 409 | } |
@@ -412,4 +412,4 @@ discard block |
||
| 412 | 412 | <?php |
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | -add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 ); |
|
| 415 | +add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3); |
|