@@ -218,8 +218,9 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | // Setup possible parts |
| 220 | 220 | $templates = array(); |
| 221 | - if ( isset( $name ) ) |
|
| 222 | - $templates[] = $slug . '-' . $name . '.php'; |
|
| 221 | + if ( isset( $name ) ) { |
|
| 222 | + $templates[] = $slug . '-' . $name . '.php'; |
|
| 223 | + } |
|
| 223 | 224 | $templates[] = $slug . '.php'; |
| 224 | 225 | |
| 225 | 226 | // Allow template parts to be filtered |
@@ -237,8 +238,9 @@ discard block |
||
| 237 | 238 | foreach ( (array)$template_names as $template_name ) { |
| 238 | 239 | |
| 239 | 240 | // Continue if template is empty |
| 240 | - if ( empty( $template_name ) ) |
|
| 241 | - continue; |
|
| 241 | + if ( empty( $template_name ) ) { |
|
| 242 | + continue; |
|
| 243 | + } |
|
| 242 | 244 | |
| 243 | 245 | // Trim off any slashes from the template name |
| 244 | 246 | $template_name = ltrim( $template_name, '/' ); |
@@ -257,8 +259,9 @@ discard block |
||
| 257 | 259 | } |
| 258 | 260 | } |
| 259 | 261 | |
| 260 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
| 261 | - load_template( $located, $require_once ); |
|
| 262 | + if ( ( true == $load ) && ! empty( $located ) ) { |
|
| 263 | + load_template( $located, $require_once ); |
|
| 264 | + } |
|
| 262 | 265 | |
| 263 | 266 | return $located; |
| 264 | 267 | } |
@@ -336,8 +339,9 @@ discard block |
||
| 336 | 339 | function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
| 337 | 340 | $args = array( 'nopaging' => true ); |
| 338 | 341 | |
| 339 | - if ( ! empty( $status ) ) |
|
| 340 | - $args['post_status'] = $status; |
|
| 342 | + if ( ! empty( $status ) ) { |
|
| 343 | + $args['post_status'] = $status; |
|
| 344 | + } |
|
| 341 | 345 | |
| 342 | 346 | $discounts = wpinv_get_discounts( $args ); |
| 343 | 347 | $options = array(); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 141 | 141 | */ |
| 142 | 142 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
| 143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
| 143 | + return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @return string |
| 159 | 159 | */ |
| 160 | 160 | function wpinv_get_theme_template_dir_name() { |
| 161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
| 161 | + return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -175,122 +175,122 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
| 178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 178 | + do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 179 | 179 | |
| 180 | - // Setup possible parts |
|
| 181 | - $templates = array(); |
|
| 182 | - if ( isset( $name ) ) |
|
| 183 | - $templates[] = $slug . '-' . $name . '.php'; |
|
| 184 | - $templates[] = $slug . '.php'; |
|
| 180 | + // Setup possible parts |
|
| 181 | + $templates = array(); |
|
| 182 | + if ( isset( $name ) ) |
|
| 183 | + $templates[] = $slug . '-' . $name . '.php'; |
|
| 184 | + $templates[] = $slug . '.php'; |
|
| 185 | 185 | |
| 186 | - // Allow template parts to be filtered |
|
| 187 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 186 | + // Allow template parts to be filtered |
|
| 187 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 188 | 188 | |
| 189 | - // Return the part that is found |
|
| 190 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 189 | + // Return the part that is found |
|
| 190 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
| 194 | - // No file found yet |
|
| 195 | - $located = false; |
|
| 194 | + // No file found yet |
|
| 195 | + $located = false; |
|
| 196 | 196 | |
| 197 | - // Try to find a template file |
|
| 198 | - foreach ( (array)$template_names as $template_name ) { |
|
| 197 | + // Try to find a template file |
|
| 198 | + foreach ( (array)$template_names as $template_name ) { |
|
| 199 | 199 | |
| 200 | - // Continue if template is empty |
|
| 201 | - if ( empty( $template_name ) ) |
|
| 202 | - continue; |
|
| 200 | + // Continue if template is empty |
|
| 201 | + if ( empty( $template_name ) ) |
|
| 202 | + continue; |
|
| 203 | 203 | |
| 204 | - // Trim off any slashes from the template name |
|
| 205 | - $template_name = ltrim( $template_name, '/' ); |
|
| 204 | + // Trim off any slashes from the template name |
|
| 205 | + $template_name = ltrim( $template_name, '/' ); |
|
| 206 | 206 | |
| 207 | - // try locating this template file by looping through the template paths |
|
| 208 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 207 | + // try locating this template file by looping through the template paths |
|
| 208 | + foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 209 | 209 | |
| 210 | - if( file_exists( $template_path . $template_name ) ) { |
|
| 211 | - $located = $template_path . $template_name; |
|
| 212 | - break; |
|
| 213 | - } |
|
| 214 | - } |
|
| 210 | + if( file_exists( $template_path . $template_name ) ) { |
|
| 211 | + $located = $template_path . $template_name; |
|
| 212 | + break; |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - if( !empty( $located ) ) { |
|
| 217 | - break; |
|
| 218 | - } |
|
| 219 | - } |
|
| 216 | + if( !empty( $located ) ) { |
|
| 217 | + break; |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
| 222 | - load_template( $located, $require_once ); |
|
| 221 | + if ( ( true == $load ) && ! empty( $located ) ) |
|
| 222 | + load_template( $located, $require_once ); |
|
| 223 | 223 | |
| 224 | - return $located; |
|
| 224 | + return $located; |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | function wpinv_get_theme_template_paths() { |
| 228 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
| 228 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
| 229 | 229 | |
| 230 | - $file_paths = array( |
|
| 231 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 232 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 233 | - 100 => wpinv_get_templates_dir() |
|
| 234 | - ); |
|
| 230 | + $file_paths = array( |
|
| 231 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 232 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 233 | + 100 => wpinv_get_templates_dir() |
|
| 234 | + ); |
|
| 235 | 235 | |
| 236 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 236 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 237 | 237 | |
| 238 | - // sort the file paths based on priority |
|
| 239 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 238 | + // sort the file paths based on priority |
|
| 239 | + ksort( $file_paths, SORT_NUMERIC ); |
|
| 240 | 240 | |
| 241 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 241 | + return array_map( 'trailingslashit', $file_paths ); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | function wpinv_checkout_meta_tags() { |
| 245 | 245 | |
| 246 | - $pages = array(); |
|
| 247 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
| 248 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 249 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 250 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
| 246 | + $pages = array(); |
|
| 247 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
| 248 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 249 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 250 | + $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
| 251 | 251 | |
| 252 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 253 | - return; |
|
| 254 | - } |
|
| 252 | + if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 253 | + return; |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
| 256 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
| 257 | 257 | } |
| 258 | 258 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
| 259 | 259 | |
| 260 | 260 | function wpinv_add_body_classes( $class ) { |
| 261 | - $classes = (array)$class; |
|
| 261 | + $classes = (array)$class; |
|
| 262 | 262 | |
| 263 | - if( wpinv_is_checkout() ) { |
|
| 264 | - $classes[] = 'wpinv-checkout'; |
|
| 265 | - $classes[] = 'wpinv-page'; |
|
| 266 | - } |
|
| 263 | + if( wpinv_is_checkout() ) { |
|
| 264 | + $classes[] = 'wpinv-checkout'; |
|
| 265 | + $classes[] = 'wpinv-page'; |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - if( wpinv_is_success_page() ) { |
|
| 269 | - $classes[] = 'wpinv-success'; |
|
| 270 | - $classes[] = 'wpinv-page'; |
|
| 271 | - } |
|
| 268 | + if( wpinv_is_success_page() ) { |
|
| 269 | + $classes[] = 'wpinv-success'; |
|
| 270 | + $classes[] = 'wpinv-page'; |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | - if( wpinv_is_failed_transaction_page() ) { |
|
| 274 | - $classes[] = 'wpinv-failed-transaction'; |
|
| 275 | - $classes[] = 'wpinv-page'; |
|
| 276 | - } |
|
| 273 | + if( wpinv_is_failed_transaction_page() ) { |
|
| 274 | + $classes[] = 'wpinv-failed-transaction'; |
|
| 275 | + $classes[] = 'wpinv-page'; |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | - if( wpinv_is_invoice_history_page() ) { |
|
| 279 | - $classes[] = 'wpinv-history'; |
|
| 280 | - $classes[] = 'wpinv-page'; |
|
| 281 | - } |
|
| 278 | + if( wpinv_is_invoice_history_page() ) { |
|
| 279 | + $classes[] = 'wpinv-history'; |
|
| 280 | + $classes[] = 'wpinv-page'; |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | - if( wpinv_is_subscriptions_history_page() ) { |
|
| 284 | - $classes[] = 'wpinv-subscription'; |
|
| 285 | - $classes[] = 'wpinv-page'; |
|
| 286 | - } |
|
| 283 | + if( wpinv_is_subscriptions_history_page() ) { |
|
| 284 | + $classes[] = 'wpinv-subscription'; |
|
| 285 | + $classes[] = 'wpinv-page'; |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | - if( wpinv_is_test_mode() ) { |
|
| 289 | - $classes[] = 'wpinv-test-mode'; |
|
| 290 | - $classes[] = 'wpinv-page'; |
|
| 291 | - } |
|
| 288 | + if( wpinv_is_test_mode() ) { |
|
| 289 | + $classes[] = 'wpinv-test-mode'; |
|
| 290 | + $classes[] = 'wpinv-page'; |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | - return array_unique( $classes ); |
|
| 293 | + return array_unique( $classes ); |
|
| 294 | 294 | } |
| 295 | 295 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
| 296 | 296 | |
@@ -859,21 +859,21 @@ discard block |
||
| 859 | 859 | |
| 860 | 860 | $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
| 861 | 861 | |
| 862 | - // Remove unavailable tags. |
|
| 862 | + // Remove unavailable tags. |
|
| 863 | 863 | $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
| 864 | 864 | |
| 865 | 865 | // Clean up white space. |
| 866 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
| 866 | + $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
| 867 | 867 | $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
| 868 | 868 | |
| 869 | 869 | // Break newlines apart and remove empty lines/trim commas and white space. |
| 870 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
| 870 | + $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
| 871 | 871 | |
| 872 | 872 | // Add html breaks. |
| 873 | - $formatted_address = implode( $separator, $formatted_address ); |
|
| 873 | + $formatted_address = implode( $separator, $formatted_address ); |
|
| 874 | 874 | |
| 875 | - // We're done! |
|
| 876 | - return $formatted_address; |
|
| 875 | + // We're done! |
|
| 876 | + return $formatted_address; |
|
| 877 | 877 | |
| 878 | 878 | } |
| 879 | 879 | |
@@ -1075,7 +1075,7 @@ discard block |
||
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | 1077 | function wpinv_empty_cart_message() { |
| 1078 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1078 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | 1081 | /** |
@@ -1343,10 +1343,10 @@ discard block |
||
| 1343 | 1343 | |
| 1344 | 1344 | if ( 0 == count( $form->get_items() ) ) { |
| 1345 | 1345 | echo aui()->alert( |
| 1346 | - array( |
|
| 1347 | - 'type' => 'warning', |
|
| 1348 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
| 1349 | - ) |
|
| 1346 | + array( |
|
| 1347 | + 'type' => 'warning', |
|
| 1348 | + 'content' => __( 'No published items found', 'invoicing' ), |
|
| 1349 | + ) |
|
| 1350 | 1350 | ); |
| 1351 | 1351 | return; |
| 1352 | 1352 | } |
@@ -1364,21 +1364,21 @@ discard block |
||
| 1364 | 1364 | $invoice = wpinv_get_invoice( $invoice_id ); |
| 1365 | 1365 | |
| 1366 | 1366 | if ( empty( $invoice ) ) { |
| 1367 | - echo aui()->alert( |
|
| 1368 | - array( |
|
| 1369 | - 'type' => 'warning', |
|
| 1370 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
| 1371 | - ) |
|
| 1367 | + echo aui()->alert( |
|
| 1368 | + array( |
|
| 1369 | + 'type' => 'warning', |
|
| 1370 | + 'content' => __( 'Invoice not found', 'invoicing' ), |
|
| 1371 | + ) |
|
| 1372 | 1372 | ); |
| 1373 | 1373 | return; |
| 1374 | 1374 | } |
| 1375 | 1375 | |
| 1376 | 1376 | if ( $invoice->is_paid() ) { |
| 1377 | - echo aui()->alert( |
|
| 1378 | - array( |
|
| 1379 | - 'type' => 'warning', |
|
| 1380 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
| 1381 | - ) |
|
| 1377 | + echo aui()->alert( |
|
| 1378 | + array( |
|
| 1379 | + 'type' => 'warning', |
|
| 1380 | + 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
| 1381 | + ) |
|
| 1382 | 1382 | ); |
| 1383 | 1383 | return; |
| 1384 | 1384 | } |
@@ -1440,7 +1440,7 @@ discard block |
||
| 1440 | 1440 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
| 1441 | 1441 | } |
| 1442 | 1442 | |
| 1443 | - if ( ! empty( $items ) ) { |
|
| 1443 | + if ( ! empty( $items ) ) { |
|
| 1444 | 1444 | $items = esc_attr( $items ); |
| 1445 | 1445 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
| 1446 | 1446 | } |
@@ -4,99 +4,99 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Displays an invoice. |
| 11 | 11 | * |
| 12 | 12 | * @param WPInv_Invoice $invoice. |
| 13 | 13 | */ |
| 14 | -function getpaid_invoice( $invoice ) { |
|
| 15 | - if ( ! empty( $invoice ) ) { |
|
| 16 | - wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) ); |
|
| 14 | +function getpaid_invoice($invoice) { |
|
| 15 | + if (!empty($invoice)) { |
|
| 16 | + wpinv_get_template('invoice/invoice.php', compact('invoice')); |
|
| 17 | 17 | } |
| 18 | 18 | } |
| 19 | -add_action( 'getpaid_invoice', 'getpaid_invoice', 10 ); |
|
| 19 | +add_action('getpaid_invoice', 'getpaid_invoice', 10); |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Displays the invoice footer. |
| 23 | 23 | */ |
| 24 | -function getpaid_invoice_footer( $invoice ) { |
|
| 25 | - if ( ! empty( $invoice ) ) { |
|
| 26 | - wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) ); |
|
| 24 | +function getpaid_invoice_footer($invoice) { |
|
| 25 | + if (!empty($invoice)) { |
|
| 26 | + wpinv_get_template('invoice/footer.php', compact('invoice')); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | -add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 ); |
|
| 29 | +add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10); |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Displays the invoice top bar. |
| 33 | 33 | */ |
| 34 | -function getpaid_invoice_header( $invoice ) { |
|
| 35 | - if ( ! empty( $invoice ) ) { |
|
| 36 | - wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) ); |
|
| 34 | +function getpaid_invoice_header($invoice) { |
|
| 35 | + if (!empty($invoice)) { |
|
| 36 | + wpinv_get_template('invoice/header.php', compact('invoice')); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | -add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 ); |
|
| 39 | +add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10); |
|
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * Displays actions on the left side of the header. |
| 43 | 43 | */ |
| 44 | -function getpaid_invoice_header_left_actions( $invoice ) { |
|
| 45 | - if ( ! empty( $invoice ) ) { |
|
| 46 | - wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) ); |
|
| 44 | +function getpaid_invoice_header_left_actions($invoice) { |
|
| 45 | + if (!empty($invoice)) { |
|
| 46 | + wpinv_get_template('invoice/header-left-actions.php', compact('invoice')); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | -add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 ); |
|
| 49 | +add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10); |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * Displays actions on the right side of the invoice top bar. |
| 53 | 53 | */ |
| 54 | -function getpaid_invoice_header_right_actions( $invoice ) { |
|
| 55 | - if ( ! empty( $invoice ) ) { |
|
| 56 | - wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) ); |
|
| 54 | +function getpaid_invoice_header_right_actions($invoice) { |
|
| 55 | + if (!empty($invoice)) { |
|
| 56 | + wpinv_get_template('invoice/header-right-actions.php', compact('invoice')); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | -add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 ); |
|
| 59 | +add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10); |
|
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * Displays the invoice title, watermark, logo etc. |
| 63 | 63 | */ |
| 64 | -function getpaid_invoice_details_top( $invoice ) { |
|
| 65 | - if ( ! empty( $invoice ) ) { |
|
| 66 | - wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) ); |
|
| 64 | +function getpaid_invoice_details_top($invoice) { |
|
| 65 | + if (!empty($invoice)) { |
|
| 66 | + wpinv_get_template('invoice/details-top.php', compact('invoice')); |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 ); |
|
| 69 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10); |
|
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * Displays the company logo. |
| 73 | 73 | */ |
| 74 | -function getpaid_invoice_logo( $invoice ) { |
|
| 75 | - if ( ! empty( $invoice ) ) { |
|
| 76 | - wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) ); |
|
| 74 | +function getpaid_invoice_logo($invoice) { |
|
| 75 | + if (!empty($invoice)) { |
|
| 76 | + wpinv_get_template('invoice/invoice-logo.php', compact('invoice')); |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | -add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' ); |
|
| 79 | +add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo'); |
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * Displays the type of invoice. |
| 83 | 83 | */ |
| 84 | -function getpaid_invoice_type( $invoice ) { |
|
| 85 | - if ( ! empty( $invoice ) ) { |
|
| 86 | - wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) ); |
|
| 84 | +function getpaid_invoice_type($invoice) { |
|
| 85 | + if (!empty($invoice)) { |
|
| 86 | + wpinv_get_template('invoice/invoice-type.php', compact('invoice')); |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | -add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' ); |
|
| 89 | +add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type'); |
|
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | 92 | * Displays the invoice details. |
| 93 | 93 | */ |
| 94 | -function getpaid_invoice_details_main( $invoice ) { |
|
| 95 | - if ( ! empty( $invoice ) ) { |
|
| 96 | - wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) ); |
|
| 94 | +function getpaid_invoice_details_main($invoice) { |
|
| 95 | + if (!empty($invoice)) { |
|
| 96 | + wpinv_get_template('invoice/details.php', compact('invoice')); |
|
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 ); |
|
| 99 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50); |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * Returns a path to the templates directory. |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
| 126 | 126 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 127 | 127 | */ |
| 128 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 129 | - return getpaid_template()->display_template( $template_name, $args, $template_path, $default_path ); |
|
| 128 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 129 | + return getpaid_template()->display_template($template_name, $args, $template_path, $default_path); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
| 140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 141 | 141 | */ |
| 142 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
| 142 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 143 | + return getpaid_template()->get_template($template_name, $args, $template_path, $default_path); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @return string |
| 150 | 150 | */ |
| 151 | 151 | function wpinv_template_path() { |
| 152 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
| 152 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @return string |
| 159 | 159 | */ |
| 160 | 160 | function wpinv_get_theme_template_dir_name() { |
| 161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
| 161 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -170,56 +170,56 @@ discard block |
||
| 170 | 170 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
| 171 | 171 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 172 | 172 | */ |
| 173 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 174 | - return getpaid_template()->locate_template( $template_name, $template_path, $default_path ); |
|
| 173 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
| 174 | + return getpaid_template()->locate_template($template_name, $template_path, $default_path); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
| 178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 177 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
| 178 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
| 179 | 179 | |
| 180 | 180 | // Setup possible parts |
| 181 | 181 | $templates = array(); |
| 182 | - if ( isset( $name ) ) |
|
| 182 | + if (isset($name)) |
|
| 183 | 183 | $templates[] = $slug . '-' . $name . '.php'; |
| 184 | 184 | $templates[] = $slug . '.php'; |
| 185 | 185 | |
| 186 | 186 | // Allow template parts to be filtered |
| 187 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 187 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
| 188 | 188 | |
| 189 | 189 | // Return the part that is found |
| 190 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 190 | + return wpinv_locate_tmpl($templates, $load, false); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
| 193 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
| 194 | 194 | // No file found yet |
| 195 | 195 | $located = false; |
| 196 | 196 | |
| 197 | 197 | // Try to find a template file |
| 198 | - foreach ( (array)$template_names as $template_name ) { |
|
| 198 | + foreach ((array) $template_names as $template_name) { |
|
| 199 | 199 | |
| 200 | 200 | // Continue if template is empty |
| 201 | - if ( empty( $template_name ) ) |
|
| 201 | + if (empty($template_name)) |
|
| 202 | 202 | continue; |
| 203 | 203 | |
| 204 | 204 | // Trim off any slashes from the template name |
| 205 | - $template_name = ltrim( $template_name, '/' ); |
|
| 205 | + $template_name = ltrim($template_name, '/'); |
|
| 206 | 206 | |
| 207 | 207 | // try locating this template file by looping through the template paths |
| 208 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 208 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
| 209 | 209 | |
| 210 | - if( file_exists( $template_path . $template_name ) ) { |
|
| 210 | + if (file_exists($template_path . $template_name)) { |
|
| 211 | 211 | $located = $template_path . $template_name; |
| 212 | 212 | break; |
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - if( !empty( $located ) ) { |
|
| 216 | + if (!empty($located)) { |
|
| 217 | 217 | break; |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
| 222 | - load_template( $located, $require_once ); |
|
| 221 | + if ((true == $load) && !empty($located)) |
|
| 222 | + load_template($located, $require_once); |
|
| 223 | 223 | |
| 224 | 224 | return $located; |
| 225 | 225 | } |
@@ -228,155 +228,155 @@ discard block |
||
| 228 | 228 | $template_dir = wpinv_get_theme_template_dir_name(); |
| 229 | 229 | |
| 230 | 230 | $file_paths = array( |
| 231 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 232 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 231 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
| 232 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
| 233 | 233 | 100 => wpinv_get_templates_dir() |
| 234 | 234 | ); |
| 235 | 235 | |
| 236 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 236 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
| 237 | 237 | |
| 238 | 238 | // sort the file paths based on priority |
| 239 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 239 | + ksort($file_paths, SORT_NUMERIC); |
|
| 240 | 240 | |
| 241 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 241 | + return array_map('trailingslashit', $file_paths); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | function wpinv_checkout_meta_tags() { |
| 245 | 245 | |
| 246 | 246 | $pages = array(); |
| 247 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
| 248 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 249 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 250 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
| 247 | + $pages[] = wpinv_get_option('success_page'); |
|
| 248 | + $pages[] = wpinv_get_option('failure_page'); |
|
| 249 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
| 250 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
| 251 | 251 | |
| 252 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 252 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
| 253 | 253 | return; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
| 257 | 257 | } |
| 258 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
| 258 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
| 259 | 259 | |
| 260 | -function wpinv_add_body_classes( $class ) { |
|
| 261 | - $classes = (array)$class; |
|
| 260 | +function wpinv_add_body_classes($class) { |
|
| 261 | + $classes = (array) $class; |
|
| 262 | 262 | |
| 263 | - if( wpinv_is_checkout() ) { |
|
| 263 | + if (wpinv_is_checkout()) { |
|
| 264 | 264 | $classes[] = 'wpinv-checkout'; |
| 265 | 265 | $classes[] = 'wpinv-page'; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - if( wpinv_is_success_page() ) { |
|
| 268 | + if (wpinv_is_success_page()) { |
|
| 269 | 269 | $classes[] = 'wpinv-success'; |
| 270 | 270 | $classes[] = 'wpinv-page'; |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - if( wpinv_is_failed_transaction_page() ) { |
|
| 273 | + if (wpinv_is_failed_transaction_page()) { |
|
| 274 | 274 | $classes[] = 'wpinv-failed-transaction'; |
| 275 | 275 | $classes[] = 'wpinv-page'; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - if( wpinv_is_invoice_history_page() ) { |
|
| 278 | + if (wpinv_is_invoice_history_page()) { |
|
| 279 | 279 | $classes[] = 'wpinv-history'; |
| 280 | 280 | $classes[] = 'wpinv-page'; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - if( wpinv_is_subscriptions_history_page() ) { |
|
| 283 | + if (wpinv_is_subscriptions_history_page()) { |
|
| 284 | 284 | $classes[] = 'wpinv-subscription'; |
| 285 | 285 | $classes[] = 'wpinv-page'; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - if( wpinv_is_test_mode() ) { |
|
| 288 | + if (wpinv_is_test_mode()) { |
|
| 289 | 289 | $classes[] = 'wpinv-test-mode'; |
| 290 | 290 | $classes[] = 'wpinv-page'; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - return array_unique( $classes ); |
|
| 293 | + return array_unique($classes); |
|
| 294 | 294 | } |
| 295 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
| 295 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
| 296 | 296 | |
| 297 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
| 298 | - $args = array( 'nopaging' => true ); |
|
| 297 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
| 298 | + $args = array('nopaging' => true); |
|
| 299 | 299 | |
| 300 | - if ( ! empty( $status ) ) |
|
| 300 | + if (!empty($status)) |
|
| 301 | 301 | $args['post_status'] = $status; |
| 302 | 302 | |
| 303 | - $discounts = wpinv_get_discounts( $args ); |
|
| 303 | + $discounts = wpinv_get_discounts($args); |
|
| 304 | 304 | $options = array(); |
| 305 | 305 | |
| 306 | - if ( $discounts ) { |
|
| 307 | - foreach ( $discounts as $discount ) { |
|
| 308 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
| 306 | + if ($discounts) { |
|
| 307 | + foreach ($discounts as $discount) { |
|
| 308 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
| 309 | 309 | } |
| 310 | 310 | } else { |
| 311 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
| 311 | + $options[0] = __('No discounts found', 'invoicing'); |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - $output = wpinv_html_select( array( |
|
| 314 | + $output = wpinv_html_select(array( |
|
| 315 | 315 | 'name' => $name, |
| 316 | 316 | 'selected' => $selected, |
| 317 | 317 | 'options' => $options, |
| 318 | 318 | 'show_option_all' => false, |
| 319 | 319 | 'show_option_none' => false, |
| 320 | - ) ); |
|
| 320 | + )); |
|
| 321 | 321 | |
| 322 | 322 | return $output; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
| 326 | - $current = date( 'Y' ); |
|
| 327 | - $start_year = $current - absint( $years_before ); |
|
| 328 | - $end_year = $current + absint( $years_after ); |
|
| 329 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
| 325 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
| 326 | + $current = date('Y'); |
|
| 327 | + $start_year = $current - absint($years_before); |
|
| 328 | + $end_year = $current + absint($years_after); |
|
| 329 | + $selected = empty($selected) ? date('Y') : $selected; |
|
| 330 | 330 | $options = array(); |
| 331 | 331 | |
| 332 | - while ( $start_year <= $end_year ) { |
|
| 333 | - $options[ absint( $start_year ) ] = $start_year; |
|
| 332 | + while ($start_year <= $end_year) { |
|
| 333 | + $options[absint($start_year)] = $start_year; |
|
| 334 | 334 | $start_year++; |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - $output = wpinv_html_select( array( |
|
| 337 | + $output = wpinv_html_select(array( |
|
| 338 | 338 | 'name' => $name, |
| 339 | 339 | 'selected' => $selected, |
| 340 | 340 | 'options' => $options, |
| 341 | 341 | 'show_option_all' => false, |
| 342 | 342 | 'show_option_none' => false |
| 343 | - ) ); |
|
| 343 | + )); |
|
| 344 | 344 | |
| 345 | 345 | return $output; |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
| 348 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
| 349 | 349 | |
| 350 | 350 | $options = array( |
| 351 | - '1' => __( 'January', 'invoicing' ), |
|
| 352 | - '2' => __( 'February', 'invoicing' ), |
|
| 353 | - '3' => __( 'March', 'invoicing' ), |
|
| 354 | - '4' => __( 'April', 'invoicing' ), |
|
| 355 | - '5' => __( 'May', 'invoicing' ), |
|
| 356 | - '6' => __( 'June', 'invoicing' ), |
|
| 357 | - '7' => __( 'July', 'invoicing' ), |
|
| 358 | - '8' => __( 'August', 'invoicing' ), |
|
| 359 | - '9' => __( 'September', 'invoicing' ), |
|
| 360 | - '10' => __( 'October', 'invoicing' ), |
|
| 361 | - '11' => __( 'November', 'invoicing' ), |
|
| 362 | - '12' => __( 'December', 'invoicing' ), |
|
| 351 | + '1' => __('January', 'invoicing'), |
|
| 352 | + '2' => __('February', 'invoicing'), |
|
| 353 | + '3' => __('March', 'invoicing'), |
|
| 354 | + '4' => __('April', 'invoicing'), |
|
| 355 | + '5' => __('May', 'invoicing'), |
|
| 356 | + '6' => __('June', 'invoicing'), |
|
| 357 | + '7' => __('July', 'invoicing'), |
|
| 358 | + '8' => __('August', 'invoicing'), |
|
| 359 | + '9' => __('September', 'invoicing'), |
|
| 360 | + '10' => __('October', 'invoicing'), |
|
| 361 | + '11' => __('November', 'invoicing'), |
|
| 362 | + '12' => __('December', 'invoicing'), |
|
| 363 | 363 | ); |
| 364 | 364 | |
| 365 | 365 | // If no month is selected, default to the current month |
| 366 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
| 366 | + $selected = empty($selected) ? date('n') : $selected; |
|
| 367 | 367 | |
| 368 | - $output = wpinv_html_select( array( |
|
| 368 | + $output = wpinv_html_select(array( |
|
| 369 | 369 | 'name' => $name, |
| 370 | 370 | 'selected' => $selected, |
| 371 | 371 | 'options' => $options, |
| 372 | 372 | 'show_option_all' => false, |
| 373 | 373 | 'show_option_none' => false |
| 374 | - ) ); |
|
| 374 | + )); |
|
| 375 | 375 | |
| 376 | 376 | return $output; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | -function wpinv_html_select( $args = array() ) { |
|
| 379 | +function wpinv_html_select($args = array()) { |
|
| 380 | 380 | $defaults = array( |
| 381 | 381 | 'options' => array(), |
| 382 | 382 | 'name' => null, |
@@ -385,8 +385,8 @@ discard block |
||
| 385 | 385 | 'selected' => 0, |
| 386 | 386 | 'placeholder' => null, |
| 387 | 387 | 'multiple' => false, |
| 388 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
| 389 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
| 388 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
| 389 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
| 390 | 390 | 'data' => array(), |
| 391 | 391 | 'onchange' => null, |
| 392 | 392 | 'required' => false, |
@@ -394,74 +394,74 @@ discard block |
||
| 394 | 394 | 'readonly' => false, |
| 395 | 395 | ); |
| 396 | 396 | |
| 397 | - $args = wp_parse_args( $args, $defaults ); |
|
| 397 | + $args = wp_parse_args($args, $defaults); |
|
| 398 | 398 | |
| 399 | 399 | $data_elements = ''; |
| 400 | - foreach ( $args['data'] as $key => $value ) { |
|
| 401 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
| 400 | + foreach ($args['data'] as $key => $value) { |
|
| 401 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - if( $args['multiple'] ) { |
|
| 404 | + if ($args['multiple']) { |
|
| 405 | 405 | $multiple = ' MULTIPLE'; |
| 406 | 406 | } else { |
| 407 | 407 | $multiple = ''; |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | - if( $args['placeholder'] ) { |
|
| 410 | + if ($args['placeholder']) { |
|
| 411 | 411 | $placeholder = $args['placeholder']; |
| 412 | 412 | } else { |
| 413 | 413 | $placeholder = ''; |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | $options = ''; |
| 417 | - if( !empty( $args['onchange'] ) ) { |
|
| 418 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
| 417 | + if (!empty($args['onchange'])) { |
|
| 418 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - if( !empty( $args['required'] ) ) { |
|
| 421 | + if (!empty($args['required'])) { |
|
| 422 | 422 | $options .= ' required="required"'; |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - if( !empty( $args['disabled'] ) ) { |
|
| 425 | + if (!empty($args['disabled'])) { |
|
| 426 | 426 | $options .= ' disabled'; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - if( !empty( $args['readonly'] ) ) { |
|
| 429 | + if (!empty($args['readonly'])) { |
|
| 430 | 430 | $options .= ' readonly'; |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 434 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
| 433 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 434 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
| 435 | 435 | |
| 436 | - if ( $args['show_option_all'] ) { |
|
| 437 | - if( $args['multiple'] ) { |
|
| 438 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
| 436 | + if ($args['show_option_all']) { |
|
| 437 | + if ($args['multiple']) { |
|
| 438 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
| 439 | 439 | } else { |
| 440 | - $selected = selected( $args['selected'], 0, false ); |
|
| 440 | + $selected = selected($args['selected'], 0, false); |
|
| 441 | 441 | } |
| 442 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
| 442 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if ( !empty( $args['options'] ) ) { |
|
| 445 | + if (!empty($args['options'])) { |
|
| 446 | 446 | |
| 447 | - if ( $args['show_option_none'] ) { |
|
| 448 | - if( $args['multiple'] ) { |
|
| 449 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
| 447 | + if ($args['show_option_none']) { |
|
| 448 | + if ($args['multiple']) { |
|
| 449 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
| 450 | 450 | } else { |
| 451 | - $selected = selected( $args['selected'] === "", true, false ); |
|
| 451 | + $selected = selected($args['selected'] === "", true, false); |
|
| 452 | 452 | } |
| 453 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
| 453 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - foreach( $args['options'] as $key => $option ) { |
|
| 456 | + foreach ($args['options'] as $key => $option) { |
|
| 457 | 457 | |
| 458 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
| 459 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
| 458 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
| 459 | + $selected = selected(true, (bool) in_array($key, $args['selected']), false); |
|
| 460 | 460 | } else { |
| 461 | - $selected = selected( $args['selected'], $key, false ); |
|
| 461 | + $selected = selected($args['selected'], $key, false); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
| 464 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | return $output; |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | -function wpinv_item_dropdown( $args = array() ) { |
|
| 473 | +function wpinv_item_dropdown($args = array()) { |
|
| 474 | 474 | $defaults = array( |
| 475 | 475 | 'name' => 'wpi_item', |
| 476 | 476 | 'id' => 'wpi_item', |
@@ -478,14 +478,14 @@ discard block |
||
| 478 | 478 | 'multiple' => false, |
| 479 | 479 | 'selected' => 0, |
| 480 | 480 | 'number' => 100, |
| 481 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
| 482 | - 'data' => array( 'search-type' => 'item' ), |
|
| 481 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
| 482 | + 'data' => array('search-type' => 'item'), |
|
| 483 | 483 | 'show_option_all' => false, |
| 484 | 484 | 'show_option_none' => false, |
| 485 | 485 | 'show_recurring' => false, |
| 486 | 486 | ); |
| 487 | 487 | |
| 488 | - $args = wp_parse_args( $args, $defaults ); |
|
| 488 | + $args = wp_parse_args($args, $defaults); |
|
| 489 | 489 | |
| 490 | 490 | $item_args = array( |
| 491 | 491 | 'post_type' => 'wpi_item', |
@@ -494,44 +494,44 @@ discard block |
||
| 494 | 494 | 'posts_per_page' => $args['number'] |
| 495 | 495 | ); |
| 496 | 496 | |
| 497 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
| 497 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
| 498 | 498 | |
| 499 | - $items = get_posts( $item_args ); |
|
| 499 | + $items = get_posts($item_args); |
|
| 500 | 500 | $options = array(); |
| 501 | - if ( $items ) { |
|
| 502 | - foreach ( $items as $item ) { |
|
| 503 | - $title = esc_html( $item->post_title ); |
|
| 501 | + if ($items) { |
|
| 502 | + foreach ($items as $item) { |
|
| 503 | + $title = esc_html($item->post_title); |
|
| 504 | 504 | |
| 505 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 506 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
| 505 | + if (!empty($args['show_recurring'])) { |
|
| 506 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | - $options[ absint( $item->ID ) ] = $title; |
|
| 509 | + $options[absint($item->ID)] = $title; |
|
| 510 | 510 | } |
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | // This ensures that any selected items are included in the drop down |
| 514 | - if( is_array( $args['selected'] ) ) { |
|
| 515 | - foreach( $args['selected'] as $item ) { |
|
| 516 | - if( ! in_array( $item, $options ) ) { |
|
| 517 | - $title = get_the_title( $item ); |
|
| 518 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 519 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
| 514 | + if (is_array($args['selected'])) { |
|
| 515 | + foreach ($args['selected'] as $item) { |
|
| 516 | + if (!in_array($item, $options)) { |
|
| 517 | + $title = get_the_title($item); |
|
| 518 | + if (!empty($args['show_recurring'])) { |
|
| 519 | + $title .= wpinv_get_item_suffix($item, false); |
|
| 520 | 520 | } |
| 521 | 521 | $options[$item] = $title; |
| 522 | 522 | } |
| 523 | 523 | } |
| 524 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
| 525 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
| 526 | - $title = get_the_title( $args['selected'] ); |
|
| 527 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 528 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
| 524 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
| 525 | + if (!in_array($args['selected'], $options)) { |
|
| 526 | + $title = get_the_title($args['selected']); |
|
| 527 | + if (!empty($args['show_recurring'])) { |
|
| 528 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
| 529 | 529 | } |
| 530 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
| 530 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
| 531 | 531 | } |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | - $output = wpinv_html_select( array( |
|
| 534 | + $output = wpinv_html_select(array( |
|
| 535 | 535 | 'name' => $args['name'], |
| 536 | 536 | 'selected' => $args['selected'], |
| 537 | 537 | 'id' => $args['id'], |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | 'show_option_all' => $args['show_option_all'], |
| 543 | 543 | 'show_option_none' => $args['show_option_none'], |
| 544 | 544 | 'data' => $args['data'], |
| 545 | - ) ); |
|
| 545 | + )); |
|
| 546 | 546 | |
| 547 | 547 | return $output; |
| 548 | 548 | } |
@@ -562,16 +562,16 @@ discard block |
||
| 562 | 562 | ); |
| 563 | 563 | |
| 564 | 564 | $options = array(); |
| 565 | - if ( $items ) { |
|
| 566 | - foreach ( $items as $item ) { |
|
| 567 | - $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false ); |
|
| 565 | + if ($items) { |
|
| 566 | + foreach ($items as $item) { |
|
| 567 | + $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false); |
|
| 568 | 568 | } |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | return $options; |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | -function wpinv_html_checkbox( $args = array() ) { |
|
| 574 | +function wpinv_html_checkbox($args = array()) { |
|
| 575 | 575 | $defaults = array( |
| 576 | 576 | 'name' => null, |
| 577 | 577 | 'current' => null, |
@@ -582,17 +582,17 @@ discard block |
||
| 582 | 582 | ) |
| 583 | 583 | ); |
| 584 | 584 | |
| 585 | - $args = wp_parse_args( $args, $defaults ); |
|
| 585 | + $args = wp_parse_args($args, $defaults); |
|
| 586 | 586 | |
| 587 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 587 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 588 | 588 | $options = ''; |
| 589 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
| 589 | + if (!empty($args['options']['disabled'])) { |
|
| 590 | 590 | $options .= ' disabled="disabled"'; |
| 591 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
| 591 | + } elseif (!empty($args['options']['readonly'])) { |
|
| 592 | 592 | $options .= ' readonly'; |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
| 595 | + $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
| 596 | 596 | |
| 597 | 597 | return $output; |
| 598 | 598 | } |
@@ -600,30 +600,30 @@ discard block |
||
| 600 | 600 | /** |
| 601 | 601 | * Displays a hidden field. |
| 602 | 602 | */ |
| 603 | -function getpaid_hidden_field( $name, $value ) { |
|
| 604 | - $name = sanitize_text_field( $name ); |
|
| 605 | - $value = esc_attr( $value ); |
|
| 603 | +function getpaid_hidden_field($name, $value) { |
|
| 604 | + $name = sanitize_text_field($name); |
|
| 605 | + $value = esc_attr($value); |
|
| 606 | 606 | |
| 607 | 607 | echo "<input type='hidden' name='$name' value='$value' />"; |
| 608 | 608 | } |
| 609 | 609 | |
| 610 | -function wpinv_html_text( $args = array() ) { |
|
| 610 | +function wpinv_html_text($args = array()) { |
|
| 611 | 611 | // Backwards compatibility |
| 612 | - if ( func_num_args() > 1 ) { |
|
| 612 | + if (func_num_args() > 1) { |
|
| 613 | 613 | $args = func_get_args(); |
| 614 | 614 | |
| 615 | 615 | $name = $args[0]; |
| 616 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
| 617 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
| 618 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
| 616 | + $value = isset($args[1]) ? $args[1] : ''; |
|
| 617 | + $label = isset($args[2]) ? $args[2] : ''; |
|
| 618 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | $defaults = array( |
| 622 | 622 | 'id' => '', |
| 623 | - 'name' => isset( $name ) ? $name : 'text', |
|
| 624 | - 'value' => isset( $value ) ? $value : null, |
|
| 625 | - 'label' => isset( $label ) ? $label : null, |
|
| 626 | - 'desc' => isset( $desc ) ? $desc : null, |
|
| 623 | + 'name' => isset($name) ? $name : 'text', |
|
| 624 | + 'value' => isset($value) ? $value : null, |
|
| 625 | + 'label' => isset($label) ? $label : null, |
|
| 626 | + 'desc' => isset($desc) ? $desc : null, |
|
| 627 | 627 | 'placeholder' => '', |
| 628 | 628 | 'class' => 'regular-text', |
| 629 | 629 | 'disabled' => false, |
@@ -633,51 +633,51 @@ discard block |
||
| 633 | 633 | 'data' => false |
| 634 | 634 | ); |
| 635 | 635 | |
| 636 | - $args = wp_parse_args( $args, $defaults ); |
|
| 636 | + $args = wp_parse_args($args, $defaults); |
|
| 637 | 637 | |
| 638 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 638 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 639 | 639 | $options = ''; |
| 640 | - if( $args['required'] ) { |
|
| 640 | + if ($args['required']) { |
|
| 641 | 641 | $options .= ' required="required"'; |
| 642 | 642 | } |
| 643 | - if( $args['readonly'] ) { |
|
| 643 | + if ($args['readonly']) { |
|
| 644 | 644 | $options .= ' readonly'; |
| 645 | 645 | } |
| 646 | - if( $args['readonly'] ) { |
|
| 646 | + if ($args['readonly']) { |
|
| 647 | 647 | $options .= ' readonly'; |
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | $data = ''; |
| 651 | - if ( !empty( $args['data'] ) ) { |
|
| 652 | - foreach ( $args['data'] as $key => $value ) { |
|
| 653 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
| 651 | + if (!empty($args['data'])) { |
|
| 652 | + foreach ($args['data'] as $key => $value) { |
|
| 653 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
| 654 | 654 | } |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 658 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 659 | - if ( ! empty( $args['desc'] ) ) { |
|
| 660 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 657 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 658 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 659 | + if (!empty($args['desc'])) { |
|
| 660 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
| 663 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
| 664 | 664 | |
| 665 | 665 | $output .= '</span>'; |
| 666 | 666 | |
| 667 | 667 | return $output; |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | -function wpinv_html_date_field( $args = array() ) { |
|
| 671 | - if( empty( $args['class'] ) ) { |
|
| 670 | +function wpinv_html_date_field($args = array()) { |
|
| 671 | + if (empty($args['class'])) { |
|
| 672 | 672 | $args['class'] = 'wpiDatepicker'; |
| 673 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
| 673 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
| 674 | 674 | $args['class'] .= ' wpiDatepicker'; |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | - return wpinv_html_text( $args ); |
|
| 677 | + return wpinv_html_text($args); |
|
| 678 | 678 | } |
| 679 | 679 | |
| 680 | -function wpinv_html_textarea( $args = array() ) { |
|
| 680 | +function wpinv_html_textarea($args = array()) { |
|
| 681 | 681 | $defaults = array( |
| 682 | 682 | 'name' => 'textarea', |
| 683 | 683 | 'value' => null, |
@@ -688,31 +688,31 @@ discard block |
||
| 688 | 688 | 'placeholder' => '', |
| 689 | 689 | ); |
| 690 | 690 | |
| 691 | - $args = wp_parse_args( $args, $defaults ); |
|
| 691 | + $args = wp_parse_args($args, $defaults); |
|
| 692 | 692 | |
| 693 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 693 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 694 | 694 | $disabled = ''; |
| 695 | - if( $args['disabled'] ) { |
|
| 695 | + if ($args['disabled']) { |
|
| 696 | 696 | $disabled = ' disabled="disabled"'; |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 700 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 701 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
| 699 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 700 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 701 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
| 702 | 702 | |
| 703 | - if ( ! empty( $args['desc'] ) ) { |
|
| 704 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 703 | + if (!empty($args['desc'])) { |
|
| 704 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 705 | 705 | } |
| 706 | 706 | $output .= '</span>'; |
| 707 | 707 | |
| 708 | 708 | return $output; |
| 709 | 709 | } |
| 710 | 710 | |
| 711 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
| 711 | +function wpinv_html_ajax_user_search($args = array()) { |
|
| 712 | 712 | $defaults = array( |
| 713 | 713 | 'name' => 'user_id', |
| 714 | 714 | 'value' => null, |
| 715 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
| 715 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
| 716 | 716 | 'label' => null, |
| 717 | 717 | 'desc' => null, |
| 718 | 718 | 'class' => '', |
@@ -721,13 +721,13 @@ discard block |
||
| 721 | 721 | 'data' => false |
| 722 | 722 | ); |
| 723 | 723 | |
| 724 | - $args = wp_parse_args( $args, $defaults ); |
|
| 724 | + $args = wp_parse_args($args, $defaults); |
|
| 725 | 725 | |
| 726 | 726 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
| 727 | 727 | |
| 728 | 728 | $output = '<span class="wpinv_user_search_wrap">'; |
| 729 | - $output .= wpinv_html_text( $args ); |
|
| 730 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
| 729 | + $output .= wpinv_html_text($args); |
|
| 730 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
| 731 | 731 | $output .= '</span>'; |
| 732 | 732 | |
| 733 | 733 | return $output; |
@@ -743,20 +743,20 @@ discard block |
||
| 743 | 743 | * |
| 744 | 744 | * @param string $template the template that is currently being used. |
| 745 | 745 | */ |
| 746 | -function wpinv_template( $template ) { |
|
| 746 | +function wpinv_template($template) { |
|
| 747 | 747 | global $post; |
| 748 | 748 | |
| 749 | - if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) { |
|
| 749 | + if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) { |
|
| 750 | 750 | |
| 751 | 751 | // If the user can view this invoice, display it. |
| 752 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
| 752 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
| 753 | 753 | |
| 754 | - return wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
| 754 | + return wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
| 755 | 755 | |
| 756 | 756 | // Else display an error message. |
| 757 | 757 | } else { |
| 758 | 758 | |
| 759 | - return wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
| 759 | + return wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
| 760 | 760 | |
| 761 | 761 | } |
| 762 | 762 | |
@@ -764,46 +764,46 @@ discard block |
||
| 764 | 764 | |
| 765 | 765 | return $template; |
| 766 | 766 | } |
| 767 | -add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
| 767 | +add_filter('template_include', 'wpinv_template', 10, 1); |
|
| 768 | 768 | |
| 769 | 769 | function wpinv_get_business_address() { |
| 770 | 770 | $business_address = wpinv_store_address(); |
| 771 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
| 771 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
| 772 | 772 | |
| 773 | 773 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
| 774 | 774 | |
| 775 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
| 775 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | /** |
| 779 | 779 | * Displays the company address. |
| 780 | 780 | */ |
| 781 | 781 | function wpinv_display_from_address() { |
| 782 | - wpinv_get_template( 'invoice/company-address.php' ); |
|
| 782 | + wpinv_get_template('invoice/company-address.php'); |
|
| 783 | 783 | } |
| 784 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 ); |
|
| 784 | +add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10); |
|
| 785 | 785 | |
| 786 | -function wpinv_watermark( $id = 0 ) { |
|
| 787 | - $output = wpinv_get_watermark( $id ); |
|
| 788 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
| 786 | +function wpinv_watermark($id = 0) { |
|
| 787 | + $output = wpinv_get_watermark($id); |
|
| 788 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
| 789 | 789 | } |
| 790 | 790 | |
| 791 | -function wpinv_get_watermark( $id ) { |
|
| 792 | - if ( !$id > 0 ) { |
|
| 791 | +function wpinv_get_watermark($id) { |
|
| 792 | + if (!$id > 0) { |
|
| 793 | 793 | return NULL; |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | - $invoice = wpinv_get_invoice( $id ); |
|
| 796 | + $invoice = wpinv_get_invoice($id); |
|
| 797 | 797 | |
| 798 | - if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) { |
|
| 799 | - if ( $invoice->is_paid() ) { |
|
| 800 | - return __( 'Paid', 'invoicing' ); |
|
| 798 | + if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) { |
|
| 799 | + if ($invoice->is_paid()) { |
|
| 800 | + return __('Paid', 'invoicing'); |
|
| 801 | 801 | } |
| 802 | - if ( $invoice->is_refunded() ) { |
|
| 803 | - return __( 'Refunded', 'invoicing' ); |
|
| 802 | + if ($invoice->is_refunded()) { |
|
| 803 | + return __('Refunded', 'invoicing'); |
|
| 804 | 804 | } |
| 805 | - if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) { |
|
| 806 | - return __( 'Cancelled', 'invoicing' ); |
|
| 805 | + if ($invoice->has_status(array('wpi-cancelled'))) { |
|
| 806 | + return __('Cancelled', 'invoicing'); |
|
| 807 | 807 | } |
| 808 | 808 | } |
| 809 | 809 | |
@@ -813,30 +813,30 @@ discard block |
||
| 813 | 813 | /** |
| 814 | 814 | * @deprecated |
| 815 | 815 | */ |
| 816 | -function wpinv_display_invoice_details( $invoice ) { |
|
| 817 | - return getpaid_invoice_meta( $invoice ); |
|
| 816 | +function wpinv_display_invoice_details($invoice) { |
|
| 817 | + return getpaid_invoice_meta($invoice); |
|
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | /** |
| 821 | 821 | * Displays invoice meta. |
| 822 | 822 | */ |
| 823 | -function getpaid_invoice_meta( $invoice ) { |
|
| 823 | +function getpaid_invoice_meta($invoice) { |
|
| 824 | 824 | |
| 825 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 825 | + $invoice = new WPInv_Invoice($invoice); |
|
| 826 | 826 | |
| 827 | 827 | // Ensure that we have an invoice. |
| 828 | - if ( 0 == $invoice->get_id() ) { |
|
| 828 | + if (0 == $invoice->get_id()) { |
|
| 829 | 829 | return; |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | // Get the invoice meta. |
| 833 | - $meta = getpaid_get_invoice_meta( $invoice ); |
|
| 833 | + $meta = getpaid_get_invoice_meta($invoice); |
|
| 834 | 834 | |
| 835 | 835 | // Display the meta. |
| 836 | - wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) ); |
|
| 836 | + wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta')); |
|
| 837 | 837 | |
| 838 | 838 | } |
| 839 | -add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 ); |
|
| 839 | +add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10); |
|
| 840 | 840 | |
| 841 | 841 | /** |
| 842 | 842 | * Retrieves the address markup to use on Invoices. |
@@ -848,29 +848,29 @@ discard block |
||
| 848 | 848 | * @param string $separator How to separate address lines. |
| 849 | 849 | * @return string |
| 850 | 850 | */ |
| 851 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
| 851 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
| 852 | 852 | |
| 853 | 853 | // Retrieve the address markup... |
| 854 | - $country= empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
| 855 | - $format = wpinv_get_full_address_format( $country ); |
|
| 854 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
| 855 | + $format = wpinv_get_full_address_format($country); |
|
| 856 | 856 | |
| 857 | 857 | // ... and the replacements. |
| 858 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
| 858 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
| 859 | 859 | |
| 860 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
| 860 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
| 861 | 861 | |
| 862 | 862 | // Remove unavailable tags. |
| 863 | - $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
|
| 863 | + $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address); |
|
| 864 | 864 | |
| 865 | 865 | // Clean up white space. |
| 866 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
| 867 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
| 866 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
| 867 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
| 868 | 868 | |
| 869 | 869 | // Break newlines apart and remove empty lines/trim commas and white space. |
| 870 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
| 870 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
| 871 | 871 | |
| 872 | 872 | // Add html breaks. |
| 873 | - $formatted_address = implode( $separator, $formatted_address ); |
|
| 873 | + $formatted_address = implode($separator, $formatted_address); |
|
| 874 | 874 | |
| 875 | 875 | // We're done! |
| 876 | 876 | return $formatted_address; |
@@ -882,88 +882,88 @@ discard block |
||
| 882 | 882 | * |
| 883 | 883 | * @param WPInv_Invoice $invoice |
| 884 | 884 | */ |
| 885 | -function wpinv_display_to_address( $invoice = 0 ) { |
|
| 886 | - if ( ! empty( $invoice ) ) { |
|
| 887 | - wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) ); |
|
| 885 | +function wpinv_display_to_address($invoice = 0) { |
|
| 886 | + if (!empty($invoice)) { |
|
| 887 | + wpinv_get_template('invoice/billing-address.php', compact('invoice')); |
|
| 888 | 888 | } |
| 889 | 889 | } |
| 890 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 ); |
|
| 890 | +add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40); |
|
| 891 | 891 | |
| 892 | 892 | |
| 893 | 893 | /** |
| 894 | 894 | * Displays invoice line items. |
| 895 | 895 | */ |
| 896 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
| 896 | +function wpinv_display_line_items($invoice_id = 0) { |
|
| 897 | 897 | |
| 898 | 898 | // Prepare the invoice. |
| 899 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 899 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 900 | 900 | |
| 901 | 901 | // Abort if there is no invoice. |
| 902 | - if ( 0 == $invoice->get_id() ) { |
|
| 902 | + if (0 == $invoice->get_id()) { |
|
| 903 | 903 | return; |
| 904 | 904 | } |
| 905 | 905 | |
| 906 | 906 | // Line item columns. |
| 907 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
| 908 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
| 907 | + $columns = getpaid_invoice_item_columns($invoice); |
|
| 908 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
| 909 | 909 | |
| 910 | - wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) ); |
|
| 910 | + wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns')); |
|
| 911 | 911 | } |
| 912 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 ); |
|
| 912 | +add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10); |
|
| 913 | 913 | |
| 914 | 914 | /** |
| 915 | 915 | * Displays invoice notices on invoices. |
| 916 | 916 | */ |
| 917 | 917 | function wpinv_display_invoice_notice() { |
| 918 | 918 | |
| 919 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
| 920 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
| 919 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
| 920 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
| 921 | 921 | |
| 922 | - if ( empty( $label ) && empty( $notice ) ) { |
|
| 922 | + if (empty($label) && empty($notice)) { |
|
| 923 | 923 | return; |
| 924 | 924 | } |
| 925 | 925 | |
| 926 | 926 | echo '<div class="mt-4 mb-4 wpinv-vat-notice">'; |
| 927 | 927 | |
| 928 | - if ( ! empty( $label ) ) { |
|
| 929 | - $label = sanitize_text_field( $label ); |
|
| 928 | + if (!empty($label)) { |
|
| 929 | + $label = sanitize_text_field($label); |
|
| 930 | 930 | echo "<h5>$label</h5>"; |
| 931 | 931 | } |
| 932 | 932 | |
| 933 | - if ( ! empty( $notice ) ) { |
|
| 934 | - echo '<small class="form-text text-muted">' . wpautop( wptexturize( $notice ) ) . '</small>'; |
|
| 933 | + if (!empty($notice)) { |
|
| 934 | + echo '<small class="form-text text-muted">' . wpautop(wptexturize($notice)) . '</small>'; |
|
| 935 | 935 | } |
| 936 | 936 | |
| 937 | 937 | echo '</div>'; |
| 938 | 938 | } |
| 939 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 ); |
|
| 939 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100); |
|
| 940 | 940 | |
| 941 | 941 | /** |
| 942 | 942 | * @param WPInv_Invoice $invoice |
| 943 | 943 | */ |
| 944 | -function wpinv_display_invoice_notes( $invoice ) { |
|
| 944 | +function wpinv_display_invoice_notes($invoice) { |
|
| 945 | 945 | |
| 946 | 946 | // Retrieve the notes. |
| 947 | - $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' ); |
|
| 947 | + $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer'); |
|
| 948 | 948 | |
| 949 | 949 | // Abort if we have non. |
| 950 | - if ( empty( $notes ) ) { |
|
| 950 | + if (empty($notes)) { |
|
| 951 | 951 | return; |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | 954 | // Echo the note. |
| 955 | 955 | echo '<div class="getpaid-invoice-notes-wrapper border position-relative w-100 mb-4 p-0">'; |
| 956 | - echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __( 'Notes', 'invoicing' ) .'</h3>'; |
|
| 956 | + echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __('Notes', 'invoicing') . '</h3>'; |
|
| 957 | 957 | echo '<ul class="getpaid-invoice-notes mt-4 p-0">'; |
| 958 | 958 | |
| 959 | - foreach( $notes as $note ) { |
|
| 960 | - wpinv_get_invoice_note_line_item( $note ); |
|
| 959 | + foreach ($notes as $note) { |
|
| 960 | + wpinv_get_invoice_note_line_item($note); |
|
| 961 | 961 | } |
| 962 | 962 | |
| 963 | 963 | echo '</ul>'; |
| 964 | 964 | echo '</div>'; |
| 965 | 965 | } |
| 966 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 ); |
|
| 966 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60); |
|
| 967 | 967 | |
| 968 | 968 | /** |
| 969 | 969 | * Loads scripts on our invoice templates. |
@@ -971,32 +971,32 @@ discard block |
||
| 971 | 971 | function wpinv_display_style() { |
| 972 | 972 | |
| 973 | 973 | // Make sure that all scripts have been loaded. |
| 974 | - if ( ! did_action( 'wp_enqueue_scripts' ) ) { |
|
| 975 | - do_action( 'wp_enqueue_scripts' ); |
|
| 974 | + if (!did_action('wp_enqueue_scripts')) { |
|
| 975 | + do_action('wp_enqueue_scripts'); |
|
| 976 | 976 | } |
| 977 | 977 | |
| 978 | 978 | // Register the invoices style. |
| 979 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) ); |
|
| 979 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css')); |
|
| 980 | 980 | |
| 981 | 981 | // Load required styles |
| 982 | - wp_print_styles( 'open-sans' ); |
|
| 983 | - wp_print_styles( 'wpinv-single-style' ); |
|
| 984 | - wp_print_styles( 'ayecode-ui' ); |
|
| 982 | + wp_print_styles('open-sans'); |
|
| 983 | + wp_print_styles('wpinv-single-style'); |
|
| 984 | + wp_print_styles('ayecode-ui'); |
|
| 985 | 985 | |
| 986 | 986 | // Maybe load custom css. |
| 987 | - $custom_css = wpinv_get_option( 'template_custom_css' ); |
|
| 987 | + $custom_css = wpinv_get_option('template_custom_css'); |
|
| 988 | 988 | |
| 989 | - if ( isset( $custom_css ) && ! empty( $custom_css ) ) { |
|
| 990 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
| 991 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
| 989 | + if (isset($custom_css) && !empty($custom_css)) { |
|
| 990 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
| 991 | + $custom_css = str_replace('>', '>', $custom_css); |
|
| 992 | 992 | echo '<style type="text/css">'; |
| 993 | 993 | echo $custom_css; |
| 994 | 994 | echo '</style>'; |
| 995 | 995 | } |
| 996 | 996 | |
| 997 | 997 | } |
| 998 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
| 999 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
| 998 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
| 999 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
| 1000 | 1000 | |
| 1001 | 1001 | |
| 1002 | 1002 | /** |
@@ -1008,41 +1008,41 @@ discard block |
||
| 1008 | 1008 | // Retrieve the current invoice. |
| 1009 | 1009 | $invoice_id = getpaid_get_current_invoice_id(); |
| 1010 | 1010 | |
| 1011 | - if ( empty( $invoice_id ) ) { |
|
| 1011 | + if (empty($invoice_id)) { |
|
| 1012 | 1012 | |
| 1013 | 1013 | return aui()->alert( |
| 1014 | 1014 | array( |
| 1015 | 1015 | 'type' => 'warning', |
| 1016 | - 'content' => __( 'Invalid invoice', 'invoicing' ), |
|
| 1016 | + 'content' => __('Invalid invoice', 'invoicing'), |
|
| 1017 | 1017 | ) |
| 1018 | 1018 | ); |
| 1019 | 1019 | |
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | 1022 | // Can the user view this invoice? |
| 1023 | - if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) { |
|
| 1023 | + if (!wpinv_user_can_view_invoice($invoice_id)) { |
|
| 1024 | 1024 | |
| 1025 | 1025 | return aui()->alert( |
| 1026 | 1026 | array( |
| 1027 | 1027 | 'type' => 'warning', |
| 1028 | - 'content' => __( 'You are not allowed to view this invoice', 'invoicing' ), |
|
| 1028 | + 'content' => __('You are not allowed to view this invoice', 'invoicing'), |
|
| 1029 | 1029 | ) |
| 1030 | 1030 | ); |
| 1031 | 1031 | |
| 1032 | 1032 | } |
| 1033 | 1033 | |
| 1034 | 1034 | // Ensure that it is not yet paid for. |
| 1035 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 1035 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 1036 | 1036 | |
| 1037 | 1037 | // Maybe mark it as viewed. |
| 1038 | - getpaid_maybe_mark_invoice_as_viewed( $invoice ); |
|
| 1038 | + getpaid_maybe_mark_invoice_as_viewed($invoice); |
|
| 1039 | 1039 | |
| 1040 | - if ( $invoice->is_paid() ) { |
|
| 1040 | + if ($invoice->is_paid()) { |
|
| 1041 | 1041 | |
| 1042 | 1042 | return aui()->alert( |
| 1043 | 1043 | array( |
| 1044 | 1044 | 'type' => 'success', |
| 1045 | - 'content' => __( 'This invoice has already been paid.', 'invoicing' ), |
|
| 1045 | + 'content' => __('This invoice has already been paid.', 'invoicing'), |
|
| 1046 | 1046 | ) |
| 1047 | 1047 | ); |
| 1048 | 1048 | |
@@ -1052,14 +1052,14 @@ discard block |
||
| 1052 | 1052 | $wpi_checkout_id = $invoice_id; |
| 1053 | 1053 | |
| 1054 | 1054 | // We'll display this invoice via the default form. |
| 1055 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
| 1055 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
| 1056 | 1056 | |
| 1057 | - if ( 0 == $form->get_id() ) { |
|
| 1057 | + if (0 == $form->get_id()) { |
|
| 1058 | 1058 | |
| 1059 | 1059 | return aui()->alert( |
| 1060 | 1060 | array( |
| 1061 | 1061 | 'type' => 'warning', |
| 1062 | - 'content' => __( 'Error loading the payment form', 'invoicing' ), |
|
| 1062 | + 'content' => __('Error loading the payment form', 'invoicing'), |
|
| 1063 | 1063 | ) |
| 1064 | 1064 | ); |
| 1065 | 1065 | |
@@ -1067,7 +1067,7 @@ discard block |
||
| 1067 | 1067 | |
| 1068 | 1068 | // Set the invoice. |
| 1069 | 1069 | $form->invoice = $invoice; |
| 1070 | - $form->set_items( $invoice->get_items() ); |
|
| 1070 | + $form->set_items($invoice->get_items()); |
|
| 1071 | 1071 | |
| 1072 | 1072 | // Generate the html. |
| 1073 | 1073 | return $form->get_html(); |
@@ -1075,7 +1075,7 @@ discard block |
||
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | 1077 | function wpinv_empty_cart_message() { |
| 1078 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1078 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | 1081 | /** |
@@ -1092,38 +1092,38 @@ discard block |
||
| 1092 | 1092 | ) |
| 1093 | 1093 | ); |
| 1094 | 1094 | } |
| 1095 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
| 1095 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
| 1096 | 1096 | |
| 1097 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
| 1098 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1097 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
| 1098 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1099 | 1099 | |
| 1100 | - if ( empty( $invoice ) ) { |
|
| 1100 | + if (empty($invoice)) { |
|
| 1101 | 1101 | return NULL; |
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | 1104 | $billing_details = $invoice->get_user_info(); |
| 1105 | - $address_row = wpinv_get_invoice_address_markup( $billing_details ); |
|
| 1105 | + $address_row = wpinv_get_invoice_address_markup($billing_details); |
|
| 1106 | 1106 | |
| 1107 | 1107 | ob_start(); |
| 1108 | 1108 | ?> |
| 1109 | 1109 | <table class="table table-bordered table-sm wpi-billing-details"> |
| 1110 | 1110 | <tbody> |
| 1111 | 1111 | <tr class="wpi-receipt-name"> |
| 1112 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
| 1113 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
| 1112 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
| 1113 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
| 1114 | 1114 | </tr> |
| 1115 | 1115 | <tr class="wpi-receipt-email"> |
| 1116 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
| 1117 | - <td><?php echo $billing_details['email'] ;?></td> |
|
| 1116 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
| 1117 | + <td><?php echo $billing_details['email']; ?></td> |
|
| 1118 | 1118 | </tr> |
| 1119 | 1119 | <tr class="wpi-receipt-address"> |
| 1120 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
| 1121 | - <td><?php echo $address_row ;?></td> |
|
| 1120 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
| 1121 | + <td><?php echo $address_row; ?></td> |
|
| 1122 | 1122 | </tr> |
| 1123 | - <?php if ( $billing_details['phone'] ) { ?> |
|
| 1123 | + <?php if ($billing_details['phone']) { ?> |
|
| 1124 | 1124 | <tr class="wpi-receipt-phone"> |
| 1125 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
| 1126 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
| 1125 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
| 1126 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
| 1127 | 1127 | </tr> |
| 1128 | 1128 | <?php } ?> |
| 1129 | 1129 | </tbody> |
@@ -1131,7 +1131,7 @@ discard block |
||
| 1131 | 1131 | <?php |
| 1132 | 1132 | $output = ob_get_clean(); |
| 1133 | 1133 | |
| 1134 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
| 1134 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
| 1135 | 1135 | |
| 1136 | 1136 | echo $output; |
| 1137 | 1137 | } |
@@ -1139,66 +1139,66 @@ discard block |
||
| 1139 | 1139 | /** |
| 1140 | 1140 | * Filters the receipt page. |
| 1141 | 1141 | */ |
| 1142 | -function wpinv_filter_success_page_content( $content ) { |
|
| 1142 | +function wpinv_filter_success_page_content($content) { |
|
| 1143 | 1143 | |
| 1144 | 1144 | // Ensure this is our page. |
| 1145 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
| 1145 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
| 1146 | 1146 | |
| 1147 | - $gateway = sanitize_text_field( $_GET['payment-confirm'] ); |
|
| 1148 | - return apply_filters( "wpinv_payment_confirm_$gateway", $content ); |
|
| 1147 | + $gateway = sanitize_text_field($_GET['payment-confirm']); |
|
| 1148 | + return apply_filters("wpinv_payment_confirm_$gateway", $content); |
|
| 1149 | 1149 | |
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | 1152 | return $content; |
| 1153 | 1153 | } |
| 1154 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
| 1154 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
| 1155 | 1155 | |
| 1156 | -function wpinv_invoice_link( $invoice_id ) { |
|
| 1157 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1156 | +function wpinv_invoice_link($invoice_id) { |
|
| 1157 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1158 | 1158 | |
| 1159 | - if ( empty( $invoice ) ) { |
|
| 1159 | + if (empty($invoice)) { |
|
| 1160 | 1160 | return NULL; |
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
| 1163 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
| 1164 | 1164 | |
| 1165 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
| 1165 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
| 1169 | - if ( empty( $note ) ) { |
|
| 1168 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
| 1169 | + if (empty($note)) { |
|
| 1170 | 1170 | return NULL; |
| 1171 | 1171 | } |
| 1172 | 1172 | |
| 1173 | - if ( is_int( $note ) ) { |
|
| 1174 | - $note = get_comment( $note ); |
|
| 1173 | + if (is_int($note)) { |
|
| 1174 | + $note = get_comment($note); |
|
| 1175 | 1175 | } |
| 1176 | 1176 | |
| 1177 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
| 1177 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
| 1178 | 1178 | return NULL; |
| 1179 | 1179 | } |
| 1180 | 1180 | |
| 1181 | - $note_classes = array( 'note' ); |
|
| 1182 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
| 1181 | + $note_classes = array('note'); |
|
| 1182 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
| 1183 | 1183 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
| 1184 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
| 1185 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
| 1184 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
| 1185 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
| 1186 | 1186 | |
| 1187 | 1187 | ob_start(); |
| 1188 | 1188 | ?> |
| 1189 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?> mt-4 pl-3 pr-3"> |
|
| 1189 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mt-4 pl-3 pr-3"> |
|
| 1190 | 1190 | <div class="note_content bg-light border position-relative p-4"> |
| 1191 | 1191 | |
| 1192 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
| 1192 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
| 1193 | 1193 | |
| 1194 | - <?php if ( ! is_admin() ) : ?> |
|
| 1194 | + <?php if (!is_admin()) : ?> |
|
| 1195 | 1195 | <em class="meta position-absolute form-text"> |
| 1196 | 1196 | <?php |
| 1197 | 1197 | printf( |
| 1198 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
| 1198 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
| 1199 | 1199 | $note->comment_author, |
| 1200 | - getpaid_format_date_value( $note->comment_date ), |
|
| 1201 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
| 1200 | + getpaid_format_date_value($note->comment_date), |
|
| 1201 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
| 1202 | 1202 | ); |
| 1203 | 1203 | ?> |
| 1204 | 1204 | </em> |
@@ -1206,21 +1206,21 @@ discard block |
||
| 1206 | 1206 | |
| 1207 | 1207 | </div> |
| 1208 | 1208 | |
| 1209 | - <?php if ( is_admin() ) : ?> |
|
| 1209 | + <?php if (is_admin()) : ?> |
|
| 1210 | 1210 | |
| 1211 | 1211 | <p class="meta px-4 py-2"> |
| 1212 | - <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"> |
|
| 1212 | + <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"> |
|
| 1213 | 1213 | <?php |
| 1214 | 1214 | printf( |
| 1215 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
| 1215 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
| 1216 | 1216 | $note->comment_author, |
| 1217 | - getpaid_format_date_value( $note->comment_date ), |
|
| 1218 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
| 1217 | + getpaid_format_date_value($note->comment_date), |
|
| 1218 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
| 1219 | 1219 | ); |
| 1220 | 1220 | ?> |
| 1221 | 1221 | </abbr> |
| 1222 | - <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?> |
|
| 1223 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
| 1222 | + <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?> |
|
| 1223 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
| 1224 | 1224 | <?php } ?> |
| 1225 | 1225 | </p> |
| 1226 | 1226 | |
@@ -1229,9 +1229,9 @@ discard block |
||
| 1229 | 1229 | </li> |
| 1230 | 1230 | <?php |
| 1231 | 1231 | $note_content = ob_get_clean(); |
| 1232 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
| 1232 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
| 1233 | 1233 | |
| 1234 | - if ( $echo ) { |
|
| 1234 | + if ($echo) { |
|
| 1235 | 1235 | echo $note_content; |
| 1236 | 1236 | } else { |
| 1237 | 1237 | return $note_content; |
@@ -1241,36 +1241,36 @@ discard block |
||
| 1241 | 1241 | function wpinv_invalid_invoice_content() { |
| 1242 | 1242 | global $post; |
| 1243 | 1243 | |
| 1244 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
| 1244 | + $invoice = wpinv_get_invoice($post->ID); |
|
| 1245 | 1245 | |
| 1246 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' ); |
|
| 1247 | - if ( !empty( $invoice->get_id() ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
| 1248 | - if ( is_user_logged_in() ) { |
|
| 1249 | - if ( wpinv_require_login_to_checkout() ) { |
|
| 1250 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 1251 | - $error = __( 'You are not allowed to view this invoice.', 'invoicing' ); |
|
| 1246 | + $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing'); |
|
| 1247 | + if (!empty($invoice->get_id()) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) { |
|
| 1248 | + if (is_user_logged_in()) { |
|
| 1249 | + if (wpinv_require_login_to_checkout()) { |
|
| 1250 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
| 1251 | + $error = __('You are not allowed to view this invoice.', 'invoicing'); |
|
| 1252 | 1252 | } |
| 1253 | 1253 | } |
| 1254 | 1254 | } else { |
| 1255 | - if ( wpinv_require_login_to_checkout() ) { |
|
| 1256 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 1257 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
| 1255 | + if (wpinv_require_login_to_checkout()) { |
|
| 1256 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
| 1257 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
| 1258 | 1258 | } |
| 1259 | 1259 | } |
| 1260 | 1260 | } |
| 1261 | 1261 | } else { |
| 1262 | - $error = __( 'This invoice is deleted or does not exist.', 'invoicing' ); |
|
| 1262 | + $error = __('This invoice is deleted or does not exist.', 'invoicing'); |
|
| 1263 | 1263 | } |
| 1264 | 1264 | ?> |
| 1265 | 1265 | <div class="row wpinv-row-invalid"> |
| 1266 | 1266 | <div class="col-md-6 col-md-offset-3 wpinv-message error"> |
| 1267 | - <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3> |
|
| 1267 | + <h3><?php _e('Access Denied', 'invoicing'); ?></h3> |
|
| 1268 | 1268 | <p class="wpinv-msg-text"><?php echo $error; ?></p> |
| 1269 | 1269 | </div> |
| 1270 | 1270 | </div> |
| 1271 | 1271 | <?php |
| 1272 | 1272 | } |
| 1273 | -add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' ); |
|
| 1273 | +add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content'); |
|
| 1274 | 1274 | |
| 1275 | 1275 | /** |
| 1276 | 1276 | * Function to get privacy policy text. |
@@ -1279,21 +1279,21 @@ discard block |
||
| 1279 | 1279 | * @return string |
| 1280 | 1280 | */ |
| 1281 | 1281 | function wpinv_get_policy_text() { |
| 1282 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
| 1282 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
| 1283 | 1283 | |
| 1284 | - $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' )); |
|
| 1284 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
| 1285 | 1285 | |
| 1286 | - if(!$privacy_page_id){ |
|
| 1287 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
| 1286 | + if (!$privacy_page_id) { |
|
| 1287 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
| 1288 | 1288 | } |
| 1289 | 1289 | |
| 1290 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
| 1290 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
| 1291 | 1291 | |
| 1292 | 1292 | $find_replace = array( |
| 1293 | 1293 | '[wpinv_privacy_policy]' => $privacy_link, |
| 1294 | 1294 | ); |
| 1295 | 1295 | |
| 1296 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
| 1296 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
| 1297 | 1297 | |
| 1298 | 1298 | return wp_kses_post(wpautop($privacy_text)); |
| 1299 | 1299 | } |
@@ -1301,21 +1301,21 @@ discard block |
||
| 1301 | 1301 | function wpinv_oxygen_fix_conflict() { |
| 1302 | 1302 | global $ct_ignore_post_types; |
| 1303 | 1303 | |
| 1304 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
| 1304 | + if (!is_array($ct_ignore_post_types)) { |
|
| 1305 | 1305 | $ct_ignore_post_types = array(); |
| 1306 | 1306 | } |
| 1307 | 1307 | |
| 1308 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' ); |
|
| 1308 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item'); |
|
| 1309 | 1309 | |
| 1310 | - foreach ( $post_types as $post_type ) { |
|
| 1310 | + foreach ($post_types as $post_type) { |
|
| 1311 | 1311 | $ct_ignore_post_types[] = $post_type; |
| 1312 | 1312 | |
| 1313 | 1313 | // Ignore post type |
| 1314 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
| 1314 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
| 1315 | 1315 | } |
| 1316 | 1316 | |
| 1317 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
| 1318 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
| 1317 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
| 1318 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
| 1319 | 1319 | } |
| 1320 | 1320 | |
| 1321 | 1321 | /** |
@@ -1323,10 +1323,10 @@ discard block |
||
| 1323 | 1323 | * |
| 1324 | 1324 | * @param GetPaid_Payment_Form $form |
| 1325 | 1325 | */ |
| 1326 | -function getpaid_display_payment_form( $form ) { |
|
| 1326 | +function getpaid_display_payment_form($form) { |
|
| 1327 | 1327 | |
| 1328 | - if ( is_numeric( $form ) ) { |
|
| 1329 | - $form = new GetPaid_Payment_Form( $form ); |
|
| 1328 | + if (is_numeric($form)) { |
|
| 1329 | + $form = new GetPaid_Payment_Form($form); |
|
| 1330 | 1330 | } |
| 1331 | 1331 | |
| 1332 | 1332 | $form->display(); |
@@ -1336,55 +1336,55 @@ discard block |
||
| 1336 | 1336 | /** |
| 1337 | 1337 | * Helper function to display a item payment form on the frontend. |
| 1338 | 1338 | */ |
| 1339 | -function getpaid_display_item_payment_form( $items ) { |
|
| 1339 | +function getpaid_display_item_payment_form($items) { |
|
| 1340 | 1340 | |
| 1341 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
| 1342 | - $form->set_items( $items ); |
|
| 1341 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
| 1342 | + $form->set_items($items); |
|
| 1343 | 1343 | |
| 1344 | - if ( 0 == count( $form->get_items() ) ) { |
|
| 1344 | + if (0 == count($form->get_items())) { |
|
| 1345 | 1345 | echo aui()->alert( |
| 1346 | 1346 | array( |
| 1347 | 1347 | 'type' => 'warning', |
| 1348 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
| 1348 | + 'content' => __('No published items found', 'invoicing'), |
|
| 1349 | 1349 | ) |
| 1350 | 1350 | ); |
| 1351 | 1351 | return; |
| 1352 | 1352 | } |
| 1353 | 1353 | |
| 1354 | - $form_items = esc_attr( getpaid_convert_items_to_string( $items ) ); |
|
| 1354 | + $form_items = esc_attr(getpaid_convert_items_to_string($items)); |
|
| 1355 | 1355 | $form_items = "<input type='hidden' name='getpaid-form-items' value='$form_items' />"; |
| 1356 | - $form->display( $form_items ); |
|
| 1356 | + $form->display($form_items); |
|
| 1357 | 1357 | } |
| 1358 | 1358 | |
| 1359 | 1359 | /** |
| 1360 | 1360 | * Helper function to display an invoice payment form on the frontend. |
| 1361 | 1361 | */ |
| 1362 | -function getpaid_display_invoice_payment_form( $invoice_id ) { |
|
| 1362 | +function getpaid_display_invoice_payment_form($invoice_id) { |
|
| 1363 | 1363 | |
| 1364 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1364 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1365 | 1365 | |
| 1366 | - if ( empty( $invoice ) ) { |
|
| 1366 | + if (empty($invoice)) { |
|
| 1367 | 1367 | echo aui()->alert( |
| 1368 | 1368 | array( |
| 1369 | 1369 | 'type' => 'warning', |
| 1370 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
| 1370 | + 'content' => __('Invoice not found', 'invoicing'), |
|
| 1371 | 1371 | ) |
| 1372 | 1372 | ); |
| 1373 | 1373 | return; |
| 1374 | 1374 | } |
| 1375 | 1375 | |
| 1376 | - if ( $invoice->is_paid() ) { |
|
| 1376 | + if ($invoice->is_paid()) { |
|
| 1377 | 1377 | echo aui()->alert( |
| 1378 | 1378 | array( |
| 1379 | 1379 | 'type' => 'warning', |
| 1380 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
| 1380 | + 'content' => __('Invoice has already been paid', 'invoicing'), |
|
| 1381 | 1381 | ) |
| 1382 | 1382 | ); |
| 1383 | 1383 | return; |
| 1384 | 1384 | } |
| 1385 | 1385 | |
| 1386 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
| 1387 | - $form->set_items( $invoice->get_items() ); |
|
| 1386 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
| 1387 | + $form->set_items($invoice->get_items()); |
|
| 1388 | 1388 | |
| 1389 | 1389 | $form->display(); |
| 1390 | 1390 | } |
@@ -1392,23 +1392,23 @@ discard block |
||
| 1392 | 1392 | /** |
| 1393 | 1393 | * Helper function to convert item string to array. |
| 1394 | 1394 | */ |
| 1395 | -function getpaid_convert_items_to_array( $items ) { |
|
| 1396 | - $items = array_filter( array_map( 'trim', explode( ',', $items ) ) ); |
|
| 1395 | +function getpaid_convert_items_to_array($items) { |
|
| 1396 | + $items = array_filter(array_map('trim', explode(',', $items))); |
|
| 1397 | 1397 | $prepared = array(); |
| 1398 | 1398 | |
| 1399 | - foreach ( $items as $item ) { |
|
| 1400 | - $data = array_map( 'trim', explode( '|', $item ) ); |
|
| 1399 | + foreach ($items as $item) { |
|
| 1400 | + $data = array_map('trim', explode('|', $item)); |
|
| 1401 | 1401 | |
| 1402 | - if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) { |
|
| 1402 | + if (empty($data[0]) || !is_numeric($data[0])) { |
|
| 1403 | 1403 | continue; |
| 1404 | 1404 | } |
| 1405 | 1405 | |
| 1406 | 1406 | $quantity = 1; |
| 1407 | - if ( isset( $data[1] ) && is_numeric( $data[1] ) ) { |
|
| 1407 | + if (isset($data[1]) && is_numeric($data[1])) { |
|
| 1408 | 1408 | $quantity = (int) $data[1]; |
| 1409 | 1409 | } |
| 1410 | 1410 | |
| 1411 | - $prepared[ $data[0] ] = $quantity; |
|
| 1411 | + $prepared[$data[0]] = $quantity; |
|
| 1412 | 1412 | |
| 1413 | 1413 | } |
| 1414 | 1414 | |
@@ -1418,13 +1418,13 @@ discard block |
||
| 1418 | 1418 | /** |
| 1419 | 1419 | * Helper function to convert item array to string. |
| 1420 | 1420 | */ |
| 1421 | -function getpaid_convert_items_to_string( $items ) { |
|
| 1421 | +function getpaid_convert_items_to_string($items) { |
|
| 1422 | 1422 | $prepared = array(); |
| 1423 | 1423 | |
| 1424 | - foreach ( $items as $item => $quantity ) { |
|
| 1424 | + foreach ($items as $item => $quantity) { |
|
| 1425 | 1425 | $prepared[] = "$item|$quantity"; |
| 1426 | 1426 | } |
| 1427 | - return implode( ',', $prepared ); |
|
| 1427 | + return implode(',', $prepared); |
|
| 1428 | 1428 | } |
| 1429 | 1429 | |
| 1430 | 1430 | /** |
@@ -1432,21 +1432,21 @@ discard block |
||
| 1432 | 1432 | * |
| 1433 | 1433 | * Provide a label and one of $form, $items or $invoice. |
| 1434 | 1434 | */ |
| 1435 | -function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) { |
|
| 1436 | - $label = sanitize_text_field( $label ); |
|
| 1435 | +function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) { |
|
| 1436 | + $label = sanitize_text_field($label); |
|
| 1437 | 1437 | |
| 1438 | - if ( ! empty( $form ) ) { |
|
| 1439 | - $form = esc_attr( $form ); |
|
| 1438 | + if (!empty($form)) { |
|
| 1439 | + $form = esc_attr($form); |
|
| 1440 | 1440 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
| 1441 | 1441 | } |
| 1442 | 1442 | |
| 1443 | - if ( ! empty( $items ) ) { |
|
| 1444 | - $items = esc_attr( $items ); |
|
| 1443 | + if (!empty($items)) { |
|
| 1444 | + $items = esc_attr($items); |
|
| 1445 | 1445 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
| 1446 | 1446 | } |
| 1447 | 1447 | |
| 1448 | - if ( ! empty( $invoice ) ) { |
|
| 1449 | - $invoice = esc_attr( $invoice ); |
|
| 1448 | + if (!empty($invoice)) { |
|
| 1449 | + $invoice = esc_attr($invoice); |
|
| 1450 | 1450 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>"; |
| 1451 | 1451 | } |
| 1452 | 1452 | |
@@ -1457,17 +1457,17 @@ discard block |
||
| 1457 | 1457 | * |
| 1458 | 1458 | * @param WPInv_Invoice $invoice |
| 1459 | 1459 | */ |
| 1460 | -function getpaid_the_invoice_description( $invoice ) { |
|
| 1460 | +function getpaid_the_invoice_description($invoice) { |
|
| 1461 | 1461 | $description = $invoice->get_description(); |
| 1462 | 1462 | |
| 1463 | - if ( empty( $description ) ) { |
|
| 1463 | + if (empty($description)) { |
|
| 1464 | 1464 | return; |
| 1465 | 1465 | } |
| 1466 | 1466 | |
| 1467 | - $description = wp_kses_post( $description ); |
|
| 1467 | + $description = wp_kses_post($description); |
|
| 1468 | 1468 | echo "<small class='getpaid-invoice-description text-dark p-2 form-text'><em>$description</em></small>"; |
| 1469 | 1469 | } |
| 1470 | -add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 ); |
|
| 1470 | +add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100); |
|
| 1471 | 1471 | |
| 1472 | 1472 | /** |
| 1473 | 1473 | * Render element on a form. |
@@ -1475,60 +1475,60 @@ discard block |
||
| 1475 | 1475 | * @param array $element |
| 1476 | 1476 | * @param GetPaid_Payment_Form $form |
| 1477 | 1477 | */ |
| 1478 | -function getpaid_payment_form_element( $element, $form ) { |
|
| 1478 | +function getpaid_payment_form_element($element, $form) { |
|
| 1479 | 1479 | |
| 1480 | 1480 | // Set up the args. |
| 1481 | - $element_type = trim( $element['type'] ); |
|
| 1481 | + $element_type = trim($element['type']); |
|
| 1482 | 1482 | $element['form'] = $form; |
| 1483 | - extract( $element ); |
|
| 1483 | + extract($element); |
|
| 1484 | 1484 | |
| 1485 | 1485 | // Try to locate the appropriate template. |
| 1486 | - $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" ); |
|
| 1486 | + $located = wpinv_locate_template("payment-forms/elements/$element_type.php"); |
|
| 1487 | 1487 | |
| 1488 | 1488 | // Abort if this is not our element. |
| 1489 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
| 1489 | + if (empty($located) || !file_exists($located)) { |
|
| 1490 | 1490 | return; |
| 1491 | 1491 | } |
| 1492 | 1492 | |
| 1493 | 1493 | // Generate the class and id of the element. |
| 1494 | - $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) ); |
|
| 1495 | - $id = isset( $id ) ? $id : uniqid( 'gp' ); |
|
| 1494 | + $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type)); |
|
| 1495 | + $id = isset($id) ? $id : uniqid('gp'); |
|
| 1496 | 1496 | |
| 1497 | 1497 | // Echo the opening wrapper. |
| 1498 | 1498 | echo "<div class='getpaid-payment-form-element $wrapper_class'>"; |
| 1499 | 1499 | |
| 1500 | 1500 | // Fires before displaying a given element type's content. |
| 1501 | - do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form ); |
|
| 1501 | + do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form); |
|
| 1502 | 1502 | |
| 1503 | 1503 | // Include the template for the element. |
| 1504 | 1504 | include $located; |
| 1505 | 1505 | |
| 1506 | 1506 | // Fires after displaying a given element type's content. |
| 1507 | - do_action( "getpaid_payment_form_{$element_type}_element", $element, $form ); |
|
| 1507 | + do_action("getpaid_payment_form_{$element_type}_element", $element, $form); |
|
| 1508 | 1508 | |
| 1509 | 1509 | // Echo the closing wrapper. |
| 1510 | 1510 | echo '</div>'; |
| 1511 | 1511 | } |
| 1512 | -add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 ); |
|
| 1512 | +add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2); |
|
| 1513 | 1513 | |
| 1514 | 1514 | /** |
| 1515 | 1515 | * Render an element's edit page. |
| 1516 | 1516 | * |
| 1517 | 1517 | * @param WP_Post $post |
| 1518 | 1518 | */ |
| 1519 | -function getpaid_payment_form_edit_element_template( $post ) { |
|
| 1519 | +function getpaid_payment_form_edit_element_template($post) { |
|
| 1520 | 1520 | |
| 1521 | 1521 | // Retrieve all elements. |
| 1522 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
| 1522 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
| 1523 | 1523 | |
| 1524 | - foreach ( $all_elements as $element ) { |
|
| 1524 | + foreach ($all_elements as $element) { |
|
| 1525 | 1525 | |
| 1526 | 1526 | // Try to locate the appropriate template. |
| 1527 | - $element = sanitize_key( $element ); |
|
| 1528 | - $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" ); |
|
| 1527 | + $element = sanitize_key($element); |
|
| 1528 | + $located = wpinv_locate_template("payment-forms-admin/edit/$element.php"); |
|
| 1529 | 1529 | |
| 1530 | 1530 | // Continue if this is not our element. |
| 1531 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
| 1531 | + if (empty($located) || !file_exists($located)) { |
|
| 1532 | 1532 | continue; |
| 1533 | 1533 | } |
| 1534 | 1534 | |
@@ -1539,7 +1539,7 @@ discard block |
||
| 1539 | 1539 | } |
| 1540 | 1540 | |
| 1541 | 1541 | } |
| 1542 | -add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' ); |
|
| 1542 | +add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template'); |
|
| 1543 | 1543 | |
| 1544 | 1544 | /** |
| 1545 | 1545 | * Render an element's preview. |
@@ -1548,16 +1548,16 @@ discard block |
||
| 1548 | 1548 | function getpaid_payment_form_render_element_preview_template() { |
| 1549 | 1549 | |
| 1550 | 1550 | // Retrieve all elements. |
| 1551 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
| 1551 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
| 1552 | 1552 | |
| 1553 | - foreach ( $all_elements as $element ) { |
|
| 1553 | + foreach ($all_elements as $element) { |
|
| 1554 | 1554 | |
| 1555 | 1555 | // Try to locate the appropriate template. |
| 1556 | - $element = sanitize_key( $element ); |
|
| 1557 | - $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" ); |
|
| 1556 | + $element = sanitize_key($element); |
|
| 1557 | + $located = wpinv_locate_template("payment-forms-admin/previews/$element.php"); |
|
| 1558 | 1558 | |
| 1559 | 1559 | // Continue if this is not our element. |
| 1560 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
| 1560 | + if (empty($located) || !file_exists($located)) { |
|
| 1561 | 1561 | continue; |
| 1562 | 1562 | } |
| 1563 | 1563 | |
@@ -1568,7 +1568,7 @@ discard block |
||
| 1568 | 1568 | } |
| 1569 | 1569 | |
| 1570 | 1570 | } |
| 1571 | -add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' ); |
|
| 1571 | +add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template'); |
|
| 1572 | 1572 | |
| 1573 | 1573 | /** |
| 1574 | 1574 | * Shows a list of gateways that support recurring payments. |
@@ -1576,17 +1576,17 @@ discard block |
||
| 1576 | 1576 | function wpinv_get_recurring_gateways_text() { |
| 1577 | 1577 | $gateways = array(); |
| 1578 | 1578 | |
| 1579 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
| 1580 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
| 1581 | - $gateways[] = sanitize_text_field( $gateway['admin_label'] ); |
|
| 1579 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
| 1580 | + if (wpinv_gateway_support_subscription($key)) { |
|
| 1581 | + $gateways[] = sanitize_text_field($gateway['admin_label']); |
|
| 1582 | 1582 | } |
| 1583 | 1583 | } |
| 1584 | 1584 | |
| 1585 | - if ( empty( $gateways ) ) { |
|
| 1586 | - return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) ."</span>"; |
|
| 1585 | + if (empty($gateways)) { |
|
| 1586 | + return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . "</span>"; |
|
| 1587 | 1587 | } |
| 1588 | 1588 | |
| 1589 | - return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>"; |
|
| 1589 | + return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>"; |
|
| 1590 | 1590 | |
| 1591 | 1591 | } |
| 1592 | 1592 | |
@@ -1596,7 +1596,7 @@ discard block |
||
| 1596 | 1596 | * @return GetPaid_Template |
| 1597 | 1597 | */ |
| 1598 | 1598 | function getpaid_template() { |
| 1599 | - return getpaid()->get( 'template' ); |
|
| 1599 | + return getpaid()->get('template'); |
|
| 1600 | 1600 | } |
| 1601 | 1601 | |
| 1602 | 1602 | /** |
@@ -1605,23 +1605,23 @@ discard block |
||
| 1605 | 1605 | * @param array args |
| 1606 | 1606 | * @return string |
| 1607 | 1607 | */ |
| 1608 | -function getpaid_paginate_links( $args ) { |
|
| 1608 | +function getpaid_paginate_links($args) { |
|
| 1609 | 1609 | |
| 1610 | 1610 | $args['type'] = 'array'; |
| 1611 | 1611 | $args['mid_size'] = 1; |
| 1612 | - $pages = paginate_links( $args ); |
|
| 1612 | + $pages = paginate_links($args); |
|
| 1613 | 1613 | |
| 1614 | - if ( ! is_array( $pages ) ) { |
|
| 1614 | + if (!is_array($pages)) { |
|
| 1615 | 1615 | return ''; |
| 1616 | 1616 | } |
| 1617 | 1617 | |
| 1618 | 1618 | $_pages = array(); |
| 1619 | - foreach ( $pages as $page ) { |
|
| 1620 | - $_pages[] = str_replace( 'page-numbers', 'page-link text-decoration-none', $page ); |
|
| 1619 | + foreach ($pages as $page) { |
|
| 1620 | + $_pages[] = str_replace('page-numbers', 'page-link text-decoration-none', $page); |
|
| 1621 | 1621 | } |
| 1622 | 1622 | |
| 1623 | 1623 | $links = "<nav>\n\t<ul class='pagination justify-content-end m-0'>\n\t\t<li class='page-item'>"; |
| 1624 | - $links .= join( "</li>\n\t\t<li class='page-item'>", $_pages ); |
|
| 1624 | + $links .= join("</li>\n\t\t<li class='page-item'>", $_pages); |
|
| 1625 | 1625 | $links .= "</li>\n\t</ul>\n</nav>\n"; |
| 1626 | 1626 | |
| 1627 | 1627 | return $links; |
@@ -1634,21 +1634,21 @@ discard block |
||
| 1634 | 1634 | * @param string state |
| 1635 | 1635 | * @return string |
| 1636 | 1636 | */ |
| 1637 | -function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false ) { |
|
| 1637 | +function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false) { |
|
| 1638 | 1638 | |
| 1639 | - $states = wpinv_get_country_states( $country ); |
|
| 1640 | - $uniqid = uniqid( '_' ); |
|
| 1639 | + $states = wpinv_get_country_states($country); |
|
| 1640 | + $uniqid = uniqid('_'); |
|
| 1641 | 1641 | |
| 1642 | - if ( ! empty( $states ) ) { |
|
| 1642 | + if (!empty($states)) { |
|
| 1643 | 1643 | |
| 1644 | - return aui()->select( array( |
|
| 1644 | + return aui()->select(array( |
|
| 1645 | 1645 | 'options' => $states, |
| 1646 | 1646 | 'name' => 'wpinv_state', |
| 1647 | 1647 | 'id' => 'wpinv_state' . $uniqid, |
| 1648 | - 'value' => sanitize_text_field( $state ), |
|
| 1648 | + 'value' => sanitize_text_field($state), |
|
| 1649 | 1649 | 'placeholder' => $placeholder, |
| 1650 | 1650 | 'required' => $required, |
| 1651 | - 'label' => wp_kses_post( $label ), |
|
| 1651 | + 'label' => wp_kses_post($label), |
|
| 1652 | 1652 | 'label_type' => 'vertical', |
| 1653 | 1653 | 'help_text' => $help_text, |
| 1654 | 1654 | 'class' => 'getpaid-address-field wpinv_state', |
@@ -1664,10 +1664,10 @@ discard block |
||
| 1664 | 1664 | 'id' => 'wpinv_state' . $uniqid, |
| 1665 | 1665 | 'placeholder' => $placeholder, |
| 1666 | 1666 | 'required' => $required, |
| 1667 | - 'label' => wp_kses_post( $label ), |
|
| 1667 | + 'label' => wp_kses_post($label), |
|
| 1668 | 1668 | 'label_type' => 'vertical', |
| 1669 | 1669 | 'help_text' => $help_text, |
| 1670 | - 'value' => sanitize_text_field( $state ), |
|
| 1670 | + 'value' => sanitize_text_field($state), |
|
| 1671 | 1671 | 'class' => 'getpaid-address-field wpinv_state', |
| 1672 | 1672 | 'wrap_class' => 'getpaid-address-field-wrapper getpaid-address-field-wrapper__state', |
| 1673 | 1673 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | * @package Invoicing/data |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | return array( |
| 12 | 12 | "AD" => "AD\d{3}", |
@@ -156,7 +156,7 @@ |
||
| 156 | 156 | $this->set_id( $invoice_id ); |
| 157 | 157 | } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
| 158 | 158 | $this->set_id( $invoice_id ); |
| 159 | - }else { |
|
| 159 | + } else { |
|
| 160 | 160 | $this->set_object_read( true ); |
| 161 | 161 | } |
| 162 | 162 | |
@@ -14,30 +14,30 @@ discard block |
||
| 14 | 14 | class WPInv_Invoice extends GetPaid_Data { |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * Which data store to load. |
|
| 18 | - * |
|
| 19 | - * @var string |
|
| 20 | - */ |
|
| 17 | + * Which data store to load. |
|
| 18 | + * |
|
| 19 | + * @var string |
|
| 20 | + */ |
|
| 21 | 21 | protected $data_store_name = 'invoice'; |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | - * This is the name of this object type. |
|
| 25 | - * |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 24 | + * This is the name of this object type. |
|
| 25 | + * |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | 28 | protected $object_type = 'invoice'; |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | - * Item Data array. This is the core item data exposed in APIs. |
|
| 32 | - * |
|
| 33 | - * @since 1.0.19 |
|
| 34 | - * @var array |
|
| 35 | - */ |
|
| 36 | - protected $data = array( |
|
| 37 | - 'parent_id' => 0, |
|
| 38 | - 'status' => 'wpi-pending', |
|
| 39 | - 'version' => '', |
|
| 40 | - 'date_created' => null, |
|
| 31 | + * Item Data array. This is the core item data exposed in APIs. |
|
| 32 | + * |
|
| 33 | + * @since 1.0.19 |
|
| 34 | + * @var array |
|
| 35 | + */ |
|
| 36 | + protected $data = array( |
|
| 37 | + 'parent_id' => 0, |
|
| 38 | + 'status' => 'wpi-pending', |
|
| 39 | + 'version' => '', |
|
| 40 | + 'date_created' => null, |
|
| 41 | 41 | 'date_modified' => null, |
| 42 | 42 | 'due_date' => null, |
| 43 | 43 | 'completed_date' => null, |
@@ -79,22 +79,22 @@ discard block |
||
| 79 | 79 | 'transaction_id' => '', |
| 80 | 80 | 'currency' => '', |
| 81 | 81 | 'disable_taxes' => false, |
| 82 | - 'subscription_id' => null, |
|
| 83 | - 'remote_subscription_id' => null, |
|
| 84 | - 'is_viewed' => false, |
|
| 85 | - 'email_cc' => '', |
|
| 86 | - 'template' => 'quantity', // hours, amount only |
|
| 87 | - 'created_via' => null, |
|
| 82 | + 'subscription_id' => null, |
|
| 83 | + 'remote_subscription_id' => null, |
|
| 84 | + 'is_viewed' => false, |
|
| 85 | + 'email_cc' => '', |
|
| 86 | + 'template' => 'quantity', // hours, amount only |
|
| 87 | + 'created_via' => null, |
|
| 88 | 88 | ); |
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | - * Stores meta in cache for future reads. |
|
| 92 | - * |
|
| 93 | - * A group must be set to to enable caching. |
|
| 94 | - * |
|
| 95 | - * @var string |
|
| 96 | - */ |
|
| 97 | - protected $cache_group = 'getpaid_invoices'; |
|
| 91 | + * Stores meta in cache for future reads. |
|
| 92 | + * |
|
| 93 | + * A group must be set to to enable caching. |
|
| 94 | + * |
|
| 95 | + * @var string |
|
| 96 | + */ |
|
| 97 | + protected $cache_group = 'getpaid_invoices'; |
|
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * Stores a reference to the original WP_Post object |
@@ -108,104 +108,104 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @var int |
| 110 | 110 | */ |
| 111 | - protected $recurring_item = null; |
|
| 111 | + protected $recurring_item = null; |
|
| 112 | 112 | |
| 113 | - /** |
|
| 113 | + /** |
|
| 114 | 114 | * Stores an array of item totals. |
| 115 | - * |
|
| 116 | - * e.g $totals['discount'] = array( |
|
| 117 | - * 'initial' => 10, |
|
| 118 | - * 'recurring' => 10, |
|
| 119 | - * ) |
|
| 115 | + * |
|
| 116 | + * e.g $totals['discount'] = array( |
|
| 117 | + * 'initial' => 10, |
|
| 118 | + * 'recurring' => 10, |
|
| 119 | + * ) |
|
| 120 | 120 | * |
| 121 | 121 | * @var array |
| 122 | 122 | */ |
| 123 | - protected $totals = array(); |
|
| 123 | + protected $totals = array(); |
|
| 124 | 124 | |
| 125 | - /** |
|
| 126 | - * Stores the status transition information. |
|
| 127 | - * |
|
| 128 | - * @since 1.0.19 |
|
| 129 | - * @var bool |
|
| 130 | - */ |
|
| 131 | - protected $status_transition = false; |
|
| 125 | + /** |
|
| 126 | + * Stores the status transition information. |
|
| 127 | + * |
|
| 128 | + * @since 1.0.19 |
|
| 129 | + * @var bool |
|
| 130 | + */ |
|
| 131 | + protected $status_transition = false; |
|
| 132 | 132 | |
| 133 | 133 | /** |
| 134 | - * Get the invoice if ID is passed, otherwise the invoice is new and empty. |
|
| 135 | - * |
|
| 136 | - * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
|
| 137 | - */ |
|
| 134 | + * Get the invoice if ID is passed, otherwise the invoice is new and empty. |
|
| 135 | + * |
|
| 136 | + * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
|
| 137 | + */ |
|
| 138 | 138 | public function __construct( $invoice = false ) { |
| 139 | 139 | |
| 140 | 140 | parent::__construct( $invoice ); |
| 141 | 141 | |
| 142 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
| 143 | - $this->set_id( $invoice ); |
|
| 144 | - } elseif ( $invoice instanceof self ) { |
|
| 145 | - $this->set_id( $invoice->get_id() ); |
|
| 146 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
| 147 | - $this->set_id( $invoice->ID ); |
|
| 148 | - } elseif ( is_array( $invoice ) ) { |
|
| 149 | - $this->set_props( $invoice ); |
|
| 150 | - |
|
| 151 | - if ( isset( $invoice['ID'] ) ) { |
|
| 152 | - $this->set_id( $invoice['ID'] ); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 156 | - $this->set_id( $invoice_id ); |
|
| 157 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 158 | - $this->set_id( $invoice_id ); |
|
| 159 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 160 | - $this->set_id( $invoice_id ); |
|
| 161 | - }else { |
|
| 162 | - $this->set_object_read( true ); |
|
| 163 | - } |
|
| 142 | + if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
| 143 | + $this->set_id( $invoice ); |
|
| 144 | + } elseif ( $invoice instanceof self ) { |
|
| 145 | + $this->set_id( $invoice->get_id() ); |
|
| 146 | + } elseif ( ! empty( $invoice->ID ) ) { |
|
| 147 | + $this->set_id( $invoice->ID ); |
|
| 148 | + } elseif ( is_array( $invoice ) ) { |
|
| 149 | + $this->set_props( $invoice ); |
|
| 150 | + |
|
| 151 | + if ( isset( $invoice['ID'] ) ) { |
|
| 152 | + $this->set_id( $invoice['ID'] ); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 156 | + $this->set_id( $invoice_id ); |
|
| 157 | + } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 158 | + $this->set_id( $invoice_id ); |
|
| 159 | + } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 160 | + $this->set_id( $invoice_id ); |
|
| 161 | + }else { |
|
| 162 | + $this->set_object_read( true ); |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | 165 | // Load the datastore. |
| 166 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 166 | + $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 167 | 167 | |
| 168 | - if ( $this->get_id() > 0 ) { |
|
| 168 | + if ( $this->get_id() > 0 ) { |
|
| 169 | 169 | $this->post = get_post( $this->get_id() ); |
| 170 | 170 | $this->ID = $this->get_id(); |
| 171 | - $this->data_store->read( $this ); |
|
| 171 | + $this->data_store->read( $this ); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
| 177 | - * Given an invoice key/number, it returns its id. |
|
| 178 | - * |
|
| 179 | - * |
|
| 180 | - * @static |
|
| 181 | - * @param string $value The invoice key or number |
|
| 182 | - * @param string $field Either key, transaction_id or number. |
|
| 183 | - * @since 1.0.15 |
|
| 184 | - * @return int |
|
| 185 | - */ |
|
| 186 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 177 | + * Given an invoice key/number, it returns its id. |
|
| 178 | + * |
|
| 179 | + * |
|
| 180 | + * @static |
|
| 181 | + * @param string $value The invoice key or number |
|
| 182 | + * @param string $field Either key, transaction_id or number. |
|
| 183 | + * @since 1.0.15 |
|
| 184 | + * @return int |
|
| 185 | + */ |
|
| 186 | + public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 187 | 187 | global $wpdb; |
| 188 | 188 | |
| 189 | - // Trim the value. |
|
| 190 | - $value = trim( $value ); |
|
| 189 | + // Trim the value. |
|
| 190 | + $value = trim( $value ); |
|
| 191 | 191 | |
| 192 | - if ( empty( $value ) ) { |
|
| 193 | - return 0; |
|
| 194 | - } |
|
| 192 | + if ( empty( $value ) ) { |
|
| 193 | + return 0; |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | 196 | // Valid fields. |
| 197 | 197 | $fields = array( 'key', 'number', 'transaction_id' ); |
| 198 | 198 | |
| 199 | - // Ensure a field has been passed. |
|
| 200 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 201 | - return 0; |
|
| 202 | - } |
|
| 199 | + // Ensure a field has been passed. |
|
| 200 | + if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 201 | + return 0; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - // Maybe retrieve from the cache. |
|
| 205 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 206 | - if ( false !== $invoice_id ) { |
|
| 207 | - return $invoice_id; |
|
| 208 | - } |
|
| 204 | + // Maybe retrieve from the cache. |
|
| 205 | + $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 206 | + if ( false !== $invoice_id ) { |
|
| 207 | + return $invoice_id; |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | 210 | // Fetch from the db. |
| 211 | 211 | $table = $wpdb->prefix . 'getpaid_invoices'; |
@@ -213,10 +213,10 @@ discard block |
||
| 213 | 213 | $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
| 214 | 214 | ); |
| 215 | 215 | |
| 216 | - // Update the cache with our data |
|
| 217 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 216 | + // Update the cache with our data |
|
| 217 | + wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 218 | 218 | |
| 219 | - return $invoice_id; |
|
| 219 | + return $invoice_id; |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /** |
@@ -242,72 +242,72 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | |
| 244 | 244 | /** |
| 245 | - * Get parent invoice ID. |
|
| 246 | - * |
|
| 247 | - * @since 1.0.19 |
|
| 248 | - * @param string $context View or edit context. |
|
| 249 | - * @return int |
|
| 250 | - */ |
|
| 251 | - public function get_parent_id( $context = 'view' ) { |
|
| 252 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
| 245 | + * Get parent invoice ID. |
|
| 246 | + * |
|
| 247 | + * @since 1.0.19 |
|
| 248 | + * @param string $context View or edit context. |
|
| 249 | + * @return int |
|
| 250 | + */ |
|
| 251 | + public function get_parent_id( $context = 'view' ) { |
|
| 252 | + return (int) $this->get_prop( 'parent_id', $context ); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
| 256 | - * Get parent invoice. |
|
| 257 | - * |
|
| 258 | - * @since 1.0.19 |
|
| 259 | - * @return WPInv_Invoice |
|
| 260 | - */ |
|
| 256 | + * Get parent invoice. |
|
| 257 | + * |
|
| 258 | + * @since 1.0.19 |
|
| 259 | + * @return WPInv_Invoice |
|
| 260 | + */ |
|
| 261 | 261 | public function get_parent_payment() { |
| 262 | 262 | return new WPInv_Invoice( $this->get_parent_id() ); |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
| 266 | - * Alias for self::get_parent_payment(). |
|
| 267 | - * |
|
| 268 | - * @since 1.0.19 |
|
| 269 | - * @return WPInv_Invoice |
|
| 270 | - */ |
|
| 266 | + * Alias for self::get_parent_payment(). |
|
| 267 | + * |
|
| 268 | + * @since 1.0.19 |
|
| 269 | + * @return WPInv_Invoice |
|
| 270 | + */ |
|
| 271 | 271 | public function get_parent() { |
| 272 | 272 | return $this->get_parent_payment(); |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
| 276 | - * Get invoice status. |
|
| 277 | - * |
|
| 278 | - * @since 1.0.19 |
|
| 279 | - * @param string $context View or edit context. |
|
| 280 | - * @return string |
|
| 281 | - */ |
|
| 282 | - public function get_status( $context = 'view' ) { |
|
| 283 | - return $this->get_prop( 'status', $context ); |
|
| 284 | - } |
|
| 276 | + * Get invoice status. |
|
| 277 | + * |
|
| 278 | + * @since 1.0.19 |
|
| 279 | + * @param string $context View or edit context. |
|
| 280 | + * @return string |
|
| 281 | + */ |
|
| 282 | + public function get_status( $context = 'view' ) { |
|
| 283 | + return $this->get_prop( 'status', $context ); |
|
| 284 | + } |
|
| 285 | 285 | |
| 286 | - /** |
|
| 287 | - * Retrieves an array of possible invoice statuses. |
|
| 288 | - * |
|
| 289 | - * @since 1.0.19 |
|
| 290 | - * @return array |
|
| 291 | - */ |
|
| 292 | - public function get_all_statuses() { |
|
| 293 | - return wpinv_get_invoice_statuses( true, true, $this ); |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - /** |
|
| 297 | - * Get invoice status nice name. |
|
| 298 | - * |
|
| 299 | - * @since 1.0.19 |
|
| 300 | - * @return string |
|
| 301 | - */ |
|
| 286 | + /** |
|
| 287 | + * Retrieves an array of possible invoice statuses. |
|
| 288 | + * |
|
| 289 | + * @since 1.0.19 |
|
| 290 | + * @return array |
|
| 291 | + */ |
|
| 292 | + public function get_all_statuses() { |
|
| 293 | + return wpinv_get_invoice_statuses( true, true, $this ); |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + /** |
|
| 297 | + * Get invoice status nice name. |
|
| 298 | + * |
|
| 299 | + * @since 1.0.19 |
|
| 300 | + * @return string |
|
| 301 | + */ |
|
| 302 | 302 | public function get_status_nicename() { |
| 303 | - $statuses = $this->get_all_statuses(); |
|
| 303 | + $statuses = $this->get_all_statuses(); |
|
| 304 | 304 | |
| 305 | 305 | $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
| 306 | 306 | |
| 307 | 307 | return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - /** |
|
| 310 | + /** |
|
| 311 | 311 | * Retrieves the invoice status label html |
| 312 | 312 | * |
| 313 | 313 | * @since 1.0.0 |
@@ -315,262 +315,262 @@ discard block |
||
| 315 | 315 | */ |
| 316 | 316 | public function get_status_label_html() { |
| 317 | 317 | |
| 318 | - $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
| 319 | - $status = sanitize_html_class( $this->get_status() ); |
|
| 318 | + $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
| 319 | + $status = sanitize_html_class( $this->get_status() ); |
|
| 320 | 320 | |
| 321 | - return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>"; |
|
| 322 | - } |
|
| 321 | + return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>"; |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | 324 | /** |
| 325 | - * Get plugin version when the invoice was created. |
|
| 326 | - * |
|
| 327 | - * @since 1.0.19 |
|
| 328 | - * @param string $context View or edit context. |
|
| 329 | - * @return string |
|
| 330 | - */ |
|
| 331 | - public function get_version( $context = 'view' ) { |
|
| 332 | - return $this->get_prop( 'version', $context ); |
|
| 333 | - } |
|
| 325 | + * Get plugin version when the invoice was created. |
|
| 326 | + * |
|
| 327 | + * @since 1.0.19 |
|
| 328 | + * @param string $context View or edit context. |
|
| 329 | + * @return string |
|
| 330 | + */ |
|
| 331 | + public function get_version( $context = 'view' ) { |
|
| 332 | + return $this->get_prop( 'version', $context ); |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | - /** |
|
| 336 | - * @deprecated |
|
| 337 | - */ |
|
| 338 | - public function get_invoice_date( $format = true ) { |
|
| 339 | - $date = getpaid_format_date( $this->get_date_completed() ); |
|
| 340 | - $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
| 341 | - $formatted = getpaid_format_date( $date ); |
|
| 335 | + /** |
|
| 336 | + * @deprecated |
|
| 337 | + */ |
|
| 338 | + public function get_invoice_date( $format = true ) { |
|
| 339 | + $date = getpaid_format_date( $this->get_date_completed() ); |
|
| 340 | + $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
| 341 | + $formatted = getpaid_format_date( $date ); |
|
| 342 | 342 | |
| 343 | - if ( $format ) { |
|
| 344 | - return $formatted; |
|
| 345 | - } |
|
| 343 | + if ( $format ) { |
|
| 344 | + return $formatted; |
|
| 345 | + } |
|
| 346 | 346 | |
| 347 | - return empty( $formatted ) ? '' : $date; |
|
| 347 | + return empty( $formatted ) ? '' : $date; |
|
| 348 | 348 | |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | /** |
| 352 | - * Get date when the invoice was created. |
|
| 353 | - * |
|
| 354 | - * @since 1.0.19 |
|
| 355 | - * @param string $context View or edit context. |
|
| 356 | - * @return string |
|
| 357 | - */ |
|
| 358 | - public function get_date_created( $context = 'view' ) { |
|
| 359 | - return $this->get_prop( 'date_created', $context ); |
|
| 360 | - } |
|
| 352 | + * Get date when the invoice was created. |
|
| 353 | + * |
|
| 354 | + * @since 1.0.19 |
|
| 355 | + * @param string $context View or edit context. |
|
| 356 | + * @return string |
|
| 357 | + */ |
|
| 358 | + public function get_date_created( $context = 'view' ) { |
|
| 359 | + return $this->get_prop( 'date_created', $context ); |
|
| 360 | + } |
|
| 361 | 361 | |
| 362 | - /** |
|
| 363 | - * Alias for self::get_date_created(). |
|
| 364 | - * |
|
| 365 | - * @since 1.0.19 |
|
| 366 | - * @param string $context View or edit context. |
|
| 367 | - * @return string |
|
| 368 | - */ |
|
| 369 | - public function get_created_date( $context = 'view' ) { |
|
| 370 | - return $this->get_date_created( $context ); |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - /** |
|
| 374 | - * Get GMT date when the invoice was created. |
|
| 375 | - * |
|
| 376 | - * @since 1.0.19 |
|
| 377 | - * @param string $context View or edit context. |
|
| 378 | - * @return string |
|
| 379 | - */ |
|
| 380 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 362 | + /** |
|
| 363 | + * Alias for self::get_date_created(). |
|
| 364 | + * |
|
| 365 | + * @since 1.0.19 |
|
| 366 | + * @param string $context View or edit context. |
|
| 367 | + * @return string |
|
| 368 | + */ |
|
| 369 | + public function get_created_date( $context = 'view' ) { |
|
| 370 | + return $this->get_date_created( $context ); |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + /** |
|
| 374 | + * Get GMT date when the invoice was created. |
|
| 375 | + * |
|
| 376 | + * @since 1.0.19 |
|
| 377 | + * @param string $context View or edit context. |
|
| 378 | + * @return string |
|
| 379 | + */ |
|
| 380 | + public function get_date_created_gmt( $context = 'view' ) { |
|
| 381 | 381 | $date = $this->get_date_created( $context ); |
| 382 | 382 | |
| 383 | 383 | if ( $date ) { |
| 384 | 384 | $date = get_gmt_from_date( $date ); |
| 385 | 385 | } |
| 386 | - return $date; |
|
| 386 | + return $date; |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /** |
| 390 | - * Get date when the invoice was last modified. |
|
| 391 | - * |
|
| 392 | - * @since 1.0.19 |
|
| 393 | - * @param string $context View or edit context. |
|
| 394 | - * @return string |
|
| 395 | - */ |
|
| 396 | - public function get_date_modified( $context = 'view' ) { |
|
| 397 | - return $this->get_prop( 'date_modified', $context ); |
|
| 398 | - } |
|
| 390 | + * Get date when the invoice was last modified. |
|
| 391 | + * |
|
| 392 | + * @since 1.0.19 |
|
| 393 | + * @param string $context View or edit context. |
|
| 394 | + * @return string |
|
| 395 | + */ |
|
| 396 | + public function get_date_modified( $context = 'view' ) { |
|
| 397 | + return $this->get_prop( 'date_modified', $context ); |
|
| 398 | + } |
|
| 399 | 399 | |
| 400 | - /** |
|
| 401 | - * Alias for self::get_date_modified(). |
|
| 402 | - * |
|
| 403 | - * @since 1.0.19 |
|
| 404 | - * @param string $context View or edit context. |
|
| 405 | - * @return string |
|
| 406 | - */ |
|
| 407 | - public function get_modified_date( $context = 'view' ) { |
|
| 408 | - return $this->get_date_modified( $context ); |
|
| 400 | + /** |
|
| 401 | + * Alias for self::get_date_modified(). |
|
| 402 | + * |
|
| 403 | + * @since 1.0.19 |
|
| 404 | + * @param string $context View or edit context. |
|
| 405 | + * @return string |
|
| 406 | + */ |
|
| 407 | + public function get_modified_date( $context = 'view' ) { |
|
| 408 | + return $this->get_date_modified( $context ); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | /** |
| 412 | - * Get GMT date when the invoice was last modified. |
|
| 413 | - * |
|
| 414 | - * @since 1.0.19 |
|
| 415 | - * @param string $context View or edit context. |
|
| 416 | - * @return string |
|
| 417 | - */ |
|
| 418 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
| 412 | + * Get GMT date when the invoice was last modified. |
|
| 413 | + * |
|
| 414 | + * @since 1.0.19 |
|
| 415 | + * @param string $context View or edit context. |
|
| 416 | + * @return string |
|
| 417 | + */ |
|
| 418 | + public function get_date_modified_gmt( $context = 'view' ) { |
|
| 419 | 419 | $date = $this->get_date_modified( $context ); |
| 420 | 420 | |
| 421 | 421 | if ( $date ) { |
| 422 | 422 | $date = get_gmt_from_date( $date ); |
| 423 | 423 | } |
| 424 | - return $date; |
|
| 424 | + return $date; |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | /** |
| 428 | - * Get the invoice due date. |
|
| 429 | - * |
|
| 430 | - * @since 1.0.19 |
|
| 431 | - * @param string $context View or edit context. |
|
| 432 | - * @return string |
|
| 433 | - */ |
|
| 434 | - public function get_due_date( $context = 'view' ) { |
|
| 435 | - return $this->get_prop( 'due_date', $context ); |
|
| 428 | + * Get the invoice due date. |
|
| 429 | + * |
|
| 430 | + * @since 1.0.19 |
|
| 431 | + * @param string $context View or edit context. |
|
| 432 | + * @return string |
|
| 433 | + */ |
|
| 434 | + public function get_due_date( $context = 'view' ) { |
|
| 435 | + return $this->get_prop( 'due_date', $context ); |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | /** |
| 439 | - * Alias for self::get_due_date(). |
|
| 440 | - * |
|
| 441 | - * @since 1.0.19 |
|
| 442 | - * @param string $context View or edit context. |
|
| 443 | - * @return string |
|
| 444 | - */ |
|
| 445 | - public function get_date_due( $context = 'view' ) { |
|
| 446 | - return $this->get_due_date( $context ); |
|
| 439 | + * Alias for self::get_due_date(). |
|
| 440 | + * |
|
| 441 | + * @since 1.0.19 |
|
| 442 | + * @param string $context View or edit context. |
|
| 443 | + * @return string |
|
| 444 | + */ |
|
| 445 | + public function get_date_due( $context = 'view' ) { |
|
| 446 | + return $this->get_due_date( $context ); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | /** |
| 450 | - * Get the invoice GMT due date. |
|
| 451 | - * |
|
| 452 | - * @since 1.0.19 |
|
| 453 | - * @param string $context View or edit context. |
|
| 454 | - * @return string |
|
| 455 | - */ |
|
| 456 | - public function get_due_date_gmt( $context = 'view' ) { |
|
| 450 | + * Get the invoice GMT due date. |
|
| 451 | + * |
|
| 452 | + * @since 1.0.19 |
|
| 453 | + * @param string $context View or edit context. |
|
| 454 | + * @return string |
|
| 455 | + */ |
|
| 456 | + public function get_due_date_gmt( $context = 'view' ) { |
|
| 457 | 457 | $date = $this->get_due_date( $context ); |
| 458 | 458 | |
| 459 | 459 | if ( $date ) { |
| 460 | 460 | $date = get_gmt_from_date( $date ); |
| 461 | 461 | } |
| 462 | - return $date; |
|
| 462 | + return $date; |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | /** |
| 466 | - * Alias for self::get_due_date_gmt(). |
|
| 467 | - * |
|
| 468 | - * @since 1.0.19 |
|
| 469 | - * @param string $context View or edit context. |
|
| 470 | - * @return string |
|
| 471 | - */ |
|
| 472 | - public function get_gmt_date_due( $context = 'view' ) { |
|
| 473 | - return $this->get_due_date_gmt( $context ); |
|
| 466 | + * Alias for self::get_due_date_gmt(). |
|
| 467 | + * |
|
| 468 | + * @since 1.0.19 |
|
| 469 | + * @param string $context View or edit context. |
|
| 470 | + * @return string |
|
| 471 | + */ |
|
| 472 | + public function get_gmt_date_due( $context = 'view' ) { |
|
| 473 | + return $this->get_due_date_gmt( $context ); |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | /** |
| 477 | - * Get date when the invoice was completed. |
|
| 478 | - * |
|
| 479 | - * @since 1.0.19 |
|
| 480 | - * @param string $context View or edit context. |
|
| 481 | - * @return string |
|
| 482 | - */ |
|
| 483 | - public function get_completed_date( $context = 'view' ) { |
|
| 484 | - return $this->get_prop( 'completed_date', $context ); |
|
| 477 | + * Get date when the invoice was completed. |
|
| 478 | + * |
|
| 479 | + * @since 1.0.19 |
|
| 480 | + * @param string $context View or edit context. |
|
| 481 | + * @return string |
|
| 482 | + */ |
|
| 483 | + public function get_completed_date( $context = 'view' ) { |
|
| 484 | + return $this->get_prop( 'completed_date', $context ); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
| 488 | - * Alias for self::get_completed_date(). |
|
| 489 | - * |
|
| 490 | - * @since 1.0.19 |
|
| 491 | - * @param string $context View or edit context. |
|
| 492 | - * @return string |
|
| 493 | - */ |
|
| 494 | - public function get_date_completed( $context = 'view' ) { |
|
| 495 | - return $this->get_completed_date( $context ); |
|
| 488 | + * Alias for self::get_completed_date(). |
|
| 489 | + * |
|
| 490 | + * @since 1.0.19 |
|
| 491 | + * @param string $context View or edit context. |
|
| 492 | + * @return string |
|
| 493 | + */ |
|
| 494 | + public function get_date_completed( $context = 'view' ) { |
|
| 495 | + return $this->get_completed_date( $context ); |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | /** |
| 499 | - * Get GMT date when the invoice was was completed. |
|
| 500 | - * |
|
| 501 | - * @since 1.0.19 |
|
| 502 | - * @param string $context View or edit context. |
|
| 503 | - * @return string |
|
| 504 | - */ |
|
| 505 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
| 499 | + * Get GMT date when the invoice was was completed. |
|
| 500 | + * |
|
| 501 | + * @since 1.0.19 |
|
| 502 | + * @param string $context View or edit context. |
|
| 503 | + * @return string |
|
| 504 | + */ |
|
| 505 | + public function get_completed_date_gmt( $context = 'view' ) { |
|
| 506 | 506 | $date = $this->get_completed_date( $context ); |
| 507 | 507 | |
| 508 | 508 | if ( $date ) { |
| 509 | 509 | $date = get_gmt_from_date( $date ); |
| 510 | 510 | } |
| 511 | - return $date; |
|
| 511 | + return $date; |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | /** |
| 515 | - * Alias for self::get_completed_date_gmt(). |
|
| 516 | - * |
|
| 517 | - * @since 1.0.19 |
|
| 518 | - * @param string $context View or edit context. |
|
| 519 | - * @return string |
|
| 520 | - */ |
|
| 521 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
| 522 | - return $this->get_completed_date_gmt( $context ); |
|
| 515 | + * Alias for self::get_completed_date_gmt(). |
|
| 516 | + * |
|
| 517 | + * @since 1.0.19 |
|
| 518 | + * @param string $context View or edit context. |
|
| 519 | + * @return string |
|
| 520 | + */ |
|
| 521 | + public function get_gmt_completed_date( $context = 'view' ) { |
|
| 522 | + return $this->get_completed_date_gmt( $context ); |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | /** |
| 526 | - * Get the invoice number. |
|
| 527 | - * |
|
| 528 | - * @since 1.0.19 |
|
| 529 | - * @param string $context View or edit context. |
|
| 530 | - * @return string |
|
| 531 | - */ |
|
| 532 | - public function get_number( $context = 'view' ) { |
|
| 533 | - $number = $this->get_prop( 'number', $context ); |
|
| 526 | + * Get the invoice number. |
|
| 527 | + * |
|
| 528 | + * @since 1.0.19 |
|
| 529 | + * @param string $context View or edit context. |
|
| 530 | + * @return string |
|
| 531 | + */ |
|
| 532 | + public function get_number( $context = 'view' ) { |
|
| 533 | + $number = $this->get_prop( 'number', $context ); |
|
| 534 | 534 | |
| 535 | - if ( empty( $number ) ) { |
|
| 536 | - $number = $this->generate_number(); |
|
| 537 | - $this->set_number( $this->generate_number() ); |
|
| 538 | - } |
|
| 535 | + if ( empty( $number ) ) { |
|
| 536 | + $number = $this->generate_number(); |
|
| 537 | + $this->set_number( $this->generate_number() ); |
|
| 538 | + } |
|
| 539 | 539 | |
| 540 | - return $number; |
|
| 540 | + return $number; |
|
| 541 | 541 | } |
| 542 | 542 | |
| 543 | - /** |
|
| 544 | - * Set the invoice number. |
|
| 545 | - * |
|
| 546 | - * @since 1.0.19 |
|
| 547 | - */ |
|
| 548 | - public function maybe_set_number() { |
|
| 543 | + /** |
|
| 544 | + * Set the invoice number. |
|
| 545 | + * |
|
| 546 | + * @since 1.0.19 |
|
| 547 | + */ |
|
| 548 | + public function maybe_set_number() { |
|
| 549 | 549 | $number = $this->get_number(); |
| 550 | 550 | |
| 551 | 551 | if ( empty( $number ) || $this->get_id() == $number ) { |
| 552 | - $this->set_number( $this->generate_number() ); |
|
| 552 | + $this->set_number( $this->generate_number() ); |
|
| 553 | 553 | } |
| 554 | 554 | |
| 555 | - } |
|
| 555 | + } |
|
| 556 | 556 | |
| 557 | 557 | /** |
| 558 | - * Get the invoice key. |
|
| 559 | - * |
|
| 560 | - * @since 1.0.19 |
|
| 561 | - * @param string $context View or edit context. |
|
| 562 | - * @return string |
|
| 563 | - */ |
|
| 564 | - public function get_key( $context = 'view' ) { |
|
| 558 | + * Get the invoice key. |
|
| 559 | + * |
|
| 560 | + * @since 1.0.19 |
|
| 561 | + * @param string $context View or edit context. |
|
| 562 | + * @return string |
|
| 563 | + */ |
|
| 564 | + public function get_key( $context = 'view' ) { |
|
| 565 | 565 | return $this->get_prop( 'key', $context ); |
| 566 | - } |
|
| 567 | - |
|
| 568 | - /** |
|
| 569 | - * Set the invoice key. |
|
| 570 | - * |
|
| 571 | - * @since 1.0.19 |
|
| 572 | - */ |
|
| 573 | - public function maybe_set_key() { |
|
| 566 | + } |
|
| 567 | + |
|
| 568 | + /** |
|
| 569 | + * Set the invoice key. |
|
| 570 | + * |
|
| 571 | + * @since 1.0.19 |
|
| 572 | + */ |
|
| 573 | + public function maybe_set_key() { |
|
| 574 | 574 | $key = $this->get_key(); |
| 575 | 575 | |
| 576 | 576 | if ( empty( $key ) ) { |
@@ -581,126 +581,126 @@ discard block |
||
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | /** |
| 584 | - * Get the invoice type. |
|
| 585 | - * |
|
| 586 | - * @since 1.0.19 |
|
| 587 | - * @param string $context View or edit context. |
|
| 588 | - * @return string |
|
| 589 | - */ |
|
| 590 | - public function get_type( $context = 'view' ) { |
|
| 584 | + * Get the invoice type. |
|
| 585 | + * |
|
| 586 | + * @since 1.0.19 |
|
| 587 | + * @param string $context View or edit context. |
|
| 588 | + * @return string |
|
| 589 | + */ |
|
| 590 | + public function get_type( $context = 'view' ) { |
|
| 591 | 591 | return $this->get_prop( 'type', $context ); |
| 592 | - } |
|
| 592 | + } |
|
| 593 | 593 | |
| 594 | - /** |
|
| 595 | - * @deprecated |
|
| 596 | - */ |
|
| 597 | - public function get_invoice_quote_type() { |
|
| 594 | + /** |
|
| 595 | + * @deprecated |
|
| 596 | + */ |
|
| 597 | + public function get_invoice_quote_type() { |
|
| 598 | 598 | ucfirst( $this->get_type() ); |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | /** |
| 602 | - * Get the invoice post type. |
|
| 603 | - * |
|
| 604 | - * @since 1.0.19 |
|
| 605 | - * @param string $context View or edit context. |
|
| 606 | - * @return string |
|
| 607 | - */ |
|
| 608 | - public function get_post_type( $context = 'view' ) { |
|
| 602 | + * Get the invoice post type. |
|
| 603 | + * |
|
| 604 | + * @since 1.0.19 |
|
| 605 | + * @param string $context View or edit context. |
|
| 606 | + * @return string |
|
| 607 | + */ |
|
| 608 | + public function get_post_type( $context = 'view' ) { |
|
| 609 | 609 | return $this->get_prop( 'post_type', $context ); |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | /** |
| 613 | - * Get the invoice mode. |
|
| 614 | - * |
|
| 615 | - * @since 1.0.19 |
|
| 616 | - * @param string $context View or edit context. |
|
| 617 | - * @return string |
|
| 618 | - */ |
|
| 619 | - public function get_mode( $context = 'view' ) { |
|
| 613 | + * Get the invoice mode. |
|
| 614 | + * |
|
| 615 | + * @since 1.0.19 |
|
| 616 | + * @param string $context View or edit context. |
|
| 617 | + * @return string |
|
| 618 | + */ |
|
| 619 | + public function get_mode( $context = 'view' ) { |
|
| 620 | 620 | return $this->get_prop( 'mode', $context ); |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | /** |
| 624 | - * Get the invoice path. |
|
| 625 | - * |
|
| 626 | - * @since 1.0.19 |
|
| 627 | - * @param string $context View or edit context. |
|
| 628 | - * @return string |
|
| 629 | - */ |
|
| 630 | - public function get_path( $context = 'view' ) { |
|
| 624 | + * Get the invoice path. |
|
| 625 | + * |
|
| 626 | + * @since 1.0.19 |
|
| 627 | + * @param string $context View or edit context. |
|
| 628 | + * @return string |
|
| 629 | + */ |
|
| 630 | + public function get_path( $context = 'view' ) { |
|
| 631 | 631 | $path = $this->get_prop( 'path', $context ); |
| 632 | - $prefix = $this->get_type(); |
|
| 632 | + $prefix = $this->get_type(); |
|
| 633 | 633 | |
| 634 | - if ( 0 !== strpos( $path, $prefix ) ) { |
|
| 635 | - $path = sanitize_title( $prefix . '-' . $this->get_id() ); |
|
| 636 | - $this->set_path( $path ); |
|
| 637 | - } |
|
| 634 | + if ( 0 !== strpos( $path, $prefix ) ) { |
|
| 635 | + $path = sanitize_title( $prefix . '-' . $this->get_id() ); |
|
| 636 | + $this->set_path( $path ); |
|
| 637 | + } |
|
| 638 | 638 | |
| 639 | - return $path; |
|
| 639 | + return $path; |
|
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | /** |
| 643 | - * Get the invoice name/title. |
|
| 644 | - * |
|
| 645 | - * @since 1.0.19 |
|
| 646 | - * @param string $context View or edit context. |
|
| 647 | - * @return string |
|
| 648 | - */ |
|
| 649 | - public function get_name( $context = 'view' ) { |
|
| 643 | + * Get the invoice name/title. |
|
| 644 | + * |
|
| 645 | + * @since 1.0.19 |
|
| 646 | + * @param string $context View or edit context. |
|
| 647 | + * @return string |
|
| 648 | + */ |
|
| 649 | + public function get_name( $context = 'view' ) { |
|
| 650 | 650 | return $this->get_prop( 'title', $context ); |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | /** |
| 654 | - * Alias of self::get_name(). |
|
| 655 | - * |
|
| 656 | - * @since 1.0.19 |
|
| 657 | - * @param string $context View or edit context. |
|
| 658 | - * @return string |
|
| 659 | - */ |
|
| 660 | - public function get_title( $context = 'view' ) { |
|
| 661 | - return $this->get_name( $context ); |
|
| 654 | + * Alias of self::get_name(). |
|
| 655 | + * |
|
| 656 | + * @since 1.0.19 |
|
| 657 | + * @param string $context View or edit context. |
|
| 658 | + * @return string |
|
| 659 | + */ |
|
| 660 | + public function get_title( $context = 'view' ) { |
|
| 661 | + return $this->get_name( $context ); |
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | /** |
| 665 | - * Get the invoice description. |
|
| 666 | - * |
|
| 667 | - * @since 1.0.19 |
|
| 668 | - * @param string $context View or edit context. |
|
| 669 | - * @return string |
|
| 670 | - */ |
|
| 671 | - public function get_description( $context = 'view' ) { |
|
| 672 | - return $this->get_prop( 'description', $context ); |
|
| 665 | + * Get the invoice description. |
|
| 666 | + * |
|
| 667 | + * @since 1.0.19 |
|
| 668 | + * @param string $context View or edit context. |
|
| 669 | + * @return string |
|
| 670 | + */ |
|
| 671 | + public function get_description( $context = 'view' ) { |
|
| 672 | + return $this->get_prop( 'description', $context ); |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | /** |
| 676 | - * Alias of self::get_description(). |
|
| 677 | - * |
|
| 678 | - * @since 1.0.19 |
|
| 679 | - * @param string $context View or edit context. |
|
| 680 | - * @return string |
|
| 681 | - */ |
|
| 682 | - public function get_excerpt( $context = 'view' ) { |
|
| 683 | - return $this->get_description( $context ); |
|
| 676 | + * Alias of self::get_description(). |
|
| 677 | + * |
|
| 678 | + * @since 1.0.19 |
|
| 679 | + * @param string $context View or edit context. |
|
| 680 | + * @return string |
|
| 681 | + */ |
|
| 682 | + public function get_excerpt( $context = 'view' ) { |
|
| 683 | + return $this->get_description( $context ); |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | /** |
| 687 | - * Alias of self::get_description(). |
|
| 688 | - * |
|
| 689 | - * @since 1.0.19 |
|
| 690 | - * @param string $context View or edit context. |
|
| 691 | - * @return string |
|
| 692 | - */ |
|
| 693 | - public function get_summary( $context = 'view' ) { |
|
| 694 | - return $this->get_description( $context ); |
|
| 687 | + * Alias of self::get_description(). |
|
| 688 | + * |
|
| 689 | + * @since 1.0.19 |
|
| 690 | + * @param string $context View or edit context. |
|
| 691 | + * @return string |
|
| 692 | + */ |
|
| 693 | + public function get_summary( $context = 'view' ) { |
|
| 694 | + return $this->get_description( $context ); |
|
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | /** |
| 698 | - * Returns the user info. |
|
| 699 | - * |
|
| 700 | - * @since 1.0.19 |
|
| 698 | + * Returns the user info. |
|
| 699 | + * |
|
| 700 | + * @since 1.0.19 |
|
| 701 | 701 | * @param string $context View or edit context. |
| 702 | - * @return array |
|
| 703 | - */ |
|
| 702 | + * @return array |
|
| 703 | + */ |
|
| 704 | 704 | public function get_user_info( $context = 'view' ) { |
| 705 | 705 | |
| 706 | 706 | $user_info = array( |
@@ -717,616 +717,616 @@ discard block |
||
| 717 | 717 | 'company' => $this->get_company( $context ), |
| 718 | 718 | 'vat_number' => $this->get_vat_number( $context ), |
| 719 | 719 | 'discount' => $this->get_discount_code( $context ), |
| 720 | - ); |
|
| 720 | + ); |
|
| 721 | + |
|
| 722 | + return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 723 | + |
|
| 724 | + } |
|
| 725 | + |
|
| 726 | + /** |
|
| 727 | + * Get the customer id. |
|
| 728 | + * |
|
| 729 | + * @since 1.0.19 |
|
| 730 | + * @param string $context View or edit context. |
|
| 731 | + * @return int |
|
| 732 | + */ |
|
| 733 | + public function get_author( $context = 'view' ) { |
|
| 734 | + return (int) $this->get_prop( 'author', $context ); |
|
| 735 | + } |
|
| 736 | + |
|
| 737 | + /** |
|
| 738 | + * Alias of self::get_author(). |
|
| 739 | + * |
|
| 740 | + * @since 1.0.19 |
|
| 741 | + * @param string $context View or edit context. |
|
| 742 | + * @return int |
|
| 743 | + */ |
|
| 744 | + public function get_user_id( $context = 'view' ) { |
|
| 745 | + return $this->get_author( $context ); |
|
| 746 | + } |
|
| 747 | + |
|
| 748 | + /** |
|
| 749 | + * Alias of self::get_author(). |
|
| 750 | + * |
|
| 751 | + * @since 1.0.19 |
|
| 752 | + * @param string $context View or edit context. |
|
| 753 | + * @return int |
|
| 754 | + */ |
|
| 755 | + public function get_customer_id( $context = 'view' ) { |
|
| 756 | + return $this->get_author( $context ); |
|
| 757 | + } |
|
| 758 | + |
|
| 759 | + /** |
|
| 760 | + * Get the customer's ip. |
|
| 761 | + * |
|
| 762 | + * @since 1.0.19 |
|
| 763 | + * @param string $context View or edit context. |
|
| 764 | + * @return string |
|
| 765 | + */ |
|
| 766 | + public function get_ip( $context = 'view' ) { |
|
| 767 | + return $this->get_prop( 'user_ip', $context ); |
|
| 768 | + } |
|
| 721 | 769 | |
| 722 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 770 | + /** |
|
| 771 | + * Alias of self::get_ip(). |
|
| 772 | + * |
|
| 773 | + * @since 1.0.19 |
|
| 774 | + * @param string $context View or edit context. |
|
| 775 | + * @return string |
|
| 776 | + */ |
|
| 777 | + public function get_user_ip( $context = 'view' ) { |
|
| 778 | + return $this->get_ip( $context ); |
|
| 779 | + } |
|
| 723 | 780 | |
| 781 | + /** |
|
| 782 | + * Alias of self::get_ip(). |
|
| 783 | + * |
|
| 784 | + * @since 1.0.19 |
|
| 785 | + * @param string $context View or edit context. |
|
| 786 | + * @return string |
|
| 787 | + */ |
|
| 788 | + public function get_customer_ip( $context = 'view' ) { |
|
| 789 | + return $this->get_ip( $context ); |
|
| 724 | 790 | } |
| 725 | 791 | |
| 726 | 792 | /** |
| 727 | - * Get the customer id. |
|
| 728 | - * |
|
| 729 | - * @since 1.0.19 |
|
| 730 | - * @param string $context View or edit context. |
|
| 731 | - * @return int |
|
| 732 | - */ |
|
| 733 | - public function get_author( $context = 'view' ) { |
|
| 734 | - return (int) $this->get_prop( 'author', $context ); |
|
| 793 | + * Get the customer's first name. |
|
| 794 | + * |
|
| 795 | + * @since 1.0.19 |
|
| 796 | + * @param string $context View or edit context. |
|
| 797 | + * @return string |
|
| 798 | + */ |
|
| 799 | + public function get_first_name( $context = 'view' ) { |
|
| 800 | + return $this->get_prop( 'first_name', $context ); |
|
| 735 | 801 | } |
| 736 | 802 | |
| 737 | 803 | /** |
| 738 | - * Alias of self::get_author(). |
|
| 739 | - * |
|
| 740 | - * @since 1.0.19 |
|
| 741 | - * @param string $context View or edit context. |
|
| 742 | - * @return int |
|
| 743 | - */ |
|
| 744 | - public function get_user_id( $context = 'view' ) { |
|
| 745 | - return $this->get_author( $context ); |
|
| 804 | + * Alias of self::get_first_name(). |
|
| 805 | + * |
|
| 806 | + * @since 1.0.19 |
|
| 807 | + * @param string $context View or edit context. |
|
| 808 | + * @return int |
|
| 809 | + */ |
|
| 810 | + public function get_user_first_name( $context = 'view' ) { |
|
| 811 | + return $this->get_first_name( $context ); |
|
| 746 | 812 | } |
| 747 | 813 | |
| 748 | - /** |
|
| 749 | - * Alias of self::get_author(). |
|
| 750 | - * |
|
| 751 | - * @since 1.0.19 |
|
| 752 | - * @param string $context View or edit context. |
|
| 753 | - * @return int |
|
| 754 | - */ |
|
| 755 | - public function get_customer_id( $context = 'view' ) { |
|
| 756 | - return $this->get_author( $context ); |
|
| 814 | + /** |
|
| 815 | + * Alias of self::get_first_name(). |
|
| 816 | + * |
|
| 817 | + * @since 1.0.19 |
|
| 818 | + * @param string $context View or edit context. |
|
| 819 | + * @return int |
|
| 820 | + */ |
|
| 821 | + public function get_customer_first_name( $context = 'view' ) { |
|
| 822 | + return $this->get_first_name( $context ); |
|
| 757 | 823 | } |
| 758 | 824 | |
| 759 | 825 | /** |
| 760 | - * Get the customer's ip. |
|
| 761 | - * |
|
| 762 | - * @since 1.0.19 |
|
| 763 | - * @param string $context View or edit context. |
|
| 764 | - * @return string |
|
| 765 | - */ |
|
| 766 | - public function get_ip( $context = 'view' ) { |
|
| 767 | - return $this->get_prop( 'user_ip', $context ); |
|
| 826 | + * Get the customer's last name. |
|
| 827 | + * |
|
| 828 | + * @since 1.0.19 |
|
| 829 | + * @param string $context View or edit context. |
|
| 830 | + * @return string |
|
| 831 | + */ |
|
| 832 | + public function get_last_name( $context = 'view' ) { |
|
| 833 | + return $this->get_prop( 'last_name', $context ); |
|
| 768 | 834 | } |
| 769 | 835 | |
| 770 | 836 | /** |
| 771 | - * Alias of self::get_ip(). |
|
| 772 | - * |
|
| 773 | - * @since 1.0.19 |
|
| 774 | - * @param string $context View or edit context. |
|
| 775 | - * @return string |
|
| 776 | - */ |
|
| 777 | - public function get_user_ip( $context = 'view' ) { |
|
| 778 | - return $this->get_ip( $context ); |
|
| 837 | + * Alias of self::get_last_name(). |
|
| 838 | + * |
|
| 839 | + * @since 1.0.19 |
|
| 840 | + * @param string $context View or edit context. |
|
| 841 | + * @return int |
|
| 842 | + */ |
|
| 843 | + public function get_user_last_name( $context = 'view' ) { |
|
| 844 | + return $this->get_last_name( $context ); |
|
| 779 | 845 | } |
| 780 | 846 | |
| 781 | - /** |
|
| 782 | - * Alias of self::get_ip(). |
|
| 783 | - * |
|
| 784 | - * @since 1.0.19 |
|
| 785 | - * @param string $context View or edit context. |
|
| 786 | - * @return string |
|
| 787 | - */ |
|
| 788 | - public function get_customer_ip( $context = 'view' ) { |
|
| 789 | - return $this->get_ip( $context ); |
|
| 847 | + /** |
|
| 848 | + * Alias of self::get_last_name(). |
|
| 849 | + * |
|
| 850 | + * @since 1.0.19 |
|
| 851 | + * @param string $context View or edit context. |
|
| 852 | + * @return int |
|
| 853 | + */ |
|
| 854 | + public function get_customer_last_name( $context = 'view' ) { |
|
| 855 | + return $this->get_last_name( $context ); |
|
| 790 | 856 | } |
| 791 | 857 | |
| 792 | 858 | /** |
| 793 | - * Get the customer's first name. |
|
| 794 | - * |
|
| 795 | - * @since 1.0.19 |
|
| 796 | - * @param string $context View or edit context. |
|
| 797 | - * @return string |
|
| 798 | - */ |
|
| 799 | - public function get_first_name( $context = 'view' ) { |
|
| 800 | - return $this->get_prop( 'first_name', $context ); |
|
| 859 | + * Get the customer's full name. |
|
| 860 | + * |
|
| 861 | + * @since 1.0.19 |
|
| 862 | + * @param string $context View or edit context. |
|
| 863 | + * @return string |
|
| 864 | + */ |
|
| 865 | + public function get_full_name( $context = 'view' ) { |
|
| 866 | + return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 801 | 867 | } |
| 802 | 868 | |
| 803 | 869 | /** |
| 804 | - * Alias of self::get_first_name(). |
|
| 805 | - * |
|
| 806 | - * @since 1.0.19 |
|
| 807 | - * @param string $context View or edit context. |
|
| 808 | - * @return int |
|
| 809 | - */ |
|
| 810 | - public function get_user_first_name( $context = 'view' ) { |
|
| 811 | - return $this->get_first_name( $context ); |
|
| 870 | + * Alias of self::get_full_name(). |
|
| 871 | + * |
|
| 872 | + * @since 1.0.19 |
|
| 873 | + * @param string $context View or edit context. |
|
| 874 | + * @return int |
|
| 875 | + */ |
|
| 876 | + public function get_user_full_name( $context = 'view' ) { |
|
| 877 | + return $this->get_full_name( $context ); |
|
| 812 | 878 | } |
| 813 | 879 | |
| 814 | - /** |
|
| 815 | - * Alias of self::get_first_name(). |
|
| 816 | - * |
|
| 817 | - * @since 1.0.19 |
|
| 818 | - * @param string $context View or edit context. |
|
| 819 | - * @return int |
|
| 820 | - */ |
|
| 821 | - public function get_customer_first_name( $context = 'view' ) { |
|
| 822 | - return $this->get_first_name( $context ); |
|
| 880 | + /** |
|
| 881 | + * Alias of self::get_full_name(). |
|
| 882 | + * |
|
| 883 | + * @since 1.0.19 |
|
| 884 | + * @param string $context View or edit context. |
|
| 885 | + * @return int |
|
| 886 | + */ |
|
| 887 | + public function get_customer_full_name( $context = 'view' ) { |
|
| 888 | + return $this->get_full_name( $context ); |
|
| 823 | 889 | } |
| 824 | 890 | |
| 825 | 891 | /** |
| 826 | - * Get the customer's last name. |
|
| 827 | - * |
|
| 828 | - * @since 1.0.19 |
|
| 829 | - * @param string $context View or edit context. |
|
| 830 | - * @return string |
|
| 831 | - */ |
|
| 832 | - public function get_last_name( $context = 'view' ) { |
|
| 833 | - return $this->get_prop( 'last_name', $context ); |
|
| 892 | + * Get the customer's phone number. |
|
| 893 | + * |
|
| 894 | + * @since 1.0.19 |
|
| 895 | + * @param string $context View or edit context. |
|
| 896 | + * @return string |
|
| 897 | + */ |
|
| 898 | + public function get_phone( $context = 'view' ) { |
|
| 899 | + return $this->get_prop( 'phone', $context ); |
|
| 834 | 900 | } |
| 835 | 901 | |
| 836 | 902 | /** |
| 837 | - * Alias of self::get_last_name(). |
|
| 838 | - * |
|
| 839 | - * @since 1.0.19 |
|
| 840 | - * @param string $context View or edit context. |
|
| 841 | - * @return int |
|
| 842 | - */ |
|
| 843 | - public function get_user_last_name( $context = 'view' ) { |
|
| 844 | - return $this->get_last_name( $context ); |
|
| 903 | + * Alias of self::get_phone(). |
|
| 904 | + * |
|
| 905 | + * @since 1.0.19 |
|
| 906 | + * @param string $context View or edit context. |
|
| 907 | + * @return int |
|
| 908 | + */ |
|
| 909 | + public function get_phone_number( $context = 'view' ) { |
|
| 910 | + return $this->get_phone( $context ); |
|
| 845 | 911 | } |
| 846 | 912 | |
| 847 | 913 | /** |
| 848 | - * Alias of self::get_last_name(). |
|
| 849 | - * |
|
| 850 | - * @since 1.0.19 |
|
| 851 | - * @param string $context View or edit context. |
|
| 852 | - * @return int |
|
| 853 | - */ |
|
| 854 | - public function get_customer_last_name( $context = 'view' ) { |
|
| 855 | - return $this->get_last_name( $context ); |
|
| 914 | + * Alias of self::get_phone(). |
|
| 915 | + * |
|
| 916 | + * @since 1.0.19 |
|
| 917 | + * @param string $context View or edit context. |
|
| 918 | + * @return int |
|
| 919 | + */ |
|
| 920 | + public function get_user_phone( $context = 'view' ) { |
|
| 921 | + return $this->get_phone( $context ); |
|
| 856 | 922 | } |
| 857 | 923 | |
| 858 | 924 | /** |
| 859 | - * Get the customer's full name. |
|
| 860 | - * |
|
| 861 | - * @since 1.0.19 |
|
| 862 | - * @param string $context View or edit context. |
|
| 863 | - * @return string |
|
| 864 | - */ |
|
| 865 | - public function get_full_name( $context = 'view' ) { |
|
| 866 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 925 | + * Alias of self::get_phone(). |
|
| 926 | + * |
|
| 927 | + * @since 1.0.19 |
|
| 928 | + * @param string $context View or edit context. |
|
| 929 | + * @return int |
|
| 930 | + */ |
|
| 931 | + public function get_customer_phone( $context = 'view' ) { |
|
| 932 | + return $this->get_phone( $context ); |
|
| 867 | 933 | } |
| 868 | 934 | |
| 869 | 935 | /** |
| 870 | - * Alias of self::get_full_name(). |
|
| 871 | - * |
|
| 872 | - * @since 1.0.19 |
|
| 873 | - * @param string $context View or edit context. |
|
| 874 | - * @return int |
|
| 875 | - */ |
|
| 876 | - public function get_user_full_name( $context = 'view' ) { |
|
| 877 | - return $this->get_full_name( $context ); |
|
| 936 | + * Get the customer's email address. |
|
| 937 | + * |
|
| 938 | + * @since 1.0.19 |
|
| 939 | + * @param string $context View or edit context. |
|
| 940 | + * @return string |
|
| 941 | + */ |
|
| 942 | + public function get_email( $context = 'view' ) { |
|
| 943 | + return $this->get_prop( 'email', $context ); |
|
| 878 | 944 | } |
| 879 | 945 | |
| 880 | 946 | /** |
| 881 | - * Alias of self::get_full_name(). |
|
| 882 | - * |
|
| 883 | - * @since 1.0.19 |
|
| 884 | - * @param string $context View or edit context. |
|
| 885 | - * @return int |
|
| 886 | - */ |
|
| 887 | - public function get_customer_full_name( $context = 'view' ) { |
|
| 888 | - return $this->get_full_name( $context ); |
|
| 947 | + * Alias of self::get_email(). |
|
| 948 | + * |
|
| 949 | + * @since 1.0.19 |
|
| 950 | + * @param string $context View or edit context. |
|
| 951 | + * @return string |
|
| 952 | + */ |
|
| 953 | + public function get_email_address( $context = 'view' ) { |
|
| 954 | + return $this->get_email( $context ); |
|
| 889 | 955 | } |
| 890 | 956 | |
| 891 | 957 | /** |
| 892 | - * Get the customer's phone number. |
|
| 893 | - * |
|
| 894 | - * @since 1.0.19 |
|
| 895 | - * @param string $context View or edit context. |
|
| 896 | - * @return string |
|
| 897 | - */ |
|
| 898 | - public function get_phone( $context = 'view' ) { |
|
| 899 | - return $this->get_prop( 'phone', $context ); |
|
| 958 | + * Alias of self::get_email(). |
|
| 959 | + * |
|
| 960 | + * @since 1.0.19 |
|
| 961 | + * @param string $context View or edit context. |
|
| 962 | + * @return int |
|
| 963 | + */ |
|
| 964 | + public function get_user_email( $context = 'view' ) { |
|
| 965 | + return $this->get_email( $context ); |
|
| 900 | 966 | } |
| 901 | 967 | |
| 902 | 968 | /** |
| 903 | - * Alias of self::get_phone(). |
|
| 904 | - * |
|
| 905 | - * @since 1.0.19 |
|
| 906 | - * @param string $context View or edit context. |
|
| 907 | - * @return int |
|
| 908 | - */ |
|
| 909 | - public function get_phone_number( $context = 'view' ) { |
|
| 910 | - return $this->get_phone( $context ); |
|
| 969 | + * Alias of self::get_email(). |
|
| 970 | + * |
|
| 971 | + * @since 1.0.19 |
|
| 972 | + * @param string $context View or edit context. |
|
| 973 | + * @return int |
|
| 974 | + */ |
|
| 975 | + public function get_customer_email( $context = 'view' ) { |
|
| 976 | + return $this->get_email( $context ); |
|
| 911 | 977 | } |
| 912 | 978 | |
| 913 | 979 | /** |
| 914 | - * Alias of self::get_phone(). |
|
| 915 | - * |
|
| 916 | - * @since 1.0.19 |
|
| 917 | - * @param string $context View or edit context. |
|
| 918 | - * @return int |
|
| 919 | - */ |
|
| 920 | - public function get_user_phone( $context = 'view' ) { |
|
| 921 | - return $this->get_phone( $context ); |
|
| 980 | + * Get the customer's country. |
|
| 981 | + * |
|
| 982 | + * @since 1.0.19 |
|
| 983 | + * @param string $context View or edit context. |
|
| 984 | + * @return string |
|
| 985 | + */ |
|
| 986 | + public function get_country( $context = 'view' ) { |
|
| 987 | + $country = $this->get_prop( 'country', $context ); |
|
| 988 | + return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 922 | 989 | } |
| 923 | 990 | |
| 924 | 991 | /** |
| 925 | - * Alias of self::get_phone(). |
|
| 926 | - * |
|
| 927 | - * @since 1.0.19 |
|
| 928 | - * @param string $context View or edit context. |
|
| 929 | - * @return int |
|
| 930 | - */ |
|
| 931 | - public function get_customer_phone( $context = 'view' ) { |
|
| 932 | - return $this->get_phone( $context ); |
|
| 992 | + * Alias of self::get_country(). |
|
| 993 | + * |
|
| 994 | + * @since 1.0.19 |
|
| 995 | + * @param string $context View or edit context. |
|
| 996 | + * @return int |
|
| 997 | + */ |
|
| 998 | + public function get_user_country( $context = 'view' ) { |
|
| 999 | + return $this->get_country( $context ); |
|
| 933 | 1000 | } |
| 934 | 1001 | |
| 935 | 1002 | /** |
| 936 | - * Get the customer's email address. |
|
| 937 | - * |
|
| 938 | - * @since 1.0.19 |
|
| 939 | - * @param string $context View or edit context. |
|
| 940 | - * @return string |
|
| 941 | - */ |
|
| 942 | - public function get_email( $context = 'view' ) { |
|
| 943 | - return $this->get_prop( 'email', $context ); |
|
| 1003 | + * Alias of self::get_country(). |
|
| 1004 | + * |
|
| 1005 | + * @since 1.0.19 |
|
| 1006 | + * @param string $context View or edit context. |
|
| 1007 | + * @return int |
|
| 1008 | + */ |
|
| 1009 | + public function get_customer_country( $context = 'view' ) { |
|
| 1010 | + return $this->get_country( $context ); |
|
| 944 | 1011 | } |
| 945 | 1012 | |
| 946 | 1013 | /** |
| 947 | - * Alias of self::get_email(). |
|
| 948 | - * |
|
| 949 | - * @since 1.0.19 |
|
| 950 | - * @param string $context View or edit context. |
|
| 951 | - * @return string |
|
| 952 | - */ |
|
| 953 | - public function get_email_address( $context = 'view' ) { |
|
| 954 | - return $this->get_email( $context ); |
|
| 1014 | + * Get the customer's state. |
|
| 1015 | + * |
|
| 1016 | + * @since 1.0.19 |
|
| 1017 | + * @param string $context View or edit context. |
|
| 1018 | + * @return string |
|
| 1019 | + */ |
|
| 1020 | + public function get_state( $context = 'view' ) { |
|
| 1021 | + $state = $this->get_prop( 'state', $context ); |
|
| 1022 | + return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 955 | 1023 | } |
| 956 | 1024 | |
| 957 | 1025 | /** |
| 958 | - * Alias of self::get_email(). |
|
| 959 | - * |
|
| 960 | - * @since 1.0.19 |
|
| 961 | - * @param string $context View or edit context. |
|
| 962 | - * @return int |
|
| 963 | - */ |
|
| 964 | - public function get_user_email( $context = 'view' ) { |
|
| 965 | - return $this->get_email( $context ); |
|
| 1026 | + * Alias of self::get_state(). |
|
| 1027 | + * |
|
| 1028 | + * @since 1.0.19 |
|
| 1029 | + * @param string $context View or edit context. |
|
| 1030 | + * @return int |
|
| 1031 | + */ |
|
| 1032 | + public function get_user_state( $context = 'view' ) { |
|
| 1033 | + return $this->get_state( $context ); |
|
| 966 | 1034 | } |
| 967 | 1035 | |
| 968 | 1036 | /** |
| 969 | - * Alias of self::get_email(). |
|
| 970 | - * |
|
| 971 | - * @since 1.0.19 |
|
| 972 | - * @param string $context View or edit context. |
|
| 973 | - * @return int |
|
| 974 | - */ |
|
| 975 | - public function get_customer_email( $context = 'view' ) { |
|
| 976 | - return $this->get_email( $context ); |
|
| 1037 | + * Alias of self::get_state(). |
|
| 1038 | + * |
|
| 1039 | + * @since 1.0.19 |
|
| 1040 | + * @param string $context View or edit context. |
|
| 1041 | + * @return int |
|
| 1042 | + */ |
|
| 1043 | + public function get_customer_state( $context = 'view' ) { |
|
| 1044 | + return $this->get_state( $context ); |
|
| 977 | 1045 | } |
| 978 | 1046 | |
| 979 | 1047 | /** |
| 980 | - * Get the customer's country. |
|
| 981 | - * |
|
| 982 | - * @since 1.0.19 |
|
| 983 | - * @param string $context View or edit context. |
|
| 984 | - * @return string |
|
| 985 | - */ |
|
| 986 | - public function get_country( $context = 'view' ) { |
|
| 987 | - $country = $this->get_prop( 'country', $context ); |
|
| 988 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 1048 | + * Get the customer's city. |
|
| 1049 | + * |
|
| 1050 | + * @since 1.0.19 |
|
| 1051 | + * @param string $context View or edit context. |
|
| 1052 | + * @return string |
|
| 1053 | + */ |
|
| 1054 | + public function get_city( $context = 'view' ) { |
|
| 1055 | + return $this->get_prop( 'city', $context ); |
|
| 989 | 1056 | } |
| 990 | 1057 | |
| 991 | 1058 | /** |
| 992 | - * Alias of self::get_country(). |
|
| 993 | - * |
|
| 994 | - * @since 1.0.19 |
|
| 995 | - * @param string $context View or edit context. |
|
| 996 | - * @return int |
|
| 997 | - */ |
|
| 998 | - public function get_user_country( $context = 'view' ) { |
|
| 999 | - return $this->get_country( $context ); |
|
| 1059 | + * Alias of self::get_city(). |
|
| 1060 | + * |
|
| 1061 | + * @since 1.0.19 |
|
| 1062 | + * @param string $context View or edit context. |
|
| 1063 | + * @return string |
|
| 1064 | + */ |
|
| 1065 | + public function get_user_city( $context = 'view' ) { |
|
| 1066 | + return $this->get_city( $context ); |
|
| 1000 | 1067 | } |
| 1001 | 1068 | |
| 1002 | 1069 | /** |
| 1003 | - * Alias of self::get_country(). |
|
| 1004 | - * |
|
| 1005 | - * @since 1.0.19 |
|
| 1006 | - * @param string $context View or edit context. |
|
| 1007 | - * @return int |
|
| 1008 | - */ |
|
| 1009 | - public function get_customer_country( $context = 'view' ) { |
|
| 1010 | - return $this->get_country( $context ); |
|
| 1070 | + * Alias of self::get_city(). |
|
| 1071 | + * |
|
| 1072 | + * @since 1.0.19 |
|
| 1073 | + * @param string $context View or edit context. |
|
| 1074 | + * @return string |
|
| 1075 | + */ |
|
| 1076 | + public function get_customer_city( $context = 'view' ) { |
|
| 1077 | + return $this->get_city( $context ); |
|
| 1011 | 1078 | } |
| 1012 | 1079 | |
| 1013 | 1080 | /** |
| 1014 | - * Get the customer's state. |
|
| 1015 | - * |
|
| 1016 | - * @since 1.0.19 |
|
| 1017 | - * @param string $context View or edit context. |
|
| 1018 | - * @return string |
|
| 1019 | - */ |
|
| 1020 | - public function get_state( $context = 'view' ) { |
|
| 1021 | - $state = $this->get_prop( 'state', $context ); |
|
| 1022 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 1081 | + * Get the customer's zip. |
|
| 1082 | + * |
|
| 1083 | + * @since 1.0.19 |
|
| 1084 | + * @param string $context View or edit context. |
|
| 1085 | + * @return string |
|
| 1086 | + */ |
|
| 1087 | + public function get_zip( $context = 'view' ) { |
|
| 1088 | + return $this->get_prop( 'zip', $context ); |
|
| 1023 | 1089 | } |
| 1024 | 1090 | |
| 1025 | 1091 | /** |
| 1026 | - * Alias of self::get_state(). |
|
| 1027 | - * |
|
| 1028 | - * @since 1.0.19 |
|
| 1029 | - * @param string $context View or edit context. |
|
| 1030 | - * @return int |
|
| 1031 | - */ |
|
| 1032 | - public function get_user_state( $context = 'view' ) { |
|
| 1033 | - return $this->get_state( $context ); |
|
| 1092 | + * Alias of self::get_zip(). |
|
| 1093 | + * |
|
| 1094 | + * @since 1.0.19 |
|
| 1095 | + * @param string $context View or edit context. |
|
| 1096 | + * @return string |
|
| 1097 | + */ |
|
| 1098 | + public function get_user_zip( $context = 'view' ) { |
|
| 1099 | + return $this->get_zip( $context ); |
|
| 1034 | 1100 | } |
| 1035 | 1101 | |
| 1036 | 1102 | /** |
| 1037 | - * Alias of self::get_state(). |
|
| 1038 | - * |
|
| 1039 | - * @since 1.0.19 |
|
| 1040 | - * @param string $context View or edit context. |
|
| 1041 | - * @return int |
|
| 1042 | - */ |
|
| 1043 | - public function get_customer_state( $context = 'view' ) { |
|
| 1044 | - return $this->get_state( $context ); |
|
| 1103 | + * Alias of self::get_zip(). |
|
| 1104 | + * |
|
| 1105 | + * @since 1.0.19 |
|
| 1106 | + * @param string $context View or edit context. |
|
| 1107 | + * @return string |
|
| 1108 | + */ |
|
| 1109 | + public function get_customer_zip( $context = 'view' ) { |
|
| 1110 | + return $this->get_zip( $context ); |
|
| 1045 | 1111 | } |
| 1046 | 1112 | |
| 1047 | 1113 | /** |
| 1048 | - * Get the customer's city. |
|
| 1049 | - * |
|
| 1050 | - * @since 1.0.19 |
|
| 1051 | - * @param string $context View or edit context. |
|
| 1052 | - * @return string |
|
| 1053 | - */ |
|
| 1054 | - public function get_city( $context = 'view' ) { |
|
| 1055 | - return $this->get_prop( 'city', $context ); |
|
| 1114 | + * Get the customer's company. |
|
| 1115 | + * |
|
| 1116 | + * @since 1.0.19 |
|
| 1117 | + * @param string $context View or edit context. |
|
| 1118 | + * @return string |
|
| 1119 | + */ |
|
| 1120 | + public function get_company( $context = 'view' ) { |
|
| 1121 | + return $this->get_prop( 'company', $context ); |
|
| 1056 | 1122 | } |
| 1057 | 1123 | |
| 1058 | 1124 | /** |
| 1059 | - * Alias of self::get_city(). |
|
| 1060 | - * |
|
| 1061 | - * @since 1.0.19 |
|
| 1062 | - * @param string $context View or edit context. |
|
| 1063 | - * @return string |
|
| 1064 | - */ |
|
| 1065 | - public function get_user_city( $context = 'view' ) { |
|
| 1066 | - return $this->get_city( $context ); |
|
| 1125 | + * Alias of self::get_company(). |
|
| 1126 | + * |
|
| 1127 | + * @since 1.0.19 |
|
| 1128 | + * @param string $context View or edit context. |
|
| 1129 | + * @return string |
|
| 1130 | + */ |
|
| 1131 | + public function get_user_company( $context = 'view' ) { |
|
| 1132 | + return $this->get_company( $context ); |
|
| 1067 | 1133 | } |
| 1068 | 1134 | |
| 1069 | 1135 | /** |
| 1070 | - * Alias of self::get_city(). |
|
| 1071 | - * |
|
| 1072 | - * @since 1.0.19 |
|
| 1073 | - * @param string $context View or edit context. |
|
| 1074 | - * @return string |
|
| 1075 | - */ |
|
| 1076 | - public function get_customer_city( $context = 'view' ) { |
|
| 1077 | - return $this->get_city( $context ); |
|
| 1136 | + * Alias of self::get_company(). |
|
| 1137 | + * |
|
| 1138 | + * @since 1.0.19 |
|
| 1139 | + * @param string $context View or edit context. |
|
| 1140 | + * @return string |
|
| 1141 | + */ |
|
| 1142 | + public function get_customer_company( $context = 'view' ) { |
|
| 1143 | + return $this->get_company( $context ); |
|
| 1078 | 1144 | } |
| 1079 | 1145 | |
| 1080 | 1146 | /** |
| 1081 | - * Get the customer's zip. |
|
| 1082 | - * |
|
| 1083 | - * @since 1.0.19 |
|
| 1084 | - * @param string $context View or edit context. |
|
| 1085 | - * @return string |
|
| 1086 | - */ |
|
| 1087 | - public function get_zip( $context = 'view' ) { |
|
| 1088 | - return $this->get_prop( 'zip', $context ); |
|
| 1147 | + * Get the customer's vat number. |
|
| 1148 | + * |
|
| 1149 | + * @since 1.0.19 |
|
| 1150 | + * @param string $context View or edit context. |
|
| 1151 | + * @return string |
|
| 1152 | + */ |
|
| 1153 | + public function get_vat_number( $context = 'view' ) { |
|
| 1154 | + return $this->get_prop( 'vat_number', $context ); |
|
| 1089 | 1155 | } |
| 1090 | 1156 | |
| 1091 | 1157 | /** |
| 1092 | - * Alias of self::get_zip(). |
|
| 1093 | - * |
|
| 1094 | - * @since 1.0.19 |
|
| 1095 | - * @param string $context View or edit context. |
|
| 1096 | - * @return string |
|
| 1097 | - */ |
|
| 1098 | - public function get_user_zip( $context = 'view' ) { |
|
| 1099 | - return $this->get_zip( $context ); |
|
| 1158 | + * Alias of self::get_vat_number(). |
|
| 1159 | + * |
|
| 1160 | + * @since 1.0.19 |
|
| 1161 | + * @param string $context View or edit context. |
|
| 1162 | + * @return string |
|
| 1163 | + */ |
|
| 1164 | + public function get_user_vat_number( $context = 'view' ) { |
|
| 1165 | + return $this->get_vat_number( $context ); |
|
| 1100 | 1166 | } |
| 1101 | 1167 | |
| 1102 | 1168 | /** |
| 1103 | - * Alias of self::get_zip(). |
|
| 1104 | - * |
|
| 1105 | - * @since 1.0.19 |
|
| 1106 | - * @param string $context View or edit context. |
|
| 1107 | - * @return string |
|
| 1108 | - */ |
|
| 1109 | - public function get_customer_zip( $context = 'view' ) { |
|
| 1110 | - return $this->get_zip( $context ); |
|
| 1169 | + * Alias of self::get_vat_number(). |
|
| 1170 | + * |
|
| 1171 | + * @since 1.0.19 |
|
| 1172 | + * @param string $context View or edit context. |
|
| 1173 | + * @return string |
|
| 1174 | + */ |
|
| 1175 | + public function get_customer_vat_number( $context = 'view' ) { |
|
| 1176 | + return $this->get_vat_number( $context ); |
|
| 1111 | 1177 | } |
| 1112 | 1178 | |
| 1113 | 1179 | /** |
| 1114 | - * Get the customer's company. |
|
| 1115 | - * |
|
| 1116 | - * @since 1.0.19 |
|
| 1117 | - * @param string $context View or edit context. |
|
| 1118 | - * @return string |
|
| 1119 | - */ |
|
| 1120 | - public function get_company( $context = 'view' ) { |
|
| 1121 | - return $this->get_prop( 'company', $context ); |
|
| 1180 | + * Get the customer's vat rate. |
|
| 1181 | + * |
|
| 1182 | + * @since 1.0.19 |
|
| 1183 | + * @param string $context View or edit context. |
|
| 1184 | + * @return string |
|
| 1185 | + */ |
|
| 1186 | + public function get_vat_rate( $context = 'view' ) { |
|
| 1187 | + return $this->get_prop( 'vat_rate', $context ); |
|
| 1122 | 1188 | } |
| 1123 | 1189 | |
| 1124 | 1190 | /** |
| 1125 | - * Alias of self::get_company(). |
|
| 1126 | - * |
|
| 1127 | - * @since 1.0.19 |
|
| 1128 | - * @param string $context View or edit context. |
|
| 1129 | - * @return string |
|
| 1130 | - */ |
|
| 1131 | - public function get_user_company( $context = 'view' ) { |
|
| 1132 | - return $this->get_company( $context ); |
|
| 1191 | + * Alias of self::get_vat_rate(). |
|
| 1192 | + * |
|
| 1193 | + * @since 1.0.19 |
|
| 1194 | + * @param string $context View or edit context. |
|
| 1195 | + * @return string |
|
| 1196 | + */ |
|
| 1197 | + public function get_user_vat_rate( $context = 'view' ) { |
|
| 1198 | + return $this->get_vat_rate( $context ); |
|
| 1133 | 1199 | } |
| 1134 | 1200 | |
| 1135 | 1201 | /** |
| 1136 | - * Alias of self::get_company(). |
|
| 1137 | - * |
|
| 1138 | - * @since 1.0.19 |
|
| 1139 | - * @param string $context View or edit context. |
|
| 1140 | - * @return string |
|
| 1141 | - */ |
|
| 1142 | - public function get_customer_company( $context = 'view' ) { |
|
| 1143 | - return $this->get_company( $context ); |
|
| 1202 | + * Alias of self::get_vat_rate(). |
|
| 1203 | + * |
|
| 1204 | + * @since 1.0.19 |
|
| 1205 | + * @param string $context View or edit context. |
|
| 1206 | + * @return string |
|
| 1207 | + */ |
|
| 1208 | + public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1209 | + return $this->get_vat_rate( $context ); |
|
| 1144 | 1210 | } |
| 1145 | 1211 | |
| 1146 | 1212 | /** |
| 1147 | - * Get the customer's vat number. |
|
| 1148 | - * |
|
| 1149 | - * @since 1.0.19 |
|
| 1150 | - * @param string $context View or edit context. |
|
| 1151 | - * @return string |
|
| 1152 | - */ |
|
| 1153 | - public function get_vat_number( $context = 'view' ) { |
|
| 1154 | - return $this->get_prop( 'vat_number', $context ); |
|
| 1213 | + * Get the customer's address. |
|
| 1214 | + * |
|
| 1215 | + * @since 1.0.19 |
|
| 1216 | + * @param string $context View or edit context. |
|
| 1217 | + * @return string |
|
| 1218 | + */ |
|
| 1219 | + public function get_address( $context = 'view' ) { |
|
| 1220 | + return $this->get_prop( 'address', $context ); |
|
| 1155 | 1221 | } |
| 1156 | 1222 | |
| 1157 | 1223 | /** |
| 1158 | - * Alias of self::get_vat_number(). |
|
| 1159 | - * |
|
| 1160 | - * @since 1.0.19 |
|
| 1161 | - * @param string $context View or edit context. |
|
| 1162 | - * @return string |
|
| 1163 | - */ |
|
| 1164 | - public function get_user_vat_number( $context = 'view' ) { |
|
| 1165 | - return $this->get_vat_number( $context ); |
|
| 1224 | + * Alias of self::get_address(). |
|
| 1225 | + * |
|
| 1226 | + * @since 1.0.19 |
|
| 1227 | + * @param string $context View or edit context. |
|
| 1228 | + * @return string |
|
| 1229 | + */ |
|
| 1230 | + public function get_user_address( $context = 'view' ) { |
|
| 1231 | + return $this->get_address( $context ); |
|
| 1166 | 1232 | } |
| 1167 | 1233 | |
| 1168 | 1234 | /** |
| 1169 | - * Alias of self::get_vat_number(). |
|
| 1170 | - * |
|
| 1171 | - * @since 1.0.19 |
|
| 1172 | - * @param string $context View or edit context. |
|
| 1173 | - * @return string |
|
| 1174 | - */ |
|
| 1175 | - public function get_customer_vat_number( $context = 'view' ) { |
|
| 1176 | - return $this->get_vat_number( $context ); |
|
| 1235 | + * Alias of self::get_address(). |
|
| 1236 | + * |
|
| 1237 | + * @since 1.0.19 |
|
| 1238 | + * @param string $context View or edit context. |
|
| 1239 | + * @return string |
|
| 1240 | + */ |
|
| 1241 | + public function get_customer_address( $context = 'view' ) { |
|
| 1242 | + return $this->get_address( $context ); |
|
| 1243 | + } |
|
| 1244 | + |
|
| 1245 | + /** |
|
| 1246 | + * Get whether the customer has viewed the invoice or not. |
|
| 1247 | + * |
|
| 1248 | + * @since 1.0.19 |
|
| 1249 | + * @param string $context View or edit context. |
|
| 1250 | + * @return bool |
|
| 1251 | + */ |
|
| 1252 | + public function get_is_viewed( $context = 'view' ) { |
|
| 1253 | + return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1254 | + } |
|
| 1255 | + |
|
| 1256 | + /** |
|
| 1257 | + * Get other recipients for invoice communications. |
|
| 1258 | + * |
|
| 1259 | + * @since 1.0.19 |
|
| 1260 | + * @param string $context View or edit context. |
|
| 1261 | + * @return bool |
|
| 1262 | + */ |
|
| 1263 | + public function get_email_cc( $context = 'view' ) { |
|
| 1264 | + return $this->get_prop( 'email_cc', $context ); |
|
| 1265 | + } |
|
| 1266 | + |
|
| 1267 | + /** |
|
| 1268 | + * Get invoice template. |
|
| 1269 | + * |
|
| 1270 | + * @since 1.0.19 |
|
| 1271 | + * @param string $context View or edit context. |
|
| 1272 | + * @return bool |
|
| 1273 | + */ |
|
| 1274 | + public function get_template( $context = 'view' ) { |
|
| 1275 | + return $this->get_prop( 'template', $context ); |
|
| 1276 | + } |
|
| 1277 | + |
|
| 1278 | + /** |
|
| 1279 | + * Get invoice source. |
|
| 1280 | + * |
|
| 1281 | + * @since 1.0.19 |
|
| 1282 | + * @param string $context View or edit context. |
|
| 1283 | + * @return bool |
|
| 1284 | + */ |
|
| 1285 | + public function get_created_via( $context = 'view' ) { |
|
| 1286 | + return $this->get_prop( 'created_via', $context ); |
|
| 1177 | 1287 | } |
| 1178 | 1288 | |
| 1179 | 1289 | /** |
| 1180 | - * Get the customer's vat rate. |
|
| 1181 | - * |
|
| 1182 | - * @since 1.0.19 |
|
| 1183 | - * @param string $context View or edit context. |
|
| 1184 | - * @return string |
|
| 1185 | - */ |
|
| 1186 | - public function get_vat_rate( $context = 'view' ) { |
|
| 1187 | - return $this->get_prop( 'vat_rate', $context ); |
|
| 1188 | - } |
|
| 1189 | - |
|
| 1190 | - /** |
|
| 1191 | - * Alias of self::get_vat_rate(). |
|
| 1192 | - * |
|
| 1193 | - * @since 1.0.19 |
|
| 1194 | - * @param string $context View or edit context. |
|
| 1195 | - * @return string |
|
| 1196 | - */ |
|
| 1197 | - public function get_user_vat_rate( $context = 'view' ) { |
|
| 1198 | - return $this->get_vat_rate( $context ); |
|
| 1199 | - } |
|
| 1200 | - |
|
| 1201 | - /** |
|
| 1202 | - * Alias of self::get_vat_rate(). |
|
| 1203 | - * |
|
| 1204 | - * @since 1.0.19 |
|
| 1205 | - * @param string $context View or edit context. |
|
| 1206 | - * @return string |
|
| 1207 | - */ |
|
| 1208 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1209 | - return $this->get_vat_rate( $context ); |
|
| 1210 | - } |
|
| 1211 | - |
|
| 1212 | - /** |
|
| 1213 | - * Get the customer's address. |
|
| 1214 | - * |
|
| 1215 | - * @since 1.0.19 |
|
| 1216 | - * @param string $context View or edit context. |
|
| 1217 | - * @return string |
|
| 1218 | - */ |
|
| 1219 | - public function get_address( $context = 'view' ) { |
|
| 1220 | - return $this->get_prop( 'address', $context ); |
|
| 1221 | - } |
|
| 1222 | - |
|
| 1223 | - /** |
|
| 1224 | - * Alias of self::get_address(). |
|
| 1225 | - * |
|
| 1226 | - * @since 1.0.19 |
|
| 1227 | - * @param string $context View or edit context. |
|
| 1228 | - * @return string |
|
| 1229 | - */ |
|
| 1230 | - public function get_user_address( $context = 'view' ) { |
|
| 1231 | - return $this->get_address( $context ); |
|
| 1232 | - } |
|
| 1233 | - |
|
| 1234 | - /** |
|
| 1235 | - * Alias of self::get_address(). |
|
| 1236 | - * |
|
| 1237 | - * @since 1.0.19 |
|
| 1238 | - * @param string $context View or edit context. |
|
| 1239 | - * @return string |
|
| 1240 | - */ |
|
| 1241 | - public function get_customer_address( $context = 'view' ) { |
|
| 1242 | - return $this->get_address( $context ); |
|
| 1243 | - } |
|
| 1244 | - |
|
| 1245 | - /** |
|
| 1246 | - * Get whether the customer has viewed the invoice or not. |
|
| 1247 | - * |
|
| 1248 | - * @since 1.0.19 |
|
| 1249 | - * @param string $context View or edit context. |
|
| 1250 | - * @return bool |
|
| 1251 | - */ |
|
| 1252 | - public function get_is_viewed( $context = 'view' ) { |
|
| 1253 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1254 | - } |
|
| 1255 | - |
|
| 1256 | - /** |
|
| 1257 | - * Get other recipients for invoice communications. |
|
| 1258 | - * |
|
| 1259 | - * @since 1.0.19 |
|
| 1260 | - * @param string $context View or edit context. |
|
| 1261 | - * @return bool |
|
| 1262 | - */ |
|
| 1263 | - public function get_email_cc( $context = 'view' ) { |
|
| 1264 | - return $this->get_prop( 'email_cc', $context ); |
|
| 1265 | - } |
|
| 1266 | - |
|
| 1267 | - /** |
|
| 1268 | - * Get invoice template. |
|
| 1269 | - * |
|
| 1270 | - * @since 1.0.19 |
|
| 1271 | - * @param string $context View or edit context. |
|
| 1272 | - * @return bool |
|
| 1273 | - */ |
|
| 1274 | - public function get_template( $context = 'view' ) { |
|
| 1275 | - return $this->get_prop( 'template', $context ); |
|
| 1276 | - } |
|
| 1277 | - |
|
| 1278 | - /** |
|
| 1279 | - * Get invoice source. |
|
| 1280 | - * |
|
| 1281 | - * @since 1.0.19 |
|
| 1282 | - * @param string $context View or edit context. |
|
| 1283 | - * @return bool |
|
| 1284 | - */ |
|
| 1285 | - public function get_created_via( $context = 'view' ) { |
|
| 1286 | - return $this->get_prop( 'created_via', $context ); |
|
| 1287 | - } |
|
| 1288 | - |
|
| 1289 | - /** |
|
| 1290 | - * Get whether the customer has confirmed their address. |
|
| 1291 | - * |
|
| 1292 | - * @since 1.0.19 |
|
| 1293 | - * @param string $context View or edit context. |
|
| 1294 | - * @return bool |
|
| 1295 | - */ |
|
| 1296 | - public function get_address_confirmed( $context = 'view' ) { |
|
| 1297 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1298 | - } |
|
| 1299 | - |
|
| 1300 | - /** |
|
| 1301 | - * Alias of self::get_address_confirmed(). |
|
| 1302 | - * |
|
| 1303 | - * @since 1.0.19 |
|
| 1304 | - * @param string $context View or edit context. |
|
| 1305 | - * @return bool |
|
| 1306 | - */ |
|
| 1307 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1308 | - return $this->get_address_confirmed( $context ); |
|
| 1309 | - } |
|
| 1310 | - |
|
| 1311 | - /** |
|
| 1312 | - * Alias of self::get_address(). |
|
| 1313 | - * |
|
| 1314 | - * @since 1.0.19 |
|
| 1315 | - * @param string $context View or edit context. |
|
| 1316 | - * @return bool |
|
| 1317 | - */ |
|
| 1318 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1319 | - return $this->get_address_confirmed( $context ); |
|
| 1320 | - } |
|
| 1321 | - |
|
| 1322 | - /** |
|
| 1323 | - * Get the invoice subtotal. |
|
| 1324 | - * |
|
| 1325 | - * @since 1.0.19 |
|
| 1326 | - * @param string $context View or edit context. |
|
| 1327 | - * @return float |
|
| 1328 | - */ |
|
| 1329 | - public function get_subtotal( $context = 'view' ) { |
|
| 1290 | + * Get whether the customer has confirmed their address. |
|
| 1291 | + * |
|
| 1292 | + * @since 1.0.19 |
|
| 1293 | + * @param string $context View or edit context. |
|
| 1294 | + * @return bool |
|
| 1295 | + */ |
|
| 1296 | + public function get_address_confirmed( $context = 'view' ) { |
|
| 1297 | + return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1298 | + } |
|
| 1299 | + |
|
| 1300 | + /** |
|
| 1301 | + * Alias of self::get_address_confirmed(). |
|
| 1302 | + * |
|
| 1303 | + * @since 1.0.19 |
|
| 1304 | + * @param string $context View or edit context. |
|
| 1305 | + * @return bool |
|
| 1306 | + */ |
|
| 1307 | + public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1308 | + return $this->get_address_confirmed( $context ); |
|
| 1309 | + } |
|
| 1310 | + |
|
| 1311 | + /** |
|
| 1312 | + * Alias of self::get_address(). |
|
| 1313 | + * |
|
| 1314 | + * @since 1.0.19 |
|
| 1315 | + * @param string $context View or edit context. |
|
| 1316 | + * @return bool |
|
| 1317 | + */ |
|
| 1318 | + public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1319 | + return $this->get_address_confirmed( $context ); |
|
| 1320 | + } |
|
| 1321 | + |
|
| 1322 | + /** |
|
| 1323 | + * Get the invoice subtotal. |
|
| 1324 | + * |
|
| 1325 | + * @since 1.0.19 |
|
| 1326 | + * @param string $context View or edit context. |
|
| 1327 | + * @return float |
|
| 1328 | + */ |
|
| 1329 | + public function get_subtotal( $context = 'view' ) { |
|
| 1330 | 1330 | $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
| 1331 | 1331 | |
| 1332 | 1332 | // Backwards compatibility. |
@@ -1338,165 +1338,165 @@ discard block |
||
| 1338 | 1338 | } |
| 1339 | 1339 | |
| 1340 | 1340 | /** |
| 1341 | - * Get the invoice discount total. |
|
| 1342 | - * |
|
| 1343 | - * @since 1.0.19 |
|
| 1344 | - * @param string $context View or edit context. |
|
| 1345 | - * @return float |
|
| 1346 | - */ |
|
| 1347 | - public function get_total_discount( $context = 'view' ) { |
|
| 1348 | - return (float) $this->get_prop( 'total_discount', $context ); |
|
| 1341 | + * Get the invoice discount total. |
|
| 1342 | + * |
|
| 1343 | + * @since 1.0.19 |
|
| 1344 | + * @param string $context View or edit context. |
|
| 1345 | + * @return float |
|
| 1346 | + */ |
|
| 1347 | + public function get_total_discount( $context = 'view' ) { |
|
| 1348 | + return (float) $this->get_prop( 'total_discount', $context ); |
|
| 1349 | 1349 | } |
| 1350 | 1350 | |
| 1351 | 1351 | /** |
| 1352 | - * Get the invoice tax total. |
|
| 1353 | - * |
|
| 1354 | - * @since 1.0.19 |
|
| 1355 | - * @param string $context View or edit context. |
|
| 1356 | - * @return float |
|
| 1357 | - */ |
|
| 1358 | - public function get_total_tax( $context = 'view' ) { |
|
| 1359 | - return (float) $this->get_prop( 'total_tax', $context ); |
|
| 1360 | - } |
|
| 1352 | + * Get the invoice tax total. |
|
| 1353 | + * |
|
| 1354 | + * @since 1.0.19 |
|
| 1355 | + * @param string $context View or edit context. |
|
| 1356 | + * @return float |
|
| 1357 | + */ |
|
| 1358 | + public function get_total_tax( $context = 'view' ) { |
|
| 1359 | + return (float) $this->get_prop( 'total_tax', $context ); |
|
| 1360 | + } |
|
| 1361 | 1361 | |
| 1362 | - /** |
|
| 1363 | - * @deprecated |
|
| 1364 | - */ |
|
| 1365 | - public function get_final_tax( $currency = false ) { |
|
| 1366 | - $tax = $this->get_total_tax(); |
|
| 1362 | + /** |
|
| 1363 | + * @deprecated |
|
| 1364 | + */ |
|
| 1365 | + public function get_final_tax( $currency = false ) { |
|
| 1366 | + $tax = $this->get_total_tax(); |
|
| 1367 | 1367 | |
| 1368 | 1368 | if ( $currency ) { |
| 1369 | - return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
| 1369 | + return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
| 1370 | 1370 | } |
| 1371 | 1371 | |
| 1372 | 1372 | return $tax; |
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | 1375 | /** |
| 1376 | - * Get the invoice fees total. |
|
| 1377 | - * |
|
| 1378 | - * @since 1.0.19 |
|
| 1379 | - * @param string $context View or edit context. |
|
| 1380 | - * @return float |
|
| 1381 | - */ |
|
| 1382 | - public function get_total_fees( $context = 'view' ) { |
|
| 1383 | - return (float) $this->get_prop( 'total_fees', $context ); |
|
| 1376 | + * Get the invoice fees total. |
|
| 1377 | + * |
|
| 1378 | + * @since 1.0.19 |
|
| 1379 | + * @param string $context View or edit context. |
|
| 1380 | + * @return float |
|
| 1381 | + */ |
|
| 1382 | + public function get_total_fees( $context = 'view' ) { |
|
| 1383 | + return (float) $this->get_prop( 'total_fees', $context ); |
|
| 1384 | 1384 | } |
| 1385 | 1385 | |
| 1386 | 1386 | /** |
| 1387 | - * Alias for self::get_total_fees(). |
|
| 1388 | - * |
|
| 1389 | - * @since 1.0.19 |
|
| 1390 | - * @param string $context View or edit context. |
|
| 1391 | - * @return float |
|
| 1392 | - */ |
|
| 1393 | - public function get_fees_total( $context = 'view' ) { |
|
| 1394 | - return $this->get_total_fees( $context ); |
|
| 1387 | + * Alias for self::get_total_fees(). |
|
| 1388 | + * |
|
| 1389 | + * @since 1.0.19 |
|
| 1390 | + * @param string $context View or edit context. |
|
| 1391 | + * @return float |
|
| 1392 | + */ |
|
| 1393 | + public function get_fees_total( $context = 'view' ) { |
|
| 1394 | + return $this->get_total_fees( $context ); |
|
| 1395 | 1395 | } |
| 1396 | 1396 | |
| 1397 | 1397 | /** |
| 1398 | - * Get the invoice total. |
|
| 1399 | - * |
|
| 1400 | - * @since 1.0.19 |
|
| 1398 | + * Get the invoice total. |
|
| 1399 | + * |
|
| 1400 | + * @since 1.0.19 |
|
| 1401 | 1401 | * @return float |
| 1402 | - */ |
|
| 1403 | - public function get_total() { |
|
| 1404 | - $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
|
| 1405 | - return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
| 1406 | - } |
|
| 1402 | + */ |
|
| 1403 | + public function get_total() { |
|
| 1404 | + $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
|
| 1405 | + return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
| 1406 | + } |
|
| 1407 | 1407 | |
| 1408 | - /** |
|
| 1409 | - * Get the invoice totals. |
|
| 1410 | - * |
|
| 1411 | - * @since 1.0.19 |
|
| 1408 | + /** |
|
| 1409 | + * Get the invoice totals. |
|
| 1410 | + * |
|
| 1411 | + * @since 1.0.19 |
|
| 1412 | 1412 | * @return float |
| 1413 | - */ |
|
| 1414 | - public function get_totals() { |
|
| 1415 | - return $this->totals; |
|
| 1413 | + */ |
|
| 1414 | + public function get_totals() { |
|
| 1415 | + return $this->totals; |
|
| 1416 | 1416 | } |
| 1417 | 1417 | |
| 1418 | 1418 | /** |
| 1419 | - * Get the initial invoice total. |
|
| 1420 | - * |
|
| 1421 | - * @since 1.0.19 |
|
| 1419 | + * Get the initial invoice total. |
|
| 1420 | + * |
|
| 1421 | + * @since 1.0.19 |
|
| 1422 | 1422 | * @param string $context View or edit context. |
| 1423 | 1423 | * @return float |
| 1424 | - */ |
|
| 1424 | + */ |
|
| 1425 | 1425 | public function get_initial_total() { |
| 1426 | 1426 | |
| 1427 | - if ( empty( $this->totals ) ) { |
|
| 1428 | - $this->recalculate_total(); |
|
| 1429 | - } |
|
| 1427 | + if ( empty( $this->totals ) ) { |
|
| 1428 | + $this->recalculate_total(); |
|
| 1429 | + } |
|
| 1430 | 1430 | |
| 1431 | - $tax = $this->totals['tax']['initial']; |
|
| 1432 | - $fee = $this->totals['fee']['initial']; |
|
| 1433 | - $discount = $this->totals['discount']['initial']; |
|
| 1434 | - $subtotal = $this->totals['subtotal']['initial']; |
|
| 1435 | - $total = $tax + $fee - $discount + $subtotal; |
|
| 1431 | + $tax = $this->totals['tax']['initial']; |
|
| 1432 | + $fee = $this->totals['fee']['initial']; |
|
| 1433 | + $discount = $this->totals['discount']['initial']; |
|
| 1434 | + $subtotal = $this->totals['subtotal']['initial']; |
|
| 1435 | + $total = $tax + $fee - $discount + $subtotal; |
|
| 1436 | 1436 | |
| 1437 | - if ( 0 > $total ) { |
|
| 1438 | - $total = 0; |
|
| 1439 | - } |
|
| 1437 | + if ( 0 > $total ) { |
|
| 1438 | + $total = 0; |
|
| 1439 | + } |
|
| 1440 | 1440 | |
| 1441 | 1441 | return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
| 1442 | - } |
|
| 1442 | + } |
|
| 1443 | 1443 | |
| 1444 | - /** |
|
| 1445 | - * Get the recurring invoice total. |
|
| 1446 | - * |
|
| 1447 | - * @since 1.0.19 |
|
| 1444 | + /** |
|
| 1445 | + * Get the recurring invoice total. |
|
| 1446 | + * |
|
| 1447 | + * @since 1.0.19 |
|
| 1448 | 1448 | * @param string $context View or edit context. |
| 1449 | 1449 | * @return float |
| 1450 | - */ |
|
| 1450 | + */ |
|
| 1451 | 1451 | public function get_recurring_total() { |
| 1452 | 1452 | |
| 1453 | - if ( empty( $this->totals ) ) { |
|
| 1454 | - $this->recalculate_total(); |
|
| 1455 | - } |
|
| 1453 | + if ( empty( $this->totals ) ) { |
|
| 1454 | + $this->recalculate_total(); |
|
| 1455 | + } |
|
| 1456 | 1456 | |
| 1457 | - $tax = $this->totals['tax']['recurring']; |
|
| 1458 | - $fee = $this->totals['fee']['recurring']; |
|
| 1459 | - $discount = $this->totals['discount']['recurring']; |
|
| 1460 | - $subtotal = $this->totals['subtotal']['recurring']; |
|
| 1461 | - $total = $tax + $fee - $discount + $subtotal; |
|
| 1457 | + $tax = $this->totals['tax']['recurring']; |
|
| 1458 | + $fee = $this->totals['fee']['recurring']; |
|
| 1459 | + $discount = $this->totals['discount']['recurring']; |
|
| 1460 | + $subtotal = $this->totals['subtotal']['recurring']; |
|
| 1461 | + $total = $tax + $fee - $discount + $subtotal; |
|
| 1462 | 1462 | |
| 1463 | - if ( 0 > $total ) { |
|
| 1464 | - $total = 0; |
|
| 1465 | - } |
|
| 1463 | + if ( 0 > $total ) { |
|
| 1464 | + $total = 0; |
|
| 1465 | + } |
|
| 1466 | 1466 | |
| 1467 | 1467 | return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
| 1468 | - } |
|
| 1468 | + } |
|
| 1469 | 1469 | |
| 1470 | - /** |
|
| 1471 | - * Returns recurring payment details. |
|
| 1472 | - * |
|
| 1473 | - * @since 1.0.19 |
|
| 1470 | + /** |
|
| 1471 | + * Returns recurring payment details. |
|
| 1472 | + * |
|
| 1473 | + * @since 1.0.19 |
|
| 1474 | 1474 | * @param string $field Optionally provide a field to return. |
| 1475 | - * @param string $currency Whether to include the currency. |
|
| 1475 | + * @param string $currency Whether to include the currency. |
|
| 1476 | 1476 | * @return float |
| 1477 | - */ |
|
| 1477 | + */ |
|
| 1478 | 1478 | public function get_recurring_details( $field = '', $currency = false ) { |
| 1479 | 1479 | |
| 1480 | - // Maybe recalculate totals. |
|
| 1481 | - if ( empty( $this->totals ) ) { |
|
| 1482 | - $this->recalculate_total(); |
|
| 1483 | - } |
|
| 1480 | + // Maybe recalculate totals. |
|
| 1481 | + if ( empty( $this->totals ) ) { |
|
| 1482 | + $this->recalculate_total(); |
|
| 1483 | + } |
|
| 1484 | 1484 | |
| 1485 | - // Prepare recurring totals. |
|
| 1485 | + // Prepare recurring totals. |
|
| 1486 | 1486 | $data = apply_filters( |
| 1487 | - 'wpinv_get_invoice_recurring_details', |
|
| 1488 | - array( |
|
| 1489 | - 'cart_details' => $this->get_cart_details(), |
|
| 1490 | - 'subtotal' => $this->totals['subtotal']['recurring'], |
|
| 1491 | - 'discount' => $this->totals['discount']['recurring'], |
|
| 1492 | - 'tax' => $this->totals['tax']['recurring'], |
|
| 1493 | - 'fee' => $this->totals['fee']['recurring'], |
|
| 1494 | - 'total' => $this->get_recurring_total(), |
|
| 1495 | - ), |
|
| 1496 | - $this, |
|
| 1497 | - $field, |
|
| 1498 | - $currency |
|
| 1499 | - ); |
|
| 1487 | + 'wpinv_get_invoice_recurring_details', |
|
| 1488 | + array( |
|
| 1489 | + 'cart_details' => $this->get_cart_details(), |
|
| 1490 | + 'subtotal' => $this->totals['subtotal']['recurring'], |
|
| 1491 | + 'discount' => $this->totals['discount']['recurring'], |
|
| 1492 | + 'tax' => $this->totals['tax']['recurring'], |
|
| 1493 | + 'fee' => $this->totals['fee']['recurring'], |
|
| 1494 | + 'total' => $this->get_recurring_total(), |
|
| 1495 | + ), |
|
| 1496 | + $this, |
|
| 1497 | + $field, |
|
| 1498 | + $currency |
|
| 1499 | + ); |
|
| 1500 | 1500 | |
| 1501 | 1501 | if ( isset( $data[$field] ) ) { |
| 1502 | 1502 | return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
@@ -1506,156 +1506,156 @@ discard block |
||
| 1506 | 1506 | } |
| 1507 | 1507 | |
| 1508 | 1508 | /** |
| 1509 | - * Get the invoice fees. |
|
| 1510 | - * |
|
| 1511 | - * @since 1.0.19 |
|
| 1512 | - * @param string $context View or edit context. |
|
| 1513 | - * @return array |
|
| 1514 | - */ |
|
| 1515 | - public function get_fees( $context = 'view' ) { |
|
| 1516 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1509 | + * Get the invoice fees. |
|
| 1510 | + * |
|
| 1511 | + * @since 1.0.19 |
|
| 1512 | + * @param string $context View or edit context. |
|
| 1513 | + * @return array |
|
| 1514 | + */ |
|
| 1515 | + public function get_fees( $context = 'view' ) { |
|
| 1516 | + return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1517 | 1517 | } |
| 1518 | 1518 | |
| 1519 | 1519 | /** |
| 1520 | - * Get the invoice discounts. |
|
| 1521 | - * |
|
| 1522 | - * @since 1.0.19 |
|
| 1523 | - * @param string $context View or edit context. |
|
| 1524 | - * @return array |
|
| 1525 | - */ |
|
| 1526 | - public function get_discounts( $context = 'view' ) { |
|
| 1527 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1520 | + * Get the invoice discounts. |
|
| 1521 | + * |
|
| 1522 | + * @since 1.0.19 |
|
| 1523 | + * @param string $context View or edit context. |
|
| 1524 | + * @return array |
|
| 1525 | + */ |
|
| 1526 | + public function get_discounts( $context = 'view' ) { |
|
| 1527 | + return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1528 | 1528 | } |
| 1529 | 1529 | |
| 1530 | 1530 | /** |
| 1531 | - * Get the invoice taxes. |
|
| 1532 | - * |
|
| 1533 | - * @since 1.0.19 |
|
| 1534 | - * @param string $context View or edit context. |
|
| 1535 | - * @return array |
|
| 1536 | - */ |
|
| 1537 | - public function get_taxes( $context = 'view' ) { |
|
| 1538 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1531 | + * Get the invoice taxes. |
|
| 1532 | + * |
|
| 1533 | + * @since 1.0.19 |
|
| 1534 | + * @param string $context View or edit context. |
|
| 1535 | + * @return array |
|
| 1536 | + */ |
|
| 1537 | + public function get_taxes( $context = 'view' ) { |
|
| 1538 | + return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1539 | 1539 | } |
| 1540 | 1540 | |
| 1541 | 1541 | /** |
| 1542 | - * Get the invoice items. |
|
| 1543 | - * |
|
| 1544 | - * @since 1.0.19 |
|
| 1545 | - * @param string $context View or edit context. |
|
| 1546 | - * @return GetPaid_Form_Item[] |
|
| 1547 | - */ |
|
| 1548 | - public function get_items( $context = 'view' ) { |
|
| 1542 | + * Get the invoice items. |
|
| 1543 | + * |
|
| 1544 | + * @since 1.0.19 |
|
| 1545 | + * @param string $context View or edit context. |
|
| 1546 | + * @return GetPaid_Form_Item[] |
|
| 1547 | + */ |
|
| 1548 | + public function get_items( $context = 'view' ) { |
|
| 1549 | 1549 | return $this->get_prop( 'items', $context ); |
| 1550 | 1550 | } |
| 1551 | 1551 | |
| 1552 | 1552 | /** |
| 1553 | - * Get the invoice's payment form. |
|
| 1554 | - * |
|
| 1555 | - * @since 1.0.19 |
|
| 1556 | - * @param string $context View or edit context. |
|
| 1557 | - * @return int |
|
| 1558 | - */ |
|
| 1559 | - public function get_payment_form( $context = 'view' ) { |
|
| 1560 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1553 | + * Get the invoice's payment form. |
|
| 1554 | + * |
|
| 1555 | + * @since 1.0.19 |
|
| 1556 | + * @param string $context View or edit context. |
|
| 1557 | + * @return int |
|
| 1558 | + */ |
|
| 1559 | + public function get_payment_form( $context = 'view' ) { |
|
| 1560 | + return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1561 | 1561 | } |
| 1562 | 1562 | |
| 1563 | 1563 | /** |
| 1564 | - * Get the invoice's submission id. |
|
| 1565 | - * |
|
| 1566 | - * @since 1.0.19 |
|
| 1567 | - * @param string $context View or edit context. |
|
| 1568 | - * @return string |
|
| 1569 | - */ |
|
| 1570 | - public function get_submission_id( $context = 'view' ) { |
|
| 1571 | - return $this->get_prop( 'submission_id', $context ); |
|
| 1564 | + * Get the invoice's submission id. |
|
| 1565 | + * |
|
| 1566 | + * @since 1.0.19 |
|
| 1567 | + * @param string $context View or edit context. |
|
| 1568 | + * @return string |
|
| 1569 | + */ |
|
| 1570 | + public function get_submission_id( $context = 'view' ) { |
|
| 1571 | + return $this->get_prop( 'submission_id', $context ); |
|
| 1572 | 1572 | } |
| 1573 | 1573 | |
| 1574 | 1574 | /** |
| 1575 | - * Get the invoice's discount code. |
|
| 1576 | - * |
|
| 1577 | - * @since 1.0.19 |
|
| 1578 | - * @param string $context View or edit context. |
|
| 1579 | - * @return string |
|
| 1580 | - */ |
|
| 1581 | - public function get_discount_code( $context = 'view' ) { |
|
| 1582 | - return $this->get_prop( 'discount_code', $context ); |
|
| 1575 | + * Get the invoice's discount code. |
|
| 1576 | + * |
|
| 1577 | + * @since 1.0.19 |
|
| 1578 | + * @param string $context View or edit context. |
|
| 1579 | + * @return string |
|
| 1580 | + */ |
|
| 1581 | + public function get_discount_code( $context = 'view' ) { |
|
| 1582 | + return $this->get_prop( 'discount_code', $context ); |
|
| 1583 | 1583 | } |
| 1584 | 1584 | |
| 1585 | 1585 | /** |
| 1586 | - * Get the invoice's gateway. |
|
| 1587 | - * |
|
| 1588 | - * @since 1.0.19 |
|
| 1589 | - * @param string $context View or edit context. |
|
| 1590 | - * @return string |
|
| 1591 | - */ |
|
| 1592 | - public function get_gateway( $context = 'view' ) { |
|
| 1593 | - return $this->get_prop( 'gateway', $context ); |
|
| 1586 | + * Get the invoice's gateway. |
|
| 1587 | + * |
|
| 1588 | + * @since 1.0.19 |
|
| 1589 | + * @param string $context View or edit context. |
|
| 1590 | + * @return string |
|
| 1591 | + */ |
|
| 1592 | + public function get_gateway( $context = 'view' ) { |
|
| 1593 | + return $this->get_prop( 'gateway', $context ); |
|
| 1594 | 1594 | } |
| 1595 | 1595 | |
| 1596 | 1596 | /** |
| 1597 | - * Get the invoice's gateway display title. |
|
| 1598 | - * |
|
| 1599 | - * @since 1.0.19 |
|
| 1600 | - * @return string |
|
| 1601 | - */ |
|
| 1597 | + * Get the invoice's gateway display title. |
|
| 1598 | + * |
|
| 1599 | + * @since 1.0.19 |
|
| 1600 | + * @return string |
|
| 1601 | + */ |
|
| 1602 | 1602 | public function get_gateway_title() { |
| 1603 | 1603 | $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
| 1604 | 1604 | return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
| 1605 | 1605 | } |
| 1606 | 1606 | |
| 1607 | 1607 | /** |
| 1608 | - * Get the invoice's transaction id. |
|
| 1609 | - * |
|
| 1610 | - * @since 1.0.19 |
|
| 1611 | - * @param string $context View or edit context. |
|
| 1612 | - * @return string |
|
| 1613 | - */ |
|
| 1614 | - public function get_transaction_id( $context = 'view' ) { |
|
| 1615 | - return $this->get_prop( 'transaction_id', $context ); |
|
| 1608 | + * Get the invoice's transaction id. |
|
| 1609 | + * |
|
| 1610 | + * @since 1.0.19 |
|
| 1611 | + * @param string $context View or edit context. |
|
| 1612 | + * @return string |
|
| 1613 | + */ |
|
| 1614 | + public function get_transaction_id( $context = 'view' ) { |
|
| 1615 | + return $this->get_prop( 'transaction_id', $context ); |
|
| 1616 | 1616 | } |
| 1617 | 1617 | |
| 1618 | 1618 | /** |
| 1619 | - * Get the invoice's currency. |
|
| 1620 | - * |
|
| 1621 | - * @since 1.0.19 |
|
| 1622 | - * @param string $context View or edit context. |
|
| 1623 | - * @return string |
|
| 1624 | - */ |
|
| 1625 | - public function get_currency( $context = 'view' ) { |
|
| 1619 | + * Get the invoice's currency. |
|
| 1620 | + * |
|
| 1621 | + * @since 1.0.19 |
|
| 1622 | + * @param string $context View or edit context. |
|
| 1623 | + * @return string |
|
| 1624 | + */ |
|
| 1625 | + public function get_currency( $context = 'view' ) { |
|
| 1626 | 1626 | $currency = $this->get_prop( 'currency', $context ); |
| 1627 | 1627 | return empty( $currency ) ? wpinv_get_currency() : $currency; |
| 1628 | 1628 | } |
| 1629 | 1629 | |
| 1630 | 1630 | /** |
| 1631 | - * Checks if we are charging taxes for this invoice. |
|
| 1632 | - * |
|
| 1633 | - * @since 1.0.19 |
|
| 1634 | - * @param string $context View or edit context. |
|
| 1635 | - * @return bool |
|
| 1636 | - */ |
|
| 1637 | - public function get_disable_taxes( $context = 'view' ) { |
|
| 1631 | + * Checks if we are charging taxes for this invoice. |
|
| 1632 | + * |
|
| 1633 | + * @since 1.0.19 |
|
| 1634 | + * @param string $context View or edit context. |
|
| 1635 | + * @return bool |
|
| 1636 | + */ |
|
| 1637 | + public function get_disable_taxes( $context = 'view' ) { |
|
| 1638 | 1638 | return (bool) $this->get_prop( 'disable_taxes', $context ); |
| 1639 | 1639 | } |
| 1640 | 1640 | |
| 1641 | 1641 | /** |
| 1642 | - * Retrieves the subscription id for an invoice. |
|
| 1643 | - * |
|
| 1644 | - * @since 1.0.19 |
|
| 1645 | - * @param string $context View or edit context. |
|
| 1646 | - * @return int |
|
| 1647 | - */ |
|
| 1642 | + * Retrieves the subscription id for an invoice. |
|
| 1643 | + * |
|
| 1644 | + * @since 1.0.19 |
|
| 1645 | + * @param string $context View or edit context. |
|
| 1646 | + * @return int |
|
| 1647 | + */ |
|
| 1648 | 1648 | public function get_subscription_id( $context = 'view' ) { |
| 1649 | - return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
| 1650 | - } |
|
| 1651 | - |
|
| 1652 | - /** |
|
| 1653 | - * Retrieves the remote subscription id for an invoice. |
|
| 1654 | - * |
|
| 1655 | - * @since 1.0.19 |
|
| 1656 | - * @param string $context View or edit context. |
|
| 1657 | - * @return int |
|
| 1658 | - */ |
|
| 1649 | + return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
| 1650 | + } |
|
| 1651 | + |
|
| 1652 | + /** |
|
| 1653 | + * Retrieves the remote subscription id for an invoice. |
|
| 1654 | + * |
|
| 1655 | + * @since 1.0.19 |
|
| 1656 | + * @param string $context View or edit context. |
|
| 1657 | + * @return int |
|
| 1658 | + */ |
|
| 1659 | 1659 | public function get_remote_subscription_id( $context = 'view' ) { |
| 1660 | 1660 | $subscription_id = $this->get_prop( 'remote_subscription_id', $context ); |
| 1661 | 1661 | |
@@ -1668,12 +1668,12 @@ discard block |
||
| 1668 | 1668 | } |
| 1669 | 1669 | |
| 1670 | 1670 | /** |
| 1671 | - * Retrieves the payment meta for an invoice. |
|
| 1672 | - * |
|
| 1673 | - * @since 1.0.19 |
|
| 1674 | - * @param string $context View or edit context. |
|
| 1675 | - * @return array |
|
| 1676 | - */ |
|
| 1671 | + * Retrieves the payment meta for an invoice. |
|
| 1672 | + * |
|
| 1673 | + * @since 1.0.19 |
|
| 1674 | + * @param string $context View or edit context. |
|
| 1675 | + * @return array |
|
| 1676 | + */ |
|
| 1677 | 1677 | public function get_payment_meta( $context = 'view' ) { |
| 1678 | 1678 | |
| 1679 | 1679 | return array( |
@@ -1693,31 +1693,31 @@ discard block |
||
| 1693 | 1693 | } |
| 1694 | 1694 | |
| 1695 | 1695 | /** |
| 1696 | - * Retrieves the cart details for an invoice. |
|
| 1697 | - * |
|
| 1698 | - * @since 1.0.19 |
|
| 1699 | - * @return array |
|
| 1700 | - */ |
|
| 1696 | + * Retrieves the cart details for an invoice. |
|
| 1697 | + * |
|
| 1698 | + * @since 1.0.19 |
|
| 1699 | + * @return array |
|
| 1700 | + */ |
|
| 1701 | 1701 | public function get_cart_details() { |
| 1702 | 1702 | $items = $this->get_items(); |
| 1703 | 1703 | $cart_details = array(); |
| 1704 | 1704 | |
| 1705 | 1705 | foreach ( $items as $item_id => $item ) { |
| 1706 | - $item->invoice_id = $this->get_id(); |
|
| 1706 | + $item->invoice_id = $this->get_id(); |
|
| 1707 | 1707 | $cart_details[] = $item->prepare_data_for_saving(); |
| 1708 | 1708 | } |
| 1709 | 1709 | |
| 1710 | 1710 | return $cart_details; |
| 1711 | - } |
|
| 1711 | + } |
|
| 1712 | 1712 | |
| 1713 | - /** |
|
| 1714 | - * Retrieves the recurring item. |
|
| 1715 | - * |
|
| 1716 | - * @return null|GetPaid_Form_Item|int |
|
| 1717 | - */ |
|
| 1718 | - public function get_recurring( $object = false ) { |
|
| 1713 | + /** |
|
| 1714 | + * Retrieves the recurring item. |
|
| 1715 | + * |
|
| 1716 | + * @return null|GetPaid_Form_Item|int |
|
| 1717 | + */ |
|
| 1718 | + public function get_recurring( $object = false ) { |
|
| 1719 | 1719 | |
| 1720 | - // Are we returning an object? |
|
| 1720 | + // Are we returning an object? |
|
| 1721 | 1721 | if ( $object ) { |
| 1722 | 1722 | return $this->get_item( $this->recurring_item ); |
| 1723 | 1723 | } |
@@ -1725,114 +1725,114 @@ discard block |
||
| 1725 | 1725 | return $this->recurring_item; |
| 1726 | 1726 | } |
| 1727 | 1727 | |
| 1728 | - /** |
|
| 1729 | - * Retrieves the subscription name. |
|
| 1730 | - * |
|
| 1731 | - * @since 1.0.19 |
|
| 1732 | - * @return string |
|
| 1733 | - */ |
|
| 1734 | - public function get_subscription_name() { |
|
| 1728 | + /** |
|
| 1729 | + * Retrieves the subscription name. |
|
| 1730 | + * |
|
| 1731 | + * @since 1.0.19 |
|
| 1732 | + * @return string |
|
| 1733 | + */ |
|
| 1734 | + public function get_subscription_name() { |
|
| 1735 | 1735 | |
| 1736 | - // Retrieve the recurring name |
|
| 1736 | + // Retrieve the recurring name |
|
| 1737 | 1737 | $item = $this->get_recurring( true ); |
| 1738 | 1738 | |
| 1739 | - // Abort if it does not exist. |
|
| 1739 | + // Abort if it does not exist. |
|
| 1740 | 1740 | if ( empty( $item ) ) { |
| 1741 | 1741 | return ''; |
| 1742 | 1742 | } |
| 1743 | 1743 | |
| 1744 | - // Return the item name. |
|
| 1744 | + // Return the item name. |
|
| 1745 | 1745 | return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
| 1746 | - } |
|
| 1747 | - |
|
| 1748 | - /** |
|
| 1749 | - * Retrieves the view url. |
|
| 1750 | - * |
|
| 1751 | - * @since 1.0.19 |
|
| 1752 | - * @return string |
|
| 1753 | - */ |
|
| 1754 | - public function get_view_url() { |
|
| 1746 | + } |
|
| 1747 | + |
|
| 1748 | + /** |
|
| 1749 | + * Retrieves the view url. |
|
| 1750 | + * |
|
| 1751 | + * @since 1.0.19 |
|
| 1752 | + * @return string |
|
| 1753 | + */ |
|
| 1754 | + public function get_view_url() { |
|
| 1755 | 1755 | $invoice_url = get_permalink( $this->get_id() ); |
| 1756 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1756 | + $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1757 | 1757 | return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
| 1758 | - } |
|
| 1758 | + } |
|
| 1759 | 1759 | |
| 1760 | - /** |
|
| 1761 | - * Retrieves the payment url. |
|
| 1762 | - * |
|
| 1763 | - * @since 1.0.19 |
|
| 1764 | - * @return string |
|
| 1765 | - */ |
|
| 1766 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1760 | + /** |
|
| 1761 | + * Retrieves the payment url. |
|
| 1762 | + * |
|
| 1763 | + * @since 1.0.19 |
|
| 1764 | + * @return string |
|
| 1765 | + */ |
|
| 1766 | + public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1767 | 1767 | |
| 1768 | - // Retrieve the checkout url. |
|
| 1768 | + // Retrieve the checkout url. |
|
| 1769 | 1769 | $pay_url = wpinv_get_checkout_uri(); |
| 1770 | 1770 | |
| 1771 | - // Maybe force ssl. |
|
| 1771 | + // Maybe force ssl. |
|
| 1772 | 1772 | if ( is_ssl() ) { |
| 1773 | 1773 | $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
| 1774 | 1774 | } |
| 1775 | 1775 | |
| 1776 | - // Add the invoice key. |
|
| 1777 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1776 | + // Add the invoice key. |
|
| 1777 | + $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1778 | 1778 | |
| 1779 | - // (Maybe?) add a secret |
|
| 1779 | + // (Maybe?) add a secret |
|
| 1780 | 1780 | if ( $secret ) { |
| 1781 | 1781 | $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
| 1782 | 1782 | } |
| 1783 | 1783 | |
| 1784 | 1784 | return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
| 1785 | - } |
|
| 1785 | + } |
|
| 1786 | 1786 | |
| 1787 | - /** |
|
| 1788 | - * Retrieves the receipt url. |
|
| 1789 | - * |
|
| 1790 | - * @since 1.0.19 |
|
| 1791 | - * @return string |
|
| 1792 | - */ |
|
| 1793 | - public function get_receipt_url() { |
|
| 1794 | - |
|
| 1795 | - // Retrieve the checkout url. |
|
| 1787 | + /** |
|
| 1788 | + * Retrieves the receipt url. |
|
| 1789 | + * |
|
| 1790 | + * @since 1.0.19 |
|
| 1791 | + * @return string |
|
| 1792 | + */ |
|
| 1793 | + public function get_receipt_url() { |
|
| 1794 | + |
|
| 1795 | + // Retrieve the checkout url. |
|
| 1796 | 1796 | $receipt_url = wpinv_get_success_page_uri(); |
| 1797 | 1797 | |
| 1798 | - // Maybe force ssl. |
|
| 1798 | + // Maybe force ssl. |
|
| 1799 | 1799 | if ( is_ssl() ) { |
| 1800 | 1800 | $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
| 1801 | 1801 | } |
| 1802 | 1802 | |
| 1803 | - // Add the invoice key. |
|
| 1804 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1803 | + // Add the invoice key. |
|
| 1804 | + $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1805 | 1805 | |
| 1806 | 1806 | return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
| 1807 | - } |
|
| 1807 | + } |
|
| 1808 | 1808 | |
| 1809 | - /** |
|
| 1810 | - * Retrieves the default status. |
|
| 1811 | - * |
|
| 1812 | - * @since 1.0.19 |
|
| 1813 | - * @return string |
|
| 1814 | - */ |
|
| 1815 | - public function get_default_status() { |
|
| 1816 | - |
|
| 1817 | - $type = $this->get_type(); |
|
| 1818 | - $status = "wpi-$type-pending"; |
|
| 1819 | - return str_replace( '-invoice', '', $status ); |
|
| 1820 | - |
|
| 1821 | - } |
|
| 1822 | - |
|
| 1823 | - /** |
|
| 1824 | - * Magic method for accessing invoice properties. |
|
| 1825 | - * |
|
| 1826 | - * @since 1.0.15 |
|
| 1827 | - * @access public |
|
| 1828 | - * |
|
| 1829 | - * @param string $key Discount data to retrieve |
|
| 1830 | - * @param string $context View or edit context. |
|
| 1831 | - * @return mixed Value of the given invoice property (if set). |
|
| 1832 | - */ |
|
| 1833 | - public function get( $key, $context = 'view' ) { |
|
| 1809 | + /** |
|
| 1810 | + * Retrieves the default status. |
|
| 1811 | + * |
|
| 1812 | + * @since 1.0.19 |
|
| 1813 | + * @return string |
|
| 1814 | + */ |
|
| 1815 | + public function get_default_status() { |
|
| 1816 | + |
|
| 1817 | + $type = $this->get_type(); |
|
| 1818 | + $status = "wpi-$type-pending"; |
|
| 1819 | + return str_replace( '-invoice', '', $status ); |
|
| 1820 | + |
|
| 1821 | + } |
|
| 1822 | + |
|
| 1823 | + /** |
|
| 1824 | + * Magic method for accessing invoice properties. |
|
| 1825 | + * |
|
| 1826 | + * @since 1.0.15 |
|
| 1827 | + * @access public |
|
| 1828 | + * |
|
| 1829 | + * @param string $key Discount data to retrieve |
|
| 1830 | + * @param string $context View or edit context. |
|
| 1831 | + * @return mixed Value of the given invoice property (if set). |
|
| 1832 | + */ |
|
| 1833 | + public function get( $key, $context = 'view' ) { |
|
| 1834 | 1834 | return $this->get_prop( $key, $context ); |
| 1835 | - } |
|
| 1835 | + } |
|
| 1836 | 1836 | |
| 1837 | 1837 | /* |
| 1838 | 1838 | |-------------------------------------------------------------------------- |
@@ -1845,130 +1845,130 @@ discard block |
||
| 1845 | 1845 | */ |
| 1846 | 1846 | |
| 1847 | 1847 | /** |
| 1848 | - * Magic method for setting invoice properties. |
|
| 1849 | - * |
|
| 1850 | - * @since 1.0.19 |
|
| 1851 | - * @access public |
|
| 1852 | - * |
|
| 1853 | - * @param string $key Discount data to retrieve |
|
| 1854 | - * @param mixed $value new value. |
|
| 1855 | - * @return mixed Value of the given invoice property (if set). |
|
| 1856 | - */ |
|
| 1857 | - public function set( $key, $value ) { |
|
| 1848 | + * Magic method for setting invoice properties. |
|
| 1849 | + * |
|
| 1850 | + * @since 1.0.19 |
|
| 1851 | + * @access public |
|
| 1852 | + * |
|
| 1853 | + * @param string $key Discount data to retrieve |
|
| 1854 | + * @param mixed $value new value. |
|
| 1855 | + * @return mixed Value of the given invoice property (if set). |
|
| 1856 | + */ |
|
| 1857 | + public function set( $key, $value ) { |
|
| 1858 | 1858 | |
| 1859 | 1859 | $setter = "set_$key"; |
| 1860 | 1860 | if ( is_callable( array( $this, $setter ) ) ) { |
| 1861 | 1861 | $this->{$setter}( $value ); |
| 1862 | 1862 | } |
| 1863 | 1863 | |
| 1864 | - } |
|
| 1864 | + } |
|
| 1865 | 1865 | |
| 1866 | - /** |
|
| 1867 | - * Sets item status. |
|
| 1868 | - * |
|
| 1869 | - * @since 1.0.19 |
|
| 1870 | - * @param string $new_status New status. |
|
| 1871 | - * @param string $note Optional note to add. |
|
| 1872 | - * @param bool $manual_update Is this a manual status change?. |
|
| 1873 | - * @return array details of change. |
|
| 1874 | - */ |
|
| 1875 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1876 | - $old_status = $this->get_status(); |
|
| 1866 | + /** |
|
| 1867 | + * Sets item status. |
|
| 1868 | + * |
|
| 1869 | + * @since 1.0.19 |
|
| 1870 | + * @param string $new_status New status. |
|
| 1871 | + * @param string $note Optional note to add. |
|
| 1872 | + * @param bool $manual_update Is this a manual status change?. |
|
| 1873 | + * @return array details of change. |
|
| 1874 | + */ |
|
| 1875 | + public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1876 | + $old_status = $this->get_status(); |
|
| 1877 | 1877 | |
| 1878 | - $statuses = $this->get_all_statuses(); |
|
| 1878 | + $statuses = $this->get_all_statuses(); |
|
| 1879 | 1879 | |
| 1880 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1881 | - unset( $statuses[ 'draft' ] ); |
|
| 1882 | - } |
|
| 1880 | + if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1881 | + unset( $statuses[ 'draft' ] ); |
|
| 1882 | + } |
|
| 1883 | 1883 | |
| 1884 | - $this->set_prop( 'status', $new_status ); |
|
| 1884 | + $this->set_prop( 'status', $new_status ); |
|
| 1885 | 1885 | |
| 1886 | - // If setting the status, ensure it's set to a valid status. |
|
| 1887 | - if ( true === $this->object_read ) { |
|
| 1886 | + // If setting the status, ensure it's set to a valid status. |
|
| 1887 | + if ( true === $this->object_read ) { |
|
| 1888 | 1888 | |
| 1889 | - // Only allow valid new status. |
|
| 1890 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1891 | - $new_status = $this->get_default_status(); |
|
| 1892 | - } |
|
| 1889 | + // Only allow valid new status. |
|
| 1890 | + if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1891 | + $new_status = $this->get_default_status(); |
|
| 1892 | + } |
|
| 1893 | 1893 | |
| 1894 | - // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
|
| 1895 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1896 | - $old_status = $this->get_default_status(); |
|
| 1897 | - } |
|
| 1894 | + // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
|
| 1895 | + if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1896 | + $old_status = $this->get_default_status(); |
|
| 1897 | + } |
|
| 1898 | 1898 | |
| 1899 | - // Paid - Renewal (i.e when duplicating a parent invoice ) |
|
| 1900 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
| 1901 | - $old_status = 'wpi-pending'; |
|
| 1902 | - } |
|
| 1899 | + // Paid - Renewal (i.e when duplicating a parent invoice ) |
|
| 1900 | + if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
| 1901 | + $old_status = 'wpi-pending'; |
|
| 1902 | + } |
|
| 1903 | 1903 | |
| 1904 | - } |
|
| 1904 | + } |
|
| 1905 | 1905 | |
| 1906 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
| 1907 | - $this->status_transition = array( |
|
| 1908 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1909 | - 'to' => $new_status, |
|
| 1910 | - 'note' => $note, |
|
| 1911 | - 'manual' => (bool) $manual_update, |
|
| 1912 | - ); |
|
| 1906 | + if ( true === $this->object_read && $old_status !== $new_status ) { |
|
| 1907 | + $this->status_transition = array( |
|
| 1908 | + 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1909 | + 'to' => $new_status, |
|
| 1910 | + 'note' => $note, |
|
| 1911 | + 'manual' => (bool) $manual_update, |
|
| 1912 | + ); |
|
| 1913 | 1913 | |
| 1914 | - if ( $manual_update ) { |
|
| 1915 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1916 | - } |
|
| 1914 | + if ( $manual_update ) { |
|
| 1915 | + do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1916 | + } |
|
| 1917 | 1917 | |
| 1918 | - $this->maybe_set_date_paid(); |
|
| 1918 | + $this->maybe_set_date_paid(); |
|
| 1919 | 1919 | |
| 1920 | - } |
|
| 1920 | + } |
|
| 1921 | 1921 | |
| 1922 | - return array( |
|
| 1923 | - 'from' => $old_status, |
|
| 1924 | - 'to' => $new_status, |
|
| 1925 | - ); |
|
| 1926 | - } |
|
| 1922 | + return array( |
|
| 1923 | + 'from' => $old_status, |
|
| 1924 | + 'to' => $new_status, |
|
| 1925 | + ); |
|
| 1926 | + } |
|
| 1927 | 1927 | |
| 1928 | - /** |
|
| 1929 | - * Maybe set date paid. |
|
| 1930 | - * |
|
| 1931 | - * Sets the date paid variable when transitioning to the payment complete |
|
| 1932 | - * order status. |
|
| 1933 | - * |
|
| 1934 | - * @since 1.0.19 |
|
| 1935 | - */ |
|
| 1936 | - public function maybe_set_date_paid() { |
|
| 1928 | + /** |
|
| 1929 | + * Maybe set date paid. |
|
| 1930 | + * |
|
| 1931 | + * Sets the date paid variable when transitioning to the payment complete |
|
| 1932 | + * order status. |
|
| 1933 | + * |
|
| 1934 | + * @since 1.0.19 |
|
| 1935 | + */ |
|
| 1936 | + public function maybe_set_date_paid() { |
|
| 1937 | 1937 | |
| 1938 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 1939 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 1940 | - } |
|
| 1941 | - } |
|
| 1938 | + if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 1939 | + $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 1940 | + } |
|
| 1941 | + } |
|
| 1942 | 1942 | |
| 1943 | 1943 | /** |
| 1944 | - * Set parent invoice ID. |
|
| 1945 | - * |
|
| 1946 | - * @since 1.0.19 |
|
| 1947 | - */ |
|
| 1948 | - public function set_parent_id( $value ) { |
|
| 1949 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
| 1950 | - return; |
|
| 1951 | - } |
|
| 1952 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 1944 | + * Set parent invoice ID. |
|
| 1945 | + * |
|
| 1946 | + * @since 1.0.19 |
|
| 1947 | + */ |
|
| 1948 | + public function set_parent_id( $value ) { |
|
| 1949 | + if ( $value && ( $value === $this->get_id() ) ) { |
|
| 1950 | + return; |
|
| 1951 | + } |
|
| 1952 | + $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 1953 | 1953 | } |
| 1954 | 1954 | |
| 1955 | 1955 | /** |
| 1956 | - * Set plugin version when the invoice was created. |
|
| 1957 | - * |
|
| 1958 | - * @since 1.0.19 |
|
| 1959 | - */ |
|
| 1960 | - public function set_version( $value ) { |
|
| 1961 | - $this->set_prop( 'version', $value ); |
|
| 1956 | + * Set plugin version when the invoice was created. |
|
| 1957 | + * |
|
| 1958 | + * @since 1.0.19 |
|
| 1959 | + */ |
|
| 1960 | + public function set_version( $value ) { |
|
| 1961 | + $this->set_prop( 'version', $value ); |
|
| 1962 | 1962 | } |
| 1963 | - |
|
| 1964 | - /** |
|
| 1965 | - * Set date when the invoice was created. |
|
| 1966 | - * |
|
| 1967 | - * @since 1.0.19 |
|
| 1968 | - * @param string $value Value to set. |
|
| 1963 | + |
|
| 1964 | + /** |
|
| 1965 | + * Set date when the invoice was created. |
|
| 1966 | + * |
|
| 1967 | + * @since 1.0.19 |
|
| 1968 | + * @param string $value Value to set. |
|
| 1969 | 1969 | * @return bool Whether or not the date was set. |
| 1970 | - */ |
|
| 1971 | - public function set_date_created( $value ) { |
|
| 1970 | + */ |
|
| 1971 | + public function set_date_created( $value ) { |
|
| 1972 | 1972 | $date = strtotime( $value ); |
| 1973 | 1973 | |
| 1974 | 1974 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1981,13 +1981,13 @@ discard block |
||
| 1981 | 1981 | } |
| 1982 | 1982 | |
| 1983 | 1983 | /** |
| 1984 | - * Set date invoice due date. |
|
| 1985 | - * |
|
| 1986 | - * @since 1.0.19 |
|
| 1987 | - * @param string $value Value to set. |
|
| 1984 | + * Set date invoice due date. |
|
| 1985 | + * |
|
| 1986 | + * @since 1.0.19 |
|
| 1987 | + * @param string $value Value to set. |
|
| 1988 | 1988 | * @return bool Whether or not the date was set. |
| 1989 | - */ |
|
| 1990 | - public function set_due_date( $value ) { |
|
| 1989 | + */ |
|
| 1990 | + public function set_due_date( $value ) { |
|
| 1991 | 1991 | $date = strtotime( $value ); |
| 1992 | 1992 | |
| 1993 | 1993 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1995,29 +1995,29 @@ discard block |
||
| 1995 | 1995 | return true; |
| 1996 | 1996 | } |
| 1997 | 1997 | |
| 1998 | - $this->set_prop( 'due_date', '' ); |
|
| 1998 | + $this->set_prop( 'due_date', '' ); |
|
| 1999 | 1999 | return false; |
| 2000 | 2000 | |
| 2001 | 2001 | } |
| 2002 | 2002 | |
| 2003 | 2003 | /** |
| 2004 | - * Alias of self::set_due_date(). |
|
| 2005 | - * |
|
| 2006 | - * @since 1.0.19 |
|
| 2007 | - * @param string $value New name. |
|
| 2008 | - */ |
|
| 2009 | - public function set_date_due( $value ) { |
|
| 2010 | - $this->set_due_date( $value ); |
|
| 2004 | + * Alias of self::set_due_date(). |
|
| 2005 | + * |
|
| 2006 | + * @since 1.0.19 |
|
| 2007 | + * @param string $value New name. |
|
| 2008 | + */ |
|
| 2009 | + public function set_date_due( $value ) { |
|
| 2010 | + $this->set_due_date( $value ); |
|
| 2011 | 2011 | } |
| 2012 | 2012 | |
| 2013 | 2013 | /** |
| 2014 | - * Set date invoice was completed. |
|
| 2015 | - * |
|
| 2016 | - * @since 1.0.19 |
|
| 2017 | - * @param string $value Value to set. |
|
| 2014 | + * Set date invoice was completed. |
|
| 2015 | + * |
|
| 2016 | + * @since 1.0.19 |
|
| 2017 | + * @param string $value Value to set. |
|
| 2018 | 2018 | * @return bool Whether or not the date was set. |
| 2019 | - */ |
|
| 2020 | - public function set_completed_date( $value ) { |
|
| 2019 | + */ |
|
| 2020 | + public function set_completed_date( $value ) { |
|
| 2021 | 2021 | $date = strtotime( $value ); |
| 2022 | 2022 | |
| 2023 | 2023 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -2025,29 +2025,29 @@ discard block |
||
| 2025 | 2025 | return true; |
| 2026 | 2026 | } |
| 2027 | 2027 | |
| 2028 | - $this->set_prop( 'completed_date', '' ); |
|
| 2028 | + $this->set_prop( 'completed_date', '' ); |
|
| 2029 | 2029 | return false; |
| 2030 | 2030 | |
| 2031 | 2031 | } |
| 2032 | 2032 | |
| 2033 | 2033 | /** |
| 2034 | - * Alias of self::set_completed_date(). |
|
| 2035 | - * |
|
| 2036 | - * @since 1.0.19 |
|
| 2037 | - * @param string $value New name. |
|
| 2038 | - */ |
|
| 2039 | - public function set_date_completed( $value ) { |
|
| 2040 | - $this->set_completed_date( $value ); |
|
| 2034 | + * Alias of self::set_completed_date(). |
|
| 2035 | + * |
|
| 2036 | + * @since 1.0.19 |
|
| 2037 | + * @param string $value New name. |
|
| 2038 | + */ |
|
| 2039 | + public function set_date_completed( $value ) { |
|
| 2040 | + $this->set_completed_date( $value ); |
|
| 2041 | 2041 | } |
| 2042 | 2042 | |
| 2043 | 2043 | /** |
| 2044 | - * Set date when the invoice was last modified. |
|
| 2045 | - * |
|
| 2046 | - * @since 1.0.19 |
|
| 2047 | - * @param string $value Value to set. |
|
| 2044 | + * Set date when the invoice was last modified. |
|
| 2045 | + * |
|
| 2046 | + * @since 1.0.19 |
|
| 2047 | + * @param string $value Value to set. |
|
| 2048 | 2048 | * @return bool Whether or not the date was set. |
| 2049 | - */ |
|
| 2050 | - public function set_date_modified( $value ) { |
|
| 2049 | + */ |
|
| 2050 | + public function set_date_modified( $value ) { |
|
| 2051 | 2051 | $date = strtotime( $value ); |
| 2052 | 2052 | |
| 2053 | 2053 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -2055,763 +2055,763 @@ discard block |
||
| 2055 | 2055 | return true; |
| 2056 | 2056 | } |
| 2057 | 2057 | |
| 2058 | - $this->set_prop( 'date_modified', '' ); |
|
| 2058 | + $this->set_prop( 'date_modified', '' ); |
|
| 2059 | 2059 | return false; |
| 2060 | 2060 | |
| 2061 | 2061 | } |
| 2062 | 2062 | |
| 2063 | 2063 | /** |
| 2064 | - * Set the invoice number. |
|
| 2065 | - * |
|
| 2066 | - * @since 1.0.19 |
|
| 2067 | - * @param string $value New number. |
|
| 2068 | - */ |
|
| 2069 | - public function set_number( $value ) { |
|
| 2064 | + * Set the invoice number. |
|
| 2065 | + * |
|
| 2066 | + * @since 1.0.19 |
|
| 2067 | + * @param string $value New number. |
|
| 2068 | + */ |
|
| 2069 | + public function set_number( $value ) { |
|
| 2070 | 2070 | $number = sanitize_text_field( $value ); |
| 2071 | - $this->set_prop( 'number', $number ); |
|
| 2071 | + $this->set_prop( 'number', $number ); |
|
| 2072 | 2072 | } |
| 2073 | 2073 | |
| 2074 | 2074 | /** |
| 2075 | - * Set the invoice type. |
|
| 2076 | - * |
|
| 2077 | - * @since 1.0.19 |
|
| 2078 | - * @param string $value Type. |
|
| 2079 | - */ |
|
| 2080 | - public function set_type( $value ) { |
|
| 2075 | + * Set the invoice type. |
|
| 2076 | + * |
|
| 2077 | + * @since 1.0.19 |
|
| 2078 | + * @param string $value Type. |
|
| 2079 | + */ |
|
| 2080 | + public function set_type( $value ) { |
|
| 2081 | 2081 | $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
| 2082 | - $this->set_prop( 'type', $type ); |
|
| 2083 | - } |
|
| 2082 | + $this->set_prop( 'type', $type ); |
|
| 2083 | + } |
|
| 2084 | 2084 | |
| 2085 | 2085 | /** |
| 2086 | - * Set the invoice post type. |
|
| 2087 | - * |
|
| 2088 | - * @since 1.0.19 |
|
| 2089 | - * @param string $value Post type. |
|
| 2090 | - */ |
|
| 2091 | - public function set_post_type( $value ) { |
|
| 2086 | + * Set the invoice post type. |
|
| 2087 | + * |
|
| 2088 | + * @since 1.0.19 |
|
| 2089 | + * @param string $value Post type. |
|
| 2090 | + */ |
|
| 2091 | + public function set_post_type( $value ) { |
|
| 2092 | 2092 | if ( getpaid_is_invoice_post_type( $value ) ) { |
| 2093 | - $this->set_type( $value ); |
|
| 2093 | + $this->set_type( $value ); |
|
| 2094 | 2094 | $this->set_prop( 'post_type', $value ); |
| 2095 | 2095 | } |
| 2096 | 2096 | } |
| 2097 | 2097 | |
| 2098 | 2098 | /** |
| 2099 | - * Set the invoice key. |
|
| 2100 | - * |
|
| 2101 | - * @since 1.0.19 |
|
| 2102 | - * @param string $value New key. |
|
| 2103 | - */ |
|
| 2104 | - public function set_key( $value ) { |
|
| 2099 | + * Set the invoice key. |
|
| 2100 | + * |
|
| 2101 | + * @since 1.0.19 |
|
| 2102 | + * @param string $value New key. |
|
| 2103 | + */ |
|
| 2104 | + public function set_key( $value ) { |
|
| 2105 | 2105 | $key = sanitize_text_field( $value ); |
| 2106 | - $this->set_prop( 'key', $key ); |
|
| 2106 | + $this->set_prop( 'key', $key ); |
|
| 2107 | 2107 | } |
| 2108 | 2108 | |
| 2109 | 2109 | /** |
| 2110 | - * Set the invoice mode. |
|
| 2111 | - * |
|
| 2112 | - * @since 1.0.19 |
|
| 2113 | - * @param string $value mode. |
|
| 2114 | - */ |
|
| 2115 | - public function set_mode( $value ) { |
|
| 2110 | + * Set the invoice mode. |
|
| 2111 | + * |
|
| 2112 | + * @since 1.0.19 |
|
| 2113 | + * @param string $value mode. |
|
| 2114 | + */ |
|
| 2115 | + public function set_mode( $value ) { |
|
| 2116 | 2116 | if ( ! in_array( $value, array( 'live', 'test' ) ) ) { |
| 2117 | 2117 | $this->set_prop( 'value', $value ); |
| 2118 | 2118 | } |
| 2119 | 2119 | } |
| 2120 | 2120 | |
| 2121 | 2121 | /** |
| 2122 | - * Set the invoice path. |
|
| 2123 | - * |
|
| 2124 | - * @since 1.0.19 |
|
| 2125 | - * @param string $value path. |
|
| 2126 | - */ |
|
| 2127 | - public function set_path( $value ) { |
|
| 2122 | + * Set the invoice path. |
|
| 2123 | + * |
|
| 2124 | + * @since 1.0.19 |
|
| 2125 | + * @param string $value path. |
|
| 2126 | + */ |
|
| 2127 | + public function set_path( $value ) { |
|
| 2128 | 2128 | $this->set_prop( 'path', $value ); |
| 2129 | 2129 | } |
| 2130 | 2130 | |
| 2131 | 2131 | /** |
| 2132 | - * Set the invoice name. |
|
| 2133 | - * |
|
| 2134 | - * @since 1.0.19 |
|
| 2135 | - * @param string $value New name. |
|
| 2136 | - */ |
|
| 2137 | - public function set_name( $value ) { |
|
| 2132 | + * Set the invoice name. |
|
| 2133 | + * |
|
| 2134 | + * @since 1.0.19 |
|
| 2135 | + * @param string $value New name. |
|
| 2136 | + */ |
|
| 2137 | + public function set_name( $value ) { |
|
| 2138 | 2138 | $name = sanitize_text_field( $value ); |
| 2139 | - $this->set_prop( 'name', $name ); |
|
| 2139 | + $this->set_prop( 'name', $name ); |
|
| 2140 | 2140 | } |
| 2141 | 2141 | |
| 2142 | 2142 | /** |
| 2143 | - * Alias of self::set_name(). |
|
| 2144 | - * |
|
| 2145 | - * @since 1.0.19 |
|
| 2146 | - * @param string $value New name. |
|
| 2147 | - */ |
|
| 2148 | - public function set_title( $value ) { |
|
| 2149 | - $this->set_name( $value ); |
|
| 2143 | + * Alias of self::set_name(). |
|
| 2144 | + * |
|
| 2145 | + * @since 1.0.19 |
|
| 2146 | + * @param string $value New name. |
|
| 2147 | + */ |
|
| 2148 | + public function set_title( $value ) { |
|
| 2149 | + $this->set_name( $value ); |
|
| 2150 | 2150 | } |
| 2151 | 2151 | |
| 2152 | 2152 | /** |
| 2153 | - * Set the invoice description. |
|
| 2154 | - * |
|
| 2155 | - * @since 1.0.19 |
|
| 2156 | - * @param string $value New description. |
|
| 2157 | - */ |
|
| 2158 | - public function set_description( $value ) { |
|
| 2153 | + * Set the invoice description. |
|
| 2154 | + * |
|
| 2155 | + * @since 1.0.19 |
|
| 2156 | + * @param string $value New description. |
|
| 2157 | + */ |
|
| 2158 | + public function set_description( $value ) { |
|
| 2159 | 2159 | $description = wp_kses_post( $value ); |
| 2160 | - return $this->set_prop( 'description', $description ); |
|
| 2160 | + return $this->set_prop( 'description', $description ); |
|
| 2161 | + } |
|
| 2162 | + |
|
| 2163 | + /** |
|
| 2164 | + * Alias of self::set_description(). |
|
| 2165 | + * |
|
| 2166 | + * @since 1.0.19 |
|
| 2167 | + * @param string $value New description. |
|
| 2168 | + */ |
|
| 2169 | + public function set_excerpt( $value ) { |
|
| 2170 | + $this->set_description( $value ); |
|
| 2171 | + } |
|
| 2172 | + |
|
| 2173 | + /** |
|
| 2174 | + * Alias of self::set_description(). |
|
| 2175 | + * |
|
| 2176 | + * @since 1.0.19 |
|
| 2177 | + * @param string $value New description. |
|
| 2178 | + */ |
|
| 2179 | + public function set_summary( $value ) { |
|
| 2180 | + $this->set_description( $value ); |
|
| 2161 | 2181 | } |
| 2162 | 2182 | |
| 2163 | 2183 | /** |
| 2164 | - * Alias of self::set_description(). |
|
| 2165 | - * |
|
| 2166 | - * @since 1.0.19 |
|
| 2167 | - * @param string $value New description. |
|
| 2168 | - */ |
|
| 2169 | - public function set_excerpt( $value ) { |
|
| 2170 | - $this->set_description( $value ); |
|
| 2184 | + * Set the receiver of the invoice. |
|
| 2185 | + * |
|
| 2186 | + * @since 1.0.19 |
|
| 2187 | + * @param int $value New author. |
|
| 2188 | + */ |
|
| 2189 | + public function set_author( $value ) { |
|
| 2190 | + $user = get_user_by( 'id', (int) $value ); |
|
| 2191 | + |
|
| 2192 | + if ( $user && $user->ID ) { |
|
| 2193 | + $this->set_prop( 'author', $user->ID ); |
|
| 2194 | + $this->set_prop( 'email', $user->user_email ); |
|
| 2195 | + } |
|
| 2196 | + |
|
| 2171 | 2197 | } |
| 2172 | 2198 | |
| 2173 | 2199 | /** |
| 2174 | - * Alias of self::set_description(). |
|
| 2175 | - * |
|
| 2176 | - * @since 1.0.19 |
|
| 2177 | - * @param string $value New description. |
|
| 2178 | - */ |
|
| 2179 | - public function set_summary( $value ) { |
|
| 2180 | - $this->set_description( $value ); |
|
| 2200 | + * Alias of self::set_author(). |
|
| 2201 | + * |
|
| 2202 | + * @since 1.0.19 |
|
| 2203 | + * @param int $value New user id. |
|
| 2204 | + */ |
|
| 2205 | + public function set_user_id( $value ) { |
|
| 2206 | + $this->set_author( $value ); |
|
| 2181 | 2207 | } |
| 2182 | 2208 | |
| 2183 | 2209 | /** |
| 2184 | - * Set the receiver of the invoice. |
|
| 2185 | - * |
|
| 2186 | - * @since 1.0.19 |
|
| 2187 | - * @param int $value New author. |
|
| 2188 | - */ |
|
| 2189 | - public function set_author( $value ) { |
|
| 2190 | - $user = get_user_by( 'id', (int) $value ); |
|
| 2210 | + * Alias of self::set_author(). |
|
| 2211 | + * |
|
| 2212 | + * @since 1.0.19 |
|
| 2213 | + * @param int $value New user id. |
|
| 2214 | + */ |
|
| 2215 | + public function set_customer_id( $value ) { |
|
| 2216 | + $this->set_author( $value ); |
|
| 2217 | + } |
|
| 2191 | 2218 | |
| 2192 | - if ( $user && $user->ID ) { |
|
| 2193 | - $this->set_prop( 'author', $user->ID ); |
|
| 2194 | - $this->set_prop( 'email', $user->user_email ); |
|
| 2195 | - } |
|
| 2219 | + /** |
|
| 2220 | + * Set the customer's ip. |
|
| 2221 | + * |
|
| 2222 | + * @since 1.0.19 |
|
| 2223 | + * @param string $value ip address. |
|
| 2224 | + */ |
|
| 2225 | + public function set_ip( $value ) { |
|
| 2226 | + $this->set_prop( 'ip', $value ); |
|
| 2227 | + } |
|
| 2196 | 2228 | |
| 2229 | + /** |
|
| 2230 | + * Alias of self::set_ip(). |
|
| 2231 | + * |
|
| 2232 | + * @since 1.0.19 |
|
| 2233 | + * @param string $value ip address. |
|
| 2234 | + */ |
|
| 2235 | + public function set_user_ip( $value ) { |
|
| 2236 | + $this->set_ip( $value ); |
|
| 2197 | 2237 | } |
| 2198 | 2238 | |
| 2199 | 2239 | /** |
| 2200 | - * Alias of self::set_author(). |
|
| 2201 | - * |
|
| 2202 | - * @since 1.0.19 |
|
| 2203 | - * @param int $value New user id. |
|
| 2204 | - */ |
|
| 2205 | - public function set_user_id( $value ) { |
|
| 2206 | - $this->set_author( $value ); |
|
| 2240 | + * Set the customer's first name. |
|
| 2241 | + * |
|
| 2242 | + * @since 1.0.19 |
|
| 2243 | + * @param string $value first name. |
|
| 2244 | + */ |
|
| 2245 | + public function set_first_name( $value ) { |
|
| 2246 | + $this->set_prop( 'first_name', $value ); |
|
| 2207 | 2247 | } |
| 2208 | 2248 | |
| 2209 | 2249 | /** |
| 2210 | - * Alias of self::set_author(). |
|
| 2211 | - * |
|
| 2212 | - * @since 1.0.19 |
|
| 2213 | - * @param int $value New user id. |
|
| 2214 | - */ |
|
| 2215 | - public function set_customer_id( $value ) { |
|
| 2216 | - $this->set_author( $value ); |
|
| 2250 | + * Alias of self::set_first_name(). |
|
| 2251 | + * |
|
| 2252 | + * @since 1.0.19 |
|
| 2253 | + * @param string $value first name. |
|
| 2254 | + */ |
|
| 2255 | + public function set_user_first_name( $value ) { |
|
| 2256 | + $this->set_first_name( $value ); |
|
| 2217 | 2257 | } |
| 2218 | 2258 | |
| 2219 | 2259 | /** |
| 2220 | - * Set the customer's ip. |
|
| 2221 | - * |
|
| 2222 | - * @since 1.0.19 |
|
| 2223 | - * @param string $value ip address. |
|
| 2224 | - */ |
|
| 2225 | - public function set_ip( $value ) { |
|
| 2226 | - $this->set_prop( 'ip', $value ); |
|
| 2260 | + * Alias of self::set_first_name(). |
|
| 2261 | + * |
|
| 2262 | + * @since 1.0.19 |
|
| 2263 | + * @param string $value first name. |
|
| 2264 | + */ |
|
| 2265 | + public function set_customer_first_name( $value ) { |
|
| 2266 | + $this->set_first_name( $value ); |
|
| 2227 | 2267 | } |
| 2228 | 2268 | |
| 2229 | 2269 | /** |
| 2230 | - * Alias of self::set_ip(). |
|
| 2231 | - * |
|
| 2232 | - * @since 1.0.19 |
|
| 2233 | - * @param string $value ip address. |
|
| 2234 | - */ |
|
| 2235 | - public function set_user_ip( $value ) { |
|
| 2236 | - $this->set_ip( $value ); |
|
| 2270 | + * Set the customer's last name. |
|
| 2271 | + * |
|
| 2272 | + * @since 1.0.19 |
|
| 2273 | + * @param string $value last name. |
|
| 2274 | + */ |
|
| 2275 | + public function set_last_name( $value ) { |
|
| 2276 | + $this->set_prop( 'last_name', $value ); |
|
| 2237 | 2277 | } |
| 2238 | 2278 | |
| 2239 | 2279 | /** |
| 2240 | - * Set the customer's first name. |
|
| 2241 | - * |
|
| 2242 | - * @since 1.0.19 |
|
| 2243 | - * @param string $value first name. |
|
| 2244 | - */ |
|
| 2245 | - public function set_first_name( $value ) { |
|
| 2246 | - $this->set_prop( 'first_name', $value ); |
|
| 2280 | + * Alias of self::set_last_name(). |
|
| 2281 | + * |
|
| 2282 | + * @since 1.0.19 |
|
| 2283 | + * @param string $value last name. |
|
| 2284 | + */ |
|
| 2285 | + public function set_user_last_name( $value ) { |
|
| 2286 | + $this->set_last_name( $value ); |
|
| 2247 | 2287 | } |
| 2248 | 2288 | |
| 2249 | 2289 | /** |
| 2250 | - * Alias of self::set_first_name(). |
|
| 2251 | - * |
|
| 2252 | - * @since 1.0.19 |
|
| 2253 | - * @param string $value first name. |
|
| 2254 | - */ |
|
| 2255 | - public function set_user_first_name( $value ) { |
|
| 2256 | - $this->set_first_name( $value ); |
|
| 2290 | + * Alias of self::set_last_name(). |
|
| 2291 | + * |
|
| 2292 | + * @since 1.0.19 |
|
| 2293 | + * @param string $value last name. |
|
| 2294 | + */ |
|
| 2295 | + public function set_customer_last_name( $value ) { |
|
| 2296 | + $this->set_last_name( $value ); |
|
| 2257 | 2297 | } |
| 2258 | 2298 | |
| 2259 | 2299 | /** |
| 2260 | - * Alias of self::set_first_name(). |
|
| 2261 | - * |
|
| 2262 | - * @since 1.0.19 |
|
| 2263 | - * @param string $value first name. |
|
| 2264 | - */ |
|
| 2265 | - public function set_customer_first_name( $value ) { |
|
| 2266 | - $this->set_first_name( $value ); |
|
| 2300 | + * Set the customer's phone number. |
|
| 2301 | + * |
|
| 2302 | + * @since 1.0.19 |
|
| 2303 | + * @param string $value phone. |
|
| 2304 | + */ |
|
| 2305 | + public function set_phone( $value ) { |
|
| 2306 | + $this->set_prop( 'phone', $value ); |
|
| 2267 | 2307 | } |
| 2268 | 2308 | |
| 2269 | 2309 | /** |
| 2270 | - * Set the customer's last name. |
|
| 2271 | - * |
|
| 2272 | - * @since 1.0.19 |
|
| 2273 | - * @param string $value last name. |
|
| 2274 | - */ |
|
| 2275 | - public function set_last_name( $value ) { |
|
| 2276 | - $this->set_prop( 'last_name', $value ); |
|
| 2310 | + * Alias of self::set_phone(). |
|
| 2311 | + * |
|
| 2312 | + * @since 1.0.19 |
|
| 2313 | + * @param string $value phone. |
|
| 2314 | + */ |
|
| 2315 | + public function set_user_phone( $value ) { |
|
| 2316 | + $this->set_phone( $value ); |
|
| 2277 | 2317 | } |
| 2278 | 2318 | |
| 2279 | 2319 | /** |
| 2280 | - * Alias of self::set_last_name(). |
|
| 2281 | - * |
|
| 2282 | - * @since 1.0.19 |
|
| 2283 | - * @param string $value last name. |
|
| 2284 | - */ |
|
| 2285 | - public function set_user_last_name( $value ) { |
|
| 2286 | - $this->set_last_name( $value ); |
|
| 2320 | + * Alias of self::set_phone(). |
|
| 2321 | + * |
|
| 2322 | + * @since 1.0.19 |
|
| 2323 | + * @param string $value phone. |
|
| 2324 | + */ |
|
| 2325 | + public function set_customer_phone( $value ) { |
|
| 2326 | + $this->set_phone( $value ); |
|
| 2287 | 2327 | } |
| 2288 | 2328 | |
| 2289 | 2329 | /** |
| 2290 | - * Alias of self::set_last_name(). |
|
| 2291 | - * |
|
| 2292 | - * @since 1.0.19 |
|
| 2293 | - * @param string $value last name. |
|
| 2294 | - */ |
|
| 2295 | - public function set_customer_last_name( $value ) { |
|
| 2296 | - $this->set_last_name( $value ); |
|
| 2330 | + * Alias of self::set_phone(). |
|
| 2331 | + * |
|
| 2332 | + * @since 1.0.19 |
|
| 2333 | + * @param string $value phone. |
|
| 2334 | + */ |
|
| 2335 | + public function set_phone_number( $value ) { |
|
| 2336 | + $this->set_phone( $value ); |
|
| 2297 | 2337 | } |
| 2298 | 2338 | |
| 2299 | 2339 | /** |
| 2300 | - * Set the customer's phone number. |
|
| 2301 | - * |
|
| 2302 | - * @since 1.0.19 |
|
| 2303 | - * @param string $value phone. |
|
| 2304 | - */ |
|
| 2305 | - public function set_phone( $value ) { |
|
| 2306 | - $this->set_prop( 'phone', $value ); |
|
| 2340 | + * Set the customer's email address. |
|
| 2341 | + * |
|
| 2342 | + * @since 1.0.19 |
|
| 2343 | + * @param string $value email address. |
|
| 2344 | + */ |
|
| 2345 | + public function set_email( $value ) { |
|
| 2346 | + $this->set_prop( 'email', $value ); |
|
| 2307 | 2347 | } |
| 2308 | 2348 | |
| 2309 | 2349 | /** |
| 2310 | - * Alias of self::set_phone(). |
|
| 2311 | - * |
|
| 2312 | - * @since 1.0.19 |
|
| 2313 | - * @param string $value phone. |
|
| 2314 | - */ |
|
| 2315 | - public function set_user_phone( $value ) { |
|
| 2316 | - $this->set_phone( $value ); |
|
| 2350 | + * Alias of self::set_email(). |
|
| 2351 | + * |
|
| 2352 | + * @since 1.0.19 |
|
| 2353 | + * @param string $value email address. |
|
| 2354 | + */ |
|
| 2355 | + public function set_user_email( $value ) { |
|
| 2356 | + $this->set_email( $value ); |
|
| 2317 | 2357 | } |
| 2318 | 2358 | |
| 2319 | 2359 | /** |
| 2320 | - * Alias of self::set_phone(). |
|
| 2321 | - * |
|
| 2322 | - * @since 1.0.19 |
|
| 2323 | - * @param string $value phone. |
|
| 2324 | - */ |
|
| 2325 | - public function set_customer_phone( $value ) { |
|
| 2326 | - $this->set_phone( $value ); |
|
| 2360 | + * Alias of self::set_email(). |
|
| 2361 | + * |
|
| 2362 | + * @since 1.0.19 |
|
| 2363 | + * @param string $value email address. |
|
| 2364 | + */ |
|
| 2365 | + public function set_email_address( $value ) { |
|
| 2366 | + $this->set_email( $value ); |
|
| 2327 | 2367 | } |
| 2328 | 2368 | |
| 2329 | 2369 | /** |
| 2330 | - * Alias of self::set_phone(). |
|
| 2331 | - * |
|
| 2332 | - * @since 1.0.19 |
|
| 2333 | - * @param string $value phone. |
|
| 2334 | - */ |
|
| 2335 | - public function set_phone_number( $value ) { |
|
| 2336 | - $this->set_phone( $value ); |
|
| 2370 | + * Alias of self::set_email(). |
|
| 2371 | + * |
|
| 2372 | + * @since 1.0.19 |
|
| 2373 | + * @param string $value email address. |
|
| 2374 | + */ |
|
| 2375 | + public function set_customer_email( $value ) { |
|
| 2376 | + $this->set_email( $value ); |
|
| 2337 | 2377 | } |
| 2338 | 2378 | |
| 2339 | 2379 | /** |
| 2340 | - * Set the customer's email address. |
|
| 2341 | - * |
|
| 2342 | - * @since 1.0.19 |
|
| 2343 | - * @param string $value email address. |
|
| 2344 | - */ |
|
| 2345 | - public function set_email( $value ) { |
|
| 2346 | - $this->set_prop( 'email', $value ); |
|
| 2380 | + * Set the customer's country. |
|
| 2381 | + * |
|
| 2382 | + * @since 1.0.19 |
|
| 2383 | + * @param string $value country. |
|
| 2384 | + */ |
|
| 2385 | + public function set_country( $value ) { |
|
| 2386 | + $this->set_prop( 'country', $value ); |
|
| 2347 | 2387 | } |
| 2348 | 2388 | |
| 2349 | 2389 | /** |
| 2350 | - * Alias of self::set_email(). |
|
| 2351 | - * |
|
| 2352 | - * @since 1.0.19 |
|
| 2353 | - * @param string $value email address. |
|
| 2354 | - */ |
|
| 2355 | - public function set_user_email( $value ) { |
|
| 2356 | - $this->set_email( $value ); |
|
| 2390 | + * Alias of self::set_country(). |
|
| 2391 | + * |
|
| 2392 | + * @since 1.0.19 |
|
| 2393 | + * @param string $value country. |
|
| 2394 | + */ |
|
| 2395 | + public function set_user_country( $value ) { |
|
| 2396 | + $this->set_country( $value ); |
|
| 2357 | 2397 | } |
| 2358 | 2398 | |
| 2359 | 2399 | /** |
| 2360 | - * Alias of self::set_email(). |
|
| 2361 | - * |
|
| 2362 | - * @since 1.0.19 |
|
| 2363 | - * @param string $value email address. |
|
| 2364 | - */ |
|
| 2365 | - public function set_email_address( $value ) { |
|
| 2366 | - $this->set_email( $value ); |
|
| 2400 | + * Alias of self::set_country(). |
|
| 2401 | + * |
|
| 2402 | + * @since 1.0.19 |
|
| 2403 | + * @param string $value country. |
|
| 2404 | + */ |
|
| 2405 | + public function set_customer_country( $value ) { |
|
| 2406 | + $this->set_country( $value ); |
|
| 2367 | 2407 | } |
| 2368 | 2408 | |
| 2369 | 2409 | /** |
| 2370 | - * Alias of self::set_email(). |
|
| 2371 | - * |
|
| 2372 | - * @since 1.0.19 |
|
| 2373 | - * @param string $value email address. |
|
| 2374 | - */ |
|
| 2375 | - public function set_customer_email( $value ) { |
|
| 2376 | - $this->set_email( $value ); |
|
| 2410 | + * Set the customer's state. |
|
| 2411 | + * |
|
| 2412 | + * @since 1.0.19 |
|
| 2413 | + * @param string $value state. |
|
| 2414 | + */ |
|
| 2415 | + public function set_state( $value ) { |
|
| 2416 | + $this->set_prop( 'state', $value ); |
|
| 2377 | 2417 | } |
| 2378 | 2418 | |
| 2379 | 2419 | /** |
| 2380 | - * Set the customer's country. |
|
| 2381 | - * |
|
| 2382 | - * @since 1.0.19 |
|
| 2383 | - * @param string $value country. |
|
| 2384 | - */ |
|
| 2385 | - public function set_country( $value ) { |
|
| 2386 | - $this->set_prop( 'country', $value ); |
|
| 2420 | + * Alias of self::set_state(). |
|
| 2421 | + * |
|
| 2422 | + * @since 1.0.19 |
|
| 2423 | + * @param string $value state. |
|
| 2424 | + */ |
|
| 2425 | + public function set_user_state( $value ) { |
|
| 2426 | + $this->set_state( $value ); |
|
| 2387 | 2427 | } |
| 2388 | 2428 | |
| 2389 | 2429 | /** |
| 2390 | - * Alias of self::set_country(). |
|
| 2391 | - * |
|
| 2392 | - * @since 1.0.19 |
|
| 2393 | - * @param string $value country. |
|
| 2394 | - */ |
|
| 2395 | - public function set_user_country( $value ) { |
|
| 2396 | - $this->set_country( $value ); |
|
| 2430 | + * Alias of self::set_state(). |
|
| 2431 | + * |
|
| 2432 | + * @since 1.0.19 |
|
| 2433 | + * @param string $value state. |
|
| 2434 | + */ |
|
| 2435 | + public function set_customer_state( $value ) { |
|
| 2436 | + $this->set_state( $value ); |
|
| 2397 | 2437 | } |
| 2398 | 2438 | |
| 2399 | 2439 | /** |
| 2400 | - * Alias of self::set_country(). |
|
| 2401 | - * |
|
| 2402 | - * @since 1.0.19 |
|
| 2403 | - * @param string $value country. |
|
| 2404 | - */ |
|
| 2405 | - public function set_customer_country( $value ) { |
|
| 2406 | - $this->set_country( $value ); |
|
| 2440 | + * Set the customer's city. |
|
| 2441 | + * |
|
| 2442 | + * @since 1.0.19 |
|
| 2443 | + * @param string $value city. |
|
| 2444 | + */ |
|
| 2445 | + public function set_city( $value ) { |
|
| 2446 | + $this->set_prop( 'city', $value ); |
|
| 2407 | 2447 | } |
| 2408 | 2448 | |
| 2409 | 2449 | /** |
| 2410 | - * Set the customer's state. |
|
| 2411 | - * |
|
| 2412 | - * @since 1.0.19 |
|
| 2413 | - * @param string $value state. |
|
| 2414 | - */ |
|
| 2415 | - public function set_state( $value ) { |
|
| 2416 | - $this->set_prop( 'state', $value ); |
|
| 2450 | + * Alias of self::set_city(). |
|
| 2451 | + * |
|
| 2452 | + * @since 1.0.19 |
|
| 2453 | + * @param string $value city. |
|
| 2454 | + */ |
|
| 2455 | + public function set_user_city( $value ) { |
|
| 2456 | + $this->set_city( $value ); |
|
| 2417 | 2457 | } |
| 2418 | 2458 | |
| 2419 | 2459 | /** |
| 2420 | - * Alias of self::set_state(). |
|
| 2421 | - * |
|
| 2422 | - * @since 1.0.19 |
|
| 2423 | - * @param string $value state. |
|
| 2424 | - */ |
|
| 2425 | - public function set_user_state( $value ) { |
|
| 2426 | - $this->set_state( $value ); |
|
| 2460 | + * Alias of self::set_city(). |
|
| 2461 | + * |
|
| 2462 | + * @since 1.0.19 |
|
| 2463 | + * @param string $value city. |
|
| 2464 | + */ |
|
| 2465 | + public function set_customer_city( $value ) { |
|
| 2466 | + $this->set_city( $value ); |
|
| 2427 | 2467 | } |
| 2428 | 2468 | |
| 2429 | 2469 | /** |
| 2430 | - * Alias of self::set_state(). |
|
| 2431 | - * |
|
| 2432 | - * @since 1.0.19 |
|
| 2433 | - * @param string $value state. |
|
| 2434 | - */ |
|
| 2435 | - public function set_customer_state( $value ) { |
|
| 2436 | - $this->set_state( $value ); |
|
| 2470 | + * Set the customer's zip code. |
|
| 2471 | + * |
|
| 2472 | + * @since 1.0.19 |
|
| 2473 | + * @param string $value zip. |
|
| 2474 | + */ |
|
| 2475 | + public function set_zip( $value ) { |
|
| 2476 | + $this->set_prop( 'zip', $value ); |
|
| 2437 | 2477 | } |
| 2438 | 2478 | |
| 2439 | 2479 | /** |
| 2440 | - * Set the customer's city. |
|
| 2441 | - * |
|
| 2442 | - * @since 1.0.19 |
|
| 2443 | - * @param string $value city. |
|
| 2444 | - */ |
|
| 2445 | - public function set_city( $value ) { |
|
| 2446 | - $this->set_prop( 'city', $value ); |
|
| 2480 | + * Alias of self::set_zip(). |
|
| 2481 | + * |
|
| 2482 | + * @since 1.0.19 |
|
| 2483 | + * @param string $value zip. |
|
| 2484 | + */ |
|
| 2485 | + public function set_user_zip( $value ) { |
|
| 2486 | + $this->set_zip( $value ); |
|
| 2447 | 2487 | } |
| 2448 | 2488 | |
| 2449 | 2489 | /** |
| 2450 | - * Alias of self::set_city(). |
|
| 2451 | - * |
|
| 2452 | - * @since 1.0.19 |
|
| 2453 | - * @param string $value city. |
|
| 2454 | - */ |
|
| 2455 | - public function set_user_city( $value ) { |
|
| 2456 | - $this->set_city( $value ); |
|
| 2490 | + * Alias of self::set_zip(). |
|
| 2491 | + * |
|
| 2492 | + * @since 1.0.19 |
|
| 2493 | + * @param string $value zip. |
|
| 2494 | + */ |
|
| 2495 | + public function set_customer_zip( $value ) { |
|
| 2496 | + $this->set_zip( $value ); |
|
| 2457 | 2497 | } |
| 2458 | 2498 | |
| 2459 | 2499 | /** |
| 2460 | - * Alias of self::set_city(). |
|
| 2461 | - * |
|
| 2462 | - * @since 1.0.19 |
|
| 2463 | - * @param string $value city. |
|
| 2464 | - */ |
|
| 2465 | - public function set_customer_city( $value ) { |
|
| 2466 | - $this->set_city( $value ); |
|
| 2500 | + * Set the customer's company. |
|
| 2501 | + * |
|
| 2502 | + * @since 1.0.19 |
|
| 2503 | + * @param string $value company. |
|
| 2504 | + */ |
|
| 2505 | + public function set_company( $value ) { |
|
| 2506 | + $this->set_prop( 'company', $value ); |
|
| 2467 | 2507 | } |
| 2468 | 2508 | |
| 2469 | 2509 | /** |
| 2470 | - * Set the customer's zip code. |
|
| 2471 | - * |
|
| 2472 | - * @since 1.0.19 |
|
| 2473 | - * @param string $value zip. |
|
| 2474 | - */ |
|
| 2475 | - public function set_zip( $value ) { |
|
| 2476 | - $this->set_prop( 'zip', $value ); |
|
| 2510 | + * Alias of self::set_company(). |
|
| 2511 | + * |
|
| 2512 | + * @since 1.0.19 |
|
| 2513 | + * @param string $value company. |
|
| 2514 | + */ |
|
| 2515 | + public function set_user_company( $value ) { |
|
| 2516 | + $this->set_company( $value ); |
|
| 2477 | 2517 | } |
| 2478 | 2518 | |
| 2479 | 2519 | /** |
| 2480 | - * Alias of self::set_zip(). |
|
| 2481 | - * |
|
| 2482 | - * @since 1.0.19 |
|
| 2483 | - * @param string $value zip. |
|
| 2484 | - */ |
|
| 2485 | - public function set_user_zip( $value ) { |
|
| 2486 | - $this->set_zip( $value ); |
|
| 2520 | + * Alias of self::set_company(). |
|
| 2521 | + * |
|
| 2522 | + * @since 1.0.19 |
|
| 2523 | + * @param string $value company. |
|
| 2524 | + */ |
|
| 2525 | + public function set_customer_company( $value ) { |
|
| 2526 | + $this->set_company( $value ); |
|
| 2487 | 2527 | } |
| 2488 | 2528 | |
| 2489 | 2529 | /** |
| 2490 | - * Alias of self::set_zip(). |
|
| 2491 | - * |
|
| 2492 | - * @since 1.0.19 |
|
| 2493 | - * @param string $value zip. |
|
| 2494 | - */ |
|
| 2495 | - public function set_customer_zip( $value ) { |
|
| 2496 | - $this->set_zip( $value ); |
|
| 2530 | + * Set the customer's var number. |
|
| 2531 | + * |
|
| 2532 | + * @since 1.0.19 |
|
| 2533 | + * @param string $value var number. |
|
| 2534 | + */ |
|
| 2535 | + public function set_vat_number( $value ) { |
|
| 2536 | + $this->set_prop( 'vat_number', $value ); |
|
| 2497 | 2537 | } |
| 2498 | 2538 | |
| 2499 | 2539 | /** |
| 2500 | - * Set the customer's company. |
|
| 2501 | - * |
|
| 2502 | - * @since 1.0.19 |
|
| 2503 | - * @param string $value company. |
|
| 2504 | - */ |
|
| 2505 | - public function set_company( $value ) { |
|
| 2506 | - $this->set_prop( 'company', $value ); |
|
| 2540 | + * Alias of self::set_vat_number(). |
|
| 2541 | + * |
|
| 2542 | + * @since 1.0.19 |
|
| 2543 | + * @param string $value var number. |
|
| 2544 | + */ |
|
| 2545 | + public function set_user_vat_number( $value ) { |
|
| 2546 | + $this->set_vat_number( $value ); |
|
| 2507 | 2547 | } |
| 2508 | 2548 | |
| 2509 | 2549 | /** |
| 2510 | - * Alias of self::set_company(). |
|
| 2511 | - * |
|
| 2512 | - * @since 1.0.19 |
|
| 2513 | - * @param string $value company. |
|
| 2514 | - */ |
|
| 2515 | - public function set_user_company( $value ) { |
|
| 2516 | - $this->set_company( $value ); |
|
| 2550 | + * Alias of self::set_vat_number(). |
|
| 2551 | + * |
|
| 2552 | + * @since 1.0.19 |
|
| 2553 | + * @param string $value var number. |
|
| 2554 | + */ |
|
| 2555 | + public function set_customer_vat_number( $value ) { |
|
| 2556 | + $this->set_vat_number( $value ); |
|
| 2517 | 2557 | } |
| 2518 | 2558 | |
| 2519 | 2559 | /** |
| 2520 | - * Alias of self::set_company(). |
|
| 2521 | - * |
|
| 2522 | - * @since 1.0.19 |
|
| 2523 | - * @param string $value company. |
|
| 2524 | - */ |
|
| 2525 | - public function set_customer_company( $value ) { |
|
| 2526 | - $this->set_company( $value ); |
|
| 2560 | + * Set the customer's vat rate. |
|
| 2561 | + * |
|
| 2562 | + * @since 1.0.19 |
|
| 2563 | + * @param string $value var rate. |
|
| 2564 | + */ |
|
| 2565 | + public function set_vat_rate( $value ) { |
|
| 2566 | + $this->set_prop( 'vat_rate', $value ); |
|
| 2527 | 2567 | } |
| 2528 | 2568 | |
| 2529 | 2569 | /** |
| 2530 | - * Set the customer's var number. |
|
| 2531 | - * |
|
| 2532 | - * @since 1.0.19 |
|
| 2533 | - * @param string $value var number. |
|
| 2534 | - */ |
|
| 2535 | - public function set_vat_number( $value ) { |
|
| 2536 | - $this->set_prop( 'vat_number', $value ); |
|
| 2570 | + * Alias of self::set_vat_rate(). |
|
| 2571 | + * |
|
| 2572 | + * @since 1.0.19 |
|
| 2573 | + * @param string $value var number. |
|
| 2574 | + */ |
|
| 2575 | + public function set_user_vat_rate( $value ) { |
|
| 2576 | + $this->set_vat_rate( $value ); |
|
| 2537 | 2577 | } |
| 2538 | 2578 | |
| 2539 | 2579 | /** |
| 2540 | - * Alias of self::set_vat_number(). |
|
| 2541 | - * |
|
| 2542 | - * @since 1.0.19 |
|
| 2543 | - * @param string $value var number. |
|
| 2544 | - */ |
|
| 2545 | - public function set_user_vat_number( $value ) { |
|
| 2546 | - $this->set_vat_number( $value ); |
|
| 2580 | + * Alias of self::set_vat_rate(). |
|
| 2581 | + * |
|
| 2582 | + * @since 1.0.19 |
|
| 2583 | + * @param string $value var number. |
|
| 2584 | + */ |
|
| 2585 | + public function set_customer_vat_rate( $value ) { |
|
| 2586 | + $this->set_vat_rate( $value ); |
|
| 2547 | 2587 | } |
| 2548 | 2588 | |
| 2549 | 2589 | /** |
| 2550 | - * Alias of self::set_vat_number(). |
|
| 2551 | - * |
|
| 2552 | - * @since 1.0.19 |
|
| 2553 | - * @param string $value var number. |
|
| 2554 | - */ |
|
| 2555 | - public function set_customer_vat_number( $value ) { |
|
| 2556 | - $this->set_vat_number( $value ); |
|
| 2590 | + * Set the customer's address. |
|
| 2591 | + * |
|
| 2592 | + * @since 1.0.19 |
|
| 2593 | + * @param string $value address. |
|
| 2594 | + */ |
|
| 2595 | + public function set_address( $value ) { |
|
| 2596 | + $this->set_prop( 'address', $value ); |
|
| 2557 | 2597 | } |
| 2558 | 2598 | |
| 2559 | 2599 | /** |
| 2560 | - * Set the customer's vat rate. |
|
| 2561 | - * |
|
| 2562 | - * @since 1.0.19 |
|
| 2563 | - * @param string $value var rate. |
|
| 2564 | - */ |
|
| 2565 | - public function set_vat_rate( $value ) { |
|
| 2566 | - $this->set_prop( 'vat_rate', $value ); |
|
| 2600 | + * Alias of self::set_address(). |
|
| 2601 | + * |
|
| 2602 | + * @since 1.0.19 |
|
| 2603 | + * @param string $value address. |
|
| 2604 | + */ |
|
| 2605 | + public function set_user_address( $value ) { |
|
| 2606 | + $this->set_address( $value ); |
|
| 2567 | 2607 | } |
| 2568 | 2608 | |
| 2569 | 2609 | /** |
| 2570 | - * Alias of self::set_vat_rate(). |
|
| 2571 | - * |
|
| 2572 | - * @since 1.0.19 |
|
| 2573 | - * @param string $value var number. |
|
| 2574 | - */ |
|
| 2575 | - public function set_user_vat_rate( $value ) { |
|
| 2576 | - $this->set_vat_rate( $value ); |
|
| 2610 | + * Alias of self::set_address(). |
|
| 2611 | + * |
|
| 2612 | + * @since 1.0.19 |
|
| 2613 | + * @param string $value address. |
|
| 2614 | + */ |
|
| 2615 | + public function set_customer_address( $value ) { |
|
| 2616 | + $this->set_address( $value ); |
|
| 2577 | 2617 | } |
| 2578 | 2618 | |
| 2579 | 2619 | /** |
| 2580 | - * Alias of self::set_vat_rate(). |
|
| 2581 | - * |
|
| 2582 | - * @since 1.0.19 |
|
| 2583 | - * @param string $value var number. |
|
| 2584 | - */ |
|
| 2585 | - public function set_customer_vat_rate( $value ) { |
|
| 2586 | - $this->set_vat_rate( $value ); |
|
| 2620 | + * Set whether the customer has viewed the invoice or not. |
|
| 2621 | + * |
|
| 2622 | + * @since 1.0.19 |
|
| 2623 | + * @param int|bool $value confirmed. |
|
| 2624 | + */ |
|
| 2625 | + public function set_is_viewed( $value ) { |
|
| 2626 | + $this->set_prop( 'is_viewed', $value ); |
|
| 2587 | 2627 | } |
| 2588 | 2628 | |
| 2589 | 2629 | /** |
| 2590 | - * Set the customer's address. |
|
| 2591 | - * |
|
| 2592 | - * @since 1.0.19 |
|
| 2593 | - * @param string $value address. |
|
| 2594 | - */ |
|
| 2595 | - public function set_address( $value ) { |
|
| 2596 | - $this->set_prop( 'address', $value ); |
|
| 2630 | + * Set extra email recipients. |
|
| 2631 | + * |
|
| 2632 | + * @since 1.0.19 |
|
| 2633 | + * @param string $value email recipients. |
|
| 2634 | + */ |
|
| 2635 | + public function set_email_cc( $value ) { |
|
| 2636 | + $this->set_prop( 'email_cc', $value ); |
|
| 2597 | 2637 | } |
| 2598 | 2638 | |
| 2599 | 2639 | /** |
| 2600 | - * Alias of self::set_address(). |
|
| 2601 | - * |
|
| 2602 | - * @since 1.0.19 |
|
| 2603 | - * @param string $value address. |
|
| 2604 | - */ |
|
| 2605 | - public function set_user_address( $value ) { |
|
| 2606 | - $this->set_address( $value ); |
|
| 2640 | + * Set the invoice template. |
|
| 2641 | + * |
|
| 2642 | + * @since 1.0.19 |
|
| 2643 | + * @param string $value template. |
|
| 2644 | + */ |
|
| 2645 | + public function set_template( $value ) { |
|
| 2646 | + if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2647 | + $this->set_prop( 'template', $value ); |
|
| 2648 | + } |
|
| 2607 | 2649 | } |
| 2608 | 2650 | |
| 2609 | 2651 | /** |
| 2610 | - * Alias of self::set_address(). |
|
| 2611 | - * |
|
| 2612 | - * @since 1.0.19 |
|
| 2613 | - * @param string $value address. |
|
| 2614 | - */ |
|
| 2615 | - public function set_customer_address( $value ) { |
|
| 2616 | - $this->set_address( $value ); |
|
| 2652 | + * Set the invoice source. |
|
| 2653 | + * |
|
| 2654 | + * @since 1.0.19 |
|
| 2655 | + * @param string $value email recipients. |
|
| 2656 | + */ |
|
| 2657 | + public function created_via( $value ) { |
|
| 2658 | + $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
| 2617 | 2659 | } |
| 2618 | 2660 | |
| 2619 | 2661 | /** |
| 2620 | - * Set whether the customer has viewed the invoice or not. |
|
| 2621 | - * |
|
| 2622 | - * @since 1.0.19 |
|
| 2623 | - * @param int|bool $value confirmed. |
|
| 2624 | - */ |
|
| 2625 | - public function set_is_viewed( $value ) { |
|
| 2626 | - $this->set_prop( 'is_viewed', $value ); |
|
| 2627 | - } |
|
| 2628 | - |
|
| 2629 | - /** |
|
| 2630 | - * Set extra email recipients. |
|
| 2631 | - * |
|
| 2632 | - * @since 1.0.19 |
|
| 2633 | - * @param string $value email recipients. |
|
| 2634 | - */ |
|
| 2635 | - public function set_email_cc( $value ) { |
|
| 2636 | - $this->set_prop( 'email_cc', $value ); |
|
| 2637 | - } |
|
| 2638 | - |
|
| 2639 | - /** |
|
| 2640 | - * Set the invoice template. |
|
| 2641 | - * |
|
| 2642 | - * @since 1.0.19 |
|
| 2643 | - * @param string $value template. |
|
| 2644 | - */ |
|
| 2645 | - public function set_template( $value ) { |
|
| 2646 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2647 | - $this->set_prop( 'template', $value ); |
|
| 2648 | - } |
|
| 2649 | - } |
|
| 2650 | - |
|
| 2651 | - /** |
|
| 2652 | - * Set the invoice source. |
|
| 2653 | - * |
|
| 2654 | - * @since 1.0.19 |
|
| 2655 | - * @param string $value email recipients. |
|
| 2656 | - */ |
|
| 2657 | - public function created_via( $value ) { |
|
| 2658 | - $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
| 2659 | - } |
|
| 2660 | - |
|
| 2661 | - /** |
|
| 2662 | - * Set the customer's address confirmed status. |
|
| 2663 | - * |
|
| 2664 | - * @since 1.0.19 |
|
| 2665 | - * @param int|bool $value confirmed. |
|
| 2666 | - */ |
|
| 2667 | - public function set_address_confirmed( $value ) { |
|
| 2668 | - $this->set_prop( 'address_confirmed', $value ); |
|
| 2662 | + * Set the customer's address confirmed status. |
|
| 2663 | + * |
|
| 2664 | + * @since 1.0.19 |
|
| 2665 | + * @param int|bool $value confirmed. |
|
| 2666 | + */ |
|
| 2667 | + public function set_address_confirmed( $value ) { |
|
| 2668 | + $this->set_prop( 'address_confirmed', $value ); |
|
| 2669 | 2669 | } |
| 2670 | 2670 | |
| 2671 | 2671 | /** |
| 2672 | - * Alias of self::set_address_confirmed(). |
|
| 2673 | - * |
|
| 2674 | - * @since 1.0.19 |
|
| 2675 | - * @param int|bool $value confirmed. |
|
| 2676 | - */ |
|
| 2677 | - public function set_user_address_confirmed( $value ) { |
|
| 2678 | - $this->set_address_confirmed( $value ); |
|
| 2672 | + * Alias of self::set_address_confirmed(). |
|
| 2673 | + * |
|
| 2674 | + * @since 1.0.19 |
|
| 2675 | + * @param int|bool $value confirmed. |
|
| 2676 | + */ |
|
| 2677 | + public function set_user_address_confirmed( $value ) { |
|
| 2678 | + $this->set_address_confirmed( $value ); |
|
| 2679 | 2679 | } |
| 2680 | 2680 | |
| 2681 | 2681 | /** |
| 2682 | - * Alias of self::set_address_confirmed(). |
|
| 2683 | - * |
|
| 2684 | - * @since 1.0.19 |
|
| 2685 | - * @param int|bool $value confirmed. |
|
| 2686 | - */ |
|
| 2687 | - public function set_customer_address_confirmed( $value ) { |
|
| 2688 | - $this->set_address_confirmed( $value ); |
|
| 2682 | + * Alias of self::set_address_confirmed(). |
|
| 2683 | + * |
|
| 2684 | + * @since 1.0.19 |
|
| 2685 | + * @param int|bool $value confirmed. |
|
| 2686 | + */ |
|
| 2687 | + public function set_customer_address_confirmed( $value ) { |
|
| 2688 | + $this->set_address_confirmed( $value ); |
|
| 2689 | 2689 | } |
| 2690 | 2690 | |
| 2691 | 2691 | /** |
| 2692 | - * Set the invoice sub total. |
|
| 2693 | - * |
|
| 2694 | - * @since 1.0.19 |
|
| 2695 | - * @param float $value sub total. |
|
| 2696 | - */ |
|
| 2697 | - public function set_subtotal( $value ) { |
|
| 2698 | - $this->set_prop( 'subtotal', $value ); |
|
| 2692 | + * Set the invoice sub total. |
|
| 2693 | + * |
|
| 2694 | + * @since 1.0.19 |
|
| 2695 | + * @param float $value sub total. |
|
| 2696 | + */ |
|
| 2697 | + public function set_subtotal( $value ) { |
|
| 2698 | + $this->set_prop( 'subtotal', $value ); |
|
| 2699 | 2699 | } |
| 2700 | 2700 | |
| 2701 | 2701 | /** |
| 2702 | - * Set the invoice discount amount. |
|
| 2703 | - * |
|
| 2704 | - * @since 1.0.19 |
|
| 2705 | - * @param float $value discount total. |
|
| 2706 | - */ |
|
| 2707 | - public function set_total_discount( $value ) { |
|
| 2708 | - $this->set_prop( 'total_discount', $value ); |
|
| 2702 | + * Set the invoice discount amount. |
|
| 2703 | + * |
|
| 2704 | + * @since 1.0.19 |
|
| 2705 | + * @param float $value discount total. |
|
| 2706 | + */ |
|
| 2707 | + public function set_total_discount( $value ) { |
|
| 2708 | + $this->set_prop( 'total_discount', $value ); |
|
| 2709 | 2709 | } |
| 2710 | 2710 | |
| 2711 | 2711 | /** |
| 2712 | - * Alias of self::set_total_discount(). |
|
| 2713 | - * |
|
| 2714 | - * @since 1.0.19 |
|
| 2715 | - * @param float $value discount total. |
|
| 2716 | - */ |
|
| 2717 | - public function set_discount( $value ) { |
|
| 2718 | - $this->set_total_discount( $value ); |
|
| 2712 | + * Alias of self::set_total_discount(). |
|
| 2713 | + * |
|
| 2714 | + * @since 1.0.19 |
|
| 2715 | + * @param float $value discount total. |
|
| 2716 | + */ |
|
| 2717 | + public function set_discount( $value ) { |
|
| 2718 | + $this->set_total_discount( $value ); |
|
| 2719 | 2719 | } |
| 2720 | 2720 | |
| 2721 | 2721 | /** |
| 2722 | - * Set the invoice tax amount. |
|
| 2723 | - * |
|
| 2724 | - * @since 1.0.19 |
|
| 2725 | - * @param float $value tax total. |
|
| 2726 | - */ |
|
| 2727 | - public function set_total_tax( $value ) { |
|
| 2728 | - $this->set_prop( 'total_tax', $value ); |
|
| 2722 | + * Set the invoice tax amount. |
|
| 2723 | + * |
|
| 2724 | + * @since 1.0.19 |
|
| 2725 | + * @param float $value tax total. |
|
| 2726 | + */ |
|
| 2727 | + public function set_total_tax( $value ) { |
|
| 2728 | + $this->set_prop( 'total_tax', $value ); |
|
| 2729 | 2729 | } |
| 2730 | 2730 | |
| 2731 | 2731 | /** |
| 2732 | - * Alias of self::set_total_tax(). |
|
| 2733 | - * |
|
| 2734 | - * @since 1.0.19 |
|
| 2735 | - * @param float $value tax total. |
|
| 2736 | - */ |
|
| 2737 | - public function set_tax_total( $value ) { |
|
| 2738 | - $this->set_total_tax( $value ); |
|
| 2732 | + * Alias of self::set_total_tax(). |
|
| 2733 | + * |
|
| 2734 | + * @since 1.0.19 |
|
| 2735 | + * @param float $value tax total. |
|
| 2736 | + */ |
|
| 2737 | + public function set_tax_total( $value ) { |
|
| 2738 | + $this->set_total_tax( $value ); |
|
| 2739 | 2739 | } |
| 2740 | 2740 | |
| 2741 | 2741 | /** |
| 2742 | - * Set the invoice fees amount. |
|
| 2743 | - * |
|
| 2744 | - * @since 1.0.19 |
|
| 2745 | - * @param float $value fees total. |
|
| 2746 | - */ |
|
| 2747 | - public function set_total_fees( $value ) { |
|
| 2748 | - $this->set_prop( 'total_fees', $value ); |
|
| 2742 | + * Set the invoice fees amount. |
|
| 2743 | + * |
|
| 2744 | + * @since 1.0.19 |
|
| 2745 | + * @param float $value fees total. |
|
| 2746 | + */ |
|
| 2747 | + public function set_total_fees( $value ) { |
|
| 2748 | + $this->set_prop( 'total_fees', $value ); |
|
| 2749 | 2749 | } |
| 2750 | 2750 | |
| 2751 | 2751 | /** |
| 2752 | - * Alias of self::set_total_fees(). |
|
| 2753 | - * |
|
| 2754 | - * @since 1.0.19 |
|
| 2755 | - * @param float $value fees total. |
|
| 2756 | - */ |
|
| 2757 | - public function set_fees_total( $value ) { |
|
| 2758 | - $this->set_total_fees( $value ); |
|
| 2752 | + * Alias of self::set_total_fees(). |
|
| 2753 | + * |
|
| 2754 | + * @since 1.0.19 |
|
| 2755 | + * @param float $value fees total. |
|
| 2756 | + */ |
|
| 2757 | + public function set_fees_total( $value ) { |
|
| 2758 | + $this->set_total_fees( $value ); |
|
| 2759 | 2759 | } |
| 2760 | 2760 | |
| 2761 | 2761 | /** |
| 2762 | - * Set the invoice fees. |
|
| 2763 | - * |
|
| 2764 | - * @since 1.0.19 |
|
| 2765 | - * @param array $value fees. |
|
| 2766 | - */ |
|
| 2767 | - public function set_fees( $value ) { |
|
| 2762 | + * Set the invoice fees. |
|
| 2763 | + * |
|
| 2764 | + * @since 1.0.19 |
|
| 2765 | + * @param array $value fees. |
|
| 2766 | + */ |
|
| 2767 | + public function set_fees( $value ) { |
|
| 2768 | 2768 | |
| 2769 | - if ( ! is_array( $value ) ) { |
|
| 2770 | - $value = array(); |
|
| 2771 | - } |
|
| 2769 | + if ( ! is_array( $value ) ) { |
|
| 2770 | + $value = array(); |
|
| 2771 | + } |
|
| 2772 | 2772 | |
| 2773 | - $this->set_prop( 'fees', $value ); |
|
| 2773 | + $this->set_prop( 'fees', $value ); |
|
| 2774 | 2774 | |
| 2775 | 2775 | } |
| 2776 | 2776 | |
| 2777 | 2777 | /** |
| 2778 | - * Set the invoice taxes. |
|
| 2779 | - * |
|
| 2780 | - * @since 1.0.19 |
|
| 2781 | - * @param array $value taxes. |
|
| 2782 | - */ |
|
| 2783 | - public function set_taxes( $value ) { |
|
| 2778 | + * Set the invoice taxes. |
|
| 2779 | + * |
|
| 2780 | + * @since 1.0.19 |
|
| 2781 | + * @param array $value taxes. |
|
| 2782 | + */ |
|
| 2783 | + public function set_taxes( $value ) { |
|
| 2784 | 2784 | |
| 2785 | - if ( ! is_array( $value ) ) { |
|
| 2786 | - $value = array(); |
|
| 2787 | - } |
|
| 2785 | + if ( ! is_array( $value ) ) { |
|
| 2786 | + $value = array(); |
|
| 2787 | + } |
|
| 2788 | 2788 | |
| 2789 | - $this->set_prop( 'taxes', $value ); |
|
| 2789 | + $this->set_prop( 'taxes', $value ); |
|
| 2790 | 2790 | |
| 2791 | 2791 | } |
| 2792 | 2792 | |
| 2793 | 2793 | /** |
| 2794 | - * Set the invoice discounts. |
|
| 2795 | - * |
|
| 2796 | - * @since 1.0.19 |
|
| 2797 | - * @param array $value discounts. |
|
| 2798 | - */ |
|
| 2799 | - public function set_discounts( $value ) { |
|
| 2794 | + * Set the invoice discounts. |
|
| 2795 | + * |
|
| 2796 | + * @since 1.0.19 |
|
| 2797 | + * @param array $value discounts. |
|
| 2798 | + */ |
|
| 2799 | + public function set_discounts( $value ) { |
|
| 2800 | 2800 | |
| 2801 | - if ( ! is_array( $value ) ) { |
|
| 2802 | - $value = array(); |
|
| 2803 | - } |
|
| 2801 | + if ( ! is_array( $value ) ) { |
|
| 2802 | + $value = array(); |
|
| 2803 | + } |
|
| 2804 | 2804 | |
| 2805 | - $this->set_prop( 'discounts', $value ); |
|
| 2805 | + $this->set_prop( 'discounts', $value ); |
|
| 2806 | 2806 | } |
| 2807 | 2807 | |
| 2808 | 2808 | /** |
| 2809 | - * Set the invoice items. |
|
| 2810 | - * |
|
| 2811 | - * @since 1.0.19 |
|
| 2812 | - * @param GetPaid_Form_Item[] $value items. |
|
| 2813 | - */ |
|
| 2814 | - public function set_items( $value ) { |
|
| 2809 | + * Set the invoice items. |
|
| 2810 | + * |
|
| 2811 | + * @since 1.0.19 |
|
| 2812 | + * @param GetPaid_Form_Item[] $value items. |
|
| 2813 | + */ |
|
| 2814 | + public function set_items( $value ) { |
|
| 2815 | 2815 | |
| 2816 | 2816 | // Remove existing items. |
| 2817 | 2817 | $this->set_prop( 'items', array() ); |
@@ -2828,95 +2828,95 @@ discard block |
||
| 2828 | 2828 | } |
| 2829 | 2829 | |
| 2830 | 2830 | /** |
| 2831 | - * Set the payment form. |
|
| 2832 | - * |
|
| 2833 | - * @since 1.0.19 |
|
| 2834 | - * @param int $value payment form. |
|
| 2835 | - */ |
|
| 2836 | - public function set_payment_form( $value ) { |
|
| 2837 | - $this->set_prop( 'payment_form', $value ); |
|
| 2831 | + * Set the payment form. |
|
| 2832 | + * |
|
| 2833 | + * @since 1.0.19 |
|
| 2834 | + * @param int $value payment form. |
|
| 2835 | + */ |
|
| 2836 | + public function set_payment_form( $value ) { |
|
| 2837 | + $this->set_prop( 'payment_form', $value ); |
|
| 2838 | 2838 | } |
| 2839 | 2839 | |
| 2840 | 2840 | /** |
| 2841 | - * Set the submission id. |
|
| 2842 | - * |
|
| 2843 | - * @since 1.0.19 |
|
| 2844 | - * @param string $value submission id. |
|
| 2845 | - */ |
|
| 2846 | - public function set_submission_id( $value ) { |
|
| 2847 | - $this->set_prop( 'submission_id', $value ); |
|
| 2841 | + * Set the submission id. |
|
| 2842 | + * |
|
| 2843 | + * @since 1.0.19 |
|
| 2844 | + * @param string $value submission id. |
|
| 2845 | + */ |
|
| 2846 | + public function set_submission_id( $value ) { |
|
| 2847 | + $this->set_prop( 'submission_id', $value ); |
|
| 2848 | 2848 | } |
| 2849 | 2849 | |
| 2850 | 2850 | /** |
| 2851 | - * Set the discount code. |
|
| 2852 | - * |
|
| 2853 | - * @since 1.0.19 |
|
| 2854 | - * @param string $value discount code. |
|
| 2855 | - */ |
|
| 2856 | - public function set_discount_code( $value ) { |
|
| 2857 | - $this->set_prop( 'discount_code', $value ); |
|
| 2851 | + * Set the discount code. |
|
| 2852 | + * |
|
| 2853 | + * @since 1.0.19 |
|
| 2854 | + * @param string $value discount code. |
|
| 2855 | + */ |
|
| 2856 | + public function set_discount_code( $value ) { |
|
| 2857 | + $this->set_prop( 'discount_code', $value ); |
|
| 2858 | 2858 | } |
| 2859 | 2859 | |
| 2860 | 2860 | /** |
| 2861 | - * Set the gateway. |
|
| 2862 | - * |
|
| 2863 | - * @since 1.0.19 |
|
| 2864 | - * @param string $value gateway. |
|
| 2865 | - */ |
|
| 2866 | - public function set_gateway( $value ) { |
|
| 2867 | - $this->set_prop( 'gateway', $value ); |
|
| 2861 | + * Set the gateway. |
|
| 2862 | + * |
|
| 2863 | + * @since 1.0.19 |
|
| 2864 | + * @param string $value gateway. |
|
| 2865 | + */ |
|
| 2866 | + public function set_gateway( $value ) { |
|
| 2867 | + $this->set_prop( 'gateway', $value ); |
|
| 2868 | 2868 | } |
| 2869 | 2869 | |
| 2870 | 2870 | /** |
| 2871 | - * Set the transaction id. |
|
| 2872 | - * |
|
| 2873 | - * @since 1.0.19 |
|
| 2874 | - * @param string $value transaction id. |
|
| 2875 | - */ |
|
| 2876 | - public function set_transaction_id( $value ) { |
|
| 2877 | - if ( ! empty( $value ) ) { |
|
| 2878 | - $this->set_prop( 'transaction_id', $value ); |
|
| 2879 | - } |
|
| 2871 | + * Set the transaction id. |
|
| 2872 | + * |
|
| 2873 | + * @since 1.0.19 |
|
| 2874 | + * @param string $value transaction id. |
|
| 2875 | + */ |
|
| 2876 | + public function set_transaction_id( $value ) { |
|
| 2877 | + if ( ! empty( $value ) ) { |
|
| 2878 | + $this->set_prop( 'transaction_id', $value ); |
|
| 2879 | + } |
|
| 2880 | 2880 | } |
| 2881 | 2881 | |
| 2882 | 2882 | /** |
| 2883 | - * Set the currency id. |
|
| 2884 | - * |
|
| 2885 | - * @since 1.0.19 |
|
| 2886 | - * @param string $value currency id. |
|
| 2887 | - */ |
|
| 2888 | - public function set_currency( $value ) { |
|
| 2889 | - $this->set_prop( 'currency', $value ); |
|
| 2883 | + * Set the currency id. |
|
| 2884 | + * |
|
| 2885 | + * @since 1.0.19 |
|
| 2886 | + * @param string $value currency id. |
|
| 2887 | + */ |
|
| 2888 | + public function set_currency( $value ) { |
|
| 2889 | + $this->set_prop( 'currency', $value ); |
|
| 2890 | 2890 | } |
| 2891 | 2891 | |
| 2892 | - /** |
|
| 2893 | - * Set whether to disable taxes. |
|
| 2894 | - * |
|
| 2895 | - * @since 1.0.19 |
|
| 2896 | - * @param bool $value value. |
|
| 2897 | - */ |
|
| 2898 | - public function set_disable_taxes( $value ) { |
|
| 2899 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2900 | - } |
|
| 2892 | + /** |
|
| 2893 | + * Set whether to disable taxes. |
|
| 2894 | + * |
|
| 2895 | + * @since 1.0.19 |
|
| 2896 | + * @param bool $value value. |
|
| 2897 | + */ |
|
| 2898 | + public function set_disable_taxes( $value ) { |
|
| 2899 | + $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2900 | + } |
|
| 2901 | 2901 | |
| 2902 | 2902 | /** |
| 2903 | - * Set the subscription id. |
|
| 2904 | - * |
|
| 2905 | - * @since 1.0.19 |
|
| 2906 | - * @param string $value subscription id. |
|
| 2907 | - */ |
|
| 2908 | - public function set_subscription_id( $value ) { |
|
| 2909 | - $this->set_prop( 'subscription_id', $value ); |
|
| 2910 | - } |
|
| 2903 | + * Set the subscription id. |
|
| 2904 | + * |
|
| 2905 | + * @since 1.0.19 |
|
| 2906 | + * @param string $value subscription id. |
|
| 2907 | + */ |
|
| 2908 | + public function set_subscription_id( $value ) { |
|
| 2909 | + $this->set_prop( 'subscription_id', $value ); |
|
| 2910 | + } |
|
| 2911 | 2911 | |
| 2912 | - /** |
|
| 2913 | - * Set the remote subscription id. |
|
| 2914 | - * |
|
| 2915 | - * @since 1.0.19 |
|
| 2916 | - * @param string $value subscription id. |
|
| 2917 | - */ |
|
| 2918 | - public function set_remote_subscription_id( $value ) { |
|
| 2919 | - $this->set_prop( 'remote_subscription_id', $value ); |
|
| 2912 | + /** |
|
| 2913 | + * Set the remote subscription id. |
|
| 2914 | + * |
|
| 2915 | + * @since 1.0.19 |
|
| 2916 | + * @param string $value subscription id. |
|
| 2917 | + */ |
|
| 2918 | + public function set_remote_subscription_id( $value ) { |
|
| 2919 | + $this->set_prop( 'remote_subscription_id', $value ); |
|
| 2920 | 2920 | } |
| 2921 | 2921 | |
| 2922 | 2922 | /* |
@@ -2955,12 +2955,12 @@ discard block |
||
| 2955 | 2955 | */ |
| 2956 | 2956 | public function is_taxable() { |
| 2957 | 2957 | return ! $this->get_disable_taxes(); |
| 2958 | - } |
|
| 2958 | + } |
|
| 2959 | 2959 | |
| 2960 | - /** |
|
| 2961 | - * @deprecated |
|
| 2962 | - */ |
|
| 2963 | - public function has_vat() { |
|
| 2960 | + /** |
|
| 2961 | + * @deprecated |
|
| 2962 | + */ |
|
| 2963 | + public function has_vat() { |
|
| 2964 | 2964 | global $wpinv_euvat, $wpi_country; |
| 2965 | 2965 | |
| 2966 | 2966 | $requires_vat = false; |
@@ -2971,17 +2971,17 @@ discard block |
||
| 2971 | 2971 | } |
| 2972 | 2972 | |
| 2973 | 2973 | return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this ); |
| 2974 | - } |
|
| 2974 | + } |
|
| 2975 | 2975 | |
| 2976 | - /** |
|
| 2977 | - * Checks to see if the invoice requires payment. |
|
| 2978 | - */ |
|
| 2979 | - public function is_free() { |
|
| 2976 | + /** |
|
| 2977 | + * Checks to see if the invoice requires payment. |
|
| 2978 | + */ |
|
| 2979 | + public function is_free() { |
|
| 2980 | 2980 | $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
| 2981 | 2981 | |
| 2982 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 2983 | - $is_free = false; |
|
| 2984 | - } |
|
| 2982 | + if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 2983 | + $is_free = false; |
|
| 2984 | + } |
|
| 2985 | 2985 | |
| 2986 | 2986 | return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
| 2987 | 2987 | } |
@@ -2992,46 +2992,46 @@ discard block |
||
| 2992 | 2992 | public function is_paid() { |
| 2993 | 2993 | $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
| 2994 | 2994 | return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
| 2995 | - } |
|
| 2995 | + } |
|
| 2996 | 2996 | |
| 2997 | - /** |
|
| 2997 | + /** |
|
| 2998 | 2998 | * Checks if the invoice needs payment. |
| 2999 | 2999 | */ |
| 3000 | - public function needs_payment() { |
|
| 3001 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 3000 | + public function needs_payment() { |
|
| 3001 | + $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 3002 | 3002 | return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
| 3003 | 3003 | } |
| 3004 | 3004 | |
| 3005 | - /** |
|
| 3005 | + /** |
|
| 3006 | 3006 | * Checks if the invoice is refunded. |
| 3007 | 3007 | */ |
| 3008 | - public function is_refunded() { |
|
| 3008 | + public function is_refunded() { |
|
| 3009 | 3009 | $is_refunded = $this->has_status( 'wpi-refunded' ); |
| 3010 | 3010 | return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
| 3011 | - } |
|
| 3011 | + } |
|
| 3012 | 3012 | |
| 3013 | - /** |
|
| 3013 | + /** |
|
| 3014 | 3014 | * Checks if the invoice is held. |
| 3015 | 3015 | */ |
| 3016 | - public function is_held() { |
|
| 3016 | + public function is_held() { |
|
| 3017 | 3017 | $is_held = $this->has_status( 'wpi-onhold' ); |
| 3018 | 3018 | return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
| 3019 | - } |
|
| 3019 | + } |
|
| 3020 | 3020 | |
| 3021 | - /** |
|
| 3021 | + /** |
|
| 3022 | 3022 | * Checks if the invoice is due. |
| 3023 | 3023 | */ |
| 3024 | - public function is_due() { |
|
| 3025 | - $due_date = $this->get_due_date(); |
|
| 3026 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 3027 | - } |
|
| 3024 | + public function is_due() { |
|
| 3025 | + $due_date = $this->get_due_date(); |
|
| 3026 | + return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 3027 | + } |
|
| 3028 | 3028 | |
| 3029 | - /** |
|
| 3029 | + /** |
|
| 3030 | 3030 | * Checks if the invoice is draft. |
| 3031 | 3031 | */ |
| 3032 | - public function is_draft() { |
|
| 3032 | + public function is_draft() { |
|
| 3033 | 3033 | return $this->has_status( 'draft, auto-draft' ); |
| 3034 | - } |
|
| 3034 | + } |
|
| 3035 | 3035 | |
| 3036 | 3036 | /** |
| 3037 | 3037 | * Checks if the invoice has a given status. |
@@ -3039,9 +3039,9 @@ discard block |
||
| 3039 | 3039 | public function has_status( $status ) { |
| 3040 | 3040 | $status = wpinv_parse_list( $status ); |
| 3041 | 3041 | return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
| 3042 | - } |
|
| 3042 | + } |
|
| 3043 | 3043 | |
| 3044 | - /** |
|
| 3044 | + /** |
|
| 3045 | 3045 | * Checks if the invoice is of a given type. |
| 3046 | 3046 | */ |
| 3047 | 3047 | public function is_type( $type ) { |
@@ -3064,25 +3064,25 @@ discard block |
||
| 3064 | 3064 | */ |
| 3065 | 3065 | public function has_free_trial() { |
| 3066 | 3066 | return $this->is_recurring() && 0 == $this->get_initial_total(); |
| 3067 | - } |
|
| 3067 | + } |
|
| 3068 | 3068 | |
| 3069 | - /** |
|
| 3069 | + /** |
|
| 3070 | 3070 | * @deprecated |
| 3071 | 3071 | */ |
| 3072 | 3072 | public function is_free_trial() { |
| 3073 | 3073 | $this->has_free_trial(); |
| 3074 | 3074 | } |
| 3075 | 3075 | |
| 3076 | - /** |
|
| 3076 | + /** |
|
| 3077 | 3077 | * Check if the initial payment if 0. |
| 3078 | 3078 | * |
| 3079 | 3079 | */ |
| 3080 | - public function is_initial_free() { |
|
| 3080 | + public function is_initial_free() { |
|
| 3081 | 3081 | $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
| 3082 | 3082 | return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
| 3083 | 3083 | } |
| 3084 | 3084 | |
| 3085 | - /** |
|
| 3085 | + /** |
|
| 3086 | 3086 | * Check if the recurring item has a free trial. |
| 3087 | 3087 | * |
| 3088 | 3088 | */ |
@@ -3095,21 +3095,21 @@ discard block |
||
| 3095 | 3095 | |
| 3096 | 3096 | $item = $this->get_recurring( true ); |
| 3097 | 3097 | return $item->has_free_trial(); |
| 3098 | - } |
|
| 3098 | + } |
|
| 3099 | 3099 | |
| 3100 | - /** |
|
| 3100 | + /** |
|
| 3101 | 3101 | * Check if the free trial is a result of a discount. |
| 3102 | 3102 | */ |
| 3103 | 3103 | public function is_free_trial_from_discount() { |
| 3104 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3105 | - } |
|
| 3104 | + return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3105 | + } |
|
| 3106 | 3106 | |
| 3107 | - /** |
|
| 3107 | + /** |
|
| 3108 | 3108 | * @deprecated |
| 3109 | 3109 | */ |
| 3110 | 3110 | public function discount_first_payment_only() { |
| 3111 | 3111 | |
| 3112 | - $discount_code = $this->get_discount_code(); |
|
| 3112 | + $discount_code = $this->get_discount_code(); |
|
| 3113 | 3113 | if ( empty( $this->discount_code ) || ! $this->is_recurring() ) { |
| 3114 | 3114 | return true; |
| 3115 | 3115 | } |
@@ -3140,28 +3140,28 @@ discard block |
||
| 3140 | 3140 | */ |
| 3141 | 3141 | public function add_item( $item ) { |
| 3142 | 3142 | |
| 3143 | - if ( is_array( $item ) ) { |
|
| 3144 | - $item = $this->process_array_item( $item ); |
|
| 3145 | - } |
|
| 3143 | + if ( is_array( $item ) ) { |
|
| 3144 | + $item = $this->process_array_item( $item ); |
|
| 3145 | + } |
|
| 3146 | 3146 | |
| 3147 | - if ( is_numeric( $item ) ) { |
|
| 3148 | - $item = new GetPaid_Form_Item( $item ); |
|
| 3149 | - } |
|
| 3147 | + if ( is_numeric( $item ) ) { |
|
| 3148 | + $item = new GetPaid_Form_Item( $item ); |
|
| 3149 | + } |
|
| 3150 | 3150 | |
| 3151 | 3151 | // Make sure that it is available for purchase. |
| 3152 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3153 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3152 | + if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3153 | + return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3154 | 3154 | } |
| 3155 | 3155 | |
| 3156 | 3156 | // Do we have a recurring item? |
| 3157 | - if ( $item->is_recurring() ) { |
|
| 3157 | + if ( $item->is_recurring() ) { |
|
| 3158 | 3158 | |
| 3159 | - // An invoice can only contain one recurring item. |
|
| 3160 | - if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
| 3161 | - return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
| 3162 | - } |
|
| 3159 | + // An invoice can only contain one recurring item. |
|
| 3160 | + if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
| 3161 | + return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
| 3162 | + } |
|
| 3163 | 3163 | |
| 3164 | - $this->recurring_item = $item->get_id(); |
|
| 3164 | + $this->recurring_item = $item->get_id(); |
|
| 3165 | 3165 | } |
| 3166 | 3166 | |
| 3167 | 3167 | // Invoice id. |
@@ -3172,60 +3172,60 @@ discard block |
||
| 3172 | 3172 | $items[ (int) $item->get_id() ] = $item; |
| 3173 | 3173 | |
| 3174 | 3174 | $this->set_prop( 'items', $items ); |
| 3175 | - return true; |
|
| 3176 | - } |
|
| 3175 | + return true; |
|
| 3176 | + } |
|
| 3177 | 3177 | |
| 3178 | - /** |
|
| 3179 | - * Converts an array to an item. |
|
| 3180 | - * |
|
| 3181 | - * @since 1.0.19 |
|
| 3182 | - * @return GetPaid_Form_Item |
|
| 3183 | - */ |
|
| 3184 | - protected function process_array_item( $array ) { |
|
| 3178 | + /** |
|
| 3179 | + * Converts an array to an item. |
|
| 3180 | + * |
|
| 3181 | + * @since 1.0.19 |
|
| 3182 | + * @return GetPaid_Form_Item |
|
| 3183 | + */ |
|
| 3184 | + protected function process_array_item( $array ) { |
|
| 3185 | 3185 | |
| 3186 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
| 3187 | - $item = new GetPaid_Form_Item( $item_id ); |
|
| 3186 | + $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
| 3187 | + $item = new GetPaid_Form_Item( $item_id ); |
|
| 3188 | 3188 | |
| 3189 | - // Set item data. |
|
| 3190 | - foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
| 3191 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
| 3192 | - $method = "set_$key"; |
|
| 3193 | - $item->$method( $array[ "item_$key" ] ); |
|
| 3194 | - } |
|
| 3195 | - } |
|
| 3189 | + // Set item data. |
|
| 3190 | + foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
| 3191 | + if ( isset( $array[ "item_$key" ] ) ) { |
|
| 3192 | + $method = "set_$key"; |
|
| 3193 | + $item->$method( $array[ "item_$key" ] ); |
|
| 3194 | + } |
|
| 3195 | + } |
|
| 3196 | 3196 | |
| 3197 | - if ( isset( $array['quantity'] ) ) { |
|
| 3198 | - $item->set_quantity( $array['quantity'] ); |
|
| 3199 | - } |
|
| 3197 | + if ( isset( $array['quantity'] ) ) { |
|
| 3198 | + $item->set_quantity( $array['quantity'] ); |
|
| 3199 | + } |
|
| 3200 | 3200 | |
| 3201 | - // Set item meta. |
|
| 3202 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
| 3203 | - $item->set_item_meta( $array['meta'] ); |
|
| 3204 | - } |
|
| 3201 | + // Set item meta. |
|
| 3202 | + if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
| 3203 | + $item->set_item_meta( $array['meta'] ); |
|
| 3204 | + } |
|
| 3205 | 3205 | |
| 3206 | - return $item; |
|
| 3206 | + return $item; |
|
| 3207 | 3207 | |
| 3208 | - } |
|
| 3208 | + } |
|
| 3209 | 3209 | |
| 3210 | 3210 | /** |
| 3211 | - * Retrieves a specific item. |
|
| 3212 | - * |
|
| 3213 | - * @since 1.0.19 |
|
| 3214 | - */ |
|
| 3215 | - public function get_item( $item_id ) { |
|
| 3216 | - $items = $this->get_items(); |
|
| 3217 | - $item_id = (int) $item_id; |
|
| 3218 | - return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
| 3211 | + * Retrieves a specific item. |
|
| 3212 | + * |
|
| 3213 | + * @since 1.0.19 |
|
| 3214 | + */ |
|
| 3215 | + public function get_item( $item_id ) { |
|
| 3216 | + $items = $this->get_items(); |
|
| 3217 | + $item_id = (int) $item_id; |
|
| 3218 | + return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
| 3219 | 3219 | } |
| 3220 | 3220 | |
| 3221 | 3221 | /** |
| 3222 | - * Removes a specific item. |
|
| 3223 | - * |
|
| 3224 | - * @since 1.0.19 |
|
| 3225 | - */ |
|
| 3226 | - public function remove_item( $item_id ) { |
|
| 3227 | - $items = $this->get_items(); |
|
| 3228 | - $item_id = (int) $item_id; |
|
| 3222 | + * Removes a specific item. |
|
| 3223 | + * |
|
| 3224 | + * @since 1.0.19 |
|
| 3225 | + */ |
|
| 3226 | + public function remove_item( $item_id ) { |
|
| 3227 | + $items = $this->get_items(); |
|
| 3228 | + $item_id = (int) $item_id; |
|
| 3229 | 3229 | |
| 3230 | 3230 | if ( $item_id == $this->recurring_item ) { |
| 3231 | 3231 | $this->recurring_item = null; |
@@ -3238,35 +3238,35 @@ discard block |
||
| 3238 | 3238 | } |
| 3239 | 3239 | |
| 3240 | 3240 | /** |
| 3241 | - * Adds a fee to the invoice. |
|
| 3242 | - * |
|
| 3243 | - * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
|
| 3244 | - * @since 1.0.19 |
|
| 3245 | - */ |
|
| 3241 | + * Adds a fee to the invoice. |
|
| 3242 | + * |
|
| 3243 | + * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
|
| 3244 | + * @since 1.0.19 |
|
| 3245 | + */ |
|
| 3246 | 3246 | public function add_fee( $fee ) { |
| 3247 | 3247 | |
| 3248 | - $fees = $this->get_fees(); |
|
| 3249 | - $fees[ $fee['name'] ] = $fee; |
|
| 3250 | - $this->set_prop( 'fees', $fees ); |
|
| 3248 | + $fees = $this->get_fees(); |
|
| 3249 | + $fees[ $fee['name'] ] = $fee; |
|
| 3250 | + $this->set_prop( 'fees', $fees ); |
|
| 3251 | 3251 | |
| 3252 | 3252 | } |
| 3253 | 3253 | |
| 3254 | 3254 | /** |
| 3255 | - * Retrieves a specific fee. |
|
| 3256 | - * |
|
| 3257 | - * @since 1.0.19 |
|
| 3258 | - */ |
|
| 3259 | - public function get_fee( $fee ) { |
|
| 3255 | + * Retrieves a specific fee. |
|
| 3256 | + * |
|
| 3257 | + * @since 1.0.19 |
|
| 3258 | + */ |
|
| 3259 | + public function get_fee( $fee ) { |
|
| 3260 | 3260 | $fees = $this->get_fees(); |
| 3261 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3261 | + return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3262 | 3262 | } |
| 3263 | 3263 | |
| 3264 | 3264 | /** |
| 3265 | - * Removes a specific fee. |
|
| 3266 | - * |
|
| 3267 | - * @since 1.0.19 |
|
| 3268 | - */ |
|
| 3269 | - public function remove_fee( $fee ) { |
|
| 3265 | + * Removes a specific fee. |
|
| 3266 | + * |
|
| 3267 | + * @since 1.0.19 |
|
| 3268 | + */ |
|
| 3269 | + public function remove_fee( $fee ) { |
|
| 3270 | 3270 | $fees = $this->get_fees(); |
| 3271 | 3271 | if ( isset( $fees[ $fee ] ) ) { |
| 3272 | 3272 | unset( $fees[ $fee ] ); |
@@ -3274,43 +3274,43 @@ discard block |
||
| 3274 | 3274 | } |
| 3275 | 3275 | } |
| 3276 | 3276 | |
| 3277 | - /** |
|
| 3278 | - * Adds a discount to the invoice. |
|
| 3279 | - * |
|
| 3280 | - * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
|
| 3281 | - * @since 1.0.19 |
|
| 3282 | - */ |
|
| 3283 | - public function add_discount( $discount ) { |
|
| 3277 | + /** |
|
| 3278 | + * Adds a discount to the invoice. |
|
| 3279 | + * |
|
| 3280 | + * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
|
| 3281 | + * @since 1.0.19 |
|
| 3282 | + */ |
|
| 3283 | + public function add_discount( $discount ) { |
|
| 3284 | 3284 | |
| 3285 | - $discounts = $this->get_discounts(); |
|
| 3286 | - $discounts[ $discount['name'] ] = $discount; |
|
| 3287 | - $this->set_prop( 'discounts', $discounts ); |
|
| 3285 | + $discounts = $this->get_discounts(); |
|
| 3286 | + $discounts[ $discount['name'] ] = $discount; |
|
| 3287 | + $this->set_prop( 'discounts', $discounts ); |
|
| 3288 | 3288 | |
| 3289 | - } |
|
| 3289 | + } |
|
| 3290 | 3290 | |
| 3291 | 3291 | /** |
| 3292 | - * Retrieves a specific discount. |
|
| 3293 | - * |
|
| 3294 | - * @since 1.0.19 |
|
| 3295 | - * @return float |
|
| 3296 | - */ |
|
| 3297 | - public function get_discount( $discount = false ) { |
|
| 3292 | + * Retrieves a specific discount. |
|
| 3293 | + * |
|
| 3294 | + * @since 1.0.19 |
|
| 3295 | + * @return float |
|
| 3296 | + */ |
|
| 3297 | + public function get_discount( $discount = false ) { |
|
| 3298 | 3298 | |
| 3299 | - // Backwards compatibilty. |
|
| 3300 | - if ( empty( $discount ) ) { |
|
| 3301 | - return $this->get_total_discount(); |
|
| 3302 | - } |
|
| 3299 | + // Backwards compatibilty. |
|
| 3300 | + if ( empty( $discount ) ) { |
|
| 3301 | + return $this->get_total_discount(); |
|
| 3302 | + } |
|
| 3303 | 3303 | |
| 3304 | 3304 | $discounts = $this->get_discounts(); |
| 3305 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3305 | + return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3306 | 3306 | } |
| 3307 | 3307 | |
| 3308 | 3308 | /** |
| 3309 | - * Removes a specific discount. |
|
| 3310 | - * |
|
| 3311 | - * @since 1.0.19 |
|
| 3312 | - */ |
|
| 3313 | - public function remove_discount( $discount ) { |
|
| 3309 | + * Removes a specific discount. |
|
| 3310 | + * |
|
| 3311 | + * @since 1.0.19 |
|
| 3312 | + */ |
|
| 3313 | + public function remove_discount( $discount ) { |
|
| 3314 | 3314 | $discounts = $this->get_discounts(); |
| 3315 | 3315 | if ( isset( $discounts[ $discount ] ) ) { |
| 3316 | 3316 | unset( $discounts[ $discount ] ); |
@@ -3327,34 +3327,34 @@ discard block |
||
| 3327 | 3327 | if ( $this->is_taxable() ) { |
| 3328 | 3328 | |
| 3329 | 3329 | $taxes = $this->get_taxes(); |
| 3330 | - $taxes[ $tax['name'] ] = $tax; |
|
| 3331 | - $this->set_prop( 'taxes', $tax ); |
|
| 3330 | + $taxes[ $tax['name'] ] = $tax; |
|
| 3331 | + $this->set_prop( 'taxes', $tax ); |
|
| 3332 | 3332 | |
| 3333 | 3333 | } |
| 3334 | 3334 | } |
| 3335 | 3335 | |
| 3336 | 3336 | /** |
| 3337 | - * Retrieves a specific tax. |
|
| 3338 | - * |
|
| 3339 | - * @since 1.0.19 |
|
| 3340 | - */ |
|
| 3341 | - public function get_tax( $tax = null ) { |
|
| 3337 | + * Retrieves a specific tax. |
|
| 3338 | + * |
|
| 3339 | + * @since 1.0.19 |
|
| 3340 | + */ |
|
| 3341 | + public function get_tax( $tax = null ) { |
|
| 3342 | 3342 | |
| 3343 | - // Backwards compatility. |
|
| 3344 | - if ( empty( $tax ) ) { |
|
| 3345 | - return $this->get_total_tax(); |
|
| 3346 | - } |
|
| 3343 | + // Backwards compatility. |
|
| 3344 | + if ( empty( $tax ) ) { |
|
| 3345 | + return $this->get_total_tax(); |
|
| 3346 | + } |
|
| 3347 | 3347 | |
| 3348 | 3348 | $taxes = $this->get_taxes(); |
| 3349 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3349 | + return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3350 | 3350 | } |
| 3351 | 3351 | |
| 3352 | 3352 | /** |
| 3353 | - * Removes a specific tax. |
|
| 3354 | - * |
|
| 3355 | - * @since 1.0.19 |
|
| 3356 | - */ |
|
| 3357 | - public function remove_tax( $tax ) { |
|
| 3353 | + * Removes a specific tax. |
|
| 3354 | + * |
|
| 3355 | + * @since 1.0.19 |
|
| 3356 | + */ |
|
| 3357 | + public function remove_tax( $tax ) { |
|
| 3358 | 3358 | $taxes = $this->get_taxes(); |
| 3359 | 3359 | if ( isset( $taxes[ $tax ] ) ) { |
| 3360 | 3360 | unset( $taxes[ $tax ] ); |
@@ -3363,134 +3363,134 @@ discard block |
||
| 3363 | 3363 | } |
| 3364 | 3364 | |
| 3365 | 3365 | /** |
| 3366 | - * Recalculates the invoice subtotal. |
|
| 3367 | - * |
|
| 3368 | - * @since 1.0.19 |
|
| 3369 | - * @return float The recalculated subtotal |
|
| 3370 | - */ |
|
| 3371 | - public function recalculate_subtotal() { |
|
| 3366 | + * Recalculates the invoice subtotal. |
|
| 3367 | + * |
|
| 3368 | + * @since 1.0.19 |
|
| 3369 | + * @return float The recalculated subtotal |
|
| 3370 | + */ |
|
| 3371 | + public function recalculate_subtotal() { |
|
| 3372 | 3372 | $items = $this->get_items(); |
| 3373 | - $subtotal = 0; |
|
| 3374 | - $recurring = 0; |
|
| 3373 | + $subtotal = 0; |
|
| 3374 | + $recurring = 0; |
|
| 3375 | 3375 | |
| 3376 | 3376 | foreach ( $items as $item ) { |
| 3377 | - $subtotal += $item->get_sub_total(); |
|
| 3378 | - $recurring += $item->get_recurring_sub_total(); |
|
| 3377 | + $subtotal += $item->get_sub_total(); |
|
| 3378 | + $recurring += $item->get_recurring_sub_total(); |
|
| 3379 | 3379 | } |
| 3380 | 3380 | |
| 3381 | - $current = $this->is_renewal() ? $recurring : $subtotal; |
|
| 3382 | - $this->set_subtotal( $current ); |
|
| 3381 | + $current = $this->is_renewal() ? $recurring : $subtotal; |
|
| 3382 | + $this->set_subtotal( $current ); |
|
| 3383 | 3383 | |
| 3384 | - $this->totals['subtotal'] = array( |
|
| 3385 | - 'initial' => $subtotal, |
|
| 3386 | - 'recurring' => $recurring, |
|
| 3387 | - ); |
|
| 3384 | + $this->totals['subtotal'] = array( |
|
| 3385 | + 'initial' => $subtotal, |
|
| 3386 | + 'recurring' => $recurring, |
|
| 3387 | + ); |
|
| 3388 | 3388 | |
| 3389 | 3389 | return $current; |
| 3390 | 3390 | } |
| 3391 | 3391 | |
| 3392 | 3392 | /** |
| 3393 | - * Recalculates the invoice discount total. |
|
| 3394 | - * |
|
| 3395 | - * @since 1.0.19 |
|
| 3396 | - * @return float The recalculated discount |
|
| 3397 | - */ |
|
| 3398 | - public function recalculate_total_discount() { |
|
| 3393 | + * Recalculates the invoice discount total. |
|
| 3394 | + * |
|
| 3395 | + * @since 1.0.19 |
|
| 3396 | + * @return float The recalculated discount |
|
| 3397 | + */ |
|
| 3398 | + public function recalculate_total_discount() { |
|
| 3399 | 3399 | $discounts = $this->get_discounts(); |
| 3400 | - $discount = 0; |
|
| 3401 | - $recurring = 0; |
|
| 3400 | + $discount = 0; |
|
| 3401 | + $recurring = 0; |
|
| 3402 | 3402 | |
| 3403 | 3403 | foreach ( $discounts as $data ) { |
| 3404 | - $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
| 3405 | - $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
| 3406 | - } |
|
| 3404 | + $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
| 3405 | + $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
| 3406 | + } |
|
| 3407 | 3407 | |
| 3408 | - $current = $this->is_renewal() ? $recurring : $discount; |
|
| 3408 | + $current = $this->is_renewal() ? $recurring : $discount; |
|
| 3409 | 3409 | |
| 3410 | - $this->set_total_discount( $current ); |
|
| 3410 | + $this->set_total_discount( $current ); |
|
| 3411 | 3411 | |
| 3412 | - $this->totals['discount'] = array( |
|
| 3413 | - 'initial' => $discount, |
|
| 3414 | - 'recurring' => $recurring, |
|
| 3415 | - ); |
|
| 3412 | + $this->totals['discount'] = array( |
|
| 3413 | + 'initial' => $discount, |
|
| 3414 | + 'recurring' => $recurring, |
|
| 3415 | + ); |
|
| 3416 | 3416 | |
| 3417 | - return $current; |
|
| 3417 | + return $current; |
|
| 3418 | 3418 | |
| 3419 | 3419 | } |
| 3420 | 3420 | |
| 3421 | 3421 | /** |
| 3422 | - * Recalculates the invoice tax total. |
|
| 3423 | - * |
|
| 3424 | - * @since 1.0.19 |
|
| 3425 | - * @return float The recalculated tax |
|
| 3426 | - */ |
|
| 3427 | - public function recalculate_total_tax() { |
|
| 3422 | + * Recalculates the invoice tax total. |
|
| 3423 | + * |
|
| 3424 | + * @since 1.0.19 |
|
| 3425 | + * @return float The recalculated tax |
|
| 3426 | + */ |
|
| 3427 | + public function recalculate_total_tax() { |
|
| 3428 | 3428 | $taxes = $this->get_taxes(); |
| 3429 | - $tax = 0; |
|
| 3430 | - $recurring = 0; |
|
| 3429 | + $tax = 0; |
|
| 3430 | + $recurring = 0; |
|
| 3431 | 3431 | |
| 3432 | 3432 | foreach ( $taxes as $data ) { |
| 3433 | - $tax += wpinv_sanitize_amount( $data['initial_tax'] ); |
|
| 3434 | - $recurring += wpinv_sanitize_amount( $data['recurring_tax'] ); |
|
| 3435 | - } |
|
| 3433 | + $tax += wpinv_sanitize_amount( $data['initial_tax'] ); |
|
| 3434 | + $recurring += wpinv_sanitize_amount( $data['recurring_tax'] ); |
|
| 3435 | + } |
|
| 3436 | 3436 | |
| 3437 | - $current = $this->is_renewal() ? $recurring : $tax; |
|
| 3438 | - $this->set_total_tax( $current ); |
|
| 3437 | + $current = $this->is_renewal() ? $recurring : $tax; |
|
| 3438 | + $this->set_total_tax( $current ); |
|
| 3439 | 3439 | |
| 3440 | - $this->totals['tax'] = array( |
|
| 3441 | - 'initial' => $tax, |
|
| 3442 | - 'recurring' => $recurring, |
|
| 3443 | - ); |
|
| 3440 | + $this->totals['tax'] = array( |
|
| 3441 | + 'initial' => $tax, |
|
| 3442 | + 'recurring' => $recurring, |
|
| 3443 | + ); |
|
| 3444 | 3444 | |
| 3445 | - return $current; |
|
| 3445 | + return $current; |
|
| 3446 | 3446 | |
| 3447 | 3447 | } |
| 3448 | 3448 | |
| 3449 | 3449 | /** |
| 3450 | - * Recalculates the invoice fees total. |
|
| 3451 | - * |
|
| 3452 | - * @since 1.0.19 |
|
| 3453 | - * @return float The recalculated fee |
|
| 3454 | - */ |
|
| 3455 | - public function recalculate_total_fees() { |
|
| 3456 | - $fees = $this->get_fees(); |
|
| 3457 | - $fee = 0; |
|
| 3458 | - $recurring = 0; |
|
| 3450 | + * Recalculates the invoice fees total. |
|
| 3451 | + * |
|
| 3452 | + * @since 1.0.19 |
|
| 3453 | + * @return float The recalculated fee |
|
| 3454 | + */ |
|
| 3455 | + public function recalculate_total_fees() { |
|
| 3456 | + $fees = $this->get_fees(); |
|
| 3457 | + $fee = 0; |
|
| 3458 | + $recurring = 0; |
|
| 3459 | 3459 | |
| 3460 | 3460 | foreach ( $fees as $data ) { |
| 3461 | - $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
| 3462 | - $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
| 3463 | - } |
|
| 3461 | + $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
| 3462 | + $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
| 3463 | + } |
|
| 3464 | 3464 | |
| 3465 | - $current = $this->is_renewal() ? $recurring : $fee; |
|
| 3466 | - $this->set_total_fees( $current ); |
|
| 3465 | + $current = $this->is_renewal() ? $recurring : $fee; |
|
| 3466 | + $this->set_total_fees( $current ); |
|
| 3467 | 3467 | |
| 3468 | - $this->totals['fee'] = array( |
|
| 3469 | - 'initial' => $fee, |
|
| 3470 | - 'recurring' => $recurring, |
|
| 3471 | - ); |
|
| 3468 | + $this->totals['fee'] = array( |
|
| 3469 | + 'initial' => $fee, |
|
| 3470 | + 'recurring' => $recurring, |
|
| 3471 | + ); |
|
| 3472 | 3472 | |
| 3473 | 3473 | $this->set_total_fees( $fee ); |
| 3474 | 3474 | return $current; |
| 3475 | 3475 | } |
| 3476 | 3476 | |
| 3477 | 3477 | /** |
| 3478 | - * Recalculates the invoice total. |
|
| 3479 | - * |
|
| 3480 | - * @since 1.0.19 |
|
| 3478 | + * Recalculates the invoice total. |
|
| 3479 | + * |
|
| 3480 | + * @since 1.0.19 |
|
| 3481 | 3481 | * @return float The invoice total |
| 3482 | - */ |
|
| 3483 | - public function recalculate_total() { |
|
| 3482 | + */ |
|
| 3483 | + public function recalculate_total() { |
|
| 3484 | 3484 | $this->recalculate_subtotal(); |
| 3485 | 3485 | $this->recalculate_total_fees(); |
| 3486 | 3486 | $this->recalculate_total_discount(); |
| 3487 | 3487 | $this->recalculate_total_tax(); |
| 3488 | - return $this->get_total(); |
|
| 3489 | - } |
|
| 3488 | + return $this->get_total(); |
|
| 3489 | + } |
|
| 3490 | 3490 | |
| 3491 | - /** |
|
| 3492 | - * @deprecated |
|
| 3493 | - */ |
|
| 3491 | + /** |
|
| 3492 | + * @deprecated |
|
| 3493 | + */ |
|
| 3494 | 3494 | public function recalculate_totals( $temp = false ) { |
| 3495 | 3495 | $this->update_items( $temp ); |
| 3496 | 3496 | $this->save( true ); |
@@ -3508,7 +3508,7 @@ discard block |
||
| 3508 | 3508 | * Adds a note to an invoice. |
| 3509 | 3509 | * |
| 3510 | 3510 | * @param string $note The note being added. |
| 3511 | - * @return int|false The new note's ID on success, false on failure. |
|
| 3511 | + * @return int|false The new note's ID on success, false on failure. |
|
| 3512 | 3512 | * |
| 3513 | 3513 | */ |
| 3514 | 3514 | public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
@@ -3518,21 +3518,21 @@ discard block |
||
| 3518 | 3518 | return false; |
| 3519 | 3519 | } |
| 3520 | 3520 | |
| 3521 | - $author = 'System'; |
|
| 3522 | - $author_email = '[email protected]'; |
|
| 3521 | + $author = 'System'; |
|
| 3522 | + $author_email = '[email protected]'; |
|
| 3523 | 3523 | |
| 3524 | - // If this is an admin comment or it has been added by the user. |
|
| 3525 | - if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
| 3526 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
| 3524 | + // If this is an admin comment or it has been added by the user. |
|
| 3525 | + if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
| 3526 | + $user = get_user_by( 'id', get_current_user_id() ); |
|
| 3527 | 3527 | $author = $user->display_name; |
| 3528 | 3528 | $author_email = $user->user_email; |
| 3529 | - } |
|
| 3529 | + } |
|
| 3530 | 3530 | |
| 3531 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
| 3531 | + return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
| 3532 | 3532 | |
| 3533 | - } |
|
| 3533 | + } |
|
| 3534 | 3534 | |
| 3535 | - /** |
|
| 3535 | + /** |
|
| 3536 | 3536 | * Generates a unique key for the invoice. |
| 3537 | 3537 | */ |
| 3538 | 3538 | public function generate_key( $string = '' ) { |
@@ -3552,113 +3552,113 @@ discard block |
||
| 3552 | 3552 | $number = wpinv_get_next_invoice_number( $this->get_post_type() ); |
| 3553 | 3553 | } |
| 3554 | 3554 | |
| 3555 | - return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
| 3556 | - |
|
| 3557 | - } |
|
| 3558 | - |
|
| 3559 | - /** |
|
| 3560 | - * Handle the status transition. |
|
| 3561 | - */ |
|
| 3562 | - protected function status_transition() { |
|
| 3563 | - $status_transition = $this->status_transition; |
|
| 3564 | - |
|
| 3565 | - // Reset status transition variable. |
|
| 3566 | - $this->status_transition = false; |
|
| 3567 | - |
|
| 3568 | - if ( $status_transition ) { |
|
| 3569 | - try { |
|
| 3555 | + return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
| 3570 | 3556 | |
| 3571 | - // Fire a hook for the status change. |
|
| 3572 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
| 3573 | - |
|
| 3574 | - // @deprecated this is deprecated and will be removed in the future. |
|
| 3575 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3576 | - |
|
| 3577 | - if ( ! empty( $status_transition['from'] ) ) { |
|
| 3578 | - |
|
| 3579 | - /* translators: 1: old invoice status 2: new invoice status */ |
|
| 3580 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3581 | - |
|
| 3582 | - // Fire another hook. |
|
| 3583 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
| 3584 | - do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
| 3585 | - |
|
| 3586 | - // @deprecated this is deprecated and will be removed in the future. |
|
| 3587 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3588 | - |
|
| 3589 | - // Note the transition occurred. |
|
| 3590 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] ); |
|
| 3591 | - |
|
| 3592 | - // Work out if this was for a payment, and trigger a payment_status hook instead. |
|
| 3593 | - if ( |
|
| 3594 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3595 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3596 | - ) { |
|
| 3597 | - do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
| 3598 | - } |
|
| 3599 | - |
|
| 3600 | - // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
|
| 3601 | - if ( |
|
| 3602 | - in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3603 | - && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3604 | - ) { |
|
| 3605 | - do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
| 3606 | - } |
|
| 3607 | - } else { |
|
| 3608 | - /* translators: %s: new invoice status */ |
|
| 3609 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3610 | - |
|
| 3611 | - // Note the transition occurred. |
|
| 3612 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3557 | + } |
|
| 3613 | 3558 | |
| 3614 | - } |
|
| 3615 | - } catch ( Exception $e ) { |
|
| 3616 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3617 | - } |
|
| 3618 | - } |
|
| 3619 | - } |
|
| 3559 | + /** |
|
| 3560 | + * Handle the status transition. |
|
| 3561 | + */ |
|
| 3562 | + protected function status_transition() { |
|
| 3563 | + $status_transition = $this->status_transition; |
|
| 3564 | + |
|
| 3565 | + // Reset status transition variable. |
|
| 3566 | + $this->status_transition = false; |
|
| 3567 | + |
|
| 3568 | + if ( $status_transition ) { |
|
| 3569 | + try { |
|
| 3570 | + |
|
| 3571 | + // Fire a hook for the status change. |
|
| 3572 | + do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
| 3573 | + |
|
| 3574 | + // @deprecated this is deprecated and will be removed in the future. |
|
| 3575 | + do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3576 | + |
|
| 3577 | + if ( ! empty( $status_transition['from'] ) ) { |
|
| 3578 | + |
|
| 3579 | + /* translators: 1: old invoice status 2: new invoice status */ |
|
| 3580 | + $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3581 | + |
|
| 3582 | + // Fire another hook. |
|
| 3583 | + do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
| 3584 | + do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
| 3585 | + |
|
| 3586 | + // @deprecated this is deprecated and will be removed in the future. |
|
| 3587 | + do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3588 | + |
|
| 3589 | + // Note the transition occurred. |
|
| 3590 | + $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] ); |
|
| 3591 | + |
|
| 3592 | + // Work out if this was for a payment, and trigger a payment_status hook instead. |
|
| 3593 | + if ( |
|
| 3594 | + in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3595 | + && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3596 | + ) { |
|
| 3597 | + do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
| 3598 | + } |
|
| 3599 | + |
|
| 3600 | + // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
|
| 3601 | + if ( |
|
| 3602 | + in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3603 | + && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3604 | + ) { |
|
| 3605 | + do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
| 3606 | + } |
|
| 3607 | + } else { |
|
| 3608 | + /* translators: %s: new invoice status */ |
|
| 3609 | + $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3610 | + |
|
| 3611 | + // Note the transition occurred. |
|
| 3612 | + $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3613 | + |
|
| 3614 | + } |
|
| 3615 | + } catch ( Exception $e ) { |
|
| 3616 | + $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3617 | + } |
|
| 3618 | + } |
|
| 3619 | + } |
|
| 3620 | 3620 | |
| 3621 | - /** |
|
| 3622 | - * Updates an invoice status. |
|
| 3623 | - */ |
|
| 3624 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3621 | + /** |
|
| 3622 | + * Updates an invoice status. |
|
| 3623 | + */ |
|
| 3624 | + public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3625 | 3625 | |
| 3626 | - // Fires before updating a status. |
|
| 3627 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3626 | + // Fires before updating a status. |
|
| 3627 | + do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3628 | 3628 | |
| 3629 | - // Update the status. |
|
| 3630 | - $this->set_status( $new_status, $note, $manual ); |
|
| 3629 | + // Update the status. |
|
| 3630 | + $this->set_status( $new_status, $note, $manual ); |
|
| 3631 | 3631 | |
| 3632 | - // Save the order. |
|
| 3633 | - return $this->save(); |
|
| 3632 | + // Save the order. |
|
| 3633 | + return $this->save(); |
|
| 3634 | 3634 | |
| 3635 | - } |
|
| 3635 | + } |
|
| 3636 | 3636 | |
| 3637 | - /** |
|
| 3638 | - * @deprecated |
|
| 3639 | - */ |
|
| 3640 | - public function refresh_item_ids() { |
|
| 3637 | + /** |
|
| 3638 | + * @deprecated |
|
| 3639 | + */ |
|
| 3640 | + public function refresh_item_ids() { |
|
| 3641 | 3641 | $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) ); |
| 3642 | 3642 | update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
| 3643 | - } |
|
| 3643 | + } |
|
| 3644 | 3644 | |
| 3645 | - /** |
|
| 3646 | - * @deprecated |
|
| 3647 | - */ |
|
| 3648 | - public function update_items( $temp = false ) { |
|
| 3645 | + /** |
|
| 3646 | + * @deprecated |
|
| 3647 | + */ |
|
| 3648 | + public function update_items( $temp = false ) { |
|
| 3649 | 3649 | |
| 3650 | - $this->set_items( $this->get_items() ); |
|
| 3650 | + $this->set_items( $this->get_items() ); |
|
| 3651 | 3651 | |
| 3652 | - if ( ! $temp ) { |
|
| 3653 | - $this->save(); |
|
| 3654 | - } |
|
| 3652 | + if ( ! $temp ) { |
|
| 3653 | + $this->save(); |
|
| 3654 | + } |
|
| 3655 | 3655 | |
| 3656 | 3656 | return $this; |
| 3657 | - } |
|
| 3657 | + } |
|
| 3658 | 3658 | |
| 3659 | - /** |
|
| 3660 | - * @deprecated |
|
| 3661 | - */ |
|
| 3659 | + /** |
|
| 3660 | + * @deprecated |
|
| 3661 | + */ |
|
| 3662 | 3662 | public function validate_discount() { |
| 3663 | 3663 | |
| 3664 | 3664 | $discount_code = $this->get_discount_code(); |
@@ -3674,97 +3674,97 @@ discard block |
||
| 3674 | 3674 | |
| 3675 | 3675 | } |
| 3676 | 3676 | |
| 3677 | - /** |
|
| 3678 | - * Refunds an invoice. |
|
| 3679 | - */ |
|
| 3677 | + /** |
|
| 3678 | + * Refunds an invoice. |
|
| 3679 | + */ |
|
| 3680 | 3680 | public function refund() { |
| 3681 | - $this->set_status( 'wpi-refunded' ); |
|
| 3681 | + $this->set_status( 'wpi-refunded' ); |
|
| 3682 | 3682 | $this->save(); |
| 3683 | - } |
|
| 3683 | + } |
|
| 3684 | 3684 | |
| 3685 | - /** |
|
| 3686 | - * Marks an invoice as paid. |
|
| 3687 | - * |
|
| 3688 | - * @param string $transaction_id |
|
| 3689 | - */ |
|
| 3685 | + /** |
|
| 3686 | + * Marks an invoice as paid. |
|
| 3687 | + * |
|
| 3688 | + * @param string $transaction_id |
|
| 3689 | + */ |
|
| 3690 | 3690 | public function mark_paid( $transaction_id = null, $note = '' ) { |
| 3691 | 3691 | |
| 3692 | - // Set the transaction id. |
|
| 3693 | - if ( empty( $transaction_id ) ) { |
|
| 3694 | - $transaction_id = $this->generate_key('trans_'); |
|
| 3695 | - } |
|
| 3692 | + // Set the transaction id. |
|
| 3693 | + if ( empty( $transaction_id ) ) { |
|
| 3694 | + $transaction_id = $this->generate_key('trans_'); |
|
| 3695 | + } |
|
| 3696 | 3696 | |
| 3697 | - if ( ! $this->get_transaction_id() ) { |
|
| 3698 | - $this->set_transaction_id( $transaction_id ); |
|
| 3699 | - } |
|
| 3697 | + if ( ! $this->get_transaction_id() ) { |
|
| 3698 | + $this->set_transaction_id( $transaction_id ); |
|
| 3699 | + } |
|
| 3700 | 3700 | |
| 3701 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3702 | - return $this->save(); |
|
| 3703 | - } |
|
| 3701 | + if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3702 | + return $this->save(); |
|
| 3703 | + } |
|
| 3704 | 3704 | |
| 3705 | - // Set the completed date. |
|
| 3706 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3705 | + // Set the completed date. |
|
| 3706 | + $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3707 | 3707 | |
| 3708 | - // Set the new status. |
|
| 3709 | - if ( $this->is_renewal() ) { |
|
| 3708 | + // Set the new status. |
|
| 3709 | + if ( $this->is_renewal() ) { |
|
| 3710 | 3710 | |
| 3711 | - $_note = sprintf( |
|
| 3712 | - __( 'Renewed via %s', 'invoicing' ), |
|
| 3713 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3714 | - ); |
|
| 3711 | + $_note = sprintf( |
|
| 3712 | + __( 'Renewed via %s', 'invoicing' ), |
|
| 3713 | + $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3714 | + ); |
|
| 3715 | 3715 | |
| 3716 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3717 | - $_note = $note; |
|
| 3718 | - } |
|
| 3716 | + if ( 'none' == $this->get_gateway() ) { |
|
| 3717 | + $_note = $note; |
|
| 3718 | + } |
|
| 3719 | 3719 | |
| 3720 | - $this->set_status( 'wpi-renewal', $_note ); |
|
| 3720 | + $this->set_status( 'wpi-renewal', $_note ); |
|
| 3721 | 3721 | |
| 3722 | - } else { |
|
| 3722 | + } else { |
|
| 3723 | 3723 | |
| 3724 | - $_note = sprintf( |
|
| 3725 | - __( 'Paid via %s', 'invoicing' ), |
|
| 3726 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3727 | - ); |
|
| 3724 | + $_note = sprintf( |
|
| 3725 | + __( 'Paid via %s', 'invoicing' ), |
|
| 3726 | + $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3727 | + ); |
|
| 3728 | 3728 | |
| 3729 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3730 | - $_note = $note; |
|
| 3731 | - } |
|
| 3729 | + if ( 'none' == $this->get_gateway() ) { |
|
| 3730 | + $_note = $note; |
|
| 3731 | + } |
|
| 3732 | 3732 | |
| 3733 | - $this->set_status( 'publish',$_note ); |
|
| 3733 | + $this->set_status( 'publish',$_note ); |
|
| 3734 | 3734 | |
| 3735 | - } |
|
| 3735 | + } |
|
| 3736 | 3736 | |
| 3737 | - // Set checkout mode. |
|
| 3738 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3739 | - $this->set_mode( $mode ); |
|
| 3737 | + // Set checkout mode. |
|
| 3738 | + $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3739 | + $this->set_mode( $mode ); |
|
| 3740 | 3740 | |
| 3741 | - // Save the invoice. |
|
| 3741 | + // Save the invoice. |
|
| 3742 | 3742 | $this->save(); |
| 3743 | - } |
|
| 3744 | - |
|
| 3745 | - |
|
| 3746 | - /** |
|
| 3747 | - * Save data to the database. |
|
| 3748 | - * |
|
| 3749 | - * @since 1.0.19 |
|
| 3750 | - * @return int invoice ID |
|
| 3751 | - */ |
|
| 3752 | - public function save() { |
|
| 3753 | - $this->maybe_set_date_paid(); |
|
| 3754 | - $this->maybe_set_key(); |
|
| 3755 | - parent::save(); |
|
| 3756 | - $this->clear_cache(); |
|
| 3757 | - $this->status_transition(); |
|
| 3758 | - return $this->get_id(); |
|
| 3759 | - } |
|
| 3760 | - |
|
| 3761 | - /** |
|
| 3743 | + } |
|
| 3744 | + |
|
| 3745 | + |
|
| 3746 | + /** |
|
| 3747 | + * Save data to the database. |
|
| 3748 | + * |
|
| 3749 | + * @since 1.0.19 |
|
| 3750 | + * @return int invoice ID |
|
| 3751 | + */ |
|
| 3752 | + public function save() { |
|
| 3753 | + $this->maybe_set_date_paid(); |
|
| 3754 | + $this->maybe_set_key(); |
|
| 3755 | + parent::save(); |
|
| 3756 | + $this->clear_cache(); |
|
| 3757 | + $this->status_transition(); |
|
| 3758 | + return $this->get_id(); |
|
| 3759 | + } |
|
| 3760 | + |
|
| 3761 | + /** |
|
| 3762 | 3762 | * Clears the subscription's cache. |
| 3763 | 3763 | */ |
| 3764 | 3764 | public function clear_cache() { |
| 3765 | - wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
| 3766 | - wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
| 3767 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
| 3768 | - } |
|
| 3765 | + wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
| 3766 | + wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
| 3767 | + wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
| 3768 | + } |
|
| 3769 | 3769 | |
| 3770 | 3770 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @package Invoicing |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Invoice class. |
@@ -135,40 +135,40 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
| 137 | 137 | */ |
| 138 | - public function __construct( $invoice = false ) { |
|
| 138 | + public function __construct($invoice = false) { |
|
| 139 | 139 | |
| 140 | - parent::__construct( $invoice ); |
|
| 140 | + parent::__construct($invoice); |
|
| 141 | 141 | |
| 142 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
| 143 | - $this->set_id( $invoice ); |
|
| 144 | - } elseif ( $invoice instanceof self ) { |
|
| 145 | - $this->set_id( $invoice->get_id() ); |
|
| 146 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
| 147 | - $this->set_id( $invoice->ID ); |
|
| 148 | - } elseif ( is_array( $invoice ) ) { |
|
| 149 | - $this->set_props( $invoice ); |
|
| 142 | + if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type($invoice))) { |
|
| 143 | + $this->set_id($invoice); |
|
| 144 | + } elseif ($invoice instanceof self) { |
|
| 145 | + $this->set_id($invoice->get_id()); |
|
| 146 | + } elseif (!empty($invoice->ID)) { |
|
| 147 | + $this->set_id($invoice->ID); |
|
| 148 | + } elseif (is_array($invoice)) { |
|
| 149 | + $this->set_props($invoice); |
|
| 150 | 150 | |
| 151 | - if ( isset( $invoice['ID'] ) ) { |
|
| 152 | - $this->set_id( $invoice['ID'] ); |
|
| 151 | + if (isset($invoice['ID'])) { |
|
| 152 | + $this->set_id($invoice['ID']); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 156 | - $this->set_id( $invoice_id ); |
|
| 157 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 158 | - $this->set_id( $invoice_id ); |
|
| 159 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 160 | - $this->set_id( $invoice_id ); |
|
| 161 | - }else { |
|
| 162 | - $this->set_object_read( true ); |
|
| 155 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) { |
|
| 156 | + $this->set_id($invoice_id); |
|
| 157 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) { |
|
| 158 | + $this->set_id($invoice_id); |
|
| 159 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) { |
|
| 160 | + $this->set_id($invoice_id); |
|
| 161 | + } else { |
|
| 162 | + $this->set_object_read(true); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | // Load the datastore. |
| 166 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 166 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
| 167 | 167 | |
| 168 | - if ( $this->get_id() > 0 ) { |
|
| 169 | - $this->post = get_post( $this->get_id() ); |
|
| 168 | + if ($this->get_id() > 0) { |
|
| 169 | + $this->post = get_post($this->get_id()); |
|
| 170 | 170 | $this->ID = $this->get_id(); |
| 171 | - $this->data_store->read( $this ); |
|
| 171 | + $this->data_store->read($this); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | } |
@@ -183,38 +183,38 @@ discard block |
||
| 183 | 183 | * @since 1.0.15 |
| 184 | 184 | * @return int |
| 185 | 185 | */ |
| 186 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 186 | + public static function get_invoice_id_by_field($value, $field = 'key') { |
|
| 187 | 187 | global $wpdb; |
| 188 | 188 | |
| 189 | 189 | // Trim the value. |
| 190 | - $value = trim( $value ); |
|
| 190 | + $value = trim($value); |
|
| 191 | 191 | |
| 192 | - if ( empty( $value ) ) { |
|
| 192 | + if (empty($value)) { |
|
| 193 | 193 | return 0; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | // Valid fields. |
| 197 | - $fields = array( 'key', 'number', 'transaction_id' ); |
|
| 197 | + $fields = array('key', 'number', 'transaction_id'); |
|
| 198 | 198 | |
| 199 | 199 | // Ensure a field has been passed. |
| 200 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 200 | + if (empty($field) || !in_array($field, $fields)) { |
|
| 201 | 201 | return 0; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | // Maybe retrieve from the cache. |
| 205 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 206 | - if ( false !== $invoice_id ) { |
|
| 205 | + $invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
| 206 | + if (false !== $invoice_id) { |
|
| 207 | 207 | return $invoice_id; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | // Fetch from the db. |
| 211 | 211 | $table = $wpdb->prefix . 'getpaid_invoices'; |
| 212 | 212 | $invoice_id = (int) $wpdb->get_var( |
| 213 | - $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
| 213 | + $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
| 214 | 214 | ); |
| 215 | 215 | |
| 216 | 216 | // Update the cache with our data |
| 217 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 217 | + wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
| 218 | 218 | |
| 219 | 219 | return $invoice_id; |
| 220 | 220 | } |
@@ -222,8 +222,8 @@ discard block |
||
| 222 | 222 | /** |
| 223 | 223 | * Checks if an invoice key is set. |
| 224 | 224 | */ |
| 225 | - public function _isset( $key ) { |
|
| 226 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
| 225 | + public function _isset($key) { |
|
| 226 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /* |
@@ -248,8 +248,8 @@ discard block |
||
| 248 | 248 | * @param string $context View or edit context. |
| 249 | 249 | * @return int |
| 250 | 250 | */ |
| 251 | - public function get_parent_id( $context = 'view' ) { |
|
| 252 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
| 251 | + public function get_parent_id($context = 'view') { |
|
| 252 | + return (int) $this->get_prop('parent_id', $context); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * @return WPInv_Invoice |
| 260 | 260 | */ |
| 261 | 261 | public function get_parent_payment() { |
| 262 | - return new WPInv_Invoice( $this->get_parent_id() ); |
|
| 262 | + return new WPInv_Invoice($this->get_parent_id()); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
@@ -279,8 +279,8 @@ discard block |
||
| 279 | 279 | * @param string $context View or edit context. |
| 280 | 280 | * @return string |
| 281 | 281 | */ |
| 282 | - public function get_status( $context = 'view' ) { |
|
| 283 | - return $this->get_prop( 'status', $context ); |
|
| 282 | + public function get_status($context = 'view') { |
|
| 283 | + return $this->get_prop('status', $context); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * @return array |
| 291 | 291 | */ |
| 292 | 292 | public function get_all_statuses() { |
| 293 | - return wpinv_get_invoice_statuses( true, true, $this ); |
|
| 293 | + return wpinv_get_invoice_statuses(true, true, $this); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
@@ -302,9 +302,9 @@ discard block |
||
| 302 | 302 | public function get_status_nicename() { |
| 303 | 303 | $statuses = $this->get_all_statuses(); |
| 304 | 304 | |
| 305 | - $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
|
| 305 | + $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status(); |
|
| 306 | 306 | |
| 307 | - return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
|
| 307 | + return apply_filters('wpinv_get_invoice_status_nicename', $status, $this); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | /** |
@@ -315,8 +315,8 @@ discard block |
||
| 315 | 315 | */ |
| 316 | 316 | public function get_status_label_html() { |
| 317 | 317 | |
| 318 | - $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
| 319 | - $status = sanitize_html_class( $this->get_status() ); |
|
| 318 | + $status_label = sanitize_text_field($this->get_status_nicename()); |
|
| 319 | + $status = sanitize_html_class($this->get_status()); |
|
| 320 | 320 | |
| 321 | 321 | return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>"; |
| 322 | 322 | } |
@@ -328,23 +328,23 @@ discard block |
||
| 328 | 328 | * @param string $context View or edit context. |
| 329 | 329 | * @return string |
| 330 | 330 | */ |
| 331 | - public function get_version( $context = 'view' ) { |
|
| 332 | - return $this->get_prop( 'version', $context ); |
|
| 331 | + public function get_version($context = 'view') { |
|
| 332 | + return $this->get_prop('version', $context); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
| 336 | 336 | * @deprecated |
| 337 | 337 | */ |
| 338 | - public function get_invoice_date( $format = true ) { |
|
| 339 | - $date = getpaid_format_date( $this->get_date_completed() ); |
|
| 340 | - $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
| 341 | - $formatted = getpaid_format_date( $date ); |
|
| 338 | + public function get_invoice_date($format = true) { |
|
| 339 | + $date = getpaid_format_date($this->get_date_completed()); |
|
| 340 | + $date = empty($date) ? $this->get_date_created() : $this->get_date_completed(); |
|
| 341 | + $formatted = getpaid_format_date($date); |
|
| 342 | 342 | |
| 343 | - if ( $format ) { |
|
| 343 | + if ($format) { |
|
| 344 | 344 | return $formatted; |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - return empty( $formatted ) ? '' : $date; |
|
| 347 | + return empty($formatted) ? '' : $date; |
|
| 348 | 348 | |
| 349 | 349 | } |
| 350 | 350 | |
@@ -355,8 +355,8 @@ discard block |
||
| 355 | 355 | * @param string $context View or edit context. |
| 356 | 356 | * @return string |
| 357 | 357 | */ |
| 358 | - public function get_date_created( $context = 'view' ) { |
|
| 359 | - return $this->get_prop( 'date_created', $context ); |
|
| 358 | + public function get_date_created($context = 'view') { |
|
| 359 | + return $this->get_prop('date_created', $context); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | /** |
@@ -366,8 +366,8 @@ discard block |
||
| 366 | 366 | * @param string $context View or edit context. |
| 367 | 367 | * @return string |
| 368 | 368 | */ |
| 369 | - public function get_created_date( $context = 'view' ) { |
|
| 370 | - return $this->get_date_created( $context ); |
|
| 369 | + public function get_created_date($context = 'view') { |
|
| 370 | + return $this->get_date_created($context); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | /** |
@@ -377,11 +377,11 @@ discard block |
||
| 377 | 377 | * @param string $context View or edit context. |
| 378 | 378 | * @return string |
| 379 | 379 | */ |
| 380 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 381 | - $date = $this->get_date_created( $context ); |
|
| 380 | + public function get_date_created_gmt($context = 'view') { |
|
| 381 | + $date = $this->get_date_created($context); |
|
| 382 | 382 | |
| 383 | - if ( $date ) { |
|
| 384 | - $date = get_gmt_from_date( $date ); |
|
| 383 | + if ($date) { |
|
| 384 | + $date = get_gmt_from_date($date); |
|
| 385 | 385 | } |
| 386 | 386 | return $date; |
| 387 | 387 | } |
@@ -393,8 +393,8 @@ discard block |
||
| 393 | 393 | * @param string $context View or edit context. |
| 394 | 394 | * @return string |
| 395 | 395 | */ |
| 396 | - public function get_date_modified( $context = 'view' ) { |
|
| 397 | - return $this->get_prop( 'date_modified', $context ); |
|
| 396 | + public function get_date_modified($context = 'view') { |
|
| 397 | + return $this->get_prop('date_modified', $context); |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | /** |
@@ -404,8 +404,8 @@ discard block |
||
| 404 | 404 | * @param string $context View or edit context. |
| 405 | 405 | * @return string |
| 406 | 406 | */ |
| 407 | - public function get_modified_date( $context = 'view' ) { |
|
| 408 | - return $this->get_date_modified( $context ); |
|
| 407 | + public function get_modified_date($context = 'view') { |
|
| 408 | + return $this->get_date_modified($context); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | /** |
@@ -415,11 +415,11 @@ discard block |
||
| 415 | 415 | * @param string $context View or edit context. |
| 416 | 416 | * @return string |
| 417 | 417 | */ |
| 418 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
| 419 | - $date = $this->get_date_modified( $context ); |
|
| 418 | + public function get_date_modified_gmt($context = 'view') { |
|
| 419 | + $date = $this->get_date_modified($context); |
|
| 420 | 420 | |
| 421 | - if ( $date ) { |
|
| 422 | - $date = get_gmt_from_date( $date ); |
|
| 421 | + if ($date) { |
|
| 422 | + $date = get_gmt_from_date($date); |
|
| 423 | 423 | } |
| 424 | 424 | return $date; |
| 425 | 425 | } |
@@ -431,8 +431,8 @@ discard block |
||
| 431 | 431 | * @param string $context View or edit context. |
| 432 | 432 | * @return string |
| 433 | 433 | */ |
| 434 | - public function get_due_date( $context = 'view' ) { |
|
| 435 | - return $this->get_prop( 'due_date', $context ); |
|
| 434 | + public function get_due_date($context = 'view') { |
|
| 435 | + return $this->get_prop('due_date', $context); |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | /** |
@@ -442,8 +442,8 @@ discard block |
||
| 442 | 442 | * @param string $context View or edit context. |
| 443 | 443 | * @return string |
| 444 | 444 | */ |
| 445 | - public function get_date_due( $context = 'view' ) { |
|
| 446 | - return $this->get_due_date( $context ); |
|
| 445 | + public function get_date_due($context = 'view') { |
|
| 446 | + return $this->get_due_date($context); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | /** |
@@ -453,11 +453,11 @@ discard block |
||
| 453 | 453 | * @param string $context View or edit context. |
| 454 | 454 | * @return string |
| 455 | 455 | */ |
| 456 | - public function get_due_date_gmt( $context = 'view' ) { |
|
| 457 | - $date = $this->get_due_date( $context ); |
|
| 456 | + public function get_due_date_gmt($context = 'view') { |
|
| 457 | + $date = $this->get_due_date($context); |
|
| 458 | 458 | |
| 459 | - if ( $date ) { |
|
| 460 | - $date = get_gmt_from_date( $date ); |
|
| 459 | + if ($date) { |
|
| 460 | + $date = get_gmt_from_date($date); |
|
| 461 | 461 | } |
| 462 | 462 | return $date; |
| 463 | 463 | } |
@@ -469,8 +469,8 @@ discard block |
||
| 469 | 469 | * @param string $context View or edit context. |
| 470 | 470 | * @return string |
| 471 | 471 | */ |
| 472 | - public function get_gmt_date_due( $context = 'view' ) { |
|
| 473 | - return $this->get_due_date_gmt( $context ); |
|
| 472 | + public function get_gmt_date_due($context = 'view') { |
|
| 473 | + return $this->get_due_date_gmt($context); |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | /** |
@@ -480,8 +480,8 @@ discard block |
||
| 480 | 480 | * @param string $context View or edit context. |
| 481 | 481 | * @return string |
| 482 | 482 | */ |
| 483 | - public function get_completed_date( $context = 'view' ) { |
|
| 484 | - return $this->get_prop( 'completed_date', $context ); |
|
| 483 | + public function get_completed_date($context = 'view') { |
|
| 484 | + return $this->get_prop('completed_date', $context); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
@@ -491,8 +491,8 @@ discard block |
||
| 491 | 491 | * @param string $context View or edit context. |
| 492 | 492 | * @return string |
| 493 | 493 | */ |
| 494 | - public function get_date_completed( $context = 'view' ) { |
|
| 495 | - return $this->get_completed_date( $context ); |
|
| 494 | + public function get_date_completed($context = 'view') { |
|
| 495 | + return $this->get_completed_date($context); |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | /** |
@@ -502,11 +502,11 @@ discard block |
||
| 502 | 502 | * @param string $context View or edit context. |
| 503 | 503 | * @return string |
| 504 | 504 | */ |
| 505 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
| 506 | - $date = $this->get_completed_date( $context ); |
|
| 505 | + public function get_completed_date_gmt($context = 'view') { |
|
| 506 | + $date = $this->get_completed_date($context); |
|
| 507 | 507 | |
| 508 | - if ( $date ) { |
|
| 509 | - $date = get_gmt_from_date( $date ); |
|
| 508 | + if ($date) { |
|
| 509 | + $date = get_gmt_from_date($date); |
|
| 510 | 510 | } |
| 511 | 511 | return $date; |
| 512 | 512 | } |
@@ -518,8 +518,8 @@ discard block |
||
| 518 | 518 | * @param string $context View or edit context. |
| 519 | 519 | * @return string |
| 520 | 520 | */ |
| 521 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
| 522 | - return $this->get_completed_date_gmt( $context ); |
|
| 521 | + public function get_gmt_completed_date($context = 'view') { |
|
| 522 | + return $this->get_completed_date_gmt($context); |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | /** |
@@ -529,12 +529,12 @@ discard block |
||
| 529 | 529 | * @param string $context View or edit context. |
| 530 | 530 | * @return string |
| 531 | 531 | */ |
| 532 | - public function get_number( $context = 'view' ) { |
|
| 533 | - $number = $this->get_prop( 'number', $context ); |
|
| 532 | + public function get_number($context = 'view') { |
|
| 533 | + $number = $this->get_prop('number', $context); |
|
| 534 | 534 | |
| 535 | - if ( empty( $number ) ) { |
|
| 535 | + if (empty($number)) { |
|
| 536 | 536 | $number = $this->generate_number(); |
| 537 | - $this->set_number( $this->generate_number() ); |
|
| 537 | + $this->set_number($this->generate_number()); |
|
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | return $number; |
@@ -548,8 +548,8 @@ discard block |
||
| 548 | 548 | public function maybe_set_number() { |
| 549 | 549 | $number = $this->get_number(); |
| 550 | 550 | |
| 551 | - if ( empty( $number ) || $this->get_id() == $number ) { |
|
| 552 | - $this->set_number( $this->generate_number() ); |
|
| 551 | + if (empty($number) || $this->get_id() == $number) { |
|
| 552 | + $this->set_number($this->generate_number()); |
|
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | } |
@@ -561,8 +561,8 @@ discard block |
||
| 561 | 561 | * @param string $context View or edit context. |
| 562 | 562 | * @return string |
| 563 | 563 | */ |
| 564 | - public function get_key( $context = 'view' ) { |
|
| 565 | - return $this->get_prop( 'key', $context ); |
|
| 564 | + public function get_key($context = 'view') { |
|
| 565 | + return $this->get_prop('key', $context); |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | /** |
@@ -573,9 +573,9 @@ discard block |
||
| 573 | 573 | public function maybe_set_key() { |
| 574 | 574 | $key = $this->get_key(); |
| 575 | 575 | |
| 576 | - if ( empty( $key ) ) { |
|
| 577 | - $key = $this->generate_key( $this->get_type() . '_' ); |
|
| 578 | - $this->set_key( $key ); |
|
| 576 | + if (empty($key)) { |
|
| 577 | + $key = $this->generate_key($this->get_type() . '_'); |
|
| 578 | + $this->set_key($key); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | } |
@@ -587,15 +587,15 @@ discard block |
||
| 587 | 587 | * @param string $context View or edit context. |
| 588 | 588 | * @return string |
| 589 | 589 | */ |
| 590 | - public function get_type( $context = 'view' ) { |
|
| 591 | - return $this->get_prop( 'type', $context ); |
|
| 590 | + public function get_type($context = 'view') { |
|
| 591 | + return $this->get_prop('type', $context); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | /** |
| 595 | 595 | * @deprecated |
| 596 | 596 | */ |
| 597 | 597 | public function get_invoice_quote_type() { |
| 598 | - ucfirst( $this->get_type() ); |
|
| 598 | + ucfirst($this->get_type()); |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | /** |
@@ -605,8 +605,8 @@ discard block |
||
| 605 | 605 | * @param string $context View or edit context. |
| 606 | 606 | * @return string |
| 607 | 607 | */ |
| 608 | - public function get_post_type( $context = 'view' ) { |
|
| 609 | - return $this->get_prop( 'post_type', $context ); |
|
| 608 | + public function get_post_type($context = 'view') { |
|
| 609 | + return $this->get_prop('post_type', $context); |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | /** |
@@ -616,8 +616,8 @@ discard block |
||
| 616 | 616 | * @param string $context View or edit context. |
| 617 | 617 | * @return string |
| 618 | 618 | */ |
| 619 | - public function get_mode( $context = 'view' ) { |
|
| 620 | - return $this->get_prop( 'mode', $context ); |
|
| 619 | + public function get_mode($context = 'view') { |
|
| 620 | + return $this->get_prop('mode', $context); |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | /** |
@@ -627,13 +627,13 @@ discard block |
||
| 627 | 627 | * @param string $context View or edit context. |
| 628 | 628 | * @return string |
| 629 | 629 | */ |
| 630 | - public function get_path( $context = 'view' ) { |
|
| 631 | - $path = $this->get_prop( 'path', $context ); |
|
| 630 | + public function get_path($context = 'view') { |
|
| 631 | + $path = $this->get_prop('path', $context); |
|
| 632 | 632 | $prefix = $this->get_type(); |
| 633 | 633 | |
| 634 | - if ( 0 !== strpos( $path, $prefix ) ) { |
|
| 635 | - $path = sanitize_title( $prefix . '-' . $this->get_id() ); |
|
| 636 | - $this->set_path( $path ); |
|
| 634 | + if (0 !== strpos($path, $prefix)) { |
|
| 635 | + $path = sanitize_title($prefix . '-' . $this->get_id()); |
|
| 636 | + $this->set_path($path); |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | return $path; |
@@ -646,8 +646,8 @@ discard block |
||
| 646 | 646 | * @param string $context View or edit context. |
| 647 | 647 | * @return string |
| 648 | 648 | */ |
| 649 | - public function get_name( $context = 'view' ) { |
|
| 650 | - return $this->get_prop( 'title', $context ); |
|
| 649 | + public function get_name($context = 'view') { |
|
| 650 | + return $this->get_prop('title', $context); |
|
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | /** |
@@ -657,8 +657,8 @@ discard block |
||
| 657 | 657 | * @param string $context View or edit context. |
| 658 | 658 | * @return string |
| 659 | 659 | */ |
| 660 | - public function get_title( $context = 'view' ) { |
|
| 661 | - return $this->get_name( $context ); |
|
| 660 | + public function get_title($context = 'view') { |
|
| 661 | + return $this->get_name($context); |
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | /** |
@@ -668,8 +668,8 @@ discard block |
||
| 668 | 668 | * @param string $context View or edit context. |
| 669 | 669 | * @return string |
| 670 | 670 | */ |
| 671 | - public function get_description( $context = 'view' ) { |
|
| 672 | - return $this->get_prop( 'description', $context ); |
|
| 671 | + public function get_description($context = 'view') { |
|
| 672 | + return $this->get_prop('description', $context); |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | /** |
@@ -679,8 +679,8 @@ discard block |
||
| 679 | 679 | * @param string $context View or edit context. |
| 680 | 680 | * @return string |
| 681 | 681 | */ |
| 682 | - public function get_excerpt( $context = 'view' ) { |
|
| 683 | - return $this->get_description( $context ); |
|
| 682 | + public function get_excerpt($context = 'view') { |
|
| 683 | + return $this->get_description($context); |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | /** |
@@ -690,8 +690,8 @@ discard block |
||
| 690 | 690 | * @param string $context View or edit context. |
| 691 | 691 | * @return string |
| 692 | 692 | */ |
| 693 | - public function get_summary( $context = 'view' ) { |
|
| 694 | - return $this->get_description( $context ); |
|
| 693 | + public function get_summary($context = 'view') { |
|
| 694 | + return $this->get_description($context); |
|
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | /** |
@@ -701,25 +701,25 @@ discard block |
||
| 701 | 701 | * @param string $context View or edit context. |
| 702 | 702 | * @return array |
| 703 | 703 | */ |
| 704 | - public function get_user_info( $context = 'view' ) { |
|
| 704 | + public function get_user_info($context = 'view') { |
|
| 705 | 705 | |
| 706 | 706 | $user_info = array( |
| 707 | - 'user_id' => $this->get_user_id( $context ), |
|
| 708 | - 'email' => $this->get_email( $context ), |
|
| 709 | - 'first_name' => $this->get_first_name( $context ), |
|
| 710 | - 'last_name' => $this->get_last_name( $context ), |
|
| 711 | - 'address' => $this->get_address( $context ), |
|
| 712 | - 'phone' => $this->get_phone( $context ), |
|
| 713 | - 'city' => $this->get_city( $context ), |
|
| 714 | - 'country' => $this->get_country( $context ), |
|
| 715 | - 'state' => $this->get_state( $context ), |
|
| 716 | - 'zip' => $this->get_zip( $context ), |
|
| 717 | - 'company' => $this->get_company( $context ), |
|
| 718 | - 'vat_number' => $this->get_vat_number( $context ), |
|
| 719 | - 'discount' => $this->get_discount_code( $context ), |
|
| 707 | + 'user_id' => $this->get_user_id($context), |
|
| 708 | + 'email' => $this->get_email($context), |
|
| 709 | + 'first_name' => $this->get_first_name($context), |
|
| 710 | + 'last_name' => $this->get_last_name($context), |
|
| 711 | + 'address' => $this->get_address($context), |
|
| 712 | + 'phone' => $this->get_phone($context), |
|
| 713 | + 'city' => $this->get_city($context), |
|
| 714 | + 'country' => $this->get_country($context), |
|
| 715 | + 'state' => $this->get_state($context), |
|
| 716 | + 'zip' => $this->get_zip($context), |
|
| 717 | + 'company' => $this->get_company($context), |
|
| 718 | + 'vat_number' => $this->get_vat_number($context), |
|
| 719 | + 'discount' => $this->get_discount_code($context), |
|
| 720 | 720 | ); |
| 721 | 721 | |
| 722 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 722 | + return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this); |
|
| 723 | 723 | |
| 724 | 724 | } |
| 725 | 725 | |
@@ -730,8 +730,8 @@ discard block |
||
| 730 | 730 | * @param string $context View or edit context. |
| 731 | 731 | * @return int |
| 732 | 732 | */ |
| 733 | - public function get_author( $context = 'view' ) { |
|
| 734 | - return (int) $this->get_prop( 'author', $context ); |
|
| 733 | + public function get_author($context = 'view') { |
|
| 734 | + return (int) $this->get_prop('author', $context); |
|
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | /** |
@@ -741,8 +741,8 @@ discard block |
||
| 741 | 741 | * @param string $context View or edit context. |
| 742 | 742 | * @return int |
| 743 | 743 | */ |
| 744 | - public function get_user_id( $context = 'view' ) { |
|
| 745 | - return $this->get_author( $context ); |
|
| 744 | + public function get_user_id($context = 'view') { |
|
| 745 | + return $this->get_author($context); |
|
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | /** |
@@ -752,8 +752,8 @@ discard block |
||
| 752 | 752 | * @param string $context View or edit context. |
| 753 | 753 | * @return int |
| 754 | 754 | */ |
| 755 | - public function get_customer_id( $context = 'view' ) { |
|
| 756 | - return $this->get_author( $context ); |
|
| 755 | + public function get_customer_id($context = 'view') { |
|
| 756 | + return $this->get_author($context); |
|
| 757 | 757 | } |
| 758 | 758 | |
| 759 | 759 | /** |
@@ -763,8 +763,8 @@ discard block |
||
| 763 | 763 | * @param string $context View or edit context. |
| 764 | 764 | * @return string |
| 765 | 765 | */ |
| 766 | - public function get_ip( $context = 'view' ) { |
|
| 767 | - return $this->get_prop( 'user_ip', $context ); |
|
| 766 | + public function get_ip($context = 'view') { |
|
| 767 | + return $this->get_prop('user_ip', $context); |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | /** |
@@ -774,8 +774,8 @@ discard block |
||
| 774 | 774 | * @param string $context View or edit context. |
| 775 | 775 | * @return string |
| 776 | 776 | */ |
| 777 | - public function get_user_ip( $context = 'view' ) { |
|
| 778 | - return $this->get_ip( $context ); |
|
| 777 | + public function get_user_ip($context = 'view') { |
|
| 778 | + return $this->get_ip($context); |
|
| 779 | 779 | } |
| 780 | 780 | |
| 781 | 781 | /** |
@@ -785,8 +785,8 @@ discard block |
||
| 785 | 785 | * @param string $context View or edit context. |
| 786 | 786 | * @return string |
| 787 | 787 | */ |
| 788 | - public function get_customer_ip( $context = 'view' ) { |
|
| 789 | - return $this->get_ip( $context ); |
|
| 788 | + public function get_customer_ip($context = 'view') { |
|
| 789 | + return $this->get_ip($context); |
|
| 790 | 790 | } |
| 791 | 791 | |
| 792 | 792 | /** |
@@ -796,8 +796,8 @@ discard block |
||
| 796 | 796 | * @param string $context View or edit context. |
| 797 | 797 | * @return string |
| 798 | 798 | */ |
| 799 | - public function get_first_name( $context = 'view' ) { |
|
| 800 | - return $this->get_prop( 'first_name', $context ); |
|
| 799 | + public function get_first_name($context = 'view') { |
|
| 800 | + return $this->get_prop('first_name', $context); |
|
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | /** |
@@ -807,8 +807,8 @@ discard block |
||
| 807 | 807 | * @param string $context View or edit context. |
| 808 | 808 | * @return int |
| 809 | 809 | */ |
| 810 | - public function get_user_first_name( $context = 'view' ) { |
|
| 811 | - return $this->get_first_name( $context ); |
|
| 810 | + public function get_user_first_name($context = 'view') { |
|
| 811 | + return $this->get_first_name($context); |
|
| 812 | 812 | } |
| 813 | 813 | |
| 814 | 814 | /** |
@@ -818,8 +818,8 @@ discard block |
||
| 818 | 818 | * @param string $context View or edit context. |
| 819 | 819 | * @return int |
| 820 | 820 | */ |
| 821 | - public function get_customer_first_name( $context = 'view' ) { |
|
| 822 | - return $this->get_first_name( $context ); |
|
| 821 | + public function get_customer_first_name($context = 'view') { |
|
| 822 | + return $this->get_first_name($context); |
|
| 823 | 823 | } |
| 824 | 824 | |
| 825 | 825 | /** |
@@ -829,8 +829,8 @@ discard block |
||
| 829 | 829 | * @param string $context View or edit context. |
| 830 | 830 | * @return string |
| 831 | 831 | */ |
| 832 | - public function get_last_name( $context = 'view' ) { |
|
| 833 | - return $this->get_prop( 'last_name', $context ); |
|
| 832 | + public function get_last_name($context = 'view') { |
|
| 833 | + return $this->get_prop('last_name', $context); |
|
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | /** |
@@ -840,8 +840,8 @@ discard block |
||
| 840 | 840 | * @param string $context View or edit context. |
| 841 | 841 | * @return int |
| 842 | 842 | */ |
| 843 | - public function get_user_last_name( $context = 'view' ) { |
|
| 844 | - return $this->get_last_name( $context ); |
|
| 843 | + public function get_user_last_name($context = 'view') { |
|
| 844 | + return $this->get_last_name($context); |
|
| 845 | 845 | } |
| 846 | 846 | |
| 847 | 847 | /** |
@@ -851,8 +851,8 @@ discard block |
||
| 851 | 851 | * @param string $context View or edit context. |
| 852 | 852 | * @return int |
| 853 | 853 | */ |
| 854 | - public function get_customer_last_name( $context = 'view' ) { |
|
| 855 | - return $this->get_last_name( $context ); |
|
| 854 | + public function get_customer_last_name($context = 'view') { |
|
| 855 | + return $this->get_last_name($context); |
|
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | /** |
@@ -862,8 +862,8 @@ discard block |
||
| 862 | 862 | * @param string $context View or edit context. |
| 863 | 863 | * @return string |
| 864 | 864 | */ |
| 865 | - public function get_full_name( $context = 'view' ) { |
|
| 866 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 865 | + public function get_full_name($context = 'view') { |
|
| 866 | + return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context)); |
|
| 867 | 867 | } |
| 868 | 868 | |
| 869 | 869 | /** |
@@ -873,8 +873,8 @@ discard block |
||
| 873 | 873 | * @param string $context View or edit context. |
| 874 | 874 | * @return int |
| 875 | 875 | */ |
| 876 | - public function get_user_full_name( $context = 'view' ) { |
|
| 877 | - return $this->get_full_name( $context ); |
|
| 876 | + public function get_user_full_name($context = 'view') { |
|
| 877 | + return $this->get_full_name($context); |
|
| 878 | 878 | } |
| 879 | 879 | |
| 880 | 880 | /** |
@@ -884,8 +884,8 @@ discard block |
||
| 884 | 884 | * @param string $context View or edit context. |
| 885 | 885 | * @return int |
| 886 | 886 | */ |
| 887 | - public function get_customer_full_name( $context = 'view' ) { |
|
| 888 | - return $this->get_full_name( $context ); |
|
| 887 | + public function get_customer_full_name($context = 'view') { |
|
| 888 | + return $this->get_full_name($context); |
|
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | /** |
@@ -895,8 +895,8 @@ discard block |
||
| 895 | 895 | * @param string $context View or edit context. |
| 896 | 896 | * @return string |
| 897 | 897 | */ |
| 898 | - public function get_phone( $context = 'view' ) { |
|
| 899 | - return $this->get_prop( 'phone', $context ); |
|
| 898 | + public function get_phone($context = 'view') { |
|
| 899 | + return $this->get_prop('phone', $context); |
|
| 900 | 900 | } |
| 901 | 901 | |
| 902 | 902 | /** |
@@ -906,8 +906,8 @@ discard block |
||
| 906 | 906 | * @param string $context View or edit context. |
| 907 | 907 | * @return int |
| 908 | 908 | */ |
| 909 | - public function get_phone_number( $context = 'view' ) { |
|
| 910 | - return $this->get_phone( $context ); |
|
| 909 | + public function get_phone_number($context = 'view') { |
|
| 910 | + return $this->get_phone($context); |
|
| 911 | 911 | } |
| 912 | 912 | |
| 913 | 913 | /** |
@@ -917,8 +917,8 @@ discard block |
||
| 917 | 917 | * @param string $context View or edit context. |
| 918 | 918 | * @return int |
| 919 | 919 | */ |
| 920 | - public function get_user_phone( $context = 'view' ) { |
|
| 921 | - return $this->get_phone( $context ); |
|
| 920 | + public function get_user_phone($context = 'view') { |
|
| 921 | + return $this->get_phone($context); |
|
| 922 | 922 | } |
| 923 | 923 | |
| 924 | 924 | /** |
@@ -928,8 +928,8 @@ discard block |
||
| 928 | 928 | * @param string $context View or edit context. |
| 929 | 929 | * @return int |
| 930 | 930 | */ |
| 931 | - public function get_customer_phone( $context = 'view' ) { |
|
| 932 | - return $this->get_phone( $context ); |
|
| 931 | + public function get_customer_phone($context = 'view') { |
|
| 932 | + return $this->get_phone($context); |
|
| 933 | 933 | } |
| 934 | 934 | |
| 935 | 935 | /** |
@@ -939,8 +939,8 @@ discard block |
||
| 939 | 939 | * @param string $context View or edit context. |
| 940 | 940 | * @return string |
| 941 | 941 | */ |
| 942 | - public function get_email( $context = 'view' ) { |
|
| 943 | - return $this->get_prop( 'email', $context ); |
|
| 942 | + public function get_email($context = 'view') { |
|
| 943 | + return $this->get_prop('email', $context); |
|
| 944 | 944 | } |
| 945 | 945 | |
| 946 | 946 | /** |
@@ -950,8 +950,8 @@ discard block |
||
| 950 | 950 | * @param string $context View or edit context. |
| 951 | 951 | * @return string |
| 952 | 952 | */ |
| 953 | - public function get_email_address( $context = 'view' ) { |
|
| 954 | - return $this->get_email( $context ); |
|
| 953 | + public function get_email_address($context = 'view') { |
|
| 954 | + return $this->get_email($context); |
|
| 955 | 955 | } |
| 956 | 956 | |
| 957 | 957 | /** |
@@ -961,8 +961,8 @@ discard block |
||
| 961 | 961 | * @param string $context View or edit context. |
| 962 | 962 | * @return int |
| 963 | 963 | */ |
| 964 | - public function get_user_email( $context = 'view' ) { |
|
| 965 | - return $this->get_email( $context ); |
|
| 964 | + public function get_user_email($context = 'view') { |
|
| 965 | + return $this->get_email($context); |
|
| 966 | 966 | } |
| 967 | 967 | |
| 968 | 968 | /** |
@@ -972,8 +972,8 @@ discard block |
||
| 972 | 972 | * @param string $context View or edit context. |
| 973 | 973 | * @return int |
| 974 | 974 | */ |
| 975 | - public function get_customer_email( $context = 'view' ) { |
|
| 976 | - return $this->get_email( $context ); |
|
| 975 | + public function get_customer_email($context = 'view') { |
|
| 976 | + return $this->get_email($context); |
|
| 977 | 977 | } |
| 978 | 978 | |
| 979 | 979 | /** |
@@ -983,9 +983,9 @@ discard block |
||
| 983 | 983 | * @param string $context View or edit context. |
| 984 | 984 | * @return string |
| 985 | 985 | */ |
| 986 | - public function get_country( $context = 'view' ) { |
|
| 987 | - $country = $this->get_prop( 'country', $context ); |
|
| 988 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 986 | + public function get_country($context = 'view') { |
|
| 987 | + $country = $this->get_prop('country', $context); |
|
| 988 | + return empty($country) ? wpinv_get_default_country() : $country; |
|
| 989 | 989 | } |
| 990 | 990 | |
| 991 | 991 | /** |
@@ -995,8 +995,8 @@ discard block |
||
| 995 | 995 | * @param string $context View or edit context. |
| 996 | 996 | * @return int |
| 997 | 997 | */ |
| 998 | - public function get_user_country( $context = 'view' ) { |
|
| 999 | - return $this->get_country( $context ); |
|
| 998 | + public function get_user_country($context = 'view') { |
|
| 999 | + return $this->get_country($context); |
|
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | /** |
@@ -1006,8 +1006,8 @@ discard block |
||
| 1006 | 1006 | * @param string $context View or edit context. |
| 1007 | 1007 | * @return int |
| 1008 | 1008 | */ |
| 1009 | - public function get_customer_country( $context = 'view' ) { |
|
| 1010 | - return $this->get_country( $context ); |
|
| 1009 | + public function get_customer_country($context = 'view') { |
|
| 1010 | + return $this->get_country($context); |
|
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | 1013 | /** |
@@ -1017,9 +1017,9 @@ discard block |
||
| 1017 | 1017 | * @param string $context View or edit context. |
| 1018 | 1018 | * @return string |
| 1019 | 1019 | */ |
| 1020 | - public function get_state( $context = 'view' ) { |
|
| 1021 | - $state = $this->get_prop( 'state', $context ); |
|
| 1022 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 1020 | + public function get_state($context = 'view') { |
|
| 1021 | + $state = $this->get_prop('state', $context); |
|
| 1022 | + return empty($state) ? wpinv_get_default_state() : $state; |
|
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | 1025 | /** |
@@ -1029,8 +1029,8 @@ discard block |
||
| 1029 | 1029 | * @param string $context View or edit context. |
| 1030 | 1030 | * @return int |
| 1031 | 1031 | */ |
| 1032 | - public function get_user_state( $context = 'view' ) { |
|
| 1033 | - return $this->get_state( $context ); |
|
| 1032 | + public function get_user_state($context = 'view') { |
|
| 1033 | + return $this->get_state($context); |
|
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | 1036 | /** |
@@ -1040,8 +1040,8 @@ discard block |
||
| 1040 | 1040 | * @param string $context View or edit context. |
| 1041 | 1041 | * @return int |
| 1042 | 1042 | */ |
| 1043 | - public function get_customer_state( $context = 'view' ) { |
|
| 1044 | - return $this->get_state( $context ); |
|
| 1043 | + public function get_customer_state($context = 'view') { |
|
| 1044 | + return $this->get_state($context); |
|
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | 1047 | /** |
@@ -1051,8 +1051,8 @@ discard block |
||
| 1051 | 1051 | * @param string $context View or edit context. |
| 1052 | 1052 | * @return string |
| 1053 | 1053 | */ |
| 1054 | - public function get_city( $context = 'view' ) { |
|
| 1055 | - return $this->get_prop( 'city', $context ); |
|
| 1054 | + public function get_city($context = 'view') { |
|
| 1055 | + return $this->get_prop('city', $context); |
|
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | 1058 | /** |
@@ -1062,8 +1062,8 @@ discard block |
||
| 1062 | 1062 | * @param string $context View or edit context. |
| 1063 | 1063 | * @return string |
| 1064 | 1064 | */ |
| 1065 | - public function get_user_city( $context = 'view' ) { |
|
| 1066 | - return $this->get_city( $context ); |
|
| 1065 | + public function get_user_city($context = 'view') { |
|
| 1066 | + return $this->get_city($context); |
|
| 1067 | 1067 | } |
| 1068 | 1068 | |
| 1069 | 1069 | /** |
@@ -1073,8 +1073,8 @@ discard block |
||
| 1073 | 1073 | * @param string $context View or edit context. |
| 1074 | 1074 | * @return string |
| 1075 | 1075 | */ |
| 1076 | - public function get_customer_city( $context = 'view' ) { |
|
| 1077 | - return $this->get_city( $context ); |
|
| 1076 | + public function get_customer_city($context = 'view') { |
|
| 1077 | + return $this->get_city($context); |
|
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | 1080 | /** |
@@ -1084,8 +1084,8 @@ discard block |
||
| 1084 | 1084 | * @param string $context View or edit context. |
| 1085 | 1085 | * @return string |
| 1086 | 1086 | */ |
| 1087 | - public function get_zip( $context = 'view' ) { |
|
| 1088 | - return $this->get_prop( 'zip', $context ); |
|
| 1087 | + public function get_zip($context = 'view') { |
|
| 1088 | + return $this->get_prop('zip', $context); |
|
| 1089 | 1089 | } |
| 1090 | 1090 | |
| 1091 | 1091 | /** |
@@ -1095,8 +1095,8 @@ discard block |
||
| 1095 | 1095 | * @param string $context View or edit context. |
| 1096 | 1096 | * @return string |
| 1097 | 1097 | */ |
| 1098 | - public function get_user_zip( $context = 'view' ) { |
|
| 1099 | - return $this->get_zip( $context ); |
|
| 1098 | + public function get_user_zip($context = 'view') { |
|
| 1099 | + return $this->get_zip($context); |
|
| 1100 | 1100 | } |
| 1101 | 1101 | |
| 1102 | 1102 | /** |
@@ -1106,8 +1106,8 @@ discard block |
||
| 1106 | 1106 | * @param string $context View or edit context. |
| 1107 | 1107 | * @return string |
| 1108 | 1108 | */ |
| 1109 | - public function get_customer_zip( $context = 'view' ) { |
|
| 1110 | - return $this->get_zip( $context ); |
|
| 1109 | + public function get_customer_zip($context = 'view') { |
|
| 1110 | + return $this->get_zip($context); |
|
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 1113 | 1113 | /** |
@@ -1117,8 +1117,8 @@ discard block |
||
| 1117 | 1117 | * @param string $context View or edit context. |
| 1118 | 1118 | * @return string |
| 1119 | 1119 | */ |
| 1120 | - public function get_company( $context = 'view' ) { |
|
| 1121 | - return $this->get_prop( 'company', $context ); |
|
| 1120 | + public function get_company($context = 'view') { |
|
| 1121 | + return $this->get_prop('company', $context); |
|
| 1122 | 1122 | } |
| 1123 | 1123 | |
| 1124 | 1124 | /** |
@@ -1128,8 +1128,8 @@ discard block |
||
| 1128 | 1128 | * @param string $context View or edit context. |
| 1129 | 1129 | * @return string |
| 1130 | 1130 | */ |
| 1131 | - public function get_user_company( $context = 'view' ) { |
|
| 1132 | - return $this->get_company( $context ); |
|
| 1131 | + public function get_user_company($context = 'view') { |
|
| 1132 | + return $this->get_company($context); |
|
| 1133 | 1133 | } |
| 1134 | 1134 | |
| 1135 | 1135 | /** |
@@ -1139,8 +1139,8 @@ discard block |
||
| 1139 | 1139 | * @param string $context View or edit context. |
| 1140 | 1140 | * @return string |
| 1141 | 1141 | */ |
| 1142 | - public function get_customer_company( $context = 'view' ) { |
|
| 1143 | - return $this->get_company( $context ); |
|
| 1142 | + public function get_customer_company($context = 'view') { |
|
| 1143 | + return $this->get_company($context); |
|
| 1144 | 1144 | } |
| 1145 | 1145 | |
| 1146 | 1146 | /** |
@@ -1150,8 +1150,8 @@ discard block |
||
| 1150 | 1150 | * @param string $context View or edit context. |
| 1151 | 1151 | * @return string |
| 1152 | 1152 | */ |
| 1153 | - public function get_vat_number( $context = 'view' ) { |
|
| 1154 | - return $this->get_prop( 'vat_number', $context ); |
|
| 1153 | + public function get_vat_number($context = 'view') { |
|
| 1154 | + return $this->get_prop('vat_number', $context); |
|
| 1155 | 1155 | } |
| 1156 | 1156 | |
| 1157 | 1157 | /** |
@@ -1161,8 +1161,8 @@ discard block |
||
| 1161 | 1161 | * @param string $context View or edit context. |
| 1162 | 1162 | * @return string |
| 1163 | 1163 | */ |
| 1164 | - public function get_user_vat_number( $context = 'view' ) { |
|
| 1165 | - return $this->get_vat_number( $context ); |
|
| 1164 | + public function get_user_vat_number($context = 'view') { |
|
| 1165 | + return $this->get_vat_number($context); |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | /** |
@@ -1172,8 +1172,8 @@ discard block |
||
| 1172 | 1172 | * @param string $context View or edit context. |
| 1173 | 1173 | * @return string |
| 1174 | 1174 | */ |
| 1175 | - public function get_customer_vat_number( $context = 'view' ) { |
|
| 1176 | - return $this->get_vat_number( $context ); |
|
| 1175 | + public function get_customer_vat_number($context = 'view') { |
|
| 1176 | + return $this->get_vat_number($context); |
|
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | 1179 | /** |
@@ -1183,8 +1183,8 @@ discard block |
||
| 1183 | 1183 | * @param string $context View or edit context. |
| 1184 | 1184 | * @return string |
| 1185 | 1185 | */ |
| 1186 | - public function get_vat_rate( $context = 'view' ) { |
|
| 1187 | - return $this->get_prop( 'vat_rate', $context ); |
|
| 1186 | + public function get_vat_rate($context = 'view') { |
|
| 1187 | + return $this->get_prop('vat_rate', $context); |
|
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | 1190 | /** |
@@ -1194,8 +1194,8 @@ discard block |
||
| 1194 | 1194 | * @param string $context View or edit context. |
| 1195 | 1195 | * @return string |
| 1196 | 1196 | */ |
| 1197 | - public function get_user_vat_rate( $context = 'view' ) { |
|
| 1198 | - return $this->get_vat_rate( $context ); |
|
| 1197 | + public function get_user_vat_rate($context = 'view') { |
|
| 1198 | + return $this->get_vat_rate($context); |
|
| 1199 | 1199 | } |
| 1200 | 1200 | |
| 1201 | 1201 | /** |
@@ -1205,8 +1205,8 @@ discard block |
||
| 1205 | 1205 | * @param string $context View or edit context. |
| 1206 | 1206 | * @return string |
| 1207 | 1207 | */ |
| 1208 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1209 | - return $this->get_vat_rate( $context ); |
|
| 1208 | + public function get_customer_vat_rate($context = 'view') { |
|
| 1209 | + return $this->get_vat_rate($context); |
|
| 1210 | 1210 | } |
| 1211 | 1211 | |
| 1212 | 1212 | /** |
@@ -1216,8 +1216,8 @@ discard block |
||
| 1216 | 1216 | * @param string $context View or edit context. |
| 1217 | 1217 | * @return string |
| 1218 | 1218 | */ |
| 1219 | - public function get_address( $context = 'view' ) { |
|
| 1220 | - return $this->get_prop( 'address', $context ); |
|
| 1219 | + public function get_address($context = 'view') { |
|
| 1220 | + return $this->get_prop('address', $context); |
|
| 1221 | 1221 | } |
| 1222 | 1222 | |
| 1223 | 1223 | /** |
@@ -1227,8 +1227,8 @@ discard block |
||
| 1227 | 1227 | * @param string $context View or edit context. |
| 1228 | 1228 | * @return string |
| 1229 | 1229 | */ |
| 1230 | - public function get_user_address( $context = 'view' ) { |
|
| 1231 | - return $this->get_address( $context ); |
|
| 1230 | + public function get_user_address($context = 'view') { |
|
| 1231 | + return $this->get_address($context); |
|
| 1232 | 1232 | } |
| 1233 | 1233 | |
| 1234 | 1234 | /** |
@@ -1238,8 +1238,8 @@ discard block |
||
| 1238 | 1238 | * @param string $context View or edit context. |
| 1239 | 1239 | * @return string |
| 1240 | 1240 | */ |
| 1241 | - public function get_customer_address( $context = 'view' ) { |
|
| 1242 | - return $this->get_address( $context ); |
|
| 1241 | + public function get_customer_address($context = 'view') { |
|
| 1242 | + return $this->get_address($context); |
|
| 1243 | 1243 | } |
| 1244 | 1244 | |
| 1245 | 1245 | /** |
@@ -1249,8 +1249,8 @@ discard block |
||
| 1249 | 1249 | * @param string $context View or edit context. |
| 1250 | 1250 | * @return bool |
| 1251 | 1251 | */ |
| 1252 | - public function get_is_viewed( $context = 'view' ) { |
|
| 1253 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1252 | + public function get_is_viewed($context = 'view') { |
|
| 1253 | + return (bool) $this->get_prop('is_viewed', $context); |
|
| 1254 | 1254 | } |
| 1255 | 1255 | |
| 1256 | 1256 | /** |
@@ -1260,8 +1260,8 @@ discard block |
||
| 1260 | 1260 | * @param string $context View or edit context. |
| 1261 | 1261 | * @return bool |
| 1262 | 1262 | */ |
| 1263 | - public function get_email_cc( $context = 'view' ) { |
|
| 1264 | - return $this->get_prop( 'email_cc', $context ); |
|
| 1263 | + public function get_email_cc($context = 'view') { |
|
| 1264 | + return $this->get_prop('email_cc', $context); |
|
| 1265 | 1265 | } |
| 1266 | 1266 | |
| 1267 | 1267 | /** |
@@ -1271,8 +1271,8 @@ discard block |
||
| 1271 | 1271 | * @param string $context View or edit context. |
| 1272 | 1272 | * @return bool |
| 1273 | 1273 | */ |
| 1274 | - public function get_template( $context = 'view' ) { |
|
| 1275 | - return $this->get_prop( 'template', $context ); |
|
| 1274 | + public function get_template($context = 'view') { |
|
| 1275 | + return $this->get_prop('template', $context); |
|
| 1276 | 1276 | } |
| 1277 | 1277 | |
| 1278 | 1278 | /** |
@@ -1282,8 +1282,8 @@ discard block |
||
| 1282 | 1282 | * @param string $context View or edit context. |
| 1283 | 1283 | * @return bool |
| 1284 | 1284 | */ |
| 1285 | - public function get_created_via( $context = 'view' ) { |
|
| 1286 | - return $this->get_prop( 'created_via', $context ); |
|
| 1285 | + public function get_created_via($context = 'view') { |
|
| 1286 | + return $this->get_prop('created_via', $context); |
|
| 1287 | 1287 | } |
| 1288 | 1288 | |
| 1289 | 1289 | /** |
@@ -1293,8 +1293,8 @@ discard block |
||
| 1293 | 1293 | * @param string $context View or edit context. |
| 1294 | 1294 | * @return bool |
| 1295 | 1295 | */ |
| 1296 | - public function get_address_confirmed( $context = 'view' ) { |
|
| 1297 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1296 | + public function get_address_confirmed($context = 'view') { |
|
| 1297 | + return (bool) $this->get_prop('address_confirmed', $context); |
|
| 1298 | 1298 | } |
| 1299 | 1299 | |
| 1300 | 1300 | /** |
@@ -1304,8 +1304,8 @@ discard block |
||
| 1304 | 1304 | * @param string $context View or edit context. |
| 1305 | 1305 | * @return bool |
| 1306 | 1306 | */ |
| 1307 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1308 | - return $this->get_address_confirmed( $context ); |
|
| 1307 | + public function get_user_address_confirmed($context = 'view') { |
|
| 1308 | + return $this->get_address_confirmed($context); |
|
| 1309 | 1309 | } |
| 1310 | 1310 | |
| 1311 | 1311 | /** |
@@ -1315,8 +1315,8 @@ discard block |
||
| 1315 | 1315 | * @param string $context View or edit context. |
| 1316 | 1316 | * @return bool |
| 1317 | 1317 | */ |
| 1318 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1319 | - return $this->get_address_confirmed( $context ); |
|
| 1318 | + public function get_customer_address_confirmed($context = 'view') { |
|
| 1319 | + return $this->get_address_confirmed($context); |
|
| 1320 | 1320 | } |
| 1321 | 1321 | |
| 1322 | 1322 | /** |
@@ -1326,12 +1326,12 @@ discard block |
||
| 1326 | 1326 | * @param string $context View or edit context. |
| 1327 | 1327 | * @return float |
| 1328 | 1328 | */ |
| 1329 | - public function get_subtotal( $context = 'view' ) { |
|
| 1330 | - $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
|
| 1329 | + public function get_subtotal($context = 'view') { |
|
| 1330 | + $subtotal = (float) $this->get_prop('subtotal', $context); |
|
| 1331 | 1331 | |
| 1332 | 1332 | // Backwards compatibility. |
| 1333 | - if ( is_bool( $context ) && $context ) { |
|
| 1334 | - return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() ); |
|
| 1333 | + if (is_bool($context) && $context) { |
|
| 1334 | + return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency()); |
|
| 1335 | 1335 | } |
| 1336 | 1336 | |
| 1337 | 1337 | return $subtotal; |
@@ -1344,8 +1344,8 @@ discard block |
||
| 1344 | 1344 | * @param string $context View or edit context. |
| 1345 | 1345 | * @return float |
| 1346 | 1346 | */ |
| 1347 | - public function get_total_discount( $context = 'view' ) { |
|
| 1348 | - return (float) $this->get_prop( 'total_discount', $context ); |
|
| 1347 | + public function get_total_discount($context = 'view') { |
|
| 1348 | + return (float) $this->get_prop('total_discount', $context); |
|
| 1349 | 1349 | } |
| 1350 | 1350 | |
| 1351 | 1351 | /** |
@@ -1355,18 +1355,18 @@ discard block |
||
| 1355 | 1355 | * @param string $context View or edit context. |
| 1356 | 1356 | * @return float |
| 1357 | 1357 | */ |
| 1358 | - public function get_total_tax( $context = 'view' ) { |
|
| 1359 | - return (float) $this->get_prop( 'total_tax', $context ); |
|
| 1358 | + public function get_total_tax($context = 'view') { |
|
| 1359 | + return (float) $this->get_prop('total_tax', $context); |
|
| 1360 | 1360 | } |
| 1361 | 1361 | |
| 1362 | 1362 | /** |
| 1363 | 1363 | * @deprecated |
| 1364 | 1364 | */ |
| 1365 | - public function get_final_tax( $currency = false ) { |
|
| 1365 | + public function get_final_tax($currency = false) { |
|
| 1366 | 1366 | $tax = $this->get_total_tax(); |
| 1367 | 1367 | |
| 1368 | - if ( $currency ) { |
|
| 1369 | - return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
| 1368 | + if ($currency) { |
|
| 1369 | + return wpinv_price(wpinv_format_amount($tax, NULL, false), $this->get_currency()); |
|
| 1370 | 1370 | } |
| 1371 | 1371 | |
| 1372 | 1372 | return $tax; |
@@ -1379,8 +1379,8 @@ discard block |
||
| 1379 | 1379 | * @param string $context View or edit context. |
| 1380 | 1380 | * @return float |
| 1381 | 1381 | */ |
| 1382 | - public function get_total_fees( $context = 'view' ) { |
|
| 1383 | - return (float) $this->get_prop( 'total_fees', $context ); |
|
| 1382 | + public function get_total_fees($context = 'view') { |
|
| 1383 | + return (float) $this->get_prop('total_fees', $context); |
|
| 1384 | 1384 | } |
| 1385 | 1385 | |
| 1386 | 1386 | /** |
@@ -1390,8 +1390,8 @@ discard block |
||
| 1390 | 1390 | * @param string $context View or edit context. |
| 1391 | 1391 | * @return float |
| 1392 | 1392 | */ |
| 1393 | - public function get_fees_total( $context = 'view' ) { |
|
| 1394 | - return $this->get_total_fees( $context ); |
|
| 1393 | + public function get_fees_total($context = 'view') { |
|
| 1394 | + return $this->get_total_fees($context); |
|
| 1395 | 1395 | } |
| 1396 | 1396 | |
| 1397 | 1397 | /** |
@@ -1402,7 +1402,7 @@ discard block |
||
| 1402 | 1402 | */ |
| 1403 | 1403 | public function get_total() { |
| 1404 | 1404 | $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
| 1405 | - return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
| 1405 | + return apply_filters('getpaid_get_invoice_total_amount', $total, $this); |
|
| 1406 | 1406 | } |
| 1407 | 1407 | |
| 1408 | 1408 | /** |
@@ -1424,7 +1424,7 @@ discard block |
||
| 1424 | 1424 | */ |
| 1425 | 1425 | public function get_initial_total() { |
| 1426 | 1426 | |
| 1427 | - if ( empty( $this->totals ) ) { |
|
| 1427 | + if (empty($this->totals)) { |
|
| 1428 | 1428 | $this->recalculate_total(); |
| 1429 | 1429 | } |
| 1430 | 1430 | |
@@ -1434,11 +1434,11 @@ discard block |
||
| 1434 | 1434 | $subtotal = $this->totals['subtotal']['initial']; |
| 1435 | 1435 | $total = $tax + $fee - $discount + $subtotal; |
| 1436 | 1436 | |
| 1437 | - if ( 0 > $total ) { |
|
| 1437 | + if (0 > $total) { |
|
| 1438 | 1438 | $total = 0; |
| 1439 | 1439 | } |
| 1440 | 1440 | |
| 1441 | - return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
|
| 1441 | + return apply_filters('wpinv_get_initial_invoice_total', $total, $this); |
|
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | 1444 | /** |
@@ -1450,7 +1450,7 @@ discard block |
||
| 1450 | 1450 | */ |
| 1451 | 1451 | public function get_recurring_total() { |
| 1452 | 1452 | |
| 1453 | - if ( empty( $this->totals ) ) { |
|
| 1453 | + if (empty($this->totals)) { |
|
| 1454 | 1454 | $this->recalculate_total(); |
| 1455 | 1455 | } |
| 1456 | 1456 | |
@@ -1460,11 +1460,11 @@ discard block |
||
| 1460 | 1460 | $subtotal = $this->totals['subtotal']['recurring']; |
| 1461 | 1461 | $total = $tax + $fee - $discount + $subtotal; |
| 1462 | 1462 | |
| 1463 | - if ( 0 > $total ) { |
|
| 1463 | + if (0 > $total) { |
|
| 1464 | 1464 | $total = 0; |
| 1465 | 1465 | } |
| 1466 | 1466 | |
| 1467 | - return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
|
| 1467 | + return apply_filters('wpinv_get_recurring_invoice_total', $total, $this); |
|
| 1468 | 1468 | } |
| 1469 | 1469 | |
| 1470 | 1470 | /** |
@@ -1475,10 +1475,10 @@ discard block |
||
| 1475 | 1475 | * @param string $currency Whether to include the currency. |
| 1476 | 1476 | * @return float |
| 1477 | 1477 | */ |
| 1478 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
| 1478 | + public function get_recurring_details($field = '', $currency = false) { |
|
| 1479 | 1479 | |
| 1480 | 1480 | // Maybe recalculate totals. |
| 1481 | - if ( empty( $this->totals ) ) { |
|
| 1481 | + if (empty($this->totals)) { |
|
| 1482 | 1482 | $this->recalculate_total(); |
| 1483 | 1483 | } |
| 1484 | 1484 | |
@@ -1498,8 +1498,8 @@ discard block |
||
| 1498 | 1498 | $currency |
| 1499 | 1499 | ); |
| 1500 | 1500 | |
| 1501 | - if ( isset( $data[$field] ) ) { |
|
| 1502 | - return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
|
| 1501 | + if (isset($data[$field])) { |
|
| 1502 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
| 1503 | 1503 | } |
| 1504 | 1504 | |
| 1505 | 1505 | return $data; |
@@ -1512,8 +1512,8 @@ discard block |
||
| 1512 | 1512 | * @param string $context View or edit context. |
| 1513 | 1513 | * @return array |
| 1514 | 1514 | */ |
| 1515 | - public function get_fees( $context = 'view' ) { |
|
| 1516 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1515 | + public function get_fees($context = 'view') { |
|
| 1516 | + return wpinv_parse_list($this->get_prop('fees', $context)); |
|
| 1517 | 1517 | } |
| 1518 | 1518 | |
| 1519 | 1519 | /** |
@@ -1523,8 +1523,8 @@ discard block |
||
| 1523 | 1523 | * @param string $context View or edit context. |
| 1524 | 1524 | * @return array |
| 1525 | 1525 | */ |
| 1526 | - public function get_discounts( $context = 'view' ) { |
|
| 1527 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1526 | + public function get_discounts($context = 'view') { |
|
| 1527 | + return wpinv_parse_list($this->get_prop('discounts', $context)); |
|
| 1528 | 1528 | } |
| 1529 | 1529 | |
| 1530 | 1530 | /** |
@@ -1534,8 +1534,8 @@ discard block |
||
| 1534 | 1534 | * @param string $context View or edit context. |
| 1535 | 1535 | * @return array |
| 1536 | 1536 | */ |
| 1537 | - public function get_taxes( $context = 'view' ) { |
|
| 1538 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1537 | + public function get_taxes($context = 'view') { |
|
| 1538 | + return wpinv_parse_list($this->get_prop('taxes', $context)); |
|
| 1539 | 1539 | } |
| 1540 | 1540 | |
| 1541 | 1541 | /** |
@@ -1545,8 +1545,8 @@ discard block |
||
| 1545 | 1545 | * @param string $context View or edit context. |
| 1546 | 1546 | * @return GetPaid_Form_Item[] |
| 1547 | 1547 | */ |
| 1548 | - public function get_items( $context = 'view' ) { |
|
| 1549 | - return $this->get_prop( 'items', $context ); |
|
| 1548 | + public function get_items($context = 'view') { |
|
| 1549 | + return $this->get_prop('items', $context); |
|
| 1550 | 1550 | } |
| 1551 | 1551 | |
| 1552 | 1552 | /** |
@@ -1556,8 +1556,8 @@ discard block |
||
| 1556 | 1556 | * @param string $context View or edit context. |
| 1557 | 1557 | * @return int |
| 1558 | 1558 | */ |
| 1559 | - public function get_payment_form( $context = 'view' ) { |
|
| 1560 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1559 | + public function get_payment_form($context = 'view') { |
|
| 1560 | + return intval($this->get_prop('payment_form', $context)); |
|
| 1561 | 1561 | } |
| 1562 | 1562 | |
| 1563 | 1563 | /** |
@@ -1567,8 +1567,8 @@ discard block |
||
| 1567 | 1567 | * @param string $context View or edit context. |
| 1568 | 1568 | * @return string |
| 1569 | 1569 | */ |
| 1570 | - public function get_submission_id( $context = 'view' ) { |
|
| 1571 | - return $this->get_prop( 'submission_id', $context ); |
|
| 1570 | + public function get_submission_id($context = 'view') { |
|
| 1571 | + return $this->get_prop('submission_id', $context); |
|
| 1572 | 1572 | } |
| 1573 | 1573 | |
| 1574 | 1574 | /** |
@@ -1578,8 +1578,8 @@ discard block |
||
| 1578 | 1578 | * @param string $context View or edit context. |
| 1579 | 1579 | * @return string |
| 1580 | 1580 | */ |
| 1581 | - public function get_discount_code( $context = 'view' ) { |
|
| 1582 | - return $this->get_prop( 'discount_code', $context ); |
|
| 1581 | + public function get_discount_code($context = 'view') { |
|
| 1582 | + return $this->get_prop('discount_code', $context); |
|
| 1583 | 1583 | } |
| 1584 | 1584 | |
| 1585 | 1585 | /** |
@@ -1589,8 +1589,8 @@ discard block |
||
| 1589 | 1589 | * @param string $context View or edit context. |
| 1590 | 1590 | * @return string |
| 1591 | 1591 | */ |
| 1592 | - public function get_gateway( $context = 'view' ) { |
|
| 1593 | - return $this->get_prop( 'gateway', $context ); |
|
| 1592 | + public function get_gateway($context = 'view') { |
|
| 1593 | + return $this->get_prop('gateway', $context); |
|
| 1594 | 1594 | } |
| 1595 | 1595 | |
| 1596 | 1596 | /** |
@@ -1600,8 +1600,8 @@ discard block |
||
| 1600 | 1600 | * @return string |
| 1601 | 1601 | */ |
| 1602 | 1602 | public function get_gateway_title() { |
| 1603 | - $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
|
| 1604 | - return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
|
| 1603 | + $title = wpinv_get_gateway_checkout_label($this->get_gateway()); |
|
| 1604 | + return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this); |
|
| 1605 | 1605 | } |
| 1606 | 1606 | |
| 1607 | 1607 | /** |
@@ -1611,8 +1611,8 @@ discard block |
||
| 1611 | 1611 | * @param string $context View or edit context. |
| 1612 | 1612 | * @return string |
| 1613 | 1613 | */ |
| 1614 | - public function get_transaction_id( $context = 'view' ) { |
|
| 1615 | - return $this->get_prop( 'transaction_id', $context ); |
|
| 1614 | + public function get_transaction_id($context = 'view') { |
|
| 1615 | + return $this->get_prop('transaction_id', $context); |
|
| 1616 | 1616 | } |
| 1617 | 1617 | |
| 1618 | 1618 | /** |
@@ -1622,9 +1622,9 @@ discard block |
||
| 1622 | 1622 | * @param string $context View or edit context. |
| 1623 | 1623 | * @return string |
| 1624 | 1624 | */ |
| 1625 | - public function get_currency( $context = 'view' ) { |
|
| 1626 | - $currency = $this->get_prop( 'currency', $context ); |
|
| 1627 | - return empty( $currency ) ? wpinv_get_currency() : $currency; |
|
| 1625 | + public function get_currency($context = 'view') { |
|
| 1626 | + $currency = $this->get_prop('currency', $context); |
|
| 1627 | + return empty($currency) ? wpinv_get_currency() : $currency; |
|
| 1628 | 1628 | } |
| 1629 | 1629 | |
| 1630 | 1630 | /** |
@@ -1634,8 +1634,8 @@ discard block |
||
| 1634 | 1634 | * @param string $context View or edit context. |
| 1635 | 1635 | * @return bool |
| 1636 | 1636 | */ |
| 1637 | - public function get_disable_taxes( $context = 'view' ) { |
|
| 1638 | - return (bool) $this->get_prop( 'disable_taxes', $context ); |
|
| 1637 | + public function get_disable_taxes($context = 'view') { |
|
| 1638 | + return (bool) $this->get_prop('disable_taxes', $context); |
|
| 1639 | 1639 | } |
| 1640 | 1640 | |
| 1641 | 1641 | /** |
@@ -1645,8 +1645,8 @@ discard block |
||
| 1645 | 1645 | * @param string $context View or edit context. |
| 1646 | 1646 | * @return int |
| 1647 | 1647 | */ |
| 1648 | - public function get_subscription_id( $context = 'view' ) { |
|
| 1649 | - return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
| 1648 | + public function get_subscription_id($context = 'view') { |
|
| 1649 | + return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context); |
|
| 1650 | 1650 | } |
| 1651 | 1651 | |
| 1652 | 1652 | /** |
@@ -1656,12 +1656,12 @@ discard block |
||
| 1656 | 1656 | * @param string $context View or edit context. |
| 1657 | 1657 | * @return int |
| 1658 | 1658 | */ |
| 1659 | - public function get_remote_subscription_id( $context = 'view' ) { |
|
| 1660 | - $subscription_id = $this->get_prop( 'remote_subscription_id', $context ); |
|
| 1659 | + public function get_remote_subscription_id($context = 'view') { |
|
| 1660 | + $subscription_id = $this->get_prop('remote_subscription_id', $context); |
|
| 1661 | 1661 | |
| 1662 | - if ( empty( $subscription_id ) && $this->is_renewal() ) { |
|
| 1662 | + if (empty($subscription_id) && $this->is_renewal()) { |
|
| 1663 | 1663 | $parent = $this->get_parent(); |
| 1664 | - return $parent->get_subscription_id( $context ); |
|
| 1664 | + return $parent->get_subscription_id($context); |
|
| 1665 | 1665 | } |
| 1666 | 1666 | |
| 1667 | 1667 | return $subscription_id; |
@@ -1674,20 +1674,20 @@ discard block |
||
| 1674 | 1674 | * @param string $context View or edit context. |
| 1675 | 1675 | * @return array |
| 1676 | 1676 | */ |
| 1677 | - public function get_payment_meta( $context = 'view' ) { |
|
| 1677 | + public function get_payment_meta($context = 'view') { |
|
| 1678 | 1678 | |
| 1679 | 1679 | return array( |
| 1680 | - 'price' => $this->get_total( $context ), |
|
| 1681 | - 'date' => $this->get_date_created( $context ), |
|
| 1682 | - 'user_email' => $this->get_email( $context ), |
|
| 1683 | - 'invoice_key' => $this->get_key( $context ), |
|
| 1684 | - 'currency' => $this->get_currency( $context ), |
|
| 1685 | - 'items' => $this->get_items( $context ), |
|
| 1686 | - 'user_info' => $this->get_user_info( $context ), |
|
| 1680 | + 'price' => $this->get_total($context), |
|
| 1681 | + 'date' => $this->get_date_created($context), |
|
| 1682 | + 'user_email' => $this->get_email($context), |
|
| 1683 | + 'invoice_key' => $this->get_key($context), |
|
| 1684 | + 'currency' => $this->get_currency($context), |
|
| 1685 | + 'items' => $this->get_items($context), |
|
| 1686 | + 'user_info' => $this->get_user_info($context), |
|
| 1687 | 1687 | 'cart_details' => $this->get_cart_details(), |
| 1688 | - 'status' => $this->get_status( $context ), |
|
| 1689 | - 'fees' => $this->get_fees( $context ), |
|
| 1690 | - 'taxes' => $this->get_taxes( $context ), |
|
| 1688 | + 'status' => $this->get_status($context), |
|
| 1689 | + 'fees' => $this->get_fees($context), |
|
| 1690 | + 'taxes' => $this->get_taxes($context), |
|
| 1691 | 1691 | ); |
| 1692 | 1692 | |
| 1693 | 1693 | } |
@@ -1702,9 +1702,9 @@ discard block |
||
| 1702 | 1702 | $items = $this->get_items(); |
| 1703 | 1703 | $cart_details = array(); |
| 1704 | 1704 | |
| 1705 | - foreach ( $items as $item_id => $item ) { |
|
| 1705 | + foreach ($items as $item_id => $item) { |
|
| 1706 | 1706 | $item->invoice_id = $this->get_id(); |
| 1707 | - $cart_details[] = $item->prepare_data_for_saving(); |
|
| 1707 | + $cart_details[] = $item->prepare_data_for_saving(); |
|
| 1708 | 1708 | } |
| 1709 | 1709 | |
| 1710 | 1710 | return $cart_details; |
@@ -1715,11 +1715,11 @@ discard block |
||
| 1715 | 1715 | * |
| 1716 | 1716 | * @return null|GetPaid_Form_Item|int |
| 1717 | 1717 | */ |
| 1718 | - public function get_recurring( $object = false ) { |
|
| 1718 | + public function get_recurring($object = false) { |
|
| 1719 | 1719 | |
| 1720 | 1720 | // Are we returning an object? |
| 1721 | - if ( $object ) { |
|
| 1722 | - return $this->get_item( $this->recurring_item ); |
|
| 1721 | + if ($object) { |
|
| 1722 | + return $this->get_item($this->recurring_item); |
|
| 1723 | 1723 | } |
| 1724 | 1724 | |
| 1725 | 1725 | return $this->recurring_item; |
@@ -1734,15 +1734,15 @@ discard block |
||
| 1734 | 1734 | public function get_subscription_name() { |
| 1735 | 1735 | |
| 1736 | 1736 | // Retrieve the recurring name |
| 1737 | - $item = $this->get_recurring( true ); |
|
| 1737 | + $item = $this->get_recurring(true); |
|
| 1738 | 1738 | |
| 1739 | 1739 | // Abort if it does not exist. |
| 1740 | - if ( empty( $item ) ) { |
|
| 1740 | + if (empty($item)) { |
|
| 1741 | 1741 | return ''; |
| 1742 | 1742 | } |
| 1743 | 1743 | |
| 1744 | 1744 | // Return the item name. |
| 1745 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
|
| 1745 | + return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this); |
|
| 1746 | 1746 | } |
| 1747 | 1747 | |
| 1748 | 1748 | /** |
@@ -1752,9 +1752,9 @@ discard block |
||
| 1752 | 1752 | * @return string |
| 1753 | 1753 | */ |
| 1754 | 1754 | public function get_view_url() { |
| 1755 | - $invoice_url = get_permalink( $this->get_id() ); |
|
| 1756 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1757 | - return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
|
| 1755 | + $invoice_url = get_permalink($this->get_id()); |
|
| 1756 | + $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url); |
|
| 1757 | + return apply_filters('wpinv_get_view_url', $invoice_url, $this); |
|
| 1758 | 1758 | } |
| 1759 | 1759 | |
| 1760 | 1760 | /** |
@@ -1763,25 +1763,25 @@ discard block |
||
| 1763 | 1763 | * @since 1.0.19 |
| 1764 | 1764 | * @return string |
| 1765 | 1765 | */ |
| 1766 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1766 | + public function get_checkout_payment_url($deprecated = false, $secret = false) { |
|
| 1767 | 1767 | |
| 1768 | 1768 | // Retrieve the checkout url. |
| 1769 | 1769 | $pay_url = wpinv_get_checkout_uri(); |
| 1770 | 1770 | |
| 1771 | 1771 | // Maybe force ssl. |
| 1772 | - if ( is_ssl() ) { |
|
| 1773 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
| 1772 | + if (is_ssl()) { |
|
| 1773 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
| 1774 | 1774 | } |
| 1775 | 1775 | |
| 1776 | 1776 | // Add the invoice key. |
| 1777 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1777 | + $pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url); |
|
| 1778 | 1778 | |
| 1779 | 1779 | // (Maybe?) add a secret |
| 1780 | - if ( $secret ) { |
|
| 1781 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
|
| 1780 | + if ($secret) { |
|
| 1781 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url); |
|
| 1782 | 1782 | } |
| 1783 | 1783 | |
| 1784 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
|
| 1784 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret); |
|
| 1785 | 1785 | } |
| 1786 | 1786 | |
| 1787 | 1787 | /** |
@@ -1796,14 +1796,14 @@ discard block |
||
| 1796 | 1796 | $receipt_url = wpinv_get_success_page_uri(); |
| 1797 | 1797 | |
| 1798 | 1798 | // Maybe force ssl. |
| 1799 | - if ( is_ssl() ) { |
|
| 1800 | - $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
|
| 1799 | + if (is_ssl()) { |
|
| 1800 | + $receipt_url = str_replace('http:', 'https:', $receipt_url); |
|
| 1801 | 1801 | } |
| 1802 | 1802 | |
| 1803 | 1803 | // Add the invoice key. |
| 1804 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1804 | + $receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url); |
|
| 1805 | 1805 | |
| 1806 | - return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
|
| 1806 | + return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this); |
|
| 1807 | 1807 | } |
| 1808 | 1808 | |
| 1809 | 1809 | /** |
@@ -1816,7 +1816,7 @@ discard block |
||
| 1816 | 1816 | |
| 1817 | 1817 | $type = $this->get_type(); |
| 1818 | 1818 | $status = "wpi-$type-pending"; |
| 1819 | - return str_replace( '-invoice', '', $status ); |
|
| 1819 | + return str_replace('-invoice', '', $status); |
|
| 1820 | 1820 | |
| 1821 | 1821 | } |
| 1822 | 1822 | |
@@ -1830,8 +1830,8 @@ discard block |
||
| 1830 | 1830 | * @param string $context View or edit context. |
| 1831 | 1831 | * @return mixed Value of the given invoice property (if set). |
| 1832 | 1832 | */ |
| 1833 | - public function get( $key, $context = 'view' ) { |
|
| 1834 | - return $this->get_prop( $key, $context ); |
|
| 1833 | + public function get($key, $context = 'view') { |
|
| 1834 | + return $this->get_prop($key, $context); |
|
| 1835 | 1835 | } |
| 1836 | 1836 | |
| 1837 | 1837 | /* |
@@ -1854,11 +1854,11 @@ discard block |
||
| 1854 | 1854 | * @param mixed $value new value. |
| 1855 | 1855 | * @return mixed Value of the given invoice property (if set). |
| 1856 | 1856 | */ |
| 1857 | - public function set( $key, $value ) { |
|
| 1857 | + public function set($key, $value) { |
|
| 1858 | 1858 | |
| 1859 | 1859 | $setter = "set_$key"; |
| 1860 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
| 1861 | - $this->{$setter}( $value ); |
|
| 1860 | + if (is_callable(array($this, $setter))) { |
|
| 1861 | + $this->{$setter}($value); |
|
| 1862 | 1862 | } |
| 1863 | 1863 | |
| 1864 | 1864 | } |
@@ -1872,47 +1872,47 @@ discard block |
||
| 1872 | 1872 | * @param bool $manual_update Is this a manual status change?. |
| 1873 | 1873 | * @return array details of change. |
| 1874 | 1874 | */ |
| 1875 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1875 | + public function set_status($new_status, $note = '', $manual_update = false) { |
|
| 1876 | 1876 | $old_status = $this->get_status(); |
| 1877 | 1877 | |
| 1878 | 1878 | $statuses = $this->get_all_statuses(); |
| 1879 | 1879 | |
| 1880 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1881 | - unset( $statuses[ 'draft' ] ); |
|
| 1880 | + if (isset($statuses['draft'])) { |
|
| 1881 | + unset($statuses['draft']); |
|
| 1882 | 1882 | } |
| 1883 | 1883 | |
| 1884 | - $this->set_prop( 'status', $new_status ); |
|
| 1884 | + $this->set_prop('status', $new_status); |
|
| 1885 | 1885 | |
| 1886 | 1886 | // If setting the status, ensure it's set to a valid status. |
| 1887 | - if ( true === $this->object_read ) { |
|
| 1887 | + if (true === $this->object_read) { |
|
| 1888 | 1888 | |
| 1889 | 1889 | // Only allow valid new status. |
| 1890 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1890 | + if (!array_key_exists($new_status, $statuses)) { |
|
| 1891 | 1891 | $new_status = $this->get_default_status(); |
| 1892 | 1892 | } |
| 1893 | 1893 | |
| 1894 | 1894 | // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
| 1895 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1895 | + if ($old_status && !array_key_exists($new_status, $statuses)) { |
|
| 1896 | 1896 | $old_status = $this->get_default_status(); |
| 1897 | 1897 | } |
| 1898 | 1898 | |
| 1899 | 1899 | // Paid - Renewal (i.e when duplicating a parent invoice ) |
| 1900 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
| 1900 | + if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) { |
|
| 1901 | 1901 | $old_status = 'wpi-pending'; |
| 1902 | 1902 | } |
| 1903 | 1903 | |
| 1904 | 1904 | } |
| 1905 | 1905 | |
| 1906 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
| 1906 | + if (true === $this->object_read && $old_status !== $new_status) { |
|
| 1907 | 1907 | $this->status_transition = array( |
| 1908 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1908 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
| 1909 | 1909 | 'to' => $new_status, |
| 1910 | 1910 | 'note' => $note, |
| 1911 | 1911 | 'manual' => (bool) $manual_update, |
| 1912 | 1912 | ); |
| 1913 | 1913 | |
| 1914 | - if ( $manual_update ) { |
|
| 1915 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1914 | + if ($manual_update) { |
|
| 1915 | + do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status); |
|
| 1916 | 1916 | } |
| 1917 | 1917 | |
| 1918 | 1918 | $this->maybe_set_date_paid(); |
@@ -1935,8 +1935,8 @@ discard block |
||
| 1935 | 1935 | */ |
| 1936 | 1936 | public function maybe_set_date_paid() { |
| 1937 | 1937 | |
| 1938 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 1939 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 1938 | + if (!$this->get_date_completed('edit') && $this->is_paid()) { |
|
| 1939 | + $this->set_date_completed(current_time('mysql')); |
|
| 1940 | 1940 | } |
| 1941 | 1941 | } |
| 1942 | 1942 | |
@@ -1945,11 +1945,11 @@ discard block |
||
| 1945 | 1945 | * |
| 1946 | 1946 | * @since 1.0.19 |
| 1947 | 1947 | */ |
| 1948 | - public function set_parent_id( $value ) { |
|
| 1949 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
| 1948 | + public function set_parent_id($value) { |
|
| 1949 | + if ($value && ($value === $this->get_id())) { |
|
| 1950 | 1950 | return; |
| 1951 | 1951 | } |
| 1952 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 1952 | + $this->set_prop('parent_id', absint($value)); |
|
| 1953 | 1953 | } |
| 1954 | 1954 | |
| 1955 | 1955 | /** |
@@ -1957,8 +1957,8 @@ discard block |
||
| 1957 | 1957 | * |
| 1958 | 1958 | * @since 1.0.19 |
| 1959 | 1959 | */ |
| 1960 | - public function set_version( $value ) { |
|
| 1961 | - $this->set_prop( 'version', $value ); |
|
| 1960 | + public function set_version($value) { |
|
| 1961 | + $this->set_prop('version', $value); |
|
| 1962 | 1962 | } |
| 1963 | 1963 | |
| 1964 | 1964 | /** |
@@ -1968,15 +1968,15 @@ discard block |
||
| 1968 | 1968 | * @param string $value Value to set. |
| 1969 | 1969 | * @return bool Whether or not the date was set. |
| 1970 | 1970 | */ |
| 1971 | - public function set_date_created( $value ) { |
|
| 1972 | - $date = strtotime( $value ); |
|
| 1971 | + public function set_date_created($value) { |
|
| 1972 | + $date = strtotime($value); |
|
| 1973 | 1973 | |
| 1974 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 1975 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
| 1974 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 1975 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
| 1976 | 1976 | return true; |
| 1977 | 1977 | } |
| 1978 | 1978 | |
| 1979 | - return $this->set_prop( 'date_created', '' ); |
|
| 1979 | + return $this->set_prop('date_created', ''); |
|
| 1980 | 1980 | |
| 1981 | 1981 | } |
| 1982 | 1982 | |
@@ -1987,15 +1987,15 @@ discard block |
||
| 1987 | 1987 | * @param string $value Value to set. |
| 1988 | 1988 | * @return bool Whether or not the date was set. |
| 1989 | 1989 | */ |
| 1990 | - public function set_due_date( $value ) { |
|
| 1991 | - $date = strtotime( $value ); |
|
| 1990 | + public function set_due_date($value) { |
|
| 1991 | + $date = strtotime($value); |
|
| 1992 | 1992 | |
| 1993 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 1994 | - $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) ); |
|
| 1993 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 1994 | + $this->set_prop('due_date', date('Y-m-d H:i:s', $date)); |
|
| 1995 | 1995 | return true; |
| 1996 | 1996 | } |
| 1997 | 1997 | |
| 1998 | - $this->set_prop( 'due_date', '' ); |
|
| 1998 | + $this->set_prop('due_date', ''); |
|
| 1999 | 1999 | return false; |
| 2000 | 2000 | |
| 2001 | 2001 | } |
@@ -2006,8 +2006,8 @@ discard block |
||
| 2006 | 2006 | * @since 1.0.19 |
| 2007 | 2007 | * @param string $value New name. |
| 2008 | 2008 | */ |
| 2009 | - public function set_date_due( $value ) { |
|
| 2010 | - $this->set_due_date( $value ); |
|
| 2009 | + public function set_date_due($value) { |
|
| 2010 | + $this->set_due_date($value); |
|
| 2011 | 2011 | } |
| 2012 | 2012 | |
| 2013 | 2013 | /** |
@@ -2017,15 +2017,15 @@ discard block |
||
| 2017 | 2017 | * @param string $value Value to set. |
| 2018 | 2018 | * @return bool Whether or not the date was set. |
| 2019 | 2019 | */ |
| 2020 | - public function set_completed_date( $value ) { |
|
| 2021 | - $date = strtotime( $value ); |
|
| 2020 | + public function set_completed_date($value) { |
|
| 2021 | + $date = strtotime($value); |
|
| 2022 | 2022 | |
| 2023 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 2024 | - $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) ); |
|
| 2023 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 2024 | + $this->set_prop('completed_date', date('Y-m-d H:i:s', $date)); |
|
| 2025 | 2025 | return true; |
| 2026 | 2026 | } |
| 2027 | 2027 | |
| 2028 | - $this->set_prop( 'completed_date', '' ); |
|
| 2028 | + $this->set_prop('completed_date', ''); |
|
| 2029 | 2029 | return false; |
| 2030 | 2030 | |
| 2031 | 2031 | } |
@@ -2036,8 +2036,8 @@ discard block |
||
| 2036 | 2036 | * @since 1.0.19 |
| 2037 | 2037 | * @param string $value New name. |
| 2038 | 2038 | */ |
| 2039 | - public function set_date_completed( $value ) { |
|
| 2040 | - $this->set_completed_date( $value ); |
|
| 2039 | + public function set_date_completed($value) { |
|
| 2040 | + $this->set_completed_date($value); |
|
| 2041 | 2041 | } |
| 2042 | 2042 | |
| 2043 | 2043 | /** |
@@ -2047,15 +2047,15 @@ discard block |
||
| 2047 | 2047 | * @param string $value Value to set. |
| 2048 | 2048 | * @return bool Whether or not the date was set. |
| 2049 | 2049 | */ |
| 2050 | - public function set_date_modified( $value ) { |
|
| 2051 | - $date = strtotime( $value ); |
|
| 2050 | + public function set_date_modified($value) { |
|
| 2051 | + $date = strtotime($value); |
|
| 2052 | 2052 | |
| 2053 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 2054 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
| 2053 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 2054 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
| 2055 | 2055 | return true; |
| 2056 | 2056 | } |
| 2057 | 2057 | |
| 2058 | - $this->set_prop( 'date_modified', '' ); |
|
| 2058 | + $this->set_prop('date_modified', ''); |
|
| 2059 | 2059 | return false; |
| 2060 | 2060 | |
| 2061 | 2061 | } |
@@ -2066,9 +2066,9 @@ discard block |
||
| 2066 | 2066 | * @since 1.0.19 |
| 2067 | 2067 | * @param string $value New number. |
| 2068 | 2068 | */ |
| 2069 | - public function set_number( $value ) { |
|
| 2070 | - $number = sanitize_text_field( $value ); |
|
| 2071 | - $this->set_prop( 'number', $number ); |
|
| 2069 | + public function set_number($value) { |
|
| 2070 | + $number = sanitize_text_field($value); |
|
| 2071 | + $this->set_prop('number', $number); |
|
| 2072 | 2072 | } |
| 2073 | 2073 | |
| 2074 | 2074 | /** |
@@ -2077,9 +2077,9 @@ discard block |
||
| 2077 | 2077 | * @since 1.0.19 |
| 2078 | 2078 | * @param string $value Type. |
| 2079 | 2079 | */ |
| 2080 | - public function set_type( $value ) { |
|
| 2081 | - $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
|
| 2082 | - $this->set_prop( 'type', $type ); |
|
| 2080 | + public function set_type($value) { |
|
| 2081 | + $type = sanitize_text_field(str_replace('wpi_', '', $value)); |
|
| 2082 | + $this->set_prop('type', $type); |
|
| 2083 | 2083 | } |
| 2084 | 2084 | |
| 2085 | 2085 | /** |
@@ -2088,10 +2088,10 @@ discard block |
||
| 2088 | 2088 | * @since 1.0.19 |
| 2089 | 2089 | * @param string $value Post type. |
| 2090 | 2090 | */ |
| 2091 | - public function set_post_type( $value ) { |
|
| 2092 | - if ( getpaid_is_invoice_post_type( $value ) ) { |
|
| 2093 | - $this->set_type( $value ); |
|
| 2094 | - $this->set_prop( 'post_type', $value ); |
|
| 2091 | + public function set_post_type($value) { |
|
| 2092 | + if (getpaid_is_invoice_post_type($value)) { |
|
| 2093 | + $this->set_type($value); |
|
| 2094 | + $this->set_prop('post_type', $value); |
|
| 2095 | 2095 | } |
| 2096 | 2096 | } |
| 2097 | 2097 | |
@@ -2101,9 +2101,9 @@ discard block |
||
| 2101 | 2101 | * @since 1.0.19 |
| 2102 | 2102 | * @param string $value New key. |
| 2103 | 2103 | */ |
| 2104 | - public function set_key( $value ) { |
|
| 2105 | - $key = sanitize_text_field( $value ); |
|
| 2106 | - $this->set_prop( 'key', $key ); |
|
| 2104 | + public function set_key($value) { |
|
| 2105 | + $key = sanitize_text_field($value); |
|
| 2106 | + $this->set_prop('key', $key); |
|
| 2107 | 2107 | } |
| 2108 | 2108 | |
| 2109 | 2109 | /** |
@@ -2112,9 +2112,9 @@ discard block |
||
| 2112 | 2112 | * @since 1.0.19 |
| 2113 | 2113 | * @param string $value mode. |
| 2114 | 2114 | */ |
| 2115 | - public function set_mode( $value ) { |
|
| 2116 | - if ( ! in_array( $value, array( 'live', 'test' ) ) ) { |
|
| 2117 | - $this->set_prop( 'value', $value ); |
|
| 2115 | + public function set_mode($value) { |
|
| 2116 | + if (!in_array($value, array('live', 'test'))) { |
|
| 2117 | + $this->set_prop('value', $value); |
|
| 2118 | 2118 | } |
| 2119 | 2119 | } |
| 2120 | 2120 | |
@@ -2124,8 +2124,8 @@ discard block |
||
| 2124 | 2124 | * @since 1.0.19 |
| 2125 | 2125 | * @param string $value path. |
| 2126 | 2126 | */ |
| 2127 | - public function set_path( $value ) { |
|
| 2128 | - $this->set_prop( 'path', $value ); |
|
| 2127 | + public function set_path($value) { |
|
| 2128 | + $this->set_prop('path', $value); |
|
| 2129 | 2129 | } |
| 2130 | 2130 | |
| 2131 | 2131 | /** |
@@ -2134,9 +2134,9 @@ discard block |
||
| 2134 | 2134 | * @since 1.0.19 |
| 2135 | 2135 | * @param string $value New name. |
| 2136 | 2136 | */ |
| 2137 | - public function set_name( $value ) { |
|
| 2138 | - $name = sanitize_text_field( $value ); |
|
| 2139 | - $this->set_prop( 'name', $name ); |
|
| 2137 | + public function set_name($value) { |
|
| 2138 | + $name = sanitize_text_field($value); |
|
| 2139 | + $this->set_prop('name', $name); |
|
| 2140 | 2140 | } |
| 2141 | 2141 | |
| 2142 | 2142 | /** |
@@ -2145,8 +2145,8 @@ discard block |
||
| 2145 | 2145 | * @since 1.0.19 |
| 2146 | 2146 | * @param string $value New name. |
| 2147 | 2147 | */ |
| 2148 | - public function set_title( $value ) { |
|
| 2149 | - $this->set_name( $value ); |
|
| 2148 | + public function set_title($value) { |
|
| 2149 | + $this->set_name($value); |
|
| 2150 | 2150 | } |
| 2151 | 2151 | |
| 2152 | 2152 | /** |
@@ -2155,9 +2155,9 @@ discard block |
||
| 2155 | 2155 | * @since 1.0.19 |
| 2156 | 2156 | * @param string $value New description. |
| 2157 | 2157 | */ |
| 2158 | - public function set_description( $value ) { |
|
| 2159 | - $description = wp_kses_post( $value ); |
|
| 2160 | - return $this->set_prop( 'description', $description ); |
|
| 2158 | + public function set_description($value) { |
|
| 2159 | + $description = wp_kses_post($value); |
|
| 2160 | + return $this->set_prop('description', $description); |
|
| 2161 | 2161 | } |
| 2162 | 2162 | |
| 2163 | 2163 | /** |
@@ -2166,8 +2166,8 @@ discard block |
||
| 2166 | 2166 | * @since 1.0.19 |
| 2167 | 2167 | * @param string $value New description. |
| 2168 | 2168 | */ |
| 2169 | - public function set_excerpt( $value ) { |
|
| 2170 | - $this->set_description( $value ); |
|
| 2169 | + public function set_excerpt($value) { |
|
| 2170 | + $this->set_description($value); |
|
| 2171 | 2171 | } |
| 2172 | 2172 | |
| 2173 | 2173 | /** |
@@ -2176,8 +2176,8 @@ discard block |
||
| 2176 | 2176 | * @since 1.0.19 |
| 2177 | 2177 | * @param string $value New description. |
| 2178 | 2178 | */ |
| 2179 | - public function set_summary( $value ) { |
|
| 2180 | - $this->set_description( $value ); |
|
| 2179 | + public function set_summary($value) { |
|
| 2180 | + $this->set_description($value); |
|
| 2181 | 2181 | } |
| 2182 | 2182 | |
| 2183 | 2183 | /** |
@@ -2186,12 +2186,12 @@ discard block |
||
| 2186 | 2186 | * @since 1.0.19 |
| 2187 | 2187 | * @param int $value New author. |
| 2188 | 2188 | */ |
| 2189 | - public function set_author( $value ) { |
|
| 2190 | - $user = get_user_by( 'id', (int) $value ); |
|
| 2189 | + public function set_author($value) { |
|
| 2190 | + $user = get_user_by('id', (int) $value); |
|
| 2191 | 2191 | |
| 2192 | - if ( $user && $user->ID ) { |
|
| 2193 | - $this->set_prop( 'author', $user->ID ); |
|
| 2194 | - $this->set_prop( 'email', $user->user_email ); |
|
| 2192 | + if ($user && $user->ID) { |
|
| 2193 | + $this->set_prop('author', $user->ID); |
|
| 2194 | + $this->set_prop('email', $user->user_email); |
|
| 2195 | 2195 | } |
| 2196 | 2196 | |
| 2197 | 2197 | } |
@@ -2202,8 +2202,8 @@ discard block |
||
| 2202 | 2202 | * @since 1.0.19 |
| 2203 | 2203 | * @param int $value New user id. |
| 2204 | 2204 | */ |
| 2205 | - public function set_user_id( $value ) { |
|
| 2206 | - $this->set_author( $value ); |
|
| 2205 | + public function set_user_id($value) { |
|
| 2206 | + $this->set_author($value); |
|
| 2207 | 2207 | } |
| 2208 | 2208 | |
| 2209 | 2209 | /** |
@@ -2212,8 +2212,8 @@ discard block |
||
| 2212 | 2212 | * @since 1.0.19 |
| 2213 | 2213 | * @param int $value New user id. |
| 2214 | 2214 | */ |
| 2215 | - public function set_customer_id( $value ) { |
|
| 2216 | - $this->set_author( $value ); |
|
| 2215 | + public function set_customer_id($value) { |
|
| 2216 | + $this->set_author($value); |
|
| 2217 | 2217 | } |
| 2218 | 2218 | |
| 2219 | 2219 | /** |
@@ -2222,8 +2222,8 @@ discard block |
||
| 2222 | 2222 | * @since 1.0.19 |
| 2223 | 2223 | * @param string $value ip address. |
| 2224 | 2224 | */ |
| 2225 | - public function set_ip( $value ) { |
|
| 2226 | - $this->set_prop( 'ip', $value ); |
|
| 2225 | + public function set_ip($value) { |
|
| 2226 | + $this->set_prop('ip', $value); |
|
| 2227 | 2227 | } |
| 2228 | 2228 | |
| 2229 | 2229 | /** |
@@ -2232,8 +2232,8 @@ discard block |
||
| 2232 | 2232 | * @since 1.0.19 |
| 2233 | 2233 | * @param string $value ip address. |
| 2234 | 2234 | */ |
| 2235 | - public function set_user_ip( $value ) { |
|
| 2236 | - $this->set_ip( $value ); |
|
| 2235 | + public function set_user_ip($value) { |
|
| 2236 | + $this->set_ip($value); |
|
| 2237 | 2237 | } |
| 2238 | 2238 | |
| 2239 | 2239 | /** |
@@ -2242,8 +2242,8 @@ discard block |
||
| 2242 | 2242 | * @since 1.0.19 |
| 2243 | 2243 | * @param string $value first name. |
| 2244 | 2244 | */ |
| 2245 | - public function set_first_name( $value ) { |
|
| 2246 | - $this->set_prop( 'first_name', $value ); |
|
| 2245 | + public function set_first_name($value) { |
|
| 2246 | + $this->set_prop('first_name', $value); |
|
| 2247 | 2247 | } |
| 2248 | 2248 | |
| 2249 | 2249 | /** |
@@ -2252,8 +2252,8 @@ discard block |
||
| 2252 | 2252 | * @since 1.0.19 |
| 2253 | 2253 | * @param string $value first name. |
| 2254 | 2254 | */ |
| 2255 | - public function set_user_first_name( $value ) { |
|
| 2256 | - $this->set_first_name( $value ); |
|
| 2255 | + public function set_user_first_name($value) { |
|
| 2256 | + $this->set_first_name($value); |
|
| 2257 | 2257 | } |
| 2258 | 2258 | |
| 2259 | 2259 | /** |
@@ -2262,8 +2262,8 @@ discard block |
||
| 2262 | 2262 | * @since 1.0.19 |
| 2263 | 2263 | * @param string $value first name. |
| 2264 | 2264 | */ |
| 2265 | - public function set_customer_first_name( $value ) { |
|
| 2266 | - $this->set_first_name( $value ); |
|
| 2265 | + public function set_customer_first_name($value) { |
|
| 2266 | + $this->set_first_name($value); |
|
| 2267 | 2267 | } |
| 2268 | 2268 | |
| 2269 | 2269 | /** |
@@ -2272,8 +2272,8 @@ discard block |
||
| 2272 | 2272 | * @since 1.0.19 |
| 2273 | 2273 | * @param string $value last name. |
| 2274 | 2274 | */ |
| 2275 | - public function set_last_name( $value ) { |
|
| 2276 | - $this->set_prop( 'last_name', $value ); |
|
| 2275 | + public function set_last_name($value) { |
|
| 2276 | + $this->set_prop('last_name', $value); |
|
| 2277 | 2277 | } |
| 2278 | 2278 | |
| 2279 | 2279 | /** |
@@ -2282,8 +2282,8 @@ discard block |
||
| 2282 | 2282 | * @since 1.0.19 |
| 2283 | 2283 | * @param string $value last name. |
| 2284 | 2284 | */ |
| 2285 | - public function set_user_last_name( $value ) { |
|
| 2286 | - $this->set_last_name( $value ); |
|
| 2285 | + public function set_user_last_name($value) { |
|
| 2286 | + $this->set_last_name($value); |
|
| 2287 | 2287 | } |
| 2288 | 2288 | |
| 2289 | 2289 | /** |
@@ -2292,8 +2292,8 @@ discard block |
||
| 2292 | 2292 | * @since 1.0.19 |
| 2293 | 2293 | * @param string $value last name. |
| 2294 | 2294 | */ |
| 2295 | - public function set_customer_last_name( $value ) { |
|
| 2296 | - $this->set_last_name( $value ); |
|
| 2295 | + public function set_customer_last_name($value) { |
|
| 2296 | + $this->set_last_name($value); |
|
| 2297 | 2297 | } |
| 2298 | 2298 | |
| 2299 | 2299 | /** |
@@ -2302,8 +2302,8 @@ discard block |
||
| 2302 | 2302 | * @since 1.0.19 |
| 2303 | 2303 | * @param string $value phone. |
| 2304 | 2304 | */ |
| 2305 | - public function set_phone( $value ) { |
|
| 2306 | - $this->set_prop( 'phone', $value ); |
|
| 2305 | + public function set_phone($value) { |
|
| 2306 | + $this->set_prop('phone', $value); |
|
| 2307 | 2307 | } |
| 2308 | 2308 | |
| 2309 | 2309 | /** |
@@ -2312,8 +2312,8 @@ discard block |
||
| 2312 | 2312 | * @since 1.0.19 |
| 2313 | 2313 | * @param string $value phone. |
| 2314 | 2314 | */ |
| 2315 | - public function set_user_phone( $value ) { |
|
| 2316 | - $this->set_phone( $value ); |
|
| 2315 | + public function set_user_phone($value) { |
|
| 2316 | + $this->set_phone($value); |
|
| 2317 | 2317 | } |
| 2318 | 2318 | |
| 2319 | 2319 | /** |
@@ -2322,8 +2322,8 @@ discard block |
||
| 2322 | 2322 | * @since 1.0.19 |
| 2323 | 2323 | * @param string $value phone. |
| 2324 | 2324 | */ |
| 2325 | - public function set_customer_phone( $value ) { |
|
| 2326 | - $this->set_phone( $value ); |
|
| 2325 | + public function set_customer_phone($value) { |
|
| 2326 | + $this->set_phone($value); |
|
| 2327 | 2327 | } |
| 2328 | 2328 | |
| 2329 | 2329 | /** |
@@ -2332,8 +2332,8 @@ discard block |
||
| 2332 | 2332 | * @since 1.0.19 |
| 2333 | 2333 | * @param string $value phone. |
| 2334 | 2334 | */ |
| 2335 | - public function set_phone_number( $value ) { |
|
| 2336 | - $this->set_phone( $value ); |
|
| 2335 | + public function set_phone_number($value) { |
|
| 2336 | + $this->set_phone($value); |
|
| 2337 | 2337 | } |
| 2338 | 2338 | |
| 2339 | 2339 | /** |
@@ -2342,8 +2342,8 @@ discard block |
||
| 2342 | 2342 | * @since 1.0.19 |
| 2343 | 2343 | * @param string $value email address. |
| 2344 | 2344 | */ |
| 2345 | - public function set_email( $value ) { |
|
| 2346 | - $this->set_prop( 'email', $value ); |
|
| 2345 | + public function set_email($value) { |
|
| 2346 | + $this->set_prop('email', $value); |
|
| 2347 | 2347 | } |
| 2348 | 2348 | |
| 2349 | 2349 | /** |
@@ -2352,8 +2352,8 @@ discard block |
||
| 2352 | 2352 | * @since 1.0.19 |
| 2353 | 2353 | * @param string $value email address. |
| 2354 | 2354 | */ |
| 2355 | - public function set_user_email( $value ) { |
|
| 2356 | - $this->set_email( $value ); |
|
| 2355 | + public function set_user_email($value) { |
|
| 2356 | + $this->set_email($value); |
|
| 2357 | 2357 | } |
| 2358 | 2358 | |
| 2359 | 2359 | /** |
@@ -2362,8 +2362,8 @@ discard block |
||
| 2362 | 2362 | * @since 1.0.19 |
| 2363 | 2363 | * @param string $value email address. |
| 2364 | 2364 | */ |
| 2365 | - public function set_email_address( $value ) { |
|
| 2366 | - $this->set_email( $value ); |
|
| 2365 | + public function set_email_address($value) { |
|
| 2366 | + $this->set_email($value); |
|
| 2367 | 2367 | } |
| 2368 | 2368 | |
| 2369 | 2369 | /** |
@@ -2372,8 +2372,8 @@ discard block |
||
| 2372 | 2372 | * @since 1.0.19 |
| 2373 | 2373 | * @param string $value email address. |
| 2374 | 2374 | */ |
| 2375 | - public function set_customer_email( $value ) { |
|
| 2376 | - $this->set_email( $value ); |
|
| 2375 | + public function set_customer_email($value) { |
|
| 2376 | + $this->set_email($value); |
|
| 2377 | 2377 | } |
| 2378 | 2378 | |
| 2379 | 2379 | /** |
@@ -2382,8 +2382,8 @@ discard block |
||
| 2382 | 2382 | * @since 1.0.19 |
| 2383 | 2383 | * @param string $value country. |
| 2384 | 2384 | */ |
| 2385 | - public function set_country( $value ) { |
|
| 2386 | - $this->set_prop( 'country', $value ); |
|
| 2385 | + public function set_country($value) { |
|
| 2386 | + $this->set_prop('country', $value); |
|
| 2387 | 2387 | } |
| 2388 | 2388 | |
| 2389 | 2389 | /** |
@@ -2392,8 +2392,8 @@ discard block |
||
| 2392 | 2392 | * @since 1.0.19 |
| 2393 | 2393 | * @param string $value country. |
| 2394 | 2394 | */ |
| 2395 | - public function set_user_country( $value ) { |
|
| 2396 | - $this->set_country( $value ); |
|
| 2395 | + public function set_user_country($value) { |
|
| 2396 | + $this->set_country($value); |
|
| 2397 | 2397 | } |
| 2398 | 2398 | |
| 2399 | 2399 | /** |
@@ -2402,8 +2402,8 @@ discard block |
||
| 2402 | 2402 | * @since 1.0.19 |
| 2403 | 2403 | * @param string $value country. |
| 2404 | 2404 | */ |
| 2405 | - public function set_customer_country( $value ) { |
|
| 2406 | - $this->set_country( $value ); |
|
| 2405 | + public function set_customer_country($value) { |
|
| 2406 | + $this->set_country($value); |
|
| 2407 | 2407 | } |
| 2408 | 2408 | |
| 2409 | 2409 | /** |
@@ -2412,8 +2412,8 @@ discard block |
||
| 2412 | 2412 | * @since 1.0.19 |
| 2413 | 2413 | * @param string $value state. |
| 2414 | 2414 | */ |
| 2415 | - public function set_state( $value ) { |
|
| 2416 | - $this->set_prop( 'state', $value ); |
|
| 2415 | + public function set_state($value) { |
|
| 2416 | + $this->set_prop('state', $value); |
|
| 2417 | 2417 | } |
| 2418 | 2418 | |
| 2419 | 2419 | /** |
@@ -2422,8 +2422,8 @@ discard block |
||
| 2422 | 2422 | * @since 1.0.19 |
| 2423 | 2423 | * @param string $value state. |
| 2424 | 2424 | */ |
| 2425 | - public function set_user_state( $value ) { |
|
| 2426 | - $this->set_state( $value ); |
|
| 2425 | + public function set_user_state($value) { |
|
| 2426 | + $this->set_state($value); |
|
| 2427 | 2427 | } |
| 2428 | 2428 | |
| 2429 | 2429 | /** |
@@ -2432,8 +2432,8 @@ discard block |
||
| 2432 | 2432 | * @since 1.0.19 |
| 2433 | 2433 | * @param string $value state. |
| 2434 | 2434 | */ |
| 2435 | - public function set_customer_state( $value ) { |
|
| 2436 | - $this->set_state( $value ); |
|
| 2435 | + public function set_customer_state($value) { |
|
| 2436 | + $this->set_state($value); |
|
| 2437 | 2437 | } |
| 2438 | 2438 | |
| 2439 | 2439 | /** |
@@ -2442,8 +2442,8 @@ discard block |
||
| 2442 | 2442 | * @since 1.0.19 |
| 2443 | 2443 | * @param string $value city. |
| 2444 | 2444 | */ |
| 2445 | - public function set_city( $value ) { |
|
| 2446 | - $this->set_prop( 'city', $value ); |
|
| 2445 | + public function set_city($value) { |
|
| 2446 | + $this->set_prop('city', $value); |
|
| 2447 | 2447 | } |
| 2448 | 2448 | |
| 2449 | 2449 | /** |
@@ -2452,8 +2452,8 @@ discard block |
||
| 2452 | 2452 | * @since 1.0.19 |
| 2453 | 2453 | * @param string $value city. |
| 2454 | 2454 | */ |
| 2455 | - public function set_user_city( $value ) { |
|
| 2456 | - $this->set_city( $value ); |
|
| 2455 | + public function set_user_city($value) { |
|
| 2456 | + $this->set_city($value); |
|
| 2457 | 2457 | } |
| 2458 | 2458 | |
| 2459 | 2459 | /** |
@@ -2462,8 +2462,8 @@ discard block |
||
| 2462 | 2462 | * @since 1.0.19 |
| 2463 | 2463 | * @param string $value city. |
| 2464 | 2464 | */ |
| 2465 | - public function set_customer_city( $value ) { |
|
| 2466 | - $this->set_city( $value ); |
|
| 2465 | + public function set_customer_city($value) { |
|
| 2466 | + $this->set_city($value); |
|
| 2467 | 2467 | } |
| 2468 | 2468 | |
| 2469 | 2469 | /** |
@@ -2472,8 +2472,8 @@ discard block |
||
| 2472 | 2472 | * @since 1.0.19 |
| 2473 | 2473 | * @param string $value zip. |
| 2474 | 2474 | */ |
| 2475 | - public function set_zip( $value ) { |
|
| 2476 | - $this->set_prop( 'zip', $value ); |
|
| 2475 | + public function set_zip($value) { |
|
| 2476 | + $this->set_prop('zip', $value); |
|
| 2477 | 2477 | } |
| 2478 | 2478 | |
| 2479 | 2479 | /** |
@@ -2482,8 +2482,8 @@ discard block |
||
| 2482 | 2482 | * @since 1.0.19 |
| 2483 | 2483 | * @param string $value zip. |
| 2484 | 2484 | */ |
| 2485 | - public function set_user_zip( $value ) { |
|
| 2486 | - $this->set_zip( $value ); |
|
| 2485 | + public function set_user_zip($value) { |
|
| 2486 | + $this->set_zip($value); |
|
| 2487 | 2487 | } |
| 2488 | 2488 | |
| 2489 | 2489 | /** |
@@ -2492,8 +2492,8 @@ discard block |
||
| 2492 | 2492 | * @since 1.0.19 |
| 2493 | 2493 | * @param string $value zip. |
| 2494 | 2494 | */ |
| 2495 | - public function set_customer_zip( $value ) { |
|
| 2496 | - $this->set_zip( $value ); |
|
| 2495 | + public function set_customer_zip($value) { |
|
| 2496 | + $this->set_zip($value); |
|
| 2497 | 2497 | } |
| 2498 | 2498 | |
| 2499 | 2499 | /** |
@@ -2502,8 +2502,8 @@ discard block |
||
| 2502 | 2502 | * @since 1.0.19 |
| 2503 | 2503 | * @param string $value company. |
| 2504 | 2504 | */ |
| 2505 | - public function set_company( $value ) { |
|
| 2506 | - $this->set_prop( 'company', $value ); |
|
| 2505 | + public function set_company($value) { |
|
| 2506 | + $this->set_prop('company', $value); |
|
| 2507 | 2507 | } |
| 2508 | 2508 | |
| 2509 | 2509 | /** |
@@ -2512,8 +2512,8 @@ discard block |
||
| 2512 | 2512 | * @since 1.0.19 |
| 2513 | 2513 | * @param string $value company. |
| 2514 | 2514 | */ |
| 2515 | - public function set_user_company( $value ) { |
|
| 2516 | - $this->set_company( $value ); |
|
| 2515 | + public function set_user_company($value) { |
|
| 2516 | + $this->set_company($value); |
|
| 2517 | 2517 | } |
| 2518 | 2518 | |
| 2519 | 2519 | /** |
@@ -2522,8 +2522,8 @@ discard block |
||
| 2522 | 2522 | * @since 1.0.19 |
| 2523 | 2523 | * @param string $value company. |
| 2524 | 2524 | */ |
| 2525 | - public function set_customer_company( $value ) { |
|
| 2526 | - $this->set_company( $value ); |
|
| 2525 | + public function set_customer_company($value) { |
|
| 2526 | + $this->set_company($value); |
|
| 2527 | 2527 | } |
| 2528 | 2528 | |
| 2529 | 2529 | /** |
@@ -2532,8 +2532,8 @@ discard block |
||
| 2532 | 2532 | * @since 1.0.19 |
| 2533 | 2533 | * @param string $value var number. |
| 2534 | 2534 | */ |
| 2535 | - public function set_vat_number( $value ) { |
|
| 2536 | - $this->set_prop( 'vat_number', $value ); |
|
| 2535 | + public function set_vat_number($value) { |
|
| 2536 | + $this->set_prop('vat_number', $value); |
|
| 2537 | 2537 | } |
| 2538 | 2538 | |
| 2539 | 2539 | /** |
@@ -2542,8 +2542,8 @@ discard block |
||
| 2542 | 2542 | * @since 1.0.19 |
| 2543 | 2543 | * @param string $value var number. |
| 2544 | 2544 | */ |
| 2545 | - public function set_user_vat_number( $value ) { |
|
| 2546 | - $this->set_vat_number( $value ); |
|
| 2545 | + public function set_user_vat_number($value) { |
|
| 2546 | + $this->set_vat_number($value); |
|
| 2547 | 2547 | } |
| 2548 | 2548 | |
| 2549 | 2549 | /** |
@@ -2552,8 +2552,8 @@ discard block |
||
| 2552 | 2552 | * @since 1.0.19 |
| 2553 | 2553 | * @param string $value var number. |
| 2554 | 2554 | */ |
| 2555 | - public function set_customer_vat_number( $value ) { |
|
| 2556 | - $this->set_vat_number( $value ); |
|
| 2555 | + public function set_customer_vat_number($value) { |
|
| 2556 | + $this->set_vat_number($value); |
|
| 2557 | 2557 | } |
| 2558 | 2558 | |
| 2559 | 2559 | /** |
@@ -2562,8 +2562,8 @@ discard block |
||
| 2562 | 2562 | * @since 1.0.19 |
| 2563 | 2563 | * @param string $value var rate. |
| 2564 | 2564 | */ |
| 2565 | - public function set_vat_rate( $value ) { |
|
| 2566 | - $this->set_prop( 'vat_rate', $value ); |
|
| 2565 | + public function set_vat_rate($value) { |
|
| 2566 | + $this->set_prop('vat_rate', $value); |
|
| 2567 | 2567 | } |
| 2568 | 2568 | |
| 2569 | 2569 | /** |
@@ -2572,8 +2572,8 @@ discard block |
||
| 2572 | 2572 | * @since 1.0.19 |
| 2573 | 2573 | * @param string $value var number. |
| 2574 | 2574 | */ |
| 2575 | - public function set_user_vat_rate( $value ) { |
|
| 2576 | - $this->set_vat_rate( $value ); |
|
| 2575 | + public function set_user_vat_rate($value) { |
|
| 2576 | + $this->set_vat_rate($value); |
|
| 2577 | 2577 | } |
| 2578 | 2578 | |
| 2579 | 2579 | /** |
@@ -2582,8 +2582,8 @@ discard block |
||
| 2582 | 2582 | * @since 1.0.19 |
| 2583 | 2583 | * @param string $value var number. |
| 2584 | 2584 | */ |
| 2585 | - public function set_customer_vat_rate( $value ) { |
|
| 2586 | - $this->set_vat_rate( $value ); |
|
| 2585 | + public function set_customer_vat_rate($value) { |
|
| 2586 | + $this->set_vat_rate($value); |
|
| 2587 | 2587 | } |
| 2588 | 2588 | |
| 2589 | 2589 | /** |
@@ -2592,8 +2592,8 @@ discard block |
||
| 2592 | 2592 | * @since 1.0.19 |
| 2593 | 2593 | * @param string $value address. |
| 2594 | 2594 | */ |
| 2595 | - public function set_address( $value ) { |
|
| 2596 | - $this->set_prop( 'address', $value ); |
|
| 2595 | + public function set_address($value) { |
|
| 2596 | + $this->set_prop('address', $value); |
|
| 2597 | 2597 | } |
| 2598 | 2598 | |
| 2599 | 2599 | /** |
@@ -2602,8 +2602,8 @@ discard block |
||
| 2602 | 2602 | * @since 1.0.19 |
| 2603 | 2603 | * @param string $value address. |
| 2604 | 2604 | */ |
| 2605 | - public function set_user_address( $value ) { |
|
| 2606 | - $this->set_address( $value ); |
|
| 2605 | + public function set_user_address($value) { |
|
| 2606 | + $this->set_address($value); |
|
| 2607 | 2607 | } |
| 2608 | 2608 | |
| 2609 | 2609 | /** |
@@ -2612,8 +2612,8 @@ discard block |
||
| 2612 | 2612 | * @since 1.0.19 |
| 2613 | 2613 | * @param string $value address. |
| 2614 | 2614 | */ |
| 2615 | - public function set_customer_address( $value ) { |
|
| 2616 | - $this->set_address( $value ); |
|
| 2615 | + public function set_customer_address($value) { |
|
| 2616 | + $this->set_address($value); |
|
| 2617 | 2617 | } |
| 2618 | 2618 | |
| 2619 | 2619 | /** |
@@ -2622,8 +2622,8 @@ discard block |
||
| 2622 | 2622 | * @since 1.0.19 |
| 2623 | 2623 | * @param int|bool $value confirmed. |
| 2624 | 2624 | */ |
| 2625 | - public function set_is_viewed( $value ) { |
|
| 2626 | - $this->set_prop( 'is_viewed', $value ); |
|
| 2625 | + public function set_is_viewed($value) { |
|
| 2626 | + $this->set_prop('is_viewed', $value); |
|
| 2627 | 2627 | } |
| 2628 | 2628 | |
| 2629 | 2629 | /** |
@@ -2632,8 +2632,8 @@ discard block |
||
| 2632 | 2632 | * @since 1.0.19 |
| 2633 | 2633 | * @param string $value email recipients. |
| 2634 | 2634 | */ |
| 2635 | - public function set_email_cc( $value ) { |
|
| 2636 | - $this->set_prop( 'email_cc', $value ); |
|
| 2635 | + public function set_email_cc($value) { |
|
| 2636 | + $this->set_prop('email_cc', $value); |
|
| 2637 | 2637 | } |
| 2638 | 2638 | |
| 2639 | 2639 | /** |
@@ -2642,9 +2642,9 @@ discard block |
||
| 2642 | 2642 | * @since 1.0.19 |
| 2643 | 2643 | * @param string $value template. |
| 2644 | 2644 | */ |
| 2645 | - public function set_template( $value ) { |
|
| 2646 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2647 | - $this->set_prop( 'template', $value ); |
|
| 2645 | + public function set_template($value) { |
|
| 2646 | + if (in_array($value, array('quantity', 'hours', 'amount'))) { |
|
| 2647 | + $this->set_prop('template', $value); |
|
| 2648 | 2648 | } |
| 2649 | 2649 | } |
| 2650 | 2650 | |
@@ -2654,8 +2654,8 @@ discard block |
||
| 2654 | 2654 | * @since 1.0.19 |
| 2655 | 2655 | * @param string $value email recipients. |
| 2656 | 2656 | */ |
| 2657 | - public function created_via( $value ) { |
|
| 2658 | - $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
| 2657 | + public function created_via($value) { |
|
| 2658 | + $this->set_prop('created_via', sanitize_text_field($value)); |
|
| 2659 | 2659 | } |
| 2660 | 2660 | |
| 2661 | 2661 | /** |
@@ -2664,8 +2664,8 @@ discard block |
||
| 2664 | 2664 | * @since 1.0.19 |
| 2665 | 2665 | * @param int|bool $value confirmed. |
| 2666 | 2666 | */ |
| 2667 | - public function set_address_confirmed( $value ) { |
|
| 2668 | - $this->set_prop( 'address_confirmed', $value ); |
|
| 2667 | + public function set_address_confirmed($value) { |
|
| 2668 | + $this->set_prop('address_confirmed', $value); |
|
| 2669 | 2669 | } |
| 2670 | 2670 | |
| 2671 | 2671 | /** |
@@ -2674,8 +2674,8 @@ discard block |
||
| 2674 | 2674 | * @since 1.0.19 |
| 2675 | 2675 | * @param int|bool $value confirmed. |
| 2676 | 2676 | */ |
| 2677 | - public function set_user_address_confirmed( $value ) { |
|
| 2678 | - $this->set_address_confirmed( $value ); |
|
| 2677 | + public function set_user_address_confirmed($value) { |
|
| 2678 | + $this->set_address_confirmed($value); |
|
| 2679 | 2679 | } |
| 2680 | 2680 | |
| 2681 | 2681 | /** |
@@ -2684,8 +2684,8 @@ discard block |
||
| 2684 | 2684 | * @since 1.0.19 |
| 2685 | 2685 | * @param int|bool $value confirmed. |
| 2686 | 2686 | */ |
| 2687 | - public function set_customer_address_confirmed( $value ) { |
|
| 2688 | - $this->set_address_confirmed( $value ); |
|
| 2687 | + public function set_customer_address_confirmed($value) { |
|
| 2688 | + $this->set_address_confirmed($value); |
|
| 2689 | 2689 | } |
| 2690 | 2690 | |
| 2691 | 2691 | /** |
@@ -2694,8 +2694,8 @@ discard block |
||
| 2694 | 2694 | * @since 1.0.19 |
| 2695 | 2695 | * @param float $value sub total. |
| 2696 | 2696 | */ |
| 2697 | - public function set_subtotal( $value ) { |
|
| 2698 | - $this->set_prop( 'subtotal', $value ); |
|
| 2697 | + public function set_subtotal($value) { |
|
| 2698 | + $this->set_prop('subtotal', $value); |
|
| 2699 | 2699 | } |
| 2700 | 2700 | |
| 2701 | 2701 | /** |
@@ -2704,8 +2704,8 @@ discard block |
||
| 2704 | 2704 | * @since 1.0.19 |
| 2705 | 2705 | * @param float $value discount total. |
| 2706 | 2706 | */ |
| 2707 | - public function set_total_discount( $value ) { |
|
| 2708 | - $this->set_prop( 'total_discount', $value ); |
|
| 2707 | + public function set_total_discount($value) { |
|
| 2708 | + $this->set_prop('total_discount', $value); |
|
| 2709 | 2709 | } |
| 2710 | 2710 | |
| 2711 | 2711 | /** |
@@ -2714,8 +2714,8 @@ discard block |
||
| 2714 | 2714 | * @since 1.0.19 |
| 2715 | 2715 | * @param float $value discount total. |
| 2716 | 2716 | */ |
| 2717 | - public function set_discount( $value ) { |
|
| 2718 | - $this->set_total_discount( $value ); |
|
| 2717 | + public function set_discount($value) { |
|
| 2718 | + $this->set_total_discount($value); |
|
| 2719 | 2719 | } |
| 2720 | 2720 | |
| 2721 | 2721 | /** |
@@ -2724,8 +2724,8 @@ discard block |
||
| 2724 | 2724 | * @since 1.0.19 |
| 2725 | 2725 | * @param float $value tax total. |
| 2726 | 2726 | */ |
| 2727 | - public function set_total_tax( $value ) { |
|
| 2728 | - $this->set_prop( 'total_tax', $value ); |
|
| 2727 | + public function set_total_tax($value) { |
|
| 2728 | + $this->set_prop('total_tax', $value); |
|
| 2729 | 2729 | } |
| 2730 | 2730 | |
| 2731 | 2731 | /** |
@@ -2734,8 +2734,8 @@ discard block |
||
| 2734 | 2734 | * @since 1.0.19 |
| 2735 | 2735 | * @param float $value tax total. |
| 2736 | 2736 | */ |
| 2737 | - public function set_tax_total( $value ) { |
|
| 2738 | - $this->set_total_tax( $value ); |
|
| 2737 | + public function set_tax_total($value) { |
|
| 2738 | + $this->set_total_tax($value); |
|
| 2739 | 2739 | } |
| 2740 | 2740 | |
| 2741 | 2741 | /** |
@@ -2744,8 +2744,8 @@ discard block |
||
| 2744 | 2744 | * @since 1.0.19 |
| 2745 | 2745 | * @param float $value fees total. |
| 2746 | 2746 | */ |
| 2747 | - public function set_total_fees( $value ) { |
|
| 2748 | - $this->set_prop( 'total_fees', $value ); |
|
| 2747 | + public function set_total_fees($value) { |
|
| 2748 | + $this->set_prop('total_fees', $value); |
|
| 2749 | 2749 | } |
| 2750 | 2750 | |
| 2751 | 2751 | /** |
@@ -2754,8 +2754,8 @@ discard block |
||
| 2754 | 2754 | * @since 1.0.19 |
| 2755 | 2755 | * @param float $value fees total. |
| 2756 | 2756 | */ |
| 2757 | - public function set_fees_total( $value ) { |
|
| 2758 | - $this->set_total_fees( $value ); |
|
| 2757 | + public function set_fees_total($value) { |
|
| 2758 | + $this->set_total_fees($value); |
|
| 2759 | 2759 | } |
| 2760 | 2760 | |
| 2761 | 2761 | /** |
@@ -2764,13 +2764,13 @@ discard block |
||
| 2764 | 2764 | * @since 1.0.19 |
| 2765 | 2765 | * @param array $value fees. |
| 2766 | 2766 | */ |
| 2767 | - public function set_fees( $value ) { |
|
| 2767 | + public function set_fees($value) { |
|
| 2768 | 2768 | |
| 2769 | - if ( ! is_array( $value ) ) { |
|
| 2769 | + if (!is_array($value)) { |
|
| 2770 | 2770 | $value = array(); |
| 2771 | 2771 | } |
| 2772 | 2772 | |
| 2773 | - $this->set_prop( 'fees', $value ); |
|
| 2773 | + $this->set_prop('fees', $value); |
|
| 2774 | 2774 | |
| 2775 | 2775 | } |
| 2776 | 2776 | |
@@ -2780,13 +2780,13 @@ discard block |
||
| 2780 | 2780 | * @since 1.0.19 |
| 2781 | 2781 | * @param array $value taxes. |
| 2782 | 2782 | */ |
| 2783 | - public function set_taxes( $value ) { |
|
| 2783 | + public function set_taxes($value) { |
|
| 2784 | 2784 | |
| 2785 | - if ( ! is_array( $value ) ) { |
|
| 2785 | + if (!is_array($value)) { |
|
| 2786 | 2786 | $value = array(); |
| 2787 | 2787 | } |
| 2788 | 2788 | |
| 2789 | - $this->set_prop( 'taxes', $value ); |
|
| 2789 | + $this->set_prop('taxes', $value); |
|
| 2790 | 2790 | |
| 2791 | 2791 | } |
| 2792 | 2792 | |
@@ -2796,13 +2796,13 @@ discard block |
||
| 2796 | 2796 | * @since 1.0.19 |
| 2797 | 2797 | * @param array $value discounts. |
| 2798 | 2798 | */ |
| 2799 | - public function set_discounts( $value ) { |
|
| 2799 | + public function set_discounts($value) { |
|
| 2800 | 2800 | |
| 2801 | - if ( ! is_array( $value ) ) { |
|
| 2801 | + if (!is_array($value)) { |
|
| 2802 | 2802 | $value = array(); |
| 2803 | 2803 | } |
| 2804 | 2804 | |
| 2805 | - $this->set_prop( 'discounts', $value ); |
|
| 2805 | + $this->set_prop('discounts', $value); |
|
| 2806 | 2806 | } |
| 2807 | 2807 | |
| 2808 | 2808 | /** |
@@ -2811,18 +2811,18 @@ discard block |
||
| 2811 | 2811 | * @since 1.0.19 |
| 2812 | 2812 | * @param GetPaid_Form_Item[] $value items. |
| 2813 | 2813 | */ |
| 2814 | - public function set_items( $value ) { |
|
| 2814 | + public function set_items($value) { |
|
| 2815 | 2815 | |
| 2816 | 2816 | // Remove existing items. |
| 2817 | - $this->set_prop( 'items', array() ); |
|
| 2817 | + $this->set_prop('items', array()); |
|
| 2818 | 2818 | |
| 2819 | 2819 | // Ensure that we have an array. |
| 2820 | - if ( ! is_array( $value ) ) { |
|
| 2820 | + if (!is_array($value)) { |
|
| 2821 | 2821 | return; |
| 2822 | 2822 | } |
| 2823 | 2823 | |
| 2824 | - foreach ( $value as $item ) { |
|
| 2825 | - $this->add_item( $item ); |
|
| 2824 | + foreach ($value as $item) { |
|
| 2825 | + $this->add_item($item); |
|
| 2826 | 2826 | } |
| 2827 | 2827 | |
| 2828 | 2828 | } |
@@ -2833,8 +2833,8 @@ discard block |
||
| 2833 | 2833 | * @since 1.0.19 |
| 2834 | 2834 | * @param int $value payment form. |
| 2835 | 2835 | */ |
| 2836 | - public function set_payment_form( $value ) { |
|
| 2837 | - $this->set_prop( 'payment_form', $value ); |
|
| 2836 | + public function set_payment_form($value) { |
|
| 2837 | + $this->set_prop('payment_form', $value); |
|
| 2838 | 2838 | } |
| 2839 | 2839 | |
| 2840 | 2840 | /** |
@@ -2843,8 +2843,8 @@ discard block |
||
| 2843 | 2843 | * @since 1.0.19 |
| 2844 | 2844 | * @param string $value submission id. |
| 2845 | 2845 | */ |
| 2846 | - public function set_submission_id( $value ) { |
|
| 2847 | - $this->set_prop( 'submission_id', $value ); |
|
| 2846 | + public function set_submission_id($value) { |
|
| 2847 | + $this->set_prop('submission_id', $value); |
|
| 2848 | 2848 | } |
| 2849 | 2849 | |
| 2850 | 2850 | /** |
@@ -2853,8 +2853,8 @@ discard block |
||
| 2853 | 2853 | * @since 1.0.19 |
| 2854 | 2854 | * @param string $value discount code. |
| 2855 | 2855 | */ |
| 2856 | - public function set_discount_code( $value ) { |
|
| 2857 | - $this->set_prop( 'discount_code', $value ); |
|
| 2856 | + public function set_discount_code($value) { |
|
| 2857 | + $this->set_prop('discount_code', $value); |
|
| 2858 | 2858 | } |
| 2859 | 2859 | |
| 2860 | 2860 | /** |
@@ -2863,8 +2863,8 @@ discard block |
||
| 2863 | 2863 | * @since 1.0.19 |
| 2864 | 2864 | * @param string $value gateway. |
| 2865 | 2865 | */ |
| 2866 | - public function set_gateway( $value ) { |
|
| 2867 | - $this->set_prop( 'gateway', $value ); |
|
| 2866 | + public function set_gateway($value) { |
|
| 2867 | + $this->set_prop('gateway', $value); |
|
| 2868 | 2868 | } |
| 2869 | 2869 | |
| 2870 | 2870 | /** |
@@ -2873,9 +2873,9 @@ discard block |
||
| 2873 | 2873 | * @since 1.0.19 |
| 2874 | 2874 | * @param string $value transaction id. |
| 2875 | 2875 | */ |
| 2876 | - public function set_transaction_id( $value ) { |
|
| 2877 | - if ( ! empty( $value ) ) { |
|
| 2878 | - $this->set_prop( 'transaction_id', $value ); |
|
| 2876 | + public function set_transaction_id($value) { |
|
| 2877 | + if (!empty($value)) { |
|
| 2878 | + $this->set_prop('transaction_id', $value); |
|
| 2879 | 2879 | } |
| 2880 | 2880 | } |
| 2881 | 2881 | |
@@ -2885,8 +2885,8 @@ discard block |
||
| 2885 | 2885 | * @since 1.0.19 |
| 2886 | 2886 | * @param string $value currency id. |
| 2887 | 2887 | */ |
| 2888 | - public function set_currency( $value ) { |
|
| 2889 | - $this->set_prop( 'currency', $value ); |
|
| 2888 | + public function set_currency($value) { |
|
| 2889 | + $this->set_prop('currency', $value); |
|
| 2890 | 2890 | } |
| 2891 | 2891 | |
| 2892 | 2892 | /** |
@@ -2895,8 +2895,8 @@ discard block |
||
| 2895 | 2895 | * @since 1.0.19 |
| 2896 | 2896 | * @param bool $value value. |
| 2897 | 2897 | */ |
| 2898 | - public function set_disable_taxes( $value ) { |
|
| 2899 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2898 | + public function set_disable_taxes($value) { |
|
| 2899 | + $this->set_prop('disable_taxes', (bool) $value); |
|
| 2900 | 2900 | } |
| 2901 | 2901 | |
| 2902 | 2902 | /** |
@@ -2905,8 +2905,8 @@ discard block |
||
| 2905 | 2905 | * @since 1.0.19 |
| 2906 | 2906 | * @param string $value subscription id. |
| 2907 | 2907 | */ |
| 2908 | - public function set_subscription_id( $value ) { |
|
| 2909 | - $this->set_prop( 'subscription_id', $value ); |
|
| 2908 | + public function set_subscription_id($value) { |
|
| 2909 | + $this->set_prop('subscription_id', $value); |
|
| 2910 | 2910 | } |
| 2911 | 2911 | |
| 2912 | 2912 | /** |
@@ -2915,8 +2915,8 @@ discard block |
||
| 2915 | 2915 | * @since 1.0.19 |
| 2916 | 2916 | * @param string $value subscription id. |
| 2917 | 2917 | */ |
| 2918 | - public function set_remote_subscription_id( $value ) { |
|
| 2919 | - $this->set_prop( 'remote_subscription_id', $value ); |
|
| 2918 | + public function set_remote_subscription_id($value) { |
|
| 2919 | + $this->set_prop('remote_subscription_id', $value); |
|
| 2920 | 2920 | } |
| 2921 | 2921 | |
| 2922 | 2922 | /* |
@@ -2933,28 +2933,28 @@ discard block |
||
| 2933 | 2933 | */ |
| 2934 | 2934 | public function is_parent() { |
| 2935 | 2935 | $parent = $this->get_parent_id(); |
| 2936 | - return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this ); |
|
| 2936 | + return apply_filters('wpinv_invoice_is_parent', empty($parent), $this); |
|
| 2937 | 2937 | } |
| 2938 | 2938 | |
| 2939 | 2939 | /** |
| 2940 | 2940 | * Checks if this is a renewal invoice. |
| 2941 | 2941 | */ |
| 2942 | 2942 | public function is_renewal() { |
| 2943 | - return ! $this->is_parent(); |
|
| 2943 | + return !$this->is_parent(); |
|
| 2944 | 2944 | } |
| 2945 | 2945 | |
| 2946 | 2946 | /** |
| 2947 | 2947 | * Checks if this is a recurring invoice. |
| 2948 | 2948 | */ |
| 2949 | 2949 | public function is_recurring() { |
| 2950 | - return $this->is_renewal() || ! empty( $this->recurring_item ); |
|
| 2950 | + return $this->is_renewal() || !empty($this->recurring_item); |
|
| 2951 | 2951 | } |
| 2952 | 2952 | |
| 2953 | 2953 | /** |
| 2954 | 2954 | * Checks if this is a taxable invoice. |
| 2955 | 2955 | */ |
| 2956 | 2956 | public function is_taxable() { |
| 2957 | - return ! $this->get_disable_taxes(); |
|
| 2957 | + return !$this->get_disable_taxes(); |
|
| 2958 | 2958 | } |
| 2959 | 2959 | |
| 2960 | 2960 | /** |
@@ -2965,57 +2965,57 @@ discard block |
||
| 2965 | 2965 | |
| 2966 | 2966 | $requires_vat = false; |
| 2967 | 2967 | |
| 2968 | - if ( $this->country ) { |
|
| 2968 | + if ($this->country) { |
|
| 2969 | 2969 | $wpi_country = $this->country; |
| 2970 | - $requires_vat = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) ); |
|
| 2970 | + $requires_vat = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this)); |
|
| 2971 | 2971 | } |
| 2972 | 2972 | |
| 2973 | - return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this ); |
|
| 2973 | + return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this); |
|
| 2974 | 2974 | } |
| 2975 | 2975 | |
| 2976 | 2976 | /** |
| 2977 | 2977 | * Checks to see if the invoice requires payment. |
| 2978 | 2978 | */ |
| 2979 | 2979 | public function is_free() { |
| 2980 | - $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
|
| 2980 | + $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0); |
|
| 2981 | 2981 | |
| 2982 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 2982 | + if ($this->is_recurring() && $this->get_recurring_total() > 0) { |
|
| 2983 | 2983 | $is_free = false; |
| 2984 | 2984 | } |
| 2985 | 2985 | |
| 2986 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
| 2986 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
| 2987 | 2987 | } |
| 2988 | 2988 | |
| 2989 | 2989 | /** |
| 2990 | 2990 | * Checks if the invoice is paid. |
| 2991 | 2991 | */ |
| 2992 | 2992 | public function is_paid() { |
| 2993 | - $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
|
| 2994 | - return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
|
| 2993 | + $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal')); |
|
| 2994 | + return apply_filters('wpinv_invoice_is_paid', $is_paid, $this); |
|
| 2995 | 2995 | } |
| 2996 | 2996 | |
| 2997 | 2997 | /** |
| 2998 | 2998 | * Checks if the invoice needs payment. |
| 2999 | 2999 | */ |
| 3000 | 3000 | public function needs_payment() { |
| 3001 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 3002 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
|
| 3001 | + $needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free(); |
|
| 3002 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this); |
|
| 3003 | 3003 | } |
| 3004 | 3004 | |
| 3005 | 3005 | /** |
| 3006 | 3006 | * Checks if the invoice is refunded. |
| 3007 | 3007 | */ |
| 3008 | 3008 | public function is_refunded() { |
| 3009 | - $is_refunded = $this->has_status( 'wpi-refunded' ); |
|
| 3010 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
| 3009 | + $is_refunded = $this->has_status('wpi-refunded'); |
|
| 3010 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
| 3011 | 3011 | } |
| 3012 | 3012 | |
| 3013 | 3013 | /** |
| 3014 | 3014 | * Checks if the invoice is held. |
| 3015 | 3015 | */ |
| 3016 | 3016 | public function is_held() { |
| 3017 | - $is_held = $this->has_status( 'wpi-onhold' ); |
|
| 3018 | - return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
|
| 3017 | + $is_held = $this->has_status('wpi-onhold'); |
|
| 3018 | + return apply_filters('wpinv_invoice_is_held', $is_held, $this); |
|
| 3019 | 3019 | } |
| 3020 | 3020 | |
| 3021 | 3021 | /** |
@@ -3023,30 +3023,30 @@ discard block |
||
| 3023 | 3023 | */ |
| 3024 | 3024 | public function is_due() { |
| 3025 | 3025 | $due_date = $this->get_due_date(); |
| 3026 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 3026 | + return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date); |
|
| 3027 | 3027 | } |
| 3028 | 3028 | |
| 3029 | 3029 | /** |
| 3030 | 3030 | * Checks if the invoice is draft. |
| 3031 | 3031 | */ |
| 3032 | 3032 | public function is_draft() { |
| 3033 | - return $this->has_status( 'draft, auto-draft' ); |
|
| 3033 | + return $this->has_status('draft, auto-draft'); |
|
| 3034 | 3034 | } |
| 3035 | 3035 | |
| 3036 | 3036 | /** |
| 3037 | 3037 | * Checks if the invoice has a given status. |
| 3038 | 3038 | */ |
| 3039 | - public function has_status( $status ) { |
|
| 3040 | - $status = wpinv_parse_list( $status ); |
|
| 3041 | - return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
|
| 3039 | + public function has_status($status) { |
|
| 3040 | + $status = wpinv_parse_list($status); |
|
| 3041 | + return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status); |
|
| 3042 | 3042 | } |
| 3043 | 3043 | |
| 3044 | 3044 | /** |
| 3045 | 3045 | * Checks if the invoice is of a given type. |
| 3046 | 3046 | */ |
| 3047 | - public function is_type( $type ) { |
|
| 3048 | - $type = wpinv_parse_list( $type ); |
|
| 3049 | - return in_array( $this->get_type(), $type ); |
|
| 3047 | + public function is_type($type) { |
|
| 3048 | + $type = wpinv_parse_list($type); |
|
| 3049 | + return in_array($this->get_type(), $type); |
|
| 3050 | 3050 | } |
| 3051 | 3051 | |
| 3052 | 3052 | /** |
@@ -3078,8 +3078,8 @@ discard block |
||
| 3078 | 3078 | * |
| 3079 | 3079 | */ |
| 3080 | 3080 | public function is_initial_free() { |
| 3081 | - $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
|
| 3082 | - return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
|
| 3081 | + $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0); |
|
| 3082 | + return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this); |
|
| 3083 | 3083 | } |
| 3084 | 3084 | |
| 3085 | 3085 | /** |
@@ -3089,11 +3089,11 @@ discard block |
||
| 3089 | 3089 | public function item_has_free_trial() { |
| 3090 | 3090 | |
| 3091 | 3091 | // Ensure we have a recurring item. |
| 3092 | - if ( ! $this->is_recurring() ) { |
|
| 3092 | + if (!$this->is_recurring()) { |
|
| 3093 | 3093 | return false; |
| 3094 | 3094 | } |
| 3095 | 3095 | |
| 3096 | - $item = $this->get_recurring( true ); |
|
| 3096 | + $item = $this->get_recurring(true); |
|
| 3097 | 3097 | return $item->has_free_trial(); |
| 3098 | 3098 | } |
| 3099 | 3099 | |
@@ -3101,7 +3101,7 @@ discard block |
||
| 3101 | 3101 | * Check if the free trial is a result of a discount. |
| 3102 | 3102 | */ |
| 3103 | 3103 | public function is_free_trial_from_discount() { |
| 3104 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3104 | + return $this->has_free_trial() && !$this->item_has_free_trial(); |
|
| 3105 | 3105 | } |
| 3106 | 3106 | |
| 3107 | 3107 | /** |
@@ -3110,17 +3110,17 @@ discard block |
||
| 3110 | 3110 | public function discount_first_payment_only() { |
| 3111 | 3111 | |
| 3112 | 3112 | $discount_code = $this->get_discount_code(); |
| 3113 | - if ( empty( $this->discount_code ) || ! $this->is_recurring() ) { |
|
| 3113 | + if (empty($this->discount_code) || !$this->is_recurring()) { |
|
| 3114 | 3114 | return true; |
| 3115 | 3115 | } |
| 3116 | 3116 | |
| 3117 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 3117 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 3118 | 3118 | |
| 3119 | - if ( ! $discount || ! $discount->exists() ) { |
|
| 3119 | + if (!$discount || !$discount->exists()) { |
|
| 3120 | 3120 | return true; |
| 3121 | 3121 | } |
| 3122 | 3122 | |
| 3123 | - return ! $discount->get_is_recurring(); |
|
| 3123 | + return !$discount->get_is_recurring(); |
|
| 3124 | 3124 | } |
| 3125 | 3125 | |
| 3126 | 3126 | /* |
@@ -3138,27 +3138,27 @@ discard block |
||
| 3138 | 3138 | * @param GetPaid_Form_Item|array $item |
| 3139 | 3139 | * @return WP_Error|Bool |
| 3140 | 3140 | */ |
| 3141 | - public function add_item( $item ) { |
|
| 3141 | + public function add_item($item) { |
|
| 3142 | 3142 | |
| 3143 | - if ( is_array( $item ) ) { |
|
| 3144 | - $item = $this->process_array_item( $item ); |
|
| 3143 | + if (is_array($item)) { |
|
| 3144 | + $item = $this->process_array_item($item); |
|
| 3145 | 3145 | } |
| 3146 | 3146 | |
| 3147 | - if ( is_numeric( $item ) ) { |
|
| 3148 | - $item = new GetPaid_Form_Item( $item ); |
|
| 3147 | + if (is_numeric($item)) { |
|
| 3148 | + $item = new GetPaid_Form_Item($item); |
|
| 3149 | 3149 | } |
| 3150 | 3150 | |
| 3151 | 3151 | // Make sure that it is available for purchase. |
| 3152 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3153 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3152 | + if ($item->get_id() > 0 && !$item->can_purchase()) { |
|
| 3153 | + return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing')); |
|
| 3154 | 3154 | } |
| 3155 | 3155 | |
| 3156 | 3156 | // Do we have a recurring item? |
| 3157 | - if ( $item->is_recurring() ) { |
|
| 3157 | + if ($item->is_recurring()) { |
|
| 3158 | 3158 | |
| 3159 | 3159 | // An invoice can only contain one recurring item. |
| 3160 | - if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
| 3161 | - return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
| 3160 | + if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) { |
|
| 3161 | + return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing')); |
|
| 3162 | 3162 | } |
| 3163 | 3163 | |
| 3164 | 3164 | $this->recurring_item = $item->get_id(); |
@@ -3169,9 +3169,9 @@ discard block |
||
| 3169 | 3169 | |
| 3170 | 3170 | // Retrieve all items. |
| 3171 | 3171 | $items = $this->get_items(); |
| 3172 | - $items[ (int) $item->get_id() ] = $item; |
|
| 3172 | + $items[(int) $item->get_id()] = $item; |
|
| 3173 | 3173 | |
| 3174 | - $this->set_prop( 'items', $items ); |
|
| 3174 | + $this->set_prop('items', $items); |
|
| 3175 | 3175 | return true; |
| 3176 | 3176 | } |
| 3177 | 3177 | |
@@ -3181,26 +3181,26 @@ discard block |
||
| 3181 | 3181 | * @since 1.0.19 |
| 3182 | 3182 | * @return GetPaid_Form_Item |
| 3183 | 3183 | */ |
| 3184 | - protected function process_array_item( $array ) { |
|
| 3184 | + protected function process_array_item($array) { |
|
| 3185 | 3185 | |
| 3186 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
| 3187 | - $item = new GetPaid_Form_Item( $item_id ); |
|
| 3186 | + $item_id = isset($array['item_id']) ? $array['item_id'] : 0; |
|
| 3187 | + $item = new GetPaid_Form_Item($item_id); |
|
| 3188 | 3188 | |
| 3189 | 3189 | // Set item data. |
| 3190 | - foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
| 3191 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
| 3190 | + foreach (array('name', 'price', 'description') as $key) { |
|
| 3191 | + if (isset($array["item_$key"])) { |
|
| 3192 | 3192 | $method = "set_$key"; |
| 3193 | - $item->$method( $array[ "item_$key" ] ); |
|
| 3193 | + $item->$method($array["item_$key"]); |
|
| 3194 | 3194 | } |
| 3195 | 3195 | } |
| 3196 | 3196 | |
| 3197 | - if ( isset( $array['quantity'] ) ) { |
|
| 3198 | - $item->set_quantity( $array['quantity'] ); |
|
| 3197 | + if (isset($array['quantity'])) { |
|
| 3198 | + $item->set_quantity($array['quantity']); |
|
| 3199 | 3199 | } |
| 3200 | 3200 | |
| 3201 | 3201 | // Set item meta. |
| 3202 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
| 3203 | - $item->set_item_meta( $array['meta'] ); |
|
| 3202 | + if (isset($array['meta']) && is_array($array['meta'])) { |
|
| 3203 | + $item->set_item_meta($array['meta']); |
|
| 3204 | 3204 | } |
| 3205 | 3205 | |
| 3206 | 3206 | return $item; |
@@ -3212,10 +3212,10 @@ discard block |
||
| 3212 | 3212 | * |
| 3213 | 3213 | * @since 1.0.19 |
| 3214 | 3214 | */ |
| 3215 | - public function get_item( $item_id ) { |
|
| 3215 | + public function get_item($item_id) { |
|
| 3216 | 3216 | $items = $this->get_items(); |
| 3217 | 3217 | $item_id = (int) $item_id; |
| 3218 | - return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
| 3218 | + return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null; |
|
| 3219 | 3219 | } |
| 3220 | 3220 | |
| 3221 | 3221 | /** |
@@ -3223,17 +3223,17 @@ discard block |
||
| 3223 | 3223 | * |
| 3224 | 3224 | * @since 1.0.19 |
| 3225 | 3225 | */ |
| 3226 | - public function remove_item( $item_id ) { |
|
| 3226 | + public function remove_item($item_id) { |
|
| 3227 | 3227 | $items = $this->get_items(); |
| 3228 | 3228 | $item_id = (int) $item_id; |
| 3229 | 3229 | |
| 3230 | - if ( $item_id == $this->recurring_item ) { |
|
| 3230 | + if ($item_id == $this->recurring_item) { |
|
| 3231 | 3231 | $this->recurring_item = null; |
| 3232 | 3232 | } |
| 3233 | 3233 | |
| 3234 | - if ( isset( $items[ $item_id ] ) ) { |
|
| 3235 | - unset( $items[ $item_id ] ); |
|
| 3236 | - $this->set_prop( 'items', $items ); |
|
| 3234 | + if (isset($items[$item_id])) { |
|
| 3235 | + unset($items[$item_id]); |
|
| 3236 | + $this->set_prop('items', $items); |
|
| 3237 | 3237 | } |
| 3238 | 3238 | } |
| 3239 | 3239 | |
@@ -3243,11 +3243,11 @@ discard block |
||
| 3243 | 3243 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
| 3244 | 3244 | * @since 1.0.19 |
| 3245 | 3245 | */ |
| 3246 | - public function add_fee( $fee ) { |
|
| 3246 | + public function add_fee($fee) { |
|
| 3247 | 3247 | |
| 3248 | 3248 | $fees = $this->get_fees(); |
| 3249 | - $fees[ $fee['name'] ] = $fee; |
|
| 3250 | - $this->set_prop( 'fees', $fees ); |
|
| 3249 | + $fees[$fee['name']] = $fee; |
|
| 3250 | + $this->set_prop('fees', $fees); |
|
| 3251 | 3251 | |
| 3252 | 3252 | } |
| 3253 | 3253 | |
@@ -3256,9 +3256,9 @@ discard block |
||
| 3256 | 3256 | * |
| 3257 | 3257 | * @since 1.0.19 |
| 3258 | 3258 | */ |
| 3259 | - public function get_fee( $fee ) { |
|
| 3259 | + public function get_fee($fee) { |
|
| 3260 | 3260 | $fees = $this->get_fees(); |
| 3261 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3261 | + return isset($fees[$fee]) ? $fees[$fee] : null; |
|
| 3262 | 3262 | } |
| 3263 | 3263 | |
| 3264 | 3264 | /** |
@@ -3266,11 +3266,11 @@ discard block |
||
| 3266 | 3266 | * |
| 3267 | 3267 | * @since 1.0.19 |
| 3268 | 3268 | */ |
| 3269 | - public function remove_fee( $fee ) { |
|
| 3269 | + public function remove_fee($fee) { |
|
| 3270 | 3270 | $fees = $this->get_fees(); |
| 3271 | - if ( isset( $fees[ $fee ] ) ) { |
|
| 3272 | - unset( $fees[ $fee ] ); |
|
| 3273 | - $this->set_prop( 'fees', $fees ); |
|
| 3271 | + if (isset($fees[$fee])) { |
|
| 3272 | + unset($fees[$fee]); |
|
| 3273 | + $this->set_prop('fees', $fees); |
|
| 3274 | 3274 | } |
| 3275 | 3275 | } |
| 3276 | 3276 | |
@@ -3280,11 +3280,11 @@ discard block |
||
| 3280 | 3280 | * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
| 3281 | 3281 | * @since 1.0.19 |
| 3282 | 3282 | */ |
| 3283 | - public function add_discount( $discount ) { |
|
| 3283 | + public function add_discount($discount) { |
|
| 3284 | 3284 | |
| 3285 | 3285 | $discounts = $this->get_discounts(); |
| 3286 | - $discounts[ $discount['name'] ] = $discount; |
|
| 3287 | - $this->set_prop( 'discounts', $discounts ); |
|
| 3286 | + $discounts[$discount['name']] = $discount; |
|
| 3287 | + $this->set_prop('discounts', $discounts); |
|
| 3288 | 3288 | |
| 3289 | 3289 | } |
| 3290 | 3290 | |
@@ -3294,15 +3294,15 @@ discard block |
||
| 3294 | 3294 | * @since 1.0.19 |
| 3295 | 3295 | * @return float |
| 3296 | 3296 | */ |
| 3297 | - public function get_discount( $discount = false ) { |
|
| 3297 | + public function get_discount($discount = false) { |
|
| 3298 | 3298 | |
| 3299 | 3299 | // Backwards compatibilty. |
| 3300 | - if ( empty( $discount ) ) { |
|
| 3300 | + if (empty($discount)) { |
|
| 3301 | 3301 | return $this->get_total_discount(); |
| 3302 | 3302 | } |
| 3303 | 3303 | |
| 3304 | 3304 | $discounts = $this->get_discounts(); |
| 3305 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3305 | + return isset($discounts[$discount]) ? $discounts[$discount] : null; |
|
| 3306 | 3306 | } |
| 3307 | 3307 | |
| 3308 | 3308 | /** |
@@ -3310,11 +3310,11 @@ discard block |
||
| 3310 | 3310 | * |
| 3311 | 3311 | * @since 1.0.19 |
| 3312 | 3312 | */ |
| 3313 | - public function remove_discount( $discount ) { |
|
| 3313 | + public function remove_discount($discount) { |
|
| 3314 | 3314 | $discounts = $this->get_discounts(); |
| 3315 | - if ( isset( $discounts[ $discount ] ) ) { |
|
| 3316 | - unset( $discounts[ $discount ] ); |
|
| 3317 | - $this->set_prop( 'discounts', $discounts ); |
|
| 3315 | + if (isset($discounts[$discount])) { |
|
| 3316 | + unset($discounts[$discount]); |
|
| 3317 | + $this->set_prop('discounts', $discounts); |
|
| 3318 | 3318 | } |
| 3319 | 3319 | } |
| 3320 | 3320 | |
@@ -3323,12 +3323,12 @@ discard block |
||
| 3323 | 3323 | * |
| 3324 | 3324 | * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
| 3325 | 3325 | */ |
| 3326 | - public function add_tax( $tax ) { |
|
| 3327 | - if ( $this->is_taxable() ) { |
|
| 3326 | + public function add_tax($tax) { |
|
| 3327 | + if ($this->is_taxable()) { |
|
| 3328 | 3328 | |
| 3329 | - $taxes = $this->get_taxes(); |
|
| 3330 | - $taxes[ $tax['name'] ] = $tax; |
|
| 3331 | - $this->set_prop( 'taxes', $tax ); |
|
| 3329 | + $taxes = $this->get_taxes(); |
|
| 3330 | + $taxes[$tax['name']] = $tax; |
|
| 3331 | + $this->set_prop('taxes', $tax); |
|
| 3332 | 3332 | |
| 3333 | 3333 | } |
| 3334 | 3334 | } |
@@ -3338,15 +3338,15 @@ discard block |
||
| 3338 | 3338 | * |
| 3339 | 3339 | * @since 1.0.19 |
| 3340 | 3340 | */ |
| 3341 | - public function get_tax( $tax = null ) { |
|
| 3341 | + public function get_tax($tax = null) { |
|
| 3342 | 3342 | |
| 3343 | 3343 | // Backwards compatility. |
| 3344 | - if ( empty( $tax ) ) { |
|
| 3344 | + if (empty($tax)) { |
|
| 3345 | 3345 | return $this->get_total_tax(); |
| 3346 | 3346 | } |
| 3347 | 3347 | |
| 3348 | 3348 | $taxes = $this->get_taxes(); |
| 3349 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3349 | + return isset($taxes[$tax]) ? $taxes[$tax] : null; |
|
| 3350 | 3350 | } |
| 3351 | 3351 | |
| 3352 | 3352 | /** |
@@ -3354,11 +3354,11 @@ discard block |
||
| 3354 | 3354 | * |
| 3355 | 3355 | * @since 1.0.19 |
| 3356 | 3356 | */ |
| 3357 | - public function remove_tax( $tax ) { |
|
| 3357 | + public function remove_tax($tax) { |
|
| 3358 | 3358 | $taxes = $this->get_taxes(); |
| 3359 | - if ( isset( $taxes[ $tax ] ) ) { |
|
| 3360 | - unset( $taxes[ $tax ] ); |
|
| 3361 | - $this->set_prop( 'taxes', $taxes ); |
|
| 3359 | + if (isset($taxes[$tax])) { |
|
| 3360 | + unset($taxes[$tax]); |
|
| 3361 | + $this->set_prop('taxes', $taxes); |
|
| 3362 | 3362 | } |
| 3363 | 3363 | } |
| 3364 | 3364 | |
@@ -3369,17 +3369,17 @@ discard block |
||
| 3369 | 3369 | * @return float The recalculated subtotal |
| 3370 | 3370 | */ |
| 3371 | 3371 | public function recalculate_subtotal() { |
| 3372 | - $items = $this->get_items(); |
|
| 3372 | + $items = $this->get_items(); |
|
| 3373 | 3373 | $subtotal = 0; |
| 3374 | 3374 | $recurring = 0; |
| 3375 | 3375 | |
| 3376 | - foreach ( $items as $item ) { |
|
| 3376 | + foreach ($items as $item) { |
|
| 3377 | 3377 | $subtotal += $item->get_sub_total(); |
| 3378 | 3378 | $recurring += $item->get_recurring_sub_total(); |
| 3379 | 3379 | } |
| 3380 | 3380 | |
| 3381 | 3381 | $current = $this->is_renewal() ? $recurring : $subtotal; |
| 3382 | - $this->set_subtotal( $current ); |
|
| 3382 | + $this->set_subtotal($current); |
|
| 3383 | 3383 | |
| 3384 | 3384 | $this->totals['subtotal'] = array( |
| 3385 | 3385 | 'initial' => $subtotal, |
@@ -3400,14 +3400,14 @@ discard block |
||
| 3400 | 3400 | $discount = 0; |
| 3401 | 3401 | $recurring = 0; |
| 3402 | 3402 | |
| 3403 | - foreach ( $discounts as $data ) { |
|
| 3404 | - $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
| 3405 | - $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
| 3403 | + foreach ($discounts as $data) { |
|
| 3404 | + $discount += wpinv_sanitize_amount($data['initial_discount']); |
|
| 3405 | + $recurring += wpinv_sanitize_amount($data['recurring_discount']); |
|
| 3406 | 3406 | } |
| 3407 | 3407 | |
| 3408 | 3408 | $current = $this->is_renewal() ? $recurring : $discount; |
| 3409 | 3409 | |
| 3410 | - $this->set_total_discount( $current ); |
|
| 3410 | + $this->set_total_discount($current); |
|
| 3411 | 3411 | |
| 3412 | 3412 | $this->totals['discount'] = array( |
| 3413 | 3413 | 'initial' => $discount, |
@@ -3425,17 +3425,17 @@ discard block |
||
| 3425 | 3425 | * @return float The recalculated tax |
| 3426 | 3426 | */ |
| 3427 | 3427 | public function recalculate_total_tax() { |
| 3428 | - $taxes = $this->get_taxes(); |
|
| 3428 | + $taxes = $this->get_taxes(); |
|
| 3429 | 3429 | $tax = 0; |
| 3430 | 3430 | $recurring = 0; |
| 3431 | 3431 | |
| 3432 | - foreach ( $taxes as $data ) { |
|
| 3433 | - $tax += wpinv_sanitize_amount( $data['initial_tax'] ); |
|
| 3434 | - $recurring += wpinv_sanitize_amount( $data['recurring_tax'] ); |
|
| 3432 | + foreach ($taxes as $data) { |
|
| 3433 | + $tax += wpinv_sanitize_amount($data['initial_tax']); |
|
| 3434 | + $recurring += wpinv_sanitize_amount($data['recurring_tax']); |
|
| 3435 | 3435 | } |
| 3436 | 3436 | |
| 3437 | 3437 | $current = $this->is_renewal() ? $recurring : $tax; |
| 3438 | - $this->set_total_tax( $current ); |
|
| 3438 | + $this->set_total_tax($current); |
|
| 3439 | 3439 | |
| 3440 | 3440 | $this->totals['tax'] = array( |
| 3441 | 3441 | 'initial' => $tax, |
@@ -3457,20 +3457,20 @@ discard block |
||
| 3457 | 3457 | $fee = 0; |
| 3458 | 3458 | $recurring = 0; |
| 3459 | 3459 | |
| 3460 | - foreach ( $fees as $data ) { |
|
| 3461 | - $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
| 3462 | - $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
| 3460 | + foreach ($fees as $data) { |
|
| 3461 | + $fee += wpinv_sanitize_amount($data['initial_fee']); |
|
| 3462 | + $recurring += wpinv_sanitize_amount($data['recurring_fee']); |
|
| 3463 | 3463 | } |
| 3464 | 3464 | |
| 3465 | 3465 | $current = $this->is_renewal() ? $recurring : $fee; |
| 3466 | - $this->set_total_fees( $current ); |
|
| 3466 | + $this->set_total_fees($current); |
|
| 3467 | 3467 | |
| 3468 | 3468 | $this->totals['fee'] = array( |
| 3469 | 3469 | 'initial' => $fee, |
| 3470 | 3470 | 'recurring' => $recurring, |
| 3471 | 3471 | ); |
| 3472 | 3472 | |
| 3473 | - $this->set_total_fees( $fee ); |
|
| 3473 | + $this->set_total_fees($fee); |
|
| 3474 | 3474 | return $current; |
| 3475 | 3475 | } |
| 3476 | 3476 | |
@@ -3491,9 +3491,9 @@ discard block |
||
| 3491 | 3491 | /** |
| 3492 | 3492 | * @deprecated |
| 3493 | 3493 | */ |
| 3494 | - public function recalculate_totals( $temp = false ) { |
|
| 3495 | - $this->update_items( $temp ); |
|
| 3496 | - $this->save( true ); |
|
| 3494 | + public function recalculate_totals($temp = false) { |
|
| 3495 | + $this->update_items($temp); |
|
| 3496 | + $this->save(true); |
|
| 3497 | 3497 | return $this; |
| 3498 | 3498 | } |
| 3499 | 3499 | |
@@ -3511,10 +3511,10 @@ discard block |
||
| 3511 | 3511 | * @return int|false The new note's ID on success, false on failure. |
| 3512 | 3512 | * |
| 3513 | 3513 | */ |
| 3514 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
| 3514 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
| 3515 | 3515 | |
| 3516 | 3516 | // Bail if no note specified or this invoice is not yet saved. |
| 3517 | - if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) { |
|
| 3517 | + if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) { |
|
| 3518 | 3518 | return false; |
| 3519 | 3519 | } |
| 3520 | 3520 | |
@@ -3522,23 +3522,23 @@ discard block |
||
| 3522 | 3522 | $author_email = '[email protected]'; |
| 3523 | 3523 | |
| 3524 | 3524 | // If this is an admin comment or it has been added by the user. |
| 3525 | - if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
| 3526 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
| 3525 | + if (is_user_logged_in() && (!$system || $added_by_user)) { |
|
| 3526 | + $user = get_user_by('id', get_current_user_id()); |
|
| 3527 | 3527 | $author = $user->display_name; |
| 3528 | 3528 | $author_email = $user->user_email; |
| 3529 | 3529 | } |
| 3530 | 3530 | |
| 3531 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
| 3531 | + return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type); |
|
| 3532 | 3532 | |
| 3533 | 3533 | } |
| 3534 | 3534 | |
| 3535 | 3535 | /** |
| 3536 | 3536 | * Generates a unique key for the invoice. |
| 3537 | 3537 | */ |
| 3538 | - public function generate_key( $string = '' ) { |
|
| 3539 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 3538 | + public function generate_key($string = '') { |
|
| 3539 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 3540 | 3540 | return strtolower( |
| 3541 | - $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) |
|
| 3541 | + $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true)) |
|
| 3542 | 3542 | ); |
| 3543 | 3543 | } |
| 3544 | 3544 | |
@@ -3548,11 +3548,11 @@ discard block |
||
| 3548 | 3548 | public function generate_number() { |
| 3549 | 3549 | $number = $this->get_id(); |
| 3550 | 3550 | |
| 3551 | - if ( wpinv_sequential_number_active( $this->get_post_type() ) ) { |
|
| 3552 | - $number = wpinv_get_next_invoice_number( $this->get_post_type() ); |
|
| 3551 | + if (wpinv_sequential_number_active($this->get_post_type())) { |
|
| 3552 | + $number = wpinv_get_next_invoice_number($this->get_post_type()); |
|
| 3553 | 3553 | } |
| 3554 | 3554 | |
| 3555 | - return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
| 3555 | + return wpinv_format_invoice_number($number, $this->get_post_type()); |
|
| 3556 | 3556 | |
| 3557 | 3557 | } |
| 3558 | 3558 | |
@@ -3565,55 +3565,55 @@ discard block |
||
| 3565 | 3565 | // Reset status transition variable. |
| 3566 | 3566 | $this->status_transition = false; |
| 3567 | 3567 | |
| 3568 | - if ( $status_transition ) { |
|
| 3568 | + if ($status_transition) { |
|
| 3569 | 3569 | try { |
| 3570 | 3570 | |
| 3571 | 3571 | // Fire a hook for the status change. |
| 3572 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
| 3572 | + do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition); |
|
| 3573 | 3573 | |
| 3574 | 3574 | // @deprecated this is deprecated and will be removed in the future. |
| 3575 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3575 | + do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
| 3576 | 3576 | |
| 3577 | - if ( ! empty( $status_transition['from'] ) ) { |
|
| 3577 | + if (!empty($status_transition['from'])) { |
|
| 3578 | 3578 | |
| 3579 | 3579 | /* translators: 1: old invoice status 2: new invoice status */ |
| 3580 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3580 | + $transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from'], $this), wpinv_status_nicename($status_transition['to'], $this)); |
|
| 3581 | 3581 | |
| 3582 | 3582 | // Fire another hook. |
| 3583 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
| 3584 | - do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
| 3583 | + do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this); |
|
| 3584 | + do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
| 3585 | 3585 | |
| 3586 | 3586 | // @deprecated this is deprecated and will be removed in the future. |
| 3587 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3587 | + do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
| 3588 | 3588 | |
| 3589 | 3589 | // Note the transition occurred. |
| 3590 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] ); |
|
| 3590 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']); |
|
| 3591 | 3591 | |
| 3592 | 3592 | // Work out if this was for a payment, and trigger a payment_status hook instead. |
| 3593 | 3593 | if ( |
| 3594 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3595 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3594 | + in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
| 3595 | + && in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
| 3596 | 3596 | ) { |
| 3597 | - do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
| 3597 | + do_action('getpaid_invoice_payment_status_changed', $this, $status_transition); |
|
| 3598 | 3598 | } |
| 3599 | 3599 | |
| 3600 | 3600 | // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
| 3601 | 3601 | if ( |
| 3602 | - in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3603 | - && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3602 | + in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
| 3603 | + && in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
| 3604 | 3604 | ) { |
| 3605 | - do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
| 3605 | + do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition); |
|
| 3606 | 3606 | } |
| 3607 | 3607 | } else { |
| 3608 | 3608 | /* translators: %s: new invoice status */ |
| 3609 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3609 | + $transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this)); |
|
| 3610 | 3610 | |
| 3611 | 3611 | // Note the transition occurred. |
| 3612 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3612 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
| 3613 | 3613 | |
| 3614 | 3614 | } |
| 3615 | - } catch ( Exception $e ) { |
|
| 3616 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3615 | + } catch (Exception $e) { |
|
| 3616 | + $this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
| 3617 | 3617 | } |
| 3618 | 3618 | } |
| 3619 | 3619 | } |
@@ -3621,13 +3621,13 @@ discard block |
||
| 3621 | 3621 | /** |
| 3622 | 3622 | * Updates an invoice status. |
| 3623 | 3623 | */ |
| 3624 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3624 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
| 3625 | 3625 | |
| 3626 | 3626 | // Fires before updating a status. |
| 3627 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3627 | + do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit')); |
|
| 3628 | 3628 | |
| 3629 | 3629 | // Update the status. |
| 3630 | - $this->set_status( $new_status, $note, $manual ); |
|
| 3630 | + $this->set_status($new_status, $note, $manual); |
|
| 3631 | 3631 | |
| 3632 | 3632 | // Save the order. |
| 3633 | 3633 | return $this->save(); |
@@ -3638,18 +3638,18 @@ discard block |
||
| 3638 | 3638 | * @deprecated |
| 3639 | 3639 | */ |
| 3640 | 3640 | public function refresh_item_ids() { |
| 3641 | - $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) ); |
|
| 3642 | - update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
|
| 3641 | + $item_ids = implode(',', array_unique(array_keys($this->get_items()))); |
|
| 3642 | + update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids); |
|
| 3643 | 3643 | } |
| 3644 | 3644 | |
| 3645 | 3645 | /** |
| 3646 | 3646 | * @deprecated |
| 3647 | 3647 | */ |
| 3648 | - public function update_items( $temp = false ) { |
|
| 3648 | + public function update_items($temp = false) { |
|
| 3649 | 3649 | |
| 3650 | - $this->set_items( $this->get_items() ); |
|
| 3650 | + $this->set_items($this->get_items()); |
|
| 3651 | 3651 | |
| 3652 | - if ( ! $temp ) { |
|
| 3652 | + if (!$temp) { |
|
| 3653 | 3653 | $this->save(); |
| 3654 | 3654 | } |
| 3655 | 3655 | |
@@ -3663,11 +3663,11 @@ discard block |
||
| 3663 | 3663 | |
| 3664 | 3664 | $discount_code = $this->get_discount_code(); |
| 3665 | 3665 | |
| 3666 | - if ( empty( $discount_code ) ) { |
|
| 3666 | + if (empty($discount_code)) { |
|
| 3667 | 3667 | return false; |
| 3668 | 3668 | } |
| 3669 | 3669 | |
| 3670 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 3670 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 3671 | 3671 | |
| 3672 | 3672 | // Ensure it is active. |
| 3673 | 3673 | return $discount->exists(); |
@@ -3678,7 +3678,7 @@ discard block |
||
| 3678 | 3678 | * Refunds an invoice. |
| 3679 | 3679 | */ |
| 3680 | 3680 | public function refund() { |
| 3681 | - $this->set_status( 'wpi-refunded' ); |
|
| 3681 | + $this->set_status('wpi-refunded'); |
|
| 3682 | 3682 | $this->save(); |
| 3683 | 3683 | } |
| 3684 | 3684 | |
@@ -3687,56 +3687,56 @@ discard block |
||
| 3687 | 3687 | * |
| 3688 | 3688 | * @param string $transaction_id |
| 3689 | 3689 | */ |
| 3690 | - public function mark_paid( $transaction_id = null, $note = '' ) { |
|
| 3690 | + public function mark_paid($transaction_id = null, $note = '') { |
|
| 3691 | 3691 | |
| 3692 | 3692 | // Set the transaction id. |
| 3693 | - if ( empty( $transaction_id ) ) { |
|
| 3693 | + if (empty($transaction_id)) { |
|
| 3694 | 3694 | $transaction_id = $this->generate_key('trans_'); |
| 3695 | 3695 | } |
| 3696 | 3696 | |
| 3697 | - if ( ! $this->get_transaction_id() ) { |
|
| 3698 | - $this->set_transaction_id( $transaction_id ); |
|
| 3697 | + if (!$this->get_transaction_id()) { |
|
| 3698 | + $this->set_transaction_id($transaction_id); |
|
| 3699 | 3699 | } |
| 3700 | 3700 | |
| 3701 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3701 | + if ($this->is_paid() && 'wpi-processing' != $this->get_status()) { |
|
| 3702 | 3702 | return $this->save(); |
| 3703 | 3703 | } |
| 3704 | 3704 | |
| 3705 | 3705 | // Set the completed date. |
| 3706 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3706 | + $this->set_date_completed(current_time('mysql')); |
|
| 3707 | 3707 | |
| 3708 | 3708 | // Set the new status. |
| 3709 | - if ( $this->is_renewal() ) { |
|
| 3709 | + if ($this->is_renewal()) { |
|
| 3710 | 3710 | |
| 3711 | 3711 | $_note = sprintf( |
| 3712 | - __( 'Renewed via %s', 'invoicing' ), |
|
| 3713 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3712 | + __('Renewed via %s', 'invoicing'), |
|
| 3713 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
| 3714 | 3714 | ); |
| 3715 | 3715 | |
| 3716 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3716 | + if ('none' == $this->get_gateway()) { |
|
| 3717 | 3717 | $_note = $note; |
| 3718 | 3718 | } |
| 3719 | 3719 | |
| 3720 | - $this->set_status( 'wpi-renewal', $_note ); |
|
| 3720 | + $this->set_status('wpi-renewal', $_note); |
|
| 3721 | 3721 | |
| 3722 | 3722 | } else { |
| 3723 | 3723 | |
| 3724 | 3724 | $_note = sprintf( |
| 3725 | - __( 'Paid via %s', 'invoicing' ), |
|
| 3726 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3725 | + __('Paid via %s', 'invoicing'), |
|
| 3726 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
| 3727 | 3727 | ); |
| 3728 | 3728 | |
| 3729 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3729 | + if ('none' == $this->get_gateway()) { |
|
| 3730 | 3730 | $_note = $note; |
| 3731 | 3731 | } |
| 3732 | 3732 | |
| 3733 | - $this->set_status( 'publish',$_note ); |
|
| 3733 | + $this->set_status('publish', $_note); |
|
| 3734 | 3734 | |
| 3735 | 3735 | } |
| 3736 | 3736 | |
| 3737 | 3737 | // Set checkout mode. |
| 3738 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3739 | - $this->set_mode( $mode ); |
|
| 3738 | + $mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live'; |
|
| 3739 | + $this->set_mode($mode); |
|
| 3740 | 3740 | |
| 3741 | 3741 | // Save the invoice. |
| 3742 | 3742 | $this->save(); |
@@ -3762,9 +3762,9 @@ discard block |
||
| 3762 | 3762 | * Clears the subscription's cache. |
| 3763 | 3763 | */ |
| 3764 | 3764 | public function clear_cache() { |
| 3765 | - wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
| 3766 | - wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
| 3767 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
| 3765 | + wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids'); |
|
| 3766 | + wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids'); |
|
| 3767 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids'); |
|
| 3768 | 3768 | } |
| 3769 | 3769 | |
| 3770 | 3770 | } |
@@ -44,15 +44,15 @@ |
||
| 44 | 44 | parent::__construct( $options ); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * The Super block output function. |
|
| 49 | - * |
|
| 50 | - * @param array $args |
|
| 51 | - * @param array $widget_args |
|
| 52 | - * @param string $content |
|
| 53 | - * |
|
| 54 | - * @return mixed|string|bool |
|
| 55 | - */ |
|
| 47 | + /** |
|
| 48 | + * The Super block output function. |
|
| 49 | + * |
|
| 50 | + * @param array $args |
|
| 51 | + * @param array $widget_args |
|
| 52 | + * @param string $content |
|
| 53 | + * |
|
| 54 | + * @return mixed|string|bool |
|
| 55 | + */ |
|
| 56 | 56 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
| 57 | 57 | return getpaid_invoice_history(); |
| 58 | 58 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -22,15 +22,15 @@ discard block |
||
| 22 | 22 | 'block-keywords'=> "['invoicing','history']", |
| 23 | 23 | 'class_name' => __CLASS__, |
| 24 | 24 | 'base_id' => 'wpinv_history', |
| 25 | - 'name' => __('GetPaid > Invoice History','invoicing'), |
|
| 25 | + 'name' => __('GetPaid > Invoice History', 'invoicing'), |
|
| 26 | 26 | 'widget_ops' => array( |
| 27 | 27 | 'classname' => 'wpinv-history-class bsui', |
| 28 | - 'description' => esc_html__('Displays invoice history.','invoicing'), |
|
| 28 | + 'description' => esc_html__('Displays invoice history.', 'invoicing'), |
|
| 29 | 29 | ), |
| 30 | 30 | 'arguments' => array( |
| 31 | 31 | 'title' => array( |
| 32 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
| 33 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
| 32 | + 'title' => __('Widget title', 'invoicing'), |
|
| 33 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
| 34 | 34 | 'type' => 'text', |
| 35 | 35 | 'desc_tip' => true, |
| 36 | 36 | 'default' => '', |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | 43 | |
| 44 | - parent::__construct( $options ); |
|
| 44 | + parent::__construct($options); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return mixed|string|bool |
| 55 | 55 | */ |
| 56 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 56 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 57 | 57 | return getpaid_invoice_history(); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -44,15 +44,15 @@ |
||
| 44 | 44 | parent::__construct( $options ); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * The Super block output function. |
|
| 49 | - * |
|
| 50 | - * @param array $args |
|
| 51 | - * @param array $widget_args |
|
| 52 | - * @param string $content |
|
| 53 | - * |
|
| 54 | - * @return mixed|string|bool |
|
| 55 | - */ |
|
| 47 | + /** |
|
| 48 | + * The Super block output function. |
|
| 49 | + * |
|
| 50 | + * @param array $args |
|
| 51 | + * @param array $widget_args |
|
| 52 | + * @param string $content |
|
| 53 | + * |
|
| 54 | + * @return mixed|string|bool |
|
| 55 | + */ |
|
| 56 | 56 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
| 57 | 57 | return wpinv_payment_receipt(); |
| 58 | 58 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; |
| 4 | 4 | } |
| 5 | 5 | |
@@ -22,15 +22,15 @@ discard block |
||
| 22 | 22 | 'block-keywords'=> "['invoicing','receipt']", |
| 23 | 23 | 'class_name' => __CLASS__, |
| 24 | 24 | 'base_id' => 'wpinv_receipt', |
| 25 | - 'name' => __('GetPaid > Invoice Receipt','invoicing'), |
|
| 25 | + 'name' => __('GetPaid > Invoice Receipt', 'invoicing'), |
|
| 26 | 26 | 'widget_ops' => array( |
| 27 | 27 | 'classname' => 'wpinv-receipt-class bsui', |
| 28 | - 'description' => esc_html__('Displays invoice receipt after checkout.','invoicing'), |
|
| 28 | + 'description' => esc_html__('Displays invoice receipt after checkout.', 'invoicing'), |
|
| 29 | 29 | ), |
| 30 | 30 | 'arguments' => array( |
| 31 | 31 | 'title' => array( |
| 32 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
| 33 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
| 32 | + 'title' => __('Widget title', 'invoicing'), |
|
| 33 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
| 34 | 34 | 'type' => 'text', |
| 35 | 35 | 'desc_tip' => true, |
| 36 | 36 | 'default' => '', |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | 43 | |
| 44 | - parent::__construct( $options ); |
|
| 44 | + parent::__construct($options); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return mixed|string|bool |
| 55 | 55 | */ |
| 56 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 56 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 57 | 57 | return wpinv_payment_receipt(); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -394,15 +394,15 @@ discard block |
||
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | /** |
| 397 | - * Fetches the database from the MaxMind service. |
|
| 398 | - * |
|
| 399 | - * @param string $license_key The license key to be used when downloading the database. |
|
| 400 | - */ |
|
| 397 | + * Fetches the database from the MaxMind service. |
|
| 398 | + * |
|
| 399 | + * @param string $license_key The license key to be used when downloading the database. |
|
| 400 | + */ |
|
| 401 | 401 | public static function geoip2_download_database() { |
| 402 | 402 | |
| 403 | 403 | // Allow us to easily interact with the filesystem. |
| 404 | 404 | require_once ABSPATH . 'wp-admin/includes/file.php'; |
| 405 | - WP_Filesystem(); |
|
| 405 | + WP_Filesystem(); |
|
| 406 | 406 | global $wp_filesystem; |
| 407 | 407 | |
| 408 | 408 | $license_key = wpinv_get_option( 'maxmind_license_key' ); |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | // Move the new database into position. |
| 436 | - $wp_filesystem->move( $database_path, $target_path, true ); |
|
| 436 | + $wp_filesystem->move( $database_path, $target_path, true ); |
|
| 437 | 437 | $wp_filesystem->delete( dirname( $database_path ) ); |
| 438 | 438 | |
| 439 | 439 | wpinv_update_option( 'wpinv_geoip2_date_updated', current_time( 'timestamp' ) ); |
@@ -452,16 +452,16 @@ discard block |
||
| 452 | 452 | |
| 453 | 453 | // The download URI of the database. |
| 454 | 454 | $source_url = add_query_arg( |
| 455 | - array( |
|
| 455 | + array( |
|
| 456 | 456 | 'license_key' => urlencode( sanitize_text_field( $license_key ) ), |
| 457 | 457 | 'edition_id' => $database, |
| 458 | - 'suffix' => 'tar.gz', |
|
| 459 | - ), |
|
| 460 | - 'https://download.maxmind.com/app/geoip_download' |
|
| 458 | + 'suffix' => 'tar.gz', |
|
| 459 | + ), |
|
| 460 | + 'https://download.maxmind.com/app/geoip_download' |
|
| 461 | 461 | ); |
| 462 | 462 | |
| 463 | 463 | // Needed for the download_url call right below. |
| 464 | - require_once ABSPATH . 'wp-admin/includes/file.php'; |
|
| 464 | + require_once ABSPATH . 'wp-admin/includes/file.php'; |
|
| 465 | 465 | |
| 466 | 466 | // Download the file. |
| 467 | 467 | $tmp_archive_path = download_url( esc_url_raw( $source_url ) ); |
@@ -470,16 +470,16 @@ discard block |
||
| 470 | 470 | if ( is_wp_error( $tmp_archive_path ) ) { |
| 471 | 471 | |
| 472 | 472 | // Transform the error into something more informative. |
| 473 | - $error_data = $tmp_archive_path->get_error_data(); |
|
| 474 | - if ( isset( $error_data['code'] ) ) { |
|
| 475 | - switch ( $error_data['code'] ) { |
|
| 476 | - case 401: |
|
| 477 | - return new WP_Error( |
|
| 478 | - 'invoicing_maxmind_geolocation_database_license_key', |
|
| 479 | - __( 'The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing' ) |
|
| 480 | - ); |
|
| 481 | - } |
|
| 482 | - } |
|
| 473 | + $error_data = $tmp_archive_path->get_error_data(); |
|
| 474 | + if ( isset( $error_data['code'] ) ) { |
|
| 475 | + switch ( $error_data['code'] ) { |
|
| 476 | + case 401: |
|
| 477 | + return new WP_Error( |
|
| 478 | + 'invoicing_maxmind_geolocation_database_license_key', |
|
| 479 | + __( 'The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing' ) |
|
| 480 | + ); |
|
| 481 | + } |
|
| 482 | + } |
|
| 483 | 483 | |
| 484 | 484 | return new WP_Error( 'invoicing_maxmind_geolocation_database_download', __( 'Failed to download the MaxMind database.', 'invoicing' ) ); |
| 485 | 485 | |
@@ -487,19 +487,19 @@ discard block |
||
| 487 | 487 | |
| 488 | 488 | // Extract the database from the archive. |
| 489 | 489 | try { |
| 490 | - $file = new PharData( $tmp_archive_path ); |
|
| 490 | + $file = new PharData( $tmp_archive_path ); |
|
| 491 | 491 | $file_path = trailingslashit( dirname( $tmp_archive_path ) ) . trailingslashit( $file->current()->getFilename() ) . $database . '.mmdb'; |
| 492 | 492 | |
| 493 | - $file->extractTo( |
|
| 494 | - dirname( $tmp_archive_path ), |
|
| 495 | - trailingslashit( $file->current()->getFilename() ) . $database . '.mmdb', |
|
| 496 | - true |
|
| 493 | + $file->extractTo( |
|
| 494 | + dirname( $tmp_archive_path ), |
|
| 495 | + trailingslashit( $file->current()->getFilename() ) . $database . '.mmdb', |
|
| 496 | + true |
|
| 497 | 497 | ); |
| 498 | 498 | |
| 499 | - } catch ( Exception $exception ) { |
|
| 500 | - return new WP_Error( 'invoicing_maxmind_geolocation_database_archive', $exception->getMessage() ); |
|
| 501 | - } finally { |
|
| 502 | - // Remove the archive since we only care about a single file in it. |
|
| 499 | + } catch ( Exception $exception ) { |
|
| 500 | + return new WP_Error( 'invoicing_maxmind_geolocation_database_archive', $exception->getMessage() ); |
|
| 501 | + } finally { |
|
| 502 | + // Remove the archive since we only care about a single file in it. |
|
| 503 | 503 | unlink( $tmp_archive_path ); |
| 504 | 504 | } |
| 505 | 505 | |
@@ -1862,7 +1862,7 @@ discard block |
||
| 1862 | 1862 | $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false; |
| 1863 | 1863 | |
| 1864 | 1864 | if ( ! $valid_company && ! empty( $wpinv_options['vat_disable_company_name_check'] ) ) { |
| 1865 | - return wp_sprintf( |
|
| 1865 | + return wp_sprintf( |
|
| 1866 | 1866 | __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ), |
| 1867 | 1867 | getpaid_vat_name() |
| 1868 | 1868 | ); |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | if ( !empty( $load_xml ) && !empty( $load_xml->geoplugin_countryCode ) ) { |
| 713 | 713 | $wpinv_ip_address_country = (string)$load_xml->geoplugin_countryCode; |
| 714 | 714 | } |
| 715 | - }elseif(!empty( $ip )){ |
|
| 715 | + } elseif(!empty( $ip )){ |
|
| 716 | 716 | $url = 'http://ip-api.com/json/' . $ip; |
| 717 | 717 | $response = wp_remote_get($url); |
| 718 | 718 | |
@@ -1513,16 +1513,18 @@ discard block |
||
| 1513 | 1513 | |
| 1514 | 1514 | if ( !empty( $tax_rates ) ) { |
| 1515 | 1515 | foreach ( $tax_rates as $key => $tax_rate ) { |
| 1516 | - if ( $country != $tax_rate['country'] ) |
|
| 1517 | - continue; |
|
| 1516 | + if ( $country != $tax_rate['country'] ) { |
|
| 1517 | + continue; |
|
| 1518 | + } |
|
| 1518 | 1519 | |
| 1519 | 1520 | if ( !empty( $tax_rate['global'] ) ) { |
| 1520 | 1521 | if ( 0 !== $tax_rate['rate'] || !empty( $tax_rate['rate'] ) ) { |
| 1521 | 1522 | $rate = number_format( $tax_rate['rate'], 4 ); |
| 1522 | 1523 | } |
| 1523 | 1524 | } else { |
| 1524 | - if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) |
|
| 1525 | - continue; |
|
| 1525 | + if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) { |
|
| 1526 | + continue; |
|
| 1527 | + } |
|
| 1526 | 1528 | |
| 1527 | 1529 | $state_rate = $tax_rate['rate']; |
| 1528 | 1530 | if ( 0 !== $state_rate || !empty( $state_rate ) ) { |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | class WPInv_EUVat { |
| 10 | 10 | |
@@ -24,128 +24,128 @@ discard block |
||
| 24 | 24 | public function init() { |
| 25 | 25 | |
| 26 | 26 | // If this is an admin page... |
| 27 | - if ( is_admin() ) { |
|
| 27 | + if (is_admin()) { |
|
| 28 | 28 | |
| 29 | 29 | // Register our scripts. |
| 30 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) ); |
|
| 31 | - add_action( 'wpinv_settings_sections_taxes', array( $this, 'section_vat_settings' ) ); |
|
| 32 | - add_action( 'wpinv_settings_taxes', array( $this, 'vat_settings' ) ); |
|
| 33 | - add_filter( 'wpinv_settings_taxes-vat_sanitize', array( $this, 'sanitize_vat_settings' ) ); |
|
| 34 | - add_filter( 'wpinv_settings_taxes-vat_rates_sanitize', array( $this, 'sanitize_vat_rates' ) ); |
|
| 35 | - add_action( 'wp_ajax_wpinv_add_vat_class', array( $this, 'add_class' ) ); |
|
| 36 | - add_action( 'wp_ajax_nopriv_wpinv_add_vat_class', array( $this, 'add_class' ) ); |
|
| 37 | - add_action( 'wp_ajax_wpinv_delete_vat_class', array( $this, 'delete_class' ) ); |
|
| 38 | - add_action( 'wp_ajax_nopriv_wpinv_delete_vat_class', array( $this, 'delete_class' ) ); |
|
| 39 | - add_action( 'wp_ajax_wpinv_update_vat_rates', array( $this, 'update_eu_rates' ) ); |
|
| 40 | - add_action( 'wp_ajax_nopriv_wpinv_update_vat_rates', array( $this, 'update_eu_rates' ) ); |
|
| 41 | - add_action( 'wp_ajax_wpinv_geoip2', array( $this, 'geoip2_download_database' ) ); |
|
| 42 | - add_action( 'wp_ajax_nopriv_wpinv_geoip2', array( $this, 'geoip2_download_database' ) ); |
|
| 30 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts')); |
|
| 31 | + add_action('wpinv_settings_sections_taxes', array($this, 'section_vat_settings')); |
|
| 32 | + add_action('wpinv_settings_taxes', array($this, 'vat_settings')); |
|
| 33 | + add_filter('wpinv_settings_taxes-vat_sanitize', array($this, 'sanitize_vat_settings')); |
|
| 34 | + add_filter('wpinv_settings_taxes-vat_rates_sanitize', array($this, 'sanitize_vat_rates')); |
|
| 35 | + add_action('wp_ajax_wpinv_add_vat_class', array($this, 'add_class')); |
|
| 36 | + add_action('wp_ajax_nopriv_wpinv_add_vat_class', array($this, 'add_class')); |
|
| 37 | + add_action('wp_ajax_wpinv_delete_vat_class', array($this, 'delete_class')); |
|
| 38 | + add_action('wp_ajax_nopriv_wpinv_delete_vat_class', array($this, 'delete_class')); |
|
| 39 | + add_action('wp_ajax_wpinv_update_vat_rates', array($this, 'update_eu_rates')); |
|
| 40 | + add_action('wp_ajax_nopriv_wpinv_update_vat_rates', array($this, 'update_eu_rates')); |
|
| 41 | + add_action('wp_ajax_wpinv_geoip2', array($this, 'geoip2_download_database')); |
|
| 42 | + add_action('wp_ajax_nopriv_wpinv_geoip2', array($this, 'geoip2_download_database')); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_vat_scripts' ) ); |
|
| 46 | - add_filter( 'wpinv_default_billing_country', array( $this, 'get_user_country' ), 10 ); |
|
| 47 | - add_filter( 'wpinv_get_user_country', array( $this, 'set_user_country' ), 10 ); |
|
| 48 | - add_action( 'wp_ajax_wpinv_vat_validate', array( $this, 'ajax_vat_validate' ) ); |
|
| 49 | - add_action( 'wp_ajax_nopriv_wpinv_vat_validate', array( $this, 'ajax_vat_validate' ) ); |
|
| 45 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_vat_scripts')); |
|
| 46 | + add_filter('wpinv_default_billing_country', array($this, 'get_user_country'), 10); |
|
| 47 | + add_filter('wpinv_get_user_country', array($this, 'set_user_country'), 10); |
|
| 48 | + add_action('wp_ajax_wpinv_vat_validate', array($this, 'ajax_vat_validate')); |
|
| 49 | + add_action('wp_ajax_nopriv_wpinv_vat_validate', array($this, 'ajax_vat_validate')); |
|
| 50 | 50 | |
| 51 | - if ( wpinv_use_taxes() && self::allow_vat_rules() ) { |
|
| 52 | - add_filter( 'wpinv_tax_rate', array( $this, 'get_rate' ), 10, 4 ); |
|
| 51 | + if (wpinv_use_taxes() && self::allow_vat_rules()) { |
|
| 52 | + add_filter('wpinv_tax_rate', array($this, 'get_rate'), 10, 4); |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - public static function get_eu_states( $sort = true ) { |
|
| 57 | - $eu_states = array( 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GB', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE' ); |
|
| 58 | - if ( $sort ) { |
|
| 59 | - $sort = sort( $eu_states ); |
|
| 56 | + public static function get_eu_states($sort = true) { |
|
| 57 | + $eu_states = array('AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GB', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE'); |
|
| 58 | + if ($sort) { |
|
| 59 | + $sort = sort($eu_states); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - return apply_filters( 'wpinv_get_eu_states', $eu_states, $sort ); |
|
| 62 | + return apply_filters('wpinv_get_eu_states', $eu_states, $sort); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - public static function get_gst_countries( $sort = true ) { |
|
| 66 | - $gst_countries = array( 'AU', 'NZ', 'CA', 'CN' ); |
|
| 65 | + public static function get_gst_countries($sort = true) { |
|
| 66 | + $gst_countries = array('AU', 'NZ', 'CA', 'CN'); |
|
| 67 | 67 | |
| 68 | - if ( $sort ) { |
|
| 69 | - $sort = sort( $gst_countries ); |
|
| 68 | + if ($sort) { |
|
| 69 | + $sort = sort($gst_countries); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - return apply_filters( 'wpinv_get_gst_countries', $gst_countries, $sort ); |
|
| 72 | + return apply_filters('wpinv_get_gst_countries', $gst_countries, $sort); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - public static function is_eu_state( $country_code ) { |
|
| 76 | - $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_eu_states() ) ? true : false; |
|
| 75 | + public static function is_eu_state($country_code) { |
|
| 76 | + $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_eu_states()) ? true : false; |
|
| 77 | 77 | |
| 78 | - return apply_filters( 'wpinv_is_eu_state', $return, $country_code ); |
|
| 78 | + return apply_filters('wpinv_is_eu_state', $return, $country_code); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - public static function is_gst_country( $country_code ) { |
|
| 82 | - $return = !empty( $country_code ) && in_array( strtoupper( $country_code ), self::get_gst_countries() ) ? true : false; |
|
| 81 | + public static function is_gst_country($country_code) { |
|
| 82 | + $return = !empty($country_code) && in_array(strtoupper($country_code), self::get_gst_countries()) ? true : false; |
|
| 83 | 83 | |
| 84 | - return apply_filters( 'wpinv_is_gst_country', $return, $country_code ); |
|
| 84 | + return apply_filters('wpinv_is_gst_country', $return, $country_code); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | public function enqueue_vat_scripts() { |
| 88 | - if( wpinv_use_taxes() && wpinv_get_option( 'apply_vat_rules' ) ) { |
|
| 88 | + if (wpinv_use_taxes() && wpinv_get_option('apply_vat_rules')) { |
|
| 89 | 89 | $this->load_vat_scripts(); |
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - public function load_vat_scripts(){ |
|
| 94 | - $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 93 | + public function load_vat_scripts() { |
|
| 94 | + $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 95 | 95 | |
| 96 | - wp_register_script( 'wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 97 | - wp_register_script( 'wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 96 | + wp_register_script('wpinv-vat-validation-script', WPINV_PLUGIN_URL . 'assets/js/jsvat' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
| 97 | + wp_register_script('wpinv-vat-script', WPINV_PLUGIN_URL . 'assets/js/euvat' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
| 98 | 98 | |
| 99 | - $vat_name = $this->get_vat_name(); |
|
| 99 | + $vat_name = $this->get_vat_name(); |
|
| 100 | 100 | |
| 101 | 101 | $vars = array(); |
| 102 | 102 | $vars['UseTaxes'] = wpinv_use_taxes(); |
| 103 | 103 | $vars['EUStates'] = self::get_eu_states(); |
| 104 | - $vars['NoRateSet'] = __( 'You have not set a rate. Do you want to continue?', 'invoicing' ); |
|
| 105 | - $vars['EmptyCompany'] = __( 'Please enter your registered company name!', 'invoicing' ); |
|
| 106 | - $vars['EmptyVAT'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name ); |
|
| 107 | - $vars['TotalsRefreshed'] = wp_sprintf( __( 'The invoice totals will be refreshed to update the %s.', 'invoicing' ), $vat_name ); |
|
| 108 | - $vars['ErrValidateVAT'] = wp_sprintf( __( 'Fail to validate the %s number!', 'invoicing' ), $vat_name ); |
|
| 109 | - $vars['ErrResetVAT'] = wp_sprintf( __( 'Fail to reset the %s number!', 'invoicing' ), $vat_name ); |
|
| 110 | - $vars['ErrInvalidVat'] = wp_sprintf( __( 'The %s number supplied does not have a valid format!', 'invoicing' ), $vat_name ); |
|
| 111 | - $vars['ErrInvalidResponse'] = __( 'An invalid response has been received from the server!', 'invoicing' ); |
|
| 104 | + $vars['NoRateSet'] = __('You have not set a rate. Do you want to continue?', 'invoicing'); |
|
| 105 | + $vars['EmptyCompany'] = __('Please enter your registered company name!', 'invoicing'); |
|
| 106 | + $vars['EmptyVAT'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name); |
|
| 107 | + $vars['TotalsRefreshed'] = wp_sprintf(__('The invoice totals will be refreshed to update the %s.', 'invoicing'), $vat_name); |
|
| 108 | + $vars['ErrValidateVAT'] = wp_sprintf(__('Fail to validate the %s number!', 'invoicing'), $vat_name); |
|
| 109 | + $vars['ErrResetVAT'] = wp_sprintf(__('Fail to reset the %s number!', 'invoicing'), $vat_name); |
|
| 110 | + $vars['ErrInvalidVat'] = wp_sprintf(__('The %s number supplied does not have a valid format!', 'invoicing'), $vat_name); |
|
| 111 | + $vars['ErrInvalidResponse'] = __('An invalid response has been received from the server!', 'invoicing'); |
|
| 112 | 112 | $vars['ApplyVATRules'] = $vars['UseTaxes'] ? self::allow_vat_rules() : false; |
| 113 | 113 | $vars['HideVatFields'] = $vars['ApplyVATRules'] ? self::hide_vat_fields() : true; |
| 114 | - $vars['ErrResponse'] = __( 'The request response is invalid!', 'invoicing' ); |
|
| 115 | - $vars['ErrRateResponse'] = __( 'The get rate request response is invalid', 'invoicing' ); |
|
| 116 | - $vars['PageRefresh'] = __( 'The page will be refreshed in 10 seconds to show the new options.', 'invoicing' ); |
|
| 117 | - $vars['RequestResponseNotValidJSON'] = __( 'The get rate request response is not valid JSON', 'invoicing' ); |
|
| 118 | - $vars['GetRateRequestFailed'] = __( 'The get rate request failed: ', 'invoicing' ); |
|
| 119 | - $vars['NoRateInformationInResponse'] = __( 'The get rate request response does not contain any rate information', 'invoicing' ); |
|
| 120 | - $vars['RatesUpdated'] = __( 'The rates have been updated. Press the save button to record these new rates.', 'invoicing' ); |
|
| 121 | - $vars['IPAddressInformation'] = __( 'IP Address Information', 'invoicing' ); |
|
| 122 | - $vars['VatValidating'] = wp_sprintf( __( 'Validating %s number...', 'invoicing' ), $vat_name ); |
|
| 123 | - $vars['VatReseting'] = __( 'Reseting...', 'invoicing' ); |
|
| 124 | - $vars['VatValidated'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name ); |
|
| 125 | - $vars['VatNotValidated'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name ); |
|
| 126 | - $vars['ConfirmDeleteClass'] = __( 'Are you sure you wish to delete this rates class?', 'invoicing' ); |
|
| 114 | + $vars['ErrResponse'] = __('The request response is invalid!', 'invoicing'); |
|
| 115 | + $vars['ErrRateResponse'] = __('The get rate request response is invalid', 'invoicing'); |
|
| 116 | + $vars['PageRefresh'] = __('The page will be refreshed in 10 seconds to show the new options.', 'invoicing'); |
|
| 117 | + $vars['RequestResponseNotValidJSON'] = __('The get rate request response is not valid JSON', 'invoicing'); |
|
| 118 | + $vars['GetRateRequestFailed'] = __('The get rate request failed: ', 'invoicing'); |
|
| 119 | + $vars['NoRateInformationInResponse'] = __('The get rate request response does not contain any rate information', 'invoicing'); |
|
| 120 | + $vars['RatesUpdated'] = __('The rates have been updated. Press the save button to record these new rates.', 'invoicing'); |
|
| 121 | + $vars['IPAddressInformation'] = __('IP Address Information', 'invoicing'); |
|
| 122 | + $vars['VatValidating'] = wp_sprintf(__('Validating %s number...', 'invoicing'), $vat_name); |
|
| 123 | + $vars['VatReseting'] = __('Reseting...', 'invoicing'); |
|
| 124 | + $vars['VatValidated'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name); |
|
| 125 | + $vars['VatNotValidated'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name); |
|
| 126 | + $vars['ConfirmDeleteClass'] = __('Are you sure you wish to delete this rates class?', 'invoicing'); |
|
| 127 | 127 | $vars['isFront'] = is_admin() ? false : true; |
| 128 | 128 | $vars['baseCountry'] = wpinv_get_default_country(); |
| 129 | - $vars['disableVATSameCountry'] = ( self::same_country_rule() == 'no' ? true : false ); |
|
| 130 | - $vars['disableVATSimpleCheck'] = wpinv_get_option( 'vat_offline_check' ) ? true : false; |
|
| 129 | + $vars['disableVATSameCountry'] = (self::same_country_rule() == 'no' ? true : false); |
|
| 130 | + $vars['disableVATSimpleCheck'] = wpinv_get_option('vat_offline_check') ? true : false; |
|
| 131 | 131 | |
| 132 | - wp_enqueue_script( 'wpinv-vat-validation-script' ); |
|
| 133 | - wp_enqueue_script( 'wpinv-vat-script' ); |
|
| 134 | - wp_localize_script( 'wpinv-vat-script', 'WPInv_VAT_Vars', $vars ); |
|
| 132 | + wp_enqueue_script('wpinv-vat-validation-script'); |
|
| 133 | + wp_enqueue_script('wpinv-vat-script'); |
|
| 134 | + wp_localize_script('wpinv-vat-script', 'WPInv_VAT_Vars', $vars); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | public static function enqueue_admin_scripts() { |
| 138 | - if( isset( $_GET['page'] ) && 'wpinv-settings' == $_GET['page'] ) { |
|
| 138 | + if (isset($_GET['page']) && 'wpinv-settings' == $_GET['page']) { |
|
| 139 | 139 | self::load_vat_scripts(); |
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - public static function section_vat_settings( $sections ) { |
|
| 144 | - if ( !empty( $sections ) ) { |
|
| 145 | - $sections['vat'] = __( 'EU VAT Settings', 'invoicing' ); |
|
| 143 | + public static function section_vat_settings($sections) { |
|
| 144 | + if (!empty($sections)) { |
|
| 145 | + $sections['vat'] = __('EU VAT Settings', 'invoicing'); |
|
| 146 | 146 | |
| 147 | - if ( self::allow_vat_classes() ) { |
|
| 148 | - $sections['vat_rates'] = __( 'EU VAT Rates', 'invoicing' ); |
|
| 147 | + if (self::allow_vat_classes()) { |
|
| 148 | + $sections['vat_rates'] = __('EU VAT Rates', 'invoicing'); |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | return $sections; |
@@ -154,52 +154,52 @@ discard block |
||
| 154 | 154 | public static function vat_rates_settings() { |
| 155 | 155 | $vat_classes = self::get_rate_classes(); |
| 156 | 156 | $vat_rates = array(); |
| 157 | - $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '_new'; |
|
| 158 | - $current_url = remove_query_arg( 'wpi_sub' ); |
|
| 157 | + $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '_new'; |
|
| 158 | + $current_url = remove_query_arg('wpi_sub'); |
|
| 159 | 159 | |
| 160 | 160 | $vat_rates['vat_rates_header'] = array( |
| 161 | 161 | 'id' => 'vat_rates_header', |
| 162 | - 'name' => '<h3>' . __( 'Manage VAT Rates', 'invoicing' ) . '</h3>', |
|
| 162 | + 'name' => '<h3>' . __('Manage VAT Rates', 'invoicing') . '</h3>', |
|
| 163 | 163 | 'desc' => '', |
| 164 | 164 | 'type' => 'header', |
| 165 | 165 | 'size' => 'regular' |
| 166 | 166 | ); |
| 167 | 167 | $vat_rates['vat_rates_class'] = array( |
| 168 | 168 | 'id' => 'vat_rates_class', |
| 169 | - 'name' => __( 'Edit VAT Rates', 'invoicing' ), |
|
| 170 | - 'desc' => __( 'The standard rate will apply where no explicit rate is provided.', 'invoicing' ), |
|
| 169 | + 'name' => __('Edit VAT Rates', 'invoicing'), |
|
| 170 | + 'desc' => __('The standard rate will apply where no explicit rate is provided.', 'invoicing'), |
|
| 171 | 171 | 'type' => 'select', |
| 172 | - 'options' => array_merge( $vat_classes, array( '_new' => __( 'Add New Rate Class', 'invoicing' ) ) ), |
|
| 173 | - 'placeholder' => __( 'Select a VAT Rate', 'invoicing' ), |
|
| 172 | + 'options' => array_merge($vat_classes, array('_new' => __('Add New Rate Class', 'invoicing'))), |
|
| 173 | + 'placeholder' => __('Select a VAT Rate', 'invoicing'), |
|
| 174 | 174 | 'selected' => $vat_class, |
| 175 | 175 | 'class' => 'wpi_select2', |
| 176 | 176 | 'onchange' => 'document.location.href="' . $current_url . '&wpi_sub=" + this.value;', |
| 177 | 177 | ); |
| 178 | 178 | |
| 179 | - if ( $vat_class != '_standard' && $vat_class != '_new' ) { |
|
| 179 | + if ($vat_class != '_standard' && $vat_class != '_new') { |
|
| 180 | 180 | $vat_rates['vat_rate_delete'] = array( |
| 181 | 181 | 'id' => 'vat_rate_delete', |
| 182 | 182 | 'type' => 'vat_rate_delete', |
| 183 | 183 | ); |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - if ( $vat_class == '_new' ) { |
|
| 186 | + if ($vat_class == '_new') { |
|
| 187 | 187 | $vat_rates['vat_rates_settings'] = array( |
| 188 | 188 | 'id' => 'vat_rates_settings', |
| 189 | - 'name' => '<h3>' . __( 'Add New Rate Class', 'invoicing' ) . '</h3>', |
|
| 189 | + 'name' => '<h3>' . __('Add New Rate Class', 'invoicing') . '</h3>', |
|
| 190 | 190 | 'type' => 'header', |
| 191 | 191 | ); |
| 192 | 192 | $vat_rates['vat_rate_name'] = array( |
| 193 | 193 | 'id' => 'vat_rate_name', |
| 194 | - 'name' => __( 'Name', 'invoicing' ), |
|
| 195 | - 'desc' => __( 'A short name for the new VAT Rate class', 'invoicing' ), |
|
| 194 | + 'name' => __('Name', 'invoicing'), |
|
| 195 | + 'desc' => __('A short name for the new VAT Rate class', 'invoicing'), |
|
| 196 | 196 | 'type' => 'text', |
| 197 | 197 | 'size' => 'regular', |
| 198 | 198 | ); |
| 199 | 199 | $vat_rates['vat_rate_desc'] = array( |
| 200 | 200 | 'id' => 'vat_rate_desc', |
| 201 | - 'name' => __( 'Description', 'invoicing' ), |
|
| 202 | - 'desc' => __( 'Manage VAT Rate class', 'invoicing' ), |
|
| 201 | + 'name' => __('Description', 'invoicing'), |
|
| 202 | + 'desc' => __('Manage VAT Rate class', 'invoicing'), |
|
| 203 | 203 | 'type' => 'text', |
| 204 | 204 | 'size' => 'regular', |
| 205 | 205 | ); |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | $vat_rates['vat_rates'] = array( |
| 212 | 212 | 'id' => 'vat_rates', |
| 213 | 213 | 'name' => '<h3>' . $vat_classes[$vat_class] . '</h3>', |
| 214 | - 'desc' => self::get_class_desc( $vat_class ), |
|
| 214 | + 'desc' => self::get_class_desc($vat_class), |
|
| 215 | 215 | 'type' => 'vat_rates', |
| 216 | 216 | ); |
| 217 | 217 | } |
@@ -219,12 +219,12 @@ discard block |
||
| 219 | 219 | return $vat_rates; |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - public static function vat_settings( $settings ) { |
|
| 223 | - if ( !empty( $settings ) ) { |
|
| 222 | + public static function vat_settings($settings) { |
|
| 223 | + if (!empty($settings)) { |
|
| 224 | 224 | $vat_settings = array(); |
| 225 | 225 | $vat_settings['vat_company_title'] = array( |
| 226 | 226 | 'id' => 'vat_company_title', |
| 227 | - 'name' => '<h3>' . __( 'Your Company Details', 'invoicing' ) . '</h3>', |
|
| 227 | + 'name' => '<h3>' . __('Your Company Details', 'invoicing') . '</h3>', |
|
| 228 | 228 | 'desc' => '', |
| 229 | 229 | 'type' => 'header', |
| 230 | 230 | 'size' => 'regular' |
@@ -232,22 +232,22 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | $vat_settings['vat_company_name'] = array( |
| 234 | 234 | 'id' => 'vat_company_name', |
| 235 | - 'name' => __( 'Your Company Name', 'invoicing' ), |
|
| 236 | - 'desc' => wp_sprintf(__( 'Your company name as it appears on your VAT return, you can verify it via your VAT ID on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
| 235 | + 'name' => __('Your Company Name', 'invoicing'), |
|
| 236 | + 'desc' => wp_sprintf(__('Your company name as it appears on your VAT return, you can verify it via your VAT ID on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
| 237 | 237 | 'type' => 'text', |
| 238 | 238 | 'size' => 'regular', |
| 239 | 239 | ); |
| 240 | 240 | |
| 241 | 241 | $vat_settings['vat_number'] = array( |
| 242 | 242 | 'id' => 'vat_number', |
| 243 | - 'name' => __( 'Your VAT Number', 'invoicing' ), |
|
| 243 | + 'name' => __('Your VAT Number', 'invoicing'), |
|
| 244 | 244 | 'type' => 'vat_number', |
| 245 | 245 | 'size' => 'regular', |
| 246 | 246 | ); |
| 247 | 247 | |
| 248 | 248 | $vat_settings['vat_settings_title'] = array( |
| 249 | 249 | 'id' => 'vat_settings_title', |
| 250 | - 'name' => '<h3>' . __( 'Apply VAT Settings', 'invoicing' ) . '</h3>', |
|
| 250 | + 'name' => '<h3>' . __('Apply VAT Settings', 'invoicing') . '</h3>', |
|
| 251 | 251 | 'desc' => '', |
| 252 | 252 | 'type' => 'header', |
| 253 | 253 | 'size' => 'regular' |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | $vat_settings['apply_vat_rules'] = array( |
| 257 | 257 | 'id' => 'apply_vat_rules', |
| 258 | - 'name' => __( 'Enable VAT Rules', 'invoicing' ), |
|
| 259 | - 'desc' => __( 'Apply VAT to consumer sales from IP addresses within the EU, even if the billing address is outside the EU.', 'invoicing' ) . '<br><font style="color:red">' . __( 'Do not disable unless you know what you are doing.', 'invoicing' ) . '</font>', |
|
| 258 | + 'name' => __('Enable VAT Rules', 'invoicing'), |
|
| 259 | + 'desc' => __('Apply VAT to consumer sales from IP addresses within the EU, even if the billing address is outside the EU.', 'invoicing') . '<br><font style="color:red">' . __('Do not disable unless you know what you are doing.', 'invoicing') . '</font>', |
|
| 260 | 260 | 'type' => 'checkbox', |
| 261 | 261 | 'std' => '1' |
| 262 | 262 | ); |
@@ -272,8 +272,8 @@ discard block |
||
| 272 | 272 | |
| 273 | 273 | $vat_settings['vat_prevent_b2c_purchase'] = array( |
| 274 | 274 | 'id' => 'vat_prevent_b2c_purchase', |
| 275 | - 'name' => __( 'Prevent EU B2C Sales', 'invoicing' ), |
|
| 276 | - 'desc' => __( 'Enable this option if you are not registered for VAT in the EU.', 'invoicing' ), |
|
| 275 | + 'name' => __('Prevent EU B2C Sales', 'invoicing'), |
|
| 276 | + 'desc' => __('Enable this option if you are not registered for VAT in the EU.', 'invoicing'), |
|
| 277 | 277 | 'type' => 'checkbox' |
| 278 | 278 | ); |
| 279 | 279 | |
@@ -281,22 +281,22 @@ discard block |
||
| 281 | 281 | |
| 282 | 282 | $vat_settings['vat_same_country_rule'] = array( |
| 283 | 283 | 'id' => 'vat_same_country_rule', |
| 284 | - 'name' => __( 'Same Country Rule', 'invoicing' ), |
|
| 285 | - 'desc' => __( 'Select how you want to handle VAT charge if sales are in the same country as the base country.', 'invoicing' ), |
|
| 284 | + 'name' => __('Same Country Rule', 'invoicing'), |
|
| 285 | + 'desc' => __('Select how you want to handle VAT charge if sales are in the same country as the base country.', 'invoicing'), |
|
| 286 | 286 | 'type' => 'select', |
| 287 | 287 | 'options' => array( |
| 288 | - '' => __( 'Normal', 'invoicing' ), |
|
| 289 | - 'no' => __( 'No VAT', 'invoicing' ), |
|
| 290 | - 'always' => __( 'Always apply VAT', 'invoicing' ), |
|
| 288 | + '' => __('Normal', 'invoicing'), |
|
| 289 | + 'no' => __('No VAT', 'invoicing'), |
|
| 290 | + 'always' => __('Always apply VAT', 'invoicing'), |
|
| 291 | 291 | ), |
| 292 | - 'placeholder' => __( 'Select an option', 'invoicing' ), |
|
| 292 | + 'placeholder' => __('Select an option', 'invoicing'), |
|
| 293 | 293 | 'std' => '', |
| 294 | 294 | 'class' => 'wpi_select2', |
| 295 | 295 | ); |
| 296 | 296 | |
| 297 | 297 | $vat_settings['vat_checkout_title'] = array( |
| 298 | 298 | 'id' => 'vat_checkout_title', |
| 299 | - 'name' => '<h3>' . __( 'Checkout Fields', 'invoicing' ) . '</h3>', |
|
| 299 | + 'name' => '<h3>' . __('Checkout Fields', 'invoicing') . '</h3>', |
|
| 300 | 300 | 'desc' => '', |
| 301 | 301 | 'type' => 'header', |
| 302 | 302 | 'size' => 'regular' |
@@ -304,22 +304,22 @@ discard block |
||
| 304 | 304 | |
| 305 | 305 | $vat_settings['vat_disable_fields'] = array( |
| 306 | 306 | 'id' => 'vat_disable_fields', |
| 307 | - 'name' => __( 'Disable VAT Fields', 'invoicing' ), |
|
| 308 | - 'desc' => __( 'Disable VAT fields if Invoicing is being used for GST.', 'invoicing' ) . '<br><font style="color:red">' . __( 'Do not disable if you have enabled Prevent EU B2C sales, otherwise Prevent EU B2C sales setting will not work.', 'invoicing' ) . '</font>', |
|
| 307 | + 'name' => __('Disable VAT Fields', 'invoicing'), |
|
| 308 | + 'desc' => __('Disable VAT fields if Invoicing is being used for GST.', 'invoicing') . '<br><font style="color:red">' . __('Do not disable if you have enabled Prevent EU B2C sales, otherwise Prevent EU B2C sales setting will not work.', 'invoicing') . '</font>', |
|
| 309 | 309 | 'type' => 'checkbox' |
| 310 | 310 | ); |
| 311 | 311 | |
| 312 | 312 | $vat_settings['maxmind_license_key'] = array( |
| 313 | 313 | 'id' => 'maxmind_license_key', |
| 314 | - 'name' => __( 'MaxMind License Key', 'invoicing' ), |
|
| 314 | + 'name' => __('MaxMind License Key', 'invoicing'), |
|
| 315 | 315 | 'type' => 'text', |
| 316 | 316 | 'size' => 'regular', |
| 317 | - 'desc' => '<a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __( 'The key that will be used when dealing with MaxMind Geolocation services.', 'invoicing' ) . '</a>', |
|
| 317 | + 'desc' => '<a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __('The key that will be used when dealing with MaxMind Geolocation services.', 'invoicing') . '</a>', |
|
| 318 | 318 | ); |
| 319 | 319 | |
| 320 | 320 | $vat_settings['vat_ip_lookup'] = array( |
| 321 | 321 | 'id' => 'vat_ip_lookup', |
| 322 | - 'name' => __( 'IP Country Look-up', 'invoicing' ), |
|
| 322 | + 'name' => __('IP Country Look-up', 'invoicing'), |
|
| 323 | 323 | 'type' => 'vat_ip_lookup', |
| 324 | 324 | 'size' => 'regular', |
| 325 | 325 | 'std' => 'default', |
@@ -328,14 +328,14 @@ discard block |
||
| 328 | 328 | |
| 329 | 329 | $vat_settings['vat_ip_country_default'] = array( |
| 330 | 330 | 'id' => 'vat_ip_country_default', |
| 331 | - 'name' => __( 'Enable IP Country as Default', 'invoicing' ), |
|
| 332 | - 'desc' => __( 'Show the country of the users IP as the default country, otherwise the site default country will be used.', 'invoicing' ), |
|
| 331 | + 'name' => __('Enable IP Country as Default', 'invoicing'), |
|
| 332 | + 'desc' => __('Show the country of the users IP as the default country, otherwise the site default country will be used.', 'invoicing'), |
|
| 333 | 333 | 'type' => 'checkbox' |
| 334 | 334 | ); |
| 335 | 335 | |
| 336 | 336 | $vat_settings['vies_validation_title'] = array( |
| 337 | 337 | 'id' => 'vies_validation_title', |
| 338 | - 'name' => '<h3>' . __( 'VIES Validation', 'invoicing' ) . '</h3>', |
|
| 338 | + 'name' => '<h3>' . __('VIES Validation', 'invoicing') . '</h3>', |
|
| 339 | 339 | 'desc' => '', |
| 340 | 340 | 'type' => 'header', |
| 341 | 341 | 'size' => 'regular' |
@@ -343,37 +343,37 @@ discard block |
||
| 343 | 343 | |
| 344 | 344 | $vat_settings['vat_vies_check'] = array( |
| 345 | 345 | 'id' => 'vat_vies_check', |
| 346 | - 'name' => __( 'Disable VIES VAT ID Check', 'invoicing' ), |
|
| 347 | - 'desc' => wp_sprintf( __( 'Prevent VAT numbers from being validated by the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
| 346 | + 'name' => __('Disable VIES VAT ID Check', 'invoicing'), |
|
| 347 | + 'desc' => wp_sprintf(__('Prevent VAT numbers from being validated by the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
| 348 | 348 | 'type' => 'checkbox' |
| 349 | 349 | ); |
| 350 | 350 | |
| 351 | 351 | $vat_settings['vat_disable_company_name_check'] = array( |
| 352 | 352 | 'id' => 'vat_disable_company_name_check', |
| 353 | - 'name' => __( 'Disable VIES Name Check', 'invoicing' ), |
|
| 354 | - 'desc' => wp_sprintf( __( 'Prevent company name from being validated by the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
| 353 | + 'name' => __('Disable VIES Name Check', 'invoicing'), |
|
| 354 | + 'desc' => wp_sprintf(__('Prevent company name from being validated by the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
| 355 | 355 | 'type' => 'checkbox' |
| 356 | 356 | ); |
| 357 | 357 | |
| 358 | 358 | $vat_settings['vat_offline_check'] = array( |
| 359 | 359 | 'id' => 'vat_offline_check', |
| 360 | - 'name' => __( 'Disable Basic Checks', 'invoicing' ), |
|
| 361 | - 'desc' => __( 'Disable basic JS checks for correct format of VAT number. (Not Recommended)', 'invoicing' ), |
|
| 360 | + 'name' => __('Disable Basic Checks', 'invoicing'), |
|
| 361 | + 'desc' => __('Disable basic JS checks for correct format of VAT number. (Not Recommended)', 'invoicing'), |
|
| 362 | 362 | 'type' => 'checkbox' |
| 363 | 363 | ); |
| 364 | 364 | |
| 365 | 365 | |
| 366 | 366 | $settings['vat'] = $vat_settings; |
| 367 | 367 | |
| 368 | - if ( self::allow_vat_classes() ) { |
|
| 368 | + if (self::allow_vat_classes()) { |
|
| 369 | 369 | $settings['vat_rates'] = self::vat_rates_settings(); |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | $eu_fallback_rate = array( |
| 373 | 373 | 'id' => 'eu_fallback_rate', |
| 374 | - 'name' => '<h3>' . __( 'VAT rate for EU member states', 'invoicing' ) . '</h3>', |
|
| 374 | + 'name' => '<h3>' . __('VAT rate for EU member states', 'invoicing') . '</h3>', |
|
| 375 | 375 | 'type' => 'eu_fallback_rate', |
| 376 | - 'desc' => __( 'Enter the VAT rate to be charged for EU member states. You can edit the rates for each member state when a country rate has been set up by pressing this button.', 'invoicing' ), |
|
| 376 | + 'desc' => __('Enter the VAT rate to be charged for EU member states. You can edit the rates for each member state when a country rate has been set up by pressing this button.', 'invoicing'), |
|
| 377 | 377 | 'std' => '20', |
| 378 | 378 | 'size' => 'small' |
| 379 | 379 | ); |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | */ |
| 389 | 389 | public static function maxmind_folder() { |
| 390 | 390 | |
| 391 | - $upload_dir = wp_upload_dir(); |
|
| 391 | + $upload_dir = wp_upload_dir(); |
|
| 392 | 392 | return $upload_dir['basedir'] . '/invoicing'; |
| 393 | 393 | |
| 394 | 394 | } |
@@ -405,39 +405,39 @@ discard block |
||
| 405 | 405 | WP_Filesystem(); |
| 406 | 406 | global $wp_filesystem; |
| 407 | 407 | |
| 408 | - $license_key = wpinv_get_option( 'maxmind_license_key' ); |
|
| 408 | + $license_key = wpinv_get_option('maxmind_license_key'); |
|
| 409 | 409 | |
| 410 | - if ( empty( $license_key ) ) { |
|
| 411 | - echo __( 'Please enter your MaxMind license key then save the settings first before downloading the databases.', 'invoicing' ); |
|
| 410 | + if (empty($license_key)) { |
|
| 411 | + echo __('Please enter your MaxMind license key then save the settings first before downloading the databases.', 'invoicing'); |
|
| 412 | 412 | exit; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | // The database files that we will download. |
| 416 | - $database_files = array( 'GeoLite2-Country', 'GeoLite2-City' ); |
|
| 416 | + $database_files = array('GeoLite2-Country', 'GeoLite2-City'); |
|
| 417 | 417 | |
| 418 | 418 | // The destination dir of all databases. |
| 419 | 419 | $destination_dir = self::maxmind_folder(); |
| 420 | 420 | |
| 421 | - if ( ! $wp_filesystem->is_dir( $destination_dir ) ) { |
|
| 422 | - $wp_filesystem->mkdir( $destination_dir ); |
|
| 421 | + if (!$wp_filesystem->is_dir($destination_dir)) { |
|
| 422 | + $wp_filesystem->mkdir($destination_dir); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - foreach( $database_files as $database ) { |
|
| 425 | + foreach ($database_files as $database) { |
|
| 426 | 426 | |
| 427 | - $database_path = self::geoip2_download_file( $license_key, $database ); |
|
| 428 | - $target_path = trailingslashit( $destination_dir ) . $database . '.mmdb'; |
|
| 427 | + $database_path = self::geoip2_download_file($license_key, $database); |
|
| 428 | + $target_path = trailingslashit($destination_dir) . $database . '.mmdb'; |
|
| 429 | 429 | |
| 430 | - if ( is_wp_error( $database_path ) ) { |
|
| 430 | + if (is_wp_error($database_path)) { |
|
| 431 | 431 | echo $database_path->get_error_message(); |
| 432 | 432 | exit; |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | // Move the new database into position. |
| 436 | - $wp_filesystem->move( $database_path, $target_path, true ); |
|
| 437 | - $wp_filesystem->delete( dirname( $database_path ) ); |
|
| 436 | + $wp_filesystem->move($database_path, $target_path, true); |
|
| 437 | + $wp_filesystem->delete(dirname($database_path)); |
|
| 438 | 438 | |
| 439 | - wpinv_update_option( 'wpinv_geoip2_date_updated', current_time( 'timestamp' ) ); |
|
| 440 | - echo sprintf( __( 'GeoIP2 %s database updated successfully.', 'invoicing' ), $database ) . ' '; |
|
| 439 | + wpinv_update_option('wpinv_geoip2_date_updated', current_time('timestamp')); |
|
| 440 | + echo sprintf(__('GeoIP2 %s database updated successfully.', 'invoicing'), $database) . ' '; |
|
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | exit; |
@@ -448,12 +448,12 @@ discard block |
||
| 448 | 448 | * |
| 449 | 449 | * @return string|WP_Error |
| 450 | 450 | */ |
| 451 | - public static function geoip2_download_file( $license_key, $database ) { |
|
| 451 | + public static function geoip2_download_file($license_key, $database) { |
|
| 452 | 452 | |
| 453 | 453 | // The download URI of the database. |
| 454 | 454 | $source_url = add_query_arg( |
| 455 | 455 | array( |
| 456 | - 'license_key' => urlencode( sanitize_text_field( $license_key ) ), |
|
| 456 | + 'license_key' => urlencode(sanitize_text_field($license_key)), |
|
| 457 | 457 | 'edition_id' => $database, |
| 458 | 458 | 'suffix' => 'tar.gz', |
| 459 | 459 | ), |
@@ -464,54 +464,54 @@ discard block |
||
| 464 | 464 | require_once ABSPATH . 'wp-admin/includes/file.php'; |
| 465 | 465 | |
| 466 | 466 | // Download the file. |
| 467 | - $tmp_archive_path = download_url( esc_url_raw( $source_url ) ); |
|
| 467 | + $tmp_archive_path = download_url(esc_url_raw($source_url)); |
|
| 468 | 468 | |
| 469 | 469 | // Did we encounter an error? |
| 470 | - if ( is_wp_error( $tmp_archive_path ) ) { |
|
| 470 | + if (is_wp_error($tmp_archive_path)) { |
|
| 471 | 471 | |
| 472 | 472 | // Transform the error into something more informative. |
| 473 | 473 | $error_data = $tmp_archive_path->get_error_data(); |
| 474 | - if ( isset( $error_data['code'] ) ) { |
|
| 475 | - switch ( $error_data['code'] ) { |
|
| 474 | + if (isset($error_data['code'])) { |
|
| 475 | + switch ($error_data['code']) { |
|
| 476 | 476 | case 401: |
| 477 | 477 | return new WP_Error( |
| 478 | 478 | 'invoicing_maxmind_geolocation_database_license_key', |
| 479 | - __( 'The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing' ) |
|
| 479 | + __('The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing') |
|
| 480 | 480 | ); |
| 481 | 481 | } |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | - return new WP_Error( 'invoicing_maxmind_geolocation_database_download', __( 'Failed to download the MaxMind database.', 'invoicing' ) ); |
|
| 484 | + return new WP_Error('invoicing_maxmind_geolocation_database_download', __('Failed to download the MaxMind database.', 'invoicing')); |
|
| 485 | 485 | |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | // Extract the database from the archive. |
| 489 | 489 | try { |
| 490 | - $file = new PharData( $tmp_archive_path ); |
|
| 491 | - $file_path = trailingslashit( dirname( $tmp_archive_path ) ) . trailingslashit( $file->current()->getFilename() ) . $database . '.mmdb'; |
|
| 490 | + $file = new PharData($tmp_archive_path); |
|
| 491 | + $file_path = trailingslashit(dirname($tmp_archive_path)) . trailingslashit($file->current()->getFilename()) . $database . '.mmdb'; |
|
| 492 | 492 | |
| 493 | 493 | $file->extractTo( |
| 494 | - dirname( $tmp_archive_path ), |
|
| 495 | - trailingslashit( $file->current()->getFilename() ) . $database . '.mmdb', |
|
| 494 | + dirname($tmp_archive_path), |
|
| 495 | + trailingslashit($file->current()->getFilename()) . $database . '.mmdb', |
|
| 496 | 496 | true |
| 497 | 497 | ); |
| 498 | 498 | |
| 499 | - } catch ( Exception $exception ) { |
|
| 500 | - return new WP_Error( 'invoicing_maxmind_geolocation_database_archive', $exception->getMessage() ); |
|
| 499 | + } catch (Exception $exception) { |
|
| 500 | + return new WP_Error('invoicing_maxmind_geolocation_database_archive', $exception->getMessage()); |
|
| 501 | 501 | } finally { |
| 502 | 502 | // Remove the archive since we only care about a single file in it. |
| 503 | - unlink( $tmp_archive_path ); |
|
| 503 | + unlink($tmp_archive_path); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | return $file_path; |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | public static function load_geoip2() { |
| 510 | - if ( defined( 'WPINV_GEOIP2_LODDED' ) ) { |
|
| 510 | + if (defined('WPINV_GEOIP2_LODDED')) { |
|
| 511 | 511 | return; |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | - if ( !class_exists( '\MaxMind\Db\Reader' ) ) { |
|
| 514 | + if (!class_exists('\MaxMind\Db\Reader')) { |
|
| 515 | 515 | $maxmind_db_files = array( |
| 516 | 516 | 'Reader/Decoder.php', |
| 517 | 517 | 'Reader/InvalidDatabaseException.php', |
@@ -520,12 +520,12 @@ discard block |
||
| 520 | 520 | 'Reader.php', |
| 521 | 521 | ); |
| 522 | 522 | |
| 523 | - foreach ( $maxmind_db_files as $key => $file ) { |
|
| 524 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/MaxMind/Db/' . $file ); |
|
| 523 | + foreach ($maxmind_db_files as $key => $file) { |
|
| 524 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/MaxMind/Db/' . $file); |
|
| 525 | 525 | } |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | - if ( !class_exists( '\GeoIp2\Database\Reader' ) ) { |
|
| 528 | + if (!class_exists('\GeoIp2\Database\Reader')) { |
|
| 529 | 529 | $geoip2_files = array( |
| 530 | 530 | 'ProviderInterface.php', |
| 531 | 531 | 'Compat/JsonSerializable.php', |
@@ -559,23 +559,23 @@ discard block |
||
| 559 | 559 | 'WebService/Client.php', |
| 560 | 560 | ); |
| 561 | 561 | |
| 562 | - foreach ( $geoip2_files as $key => $file ) { |
|
| 563 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/GeoIp2/' . $file ); |
|
| 562 | + foreach ($geoip2_files as $key => $file) { |
|
| 563 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/GeoIp2/' . $file); |
|
| 564 | 564 | } |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | - define( 'WPINV_GEOIP2_LODDED', true ); |
|
| 567 | + define('WPINV_GEOIP2_LODDED', true); |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | public static function geoip2_country_dbfile() { |
| 571 | 571 | $upload_dir = wp_upload_dir(); |
| 572 | 572 | |
| 573 | - if ( !isset( $upload_dir['basedir'] ) ) { |
|
| 573 | + if (!isset($upload_dir['basedir'])) { |
|
| 574 | 574 | return false; |
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | $filename = $upload_dir['basedir'] . '/invoicing/GeoLite2-Country.mmdb'; |
| 578 | - if ( !file_exists( $filename ) ) { |
|
| 578 | + if (!file_exists($filename)) { |
|
| 579 | 579 | return false; |
| 580 | 580 | } |
| 581 | 581 | |
@@ -585,12 +585,12 @@ discard block |
||
| 585 | 585 | public static function geoip2_city_dbfile() { |
| 586 | 586 | $upload_dir = wp_upload_dir(); |
| 587 | 587 | |
| 588 | - if ( !isset( $upload_dir['basedir'] ) ) { |
|
| 588 | + if (!isset($upload_dir['basedir'])) { |
|
| 589 | 589 | return false; |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | $filename = $upload_dir['basedir'] . '/invoicing/GeoLite2-City.mmdb'; |
| 593 | - if ( !file_exists( $filename ) ) { |
|
| 593 | + if (!file_exists($filename)) { |
|
| 594 | 594 | return false; |
| 595 | 595 | } |
| 596 | 596 | |
@@ -601,10 +601,10 @@ discard block |
||
| 601 | 601 | try { |
| 602 | 602 | self::load_geoip2(); |
| 603 | 603 | |
| 604 | - if ( $filename = self::geoip2_country_dbfile() ) { |
|
| 605 | - return new \GeoIp2\Database\Reader( $filename ); |
|
| 604 | + if ($filename = self::geoip2_country_dbfile()) { |
|
| 605 | + return new \GeoIp2\Database\Reader($filename); |
|
| 606 | 606 | } |
| 607 | - } catch( Exception $e ) { |
|
| 607 | + } catch (Exception $e) { |
|
| 608 | 608 | return false; |
| 609 | 609 | } |
| 610 | 610 | |
@@ -615,183 +615,183 @@ discard block |
||
| 615 | 615 | try { |
| 616 | 616 | self::load_geoip2(); |
| 617 | 617 | |
| 618 | - if ( $filename = self::geoip2_city_dbfile() ) { |
|
| 619 | - return new \GeoIp2\Database\Reader( $filename ); |
|
| 618 | + if ($filename = self::geoip2_city_dbfile()) { |
|
| 619 | + return new \GeoIp2\Database\Reader($filename); |
|
| 620 | 620 | } |
| 621 | - } catch( Exception $e ) { |
|
| 621 | + } catch (Exception $e) { |
|
| 622 | 622 | return false; |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | return false; |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | - public static function geoip2_country_record( $ip_address ) { |
|
| 628 | + public static function geoip2_country_record($ip_address) { |
|
| 629 | 629 | try { |
| 630 | 630 | $reader = self::geoip2_country_reader(); |
| 631 | 631 | |
| 632 | - if ( $reader ) { |
|
| 633 | - $record = $reader->country( $ip_address ); |
|
| 632 | + if ($reader) { |
|
| 633 | + $record = $reader->country($ip_address); |
|
| 634 | 634 | |
| 635 | - if ( !empty( $record->country->isoCode ) ) { |
|
| 635 | + if (!empty($record->country->isoCode)) { |
|
| 636 | 636 | return $record; |
| 637 | 637 | } |
| 638 | 638 | } |
| 639 | - } catch(\InvalidArgumentException $e) { |
|
| 640 | - wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' ); |
|
| 639 | + } catch (\InvalidArgumentException $e) { |
|
| 640 | + wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )'); |
|
| 641 | 641 | |
| 642 | 642 | return false; |
| 643 | - } catch(\GeoIp2\Exception\AddressNotFoundException $e) { |
|
| 644 | - wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' ); |
|
| 643 | + } catch (\GeoIp2\Exception\AddressNotFoundException $e) { |
|
| 644 | + wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )'); |
|
| 645 | 645 | |
| 646 | 646 | return false; |
| 647 | - } catch( Exception $e ) { |
|
| 647 | + } catch (Exception $e) { |
|
| 648 | 648 | return false; |
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | return false; |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | - public static function geoip2_city_record( $ip_address ) { |
|
| 654 | + public static function geoip2_city_record($ip_address) { |
|
| 655 | 655 | try { |
| 656 | 656 | $reader = self::geoip2_city_reader(); |
| 657 | 657 | |
| 658 | - if ( $reader ) { |
|
| 659 | - $record = $reader->city( $ip_address ); |
|
| 658 | + if ($reader) { |
|
| 659 | + $record = $reader->city($ip_address); |
|
| 660 | 660 | |
| 661 | - if ( !empty( $record->country->isoCode ) ) { |
|
| 661 | + if (!empty($record->country->isoCode)) { |
|
| 662 | 662 | return $record; |
| 663 | 663 | } |
| 664 | 664 | } |
| 665 | - } catch(\InvalidArgumentException $e) { |
|
| 666 | - wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' ); |
|
| 665 | + } catch (\InvalidArgumentException $e) { |
|
| 666 | + wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )'); |
|
| 667 | 667 | |
| 668 | 668 | return false; |
| 669 | - } catch(\GeoIp2\Exception\AddressNotFoundException $e) { |
|
| 670 | - wpinv_error_log( $e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )' ); |
|
| 669 | + } catch (\GeoIp2\Exception\AddressNotFoundException $e) { |
|
| 670 | + wpinv_error_log($e->getMessage(), 'GeoIp2 Lookup( ' . $ip_address . ' )'); |
|
| 671 | 671 | |
| 672 | 672 | return false; |
| 673 | - } catch( Exception $e ) { |
|
| 673 | + } catch (Exception $e) { |
|
| 674 | 674 | return false; |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | return false; |
| 678 | 678 | } |
| 679 | 679 | |
| 680 | - public static function geoip2_country_code( $ip_address ) { |
|
| 681 | - $record = self::geoip2_country_record( $ip_address ); |
|
| 682 | - return !empty( $record->country->isoCode ) ? $record->country->isoCode : wpinv_get_default_country(); |
|
| 680 | + public static function geoip2_country_code($ip_address) { |
|
| 681 | + $record = self::geoip2_country_record($ip_address); |
|
| 682 | + return !empty($record->country->isoCode) ? $record->country->isoCode : wpinv_get_default_country(); |
|
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | // Find country by IP address. |
| 686 | - public static function get_country_by_ip( $ip = '' ) { |
|
| 686 | + public static function get_country_by_ip($ip = '') { |
|
| 687 | 687 | global $wpinv_ip_address_country; |
| 688 | 688 | return ''; |
| 689 | - if ( !empty( $wpinv_ip_address_country ) ) { |
|
| 689 | + if (!empty($wpinv_ip_address_country)) { |
|
| 690 | 690 | return $wpinv_ip_address_country; |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | - if ( empty( $ip ) ) { |
|
| 693 | + if (empty($ip)) { |
|
| 694 | 694 | $ip = wpinv_get_ip(); |
| 695 | 695 | } |
| 696 | 696 | |
| 697 | - $ip_country_service = wpinv_get_option( 'vat_ip_lookup' ); |
|
| 698 | - $is_default = empty( $ip_country_service ) || $ip_country_service === 'default' ? true : false; |
|
| 697 | + $ip_country_service = wpinv_get_option('vat_ip_lookup'); |
|
| 698 | + $is_default = empty($ip_country_service) || $ip_country_service === 'default' ? true : false; |
|
| 699 | 699 | |
| 700 | - if ( !empty( $ip ) && $ip !== '127.0.0.1' ) { // For 127.0.0.1(localhost) use default country. |
|
| 701 | - if ( function_exists( 'geoip_country_code_by_name') && ( $ip_country_service === 'geoip' || $is_default ) ) { |
|
| 700 | + if (!empty($ip) && $ip !== '127.0.0.1') { // For 127.0.0.1(localhost) use default country. |
|
| 701 | + if (function_exists('geoip_country_code_by_name') && ($ip_country_service === 'geoip' || $is_default)) { |
|
| 702 | 702 | try { |
| 703 | - $wpinv_ip_address_country = geoip_country_code_by_name( $ip ); |
|
| 704 | - } catch( Exception $e ) { |
|
| 705 | - wpinv_error_log( $e->getMessage(), 'GeoIP Lookup( ' . $ip . ' )' ); |
|
| 703 | + $wpinv_ip_address_country = geoip_country_code_by_name($ip); |
|
| 704 | + } catch (Exception $e) { |
|
| 705 | + wpinv_error_log($e->getMessage(), 'GeoIP Lookup( ' . $ip . ' )'); |
|
| 706 | 706 | } |
| 707 | - } else if ( self::geoip2_country_dbfile() && ( $ip_country_service === 'geoip2' || $is_default ) ) { |
|
| 708 | - $wpinv_ip_address_country = self::geoip2_country_code( $ip ); |
|
| 709 | - } else if ( function_exists( 'simplexml_load_file' ) && ini_get('allow_url_fopen') && ( $ip_country_service === 'geoplugin' || $is_default ) ) { |
|
| 710 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
| 707 | + } else if (self::geoip2_country_dbfile() && ($ip_country_service === 'geoip2' || $is_default)) { |
|
| 708 | + $wpinv_ip_address_country = self::geoip2_country_code($ip); |
|
| 709 | + } else if (function_exists('simplexml_load_file') && ini_get('allow_url_fopen') && ($ip_country_service === 'geoplugin' || $is_default)) { |
|
| 710 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
| 711 | 711 | |
| 712 | - if ( !empty( $load_xml ) && !empty( $load_xml->geoplugin_countryCode ) ) { |
|
| 713 | - $wpinv_ip_address_country = (string)$load_xml->geoplugin_countryCode; |
|
| 712 | + if (!empty($load_xml) && !empty($load_xml->geoplugin_countryCode)) { |
|
| 713 | + $wpinv_ip_address_country = (string) $load_xml->geoplugin_countryCode; |
|
| 714 | 714 | } |
| 715 | - }elseif(!empty( $ip )){ |
|
| 715 | + }elseif (!empty($ip)) { |
|
| 716 | 716 | $url = 'http://ip-api.com/json/' . $ip; |
| 717 | 717 | $response = wp_remote_get($url); |
| 718 | 718 | |
| 719 | - if ( is_array( $response ) && wp_remote_retrieve_response_code( $response ) == '200' ) { |
|
| 720 | - $data = json_decode(wp_remote_retrieve_body( $response ),true); |
|
| 721 | - if(!empty($data['countryCode'])){ |
|
| 722 | - $wpinv_ip_address_country = (string)$data['countryCode']; |
|
| 719 | + if (is_array($response) && wp_remote_retrieve_response_code($response) == '200') { |
|
| 720 | + $data = json_decode(wp_remote_retrieve_body($response), true); |
|
| 721 | + if (!empty($data['countryCode'])) { |
|
| 722 | + $wpinv_ip_address_country = (string) $data['countryCode']; |
|
| 723 | 723 | } |
| 724 | 724 | } |
| 725 | 725 | } |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | - if ( empty( $wpinv_ip_address_country ) ) { |
|
| 728 | + if (empty($wpinv_ip_address_country)) { |
|
| 729 | 729 | $wpinv_ip_address_country = wpinv_get_default_country(); |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | return $wpinv_ip_address_country; |
| 733 | 733 | } |
| 734 | 734 | |
| 735 | - public static function sanitize_vat_settings( $input ) { |
|
| 735 | + public static function sanitize_vat_settings($input) { |
|
| 736 | 736 | global $wpinv_options; |
| 737 | 737 | |
| 738 | 738 | $valid = false; |
| 739 | 739 | $message = ''; |
| 740 | 740 | |
| 741 | - if ( !empty( $wpinv_options['vat_vies_check'] ) ) { |
|
| 742 | - if ( empty( $wpinv_options['vat_offline_check'] ) ) { |
|
| 743 | - $valid = self::offline_check( $input['vat_number'] ); |
|
| 741 | + if (!empty($wpinv_options['vat_vies_check'])) { |
|
| 742 | + if (empty($wpinv_options['vat_offline_check'])) { |
|
| 743 | + $valid = self::offline_check($input['vat_number']); |
|
| 744 | 744 | } else { |
| 745 | 745 | $valid = true; |
| 746 | 746 | } |
| 747 | 747 | |
| 748 | - $message = $valid ? '' : __( 'VAT number not validated', 'invoicing' ); |
|
| 748 | + $message = $valid ? '' : __('VAT number not validated', 'invoicing'); |
|
| 749 | 749 | } else { |
| 750 | - $result = self::check_vat( $input['vat_number'] ); |
|
| 750 | + $result = self::check_vat($input['vat_number']); |
|
| 751 | 751 | |
| 752 | - if ( empty( $result['valid'] ) ) { |
|
| 752 | + if (empty($result['valid'])) { |
|
| 753 | 753 | $valid = false; |
| 754 | 754 | $message = $result['message']; |
| 755 | 755 | } else { |
| 756 | - $valid = ( isset( $result['company'] ) && ( $result['company'] == '---' || ( strcasecmp( trim( $result['company'] ), trim( $input['vat_company_name'] ) ) == 0 ) ) ) || !empty( $wpinv_options['vat_disable_company_name_check'] ); |
|
| 757 | - $message = $valid ? '' : __( 'The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing' ); |
|
| 756 | + $valid = (isset($result['company']) && ($result['company'] == '---' || (strcasecmp(trim($result['company']), trim($input['vat_company_name'])) == 0))) || !empty($wpinv_options['vat_disable_company_name_check']); |
|
| 757 | + $message = $valid ? '' : __('The company name associated with the VAT number provided is not the same as the company name provided.', 'invoicing'); |
|
| 758 | 758 | } |
| 759 | 759 | } |
| 760 | 760 | |
| 761 | - if ( $message && self::is_vat_validated() != $valid ) { |
|
| 762 | - add_settings_error( 'wpinv-notices', '', $message, ( $valid ? 'updated' : 'error' ) ); |
|
| 761 | + if ($message && self::is_vat_validated() != $valid) { |
|
| 762 | + add_settings_error('wpinv-notices', '', $message, ($valid ? 'updated' : 'error')); |
|
| 763 | 763 | } |
| 764 | 764 | |
| 765 | 765 | $input['vat_valid'] = $valid; |
| 766 | 766 | return $input; |
| 767 | 767 | } |
| 768 | 768 | |
| 769 | - public static function sanitize_vat_rates( $input ) { |
|
| 770 | - if( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 771 | - add_settings_error( 'wpinv-notices', '', __( 'Your account does not have permission to add rate classes.', 'invoicing' ), 'error' ); |
|
| 769 | + public static function sanitize_vat_rates($input) { |
|
| 770 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 771 | + add_settings_error('wpinv-notices', '', __('Your account does not have permission to add rate classes.', 'invoicing'), 'error'); |
|
| 772 | 772 | return $input; |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | $vat_classes = self::get_rate_classes(); |
| 776 | - $vat_class = !empty( $_REQUEST['wpi_vat_class'] ) && isset( $vat_classes[$_REQUEST['wpi_vat_class']] )? sanitize_text_field( $_REQUEST['wpi_vat_class'] ) : ''; |
|
| 776 | + $vat_class = !empty($_REQUEST['wpi_vat_class']) && isset($vat_classes[$_REQUEST['wpi_vat_class']]) ? sanitize_text_field($_REQUEST['wpi_vat_class']) : ''; |
|
| 777 | 777 | |
| 778 | - if ( empty( $vat_class ) ) { |
|
| 779 | - add_settings_error( 'wpinv-notices', '', __( 'No valid VAT rates class contained in the request to save rates.', 'invoicing' ), 'error' ); |
|
| 778 | + if (empty($vat_class)) { |
|
| 779 | + add_settings_error('wpinv-notices', '', __('No valid VAT rates class contained in the request to save rates.', 'invoicing'), 'error'); |
|
| 780 | 780 | |
| 781 | 781 | return $input; |
| 782 | 782 | } |
| 783 | 783 | |
| 784 | - $new_rates = ! empty( $_POST['vat_rates'] ) ? array_values( $_POST['vat_rates'] ) : array(); |
|
| 784 | + $new_rates = !empty($_POST['vat_rates']) ? array_values($_POST['vat_rates']) : array(); |
|
| 785 | 785 | |
| 786 | - if ( $vat_class === '_standard' ) { |
|
| 786 | + if ($vat_class === '_standard') { |
|
| 787 | 787 | // Save the active rates in the invoice settings |
| 788 | - update_option( 'wpinv_tax_rates', $new_rates ); |
|
| 788 | + update_option('wpinv_tax_rates', $new_rates); |
|
| 789 | 789 | } else { |
| 790 | 790 | // Get the existing set of rates |
| 791 | 791 | $rates = self::get_non_standard_rates(); |
| 792 | 792 | $rates[$vat_class] = $new_rates; |
| 793 | 793 | |
| 794 | - update_option( 'wpinv_vat_rates', $rates ); |
|
| 794 | + update_option('wpinv_vat_rates', $rates); |
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | return $input; |
@@ -801,71 +801,71 @@ discard block |
||
| 801 | 801 | $response = array(); |
| 802 | 802 | $response['success'] = false; |
| 803 | 803 | |
| 804 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 805 | - $response['error'] = __( 'Invalid access!', 'invoicing' ); |
|
| 806 | - wp_send_json( $response ); |
|
| 804 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 805 | + $response['error'] = __('Invalid access!', 'invoicing'); |
|
| 806 | + wp_send_json($response); |
|
| 807 | 807 | } |
| 808 | 808 | |
| 809 | - $vat_class_name = !empty( $_POST['name'] ) ? sanitize_text_field( $_POST['name'] ) : false; |
|
| 810 | - $vat_class_desc = !empty( $_POST['desc'] ) ? sanitize_text_field( $_POST['desc'] ) : false; |
|
| 809 | + $vat_class_name = !empty($_POST['name']) ? sanitize_text_field($_POST['name']) : false; |
|
| 810 | + $vat_class_desc = !empty($_POST['desc']) ? sanitize_text_field($_POST['desc']) : false; |
|
| 811 | 811 | |
| 812 | - if ( empty( $vat_class_name ) ) { |
|
| 813 | - $response['error'] = __( 'Select the VAT rate name', 'invoicing' ); |
|
| 814 | - wp_send_json( $response ); |
|
| 812 | + if (empty($vat_class_name)) { |
|
| 813 | + $response['error'] = __('Select the VAT rate name', 'invoicing'); |
|
| 814 | + wp_send_json($response); |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | - $vat_classes = (array)self::get_rate_classes(); |
|
| 817 | + $vat_classes = (array) self::get_rate_classes(); |
|
| 818 | 818 | |
| 819 | - if ( !empty( $vat_classes ) && in_array( strtolower( $vat_class_name ), array_map( 'strtolower', array_values( $vat_classes ) ) ) ) { |
|
| 820 | - $response['error'] = wp_sprintf( __( 'A VAT Rate name "%s" already exists', 'invoicing' ), $vat_class_name ); |
|
| 821 | - wp_send_json( $response ); |
|
| 819 | + if (!empty($vat_classes) && in_array(strtolower($vat_class_name), array_map('strtolower', array_values($vat_classes)))) { |
|
| 820 | + $response['error'] = wp_sprintf(__('A VAT Rate name "%s" already exists', 'invoicing'), $vat_class_name); |
|
| 821 | + wp_send_json($response); |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | - $rate_class_key = normalize_whitespace( 'wpi-' . $vat_class_name ); |
|
| 825 | - $rate_class_key = sanitize_key( str_replace( " ", "-", $rate_class_key ) ); |
|
| 824 | + $rate_class_key = normalize_whitespace('wpi-' . $vat_class_name); |
|
| 825 | + $rate_class_key = sanitize_key(str_replace(" ", "-", $rate_class_key)); |
|
| 826 | 826 | |
| 827 | - $vat_classes = (array)self::get_rate_classes( true ); |
|
| 828 | - $vat_classes[$rate_class_key] = array( 'name' => $vat_class_name, 'desc' => $vat_class_desc ); |
|
| 827 | + $vat_classes = (array) self::get_rate_classes(true); |
|
| 828 | + $vat_classes[$rate_class_key] = array('name' => $vat_class_name, 'desc' => $vat_class_desc); |
|
| 829 | 829 | |
| 830 | - update_option( '_wpinv_vat_rate_classes', $vat_classes ); |
|
| 830 | + update_option('_wpinv_vat_rate_classes', $vat_classes); |
|
| 831 | 831 | |
| 832 | 832 | $response['success'] = true; |
| 833 | - $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=' . $rate_class_key ); |
|
| 833 | + $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=' . $rate_class_key); |
|
| 834 | 834 | |
| 835 | - wp_send_json( $response ); |
|
| 835 | + wp_send_json($response); |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | public static function delete_class() { |
| 839 | 839 | $response = array(); |
| 840 | 840 | $response['success'] = false; |
| 841 | 841 | |
| 842 | - if ( !wpinv_current_user_can_manage_invoicing() || !isset( $_POST['class'] ) ) { |
|
| 843 | - $response['error'] = __( 'Invalid access!', 'invoicing' ); |
|
| 844 | - wp_send_json( $response ); |
|
| 842 | + if (!wpinv_current_user_can_manage_invoicing() || !isset($_POST['class'])) { |
|
| 843 | + $response['error'] = __('Invalid access!', 'invoicing'); |
|
| 844 | + wp_send_json($response); |
|
| 845 | 845 | } |
| 846 | 846 | |
| 847 | - $vat_class = isset( $_POST['class'] ) && $_POST['class'] !== '' ? sanitize_text_field( $_POST['class'] ) : false; |
|
| 848 | - $vat_classes = (array)self::get_rate_classes(); |
|
| 847 | + $vat_class = isset($_POST['class']) && $_POST['class'] !== '' ? sanitize_text_field($_POST['class']) : false; |
|
| 848 | + $vat_classes = (array) self::get_rate_classes(); |
|
| 849 | 849 | |
| 850 | - if ( !isset( $vat_classes[$vat_class] ) ) { |
|
| 851 | - $response['error'] = __( 'Requested class does not exists', 'invoicing' ); |
|
| 852 | - wp_send_json( $response ); |
|
| 850 | + if (!isset($vat_classes[$vat_class])) { |
|
| 851 | + $response['error'] = __('Requested class does not exists', 'invoicing'); |
|
| 852 | + wp_send_json($response); |
|
| 853 | 853 | } |
| 854 | 854 | |
| 855 | - if ( $vat_class == '_new' || $vat_class == '_standard' ) { |
|
| 856 | - $response['error'] = __( 'You can not delete standard rates class', 'invoicing' ); |
|
| 857 | - wp_send_json( $response ); |
|
| 855 | + if ($vat_class == '_new' || $vat_class == '_standard') { |
|
| 856 | + $response['error'] = __('You can not delete standard rates class', 'invoicing'); |
|
| 857 | + wp_send_json($response); |
|
| 858 | 858 | } |
| 859 | 859 | |
| 860 | - $vat_classes = (array)self::get_rate_classes( true ); |
|
| 861 | - unset( $vat_classes[$vat_class] ); |
|
| 860 | + $vat_classes = (array) self::get_rate_classes(true); |
|
| 861 | + unset($vat_classes[$vat_class]); |
|
| 862 | 862 | |
| 863 | - update_option( '_wpinv_vat_rate_classes', $vat_classes ); |
|
| 863 | + update_option('_wpinv_vat_rate_classes', $vat_classes); |
|
| 864 | 864 | |
| 865 | 865 | $response['success'] = true; |
| 866 | - $response['redirect'] = admin_url( 'admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=_new' ); |
|
| 866 | + $response['redirect'] = admin_url('admin.php?page=wpinv-settings&tab=taxes§ion=vat_rates&wpi_sub=_new'); |
|
| 867 | 867 | |
| 868 | - wp_send_json( $response ); |
|
| 868 | + wp_send_json($response); |
|
| 869 | 869 | } |
| 870 | 870 | |
| 871 | 871 | public static function update_eu_rates() { |
@@ -874,73 +874,73 @@ discard block |
||
| 874 | 874 | $response['error'] = null; |
| 875 | 875 | $response['data'] = null; |
| 876 | 876 | |
| 877 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
| 878 | - $response['error'] = __( 'Invalid access!', 'invoicing' ); |
|
| 879 | - wp_send_json( $response ); |
|
| 877 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 878 | + $response['error'] = __('Invalid access!', 'invoicing'); |
|
| 879 | + wp_send_json($response); |
|
| 880 | 880 | } |
| 881 | 881 | |
| 882 | - $group = !empty( $_POST['group'] ) ? sanitize_text_field( $_POST['group'] ) : ''; |
|
| 883 | - $euvatrates = self::request_euvatrates( $group ); |
|
| 882 | + $group = !empty($_POST['group']) ? sanitize_text_field($_POST['group']) : ''; |
|
| 883 | + $euvatrates = self::request_euvatrates($group); |
|
| 884 | 884 | |
| 885 | - if ( !empty( $euvatrates ) ) { |
|
| 886 | - if ( !empty( $euvatrates['success'] ) && !empty( $euvatrates['rates'] ) ) { |
|
| 885 | + if (!empty($euvatrates)) { |
|
| 886 | + if (!empty($euvatrates['success']) && !empty($euvatrates['rates'])) { |
|
| 887 | 887 | $response['success'] = true; |
| 888 | 888 | $response['data']['rates'] = $euvatrates['rates']; |
| 889 | - } else if ( !empty( $euvatrates['error'] ) ) { |
|
| 889 | + } else if (!empty($euvatrates['error'])) { |
|
| 890 | 890 | $response['error'] = $euvatrates['error']; |
| 891 | 891 | } |
| 892 | 892 | } |
| 893 | 893 | |
| 894 | - wp_send_json( $response ); |
|
| 894 | + wp_send_json($response); |
|
| 895 | 895 | } |
| 896 | 896 | |
| 897 | 897 | public static function hide_vat_fields() { |
| 898 | - $hide = wpinv_get_option( 'vat_disable_fields' ); |
|
| 898 | + $hide = wpinv_get_option('vat_disable_fields'); |
|
| 899 | 899 | |
| 900 | - return apply_filters( 'wpinv_hide_vat_fields', $hide ); |
|
| 900 | + return apply_filters('wpinv_hide_vat_fields', $hide); |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | public static function same_country_rule() { |
| 904 | - $same_country_rule = wpinv_get_option( 'vat_same_country_rule' ); |
|
| 904 | + $same_country_rule = wpinv_get_option('vat_same_country_rule'); |
|
| 905 | 905 | |
| 906 | - return apply_filters( 'wpinv_vat_same_country_rule', $same_country_rule ); |
|
| 906 | + return apply_filters('wpinv_vat_same_country_rule', $same_country_rule); |
|
| 907 | 907 | } |
| 908 | 908 | |
| 909 | 909 | /** |
| 910 | 910 | * Retrieves the vat name. |
| 911 | 911 | */ |
| 912 | 912 | public function get_vat_name() { |
| 913 | - $vat_name = wpinv_get_option( 'vat_name' ); |
|
| 914 | - return empty( $vat_name ) ? __( 'VAT', 'invoicing' ) : sanitize_text_field( $vat_name ); |
|
| 913 | + $vat_name = wpinv_get_option('vat_name'); |
|
| 914 | + return empty($vat_name) ? __('VAT', 'invoicing') : sanitize_text_field($vat_name); |
|
| 915 | 915 | } |
| 916 | 916 | |
| 917 | 917 | public static function get_company_name() { |
| 918 | - $company_name = wpinv_get_option( 'vat_company_name' ); |
|
| 918 | + $company_name = wpinv_get_option('vat_company_name'); |
|
| 919 | 919 | |
| 920 | - return apply_filters( 'wpinv_get_owner_company_name', $company_name ); |
|
| 920 | + return apply_filters('wpinv_get_owner_company_name', $company_name); |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | public static function get_vat_number() { |
| 924 | - $vat_number = wpinv_get_option( 'vat_number' ); |
|
| 924 | + $vat_number = wpinv_get_option('vat_number'); |
|
| 925 | 925 | |
| 926 | - return apply_filters( 'wpinv_get_owner_vat_number', $vat_number ); |
|
| 926 | + return apply_filters('wpinv_get_owner_vat_number', $vat_number); |
|
| 927 | 927 | } |
| 928 | 928 | |
| 929 | 929 | public static function is_vat_validated() { |
| 930 | - $validated = self::get_vat_number() && wpinv_get_option( 'vat_valid' ); |
|
| 930 | + $validated = self::get_vat_number() && wpinv_get_option('vat_valid'); |
|
| 931 | 931 | |
| 932 | - return apply_filters( 'wpinv_is_owner_vat_validated', $validated ); |
|
| 932 | + return apply_filters('wpinv_is_owner_vat_validated', $validated); |
|
| 933 | 933 | } |
| 934 | 934 | |
| 935 | - public static function sanitize_vat( $vat_number, $country_code = '' ) { |
|
| 936 | - $vat_number = str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) ); |
|
| 935 | + public static function sanitize_vat($vat_number, $country_code = '') { |
|
| 936 | + $vat_number = str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number))); |
|
| 937 | 937 | |
| 938 | - if ( empty( $country_code ) ) { |
|
| 939 | - $country_code = substr( $vat_number, 0, 2 ); |
|
| 938 | + if (empty($country_code)) { |
|
| 939 | + $country_code = substr($vat_number, 0, 2); |
|
| 940 | 940 | } |
| 941 | 941 | |
| 942 | - if ( strpos( $vat_number , $country_code ) === 0 ) { |
|
| 943 | - $vat = str_replace( $country_code, '', $vat_number ); |
|
| 942 | + if (strpos($vat_number, $country_code) === 0) { |
|
| 943 | + $vat = str_replace($country_code, '', $vat_number); |
|
| 944 | 944 | } else { |
| 945 | 945 | $vat = $country_code . $vat_number; |
| 946 | 946 | } |
@@ -953,140 +953,140 @@ discard block |
||
| 953 | 953 | return $return; |
| 954 | 954 | } |
| 955 | 955 | |
| 956 | - public static function offline_check( $vat_number, $country_code = '', $formatted = false ) { |
|
| 957 | - $vat = self::sanitize_vat( $vat_number, $country_code ); |
|
| 956 | + public static function offline_check($vat_number, $country_code = '', $formatted = false) { |
|
| 957 | + $vat = self::sanitize_vat($vat_number, $country_code); |
|
| 958 | 958 | $vat_number = $vat['vat_number']; |
| 959 | 959 | $country_code = $vat['iso']; |
| 960 | 960 | $regex = array(); |
| 961 | 961 | |
| 962 | - switch ( $country_code ) { |
|
| 962 | + switch ($country_code) { |
|
| 963 | 963 | case 'AT': |
| 964 | - $regex[] = '/^(AT)U(\d{8})$/'; // Austria |
|
| 964 | + $regex[] = '/^(AT)U(\d{8})$/'; // Austria |
|
| 965 | 965 | break; |
| 966 | 966 | case 'BE': |
| 967 | - $regex[] = '/^(BE)(0?\d{9})$/'; // Belgium |
|
| 967 | + $regex[] = '/^(BE)(0?\d{9})$/'; // Belgium |
|
| 968 | 968 | break; |
| 969 | 969 | case 'BG': |
| 970 | - $regex[] = '/^(BG)(\d{9,10})$/'; // Bulgaria |
|
| 970 | + $regex[] = '/^(BG)(\d{9,10})$/'; // Bulgaria |
|
| 971 | 971 | break; |
| 972 | 972 | case 'CH': |
| 973 | 973 | case 'CHE': |
| 974 | - $regex[] = '/^(CHE)(\d{9})MWST$/'; // Switzerland (Not EU) |
|
| 974 | + $regex[] = '/^(CHE)(\d{9})MWST$/'; // Switzerland (Not EU) |
|
| 975 | 975 | break; |
| 976 | 976 | case 'CY': |
| 977 | - $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/'; // Cyprus |
|
| 977 | + $regex[] = '/^(CY)([0-5|9]\d{7}[A-Z])$/'; // Cyprus |
|
| 978 | 978 | break; |
| 979 | 979 | case 'CZ': |
| 980 | - $regex[] = '/^(CZ)(\d{8,13})$/'; // Czech Republic |
|
| 980 | + $regex[] = '/^(CZ)(\d{8,13})$/'; // Czech Republic |
|
| 981 | 981 | break; |
| 982 | 982 | case 'DE': |
| 983 | - $regex[] = '/^(DE)([1-9]\d{8})$/'; // Germany |
|
| 983 | + $regex[] = '/^(DE)([1-9]\d{8})$/'; // Germany |
|
| 984 | 984 | break; |
| 985 | 985 | case 'DK': |
| 986 | - $regex[] = '/^(DK)(\d{8})$/'; // Denmark |
|
| 986 | + $regex[] = '/^(DK)(\d{8})$/'; // Denmark |
|
| 987 | 987 | break; |
| 988 | 988 | case 'EE': |
| 989 | - $regex[] = '/^(EE)(10\d{7})$/'; // Estonia |
|
| 989 | + $regex[] = '/^(EE)(10\d{7})$/'; // Estonia |
|
| 990 | 990 | break; |
| 991 | 991 | case 'EL': |
| 992 | - $regex[] = '/^(EL)(\d{9})$/'; // Greece |
|
| 992 | + $regex[] = '/^(EL)(\d{9})$/'; // Greece |
|
| 993 | 993 | break; |
| 994 | 994 | case 'ES': |
| 995 | - $regex[] = '/^(ES)([A-Z]\d{8})$/'; // Spain (National juridical entities) |
|
| 996 | - $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/'; // Spain (Other juridical entities) |
|
| 997 | - $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/'; // Spain (Personal entities type 1) |
|
| 998 | - $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/'; // Spain (Personal entities type 2) |
|
| 995 | + $regex[] = '/^(ES)([A-Z]\d{8})$/'; // Spain (National juridical entities) |
|
| 996 | + $regex[] = '/^(ES)([A-H|N-S|W]\d{7}[A-J])$/'; // Spain (Other juridical entities) |
|
| 997 | + $regex[] = '/^(ES)([0-9|Y|Z]\d{7}[A-Z])$/'; // Spain (Personal entities type 1) |
|
| 998 | + $regex[] = '/^(ES)([K|L|M|X]\d{7}[A-Z])$/'; // Spain (Personal entities type 2) |
|
| 999 | 999 | break; |
| 1000 | 1000 | case 'EU': |
| 1001 | - $regex[] = '/^(EU)(\d{9})$/'; // EU-type |
|
| 1001 | + $regex[] = '/^(EU)(\d{9})$/'; // EU-type |
|
| 1002 | 1002 | break; |
| 1003 | 1003 | case 'FI': |
| 1004 | - $regex[] = '/^(FI)(\d{8})$/'; // Finland |
|
| 1004 | + $regex[] = '/^(FI)(\d{8})$/'; // Finland |
|
| 1005 | 1005 | break; |
| 1006 | 1006 | case 'FR': |
| 1007 | - $regex[] = '/^(FR)(\d{11})$/'; // France (1) |
|
| 1008 | - $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/'; // France (2) |
|
| 1009 | - $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/'; // France (3) |
|
| 1010 | - $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/'; // France (4) |
|
| 1007 | + $regex[] = '/^(FR)(\d{11})$/'; // France (1) |
|
| 1008 | + $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)](\d{10})$/'; // France (2) |
|
| 1009 | + $regex[] = '/^(FR)\d[(A-H)|(J-N)|(P-Z)](\d{9})$/'; // France (3) |
|
| 1010 | + $regex[] = '/^(FR)[(A-H)|(J-N)|(P-Z)]{2}(\d{9})$/'; // France (4) |
|
| 1011 | 1011 | break; |
| 1012 | 1012 | case 'GB': |
| 1013 | - $regex[] = '/^(GB)?(\d{9})$/'; // UK (Standard) |
|
| 1014 | - $regex[] = '/^(GB)?(\d{12})$/'; // UK (Branches) |
|
| 1015 | - $regex[] = '/^(GB)?(GD\d{3})$/'; // UK (Government) |
|
| 1016 | - $regex[] = '/^(GB)?(HA\d{3})$/'; // UK (Health authority) |
|
| 1013 | + $regex[] = '/^(GB)?(\d{9})$/'; // UK (Standard) |
|
| 1014 | + $regex[] = '/^(GB)?(\d{12})$/'; // UK (Branches) |
|
| 1015 | + $regex[] = '/^(GB)?(GD\d{3})$/'; // UK (Government) |
|
| 1016 | + $regex[] = '/^(GB)?(HA\d{3})$/'; // UK (Health authority) |
|
| 1017 | 1017 | break; |
| 1018 | 1018 | case 'GR': |
| 1019 | - $regex[] = '/^(GR)(\d{8,9})$/'; // Greece |
|
| 1019 | + $regex[] = '/^(GR)(\d{8,9})$/'; // Greece |
|
| 1020 | 1020 | break; |
| 1021 | 1021 | case 'HR': |
| 1022 | - $regex[] = '/^(HR)(\d{11})$/'; // Croatia |
|
| 1022 | + $regex[] = '/^(HR)(\d{11})$/'; // Croatia |
|
| 1023 | 1023 | break; |
| 1024 | 1024 | case 'HU': |
| 1025 | - $regex[] = '/^(HU)(\d{8})$/'; // Hungary |
|
| 1025 | + $regex[] = '/^(HU)(\d{8})$/'; // Hungary |
|
| 1026 | 1026 | break; |
| 1027 | 1027 | case 'IE': |
| 1028 | - $regex[] = '/^(IE)(\d{7}[A-W])$/'; // Ireland (1) |
|
| 1029 | - $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/'; // Ireland (2) |
|
| 1030 | - $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/'; // Ireland (3) (new format from 1 Jan 2013) |
|
| 1028 | + $regex[] = '/^(IE)(\d{7}[A-W])$/'; // Ireland (1) |
|
| 1029 | + $regex[] = '/^(IE)([7-9][A-Z\*\+)]\d{5}[A-W])$/'; // Ireland (2) |
|
| 1030 | + $regex[] = '/^(IE)(\d{7}[A-Z][AH])$/'; // Ireland (3) (new format from 1 Jan 2013) |
|
| 1031 | 1031 | break; |
| 1032 | 1032 | case 'IT': |
| 1033 | - $regex[] = '/^(IT)(\d{11})$/'; // Italy |
|
| 1033 | + $regex[] = '/^(IT)(\d{11})$/'; // Italy |
|
| 1034 | 1034 | break; |
| 1035 | 1035 | case 'LV': |
| 1036 | - $regex[] = '/^(LV)(\d{11})$/'; // Latvia |
|
| 1036 | + $regex[] = '/^(LV)(\d{11})$/'; // Latvia |
|
| 1037 | 1037 | break; |
| 1038 | 1038 | case 'LT': |
| 1039 | - $regex[] = '/^(LT)(\d{9}|\d{12})$/'; // Lithuania |
|
| 1039 | + $regex[] = '/^(LT)(\d{9}|\d{12})$/'; // Lithuania |
|
| 1040 | 1040 | break; |
| 1041 | 1041 | case 'LU': |
| 1042 | - $regex[] = '/^(LU)(\d{8})$/'; // Luxembourg |
|
| 1042 | + $regex[] = '/^(LU)(\d{8})$/'; // Luxembourg |
|
| 1043 | 1043 | break; |
| 1044 | 1044 | case 'MT': |
| 1045 | - $regex[] = '/^(MT)([1-9]\d{7})$/'; // Malta |
|
| 1045 | + $regex[] = '/^(MT)([1-9]\d{7})$/'; // Malta |
|
| 1046 | 1046 | break; |
| 1047 | 1047 | case 'NL': |
| 1048 | - $regex[] = '/^(NL)(\d{9})B\d{2}$/'; // Netherlands |
|
| 1048 | + $regex[] = '/^(NL)(\d{9})B\d{2}$/'; // Netherlands |
|
| 1049 | 1049 | break; |
| 1050 | 1050 | case 'NO': |
| 1051 | - $regex[] = '/^(NO)(\d{9})$/'; // Norway (Not EU) |
|
| 1051 | + $regex[] = '/^(NO)(\d{9})$/'; // Norway (Not EU) |
|
| 1052 | 1052 | break; |
| 1053 | 1053 | case 'PL': |
| 1054 | - $regex[] = '/^(PL)(\d{10})$/'; // Poland |
|
| 1054 | + $regex[] = '/^(PL)(\d{10})$/'; // Poland |
|
| 1055 | 1055 | break; |
| 1056 | 1056 | case 'PT': |
| 1057 | - $regex[] = '/^(PT)(\d{9})$/'; // Portugal |
|
| 1057 | + $regex[] = '/^(PT)(\d{9})$/'; // Portugal |
|
| 1058 | 1058 | break; |
| 1059 | 1059 | case 'RO': |
| 1060 | - $regex[] = '/^(RO)([1-9]\d{1,9})$/'; // Romania |
|
| 1060 | + $regex[] = '/^(RO)([1-9]\d{1,9})$/'; // Romania |
|
| 1061 | 1061 | break; |
| 1062 | 1062 | case 'RS': |
| 1063 | - $regex[] = '/^(RS)(\d{9})$/'; // Serbia (Not EU) |
|
| 1063 | + $regex[] = '/^(RS)(\d{9})$/'; // Serbia (Not EU) |
|
| 1064 | 1064 | break; |
| 1065 | 1065 | case 'SI': |
| 1066 | - $regex[] = '/^(SI)([1-9]\d{7})$/'; // Slovenia |
|
| 1066 | + $regex[] = '/^(SI)([1-9]\d{7})$/'; // Slovenia |
|
| 1067 | 1067 | break; |
| 1068 | 1068 | case 'SK': |
| 1069 | - $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/'; // Slovakia Republic |
|
| 1069 | + $regex[] = '/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7})$/'; // Slovakia Republic |
|
| 1070 | 1070 | break; |
| 1071 | 1071 | case 'SE': |
| 1072 | - $regex[] = '/^(SE)(\d{10}01)$/'; // Sweden |
|
| 1072 | + $regex[] = '/^(SE)(\d{10}01)$/'; // Sweden |
|
| 1073 | 1073 | break; |
| 1074 | 1074 | default: |
| 1075 | 1075 | $regex = array(); |
| 1076 | 1076 | break; |
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | - if ( empty( $regex ) ) { |
|
| 1079 | + if (empty($regex)) { |
|
| 1080 | 1080 | return false; |
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | - foreach ( $regex as $pattern ) { |
|
| 1083 | + foreach ($regex as $pattern) { |
|
| 1084 | 1084 | $matches = null; |
| 1085 | - preg_match_all( $pattern, $vat_number, $matches ); |
|
| 1085 | + preg_match_all($pattern, $vat_number, $matches); |
|
| 1086 | 1086 | |
| 1087 | - if ( !empty( $matches[1][0] ) && !empty( $matches[2][0] ) ) { |
|
| 1088 | - if ( $formatted ) { |
|
| 1089 | - return array( 'code' => $matches[1][0], 'number' => $matches[2][0] ); |
|
| 1087 | + if (!empty($matches[1][0]) && !empty($matches[2][0])) { |
|
| 1088 | + if ($formatted) { |
|
| 1089 | + return array('code' => $matches[1][0], 'number' => $matches[2][0]); |
|
| 1090 | 1090 | } else { |
| 1091 | 1091 | return true; |
| 1092 | 1092 | } |
@@ -1096,75 +1096,75 @@ discard block |
||
| 1096 | 1096 | return false; |
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | - public static function vies_check( $vat_number, $country_code = '', $result = false ) { |
|
| 1100 | - $vat = self::sanitize_vat( $vat_number, $country_code ); |
|
| 1099 | + public static function vies_check($vat_number, $country_code = '', $result = false) { |
|
| 1100 | + $vat = self::sanitize_vat($vat_number, $country_code); |
|
| 1101 | 1101 | $vat_number = $vat['vat']; |
| 1102 | 1102 | $iso = $vat['iso']; |
| 1103 | 1103 | |
| 1104 | - $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode( $iso ) . '&iso=' . urlencode( $iso ) . '&vat=' . urlencode( $vat_number ); |
|
| 1104 | + $url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . urlencode($iso) . '&iso=' . urlencode($iso) . '&vat=' . urlencode($vat_number); |
|
| 1105 | 1105 | |
| 1106 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
| 1107 | - $response = file_get_contents( $url ); |
|
| 1108 | - } else if ( function_exists( 'curl_init' ) ) { |
|
| 1106 | + if (ini_get('allow_url_fopen')) { |
|
| 1107 | + $response = file_get_contents($url); |
|
| 1108 | + } else if (function_exists('curl_init')) { |
|
| 1109 | 1109 | $ch = curl_init(); |
| 1110 | 1110 | |
| 1111 | - curl_setopt( $ch, CURLOPT_URL, $url ); |
|
| 1112 | - curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 30 ); |
|
| 1113 | - curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); |
|
| 1114 | - curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 ); |
|
| 1115 | - curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 ); |
|
| 1111 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
| 1112 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); |
|
| 1113 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
| 1114 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); |
|
| 1115 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); |
|
| 1116 | 1116 | |
| 1117 | - $response = curl_exec( $ch ); |
|
| 1117 | + $response = curl_exec($ch); |
|
| 1118 | 1118 | |
| 1119 | - if ( curl_errno( $ch ) ) { |
|
| 1120 | - wpinv_error_log( curl_error( $ch ), 'VIES CHECK ERROR' ); |
|
| 1119 | + if (curl_errno($ch)) { |
|
| 1120 | + wpinv_error_log(curl_error($ch), 'VIES CHECK ERROR'); |
|
| 1121 | 1121 | $response = ''; |
| 1122 | 1122 | } |
| 1123 | 1123 | |
| 1124 | - curl_close( $ch ); |
|
| 1124 | + curl_close($ch); |
|
| 1125 | 1125 | } else { |
| 1126 | - wpinv_error_log( 'To use VIES CHECK you must have allow_url_fopen is ON or cURL installed & active on your server.', 'VIES CHECK ERROR' ); |
|
| 1126 | + wpinv_error_log('To use VIES CHECK you must have allow_url_fopen is ON or cURL installed & active on your server.', 'VIES CHECK ERROR'); |
|
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | - if ( empty( $response ) ) { |
|
| 1129 | + if (empty($response)) { |
|
| 1130 | 1130 | return $result; |
| 1131 | 1131 | } |
| 1132 | 1132 | |
| 1133 | - if ( preg_match( '/invalid VAT number/i', $response ) ) { |
|
| 1133 | + if (preg_match('/invalid VAT number/i', $response)) { |
|
| 1134 | 1134 | return false; |
| 1135 | - } else if ( preg_match( '/valid VAT number/i', $response, $matches ) ) { |
|
| 1136 | - $content = explode( "valid VAT number", htmlentities( $response ) ); |
|
| 1135 | + } else if (preg_match('/valid VAT number/i', $response, $matches)) { |
|
| 1136 | + $content = explode("valid VAT number", htmlentities($response)); |
|
| 1137 | 1137 | |
| 1138 | - if ( !empty( $content[1] ) ) { |
|
| 1139 | - preg_match_all( '/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode( $content[1] ), $matches ); |
|
| 1138 | + if (!empty($content[1])) { |
|
| 1139 | + preg_match_all('/<tr>(.*?)<td.*?>(.*?)<\/td>(.*?)<\/tr>/si', html_entity_decode($content[1]), $matches); |
|
| 1140 | 1140 | |
| 1141 | - if ( !empty( $matches[2] ) && $matches[3] ) { |
|
| 1141 | + if (!empty($matches[2]) && $matches[3]) { |
|
| 1142 | 1142 | $return = array(); |
| 1143 | 1143 | |
| 1144 | - foreach ( $matches[2] as $key => $label ) { |
|
| 1145 | - $label = trim( $label ); |
|
| 1144 | + foreach ($matches[2] as $key => $label) { |
|
| 1145 | + $label = trim($label); |
|
| 1146 | 1146 | |
| 1147 | - switch ( strtolower( $label ) ) { |
|
| 1147 | + switch (strtolower($label)) { |
|
| 1148 | 1148 | case 'member state': |
| 1149 | - $return['state'] = trim( strip_tags( $matches[3][$key] ) ); |
|
| 1149 | + $return['state'] = trim(strip_tags($matches[3][$key])); |
|
| 1150 | 1150 | break; |
| 1151 | 1151 | case 'vat number': |
| 1152 | - $return['number'] = trim( strip_tags( $matches[3][$key] ) ); |
|
| 1152 | + $return['number'] = trim(strip_tags($matches[3][$key])); |
|
| 1153 | 1153 | break; |
| 1154 | 1154 | case 'name': |
| 1155 | - $return['company'] = trim( strip_tags( $matches[3][$key] ) ); |
|
| 1155 | + $return['company'] = trim(strip_tags($matches[3][$key])); |
|
| 1156 | 1156 | break; |
| 1157 | 1157 | case 'address': |
| 1158 | - $address = str_replace( array( "<br><br>", "<br /><br />", "<br/><br/>" ), "<br>", html_entity_decode( trim( $matches[3][$key] ) ) ); |
|
| 1159 | - $return['address'] = trim( strip_tags( $address, '<br>' ) ); |
|
| 1158 | + $address = str_replace(array("<br><br>", "<br /><br />", "<br/><br/>"), "<br>", html_entity_decode(trim($matches[3][$key]))); |
|
| 1159 | + $return['address'] = trim(strip_tags($address, '<br>')); |
|
| 1160 | 1160 | break; |
| 1161 | 1161 | case 'consultation number': |
| 1162 | - $return['consultation'] = trim( strip_tags( $matches[3][$key] ) ); |
|
| 1162 | + $return['consultation'] = trim(strip_tags($matches[3][$key])); |
|
| 1163 | 1163 | break; |
| 1164 | 1164 | } |
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | - if ( !empty( $return ) ) { |
|
| 1167 | + if (!empty($return)) { |
|
| 1168 | 1168 | return $return; |
| 1169 | 1169 | } |
| 1170 | 1170 | } |
@@ -1176,62 +1176,62 @@ discard block |
||
| 1176 | 1176 | } |
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | - public static function check_vat( $vat_number, $country_code = '' ) { |
|
| 1179 | + public static function check_vat($vat_number, $country_code = '') { |
|
| 1180 | 1180 | $vat_name = getpaid_vat_name(); |
| 1181 | 1181 | |
| 1182 | 1182 | $return = array(); |
| 1183 | 1183 | $return['valid'] = false; |
| 1184 | - $return['message'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name ); |
|
| 1184 | + $return['message'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name); |
|
| 1185 | 1185 | |
| 1186 | - if ( !wpinv_get_option( 'vat_offline_check' ) && !self::offline_check( $vat_number, $country_code ) ) { |
|
| 1186 | + if (!wpinv_get_option('vat_offline_check') && !self::offline_check($vat_number, $country_code)) { |
|
| 1187 | 1187 | return $return; |
| 1188 | 1188 | } |
| 1189 | 1189 | |
| 1190 | - $response = self::vies_check( $vat_number, $country_code ); |
|
| 1190 | + $response = self::vies_check($vat_number, $country_code); |
|
| 1191 | 1191 | |
| 1192 | - if ( $response ) { |
|
| 1193 | - $return['valid'] = true; |
|
| 1192 | + if ($response) { |
|
| 1193 | + $return['valid'] = true; |
|
| 1194 | 1194 | |
| 1195 | - if ( is_array( $response ) ) { |
|
| 1196 | - $return['company'] = isset( $response['company'] ) ? $response['company'] : ''; |
|
| 1197 | - $return['address'] = isset( $response['address'] ) ? $response['address'] : ''; |
|
| 1195 | + if (is_array($response)) { |
|
| 1196 | + $return['company'] = isset($response['company']) ? $response['company'] : ''; |
|
| 1197 | + $return['address'] = isset($response['address']) ? $response['address'] : ''; |
|
| 1198 | 1198 | $return['message'] = $return['company'] . '<br/>' . $return['address']; |
| 1199 | 1199 | } |
| 1200 | 1200 | } else { |
| 1201 | 1201 | $return['valid'] = false; |
| 1202 | - $return['message'] = wp_sprintf( __( 'Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing' ), $vat_name ); |
|
| 1202 | + $return['message'] = wp_sprintf(__('Fail to validate the %s number: EU Commission VAT server (VIES) check fails.', 'invoicing'), $vat_name); |
|
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | 1205 | return $return; |
| 1206 | 1206 | } |
| 1207 | 1207 | |
| 1208 | - public static function request_euvatrates( $group ) { |
|
| 1208 | + public static function request_euvatrates($group) { |
|
| 1209 | 1209 | $response = array(); |
| 1210 | 1210 | $response['success'] = false; |
| 1211 | 1211 | $response['error'] = null; |
| 1212 | 1212 | $response['eurates'] = null; |
| 1213 | 1213 | |
| 1214 | 1214 | $euvatrates_url = 'https://euvatrates.com/rates.json'; |
| 1215 | - $euvatrates_url = apply_filters( 'wpinv_euvatrates_url', $euvatrates_url ); |
|
| 1216 | - $api_response = wp_remote_get( $euvatrates_url ); |
|
| 1215 | + $euvatrates_url = apply_filters('wpinv_euvatrates_url', $euvatrates_url); |
|
| 1216 | + $api_response = wp_remote_get($euvatrates_url); |
|
| 1217 | 1217 | |
| 1218 | 1218 | try { |
| 1219 | - if ( is_wp_error( $api_response ) ) { |
|
| 1220 | - $response['error'] = __( $api_response->get_error_message(), 'invoicing' ); |
|
| 1219 | + if (is_wp_error($api_response)) { |
|
| 1220 | + $response['error'] = __($api_response->get_error_message(), 'invoicing'); |
|
| 1221 | 1221 | } else { |
| 1222 | - $body = json_decode( $api_response['body'] ); |
|
| 1223 | - if ( isset( $body->rates ) ) { |
|
| 1222 | + $body = json_decode($api_response['body']); |
|
| 1223 | + if (isset($body->rates)) { |
|
| 1224 | 1224 | $rates = array(); |
| 1225 | 1225 | |
| 1226 | - foreach ( $body->rates as $country_code => $rate ) { |
|
| 1226 | + foreach ($body->rates as $country_code => $rate) { |
|
| 1227 | 1227 | $vat_rate = array(); |
| 1228 | 1228 | $vat_rate['country'] = $rate->country; |
| 1229 | - $vat_rate['standard'] = (float)$rate->standard_rate; |
|
| 1230 | - $vat_rate['reduced'] = (float)$rate->reduced_rate; |
|
| 1231 | - $vat_rate['superreduced'] = (float)$rate->super_reduced_rate; |
|
| 1232 | - $vat_rate['parking'] = (float)$rate->parking_rate; |
|
| 1229 | + $vat_rate['standard'] = (float) $rate->standard_rate; |
|
| 1230 | + $vat_rate['reduced'] = (float) $rate->reduced_rate; |
|
| 1231 | + $vat_rate['superreduced'] = (float) $rate->super_reduced_rate; |
|
| 1232 | + $vat_rate['parking'] = (float) $rate->parking_rate; |
|
| 1233 | 1233 | |
| 1234 | - if ( $group !== '' && in_array( $group, array( 'standard', 'reduced', 'superreduced', 'parking' ) ) ) { |
|
| 1234 | + if ($group !== '' && in_array($group, array('standard', 'reduced', 'superreduced', 'parking'))) { |
|
| 1235 | 1235 | $vat_rate_group = array(); |
| 1236 | 1236 | $vat_rate_group['country'] = $rate->country; |
| 1237 | 1237 | $vat_rate_group[$group] = $vat_rate[$group]; |
@@ -1243,79 +1243,79 @@ discard block |
||
| 1243 | 1243 | } |
| 1244 | 1244 | |
| 1245 | 1245 | $response['success'] = true; |
| 1246 | - $response['rates'] = apply_filters( 'wpinv_process_euvatrates', $rates, $api_response, $group ); |
|
| 1246 | + $response['rates'] = apply_filters('wpinv_process_euvatrates', $rates, $api_response, $group); |
|
| 1247 | 1247 | } else { |
| 1248 | - $response['error'] = __( 'No EU rates found!', 'invoicing' ); |
|
| 1248 | + $response['error'] = __('No EU rates found!', 'invoicing'); |
|
| 1249 | 1249 | } |
| 1250 | 1250 | } |
| 1251 | - } catch ( Exception $e ) { |
|
| 1252 | - $response['error'] = __( $e->getMessage(), 'invoicing' ); |
|
| 1251 | + } catch (Exception $e) { |
|
| 1252 | + $response['error'] = __($e->getMessage(), 'invoicing'); |
|
| 1253 | 1253 | } |
| 1254 | 1254 | |
| 1255 | - return apply_filters( 'wpinv_response_euvatrates', $response, $group ); |
|
| 1255 | + return apply_filters('wpinv_response_euvatrates', $response, $group); |
|
| 1256 | 1256 | } |
| 1257 | 1257 | |
| 1258 | - public static function requires_vat( $requires_vat = false, $user_id = 0, $is_digital = null ) { |
|
| 1258 | + public static function requires_vat($requires_vat = false, $user_id = 0, $is_digital = null) { |
|
| 1259 | 1259 | global $wpi_item_id, $wpi_country; |
| 1260 | 1260 | |
| 1261 | - if ( !empty( $_POST['wpinv_country'] ) ) { |
|
| 1262 | - $country_code = trim( $_POST['wpinv_country'] ); |
|
| 1263 | - } else if ( !empty( $_POST['country'] ) ) { |
|
| 1264 | - $country_code = trim( $_POST['country'] ); |
|
| 1265 | - } else if ( !empty( $wpi_country ) ) { |
|
| 1261 | + if (!empty($_POST['wpinv_country'])) { |
|
| 1262 | + $country_code = trim($_POST['wpinv_country']); |
|
| 1263 | + } else if (!empty($_POST['country'])) { |
|
| 1264 | + $country_code = trim($_POST['country']); |
|
| 1265 | + } else if (!empty($wpi_country)) { |
|
| 1266 | 1266 | $country_code = $wpi_country; |
| 1267 | 1267 | } else { |
| 1268 | - $country_code = self::get_user_country( '', $user_id ); |
|
| 1268 | + $country_code = self::get_user_country('', $user_id); |
|
| 1269 | 1269 | } |
| 1270 | 1270 | |
| 1271 | - if ( $is_digital === null && $wpi_item_id ) { |
|
| 1272 | - $is_digital = $wpi_item_id ? self::item_has_digital_rule( $wpi_item_id ) : self::allow_vat_rules(); |
|
| 1271 | + if ($is_digital === null && $wpi_item_id) { |
|
| 1272 | + $is_digital = $wpi_item_id ? self::item_has_digital_rule($wpi_item_id) : self::allow_vat_rules(); |
|
| 1273 | 1273 | } |
| 1274 | 1274 | |
| 1275 | - if ( !empty( $country_code ) ) { |
|
| 1276 | - $requires_vat = ( self::is_eu_state( $country_code ) && ( self::is_eu_state( wpinv_get_default_country() ) || $is_digital ) ) || ( self::is_gst_country( $country_code ) && self::is_gst_country( wpinv_get_default_country() ) ); |
|
| 1275 | + if (!empty($country_code)) { |
|
| 1276 | + $requires_vat = (self::is_eu_state($country_code) && (self::is_eu_state(wpinv_get_default_country()) || $is_digital)) || (self::is_gst_country($country_code) && self::is_gst_country(wpinv_get_default_country())); |
|
| 1277 | 1277 | } |
| 1278 | 1278 | |
| 1279 | - return apply_filters( 'wpinv_requires_vat', $requires_vat, $user_id ); |
|
| 1279 | + return apply_filters('wpinv_requires_vat', $requires_vat, $user_id); |
|
| 1280 | 1280 | } |
| 1281 | 1281 | |
| 1282 | - public static function tax_label( $label = '' ) { |
|
| 1282 | + public static function tax_label($label = '') { |
|
| 1283 | 1283 | global $wpi_requires_vat; |
| 1284 | 1284 | |
| 1285 | - if ( !( $wpi_requires_vat !== 0 && $wpi_requires_vat ) ) { |
|
| 1286 | - $wpi_requires_vat = self::requires_vat( 0, false ); |
|
| 1285 | + if (!($wpi_requires_vat !== 0 && $wpi_requires_vat)) { |
|
| 1286 | + $wpi_requires_vat = self::requires_vat(0, false); |
|
| 1287 | 1287 | } |
| 1288 | 1288 | |
| 1289 | - return $wpi_requires_vat ? __( self::get_vat_name(), 'invoicing' ) : ( $label ? $label : __( 'Tax', 'invoicing' ) ); |
|
| 1289 | + return $wpi_requires_vat ? __(self::get_vat_name(), 'invoicing') : ($label ? $label : __('Tax', 'invoicing')); |
|
| 1290 | 1290 | } |
| 1291 | 1291 | |
| 1292 | 1292 | public static function standard_rates_label() { |
| 1293 | - return __( 'Standard Rates', 'invoicing' ); |
|
| 1293 | + return __('Standard Rates', 'invoicing'); |
|
| 1294 | 1294 | } |
| 1295 | 1295 | |
| 1296 | - public static function get_rate_classes( $with_desc = false ) { |
|
| 1297 | - $rate_classes_option = get_option( '_wpinv_vat_rate_classes', true ); |
|
| 1298 | - $classes = maybe_unserialize( $rate_classes_option ); |
|
| 1296 | + public static function get_rate_classes($with_desc = false) { |
|
| 1297 | + $rate_classes_option = get_option('_wpinv_vat_rate_classes', true); |
|
| 1298 | + $classes = maybe_unserialize($rate_classes_option); |
|
| 1299 | 1299 | |
| 1300 | - if ( empty( $classes ) || !is_array( $classes ) ) { |
|
| 1300 | + if (empty($classes) || !is_array($classes)) { |
|
| 1301 | 1301 | $classes = array(); |
| 1302 | 1302 | } |
| 1303 | 1303 | |
| 1304 | 1304 | $rate_classes = array(); |
| 1305 | - if ( !array_key_exists( '_standard', $classes ) ) { |
|
| 1306 | - if ( $with_desc ) { |
|
| 1307 | - $rate_classes['_standard'] = array( 'name' => self::standard_rates_label(), 'desc' => __( 'EU member states standard VAT rates', 'invoicing' ) ); |
|
| 1305 | + if (!array_key_exists('_standard', $classes)) { |
|
| 1306 | + if ($with_desc) { |
|
| 1307 | + $rate_classes['_standard'] = array('name' => self::standard_rates_label(), 'desc' => __('EU member states standard VAT rates', 'invoicing')); |
|
| 1308 | 1308 | } else { |
| 1309 | 1309 | $rate_classes['_standard'] = self::standard_rates_label(); |
| 1310 | 1310 | } |
| 1311 | 1311 | } |
| 1312 | 1312 | |
| 1313 | - foreach ( $classes as $key => $class ) { |
|
| 1314 | - $name = !empty( $class['name'] ) ? __( $class['name'], 'invoicing' ) : $key; |
|
| 1315 | - $desc = !empty( $class['desc'] ) ? __( $class['desc'], 'invoicing' ) : ''; |
|
| 1313 | + foreach ($classes as $key => $class) { |
|
| 1314 | + $name = !empty($class['name']) ? __($class['name'], 'invoicing') : $key; |
|
| 1315 | + $desc = !empty($class['desc']) ? __($class['desc'], 'invoicing') : ''; |
|
| 1316 | 1316 | |
| 1317 | - if ( $with_desc ) { |
|
| 1318 | - $rate_classes[$key] = array( 'name' => $name, 'desc' => $desc ); |
|
| 1317 | + if ($with_desc) { |
|
| 1318 | + $rate_classes[$key] = array('name' => $name, 'desc' => $desc); |
|
| 1319 | 1319 | } else { |
| 1320 | 1320 | $rate_classes[$key] = $name; |
| 1321 | 1321 | } |
@@ -1326,15 +1326,15 @@ discard block |
||
| 1326 | 1326 | |
| 1327 | 1327 | public static function get_all_classes() { |
| 1328 | 1328 | $classes = self::get_rate_classes(); |
| 1329 | - $classes['_exempt'] = __( 'Exempt (0%)', 'invoicing' ); |
|
| 1329 | + $classes['_exempt'] = __('Exempt (0%)', 'invoicing'); |
|
| 1330 | 1330 | |
| 1331 | - return apply_filters( 'wpinv_vat_get_all_classes', $classes ); |
|
| 1331 | + return apply_filters('wpinv_vat_get_all_classes', $classes); |
|
| 1332 | 1332 | } |
| 1333 | 1333 | |
| 1334 | - public static function get_class_desc( $rate_class ) { |
|
| 1335 | - $rate_classes = self::get_rate_classes( true ); |
|
| 1334 | + public static function get_class_desc($rate_class) { |
|
| 1335 | + $rate_classes = self::get_rate_classes(true); |
|
| 1336 | 1336 | |
| 1337 | - if ( !empty( $rate_classes ) && isset( $rate_classes[$rate_class] ) && isset( $rate_classes[$rate_class]['desc'] ) ) { |
|
| 1337 | + if (!empty($rate_classes) && isset($rate_classes[$rate_class]) && isset($rate_classes[$rate_class]['desc'])) { |
|
| 1338 | 1338 | return $rate_classes[$rate_class]['desc']; |
| 1339 | 1339 | } |
| 1340 | 1340 | |
@@ -1350,107 +1350,107 @@ discard block |
||
| 1350 | 1350 | 'increased' => 'Increased' |
| 1351 | 1351 | ); |
| 1352 | 1352 | |
| 1353 | - return apply_filters( 'wpinv_get_vat_groups', $vat_groups ); |
|
| 1353 | + return apply_filters('wpinv_get_vat_groups', $vat_groups); |
|
| 1354 | 1354 | } |
| 1355 | 1355 | |
| 1356 | 1356 | public static function get_rules() { |
| 1357 | 1357 | $vat_rules = array( |
| 1358 | - 'digital' => __( 'Digital Product', 'invoicing' ), |
|
| 1359 | - 'physical' => __( 'Physical Product', 'invoicing' ), |
|
| 1360 | - '_exempt' => __( 'Tax-Free Product', 'invoicing' ), |
|
| 1358 | + 'digital' => __('Digital Product', 'invoicing'), |
|
| 1359 | + 'physical' => __('Physical Product', 'invoicing'), |
|
| 1360 | + '_exempt' => __('Tax-Free Product', 'invoicing'), |
|
| 1361 | 1361 | ); |
| 1362 | - return apply_filters( 'wpinv_get_vat_rules', $vat_rules ); |
|
| 1362 | + return apply_filters('wpinv_get_vat_rules', $vat_rules); |
|
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | - public static function get_vat_rates( $class ) { |
|
| 1366 | - if ( $class === '_standard' ) { |
|
| 1365 | + public static function get_vat_rates($class) { |
|
| 1366 | + if ($class === '_standard') { |
|
| 1367 | 1367 | return wpinv_get_tax_rates(); |
| 1368 | 1368 | } |
| 1369 | 1369 | |
| 1370 | 1370 | $rates = self::get_non_standard_rates(); |
| 1371 | 1371 | |
| 1372 | - return array_key_exists( $class, $rates ) ? $rates[$class] : array(); |
|
| 1372 | + return array_key_exists($class, $rates) ? $rates[$class] : array(); |
|
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | 1375 | public static function get_non_standard_rates() { |
| 1376 | - $option = get_option( 'wpinv_vat_rates', array()); |
|
| 1377 | - return is_array( $option ) ? $option : array(); |
|
| 1376 | + $option = get_option('wpinv_vat_rates', array()); |
|
| 1377 | + return is_array($option) ? $option : array(); |
|
| 1378 | 1378 | } |
| 1379 | 1379 | |
| 1380 | 1380 | public static function allow_vat_rules() { |
| 1381 | - return ( wpinv_use_taxes() && wpinv_get_option( 'apply_vat_rules' ) ? true : false ); |
|
| 1381 | + return (wpinv_use_taxes() && wpinv_get_option('apply_vat_rules') ? true : false); |
|
| 1382 | 1382 | } |
| 1383 | 1383 | |
| 1384 | 1384 | public static function allow_vat_classes() { |
| 1385 | 1385 | return false; // TODO |
| 1386 | - return ( wpinv_get_option( 'vat_allow_classes' ) ? true : false ); |
|
| 1386 | + return (wpinv_get_option('vat_allow_classes') ? true : false); |
|
| 1387 | 1387 | } |
| 1388 | 1388 | |
| 1389 | - public static function get_item_class( $postID ) { |
|
| 1390 | - $class = get_post_meta( $postID, '_wpinv_vat_class', true ); |
|
| 1389 | + public static function get_item_class($postID) { |
|
| 1390 | + $class = get_post_meta($postID, '_wpinv_vat_class', true); |
|
| 1391 | 1391 | |
| 1392 | - if ( empty( $class ) ) { |
|
| 1392 | + if (empty($class)) { |
|
| 1393 | 1393 | $class = '_standard'; |
| 1394 | 1394 | } |
| 1395 | 1395 | |
| 1396 | - return apply_filters( 'wpinv_get_item_vat_class', $class, $postID ); |
|
| 1396 | + return apply_filters('wpinv_get_item_vat_class', $class, $postID); |
|
| 1397 | 1397 | } |
| 1398 | 1398 | |
| 1399 | - public static function item_class_label( $postID ) { |
|
| 1399 | + public static function item_class_label($postID) { |
|
| 1400 | 1400 | $vat_classes = self::get_all_classes(); |
| 1401 | 1401 | |
| 1402 | - $class = self::get_item_class( $postID ); |
|
| 1403 | - $class = isset( $vat_classes[$class] ) ? $vat_classes[$class] : __( $class, 'invoicing' ); |
|
| 1402 | + $class = self::get_item_class($postID); |
|
| 1403 | + $class = isset($vat_classes[$class]) ? $vat_classes[$class] : __($class, 'invoicing'); |
|
| 1404 | 1404 | |
| 1405 | - return apply_filters( 'wpinv_item_class_label', $class, $postID ); |
|
| 1405 | + return apply_filters('wpinv_item_class_label', $class, $postID); |
|
| 1406 | 1406 | } |
| 1407 | 1407 | |
| 1408 | - public static function get_item_rule( $postID ) { |
|
| 1409 | - $rule_type = get_post_meta( $postID, '_wpinv_vat_rule', true ); |
|
| 1408 | + public static function get_item_rule($postID) { |
|
| 1409 | + $rule_type = get_post_meta($postID, '_wpinv_vat_rule', true); |
|
| 1410 | 1410 | |
| 1411 | - if ( empty( $rule_type ) ) { |
|
| 1411 | + if (empty($rule_type)) { |
|
| 1412 | 1412 | $rule_type = self::allow_vat_rules() ? 'digital' : 'physical'; |
| 1413 | 1413 | } |
| 1414 | 1414 | |
| 1415 | - return apply_filters( 'wpinv_item_get_vat_rule', $rule_type, $postID ); |
|
| 1415 | + return apply_filters('wpinv_item_get_vat_rule', $rule_type, $postID); |
|
| 1416 | 1416 | } |
| 1417 | 1417 | |
| 1418 | - public static function item_rule_label( $postID ) { |
|
| 1418 | + public static function item_rule_label($postID) { |
|
| 1419 | 1419 | $vat_rules = self::get_rules(); |
| 1420 | - $vat_rule = self::get_item_rule( $postID ); |
|
| 1421 | - $vat_rule = isset( $vat_rules[$vat_rule] ) ? $vat_rules[$vat_rule] : $vat_rule; |
|
| 1420 | + $vat_rule = self::get_item_rule($postID); |
|
| 1421 | + $vat_rule = isset($vat_rules[$vat_rule]) ? $vat_rules[$vat_rule] : $vat_rule; |
|
| 1422 | 1422 | |
| 1423 | - return apply_filters( 'wpinv_item_rule_label', $vat_rule, $postID ); |
|
| 1423 | + return apply_filters('wpinv_item_rule_label', $vat_rule, $postID); |
|
| 1424 | 1424 | } |
| 1425 | 1425 | |
| 1426 | - public static function item_has_digital_rule( $item_id = 0 ) { |
|
| 1427 | - return self::get_item_rule( $item_id ) == 'digital' ? true : false; |
|
| 1426 | + public static function item_has_digital_rule($item_id = 0) { |
|
| 1427 | + return self::get_item_rule($item_id) == 'digital' ? true : false; |
|
| 1428 | 1428 | } |
| 1429 | 1429 | |
| 1430 | - public static function invoice_has_digital_rule( $invoice = 0 ) { |
|
| 1431 | - if ( !self::allow_vat_rules() ) { |
|
| 1430 | + public static function invoice_has_digital_rule($invoice = 0) { |
|
| 1431 | + if (!self::allow_vat_rules()) { |
|
| 1432 | 1432 | return false; |
| 1433 | 1433 | } |
| 1434 | 1434 | |
| 1435 | - if ( empty( $invoice ) ) { |
|
| 1435 | + if (empty($invoice)) { |
|
| 1436 | 1436 | return true; |
| 1437 | 1437 | } |
| 1438 | 1438 | |
| 1439 | - if ( is_int( $invoice ) ) { |
|
| 1440 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 1439 | + if (is_int($invoice)) { |
|
| 1440 | + $invoice = new WPInv_Invoice($invoice); |
|
| 1441 | 1441 | } |
| 1442 | 1442 | |
| 1443 | - if ( !( is_object( $invoice ) && is_a( $invoice, 'WPInv_Invoice' ) ) ) { |
|
| 1443 | + if (!(is_object($invoice) && is_a($invoice, 'WPInv_Invoice'))) { |
|
| 1444 | 1444 | return true; |
| 1445 | 1445 | } |
| 1446 | 1446 | |
| 1447 | - $cart_items = $invoice->get_cart_details(); |
|
| 1447 | + $cart_items = $invoice->get_cart_details(); |
|
| 1448 | 1448 | |
| 1449 | - if ( !empty( $cart_items ) ) { |
|
| 1449 | + if (!empty($cart_items)) { |
|
| 1450 | 1450 | $has_digital_rule = false; |
| 1451 | 1451 | |
| 1452 | - foreach ( $cart_items as $key => $item ) { |
|
| 1453 | - if ( self::item_has_digital_rule( $item['id'] ) ) { |
|
| 1452 | + foreach ($cart_items as $key => $item) { |
|
| 1453 | + if (self::item_has_digital_rule($item['id'])) { |
|
| 1454 | 1454 | $has_digital_rule = true; |
| 1455 | 1455 | break; |
| 1456 | 1456 | } |
@@ -1462,71 +1462,71 @@ discard block |
||
| 1462 | 1462 | return $has_digital_rule; |
| 1463 | 1463 | } |
| 1464 | 1464 | |
| 1465 | - public static function item_is_taxable( $item_id = 0, $country = false, $state = false ) { |
|
| 1466 | - if ( !wpinv_use_taxes() ) { |
|
| 1465 | + public static function item_is_taxable($item_id = 0, $country = false, $state = false) { |
|
| 1466 | + if (!wpinv_use_taxes()) { |
|
| 1467 | 1467 | return false; |
| 1468 | 1468 | } |
| 1469 | 1469 | |
| 1470 | 1470 | $is_taxable = true; |
| 1471 | 1471 | |
| 1472 | - if ( !empty( $item_id ) && self::get_item_class( $item_id ) == '_exempt' ) { |
|
| 1472 | + if (!empty($item_id) && self::get_item_class($item_id) == '_exempt') { |
|
| 1473 | 1473 | $is_taxable = false; |
| 1474 | 1474 | } |
| 1475 | 1475 | |
| 1476 | - if ( !empty( $item_id ) && self::get_item_rule( $item_id ) == '_exempt' ) { |
|
| 1476 | + if (!empty($item_id) && self::get_item_rule($item_id) == '_exempt') { |
|
| 1477 | 1477 | $is_taxable = false; |
| 1478 | 1478 | } |
| 1479 | 1479 | |
| 1480 | - return apply_filters( 'wpinv_item_is_taxable', $is_taxable, $item_id, $country , $state ); |
|
| 1480 | + return apply_filters('wpinv_item_is_taxable', $is_taxable, $item_id, $country, $state); |
|
| 1481 | 1481 | } |
| 1482 | 1482 | |
| 1483 | - public static function find_rate( $country, $state, $rate, $class ) { |
|
| 1483 | + public static function find_rate($country, $state, $rate, $class) { |
|
| 1484 | 1484 | global $wpi_zero_tax; |
| 1485 | 1485 | |
| 1486 | - if ( $class === '_exempt' || $wpi_zero_tax ) { |
|
| 1486 | + if ($class === '_exempt' || $wpi_zero_tax) { |
|
| 1487 | 1487 | return 0; |
| 1488 | 1488 | } |
| 1489 | 1489 | |
| 1490 | - $tax_rates = wpinv_get_tax_rates(); |
|
| 1490 | + $tax_rates = wpinv_get_tax_rates(); |
|
| 1491 | 1491 | |
| 1492 | - if ( $class !== '_standard' ) { |
|
| 1493 | - $class_rates = self::get_vat_rates( $class ); |
|
| 1492 | + if ($class !== '_standard') { |
|
| 1493 | + $class_rates = self::get_vat_rates($class); |
|
| 1494 | 1494 | |
| 1495 | - if ( is_array( $class_rates ) ) { |
|
| 1495 | + if (is_array($class_rates)) { |
|
| 1496 | 1496 | $indexed_class_rates = array(); |
| 1497 | 1497 | |
| 1498 | - foreach ( $class_rates as $key => $cr ) { |
|
| 1498 | + foreach ($class_rates as $key => $cr) { |
|
| 1499 | 1499 | $indexed_class_rates[$cr['country']] = $cr; |
| 1500 | 1500 | } |
| 1501 | 1501 | |
| 1502 | - $tax_rates = array_map( function( $tr ) use( $indexed_class_rates ) { |
|
| 1502 | + $tax_rates = array_map(function($tr) use($indexed_class_rates) { |
|
| 1503 | 1503 | $tr_country = $tr['country']; |
| 1504 | - if ( !isset( $indexed_class_rates[$tr_country] ) ) { |
|
| 1504 | + if (!isset($indexed_class_rates[$tr_country])) { |
|
| 1505 | 1505 | return $tr; |
| 1506 | 1506 | } |
| 1507 | 1507 | $icr = $indexed_class_rates[$tr_country]; |
| 1508 | - return ( empty( $icr['rate'] ) && $icr['rate'] !== '0' ) ? $tr : $icr; |
|
| 1508 | + return (empty($icr['rate']) && $icr['rate'] !== '0') ? $tr : $icr; |
|
| 1509 | 1509 | |
| 1510 | - }, $tax_rates, $class_rates ); |
|
| 1510 | + }, $tax_rates, $class_rates); |
|
| 1511 | 1511 | } |
| 1512 | 1512 | } |
| 1513 | 1513 | |
| 1514 | - if ( !empty( $tax_rates ) ) { |
|
| 1515 | - foreach ( $tax_rates as $key => $tax_rate ) { |
|
| 1516 | - if ( $country != $tax_rate['country'] ) |
|
| 1514 | + if (!empty($tax_rates)) { |
|
| 1515 | + foreach ($tax_rates as $key => $tax_rate) { |
|
| 1516 | + if ($country != $tax_rate['country']) |
|
| 1517 | 1517 | continue; |
| 1518 | 1518 | |
| 1519 | - if ( !empty( $tax_rate['global'] ) ) { |
|
| 1520 | - if ( 0 !== $tax_rate['rate'] || !empty( $tax_rate['rate'] ) ) { |
|
| 1521 | - $rate = number_format( $tax_rate['rate'], 4 ); |
|
| 1519 | + if (!empty($tax_rate['global'])) { |
|
| 1520 | + if (0 !== $tax_rate['rate'] || !empty($tax_rate['rate'])) { |
|
| 1521 | + $rate = number_format($tax_rate['rate'], 4); |
|
| 1522 | 1522 | } |
| 1523 | 1523 | } else { |
| 1524 | - if ( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) ) |
|
| 1524 | + if (empty($tax_rate['state']) || strtolower($state) != strtolower($tax_rate['state'])) |
|
| 1525 | 1525 | continue; |
| 1526 | 1526 | |
| 1527 | 1527 | $state_rate = $tax_rate['rate']; |
| 1528 | - if ( 0 !== $state_rate || !empty( $state_rate ) ) { |
|
| 1529 | - $rate = number_format( $state_rate, 4 ); |
|
| 1528 | + if (0 !== $state_rate || !empty($state_rate)) { |
|
| 1529 | + $rate = number_format($state_rate, 4); |
|
| 1530 | 1530 | } |
| 1531 | 1531 | } |
| 1532 | 1532 | } |
@@ -1535,84 +1535,84 @@ discard block |
||
| 1535 | 1535 | return $rate; |
| 1536 | 1536 | } |
| 1537 | 1537 | |
| 1538 | - public static function get_rate( $rate = 1, $country = '', $state = '', $item_id = 0 ) { |
|
| 1538 | + public static function get_rate($rate = 1, $country = '', $state = '', $item_id = 0) { |
|
| 1539 | 1539 | global $wpinv_options, $wpi_item_id, $wpi_zero_tax; |
| 1540 | 1540 | |
| 1541 | 1541 | $item_id = $item_id > 0 ? $item_id : $wpi_item_id; |
| 1542 | 1542 | $allow_vat_classes = self::allow_vat_classes(); |
| 1543 | - $class = $item_id ? self::get_item_class( $item_id ) : '_standard'; |
|
| 1543 | + $class = $item_id ? self::get_item_class($item_id) : '_standard'; |
|
| 1544 | 1544 | |
| 1545 | - if ( $class === '_exempt' || $wpi_zero_tax ) { |
|
| 1545 | + if ($class === '_exempt' || $wpi_zero_tax) { |
|
| 1546 | 1546 | return 0; |
| 1547 | - } else if ( !$allow_vat_classes ) { |
|
| 1547 | + } else if (!$allow_vat_classes) { |
|
| 1548 | 1548 | $class = '_standard'; |
| 1549 | 1549 | } |
| 1550 | 1550 | |
| 1551 | - if( !empty( $_POST['wpinv_country'] ) ) { |
|
| 1551 | + if (!empty($_POST['wpinv_country'])) { |
|
| 1552 | 1552 | $post_country = $_POST['wpinv_country']; |
| 1553 | - } elseif( !empty( $_POST['wpinv_country'] ) ) { |
|
| 1553 | + } elseif (!empty($_POST['wpinv_country'])) { |
|
| 1554 | 1554 | $post_country = $_POST['wpinv_country']; |
| 1555 | - } elseif( !empty( $_POST['country'] ) ) { |
|
| 1555 | + } elseif (!empty($_POST['country'])) { |
|
| 1556 | 1556 | $post_country = $_POST['country']; |
| 1557 | 1557 | } else { |
| 1558 | 1558 | $post_country = ''; |
| 1559 | 1559 | } |
| 1560 | 1560 | |
| 1561 | - $country = !empty( $post_country ) ? $post_country : wpinv_default_billing_country( $country ); |
|
| 1562 | - $base_country = wpinv_is_base_country( $country ); |
|
| 1561 | + $country = !empty($post_country) ? $post_country : wpinv_default_billing_country($country); |
|
| 1562 | + $base_country = wpinv_is_base_country($country); |
|
| 1563 | 1563 | |
| 1564 | - $requires_vat = self::requires_vat( 0, false ); |
|
| 1565 | - $is_digital = self::get_item_rule( $item_id ) == 'digital' ; |
|
| 1566 | - $rate = $requires_vat && isset( $wpinv_options['eu_fallback_rate'] ) ? $wpinv_options['eu_fallback_rate'] : $rate; |
|
| 1564 | + $requires_vat = self::requires_vat(0, false); |
|
| 1565 | + $is_digital = self::get_item_rule($item_id) == 'digital'; |
|
| 1566 | + $rate = $requires_vat && isset($wpinv_options['eu_fallback_rate']) ? $wpinv_options['eu_fallback_rate'] : $rate; |
|
| 1567 | 1567 | |
| 1568 | - if ( self::same_country_rule() == 'no' && $base_country ) { // Disable VAT to same country |
|
| 1568 | + if (self::same_country_rule() == 'no' && $base_country) { // Disable VAT to same country |
|
| 1569 | 1569 | $rate = 0; |
| 1570 | - } else if ( $requires_vat ) { |
|
| 1571 | - $vat_number = self::get_user_vat_number( '', 0, true ); |
|
| 1570 | + } else if ($requires_vat) { |
|
| 1571 | + $vat_number = self::get_user_vat_number('', 0, true); |
|
| 1572 | 1572 | $vat_info = self::current_vat_data(); |
| 1573 | 1573 | |
| 1574 | - if ( is_array( $vat_info ) ) { |
|
| 1575 | - $vat_number = isset( $vat_info['number'] ) && !empty( $vat_info['valid'] ) ? $vat_info['number'] : ""; |
|
| 1574 | + if (is_array($vat_info)) { |
|
| 1575 | + $vat_number = isset($vat_info['number']) && !empty($vat_info['valid']) ? $vat_info['number'] : ""; |
|
| 1576 | 1576 | } |
| 1577 | 1577 | |
| 1578 | - if ( $country == 'UK' ) { |
|
| 1578 | + if ($country == 'UK') { |
|
| 1579 | 1579 | $country = 'GB'; |
| 1580 | 1580 | } |
| 1581 | 1581 | |
| 1582 | - if ( !empty( $vat_number ) ) { |
|
| 1582 | + if (!empty($vat_number)) { |
|
| 1583 | 1583 | $rate = 0; |
| 1584 | 1584 | } else { |
| 1585 | - $rate = self::find_rate( $country, $state, $rate, $class ); // Fix if there are no tax rated and you try to pay an invoice it does not add the fallback tax rate |
|
| 1585 | + $rate = self::find_rate($country, $state, $rate, $class); // Fix if there are no tax rated and you try to pay an invoice it does not add the fallback tax rate |
|
| 1586 | 1586 | } |
| 1587 | 1587 | |
| 1588 | - if ( empty( $vat_number ) && !$is_digital ) { |
|
| 1589 | - if ( $base_country ) { |
|
| 1590 | - $rate = self::find_rate( $country, null, $rate, $class ); |
|
| 1588 | + if (empty($vat_number) && !$is_digital) { |
|
| 1589 | + if ($base_country) { |
|
| 1590 | + $rate = self::find_rate($country, null, $rate, $class); |
|
| 1591 | 1591 | } else { |
| 1592 | - if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) { |
|
| 1592 | + if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) { |
|
| 1593 | 1593 | $rate = $wpinv_options['eu_fallback_rate']; |
| 1594 | - } else if( !empty( $country ) ) { |
|
| 1595 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
| 1594 | + } else if (!empty($country)) { |
|
| 1595 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
| 1596 | 1596 | } |
| 1597 | 1597 | } |
| 1598 | - } else if ( empty( $vat_number ) || ( self::same_country_rule() == 'always' && $base_country ) ) { |
|
| 1599 | - if ( empty( $country ) && isset( $wpinv_options['eu_fallback_rate'] ) ) { |
|
| 1598 | + } else if (empty($vat_number) || (self::same_country_rule() == 'always' && $base_country)) { |
|
| 1599 | + if (empty($country) && isset($wpinv_options['eu_fallback_rate'])) { |
|
| 1600 | 1600 | $rate = $wpinv_options['eu_fallback_rate']; |
| 1601 | - } else if( !empty( $country ) ) { |
|
| 1602 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
| 1601 | + } else if (!empty($country)) { |
|
| 1602 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
| 1603 | 1603 | } |
| 1604 | 1604 | } |
| 1605 | 1605 | } else { |
| 1606 | - if ( $is_digital ) { |
|
| 1606 | + if ($is_digital) { |
|
| 1607 | 1607 | $ip_country_code = self::get_country_by_ip(); |
| 1608 | 1608 | |
| 1609 | - if ( $ip_country_code && self::is_eu_state( $ip_country_code ) ) { |
|
| 1610 | - $rate = self::find_rate( $ip_country_code, '', 0, $class ); |
|
| 1609 | + if ($ip_country_code && self::is_eu_state($ip_country_code)) { |
|
| 1610 | + $rate = self::find_rate($ip_country_code, '', 0, $class); |
|
| 1611 | 1611 | } else { |
| 1612 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
| 1612 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
| 1613 | 1613 | } |
| 1614 | 1614 | } else { |
| 1615 | - $rate = self::find_rate( $country, $state, $rate, $class ); |
|
| 1615 | + $rate = self::find_rate($country, $state, $rate, $class); |
|
| 1616 | 1616 | } |
| 1617 | 1617 | } |
| 1618 | 1618 | |
@@ -1620,48 +1620,48 @@ discard block |
||
| 1620 | 1620 | } |
| 1621 | 1621 | |
| 1622 | 1622 | public static function current_vat_data() { |
| 1623 | - return getpaid_session()->get( 'user_vat_data' ); |
|
| 1623 | + return getpaid_session()->get('user_vat_data'); |
|
| 1624 | 1624 | } |
| 1625 | 1625 | |
| 1626 | - public static function get_user_country( $country = '', $user_id = 0 ) { |
|
| 1627 | - $user_address = wpinv_get_user_address( $user_id, false ); |
|
| 1626 | + public static function get_user_country($country = '', $user_id = 0) { |
|
| 1627 | + $user_address = wpinv_get_user_address($user_id, false); |
|
| 1628 | 1628 | |
| 1629 | - if ( wpinv_get_option( 'vat_ip_country_default' ) ) { |
|
| 1629 | + if (wpinv_get_option('vat_ip_country_default')) { |
|
| 1630 | 1630 | $country = ''; |
| 1631 | 1631 | } |
| 1632 | 1632 | |
| 1633 | - $country = empty( $user_address ) || !isset( $user_address['country'] ) || empty( $user_address['country'] ) ? $country : $user_address['country']; |
|
| 1634 | - $result = apply_filters( 'wpinv_get_user_country', $country, $user_id ); |
|
| 1633 | + $country = empty($user_address) || !isset($user_address['country']) || empty($user_address['country']) ? $country : $user_address['country']; |
|
| 1634 | + $result = apply_filters('wpinv_get_user_country', $country, $user_id); |
|
| 1635 | 1635 | |
| 1636 | - if ( empty( $result ) ) { |
|
| 1636 | + if (empty($result)) { |
|
| 1637 | 1637 | $result = self::get_country_by_ip(); |
| 1638 | 1638 | } |
| 1639 | 1639 | |
| 1640 | 1640 | return $result; |
| 1641 | 1641 | } |
| 1642 | 1642 | |
| 1643 | - public static function set_user_country( $country = '', $user_id = 0 ) { |
|
| 1643 | + public static function set_user_country($country = '', $user_id = 0) { |
|
| 1644 | 1644 | global $wpi_userID; |
| 1645 | 1645 | |
| 1646 | - if ( empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID ) { |
|
| 1646 | + if (empty($country) && !empty($wpi_userID) && get_current_user_id() != $wpi_userID) { |
|
| 1647 | 1647 | $country = wpinv_get_default_country(); |
| 1648 | 1648 | } |
| 1649 | 1649 | |
| 1650 | 1650 | return $country; |
| 1651 | 1651 | } |
| 1652 | 1652 | |
| 1653 | - public static function get_user_vat_number( $vat_number = '', $user_id = 0, $is_valid = false ) { |
|
| 1653 | + public static function get_user_vat_number($vat_number = '', $user_id = 0, $is_valid = false) { |
|
| 1654 | 1654 | global $wpi_current_id, $wpi_userID; |
| 1655 | 1655 | |
| 1656 | - if ( !empty( $_POST['new_user'] ) ) { |
|
| 1656 | + if (!empty($_POST['new_user'])) { |
|
| 1657 | 1657 | return ''; |
| 1658 | 1658 | } |
| 1659 | 1659 | |
| 1660 | - if ( empty( $user_id ) ) { |
|
| 1661 | - $user_id = !empty( $wpi_userID ) ? $wpi_userID : ( $wpi_current_id ? wpinv_get_user_id( $wpi_current_id ) : get_current_user_id() ); |
|
| 1660 | + if (empty($user_id)) { |
|
| 1661 | + $user_id = !empty($wpi_userID) ? $wpi_userID : ($wpi_current_id ? wpinv_get_user_id($wpi_current_id) : get_current_user_id()); |
|
| 1662 | 1662 | } |
| 1663 | 1663 | |
| 1664 | - $vat_number = empty( $user_id ) ? '' : get_user_meta( $user_id, '_wpinv_vat_number', true ); |
|
| 1664 | + $vat_number = empty($user_id) ? '' : get_user_meta($user_id, '_wpinv_vat_number', true); |
|
| 1665 | 1665 | |
| 1666 | 1666 | /* TODO |
| 1667 | 1667 | if ( $is_valid && $vat_number ) { |
@@ -1672,38 +1672,38 @@ discard block |
||
| 1672 | 1672 | } |
| 1673 | 1673 | */ |
| 1674 | 1674 | |
| 1675 | - return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid ); |
|
| 1675 | + return apply_filters('wpinv_get_user_vat_number', $vat_number, $user_id, $is_valid); |
|
| 1676 | 1676 | } |
| 1677 | 1677 | |
| 1678 | - public static function get_user_company( $company = '', $user_id = 0 ) { |
|
| 1678 | + public static function get_user_company($company = '', $user_id = 0) { |
|
| 1679 | 1679 | global $wpi_current_id, $wpi_userID; |
| 1680 | 1680 | |
| 1681 | - if ( empty( $user_id ) ) { |
|
| 1682 | - $user_id = !empty( $wpi_userID ) ? $wpi_userID : ( $wpi_current_id ? wpinv_get_user_id( $wpi_current_id ) : get_current_user_id() ); |
|
| 1681 | + if (empty($user_id)) { |
|
| 1682 | + $user_id = !empty($wpi_userID) ? $wpi_userID : ($wpi_current_id ? wpinv_get_user_id($wpi_current_id) : get_current_user_id()); |
|
| 1683 | 1683 | } |
| 1684 | 1684 | |
| 1685 | - $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true ); |
|
| 1685 | + $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true); |
|
| 1686 | 1686 | |
| 1687 | - return apply_filters( 'wpinv_user_company', $company, $user_id ); |
|
| 1687 | + return apply_filters('wpinv_user_company', $company, $user_id); |
|
| 1688 | 1688 | } |
| 1689 | 1689 | |
| 1690 | - public static function save_user_vat_details( $company = '', $vat_number = '' ) { |
|
| 1691 | - $save = apply_filters( 'wpinv_allow_save_user_vat_details', true ); |
|
| 1690 | + public static function save_user_vat_details($company = '', $vat_number = '') { |
|
| 1691 | + $save = apply_filters('wpinv_allow_save_user_vat_details', true); |
|
| 1692 | 1692 | |
| 1693 | - if ( is_user_logged_in() && $save ) { |
|
| 1693 | + if (is_user_logged_in() && $save) { |
|
| 1694 | 1694 | $user_id = get_current_user_id(); |
| 1695 | 1695 | |
| 1696 | - if ( !empty( $vat_number ) ) { |
|
| 1697 | - update_user_meta( $user_id, '_wpinv_vat_number', $vat_number ); |
|
| 1696 | + if (!empty($vat_number)) { |
|
| 1697 | + update_user_meta($user_id, '_wpinv_vat_number', $vat_number); |
|
| 1698 | 1698 | } else { |
| 1699 | - delete_user_meta( $user_id, '_wpinv_vat_number'); |
|
| 1699 | + delete_user_meta($user_id, '_wpinv_vat_number'); |
|
| 1700 | 1700 | } |
| 1701 | 1701 | |
| 1702 | - if ( !empty( $company ) ) { |
|
| 1703 | - update_user_meta( $user_id, '_wpinv_company', $company ); |
|
| 1702 | + if (!empty($company)) { |
|
| 1703 | + update_user_meta($user_id, '_wpinv_company', $company); |
|
| 1704 | 1704 | } else { |
| 1705 | - delete_user_meta( $user_id, '_wpinv_company'); |
|
| 1706 | - delete_user_meta( $user_id, '_wpinv_vat_number'); |
|
| 1705 | + delete_user_meta($user_id, '_wpinv_company'); |
|
| 1706 | + delete_user_meta($user_id, '_wpinv_vat_number'); |
|
| 1707 | 1707 | } |
| 1708 | 1708 | } |
| 1709 | 1709 | |
@@ -1716,74 +1716,74 @@ discard block |
||
| 1716 | 1716 | $response = array(); |
| 1717 | 1717 | $response['success'] = false; |
| 1718 | 1718 | |
| 1719 | - if ( empty( $_REQUEST['_wpi_nonce'] ) || ( !empty( $_REQUEST['_wpi_nonce'] ) && !wp_verify_nonce( $_REQUEST['_wpi_nonce'], 'vat_validation' ) ) ) { |
|
| 1720 | - $response['error'] = __( 'Invalid security nonce', 'invoicing' ); |
|
| 1721 | - wp_send_json( $response ); |
|
| 1719 | + if (empty($_REQUEST['_wpi_nonce']) || (!empty($_REQUEST['_wpi_nonce']) && !wp_verify_nonce($_REQUEST['_wpi_nonce'], 'vat_validation'))) { |
|
| 1720 | + $response['error'] = __('Invalid security nonce', 'invoicing'); |
|
| 1721 | + wp_send_json($response); |
|
| 1722 | 1722 | } |
| 1723 | 1723 | |
| 1724 | 1724 | $vat_name = self::get_vat_name(); |
| 1725 | 1725 | |
| 1726 | - $company = !empty( $_POST['company'] ) ? sanitize_text_field( $_POST['company'] ) : ''; |
|
| 1727 | - $vat_number = !empty( $_POST['number'] ) ? sanitize_text_field( $_POST['number'] ) : ''; |
|
| 1726 | + $company = !empty($_POST['company']) ? sanitize_text_field($_POST['company']) : ''; |
|
| 1727 | + $vat_number = !empty($_POST['number']) ? sanitize_text_field($_POST['number']) : ''; |
|
| 1728 | 1728 | |
| 1729 | - $vat_info = getpaid_session()->get( 'user_vat_data' ); |
|
| 1730 | - if ( !is_array( $vat_info ) || empty( $vat_info ) ) { |
|
| 1731 | - $vat_info = array( 'company'=> $company, 'number' => '', 'valid' => true ); |
|
| 1729 | + $vat_info = getpaid_session()->get('user_vat_data'); |
|
| 1730 | + if (!is_array($vat_info) || empty($vat_info)) { |
|
| 1731 | + $vat_info = array('company'=> $company, 'number' => '', 'valid' => true); |
|
| 1732 | 1732 | } |
| 1733 | 1733 | |
| 1734 | - if ( empty( $vat_number ) ) { |
|
| 1735 | - $response['error'] = wp_sprintf( __( 'Please enter your %s number!', 'invoicing' ), $vat_name ); |
|
| 1734 | + if (empty($vat_number)) { |
|
| 1735 | + $response['error'] = wp_sprintf(__('Please enter your %s number!', 'invoicing'), $vat_name); |
|
| 1736 | 1736 | $vat_info['valid'] = false; |
| 1737 | - getpaid_session()->set( 'user_vat_data', $vat_info ); |
|
| 1738 | - wp_send_json( $response ); |
|
| 1737 | + getpaid_session()->set('user_vat_data', $vat_info); |
|
| 1738 | + wp_send_json($response); |
|
| 1739 | 1739 | } |
| 1740 | 1740 | |
| 1741 | - if ( empty( $company ) ) { |
|
| 1741 | + if (empty($company)) { |
|
| 1742 | 1742 | $vat_info['valid'] = false; |
| 1743 | - getpaid_session()->set( 'user_vat_data', $vat_info ); |
|
| 1743 | + getpaid_session()->set('user_vat_data', $vat_info); |
|
| 1744 | 1744 | |
| 1745 | - $response['error'] = __( 'Please enter your registered company name!', 'invoicing' ); |
|
| 1746 | - wp_send_json( $response ); |
|
| 1745 | + $response['error'] = __('Please enter your registered company name!', 'invoicing'); |
|
| 1746 | + wp_send_json($response); |
|
| 1747 | 1747 | } |
| 1748 | 1748 | |
| 1749 | - if ( !empty( $wpinv_options['vat_vies_check'] ) ) { |
|
| 1750 | - if ( empty( $wpinv_options['vat_offline_check'] ) && !self::offline_check( $vat_number ) ) { |
|
| 1749 | + if (!empty($wpinv_options['vat_vies_check'])) { |
|
| 1750 | + if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number)) { |
|
| 1751 | 1751 | $vat_info['valid'] = false; |
| 1752 | - getpaid_session()->set( 'user_vat_data', $vat_info ); |
|
| 1752 | + getpaid_session()->set('user_vat_data', $vat_info); |
|
| 1753 | 1753 | |
| 1754 | - $response['error'] = wp_sprintf( __( '%s number not validated', 'invoicing' ), $vat_name ); |
|
| 1755 | - wp_send_json( $response ); |
|
| 1754 | + $response['error'] = wp_sprintf(__('%s number not validated', 'invoicing'), $vat_name); |
|
| 1755 | + wp_send_json($response); |
|
| 1756 | 1756 | } |
| 1757 | 1757 | |
| 1758 | 1758 | $response['success'] = true; |
| 1759 | - $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name ); |
|
| 1759 | + $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name); |
|
| 1760 | 1760 | } else { |
| 1761 | - $result = self::check_vat( $vat_number ); |
|
| 1761 | + $result = self::check_vat($vat_number); |
|
| 1762 | 1762 | |
| 1763 | - if ( empty( $result['valid'] ) ) { |
|
| 1763 | + if (empty($result['valid'])) { |
|
| 1764 | 1764 | $response['error'] = $result['message']; |
| 1765 | - wp_send_json( $response ); |
|
| 1765 | + wp_send_json($response); |
|
| 1766 | 1766 | } |
| 1767 | 1767 | |
| 1768 | - $vies_company = !empty( $result['company'] ) ? $result['company'] : ''; |
|
| 1769 | - $vies_company = apply_filters( 'wpinv_vies_company_name', $vies_company ); |
|
| 1768 | + $vies_company = !empty($result['company']) ? $result['company'] : ''; |
|
| 1769 | + $vies_company = apply_filters('wpinv_vies_company_name', $vies_company); |
|
| 1770 | 1770 | |
| 1771 | - $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false; |
|
| 1771 | + $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false; |
|
| 1772 | 1772 | |
| 1773 | - if ( !empty( $wpinv_options['vat_disable_company_name_check'] ) || $valid_company ) { |
|
| 1773 | + if (!empty($wpinv_options['vat_disable_company_name_check']) || $valid_company) { |
|
| 1774 | 1774 | $response['success'] = true; |
| 1775 | - $response['message'] = wp_sprintf( __( '%s number validated', 'invoicing' ), $vat_name ); |
|
| 1775 | + $response['message'] = wp_sprintf(__('%s number validated', 'invoicing'), $vat_name); |
|
| 1776 | 1776 | } else { |
| 1777 | 1777 | $vat_info['valid'] = false; |
| 1778 | - getpaid_session()->set( 'user_vat_data', $vat_info ); |
|
| 1778 | + getpaid_session()->set('user_vat_data', $vat_info); |
|
| 1779 | 1779 | |
| 1780 | 1780 | $response['success'] = false; |
| 1781 | - $response['message'] = wp_sprintf( __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ), $vat_name ); |
|
| 1782 | - wp_send_json( $response ); |
|
| 1781 | + $response['message'] = wp_sprintf(__('The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing'), $vat_name); |
|
| 1782 | + wp_send_json($response); |
|
| 1783 | 1783 | } |
| 1784 | 1784 | } |
| 1785 | 1785 | |
| 1786 | - wp_send_json( $response ); |
|
| 1786 | + wp_send_json($response); |
|
| 1787 | 1787 | } |
| 1788 | 1788 | |
| 1789 | 1789 | /** |
@@ -1791,16 +1791,16 @@ discard block |
||
| 1791 | 1791 | * |
| 1792 | 1792 | * @return string |
| 1793 | 1793 | */ |
| 1794 | - public static function validate_vat_number( $vat_number, $company, $country ) { |
|
| 1794 | + public static function validate_vat_number($vat_number, $company, $country) { |
|
| 1795 | 1795 | global $wpinv_options; |
| 1796 | 1796 | |
| 1797 | 1797 | // If we are not checking the vat number via view... |
| 1798 | - if ( ! empty( $wpinv_options['vat_vies_check'] ) ) { |
|
| 1798 | + if (!empty($wpinv_options['vat_vies_check'])) { |
|
| 1799 | 1799 | |
| 1800 | 1800 | // Try validating via regex. |
| 1801 | - if ( empty( $wpinv_options['vat_offline_check'] ) && ! self::offline_check( $vat_number, $country ) ) { |
|
| 1801 | + if (empty($wpinv_options['vat_offline_check']) && !self::offline_check($vat_number, $country)) { |
|
| 1802 | 1802 | return wp_sprintf( |
| 1803 | - __( 'Your %s number is invalid', 'invoicing' ), |
|
| 1803 | + __('Your %s number is invalid', 'invoicing'), |
|
| 1804 | 1804 | getpaid_vat_name() |
| 1805 | 1805 | ); |
| 1806 | 1806 | } |
@@ -1809,23 +1809,23 @@ discard block |
||
| 1809 | 1809 | } |
| 1810 | 1810 | |
| 1811 | 1811 | // Validate the vat number. |
| 1812 | - $result = self::check_vat( $vat_number, $country ); |
|
| 1812 | + $result = self::check_vat($vat_number, $country); |
|
| 1813 | 1813 | |
| 1814 | - if ( empty( $result['valid'] ) ) { |
|
| 1814 | + if (empty($result['valid'])) { |
|
| 1815 | 1815 | return wp_sprintf( |
| 1816 | - __( 'Failed to validate the %s number via EU Commission VAT server (VIES).', 'invoicing' ), |
|
| 1816 | + __('Failed to validate the %s number via EU Commission VAT server (VIES).', 'invoicing'), |
|
| 1817 | 1817 | getpaid_vat_name() |
| 1818 | 1818 | ); |
| 1819 | 1819 | } |
| 1820 | 1820 | |
| 1821 | 1821 | // Validate the company. |
| 1822 | - $vies_company = ! empty( $result['company'] ) ? $result['company'] : ''; |
|
| 1823 | - $vies_company = apply_filters( 'wpinv_vies_company_name', $vies_company ); |
|
| 1824 | - $valid_company = $vies_company && $company && ( $vies_company == '---' || strcasecmp( trim( $vies_company ), trim( $company ) ) == 0 ) ? true : false; |
|
| 1822 | + $vies_company = !empty($result['company']) ? $result['company'] : ''; |
|
| 1823 | + $vies_company = apply_filters('wpinv_vies_company_name', $vies_company); |
|
| 1824 | + $valid_company = $vies_company && $company && ($vies_company == '---' || strcasecmp(trim($vies_company), trim($company)) == 0) ? true : false; |
|
| 1825 | 1825 | |
| 1826 | - if ( ! $valid_company && ! empty( $wpinv_options['vat_disable_company_name_check'] ) ) { |
|
| 1826 | + if (!$valid_company && !empty($wpinv_options['vat_disable_company_name_check'])) { |
|
| 1827 | 1827 | return wp_sprintf( |
| 1828 | - __( 'The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing' ), |
|
| 1828 | + __('The company name associated with the %s number provided is not the same as the company name provided.', 'invoicing'), |
|
| 1829 | 1829 | getpaid_vat_name() |
| 1830 | 1830 | ); |
| 1831 | 1831 | } |
@@ -7,17 +7,17 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | -if ( empty( $text ) ) { |
|
| 13 | - $text = __( 'Your IP address is:', 'invoicing' ); |
|
| 12 | +if (empty($text)) { |
|
| 13 | + $text = __('Your IP address is:', 'invoicing'); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -$ip_address = sanitize_text_field( wpinv_get_ip() ); |
|
| 17 | -$url = esc_url( getpaid_ip_location_url( $ip_address ) ); |
|
| 16 | +$ip_address = sanitize_text_field(wpinv_get_ip()); |
|
| 17 | +$url = esc_url(getpaid_ip_location_url($ip_address)); |
|
| 18 | 18 | |
| 19 | 19 | ?> |
| 20 | 20 | <div class="form-group getpaid-ip-info"> |
| 21 | - <span><?php echo wp_kses_post( $text ); ?></span> |
|
| 21 | + <span><?php echo wp_kses_post($text); ?></span> |
|
| 22 | 22 | <a target='_blank' href='<?php echo $url; ?>'><?php echo $ip_address; ?> <i class='fa fa-external-link-square' aria-hidden='true'></i></a> |
| 23 | 23 | </div> |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | |
| 13 | 13 | ?><!DOCTYPE html> |
@@ -16,14 +16,14 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | <head> |
| 18 | 18 | |
| 19 | - <meta charset="<?php bloginfo( 'charset' ); ?>"> |
|
| 19 | + <meta charset="<?php bloginfo('charset'); ?>"> |
|
| 20 | 20 | <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" > |
| 21 | 21 | |
| 22 | 22 | <meta name="robots" content="noindex,nofollow"> |
| 23 | 23 | |
| 24 | 24 | <link rel="profile" href="https://gmpg.org/xfn/11"> |
| 25 | 25 | |
| 26 | - <title><?php _e( 'GetPaid GeoLocation', 'invoicing' ); ?></title> |
|
| 26 | + <title><?php _e('GetPaid GeoLocation', 'invoicing'); ?></title> |
|
| 27 | 27 | |
| 28 | 28 | <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" /> |
| 29 | 29 | <script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script> |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', |
| 70 | 70 | osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
| 71 | 71 | osm = L.tileLayer( osmUrl, { maxZoom: 18, attribution: osmAttrib } ), |
| 72 | - latlng = new L.LatLng( <?php echo sanitize_text_field( $latitude );?>, <?php echo sanitize_text_field( $longitude );?> ); |
|
| 72 | + latlng = new L.LatLng( <?php echo sanitize_text_field($latitude); ?>, <?php echo sanitize_text_field($longitude); ?> ); |
|
| 73 | 73 | |
| 74 | 74 | var map = new L.Map( 'map', {center: latlng, zoom: 18, layers: [osm]}); |
| 75 | 75 | |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | map.addLayer(marker); |
| 78 | 78 | |
| 79 | 79 | marker |
| 80 | - .bindPopup("<p><?php echo esc_attr( $address );?></p>") |
|
| 80 | + .bindPopup("<p><?php echo esc_attr($address); ?></p>") |
|
| 81 | 81 | .openPopup(); |
| 82 | 82 | </script> |
| 83 | 83 | |
| 84 | - <div style="height:100px"><?php echo wp_kses_post( $content ); ?></div> |
|
| 84 | + <div style="height:100px"><?php echo wp_kses_post($content); ?></div> |
|
| 85 | 85 | |
| 86 | 86 | </body> |
| 87 | 87 | |
@@ -7,16 +7,16 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | // Totals rows. |
| 13 | 13 | $totals = apply_filters( |
| 14 | 14 | 'getpaid_payment_form_cart_table_totals', |
| 15 | 15 | array( |
| 16 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
| 17 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 18 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 19 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 16 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
| 17 | + 'tax' => __('Tax', 'invoicing'), |
|
| 18 | + 'discount' => __('Discount', 'invoicing'), |
|
| 19 | + 'total' => __('Total', 'invoicing'), |
|
| 20 | 20 | ), |
| 21 | 21 | $form |
| 22 | 22 | ); |
@@ -24,15 +24,15 @@ discard block |
||
| 24 | 24 | $currency = $form->get_currency(); |
| 25 | 25 | $country = wpinv_get_default_country(); |
| 26 | 26 | |
| 27 | -if ( ! empty( $form->invoice ) ) { |
|
| 28 | - $country = $form->invoice->get_country(); |
|
| 27 | +if (!empty($form->invoice)) { |
|
| 28 | + $country = $form->invoice->get_country(); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | -if ( ! wpinv_use_taxes() && isset( $totals['tax'] ) ) { |
|
| 32 | - unset( $totals['tax'] ); |
|
| 31 | +if (!wpinv_use_taxes() && isset($totals['tax'])) { |
|
| 32 | + unset($totals['tax']); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | -do_action( 'getpaid_before_payment_form_cart_totals', $form, $totals ); |
|
| 35 | +do_action('getpaid_before_payment_form_cart_totals', $form, $totals); |
|
| 36 | 36 | |
| 37 | 37 | $tax = 0; |
| 38 | 38 | $sub_total = 0; |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | $discount = 0; |
| 41 | 41 | |
| 42 | 42 | // Calculate totals. |
| 43 | -foreach ( $form->get_items() as $item ) { |
|
| 43 | +foreach ($form->get_items() as $item) { |
|
| 44 | 44 | |
| 45 | - if ( ! empty( $form->invoice ) && 'amount' == $form->invoice->get_template() ) { |
|
| 45 | + if (!empty($form->invoice) && 'amount' == $form->invoice->get_template()) { |
|
| 46 | 46 | $amount = $item->get_price(); |
| 47 | 47 | } else { |
| 48 | 48 | $amount = $item->get_sub_total(); |
@@ -50,11 +50,11 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | // Include the tax. |
| 53 | - if ( wpinv_use_taxes() ) { |
|
| 54 | - $rate = wpinv_get_tax_rate( $country, false, $item->get_id() ); |
|
| 53 | + if (wpinv_use_taxes()) { |
|
| 54 | + $rate = wpinv_get_tax_rate($country, false, $item->get_id()); |
|
| 55 | 55 | |
| 56 | - if ( wpinv_prices_include_tax() ) { |
|
| 57 | - $pre_tax = ( $amount - $amount * $rate * 0.01 ); |
|
| 56 | + if (wpinv_prices_include_tax()) { |
|
| 57 | + $pre_tax = ($amount - $amount * $rate * 0.01); |
|
| 58 | 58 | $item_tax = $amount - $pre_tax; |
| 59 | 59 | } else { |
| 60 | 60 | $pre_tax = $amount; |
@@ -66,41 +66,41 @@ discard block |
||
| 66 | 66 | $total = $sub_total + $tax; |
| 67 | 67 | |
| 68 | 68 | } else { |
| 69 | - $total = $total + $amount; |
|
| 69 | + $total = $total + $amount; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | ?> |
| 75 | 75 | <div class='border-top getpaid-payment-form-items-cart-totals'> |
| 76 | - <?php foreach ( $totals as $key => $label ) : ?> |
|
| 77 | - <div class="getpaid-form-cart-totals-col getpaid-form-cart-totals-<?php echo esc_attr( $key ); ?>"> |
|
| 76 | + <?php foreach ($totals as $key => $label) : ?> |
|
| 77 | + <div class="getpaid-form-cart-totals-col getpaid-form-cart-totals-<?php echo esc_attr($key); ?>"> |
|
| 78 | 78 | <div class="row"> |
| 79 | 79 | <div class="col-12 offset-sm-5 col-sm-4"> |
| 80 | - <?php echo sanitize_text_field( $label ); ?> |
|
| 80 | + <?php echo sanitize_text_field($label); ?> |
|
| 81 | 81 | </div> |
| 82 | - <div class="col-12 col-sm-3 getpaid-form-cart-totals-total-<?php echo esc_attr( $key ); ?>"> |
|
| 82 | + <div class="col-12 col-sm-3 getpaid-form-cart-totals-total-<?php echo esc_attr($key); ?>"> |
|
| 83 | 83 | <?php |
| 84 | - do_action( "getpaid_payment_form_cart_totals_$key", $form ); |
|
| 84 | + do_action("getpaid_payment_form_cart_totals_$key", $form); |
|
| 85 | 85 | |
| 86 | 86 | // Total tax. |
| 87 | - if ( 'tax' == $key ) { |
|
| 88 | - echo wpinv_price( wpinv_format_amount( $tax ), $currency ); |
|
| 87 | + if ('tax' == $key) { |
|
| 88 | + echo wpinv_price(wpinv_format_amount($tax), $currency); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | // Total discount. |
| 92 | - if ( 'discount' == $key ) { |
|
| 93 | - echo wpinv_price( wpinv_format_amount( $discount ), $currency ); |
|
| 92 | + if ('discount' == $key) { |
|
| 93 | + echo wpinv_price(wpinv_format_amount($discount), $currency); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | // Sub total. |
| 97 | - if ( 'subtotal' == $key ) { |
|
| 98 | - echo wpinv_price( wpinv_format_amount( $sub_total ), $currency ); |
|
| 97 | + if ('subtotal' == $key) { |
|
| 98 | + echo wpinv_price(wpinv_format_amount($sub_total), $currency); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // Total. |
| 102 | - if ( 'total' == $key ) { |
|
| 103 | - echo wpinv_price( wpinv_format_amount( $total ), $currency ); |
|
| 102 | + if ('total' == $key) { |
|
| 103 | + echo wpinv_price(wpinv_format_amount($total), $currency); |
|
| 104 | 104 | } |
| 105 | 105 | ?> |
| 106 | 106 | </div> |
@@ -110,4 +110,4 @@ discard block |
||
| 110 | 110 | </div> |
| 111 | 111 | |
| 112 | 112 | <?php |
| 113 | -do_action( 'getpaid_payment_form_cart_totals', $form, $totals ); |
|
| 113 | +do_action('getpaid_payment_form_cart_totals', $form, $totals); |
|