@@ -1,56 +1,56 @@ |
||
| 1 | 1 | <?php |
| 2 | -if ( !defined('ABSPATH') ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | -do_action( 'wpinv_invalid_invoice_before_display' ); ?><!DOCTYPE html> |
|
| 5 | +do_action('wpinv_invalid_invoice_before_display'); ?><!DOCTYPE html> |
|
| 6 | 6 | <html <?php language_attributes(); ?>> |
| 7 | 7 | <head> |
| 8 | 8 | <meta charset="UTF-8"> |
| 9 | 9 | <title><?php wp_title() ?></title> |
| 10 | - <meta charset="<?php bloginfo( 'charset' ); ?>" /> |
|
| 10 | + <meta charset="<?php bloginfo('charset'); ?>" /> |
|
| 11 | 11 | <meta name="viewport" content="width=device-width,initial-scale=1"> |
| 12 | 12 | <meta name="robots" content="noindex,nofollow"> |
| 13 | - <?php do_action( 'wpinv_invalid_invoice_head' ); ?> |
|
| 13 | + <?php do_action('wpinv_invalid_invoice_head'); ?> |
|
| 14 | 14 | </head> |
| 15 | 15 | <body class="body wpinv wpinv-print wpinv-invalid-invoice"> |
| 16 | - <?php do_action( 'wpinv_invalid_invoice_body_start' ); ?> |
|
| 16 | + <?php do_action('wpinv_invalid_invoice_body_start'); ?> |
|
| 17 | 17 | <div class="container wpinv-wrap"> |
| 18 | 18 | <!-- ///// Start Header --> |
| 19 | 19 | <htmlpageheader name="wpinv-pdf-header"> |
| 20 | - <?php do_action( 'wpinv_invalid_invoice_before_header' ); ?> |
|
| 20 | + <?php do_action('wpinv_invalid_invoice_before_header'); ?> |
|
| 21 | 21 | <div class="row wpinv-header"> |
| 22 | 22 | <div class="col-xs-12 wpinv-business"> |
| 23 | - <a target="_blank" href="<?php echo esc_url( wpinv_get_business_website() ); ?>"> |
|
| 24 | - <?php if ( $logo = wpinv_get_business_logo() ) { ?> |
|
| 25 | - <img class="logo" src="<?php echo esc_url( $logo ); ?>"> |
|
| 23 | + <a target="_blank" href="<?php echo esc_url(wpinv_get_business_website()); ?>"> |
|
| 24 | + <?php if ($logo = wpinv_get_business_logo()) { ?> |
|
| 25 | + <img class="logo" src="<?php echo esc_url($logo); ?>"> |
|
| 26 | 26 | <?php } else { ?> |
| 27 | - <h1><?php echo esc_html( wpinv_get_business_name() ); ?></h1> |
|
| 27 | + <h1><?php echo esc_html(wpinv_get_business_name()); ?></h1> |
|
| 28 | 28 | <?php } ?> |
| 29 | 29 | </a> |
| 30 | 30 | </div> |
| 31 | 31 | </div> |
| 32 | - <?php do_action( 'wpinv_invalid_invoice_after_header' ); ?> |
|
| 32 | + <?php do_action('wpinv_invalid_invoice_after_header'); ?> |
|
| 33 | 33 | </htmlpageheader> |
| 34 | 34 | <!-- End Header ///// --> |
| 35 | 35 | |
| 36 | - <?php do_action( 'wpinv_invalid_invoice_before_content' ); ?> |
|
| 36 | + <?php do_action('wpinv_invalid_invoice_before_content'); ?> |
|
| 37 | 37 | |
| 38 | - <?php do_action( 'wpinv_invalid_invoice_content' ); ?> |
|
| 38 | + <?php do_action('wpinv_invalid_invoice_content'); ?> |
|
| 39 | 39 | |
| 40 | - <?php do_action( 'wpinv_invalid_invoice_after_content' ); ?> |
|
| 40 | + <?php do_action('wpinv_invalid_invoice_after_content'); ?> |
|
| 41 | 41 | |
| 42 | 42 | <!-- ///// Start Footer --> |
| 43 | 43 | <htmlpagefooter name="wpinv-pdf-footer"> |
| 44 | - <?php do_action( 'wpinv_invalid_invoice_before_footer' ); ?> |
|
| 44 | + <?php do_action('wpinv_invalid_invoice_before_footer'); ?> |
|
| 45 | 45 | <div class="row wpinv-footer"> |
| 46 | 46 | <div class="col-sm-12"> |
| 47 | 47 | <div class="footer-text"><?php echo wpinv_get_business_footer(); ?></div> |
| 48 | 48 | </div> |
| 49 | 49 | </div> |
| 50 | - <?php do_action( 'wpinv_invalid_invoice_after_footer' ); ?> |
|
| 50 | + <?php do_action('wpinv_invalid_invoice_after_footer'); ?> |
|
| 51 | 51 | </htmlpagefooter> |
| 52 | 52 | <!-- End Footer ///// --> |
| 53 | 53 | </div> |
| 54 | - <?php do_action( 'wpinv_invalid_invoice_body_end' ); ?> |
|
| 54 | + <?php do_action('wpinv_invalid_invoice_body_end'); ?> |
|
| 55 | 55 | </body> |
| 56 | 56 | </html> |
| 57 | 57 | \ No newline at end of file |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly |
| 4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 4 | +if (!defined('ABSPATH')) exit; |
|
| 5 | 5 | |
| 6 | 6 | abstract class Wpinv_DB { |
| 7 | 7 | |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | * @since 1.0.0 |
| 67 | 67 | * @return object |
| 68 | 68 | */ |
| 69 | - public function get( $row_id ) { |
|
| 69 | + public function get($row_id) { |
|
| 70 | 70 | global $wpdb; |
| 71 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
| 71 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -78,10 +78,10 @@ discard block |
||
| 78 | 78 | * @since 1.0.0 |
| 79 | 79 | * @return object |
| 80 | 80 | */ |
| 81 | - public function get_by( $column, $row_id ) { |
|
| 81 | + public function get_by($column, $row_id) { |
|
| 82 | 82 | global $wpdb; |
| 83 | - $column = esc_sql( $column ); |
|
| 84 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
| 83 | + $column = esc_sql($column); |
|
| 84 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id)); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -91,10 +91,10 @@ discard block |
||
| 91 | 91 | * @since 1.0.0 |
| 92 | 92 | * @return string |
| 93 | 93 | */ |
| 94 | - public function get_column( $column, $row_id ) { |
|
| 94 | + public function get_column($column, $row_id) { |
|
| 95 | 95 | global $wpdb; |
| 96 | - $column = esc_sql( $column ); |
|
| 97 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
| 96 | + $column = esc_sql($column); |
|
| 97 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -104,11 +104,11 @@ discard block |
||
| 104 | 104 | * @since 1.0.0 |
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
| 107 | + public function get_column_by($column, $column_where, $column_value) { |
|
| 108 | 108 | global $wpdb; |
| 109 | - $column_where = esc_sql( $column_where ); |
|
| 110 | - $column = esc_sql( $column ); |
|
| 111 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
| 109 | + $column_where = esc_sql($column_where); |
|
| 110 | + $column = esc_sql($column); |
|
| 111 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value)); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -118,31 +118,31 @@ discard block |
||
| 118 | 118 | * @since 1.0.0 |
| 119 | 119 | * @return int |
| 120 | 120 | */ |
| 121 | - public function insert( $data, $type = '' ) { |
|
| 121 | + public function insert($data, $type = '') { |
|
| 122 | 122 | global $wpdb; |
| 123 | 123 | |
| 124 | 124 | // Set default values |
| 125 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
| 125 | + $data = wp_parse_args($data, $this->get_column_defaults()); |
|
| 126 | 126 | |
| 127 | - do_action( 'wpinv_pre_insert_' . $type, $data ); |
|
| 127 | + do_action('wpinv_pre_insert_' . $type, $data); |
|
| 128 | 128 | |
| 129 | 129 | // Initialise column format array |
| 130 | 130 | $column_formats = $this->get_columns(); |
| 131 | 131 | |
| 132 | 132 | // Force fields to lower case |
| 133 | - $data = array_change_key_case( $data ); |
|
| 133 | + $data = array_change_key_case($data); |
|
| 134 | 134 | |
| 135 | 135 | // White list columns |
| 136 | - $data = array_intersect_key( $data, $column_formats ); |
|
| 136 | + $data = array_intersect_key($data, $column_formats); |
|
| 137 | 137 | |
| 138 | 138 | // Reorder $column_formats to match the order of columns given in $data |
| 139 | - $data_keys = array_keys( $data ); |
|
| 140 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
| 139 | + $data_keys = array_keys($data); |
|
| 140 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
| 141 | 141 | |
| 142 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
| 142 | + $wpdb->insert($this->table_name, $data, $column_formats); |
|
| 143 | 143 | $wpdb_insert_id = $wpdb->insert_id; |
| 144 | 144 | |
| 145 | - do_action( 'wpinv_post_insert_' . $type, $wpdb_insert_id, $data ); |
|
| 145 | + do_action('wpinv_post_insert_' . $type, $wpdb_insert_id, $data); |
|
| 146 | 146 | |
| 147 | 147 | return $wpdb_insert_id; |
| 148 | 148 | } |
@@ -154,18 +154,18 @@ discard block |
||
| 154 | 154 | * @since 1.0.0 |
| 155 | 155 | * @return bool |
| 156 | 156 | */ |
| 157 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
| 157 | + public function update($row_id, $data = array(), $where = '') { |
|
| 158 | 158 | |
| 159 | 159 | global $wpdb; |
| 160 | 160 | |
| 161 | 161 | // Row ID must be positive integer |
| 162 | - $row_id = absint( $row_id ); |
|
| 162 | + $row_id = absint($row_id); |
|
| 163 | 163 | |
| 164 | - if( empty( $row_id ) ) { |
|
| 164 | + if (empty($row_id)) { |
|
| 165 | 165 | return false; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - if( empty( $where ) ) { |
|
| 168 | + if (empty($where)) { |
|
| 169 | 169 | $where = $this->primary_key; |
| 170 | 170 | } |
| 171 | 171 | |
@@ -173,16 +173,16 @@ discard block |
||
| 173 | 173 | $column_formats = $this->get_columns(); |
| 174 | 174 | |
| 175 | 175 | // Force fields to lower case |
| 176 | - $data = array_change_key_case( $data ); |
|
| 176 | + $data = array_change_key_case($data); |
|
| 177 | 177 | |
| 178 | 178 | // White list columns |
| 179 | - $data = array_intersect_key( $data, $column_formats ); |
|
| 179 | + $data = array_intersect_key($data, $column_formats); |
|
| 180 | 180 | |
| 181 | 181 | // Reorder $column_formats to match the order of columns given in $data |
| 182 | - $data_keys = array_keys( $data ); |
|
| 183 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
| 182 | + $data_keys = array_keys($data); |
|
| 183 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
| 184 | 184 | |
| 185 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
| 185 | + if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) { |
|
| 186 | 186 | return false; |
| 187 | 187 | } |
| 188 | 188 | |
@@ -196,18 +196,18 @@ discard block |
||
| 196 | 196 | * @since 1.0.0 |
| 197 | 197 | * @return bool |
| 198 | 198 | */ |
| 199 | - public function delete( $row_id = 0 ) { |
|
| 199 | + public function delete($row_id = 0) { |
|
| 200 | 200 | |
| 201 | 201 | global $wpdb; |
| 202 | 202 | |
| 203 | 203 | // Row ID must be positive integer |
| 204 | - $row_id = absint( $row_id ); |
|
| 204 | + $row_id = absint($row_id); |
|
| 205 | 205 | |
| 206 | - if( empty( $row_id ) ) { |
|
| 206 | + if (empty($row_id)) { |
|
| 207 | 207 | return false; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
| 210 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) { |
|
| 211 | 211 | return false; |
| 212 | 212 | } |
| 213 | 213 | |
@@ -221,11 +221,11 @@ discard block |
||
| 221 | 221 | * @param string $table The table name |
| 222 | 222 | * @return bool If the table name exists |
| 223 | 223 | */ |
| 224 | - public function table_exists( $table ) { |
|
| 224 | + public function table_exists($table) { |
|
| 225 | 225 | global $wpdb; |
| 226 | - $table = sanitize_text_field( $table ); |
|
| 226 | + $table = sanitize_text_field($table); |
|
| 227 | 227 | |
| 228 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
| 228 | + return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * @return bool Returns if the customers table was installed and upgrade routine run |
| 236 | 236 | */ |
| 237 | 237 | public function installed() { |
| 238 | - return $this->table_exists( $this->table_name ); |
|
| 238 | + return $this->table_exists($this->table_name); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | } |
@@ -1,25 +1,25 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | 6 | // Load colours |
| 7 | -$bg = wpinv_get_option( 'email_background_color', '#f5f5f5' ); |
|
| 8 | -$body = wpinv_get_option( 'email_body_background_color', '#fdfdfd' ); |
|
| 9 | -$base = wpinv_get_option( 'email_base_color', '#557da2' ); |
|
| 10 | -$base_text = wpinv_light_or_dark( $base, '#202020', '#ffffff' ); |
|
| 11 | -$text = wpinv_get_option( 'email_text_color', '#505050' ); |
|
| 7 | +$bg = wpinv_get_option('email_background_color', '#f5f5f5'); |
|
| 8 | +$body = wpinv_get_option('email_body_background_color', '#fdfdfd'); |
|
| 9 | +$base = wpinv_get_option('email_base_color', '#557da2'); |
|
| 10 | +$base_text = wpinv_light_or_dark($base, '#202020', '#ffffff'); |
|
| 11 | +$text = wpinv_get_option('email_text_color', '#505050'); |
|
| 12 | 12 | |
| 13 | -$bg_darker_10 = wpinv_hex_darker( $bg, 10 ); |
|
| 14 | -$body_darker_10 = wpinv_hex_darker( $body, 10 ); |
|
| 15 | -$base_lighter_20 = wpinv_hex_lighter( $base, 20 ); |
|
| 16 | -$base_lighter_40 = wpinv_hex_lighter( $base, 40 ); |
|
| 17 | -$text_lighter_20 = wpinv_hex_lighter( $text, 20 ); |
|
| 13 | +$bg_darker_10 = wpinv_hex_darker($bg, 10); |
|
| 14 | +$body_darker_10 = wpinv_hex_darker($body, 10); |
|
| 15 | +$base_lighter_20 = wpinv_hex_lighter($base, 20); |
|
| 16 | +$base_lighter_40 = wpinv_hex_lighter($base, 40); |
|
| 17 | +$text_lighter_20 = wpinv_hex_lighter($text, 20); |
|
| 18 | 18 | |
| 19 | 19 | // !important; is a gmail hack to prevent styles being stripped if it doesn't like something. |
| 20 | 20 | ?> |
| 21 | 21 | #wrapper { |
| 22 | - background-color: <?php echo esc_attr( $bg ); ?>; |
|
| 22 | + background-color: <?php echo esc_attr($bg); ?>; |
|
| 23 | 23 | margin: 0; |
| 24 | 24 | -webkit-text-size-adjust: none !important; |
| 25 | 25 | padding: 3%; |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | #template_container { |
| 42 | 42 | box-shadow: 0 1px 4px rgba(0,0,0,0.1) !important; |
| 43 | - background-color: <?php echo esc_attr( $body ); ?>; |
|
| 44 | - border: 1px solid <?php echo esc_attr( $bg_darker_10 ); ?>; |
|
| 43 | + background-color: <?php echo esc_attr($body); ?>; |
|
| 44 | + border: 1px solid <?php echo esc_attr($bg_darker_10); ?>; |
|
| 45 | 45 | border-radius: 3px !important; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | #template_header { |
| 49 | - background-color: <?php echo esc_attr( $base ); ?>; |
|
| 49 | + background-color: <?php echo esc_attr($base); ?>; |
|
| 50 | 50 | border-radius: 3px 3px 0 0 !important; |
| 51 | - color: <?php echo esc_attr( $base_text ); ?>; |
|
| 51 | + color: <?php echo esc_attr($base_text); ?>; |
|
| 52 | 52 | border-bottom: 0; |
| 53 | 53 | font-weight: bold; |
| 54 | 54 | line-height: 100%; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | #template_header h1 { |
| 64 | - color: <?php echo esc_attr( $base_text ); ?>; |
|
| 64 | + color: <?php echo esc_attr($base_text); ?>; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | #template_footer td { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | #template_footer #credit { |
| 74 | 74 | border:0; |
| 75 | - color: <?php echo esc_attr( $base_lighter_40 ); ?>; |
|
| 75 | + color: <?php echo esc_attr($base_lighter_40); ?>; |
|
| 76 | 76 | font-family: Arial; |
| 77 | 77 | font-size:12px; |
| 78 | 78 | line-height:125%; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | #body_content { |
| 84 | - background-color: <?php echo esc_attr( $body ); ?>; |
|
| 84 | + background-color: <?php echo esc_attr($body); ?>; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | #body_content table td { |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | #body_content_inner { |
| 104 | - color: <?php echo esc_attr( $text_lighter_20 ); ?>; |
|
| 104 | + color: <?php echo esc_attr($text_lighter_20); ?>; |
|
| 105 | 105 | font-family: Arial,Helvetica,sans-serif; |
| 106 | 106 | font-size: 14px; |
| 107 | 107 | line-height: 150%; |
@@ -109,17 +109,17 @@ discard block |
||
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | .td { |
| 112 | - color: <?php echo esc_attr( $text_lighter_20 ); ?>; |
|
| 113 | - border: 1px solid <?php echo esc_attr( $body_darker_10 ); ?>; |
|
| 112 | + color: <?php echo esc_attr($text_lighter_20); ?>; |
|
| 113 | + border: 1px solid <?php echo esc_attr($body_darker_10); ?>; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | .text { |
| 117 | - color: <?php echo esc_attr( $text ); ?>; |
|
| 117 | + color: <?php echo esc_attr($text); ?>; |
|
| 118 | 118 | font-family: Arial,Helvetica,sans-serif; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | .link { |
| 122 | - color: <?php echo esc_attr( $base ); ?>; |
|
| 122 | + color: <?php echo esc_attr($base); ?>; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | #header_wrapper { |
@@ -128,19 +128,19 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | h1 { |
| 131 | - color: <?php echo esc_attr( $base ); ?>; |
|
| 131 | + color: <?php echo esc_attr($base); ?>; |
|
| 132 | 132 | font-family: Arial,Helvetica,sans-serif; |
| 133 | 133 | font-size: 30px; |
| 134 | 134 | font-weight: 300; |
| 135 | 135 | line-height: 150%; |
| 136 | 136 | margin: 0; |
| 137 | 137 | text-align: <?php echo is_rtl() ? 'right' : 'left'; ?>; |
| 138 | - text-shadow: 0 1px 0 <?php echo esc_attr( $base_lighter_20 ); ?>; |
|
| 138 | + text-shadow: 0 1px 0 <?php echo esc_attr($base_lighter_20); ?>; |
|
| 139 | 139 | -webkit-font-smoothing: antialiased; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | h2 { |
| 143 | - color: <?php echo esc_attr( $base ); ?>; |
|
| 143 | + color: <?php echo esc_attr($base); ?>; |
|
| 144 | 144 | display: block; |
| 145 | 145 | font-family: Arial,Helvetica,sans-serif; |
| 146 | 146 | font-size: 18px; |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | h3 { |
| 154 | - color: <?php echo esc_attr( $base ); ?>; |
|
| 154 | + color: <?php echo esc_attr($base); ?>; |
|
| 155 | 155 | display: block; |
| 156 | 156 | font-family: Arial,Helvetica,sans-serif; |
| 157 | 157 | font-size: 16px; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | a { |
| 165 | - color: <?php echo esc_attr( $base ); ?>; |
|
| 165 | + color: <?php echo esc_attr($base); ?>; |
|
| 166 | 166 | font-weight: normal; |
| 167 | 167 | text-decoration: underline; |
| 168 | 168 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | .table-bordered { |
| 183 | - border: 1px solid <?php echo esc_attr( $body_darker_10 ); ?>; |
|
| 183 | + border: 1px solid <?php echo esc_attr($body_darker_10); ?>; |
|
| 184 | 184 | border-collapse: collapse; |
| 185 | 185 | border-spacing: 0; |
| 186 | 186 | width: 100%; |
@@ -188,8 +188,8 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | .table-bordered th, |
| 190 | 190 | .table-bordered td { |
| 191 | - border: 1px solid <?php echo esc_attr( $body_darker_10 ); ?>; |
|
| 192 | - color: <?php echo esc_attr( $text_lighter_20 ); ?>; |
|
| 191 | + border: 1px solid <?php echo esc_attr($body_darker_10); ?>; |
|
| 192 | + color: <?php echo esc_attr($text_lighter_20); ?>; |
|
| 193 | 193 | font-size: 14px; |
| 194 | 194 | } |
| 195 | 195 | .small { |
@@ -288,9 +288,9 @@ discard block |
||
| 288 | 288 | text-decoration: none; |
| 289 | 289 | } |
| 290 | 290 | .btn-default { |
| 291 | - color: <?php echo esc_attr( $base_text ); ?>; |
|
| 292 | - background-color: <?php echo esc_attr( $base ); ?>; |
|
| 293 | - border-color: <?php echo esc_attr( $base ); ?>; |
|
| 291 | + color: <?php echo esc_attr($base_text); ?>; |
|
| 292 | + background-color: <?php echo esc_attr($base); ?>; |
|
| 293 | + border-color: <?php echo esc_attr($base); ?>; |
|
| 294 | 294 | } |
| 295 | 295 | .btn-primary { |
| 296 | 296 | color: #fff; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | 6 | global $wpinv_euvat, $ajax_cart_details; |
@@ -11,152 +11,152 @@ discard block |
||
| 11 | 11 | $quantities_enabled = wpinv_item_quantities_enabled(); |
| 12 | 12 | $use_taxes = wpinv_use_taxes(); |
| 13 | 13 | $zero_tax = !(float)$invoice->get_tax() > 0 ? true : false; |
| 14 | -$tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' ); |
|
| 15 | -$tax_title = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
| 14 | +$tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing'); |
|
| 15 | +$tax_title = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
| 16 | 16 | |
| 17 | -do_action( 'wpinv_before_email_items', $invoice ); ?> |
|
| 17 | +do_action('wpinv_before_email_items', $invoice); ?> |
|
| 18 | 18 | <div id="wpinv-email-items"> |
| 19 | - <h3 class="wpinv-items-t"><?php echo apply_filters( 'wpinv_email_items_title', __( 'Items', 'invoicing' ) ); ?></h3> |
|
| 19 | + <h3 class="wpinv-items-t"><?php echo apply_filters('wpinv_email_items_title', __('Items', 'invoicing')); ?></h3> |
|
| 20 | 20 | <table id="wpinv_checkout_cart" class="table table-bordered table-hover"> |
| 21 | 21 | <thead> |
| 22 | 22 | <tr class="wpinv_cart_header_row"> |
| 23 | - <?php do_action( 'wpinv_email_items_table_header_first' ); ?> |
|
| 24 | - <th class="wpinv_cart_item_name text-left"><?php _e( 'Item Name', 'invoicing' ); ?></th> |
|
| 25 | - <th class="wpinv_cart_item_price text-right"><?php _e( 'Item Price', 'invoicing' ); ?></th> |
|
| 26 | - <?php if ( $quantities_enabled ) { ?> |
|
| 27 | - <th class="wpinv_cart_item_qty text-right"><?php _e( 'Qty', 'invoicing' ); ?></th> |
|
| 23 | + <?php do_action('wpinv_email_items_table_header_first'); ?> |
|
| 24 | + <th class="wpinv_cart_item_name text-left"><?php _e('Item Name', 'invoicing'); ?></th> |
|
| 25 | + <th class="wpinv_cart_item_price text-right"><?php _e('Item Price', 'invoicing'); ?></th> |
|
| 26 | + <?php if ($quantities_enabled) { ?> |
|
| 27 | + <th class="wpinv_cart_item_qty text-right"><?php _e('Qty', 'invoicing'); ?></th> |
|
| 28 | 28 | <?php } ?> |
| 29 | - <?php if ( !$zero_tax && $use_taxes ) { ?> |
|
| 29 | + <?php if (!$zero_tax && $use_taxes) { ?> |
|
| 30 | 30 | <th class="wpinv_cart_item_tax text-right"><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></th> |
| 31 | 31 | <?php } ?> |
| 32 | - <th class="wpinv_cart_item_subtotal text-right"><?php echo __( 'Item Total', 'invoicing' ) . ' <span class="normal small">' . $tax_title . '<span>'; ?></th> |
|
| 33 | - <?php do_action( 'wpinv_email_items_table_header_last' ); ?> |
|
| 32 | + <th class="wpinv_cart_item_subtotal text-right"><?php echo __('Item Total', 'invoicing') . ' <span class="normal small">' . $tax_title . '<span>'; ?></th> |
|
| 33 | + <?php do_action('wpinv_email_items_table_header_last'); ?> |
|
| 34 | 34 | </tr> |
| 35 | 35 | </thead> |
| 36 | 36 | <tbody> |
| 37 | 37 | <?php |
| 38 | - do_action( 'wpinv_email_items_before' ); |
|
| 39 | - if ( $cart_items ) { |
|
| 40 | - foreach ( $cart_items as $key => $item ) { |
|
| 41 | - $wpi_item = $item['id'] ? new WPInv_Item( $item['id'] ) : NULL; |
|
| 38 | + do_action('wpinv_email_items_before'); |
|
| 39 | + if ($cart_items) { |
|
| 40 | + foreach ($cart_items as $key => $item) { |
|
| 41 | + $wpi_item = $item['id'] ? new WPInv_Item($item['id']) : NULL; |
|
| 42 | 42 | ?> |
| 43 | - <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr( $key ) . '_' . esc_attr( $item['id'] ); ?>" data-item-id="<?php echo esc_attr( $item['id'] ); ?>"> |
|
| 44 | - <?php do_action( 'wpinv_email_items_table_body_first', $item ); ?> |
|
| 43 | + <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr($key) . '_' . esc_attr($item['id']); ?>" data-item-id="<?php echo esc_attr($item['id']); ?>"> |
|
| 44 | + <?php do_action('wpinv_email_items_table_body_first', $item); ?> |
|
| 45 | 45 | <td class="wpinv_cart_item_name text-left"> |
| 46 | 46 | <?php |
| 47 | - if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $item['id'] ) ) { |
|
| 47 | + if (current_theme_supports('post-thumbnails') && has_post_thumbnail($item['id'])) { |
|
| 48 | 48 | echo '<div class="wpinv_cart_item_image">'; |
| 49 | - echo get_the_post_thumbnail( $item['id'], apply_filters( 'wpinv_checkout_image_size', array( 25,25 ) ) ); |
|
| 49 | + echo get_the_post_thumbnail($item['id'], apply_filters('wpinv_checkout_image_size', array(25, 25))); |
|
| 50 | 50 | echo '</div>'; |
| 51 | 51 | } |
| 52 | - $item_title = esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $wpi_item ); |
|
| 52 | + $item_title = esc_html(wpinv_get_cart_item_name($item)) . wpinv_get_item_suffix($wpi_item); |
|
| 53 | 53 | echo '<span class="wpinv_email_cart_item_title">' . $item_title . '</span>'; |
| 54 | 54 | |
| 55 | - $summary = apply_filters( 'wpinv_email_invoice_line_item_summary', '', $item, $wpi_item, $invoice ); |
|
| 56 | - if ( !empty( $summary ) ) { |
|
| 55 | + $summary = apply_filters('wpinv_email_invoice_line_item_summary', '', $item, $wpi_item, $invoice); |
|
| 56 | + if (!empty($summary)) { |
|
| 57 | 57 | echo '<p class="small">' . $summary . '</p>'; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - do_action( 'wpinv_email_cart_item_title_after', $item, $key ); |
|
| 60 | + do_action('wpinv_email_cart_item_title_after', $item, $key); |
|
| 61 | 61 | ?> |
| 62 | 62 | </td> |
| 63 | 63 | <td class="wpinv_cart_item_price text-right"> |
| 64 | 64 | <?php |
| 65 | - echo wpinv_cart_item_price( $item ); |
|
| 66 | - do_action( 'wpinv_email_cart_item_price_after', $item, $key ); |
|
| 65 | + echo wpinv_cart_item_price($item); |
|
| 66 | + do_action('wpinv_email_cart_item_price_after', $item, $key); |
|
| 67 | 67 | ?> |
| 68 | 68 | </td> |
| 69 | - <?php if ( $quantities_enabled ) { ?> |
|
| 69 | + <?php if ($quantities_enabled) { ?> |
|
| 70 | 70 | <td class="wpinv_cart_item_qty text-right"> |
| 71 | 71 | <?php |
| 72 | - echo wpinv_get_cart_item_quantity( $item ); |
|
| 73 | - do_action( 'wpinv_email_item_quantitiy', $item, $key ); |
|
| 72 | + echo wpinv_get_cart_item_quantity($item); |
|
| 73 | + do_action('wpinv_email_item_quantitiy', $item, $key); |
|
| 74 | 74 | ?> |
| 75 | 75 | </td> |
| 76 | 76 | <?php } ?> |
| 77 | - <?php if ( !$zero_tax && $use_taxes ) { ?> |
|
| 77 | + <?php if (!$zero_tax && $use_taxes) { ?> |
|
| 78 | 78 | <td class="wpinv_cart_item_tax text-right"> |
| 79 | 79 | <?php |
| 80 | - echo wpinv_cart_item_tax( $item ); |
|
| 81 | - do_action( 'wpinv_email_item_tax', $item, $key ); |
|
| 80 | + echo wpinv_cart_item_tax($item); |
|
| 81 | + do_action('wpinv_email_item_tax', $item, $key); |
|
| 82 | 82 | ?> |
| 83 | 83 | </td> |
| 84 | 84 | <?php } ?> |
| 85 | 85 | <td class="wpinv_cart_item_subtotal text-right"> |
| 86 | 86 | <?php |
| 87 | - echo wpinv_cart_item_subtotal( $item ); |
|
| 88 | - do_action( 'wpinv_email_item_subtotal', $item, $key ); |
|
| 87 | + echo wpinv_cart_item_subtotal($item); |
|
| 88 | + do_action('wpinv_email_item_subtotal', $item, $key); |
|
| 89 | 89 | ?> |
| 90 | 90 | </td> |
| 91 | - <?php do_action( 'wpinv_email_items_table_body_last', $item, $key ); ?> |
|
| 91 | + <?php do_action('wpinv_email_items_table_body_last', $item, $key); ?> |
|
| 92 | 92 | </tr> |
| 93 | 93 | <?php } ?> |
| 94 | 94 | <?php } ?> |
| 95 | - <?php do_action( 'wpinv_email_items_middle' ); ?> |
|
| 96 | - <?php do_action( 'wpinv_email_items_after' ); ?> |
|
| 95 | + <?php do_action('wpinv_email_items_middle'); ?> |
|
| 96 | + <?php do_action('wpinv_email_items_after'); ?> |
|
| 97 | 97 | </tbody> |
| 98 | 98 | <tfoot> |
| 99 | - <?php $cart_columns = wpinv_checkout_cart_columns(); if ( $zero_tax && $use_taxes ) { $cart_columns--; } ?> |
|
| 100 | - <?php if ( has_action( 'wpinv_email_footer_buttons' ) ) { ?> |
|
| 99 | + <?php $cart_columns = wpinv_checkout_cart_columns(); if ($zero_tax && $use_taxes) { $cart_columns--; } ?> |
|
| 100 | + <?php if (has_action('wpinv_email_footer_buttons')) { ?> |
|
| 101 | 101 | <tr class="wpinv_cart_footer_row"> |
| 102 | - <?php do_action( 'wpinv_email_items_table_buttons_first', $cart_items ); ?> |
|
| 103 | - <td colspan="<?php echo ( $cart_columns ); ?>"> |
|
| 104 | - <?php do_action( 'wpinv_email_footer_buttons' ); ?> |
|
| 102 | + <?php do_action('wpinv_email_items_table_buttons_first', $cart_items); ?> |
|
| 103 | + <td colspan="<?php echo ($cart_columns); ?>"> |
|
| 104 | + <?php do_action('wpinv_email_footer_buttons'); ?> |
|
| 105 | 105 | </td> |
| 106 | - <?php do_action( 'wpinv_email_items_table_buttons_first', $cart_items ); ?> |
|
| 106 | + <?php do_action('wpinv_email_items_table_buttons_first', $cart_items); ?> |
|
| 107 | 107 | </tr> |
| 108 | 108 | <?php } ?> |
| 109 | 109 | |
| 110 | - <?php if ( !$zero_tax && $use_taxes && !wpinv_prices_include_tax() && wpinv_is_cart_taxed() ) { ?> |
|
| 110 | + <?php if (!$zero_tax && $use_taxes && !wpinv_prices_include_tax() && wpinv_is_cart_taxed()) { ?> |
|
| 111 | 111 | <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"> |
| 112 | - <?php do_action( 'wpinv_email_items_table_subtotal_first', $cart_items ); ?> |
|
| 113 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_subtotal_label text-right"> |
|
| 114 | - <strong><?php _e( 'Sub-Total', 'invoicing' ); ?>:</strong> |
|
| 112 | + <?php do_action('wpinv_email_items_table_subtotal_first', $cart_items); ?> |
|
| 113 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_subtotal_label text-right"> |
|
| 114 | + <strong><?php _e('Sub-Total', 'invoicing'); ?>:</strong> |
|
| 115 | 115 | </td> |
| 116 | 116 | <td class="wpinv_cart_subtotal text-right"> |
| 117 | - <span class="wpinv_cart_subtotal_amount bold"><?php echo $invoice->get_subtotal( true ); ?></span> |
|
| 117 | + <span class="wpinv_cart_subtotal_amount bold"><?php echo $invoice->get_subtotal(true); ?></span> |
|
| 118 | 118 | </td> |
| 119 | - <?php do_action( 'wpinv_email_items_table_subtotal_last', $cart_items, $invoice ); ?> |
|
| 119 | + <?php do_action('wpinv_email_items_table_subtotal_last', $cart_items, $invoice); ?> |
|
| 120 | 120 | </tr> |
| 121 | 121 | <?php } ?> |
| 122 | 122 | |
| 123 | - <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?> |
|
| 123 | + <?php if (wpinv_discount($invoice_id, false) > 0) { ?> |
|
| 124 | 124 | <tr class="wpinv_cart_footer_row wpinv_cart_discount_row"> |
| 125 | - <?php do_action( 'wpinv_receipt_items_table_discount_first', $cart_items, $invoice ); ?> |
|
| 126 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_discount_label text-right"> |
|
| 127 | - <strong><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</strong> |
|
| 125 | + <?php do_action('wpinv_receipt_items_table_discount_first', $cart_items, $invoice); ?> |
|
| 126 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_discount_label text-right"> |
|
| 127 | + <strong><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</strong> |
|
| 128 | 128 | </td> |
| 129 | 129 | <td class="wpinv_cart_discount text-right"> |
| 130 | - <span class="wpinv_cart_discount_amount"><?php echo wpinv_discount( $invoice_id, true, true ); ?></span> |
|
| 130 | + <span class="wpinv_cart_discount_amount"><?php echo wpinv_discount($invoice_id, true, true); ?></span> |
|
| 131 | 131 | </td> |
| 132 | - <?php do_action( 'wpinv_receipt_items_table_discount_last', $cart_items, $invoice ); ?> |
|
| 132 | + <?php do_action('wpinv_receipt_items_table_discount_last', $cart_items, $invoice); ?> |
|
| 133 | 133 | </tr> |
| 134 | 134 | <?php } ?> |
| 135 | 135 | |
| 136 | - <?php if ( !$zero_tax && $use_taxes && wpinv_is_cart_taxed() ) { ?> |
|
| 136 | + <?php if (!$zero_tax && $use_taxes && wpinv_is_cart_taxed()) { ?> |
|
| 137 | 137 | <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"> |
| 138 | - <?php do_action( 'wpinv_email_items_table_tax_first', $cart_items, $invoice ); ?> |
|
| 139 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_tax_label text-right"> |
|
| 138 | + <?php do_action('wpinv_email_items_table_tax_first', $cart_items, $invoice); ?> |
|
| 139 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_tax_label text-right"> |
|
| 140 | 140 | <strong><?php echo $tax_label; ?>:</strong> |
| 141 | 141 | </td> |
| 142 | 142 | <td class="wpinv_cart_tax text-right"> |
| 143 | - <span class="wpinv_cart_tax_amount"><?php echo $invoice->get_tax( true ); ?></span> |
|
| 143 | + <span class="wpinv_cart_tax_amount"><?php echo $invoice->get_tax(true); ?></span> |
|
| 144 | 144 | </td> |
| 145 | - <?php do_action( 'wpinv_email_items_table_tax_last', $cart_items, $invoice ); ?> |
|
| 145 | + <?php do_action('wpinv_email_items_table_tax_last', $cart_items, $invoice); ?> |
|
| 146 | 146 | </tr> |
| 147 | 147 | <?php } ?> |
| 148 | 148 | |
| 149 | 149 | <tr class="wpinv_cart_footer_row"> |
| 150 | - <?php do_action( 'wpinv_email_items_table_footer_first', $cart_items, $invoice ); ?> |
|
| 151 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_total_label text-right"> |
|
| 152 | - <?php echo apply_filters( 'wpinv_email_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?> |
|
| 150 | + <?php do_action('wpinv_email_items_table_footer_first', $cart_items, $invoice); ?> |
|
| 151 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_total_label text-right"> |
|
| 152 | + <?php echo apply_filters('wpinv_email_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?> |
|
| 153 | 153 | </td> |
| 154 | 154 | <td class="wpinv_cart_total text-right"> |
| 155 | - <span class="wpinv_cart_amount bold"><?php echo $invoice->get_total( true ); ?></span> |
|
| 155 | + <span class="wpinv_cart_amount bold"><?php echo $invoice->get_total(true); ?></span> |
|
| 156 | 156 | </td> |
| 157 | - <?php do_action( 'wpinv_email_items_table_footer_last', $cart_items, $invoice ); ?> |
|
| 157 | + <?php do_action('wpinv_email_items_table_footer_last', $cart_items, $invoice); ?> |
|
| 158 | 158 | </tr> |
| 159 | 159 | </tfoot> |
| 160 | 160 | </table> |
| 161 | 161 | </div> |
| 162 | -<?php do_action( 'wpinv_after_email_items', $invoice ); ?> |
|
| 163 | 162 | \ No newline at end of file |
| 163 | +<?php do_action('wpinv_after_email_items', $invoice); ?> |
|
| 164 | 164 | \ No newline at end of file |
@@ -5,138 +5,138 @@ |
||
| 5 | 5 | |
| 6 | 6 | global $wpinv_euvat, $post, $ajax_cart_details, $wpi_cart_columns, $wpi_session; |
| 7 | 7 | $invoice = wpinv_get_invoice_cart(); |
| 8 | -$cart_items = !empty( $ajax_cart_details ) ? $ajax_cart_details : wpinv_get_cart_content_details(); |
|
| 8 | +$cart_items = !empty($ajax_cart_details) ? $ajax_cart_details : wpinv_get_cart_content_details(); |
|
| 9 | 9 | $quantities_enabled = wpinv_item_quantities_enabled(); |
| 10 | 10 | $use_taxes = wpinv_use_taxes(); |
| 11 | 11 | $tax_label = $wpinv_euvat->tax_label(); |
| 12 | -$tax_title = $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
| 12 | +$tax_title = $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
| 13 | 13 | ?> |
| 14 | 14 | <table id="wpinv_checkout_cart" class="table table-bordered table-hover"> |
| 15 | 15 | <thead> |
| 16 | 16 | <tr class="wpinv_cart_header_row"> |
| 17 | - <?php do_action( 'wpinv_checkout_table_header_first' ); ?> |
|
| 18 | - <th class="wpinv_cart_item_name text-left"><?php _e( 'Item Name', 'invoicing' ); ?></th> |
|
| 19 | - <th class="wpinv_cart_item_price text-right"><?php _e( 'Item Price', 'invoicing' ); ?></th> |
|
| 20 | - <?php if ( $quantities_enabled ) { ?> |
|
| 21 | - <th class="wpinv_cart_item_qty text-right"><?php _e( 'Qty', 'invoicing' ); ?></th> |
|
| 17 | + <?php do_action('wpinv_checkout_table_header_first'); ?> |
|
| 18 | + <th class="wpinv_cart_item_name text-left"><?php _e('Item Name', 'invoicing'); ?></th> |
|
| 19 | + <th class="wpinv_cart_item_price text-right"><?php _e('Item Price', 'invoicing'); ?></th> |
|
| 20 | + <?php if ($quantities_enabled) { ?> |
|
| 21 | + <th class="wpinv_cart_item_qty text-right"><?php _e('Qty', 'invoicing'); ?></th> |
|
| 22 | 22 | <?php } ?> |
| 23 | - <?php if ( $use_taxes ) { ?> |
|
| 23 | + <?php if ($use_taxes) { ?> |
|
| 24 | 24 | <th class="wpinv_cart_item_tax text-right"><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></th> |
| 25 | 25 | <?php } ?> |
| 26 | - <th class="wpinv_cart_item_subtotal text-right"><?php echo __( 'Item Total', 'invoicing' ) . ' <span class="normal small">' . $tax_title . '<span>'; ?></th> |
|
| 27 | - <?php do_action( 'wpinv_checkout_table_header_last' ); ?> |
|
| 26 | + <th class="wpinv_cart_item_subtotal text-right"><?php echo __('Item Total', 'invoicing') . ' <span class="normal small">' . $tax_title . '<span>'; ?></th> |
|
| 27 | + <?php do_action('wpinv_checkout_table_header_last'); ?> |
|
| 28 | 28 | </tr> |
| 29 | 29 | </thead> |
| 30 | 30 | <tbody> |
| 31 | 31 | <?php |
| 32 | - do_action( 'wpinv_cart_items_before' ); |
|
| 32 | + do_action('wpinv_cart_items_before'); |
|
| 33 | 33 | |
| 34 | - if ( $cart_items ) { |
|
| 35 | - foreach ( $cart_items as $key => $item ) { |
|
| 36 | - $wpi_item = !empty( $item['id'] ) ? new WPInv_Item( $item['id'] ) : NULL; |
|
| 34 | + if ($cart_items) { |
|
| 35 | + foreach ($cart_items as $key => $item) { |
|
| 36 | + $wpi_item = !empty($item['id']) ? new WPInv_Item($item['id']) : NULL; |
|
| 37 | 37 | ?> |
| 38 | - <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr( $key ) . '_' . esc_attr( $item['id'] ); ?>" data-item-id="<?php echo esc_attr( $item['id'] ); ?>"> |
|
| 39 | - <?php do_action( 'wpinv_checkout_table_body_first', $item ); ?> |
|
| 38 | + <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr($key) . '_' . esc_attr($item['id']); ?>" data-item-id="<?php echo esc_attr($item['id']); ?>"> |
|
| 39 | + <?php do_action('wpinv_checkout_table_body_first', $item); ?> |
|
| 40 | 40 | <td class="wpinv_cart_item_name text-left"> |
| 41 | 41 | <?php |
| 42 | - if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $item['id'] ) ) { |
|
| 42 | + if (current_theme_supports('post-thumbnails') && has_post_thumbnail($item['id'])) { |
|
| 43 | 43 | echo '<div class="wpinv_cart_item_image">'; |
| 44 | - echo get_the_post_thumbnail( $item['id'], apply_filters( 'wpinv_checkout_image_size', array( 25,25 ) ) ); |
|
| 44 | + echo get_the_post_thumbnail($item['id'], apply_filters('wpinv_checkout_image_size', array(25, 25))); |
|
| 45 | 45 | echo '</div>'; |
| 46 | 46 | } |
| 47 | - $item_title = esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $wpi_item ); |
|
| 47 | + $item_title = esc_html(wpinv_get_cart_item_name($item)) . wpinv_get_item_suffix($wpi_item); |
|
| 48 | 48 | echo '<span class="wpinv_checkout_cart_item_title">' . $item_title . '</span>'; |
| 49 | - $summary = apply_filters( 'wpinv_checkout_cart_line_item_summary', '', $item, $wpi_item, $invoice ); |
|
| 50 | - if ( !empty( $summary ) ) { |
|
| 49 | + $summary = apply_filters('wpinv_checkout_cart_line_item_summary', '', $item, $wpi_item, $invoice); |
|
| 50 | + if (!empty($summary)) { |
|
| 51 | 51 | echo $summary; |
| 52 | 52 | } |
| 53 | 53 | ?> |
| 54 | 54 | </td> |
| 55 | 55 | <td class="wpinv_cart_item_price text-right"> |
| 56 | 56 | <?php |
| 57 | - echo wpinv_cart_item_price( $item ); |
|
| 58 | - do_action( 'wpinv_checkout_cart_item_price_after', $item, $key ); |
|
| 57 | + echo wpinv_cart_item_price($item); |
|
| 58 | + do_action('wpinv_checkout_cart_item_price_after', $item, $key); |
|
| 59 | 59 | ?> |
| 60 | 60 | </td> |
| 61 | - <?php if ( $quantities_enabled ) { ?> |
|
| 61 | + <?php if ($quantities_enabled) { ?> |
|
| 62 | 62 | <td class="wpinv_cart_item_qty text-right"> |
| 63 | 63 | <?php |
| 64 | - echo wpinv_get_cart_item_quantity( $item ); |
|
| 65 | - do_action( 'wpinv_cart_item_quantitiy', $item, $key ); |
|
| 64 | + echo wpinv_get_cart_item_quantity($item); |
|
| 65 | + do_action('wpinv_cart_item_quantitiy', $item, $key); |
|
| 66 | 66 | ?> |
| 67 | 67 | </td> |
| 68 | 68 | <?php } ?> |
| 69 | - <?php if ( $use_taxes ) { ?> |
|
| 69 | + <?php if ($use_taxes) { ?> |
|
| 70 | 70 | <td class="wpinv_cart_item_tax text-right"> |
| 71 | 71 | <?php |
| 72 | - echo wpinv_cart_item_tax( $item ); |
|
| 72 | + echo wpinv_cart_item_tax($item); |
|
| 73 | 73 | //echo wpinv_get_cart_item_tax( $wpi_item->ID, $subtotal = '', $options = array() ); |
| 74 | - do_action( 'wpinv_cart_item_tax', $item, $key ); |
|
| 74 | + do_action('wpinv_cart_item_tax', $item, $key); |
|
| 75 | 75 | ?> |
| 76 | 76 | </td> |
| 77 | 77 | <?php } ?> |
| 78 | 78 | <td class="wpinv_cart_item_subtotal text-right"> |
| 79 | 79 | <?php |
| 80 | - echo wpinv_cart_item_subtotal( $item ); |
|
| 81 | - do_action( 'wpinv_cart_item_subtotal', $item, $key ); |
|
| 80 | + echo wpinv_cart_item_subtotal($item); |
|
| 81 | + do_action('wpinv_cart_item_subtotal', $item, $key); |
|
| 82 | 82 | ?> |
| 83 | 83 | </td> |
| 84 | - <?php do_action( 'wpinv_checkout_table_body_last', $item, $key ); ?> |
|
| 84 | + <?php do_action('wpinv_checkout_table_body_last', $item, $key); ?> |
|
| 85 | 85 | </tr> |
| 86 | 86 | <?php } ?> |
| 87 | 87 | <?php } ?> |
| 88 | - <?php do_action( 'wpinv_cart_items_middle' ); ?> |
|
| 89 | - <?php do_action( 'wpinv_cart_items_after' ); ?> |
|
| 88 | + <?php do_action('wpinv_cart_items_middle'); ?> |
|
| 89 | + <?php do_action('wpinv_cart_items_after'); ?> |
|
| 90 | 90 | </tbody> |
| 91 | 91 | <tfoot> |
| 92 | 92 | <?php $cart_columns = wpinv_checkout_cart_columns(); ?> |
| 93 | - <?php if ( has_action( 'wpinv_cart_footer_buttons' ) ) { ?> |
|
| 93 | + <?php if (has_action('wpinv_cart_footer_buttons')) { ?> |
|
| 94 | 94 | <tr class="wpinv_cart_footer_row"> |
| 95 | - <?php do_action( 'wpinv_checkout_table_buttons_first', $cart_items ); ?> |
|
| 96 | - <td colspan="<?php echo ( $cart_columns ); ?>"> |
|
| 97 | - <?php do_action( 'wpinv_cart_footer_buttons' ); ?> |
|
| 95 | + <?php do_action('wpinv_checkout_table_buttons_first', $cart_items); ?> |
|
| 96 | + <td colspan="<?php echo ($cart_columns); ?>"> |
|
| 97 | + <?php do_action('wpinv_cart_footer_buttons'); ?> |
|
| 98 | 98 | </td> |
| 99 | - <?php do_action( 'wpinv_checkout_table_buttons_first', $cart_items ); ?> |
|
| 99 | + <?php do_action('wpinv_checkout_table_buttons_first', $cart_items); ?> |
|
| 100 | 100 | </tr> |
| 101 | 101 | <?php } ?> |
| 102 | 102 | |
| 103 | - <?php if ( $use_taxes && !wpinv_prices_include_tax() ) { ?> |
|
| 104 | - <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if ( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>> |
|
| 105 | - <?php do_action( 'wpinv_checkout_table_subtotal_first', $cart_items ); ?> |
|
| 106 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_subtotal_label text-right"> |
|
| 107 | - <strong><?php _e( 'Sub-Total', 'invoicing' ); ?>:</strong> |
|
| 103 | + <?php if ($use_taxes && !wpinv_prices_include_tax()) { ?> |
|
| 104 | + <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if (!wpinv_is_cart_taxed()) echo ' style="display:none;"'; ?>> |
|
| 105 | + <?php do_action('wpinv_checkout_table_subtotal_first', $cart_items); ?> |
|
| 106 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_subtotal_label text-right"> |
|
| 107 | + <strong><?php _e('Sub-Total', 'invoicing'); ?>:</strong> |
|
| 108 | 108 | </td> |
| 109 | 109 | <td class="wpinv_cart_subtotal text-right"> |
| 110 | - <span class="wpinv_cart_subtotal_amount bold"><?php echo wpinv_cart_subtotal( $cart_items ); ?></span> |
|
| 110 | + <span class="wpinv_cart_subtotal_amount bold"><?php echo wpinv_cart_subtotal($cart_items); ?></span> |
|
| 111 | 111 | </td> |
| 112 | - <?php do_action( 'wpinv_checkout_table_subtotal_last', $cart_items ); ?> |
|
| 112 | + <?php do_action('wpinv_checkout_table_subtotal_last', $cart_items); ?> |
|
| 113 | 113 | </tr> |
| 114 | 114 | <?php } ?> |
| 115 | 115 | |
| 116 | - <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html( $cart_items ); ?> |
|
| 116 | + <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html($cart_items); ?> |
|
| 117 | 117 | |
| 118 | - <?php if ( $use_taxes ) { ?> |
|
| 119 | - <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>> |
|
| 120 | - <?php do_action( 'wpinv_checkout_table_tax_first' ); ?> |
|
| 121 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_tax_label text-right"> |
|
| 118 | + <?php if ($use_taxes) { ?> |
|
| 119 | + <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if (!wpinv_is_cart_taxed()) echo ' style="display:none;"'; ?>> |
|
| 120 | + <?php do_action('wpinv_checkout_table_tax_first'); ?> |
|
| 121 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_tax_label text-right"> |
|
| 122 | 122 | <strong><?php echo $tax_label; ?>:</strong> |
| 123 | 123 | </td> |
| 124 | 124 | <td class="wpinv_cart_tax text-right"> |
| 125 | - <span class="wpinv_cart_tax_amount" data-tax="<?php echo wpinv_get_cart_tax( $cart_items ); ?>"><?php echo esc_html( wpinv_cart_tax( $cart_items ) ); ?></span> |
|
| 125 | + <span class="wpinv_cart_tax_amount" data-tax="<?php echo wpinv_get_cart_tax($cart_items); ?>"><?php echo esc_html(wpinv_cart_tax($cart_items)); ?></span> |
|
| 126 | 126 | </td> |
| 127 | - <?php do_action( 'wpinv_checkout_table_tax_last' ); ?> |
|
| 127 | + <?php do_action('wpinv_checkout_table_tax_last'); ?> |
|
| 128 | 128 | </tr> |
| 129 | 129 | <?php } ?> |
| 130 | 130 | |
| 131 | 131 | <tr class="wpinv_cart_footer_row wpinv_cart_total_row"> |
| 132 | - <?php do_action( 'wpinv_checkout_table_footer_first' ); ?> |
|
| 133 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_total_label text-right"> |
|
| 134 | - <?php echo apply_filters( 'wpinv_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?> |
|
| 132 | + <?php do_action('wpinv_checkout_table_footer_first'); ?> |
|
| 133 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_total_label text-right"> |
|
| 134 | + <?php echo apply_filters('wpinv_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?> |
|
| 135 | 135 | </td> |
| 136 | 136 | <td class="wpinv_cart_total text-right"> |
| 137 | - <span class="wpinv_cart_amount bold" data-subtotal="<?php echo wpinv_get_cart_total( $cart_items ); ?>" data-total="<?php echo wpinv_get_cart_total( NULL, NULL, $invoice ); ?>"><?php wpinv_cart_total( $cart_items, true, $invoice ); ?></span> |
|
| 137 | + <span class="wpinv_cart_amount bold" data-subtotal="<?php echo wpinv_get_cart_total($cart_items); ?>" data-total="<?php echo wpinv_get_cart_total(NULL, NULL, $invoice); ?>"><?php wpinv_cart_total($cart_items, true, $invoice); ?></span> |
|
| 138 | 138 | </td> |
| 139 | - <?php do_action( 'wpinv_checkout_table_footer_last' ); ?> |
|
| 139 | + <?php do_action('wpinv_checkout_table_footer_last'); ?> |
|
| 140 | 140 | </tr> |
| 141 | 141 | </tfoot> |
| 142 | 142 | </table> |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly |
| 3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if (!defined('ABSPATH')) exit; |
|
| 4 | 4 | |
| 5 | 5 | class WPInv_Item { |
| 6 | 6 | public $ID = 0; |
@@ -47,26 +47,26 @@ discard block |
||
| 47 | 47 | public $filter; |
| 48 | 48 | |
| 49 | 49 | |
| 50 | - public function __construct( $_id = false, $_args = array() ) { |
|
| 51 | - $item = WP_Post::get_instance( $_id ); |
|
| 52 | - return $this->setup_item( $item ); |
|
| 50 | + public function __construct($_id = false, $_args = array()) { |
|
| 51 | + $item = WP_Post::get_instance($_id); |
|
| 52 | + return $this->setup_item($item); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - private function setup_item( $item ) { |
|
| 56 | - if( ! is_object( $item ) ) { |
|
| 55 | + private function setup_item($item) { |
|
| 56 | + if (!is_object($item)) { |
|
| 57 | 57 | return false; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if( ! is_a( $item, 'WP_Post' ) ) { |
|
| 60 | + if (!is_a($item, 'WP_Post')) { |
|
| 61 | 61 | return false; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - if( 'wpi_item' !== $item->post_type ) { |
|
| 64 | + if ('wpi_item' !== $item->post_type) { |
|
| 65 | 65 | return false; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - foreach ( $item as $key => $value ) { |
|
| 69 | - switch ( $key ) { |
|
| 68 | + foreach ($item as $key => $value) { |
|
| 69 | + switch ($key) { |
|
| 70 | 70 | default: |
| 71 | 71 | $this->$key = $value; |
| 72 | 72 | break; |
@@ -76,38 +76,38 @@ discard block |
||
| 76 | 76 | return true; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - public function __get( $key ) { |
|
| 80 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
| 81 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
| 79 | + public function __get($key) { |
|
| 80 | + if (method_exists($this, 'get_' . $key)) { |
|
| 81 | + return call_user_func(array($this, 'get_' . $key)); |
|
| 82 | 82 | } else { |
| 83 | - return new WP_Error( 'wpinv-item-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) ); |
|
| 83 | + return new WP_Error('wpinv-item-invalid-property', sprintf(__('Can\'t get property %s', 'invoicing'), $key)); |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - public function create( $data = array(), $wp_error = false ) { |
|
| 88 | - if ( $this->ID != 0 ) { |
|
| 87 | + public function create($data = array(), $wp_error = false) { |
|
| 88 | + if ($this->ID != 0) { |
|
| 89 | 89 | return false; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | $defaults = array( |
| 93 | 93 | 'post_type' => 'wpi_item', |
| 94 | 94 | 'post_status' => 'draft', |
| 95 | - 'post_title' => __( 'New Invoice Item', 'invoicing' ) |
|
| 95 | + 'post_title' => __('New Invoice Item', 'invoicing') |
|
| 96 | 96 | ); |
| 97 | 97 | |
| 98 | - $args = wp_parse_args( $data, $defaults ); |
|
| 98 | + $args = wp_parse_args($data, $defaults); |
|
| 99 | 99 | |
| 100 | - do_action( 'wpinv_item_pre_create', $args ); |
|
| 100 | + do_action('wpinv_item_pre_create', $args); |
|
| 101 | 101 | |
| 102 | - $id = wp_insert_post( $args, $wp_error ); |
|
| 102 | + $id = wp_insert_post($args, $wp_error); |
|
| 103 | 103 | if ($wp_error && is_wp_error($id)) { |
| 104 | 104 | return $id; |
| 105 | 105 | } |
| 106 | - if ( !$id ) { |
|
| 106 | + if (!$id) { |
|
| 107 | 107 | return false; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - $item = WP_Post::get_instance( $id ); |
|
| 110 | + $item = WP_Post::get_instance($id); |
|
| 111 | 111 | |
| 112 | 112 | if (!empty($item) && !empty($data['meta'])) { |
| 113 | 113 | $this->ID = $item->ID; |
@@ -115,47 +115,47 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | // Set custom id if not set. |
| 118 | - if ( empty( $data['meta']['custom_id'] ) && !$this->get_custom_id() ) { |
|
| 119 | - $this->save_metas( array( 'custom_id' => $id ) ); |
|
| 118 | + if (empty($data['meta']['custom_id']) && !$this->get_custom_id()) { |
|
| 119 | + $this->save_metas(array('custom_id' => $id)); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - do_action( 'wpinv_item_create', $id, $args ); |
|
| 122 | + do_action('wpinv_item_create', $id, $args); |
|
| 123 | 123 | |
| 124 | - return $this->setup_item( $item ); |
|
| 124 | + return $this->setup_item($item); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - public function update( $data = array(), $wp_error = false ) { |
|
| 128 | - if ( !$this->ID > 0 ) { |
|
| 127 | + public function update($data = array(), $wp_error = false) { |
|
| 128 | + if (!$this->ID > 0) { |
|
| 129 | 129 | return false; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | $data['ID'] = $this->ID; |
| 133 | 133 | |
| 134 | - do_action( 'wpinv_item_pre_update', $data ); |
|
| 134 | + do_action('wpinv_item_pre_update', $data); |
|
| 135 | 135 | |
| 136 | - $id = wp_update_post( $data, $wp_error ); |
|
| 136 | + $id = wp_update_post($data, $wp_error); |
|
| 137 | 137 | if ($wp_error && is_wp_error($id)) { |
| 138 | 138 | return $id; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if ( !$id ) { |
|
| 141 | + if (!$id) { |
|
| 142 | 142 | return false; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - $item = WP_Post::get_instance( $id ); |
|
| 145 | + $item = WP_Post::get_instance($id); |
|
| 146 | 146 | if (!empty($item) && !empty($data['meta'])) { |
| 147 | 147 | $this->ID = $item->ID; |
| 148 | 148 | $this->save_metas($data['meta']); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Set custom id if not set. |
| 152 | - if ( empty( $data['meta']['custom_id'] ) && !$this->get_custom_id() ) { |
|
| 153 | - $this->save_metas( array( 'custom_id' => $id ) ); |
|
| 152 | + if (empty($data['meta']['custom_id']) && !$this->get_custom_id()) { |
|
| 153 | + $this->save_metas(array('custom_id' => $id)); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - do_action( 'wpinv_item_update', $id, $data ); |
|
| 156 | + do_action('wpinv_item_update', $id, $data); |
|
| 157 | 157 | |
| 158 | - return $this->setup_item( $item ); |
|
| 158 | + return $this->setup_item($item); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | public function get_ID() { |
@@ -163,119 +163,119 @@ discard block |
||
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | public function get_name() { |
| 166 | - return get_the_title( $this->ID ); |
|
| 166 | + return get_the_title($this->ID); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | public function get_title() { |
| 170 | - return get_the_title( $this->ID ); |
|
| 170 | + return get_the_title($this->ID); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | public function get_status() { |
| 174 | - return get_post_status( $this->ID ); |
|
| 174 | + return get_post_status($this->ID); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | public function get_summary() { |
| 178 | - return get_the_excerpt( $this->ID ); |
|
| 178 | + return get_the_excerpt($this->ID); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | public function get_price() { |
| 182 | - if ( ! isset( $this->price ) ) { |
|
| 183 | - $this->price = get_post_meta( $this->ID, '_wpinv_price', true ); |
|
| 182 | + if (!isset($this->price)) { |
|
| 183 | + $this->price = get_post_meta($this->ID, '_wpinv_price', true); |
|
| 184 | 184 | |
| 185 | - if ( $this->price ) { |
|
| 186 | - $this->price = wpinv_sanitize_amount( $this->price ); |
|
| 185 | + if ($this->price) { |
|
| 186 | + $this->price = wpinv_sanitize_amount($this->price); |
|
| 187 | 187 | } else { |
| 188 | 188 | $this->price = 0; |
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - return apply_filters( 'wpinv_get_item_price', $this->price, $this->ID ); |
|
| 192 | + return apply_filters('wpinv_get_item_price', $this->price, $this->ID); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | public function get_vat_rule() { |
| 196 | 196 | global $wpinv_euvat; |
| 197 | 197 | |
| 198 | - if( !isset( $this->vat_rule ) ) { |
|
| 199 | - $this->vat_rule = get_post_meta( $this->ID, '_wpinv_vat_rule', true ); |
|
| 198 | + if (!isset($this->vat_rule)) { |
|
| 199 | + $this->vat_rule = get_post_meta($this->ID, '_wpinv_vat_rule', true); |
|
| 200 | 200 | |
| 201 | - if ( empty( $this->vat_rule ) ) { |
|
| 201 | + if (empty($this->vat_rule)) { |
|
| 202 | 202 | $this->vat_rule = $wpinv_euvat->allow_vat_rules() ? 'digital' : 'physical'; |
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - return apply_filters( 'wpinv_get_item_vat_rule', $this->vat_rule, $this->ID ); |
|
| 206 | + return apply_filters('wpinv_get_item_vat_rule', $this->vat_rule, $this->ID); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | public function get_vat_class() { |
| 210 | - if( !isset( $this->vat_class ) ) { |
|
| 211 | - $this->vat_class = get_post_meta( $this->ID, '_wpinv_vat_class', true ); |
|
| 210 | + if (!isset($this->vat_class)) { |
|
| 211 | + $this->vat_class = get_post_meta($this->ID, '_wpinv_vat_class', true); |
|
| 212 | 212 | |
| 213 | - if ( empty( $this->vat_class ) ) { |
|
| 213 | + if (empty($this->vat_class)) { |
|
| 214 | 214 | $this->vat_class = '_standard'; |
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - return apply_filters( 'wpinv_get_item_vat_class', $this->vat_class, $this->ID ); |
|
| 218 | + return apply_filters('wpinv_get_item_vat_class', $this->vat_class, $this->ID); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | public function get_type() { |
| 222 | - if( ! isset( $this->type ) ) { |
|
| 223 | - $this->type = get_post_meta( $this->ID, '_wpinv_type', true ); |
|
| 222 | + if (!isset($this->type)) { |
|
| 223 | + $this->type = get_post_meta($this->ID, '_wpinv_type', true); |
|
| 224 | 224 | |
| 225 | - if ( empty( $this->type ) ) { |
|
| 225 | + if (empty($this->type)) { |
|
| 226 | 226 | $this->type = 'custom'; |
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - return apply_filters( 'wpinv_get_item_type', $this->type, $this->ID ); |
|
| 230 | + return apply_filters('wpinv_get_item_type', $this->type, $this->ID); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | public function get_custom_id() { |
| 234 | - $custom_id = get_post_meta( $this->ID, '_wpinv_custom_id', true ); |
|
| 234 | + $custom_id = get_post_meta($this->ID, '_wpinv_custom_id', true); |
|
| 235 | 235 | |
| 236 | - return apply_filters( 'wpinv_get_item_custom_id', $custom_id, $this->ID ); |
|
| 236 | + return apply_filters('wpinv_get_item_custom_id', $custom_id, $this->ID); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | public function get_custom_name() { |
| 240 | - $custom_name = get_post_meta( $this->ID, '_wpinv_custom_name', true ); |
|
| 240 | + $custom_name = get_post_meta($this->ID, '_wpinv_custom_name', true); |
|
| 241 | 241 | |
| 242 | - return apply_filters( 'wpinv_get_item_custom_name', $custom_name, $this->ID ); |
|
| 242 | + return apply_filters('wpinv_get_item_custom_name', $custom_name, $this->ID); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | public function get_custom_singular_name() { |
| 246 | - $custom_singular_name = get_post_meta( $this->ID, '_wpinv_custom_singular_name', true ); |
|
| 246 | + $custom_singular_name = get_post_meta($this->ID, '_wpinv_custom_singular_name', true); |
|
| 247 | 247 | |
| 248 | - return apply_filters( 'wpinv_get_item_custom_singular_name', $custom_singular_name, $this->ID ); |
|
| 248 | + return apply_filters('wpinv_get_item_custom_singular_name', $custom_singular_name, $this->ID); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | public function get_editable() { |
| 252 | - $editable = get_post_meta( $this->ID, '_wpinv_editable', true ); |
|
| 252 | + $editable = get_post_meta($this->ID, '_wpinv_editable', true); |
|
| 253 | 253 | |
| 254 | - return apply_filters( 'wpinv_item_get_editable', $editable, $this->ID ); |
|
| 254 | + return apply_filters('wpinv_item_get_editable', $editable, $this->ID); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | public function get_excerpt() { |
| 258 | - $excerpt = get_the_excerpt( $this->ID ); |
|
| 258 | + $excerpt = get_the_excerpt($this->ID); |
|
| 259 | 259 | |
| 260 | - return apply_filters( 'wpinv_item_get_excerpt', $excerpt, $this->ID ); |
|
| 260 | + return apply_filters('wpinv_item_get_excerpt', $excerpt, $this->ID); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | public function get_is_recurring() { |
| 264 | - $is_recurring = get_post_meta( $this->ID, '_wpinv_is_recurring', true ); |
|
| 264 | + $is_recurring = get_post_meta($this->ID, '_wpinv_is_recurring', true); |
|
| 265 | 265 | |
| 266 | - return apply_filters( 'wpinv_item_get_is_recurring', $is_recurring, $this->ID ); |
|
| 266 | + return apply_filters('wpinv_item_get_is_recurring', $is_recurring, $this->ID); |
|
| 267 | 267 | |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - public function get_recurring_period( $full = false ) { |
|
| 271 | - $period = get_post_meta( $this->ID, '_wpinv_recurring_period', true ); |
|
| 270 | + public function get_recurring_period($full = false) { |
|
| 271 | + $period = get_post_meta($this->ID, '_wpinv_recurring_period', true); |
|
| 272 | 272 | |
| 273 | - if ( !in_array( $period, array( 'D', 'W', 'M', 'Y' ) ) ) { |
|
| 273 | + if (!in_array($period, array('D', 'W', 'M', 'Y'))) { |
|
| 274 | 274 | $period = 'D'; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - if ( $full ) { |
|
| 278 | - switch( $period ) { |
|
| 277 | + if ($full) { |
|
| 278 | + switch ($period) { |
|
| 279 | 279 | case 'D': |
| 280 | 280 | $period = 'day'; |
| 281 | 281 | break; |
@@ -291,40 +291,40 @@ discard block |
||
| 291 | 291 | } |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - return apply_filters( 'wpinv_item_recurring_period', $period, $full, $this->ID ); |
|
| 294 | + return apply_filters('wpinv_item_recurring_period', $period, $full, $this->ID); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | public function get_recurring_interval() { |
| 298 | - $interval = (int)get_post_meta( $this->ID, '_wpinv_recurring_interval', true ); |
|
| 298 | + $interval = (int)get_post_meta($this->ID, '_wpinv_recurring_interval', true); |
|
| 299 | 299 | |
| 300 | - if ( !$interval > 0 ) { |
|
| 300 | + if (!$interval > 0) { |
|
| 301 | 301 | $interval = 1; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - return apply_filters( 'wpinv_item_recurring_interval', $interval, $this->ID ); |
|
| 304 | + return apply_filters('wpinv_item_recurring_interval', $interval, $this->ID); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | public function get_recurring_limit() { |
| 308 | - $limit = get_post_meta( $this->ID, '_wpinv_recurring_limit', true ); |
|
| 308 | + $limit = get_post_meta($this->ID, '_wpinv_recurring_limit', true); |
|
| 309 | 309 | |
| 310 | - return (int)apply_filters( 'wpinv_item_recurring_limit', $limit, $this->ID ); |
|
| 310 | + return (int)apply_filters('wpinv_item_recurring_limit', $limit, $this->ID); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | public function get_free_trial() { |
| 314 | - $free_trial = get_post_meta( $this->ID, '_wpinv_free_trial', true ); |
|
| 314 | + $free_trial = get_post_meta($this->ID, '_wpinv_free_trial', true); |
|
| 315 | 315 | |
| 316 | - return apply_filters( 'wpinv_item_get_free_trial', $free_trial, $this->ID ); |
|
| 316 | + return apply_filters('wpinv_item_get_free_trial', $free_trial, $this->ID); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - public function get_trial_period( $full = false ) { |
|
| 320 | - $period = get_post_meta( $this->ID, '_wpinv_trial_period', true ); |
|
| 319 | + public function get_trial_period($full = false) { |
|
| 320 | + $period = get_post_meta($this->ID, '_wpinv_trial_period', true); |
|
| 321 | 321 | |
| 322 | - if ( !in_array( $period, array( 'D', 'W', 'M', 'Y' ) ) ) { |
|
| 322 | + if (!in_array($period, array('D', 'W', 'M', 'Y'))) { |
|
| 323 | 323 | $period = 'D'; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - if ( $full ) { |
|
| 327 | - switch( $period ) { |
|
| 326 | + if ($full) { |
|
| 327 | + switch ($period) { |
|
| 328 | 328 | case 'D': |
| 329 | 329 | $period = 'day'; |
| 330 | 330 | break; |
@@ -340,47 +340,47 @@ discard block |
||
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - return apply_filters( 'wpinv_item_trial_period', $period, $full, $this->ID ); |
|
| 343 | + return apply_filters('wpinv_item_trial_period', $period, $full, $this->ID); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | public function get_trial_interval() { |
| 347 | - $interval = absint( get_post_meta( $this->ID, '_wpinv_trial_interval', true ) ); |
|
| 347 | + $interval = absint(get_post_meta($this->ID, '_wpinv_trial_interval', true)); |
|
| 348 | 348 | |
| 349 | - if ( !$interval > 0 ) { |
|
| 349 | + if (!$interval > 0) { |
|
| 350 | 350 | $interval = 1; |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | - return apply_filters( 'wpinv_item_trial_interval', $interval, $this->ID ); |
|
| 353 | + return apply_filters('wpinv_item_trial_interval', $interval, $this->ID); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | public function get_the_price() { |
| 357 | - $item_price = wpinv_price( wpinv_format_amount( $this->price ) ); |
|
| 357 | + $item_price = wpinv_price(wpinv_format_amount($this->price)); |
|
| 358 | 358 | |
| 359 | - return apply_filters( 'wpinv_get_the_item_price', $item_price, $this->ID ); |
|
| 359 | + return apply_filters('wpinv_get_the_item_price', $item_price, $this->ID); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | public function is_recurring() { |
| 363 | 363 | $is_recurring = $this->get_is_recurring(); |
| 364 | 364 | |
| 365 | - return (bool)apply_filters( 'wpinv_is_recurring_item', $is_recurring, $this->ID ); |
|
| 365 | + return (bool)apply_filters('wpinv_is_recurring_item', $is_recurring, $this->ID); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | public function has_free_trial() { |
| 369 | 369 | $free_trial = $this->is_recurring() && $this->get_free_trial() ? true : false; |
| 370 | 370 | |
| 371 | - return (bool)apply_filters( 'wpinv_item_has_free_trial', $free_trial, $this->ID ); |
|
| 371 | + return (bool)apply_filters('wpinv_item_has_free_trial', $free_trial, $this->ID); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | public function is_free() { |
| 375 | 375 | $is_free = false; |
| 376 | 376 | |
| 377 | - $price = get_post_meta( $this->ID, '_wpinv_price', true ); |
|
| 377 | + $price = get_post_meta($this->ID, '_wpinv_price', true); |
|
| 378 | 378 | |
| 379 | - if ( (float)$price == 0 ) { |
|
| 379 | + if ((float)$price == 0) { |
|
| 380 | 380 | $is_free = true; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID ); |
|
| 383 | + return (bool)apply_filters('wpinv_is_free_item', $is_free, $this->ID); |
|
| 384 | 384 | |
| 385 | 385 | } |
| 386 | 386 | |
@@ -389,15 +389,15 @@ discard block |
||
| 389 | 389 | |
| 390 | 390 | $is_editable = $editable === 0 || $editable === '0' ? false : true; |
| 391 | 391 | |
| 392 | - return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID ); |
|
| 392 | + return (bool)apply_filters('wpinv_item_is_editable', $is_editable, $this->ID); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - public function save_metas( $metas = array() ) { |
|
| 396 | - if ( empty( $metas ) ) { |
|
| 395 | + public function save_metas($metas = array()) { |
|
| 396 | + if (empty($metas)) { |
|
| 397 | 397 | return false; |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - foreach ( $metas as $meta_key => $meta_value ) { |
|
| 400 | + foreach ($metas as $meta_key => $meta_value) { |
|
| 401 | 401 | $meta_key = strpos($meta_key, '_wpinv_') !== 0 ? '_wpinv_' . $meta_key : $meta_key; |
| 402 | 402 | |
| 403 | 403 | $this->update_meta($meta_key, $meta_value); |
@@ -406,66 +406,66 @@ discard block |
||
| 406 | 406 | return true; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
| 410 | - if ( empty( $meta_key ) ) { |
|
| 409 | + public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') { |
|
| 410 | + if (empty($meta_key)) { |
|
| 411 | 411 | return false; |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - $meta_value = apply_filters( 'wpinv_update_item_meta_' . $meta_key, $meta_value, $this->ID ); |
|
| 414 | + $meta_value = apply_filters('wpinv_update_item_meta_' . $meta_key, $meta_value, $this->ID); |
|
| 415 | 415 | |
| 416 | - return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value ); |
|
| 416 | + return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value); |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - public function get_fees( $type = 'fee', $item_id = 0 ) { |
|
| 419 | + public function get_fees($type = 'fee', $item_id = 0) { |
|
| 420 | 420 | global $wpi_session; |
| 421 | 421 | |
| 422 | - $fees = $wpi_session->get( 'wpi_cart_fees' ); |
|
| 422 | + $fees = $wpi_session->get('wpi_cart_fees'); |
|
| 423 | 423 | |
| 424 | - if ( ! wpinv_get_cart_contents() ) { |
|
| 424 | + if (!wpinv_get_cart_contents()) { |
|
| 425 | 425 | // We can only get item type fees when the cart is empty |
| 426 | 426 | $type = 'custom'; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - if ( ! empty( $fees ) && ! empty( $type ) && 'all' !== $type ) { |
|
| 430 | - foreach( $fees as $key => $fee ) { |
|
| 431 | - if( ! empty( $fee['type'] ) && $type != $fee['type'] ) { |
|
| 432 | - unset( $fees[ $key ] ); |
|
| 429 | + if (!empty($fees) && !empty($type) && 'all' !== $type) { |
|
| 430 | + foreach ($fees as $key => $fee) { |
|
| 431 | + if (!empty($fee['type']) && $type != $fee['type']) { |
|
| 432 | + unset($fees[$key]); |
|
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | - if ( ! empty( $fees ) && ! empty( $item_id ) ) { |
|
| 437 | + if (!empty($fees) && !empty($item_id)) { |
|
| 438 | 438 | // Remove fees that don't belong to the specified Item |
| 439 | - foreach ( $fees as $key => $fee ) { |
|
| 440 | - if ( (int) $item_id !== (int)$fee['custom_id'] ) { |
|
| 441 | - unset( $fees[ $key ] ); |
|
| 439 | + foreach ($fees as $key => $fee) { |
|
| 440 | + if ((int)$item_id !== (int)$fee['custom_id']) { |
|
| 441 | + unset($fees[$key]); |
|
| 442 | 442 | } |
| 443 | 443 | } |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | - if ( ! empty( $fees ) ) { |
|
| 446 | + if (!empty($fees)) { |
|
| 447 | 447 | // Remove fees that belong to a specific item but are not in the cart |
| 448 | - foreach( $fees as $key => $fee ) { |
|
| 449 | - if( empty( $fee['custom_id'] ) ) { |
|
| 448 | + foreach ($fees as $key => $fee) { |
|
| 449 | + if (empty($fee['custom_id'])) { |
|
| 450 | 450 | continue; |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | - if ( !wpinv_item_in_cart( $fee['custom_id'] ) ) { |
|
| 454 | - unset( $fees[ $key ] ); |
|
| 453 | + if (!wpinv_item_in_cart($fee['custom_id'])) { |
|
| 454 | + unset($fees[$key]); |
|
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | - return ! empty( $fees ) ? $fees : array(); |
|
| 459 | + return !empty($fees) ? $fees : array(); |
|
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | public function can_purchase() { |
| 463 | 463 | $can_purchase = true; |
| 464 | 464 | |
| 465 | - if ( !current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) { |
|
| 465 | + if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') { |
|
| 466 | 466 | $can_purchase = false; |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | - return (bool)apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this ); |
|
| 469 | + return (bool)apply_filters('wpinv_can_purchase_item', $can_purchase, $this); |
|
| 470 | 470 | } |
| 471 | 471 | } |
@@ -9,58 +9,58 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | // If uninstall not called from WordPress, then exit. |
| 12 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
| 12 | +if (!defined('WP_UNINSTALL_PLUGIN')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | global $wpdb, $wp_version; |
| 17 | 17 | |
| 18 | -$remove_data = get_option( 'wpinv_remove_data_on_invoice_unistall' ); |
|
| 18 | +$remove_data = get_option('wpinv_remove_data_on_invoice_unistall'); |
|
| 19 | 19 | |
| 20 | 20 | /* |
| 21 | 21 | * Only remove ALL product and page data if WPINV_REMOVE_ALL_DATA constant is set to true in user's |
| 22 | 22 | * wp-config.php. This is to prevent data loss when deleting the plugin from the backend |
| 23 | 23 | * and to ensure only the site owner can perform this action. |
| 24 | 24 | */ |
| 25 | -if ( defined( 'WPINV_REMOVE_ALL_DATA' ) ) { |
|
| 25 | +if (defined('WPINV_REMOVE_ALL_DATA')) { |
|
| 26 | 26 | $remove_data = true === WPINV_REMOVE_ALL_DATA ? true : false; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | -if ( $remove_data ) { |
|
| 29 | +if ($remove_data) { |
|
| 30 | 30 | // Load Invoicing file. |
| 31 | - include_once( 'invoicing.php' ); |
|
| 31 | + include_once('invoicing.php'); |
|
| 32 | 32 | |
| 33 | 33 | // Roles + caps. |
| 34 | - include_once( dirname( __FILE__ ) . '/includes/admin/install.php' ); |
|
| 34 | + include_once(dirname(__FILE__) . '/includes/admin/install.php'); |
|
| 35 | 35 | wpinv_remove_admin_caps(); |
| 36 | 36 | |
| 37 | - $settings = get_option( 'wpinv_settings' ); |
|
| 37 | + $settings = get_option('wpinv_settings'); |
|
| 38 | 38 | |
| 39 | 39 | // Delete pages. |
| 40 | - $wpi_pages = array( 'checkout_page', 'success_page', 'failure_page', 'invoice_history_page', 'quote_history_page', 'invoice_subscription_page' ); |
|
| 41 | - foreach ( $wpi_pages as $page ) { |
|
| 42 | - if ( !empty( $page ) && !empty( $settings[ $page ] ) ) { |
|
| 43 | - wp_delete_post( $settings[ $page ], true ); |
|
| 40 | + $wpi_pages = array('checkout_page', 'success_page', 'failure_page', 'invoice_history_page', 'quote_history_page', 'invoice_subscription_page'); |
|
| 41 | + foreach ($wpi_pages as $page) { |
|
| 42 | + if (!empty($page) && !empty($settings[$page])) { |
|
| 43 | + wp_delete_post($settings[$page], true); |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | // Delete posts + data. |
| 48 | - $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'wpi_invoice', 'wpi_item', 'wpi_discount', 'wpi_quote' );" ); |
|
| 49 | - $wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" ); |
|
| 48 | + $wpdb->query("DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'wpi_invoice', 'wpi_item', 'wpi_discount', 'wpi_quote' );"); |
|
| 49 | + $wpdb->query("DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;"); |
|
| 50 | 50 | |
| 51 | 51 | // Delete comments. |
| 52 | - $wpdb->query( "DELETE FROM {$wpdb->comments} WHERE comment_type LIKE 'wpinv_note';" ); |
|
| 53 | - $wpdb->query( "DELETE meta FROM {$wpdb->commentmeta} meta LEFT JOIN {$wpdb->comments} comments ON comments.comment_ID = meta.comment_id WHERE comments.comment_ID IS NULL;" ); |
|
| 52 | + $wpdb->query("DELETE FROM {$wpdb->comments} WHERE comment_type LIKE 'wpinv_note';"); |
|
| 53 | + $wpdb->query("DELETE meta FROM {$wpdb->commentmeta} meta LEFT JOIN {$wpdb->comments} comments ON comments.comment_ID = meta.comment_id WHERE comments.comment_ID IS NULL;"); |
|
| 54 | 54 | |
| 55 | 55 | // Delete user meta. |
| 56 | - $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%_wpinv_%' OR meta_key LIKE '%_wpi_invoice%' OR meta_key LIKE '%_wpi_item%' OR meta_key LIKE '%_wpi_discount%' OR meta_key LIKE '_wpi_stripe%' OR meta_key LIKE '%_wpi_quote%';" ); |
|
| 56 | + $wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%_wpinv_%' OR meta_key LIKE '%_wpi_invoice%' OR meta_key LIKE '%_wpi_item%' OR meta_key LIKE '%_wpi_discount%' OR meta_key LIKE '_wpi_stripe%' OR meta_key LIKE '%_wpi_quote%';"); |
|
| 57 | 57 | |
| 58 | 58 | // Cleanup Cron Schedule |
| 59 | - wp_clear_scheduled_hook( 'wp_session_garbage_collection' ); |
|
| 60 | - wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' ); |
|
| 59 | + wp_clear_scheduled_hook('wp_session_garbage_collection'); |
|
| 60 | + wp_clear_scheduled_hook('wpinv_register_schedule_event_twicedaily'); |
|
| 61 | 61 | |
| 62 | 62 | // Delete options. |
| 63 | - $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wpinv_%' OR option_name LIKE '_wpinv_%' OR option_name LIKE '\_transient\_wpinv\_%';" ); |
|
| 63 | + $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wpinv_%' OR option_name LIKE '_wpinv_%' OR option_name LIKE '\_transient\_wpinv\_%';"); |
|
| 64 | 64 | |
| 65 | 65 | // Clear any cached data that has been removed |
| 66 | 66 | wp_cache_flush(); |
@@ -1,68 +1,68 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | 6 | global $wpinv_euvat; |
| 7 | 7 | |
| 8 | -$sent_to_admin = !empty( $sent_to_admin ) ? true : false; |
|
| 9 | -$invoice_url = $invoice->get_view_url( true ); |
|
| 8 | +$sent_to_admin = !empty($sent_to_admin) ? true : false; |
|
| 9 | +$invoice_url = $invoice->get_view_url(true); |
|
| 10 | 10 | $use_taxes = wpinv_use_taxes(); |
| 11 | 11 | $vat_name = $wpinv_euvat->get_vat_name(); |
| 12 | 12 | |
| 13 | -do_action( 'wpinv_email_before_invoice_details', $invoice, $sent_to_admin ); ?> |
|
| 13 | +do_action('wpinv_email_before_invoice_details', $invoice, $sent_to_admin); ?> |
|
| 14 | 14 | <div id="wpinv-email-details"> |
| 15 | - <h3 class="wpinv-details-t"><?php echo apply_filters( 'wpinv_email_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ); ?></h3> |
|
| 15 | + <h3 class="wpinv-details-t"><?php echo apply_filters('wpinv_email_details_title', __('Invoice Details', 'invoicing'), $invoice); ?></h3> |
|
| 16 | 16 | <table class="table table-bordered table-sm"> |
| 17 | - <?php if ( $invoice_number = $invoice->get_number() ) { ?> |
|
| 17 | + <?php if ($invoice_number = $invoice->get_number()) { ?> |
|
| 18 | 18 | <tr> |
| 19 | - <td><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></td> |
|
| 20 | - <td><a href="<?php echo esc_url( $invoice_url ) ;?>"><?php echo $invoice_number; ?></a></td> |
|
| 19 | + <td><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></td> |
|
| 20 | + <td><a href="<?php echo esc_url($invoice_url); ?>"><?php echo $invoice_number; ?></a></td> |
|
| 21 | 21 | </tr> |
| 22 | 22 | <?php } ?> |
| 23 | 23 | <tr> |
| 24 | - <td><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></td> |
|
| 25 | - <td><?php echo $invoice->get_status( true ); ?></td> |
|
| 24 | + <td><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></td> |
|
| 25 | + <td><?php echo $invoice->get_status(true); ?></td> |
|
| 26 | 26 | </tr> |
| 27 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
| 27 | + <?php if ($invoice->is_renewal()) { ?> |
|
| 28 | 28 | <tr> |
| 29 | - <td><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></td> |
|
| 30 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
| 29 | + <td><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></td> |
|
| 30 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
| 31 | 31 | </tr> |
| 32 | 32 | <?php } ?> |
| 33 | - <?php if ( ( $gateway_title = $invoice->get_gateway_title() ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?> |
|
| 34 | - <td><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></td> |
|
| 33 | + <?php if (($gateway_title = $invoice->get_gateway_title()) && ($invoice->is_paid() || $invoice->is_refunded())) { ?> |
|
| 34 | + <td><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></td> |
|
| 35 | 35 | <td><?php echo $gateway_title; ?></td> |
| 36 | 36 | <?php } ?> |
| 37 | - <?php if ( $invoice_date = $invoice->get_invoice_date( false ) ) { ?> |
|
| 37 | + <?php if ($invoice_date = $invoice->get_invoice_date(false)) { ?> |
|
| 38 | 38 | <tr> |
| 39 | - <td><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></td> |
|
| 40 | - <td><?php echo wp_sprintf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $invoice_date ) ), $invoice->get_invoice_date() ); ?></td> |
|
| 39 | + <td><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></td> |
|
| 40 | + <td><?php echo wp_sprintf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($invoice_date)), $invoice->get_invoice_date()); ?></td> |
|
| 41 | 41 | </tr> |
| 42 | 42 | <?php } ?> |
| 43 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date() ) ) { ?> |
|
| 43 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date())) { ?> |
|
| 44 | 44 | <tr> |
| 45 | - <td><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></td> |
|
| 46 | - <td><?php echo wp_sprintf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $due_date ) ), $invoice->get_due_date( true ) ); ?></td> |
|
| 45 | + <td><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></td> |
|
| 46 | + <td><?php echo wp_sprintf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($due_date)), $invoice->get_due_date(true)); ?></td> |
|
| 47 | 47 | </tr> |
| 48 | 48 | <?php } ?> |
| 49 | - <?php do_action( 'wpinv_email_invoice_details_after_due_date', $invoice->ID ); ?> |
|
| 50 | - <?php if ( empty( $sent_to_admin ) && ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) ) { ?> |
|
| 49 | + <?php do_action('wpinv_email_invoice_details_after_due_date', $invoice->ID); ?> |
|
| 50 | + <?php if (empty($sent_to_admin) && ($owner_vat_number = $wpinv_euvat->get_vat_number())) { ?> |
|
| 51 | 51 | <tr> |
| 52 | - <td><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></td> |
|
| 52 | + <td><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></td> |
|
| 53 | 53 | <td><?php echo $owner_vat_number; ?></td> |
| 54 | 54 | </tr> |
| 55 | 55 | <?php } ?> |
| 56 | - <?php if ( $use_taxes && ( $user_vat_number = $invoice->vat_number ) ) { ?> |
|
| 56 | + <?php if ($use_taxes && ($user_vat_number = $invoice->vat_number)) { ?> |
|
| 57 | 57 | <tr> |
| 58 | - <td><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></td> |
|
| 58 | + <td><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></td> |
|
| 59 | 59 | <td><?php echo $user_vat_number; ?></td> |
| 60 | 60 | </tr> |
| 61 | 61 | <?php } ?> |
| 62 | 62 | <tr class="table-active"> |
| 63 | - <td><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></td> |
|
| 64 | - <td><strong><?php echo $invoice->get_total( true ); ?></strong></td> |
|
| 63 | + <td><strong><?php _e('Total Amount', 'invoicing') ?></strong></td> |
|
| 64 | + <td><strong><?php echo $invoice->get_total(true); ?></strong></td> |
|
| 65 | 65 | </tr> |
| 66 | 66 | </table> |
| 67 | 67 | </div> |
| 68 | -<?php do_action( 'wpinv_email_after_invoice_details', $invoice, $sent_to_admin ); ?> |
|
| 69 | 68 | \ No newline at end of file |
| 69 | +<?php do_action('wpinv_email_after_invoice_details', $invoice, $sent_to_admin); ?> |
|
| 70 | 70 | \ No newline at end of file |
@@ -1,156 +1,156 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -function wpinv_is_subscription_payment( $invoice = '' ) { |
|
| 4 | - if ( empty( $invoice ) ) { |
|
| 3 | +function wpinv_is_subscription_payment($invoice = '') { |
|
| 4 | + if (empty($invoice)) { |
|
| 5 | 5 | return false; |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | - if ( !is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
| 9 | - $invoice = wpinv_get_invoice( $invoice ); |
|
| 8 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
| 9 | + $invoice = wpinv_get_invoice($invoice); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | - if ( empty( $invoice ) ) { |
|
| 12 | + if (empty($invoice)) { |
|
| 13 | 13 | return false; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - if ( $invoice->is_renewal() ) { |
|
| 16 | + if ($invoice->is_renewal()) { |
|
| 17 | 17 | return true; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | return false; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | -function wpinv_payment_link_transaction_id( $invoice = '' ) { |
|
| 24 | - if ( empty( $invoice ) ) { |
|
| 23 | +function wpinv_payment_link_transaction_id($invoice = '') { |
|
| 24 | + if (empty($invoice)) { |
|
| 25 | 25 | return false; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - if ( !is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
| 29 | - $invoice = wpinv_get_invoice( $invoice ); |
|
| 28 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
| 29 | + $invoice = wpinv_get_invoice($invoice); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - if ( empty( $invoice ) ) { |
|
| 32 | + if (empty($invoice)) { |
|
| 33 | 33 | return false; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - return apply_filters( 'wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice ); |
|
| 36 | + return apply_filters('wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | -function wpinv_subscription_initial_payment_desc( $amount, $period, $interval, $trial_period = '', $trial_interval = 0 ) { |
|
| 39 | +function wpinv_subscription_initial_payment_desc($amount, $period, $interval, $trial_period = '', $trial_interval = 0) { |
|
| 40 | 40 | $interval = (int)$interval > 0 ? (int)$interval : 1; |
| 41 | 41 | |
| 42 | - if ( $trial_interval > 0 && !empty( $trial_period ) ) { |
|
| 43 | - $amount = __( 'Free', 'invoicing' ); |
|
| 42 | + if ($trial_interval > 0 && !empty($trial_period)) { |
|
| 43 | + $amount = __('Free', 'invoicing'); |
|
| 44 | 44 | $interval = $trial_interval; |
| 45 | 45 | $period = $trial_period; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $description = ''; |
| 49 | - switch ( $period ) { |
|
| 49 | + switch ($period) { |
|
| 50 | 50 | case 'D' : |
| 51 | 51 | case 'day' : |
| 52 | - $description = wp_sprintf( _n( '%s for the first day.', '%s for the first %d days.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 52 | + $description = wp_sprintf(_n('%s for the first day.', '%s for the first %d days.', $interval, 'invoicing'), $amount, $interval); |
|
| 53 | 53 | break; |
| 54 | 54 | case 'W' : |
| 55 | 55 | case 'week' : |
| 56 | - $description = wp_sprintf( _n( '%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 56 | + $description = wp_sprintf(_n('%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing'), $amount, $interval); |
|
| 57 | 57 | break; |
| 58 | 58 | case 'M' : |
| 59 | 59 | case 'month' : |
| 60 | - $description = wp_sprintf( _n( '%s for the first month.', '%s for the first %d months.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 60 | + $description = wp_sprintf(_n('%s for the first month.', '%s for the first %d months.', $interval, 'invoicing'), $amount, $interval); |
|
| 61 | 61 | break; |
| 62 | 62 | case 'Y' : |
| 63 | 63 | case 'year' : |
| 64 | - $description = wp_sprintf( _n( '%s for the first year.', '%s for the first %d years.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 64 | + $description = wp_sprintf(_n('%s for the first year.', '%s for the first %d years.', $interval, 'invoicing'), $amount, $interval); |
|
| 65 | 65 | break; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - return apply_filters( 'wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval ); |
|
| 68 | + return apply_filters('wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | -function wpinv_subscription_recurring_payment_desc( $amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0 ) { |
|
| 71 | +function wpinv_subscription_recurring_payment_desc($amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0) { |
|
| 72 | 72 | $interval = (int)$interval > 0 ? (int)$interval : 1; |
| 73 | 73 | $bill_times = (int)$bill_times > 0 ? (int)$bill_times : 0; |
| 74 | 74 | |
| 75 | 75 | $description = ''; |
| 76 | - switch ( $period ) { |
|
| 76 | + switch ($period) { |
|
| 77 | 77 | case 'D' : |
| 78 | 78 | case 'day' : |
| 79 | - if ( (int)$bill_times > 0 ) { |
|
| 80 | - if ( $interval > 1 ) { |
|
| 81 | - if ( $bill_times > 1 ) { |
|
| 82 | - $description = wp_sprintf( __( '%s for each %d days, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
| 79 | + if ((int)$bill_times > 0) { |
|
| 80 | + if ($interval > 1) { |
|
| 81 | + if ($bill_times > 1) { |
|
| 82 | + $description = wp_sprintf(__('%s for each %d days, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
| 83 | 83 | } else { |
| 84 | - $description = wp_sprintf( __( '%s for %d days.', 'invoicing' ), $amount, $interval ); |
|
| 84 | + $description = wp_sprintf(__('%s for %d days.', 'invoicing'), $amount, $interval); |
|
| 85 | 85 | } |
| 86 | 86 | } else { |
| 87 | - $description = wp_sprintf( _n( '%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
| 87 | + $description = wp_sprintf(_n('%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
| 88 | 88 | } |
| 89 | 89 | } else { |
| 90 | - $description = wp_sprintf( _n( '%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval ); |
|
| 90 | + $description = wp_sprintf(_n('%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval); |
|
| 91 | 91 | } |
| 92 | 92 | break; |
| 93 | 93 | case 'W' : |
| 94 | 94 | case 'week' : |
| 95 | - if ( (int)$bill_times > 0 ) { |
|
| 96 | - if ( $interval > 1 ) { |
|
| 97 | - if ( $bill_times > 1 ) { |
|
| 98 | - $description = wp_sprintf( __( '%s for each %d weeks, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
| 95 | + if ((int)$bill_times > 0) { |
|
| 96 | + if ($interval > 1) { |
|
| 97 | + if ($bill_times > 1) { |
|
| 98 | + $description = wp_sprintf(__('%s for each %d weeks, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
| 99 | 99 | } else { |
| 100 | - $description = wp_sprintf( __( '%s for %d weeks.', 'invoicing' ), $amount, $interval ); |
|
| 100 | + $description = wp_sprintf(__('%s for %d weeks.', 'invoicing'), $amount, $interval); |
|
| 101 | 101 | } |
| 102 | 102 | } else { |
| 103 | - $description = wp_sprintf( _n( '%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
| 103 | + $description = wp_sprintf(_n('%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
| 104 | 104 | } |
| 105 | 105 | } else { |
| 106 | - $description = wp_sprintf( _n( '%s for each week.', '%s for each %d weeks.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 106 | + $description = wp_sprintf(_n('%s for each week.', '%s for each %d weeks.', $interval, 'invoicing'), $amount, $interval); |
|
| 107 | 107 | } |
| 108 | 108 | break; |
| 109 | 109 | case 'M' : |
| 110 | 110 | case 'month' : |
| 111 | - if ( (int)$bill_times > 0 ) { |
|
| 112 | - if ( $interval > 1 ) { |
|
| 113 | - if ( $bill_times > 1 ) { |
|
| 114 | - $description = wp_sprintf( __( '%s for each %d months, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
| 111 | + if ((int)$bill_times > 0) { |
|
| 112 | + if ($interval > 1) { |
|
| 113 | + if ($bill_times > 1) { |
|
| 114 | + $description = wp_sprintf(__('%s for each %d months, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
| 115 | 115 | } else { |
| 116 | - $description = wp_sprintf( __( '%s for %d months.', 'invoicing' ), $amount, $interval ); |
|
| 116 | + $description = wp_sprintf(__('%s for %d months.', 'invoicing'), $amount, $interval); |
|
| 117 | 117 | } |
| 118 | 118 | } else { |
| 119 | - $description = wp_sprintf( _n( '%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
| 119 | + $description = wp_sprintf(_n('%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
| 120 | 120 | } |
| 121 | 121 | } else { |
| 122 | - $description = wp_sprintf( _n( '%s for each month.', '%s for each %d months.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 122 | + $description = wp_sprintf(_n('%s for each month.', '%s for each %d months.', $interval, 'invoicing'), $amount, $interval); |
|
| 123 | 123 | } |
| 124 | 124 | break; |
| 125 | 125 | case 'Y' : |
| 126 | 126 | case 'year' : |
| 127 | - if ( (int)$bill_times > 0 ) { |
|
| 128 | - if ( $interval > 1 ) { |
|
| 129 | - if ( $bill_times > 1 ) { |
|
| 130 | - $description = wp_sprintf( __( '%s for each %d years, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
| 127 | + if ((int)$bill_times > 0) { |
|
| 128 | + if ($interval > 1) { |
|
| 129 | + if ($bill_times > 1) { |
|
| 130 | + $description = wp_sprintf(__('%s for each %d years, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
| 131 | 131 | } else { |
| 132 | - $description = wp_sprintf( __( '%s for %d years.', 'invoicing'), $amount, $interval ); |
|
| 132 | + $description = wp_sprintf(__('%s for %d years.', 'invoicing'), $amount, $interval); |
|
| 133 | 133 | } |
| 134 | 134 | } else { |
| 135 | - $description = wp_sprintf( _n( '%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
| 135 | + $description = wp_sprintf(_n('%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
| 136 | 136 | } |
| 137 | 137 | } else { |
| 138 | - $description = wp_sprintf( _n( '%s for each year.', '%s for each %d years.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 138 | + $description = wp_sprintf(_n('%s for each year.', '%s for each %d years.', $interval, 'invoicing'), $amount, $interval); |
|
| 139 | 139 | } |
| 140 | 140 | break; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - return apply_filters( 'wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval ); |
|
| 143 | + return apply_filters('wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | -function wpinv_subscription_payment_desc( $invoice ) { |
|
| 147 | - if ( empty( $invoice ) ) { |
|
| 146 | +function wpinv_subscription_payment_desc($invoice) { |
|
| 147 | + if (empty($invoice)) { |
|
| 148 | 148 | return NULL; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | $description = ''; |
| 152 | - if ( $invoice->is_parent() && $item = $invoice->get_recurring( true ) ) { |
|
| 153 | - if ( $item->has_free_trial() ) { |
|
| 152 | + if ($invoice->is_parent() && $item = $invoice->get_recurring(true)) { |
|
| 153 | + if ($item->has_free_trial()) { |
|
| 154 | 154 | $trial_period = $item->get_trial_period(); |
| 155 | 155 | $trial_interval = $item->get_trial_interval(); |
| 156 | 156 | } else { |
@@ -158,45 +158,45 @@ discard block |
||
| 158 | 158 | $trial_interval = 0; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - $description = wpinv_get_billing_cycle( $invoice->get_total(), $invoice->get_recurring_details( 'total' ), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency() ); |
|
| 161 | + $description = wpinv_get_billing_cycle($invoice->get_total(), $invoice->get_recurring_details('total'), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency()); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - return apply_filters( 'wpinv_subscription_payment_desc', $description, $invoice ); |
|
| 164 | + return apply_filters('wpinv_subscription_payment_desc', $description, $invoice); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | -function wpinv_get_billing_cycle( $initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '' ) { |
|
| 168 | - $initial_total = wpinv_round_amount( $initial ); |
|
| 169 | - $recurring_total = wpinv_round_amount( $recurring ); |
|
| 167 | +function wpinv_get_billing_cycle($initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '') { |
|
| 168 | + $initial_total = wpinv_round_amount($initial); |
|
| 169 | + $recurring_total = wpinv_round_amount($recurring); |
|
| 170 | 170 | |
| 171 | - if ( $trial_interval > 0 && !empty( $trial_period ) ) { |
|
| 171 | + if ($trial_interval > 0 && !empty($trial_period)) { |
|
| 172 | 172 | // Free trial |
| 173 | 173 | } else { |
| 174 | - if ( $bill_times == 1 ) { |
|
| 174 | + if ($bill_times == 1) { |
|
| 175 | 175 | $recurring_total = $initial_total; |
| 176 | - } else if ( $bill_times > 1 && $initial_total != $recurring_total ) { |
|
| 176 | + } else if ($bill_times > 1 && $initial_total != $recurring_total) { |
|
| 177 | 177 | $bill_times--; |
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - $initial_amount = wpinv_price( wpinv_format_amount( $initial_total ), $currency ); |
|
| 182 | - $recurring_amount = wpinv_price( wpinv_format_amount( $recurring_total ), $currency ); |
|
| 181 | + $initial_amount = wpinv_price(wpinv_format_amount($initial_total), $currency); |
|
| 182 | + $recurring_amount = wpinv_price(wpinv_format_amount($recurring_total), $currency); |
|
| 183 | 183 | |
| 184 | - $recurring = wpinv_subscription_recurring_payment_desc( $recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval ); |
|
| 184 | + $recurring = wpinv_subscription_recurring_payment_desc($recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval); |
|
| 185 | 185 | |
| 186 | - if ( $initial_total != $recurring_total ) { |
|
| 187 | - $initial = wpinv_subscription_initial_payment_desc( $initial_amount, $period, $interval, $trial_period, $trial_interval ); |
|
| 186 | + if ($initial_total != $recurring_total) { |
|
| 187 | + $initial = wpinv_subscription_initial_payment_desc($initial_amount, $period, $interval, $trial_period, $trial_interval); |
|
| 188 | 188 | |
| 189 | - $description = wp_sprintf( __( '%s Then %s', 'invoicing' ), $initial, $recurring ); |
|
| 189 | + $description = wp_sprintf(__('%s Then %s', 'invoicing'), $initial, $recurring); |
|
| 190 | 190 | } else { |
| 191 | 191 | $description = $recurring; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - return apply_filters( 'wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency ); |
|
| 194 | + return apply_filters('wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | -function wpinv_recurring_send_payment_failed( $invoice ) { |
|
| 198 | - if ( !empty( $invoice->ID ) ) { |
|
| 199 | - wpinv_failed_invoice_notification( $invoice->ID ); |
|
| 197 | +function wpinv_recurring_send_payment_failed($invoice) { |
|
| 198 | + if (!empty($invoice->ID)) { |
|
| 199 | + wpinv_failed_invoice_notification($invoice->ID); |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | -add_action( 'wpinv_recurring_payment_failed', 'wpinv_recurring_send_payment_failed', 10, 1 ); |
|
| 203 | 202 | \ No newline at end of file |
| 203 | +add_action('wpinv_recurring_payment_failed', 'wpinv_recurring_send_payment_failed', 10, 1); |
|
| 204 | 204 | \ No newline at end of file |