@@ -31,6 +31,9 @@ discard block |
||
| 31 | 31 | return apply_filters( 'wpinv_get_ip', $ip ); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | +/** |
|
| 35 | + * @return string |
|
| 36 | + */ |
|
| 34 | 37 | function wpinv_get_user_agent() { |
| 35 | 38 | if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
| 36 | 39 | $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
@@ -41,6 +44,9 @@ discard block |
||
| 41 | 44 | return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
| 42 | 45 | } |
| 43 | 46 | |
| 47 | +/** |
|
| 48 | + * @param integer $decimals |
|
| 49 | + */ |
|
| 44 | 50 | function wpinv_sanitize_amount( $amount, $decimals = NULL ) { |
| 45 | 51 | $is_negative = false; |
| 46 | 52 | $thousands_sep = wpinv_thousands_separator(); |
@@ -79,6 +85,9 @@ discard block |
||
| 79 | 85 | } |
| 80 | 86 | add_filter( 'wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1 ); |
| 81 | 87 | |
| 88 | +/** |
|
| 89 | + * @param integer $decimals |
|
| 90 | + */ |
|
| 82 | 91 | function wpinv_round_amount( $amount, $decimals = NULL ) { |
| 83 | 92 | if ( $decimals === NULL ) { |
| 84 | 93 | $decimals = wpinv_decimals(); |
@@ -117,6 +126,9 @@ discard block |
||
| 117 | 126 | return $status; |
| 118 | 127 | } |
| 119 | 128 | |
| 129 | +/** |
|
| 130 | + * @return string |
|
| 131 | + */ |
|
| 120 | 132 | function wpinv_get_currency() { |
| 121 | 133 | $currency = wpinv_get_option( 'currency', 'USD' ); |
| 122 | 134 | |
@@ -187,6 +199,9 @@ discard block |
||
| 187 | 199 | return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
| 188 | 200 | } |
| 189 | 201 | |
| 202 | +/** |
|
| 203 | + * @return string |
|
| 204 | + */ |
|
| 190 | 205 | function wpinv_currency_position() { |
| 191 | 206 | $position = wpinv_get_option( 'currency_position', 'left' ); |
| 192 | 207 | |
@@ -315,6 +330,9 @@ discard block |
||
| 315 | 330 | return $price; |
| 316 | 331 | } |
| 317 | 332 | |
| 333 | +/** |
|
| 334 | + * @return string |
|
| 335 | + */ |
|
| 318 | 336 | function wpinv_format_amount( $amount, $decimals = NULL, $calculate = false ) { |
| 319 | 337 | $thousands_sep = wpinv_thousands_separator(); |
| 320 | 338 | $decimal_sep = wpinv_decimal_separator(); |
@@ -365,6 +383,9 @@ discard block |
||
| 365 | 383 | return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
| 366 | 384 | } |
| 367 | 385 | |
| 386 | +/** |
|
| 387 | + * @return string |
|
| 388 | + */ |
|
| 368 | 389 | function wpinv_get_file_extension( $str ) { |
| 369 | 390 | $parts = explode( '.', $str ); |
| 370 | 391 | return end( $parts ); |
@@ -569,6 +590,9 @@ discard block |
||
| 569 | 590 | return strlen( $str ); |
| 570 | 591 | } |
| 571 | 592 | |
| 593 | +/** |
|
| 594 | + * @param string $str |
|
| 595 | + */ |
|
| 572 | 596 | function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
| 573 | 597 | if ( function_exists( 'mb_strtolower' ) ) { |
| 574 | 598 | return mb_strtolower( $str, $encoding ); |
@@ -577,6 +601,9 @@ discard block |
||
| 577 | 601 | return strtolower( $str ); |
| 578 | 602 | } |
| 579 | 603 | |
| 604 | +/** |
|
| 605 | + * @param string $str |
|
| 606 | + */ |
|
| 580 | 607 | function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
| 581 | 608 | if ( function_exists( 'mb_strtoupper' ) ) { |
| 582 | 609 | return mb_strtoupper( $str, $encoding ); |
@@ -654,7 +681,7 @@ discard block |
||
| 654 | 681 | * |
| 655 | 682 | * @param string $str The string being decoded. |
| 656 | 683 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 657 | - * @return string The width of string. |
|
| 684 | + * @return integer The width of string. |
|
| 658 | 685 | */ |
| 659 | 686 | function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
| 660 | 687 | if ( function_exists( 'mb_strwidth' ) ) { |
@@ -708,6 +735,12 @@ discard block |
||
| 708 | 735 | if ( ! function_exists( 'cal_days_in_month' ) ) { |
| 709 | 736 | // Fallback in case the calendar extension is not loaded in PHP |
| 710 | 737 | // Only supports Gregorian calendar |
| 738 | + |
|
| 739 | + /** |
|
| 740 | + * @param integer $calendar |
|
| 741 | + * @param string $month |
|
| 742 | + * @param string $year |
|
| 743 | + */ |
|
| 711 | 744 | function cal_days_in_month( $calendar, $month, $year ) { |
| 712 | 745 | return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
| 713 | 746 | } |
@@ -7,89 +7,89 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | function wpinv_item_quantities_enabled() { |
| 15 | - $ret = wpinv_get_option( 'item_quantities', true ); |
|
| 15 | + $ret = wpinv_get_option('item_quantities', true); |
|
| 16 | 16 | |
| 17 | - return (bool) apply_filters( 'wpinv_item_quantities_enabled', $ret ); |
|
| 17 | + return (bool)apply_filters('wpinv_item_quantities_enabled', $ret); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | function wpinv_get_ip() { |
| 21 | 21 | $ip = '127.0.0.1'; |
| 22 | 22 | |
| 23 | - if ( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
| 24 | - $ip = sanitize_text_field( $_SERVER['HTTP_CLIENT_IP'] ); |
|
| 25 | - } elseif ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
| 26 | - $ip = sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_FOR'] ); |
|
| 27 | - } elseif( !empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
| 28 | - $ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] ); |
|
| 23 | + if (!empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
| 24 | + $ip = sanitize_text_field($_SERVER['HTTP_CLIENT_IP']); |
|
| 25 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 26 | + $ip = sanitize_text_field($_SERVER['HTTP_X_FORWARDED_FOR']); |
|
| 27 | + } elseif (!empty($_SERVER['REMOTE_ADDR'])) { |
|
| 28 | + $ip = sanitize_text_field($_SERVER['REMOTE_ADDR']); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - return apply_filters( 'wpinv_get_ip', $ip ); |
|
| 31 | + return apply_filters('wpinv_get_ip', $ip); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | function wpinv_get_user_agent() { |
| 35 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
| 36 | - $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
|
| 35 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
| 36 | + $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); |
|
| 37 | 37 | } else { |
| 38 | 38 | $user_agent = ''; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
|
| 41 | + return apply_filters('wpinv_get_user_agent', $user_agent); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | -function wpinv_sanitize_amount( $amount, $decimals = NULL ) { |
|
| 44 | +function wpinv_sanitize_amount($amount, $decimals = NULL) { |
|
| 45 | 45 | $is_negative = false; |
| 46 | 46 | $thousands_sep = wpinv_thousands_separator(); |
| 47 | 47 | $decimal_sep = wpinv_decimal_separator(); |
| 48 | - if ( $decimals === NULL ) { |
|
| 48 | + if ($decimals === NULL) { |
|
| 49 | 49 | $decimals = wpinv_decimals(); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // Sanitize the amount |
| 53 | - if ( $decimal_sep == ',' && false !== ( $found = strpos( $amount, $decimal_sep ) ) ) { |
|
| 54 | - if ( ( $thousands_sep == '.' || $thousands_sep == ' ' ) && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 55 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
| 56 | - } elseif( empty( $thousands_sep ) && false !== ( $found = strpos( $amount, '.' ) ) ) { |
|
| 57 | - $amount = str_replace( '.', '', $amount ); |
|
| 53 | + if ($decimal_sep == ',' && false !== ($found = strpos($amount, $decimal_sep))) { |
|
| 54 | + if (($thousands_sep == '.' || $thousands_sep == ' ') && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 55 | + $amount = str_replace($thousands_sep, '', $amount); |
|
| 56 | + } elseif (empty($thousands_sep) && false !== ($found = strpos($amount, '.'))) { |
|
| 57 | + $amount = str_replace('.', '', $amount); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $amount = str_replace( $decimal_sep, '.', $amount ); |
|
| 61 | - } elseif( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 62 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
| 60 | + $amount = str_replace($decimal_sep, '.', $amount); |
|
| 61 | + } elseif ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 62 | + $amount = str_replace($thousands_sep, '', $amount); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if( $amount < 0 ) { |
|
| 65 | + if ($amount < 0) { |
|
| 66 | 66 | $is_negative = true; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - $amount = preg_replace( '/[^0-9\.]/', '', $amount ); |
|
| 69 | + $amount = preg_replace('/[^0-9\.]/', '', $amount); |
|
| 70 | 70 | |
| 71 | - $decimals = apply_filters( 'wpinv_sanitize_amount_decimals', absint( $decimals ), $amount ); |
|
| 72 | - $amount = number_format( (double) $amount, absint( $decimals ), '.', '' ); |
|
| 71 | + $decimals = apply_filters('wpinv_sanitize_amount_decimals', absint($decimals), $amount); |
|
| 72 | + $amount = number_format((double)$amount, absint($decimals), '.', ''); |
|
| 73 | 73 | |
| 74 | - if( $is_negative ) { |
|
| 74 | + if ($is_negative) { |
|
| 75 | 75 | $amount *= -1; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - return apply_filters( 'wpinv_sanitize_amount', $amount, $decimals ); |
|
| 78 | + return apply_filters('wpinv_sanitize_amount', $amount, $decimals); |
|
| 79 | 79 | } |
| 80 | -add_filter( 'wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1 ); |
|
| 80 | +add_filter('wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1); |
|
| 81 | 81 | |
| 82 | -function wpinv_round_amount( $amount, $decimals = NULL ) { |
|
| 83 | - if ( $decimals === NULL ) { |
|
| 82 | +function wpinv_round_amount($amount, $decimals = NULL) { |
|
| 83 | + if ($decimals === NULL) { |
|
| 84 | 84 | $decimals = wpinv_decimals(); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - $amount = round( (double)$amount, wpinv_currency_decimal_filter( absint( $decimals ) ) ); |
|
| 87 | + $amount = round((double)$amount, wpinv_currency_decimal_filter(absint($decimals))); |
|
| 88 | 88 | |
| 89 | - return apply_filters( 'wpinv_round_amount', $amount, $decimals ); |
|
| 89 | + return apply_filters('wpinv_round_amount', $amount, $decimals); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | -function wpinv_get_invoice_statuses( $trashed = false ) { |
|
| 92 | +function wpinv_get_invoice_statuses($trashed = false) { |
|
| 93 | 93 | global $post; |
| 94 | 94 | $invoice_statuses = array(); |
| 95 | 95 | $invoice_statuses = array( |
@@ -103,32 +103,32 @@ discard block |
||
| 103 | 103 | 'wpi-renewal' => __('Renewal Payment', 'invoicing') |
| 104 | 104 | ); |
| 105 | 105 | |
| 106 | - if ( $trashed ) { |
|
| 107 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
| 106 | + if ($trashed) { |
|
| 107 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - return apply_filters( 'wpinv_statuses', $invoice_statuses ); |
|
| 110 | + return apply_filters('wpinv_statuses', $invoice_statuses); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | -function wpinv_status_nicename( $status ) { |
|
| 113 | +function wpinv_status_nicename($status) { |
|
| 114 | 114 | $statuses = wpinv_get_invoice_statuses(); |
| 115 | - $status = isset( $statuses[$status] ) ? $statuses[$status] : __( $status, 'invoicing' ); |
|
| 115 | + $status = isset($statuses[$status]) ? $statuses[$status] : __($status, 'invoicing'); |
|
| 116 | 116 | |
| 117 | 117 | return $status; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | function wpinv_get_currency() { |
| 121 | - $currency = wpinv_get_option( 'currency', 'USD' ); |
|
| 121 | + $currency = wpinv_get_option('currency', 'USD'); |
|
| 122 | 122 | |
| 123 | - return apply_filters( 'wpinv_currency', $currency ); |
|
| 123 | + return apply_filters('wpinv_currency', $currency); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | -function wpinv_currency_symbol( $currency = '' ) { |
|
| 127 | - if ( empty( $currency ) ) { |
|
| 126 | +function wpinv_currency_symbol($currency = '') { |
|
| 127 | + if (empty($currency)) { |
|
| 128 | 128 | $currency = wpinv_get_currency(); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - $symbols = apply_filters( 'wpinv_currency_symbols', array( |
|
| 131 | + $symbols = apply_filters('wpinv_currency_symbols', array( |
|
| 132 | 132 | 'AED' => 'د.إ', |
| 133 | 133 | 'AFN' => '؋', |
| 134 | 134 | 'ALL' => 'L', |
@@ -291,208 +291,208 @@ discard block |
||
| 291 | 291 | 'YER' => '﷼', |
| 292 | 292 | 'ZAR' => 'R', |
| 293 | 293 | 'ZMW' => 'ZK', |
| 294 | - ) ); |
|
| 294 | + )); |
|
| 295 | 295 | |
| 296 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency; |
|
| 296 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
| 297 | 297 | |
| 298 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
| 298 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | function wpinv_currency_position() { |
| 302 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
| 302 | + $position = wpinv_get_option('currency_position', 'left'); |
|
| 303 | 303 | |
| 304 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
| 304 | + return apply_filters('wpinv_currency_position', $position); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | function wpinv_thousands_separator() { |
| 308 | - $thousand_sep = wpinv_get_option( 'thousands_separator', ',' ); |
|
| 308 | + $thousand_sep = wpinv_get_option('thousands_separator', ','); |
|
| 309 | 309 | |
| 310 | - return apply_filters( 'wpinv_thousands_separator', $thousand_sep ); |
|
| 310 | + return apply_filters('wpinv_thousands_separator', $thousand_sep); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | function wpinv_decimal_separator() { |
| 314 | - $decimal_sep = wpinv_get_option( 'decimal_separator', '.' ); |
|
| 314 | + $decimal_sep = wpinv_get_option('decimal_separator', '.'); |
|
| 315 | 315 | |
| 316 | - return apply_filters( 'wpinv_decimal_separator', $decimal_sep ); |
|
| 316 | + return apply_filters('wpinv_decimal_separator', $decimal_sep); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | function wpinv_decimals() { |
| 320 | - $decimals = apply_filters( 'wpinv_decimals', wpinv_get_option( 'decimals', 2 ) ); |
|
| 320 | + $decimals = apply_filters('wpinv_decimals', wpinv_get_option('decimals', 2)); |
|
| 321 | 321 | |
| 322 | - return absint( $decimals ); |
|
| 322 | + return absint($decimals); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | function wpinv_get_currencies() { |
| 326 | 326 | $currencies = array( |
| 327 | - 'USD' => __( 'US Dollar', 'invoicing' ), |
|
| 328 | - 'EUR' => __( 'Euro', 'invoicing' ), |
|
| 329 | - 'GBP' => __( 'Pound Sterling', 'invoicing' ), |
|
| 330 | - 'AFN' => __( 'Afghan Afghani', 'invoicing' ), |
|
| 331 | - 'ALL' => __( 'Albanian Lek', 'invoicing' ), |
|
| 332 | - 'AMD' => __( 'Armenian Dram', 'invoicing' ), |
|
| 333 | - 'ANG' => __( 'Netherlands Antillean Guilder', 'invoicing' ), |
|
| 334 | - 'AOA' => __( 'Angolan Kwanza', 'invoicing' ), |
|
| 335 | - 'ARS' => __( 'Argentine Peso', 'invoicing' ), |
|
| 336 | - 'AUD' => __( 'Australian Dollar', 'invoicing' ), |
|
| 337 | - 'AWG' => __( 'Aruban Florin', 'invoicing' ), |
|
| 338 | - 'AZN' => __( 'Azerbaijani Manat', 'invoicing' ), |
|
| 339 | - 'BAM' => __( 'Bosnia and Herzegovina Convertible Marka', 'invoicing' ), |
|
| 340 | - 'BBD' => __( 'Barbadian Dollar', 'invoicing' ), |
|
| 341 | - 'BDT' => __( 'Bangladeshi Taka', 'invoicing' ), |
|
| 342 | - 'BGN' => __( 'Bulgarian Lev', 'invoicing' ), |
|
| 343 | - 'BHD' => __( 'Bahraini Dinar', 'invoicing' ), |
|
| 344 | - 'BIF' => __( 'Burundian Franc', 'invoicing' ), |
|
| 345 | - 'BMD' => __( 'Bermudian Dollar', 'invoicing' ), |
|
| 346 | - 'BND' => __( 'Brunei Dollar', 'invoicing' ), |
|
| 347 | - 'BOB' => __( 'Bolivian Boliviano', 'invoicing' ), |
|
| 348 | - 'BRL' => __( 'Brazilian Real', 'invoicing' ), |
|
| 349 | - 'BSD' => __( 'Bahamian Dollar', 'invoicing' ), |
|
| 350 | - 'BTC' => __( 'Bitcoin', 'invoicing' ), |
|
| 351 | - 'BTN' => __( 'Bhutanese Ngultrum', 'invoicing' ), |
|
| 352 | - 'BWP' => __( 'Botswana Pula', 'invoicing' ), |
|
| 353 | - 'BYR' => __( 'Belarusian Ruble', 'invoicing' ), |
|
| 354 | - 'BZD' => __( 'Belize Dollar', 'invoicing' ), |
|
| 355 | - 'CAD' => __( 'Canadian Dollar', 'invoicing' ), |
|
| 356 | - 'CDF' => __( 'Congolese Franc', 'invoicing' ), |
|
| 357 | - 'CHF' => __( 'Swiss Franc', 'invoicing' ), |
|
| 358 | - 'CLP' => __( 'Chilean Peso', 'invoicing' ), |
|
| 359 | - 'CNY' => __( 'Chinese Yuan', 'invoicing' ), |
|
| 360 | - 'COP' => __( 'Colombian Peso', 'invoicing' ), |
|
| 361 | - 'CRC' => __( 'Costa Rican Colon', 'invoicing' ), |
|
| 362 | - 'CUC' => __( 'Cuban Convertible Peso', 'invoicing' ), |
|
| 363 | - 'CUP' => __( 'Cuban Peso', 'invoicing' ), |
|
| 364 | - 'CVE' => __( 'Cape Verdean escudo', 'invoicing' ), |
|
| 365 | - 'CZK' => __( 'Czech Koruna', 'invoicing' ), |
|
| 366 | - 'DJF' => __( 'Djiboutian Franc', 'invoicing' ), |
|
| 367 | - 'DKK' => __( 'Danish Krone', 'invoicing' ), |
|
| 368 | - 'DOP' => __( 'Dominican Peso', 'invoicing' ), |
|
| 369 | - 'DZD' => __( 'Algerian Dinar', 'invoicing' ), |
|
| 370 | - 'EGP' => __( 'Egyptian Pound', 'invoicing' ), |
|
| 371 | - 'ERN' => __( 'Eritrean Nakfa', 'invoicing' ), |
|
| 372 | - 'ETB' => __( 'Ethiopian irr', 'invoicing' ), |
|
| 373 | - 'FJD' => __( 'Fijian Dollar', 'invoicing' ), |
|
| 374 | - 'FKP' => __( 'Falkland Islands Pound', 'invoicing' ), |
|
| 375 | - 'GEL' => __( 'Georgian lari', 'invoicing' ), |
|
| 376 | - 'GGP' => __( 'Guernsey Pound', 'invoicing' ), |
|
| 377 | - 'GHS' => __( 'Ghana cedi', 'invoicing' ), |
|
| 378 | - 'GIP' => __( 'Gibraltar Pound', 'invoicing' ), |
|
| 379 | - 'GMD' => __( 'Gambian Dalasi', 'invoicing' ), |
|
| 380 | - 'GNF' => __( 'Guinean Franc', 'invoicing' ), |
|
| 381 | - 'GTQ' => __( 'Guatemalan Quetzal', 'invoicing' ), |
|
| 382 | - 'GYD' => __( 'Guyanese Dollar', 'invoicing' ), |
|
| 383 | - 'HKD' => __( 'Hong Kong Dollar', 'invoicing' ), |
|
| 384 | - 'HNL' => __( 'Honduran Lempira', 'invoicing' ), |
|
| 385 | - 'HRK' => __( 'Croatian Kuna', 'invoicing' ), |
|
| 386 | - 'HTG' => __( 'Haitian Gourde', 'invoicing' ), |
|
| 387 | - 'HUF' => __( 'Hungarian Forint', 'invoicing' ), |
|
| 388 | - 'IDR' => __( 'Indonesian Rupiah', 'invoicing' ), |
|
| 389 | - 'ILS' => __( 'Israeli New Shekel', 'invoicing' ), |
|
| 390 | - 'IMP' => __( 'Manx Pound', 'invoicing' ), |
|
| 391 | - 'INR' => __( 'Indian Rupee', 'invoicing' ), |
|
| 392 | - 'IQD' => __( 'Iraqi Dinar', 'invoicing' ), |
|
| 393 | - 'IRR' => __( 'Iranian Rial', 'invoicing' ), |
|
| 394 | - 'IRT' => __( 'Iranian Toman', 'invoicing' ), |
|
| 395 | - 'ISK' => __( 'Icelandic Krona', 'invoicing' ), |
|
| 396 | - 'JEP' => __( 'Jersey Pound', 'invoicing' ), |
|
| 397 | - 'JMD' => __( 'Jamaican Dollar', 'invoicing' ), |
|
| 398 | - 'JOD' => __( 'Jordanian Dinar', 'invoicing' ), |
|
| 399 | - 'JPY' => __( 'Japanese Yen', 'invoicing' ), |
|
| 400 | - 'KES' => __( 'Kenyan Shilling', 'invoicing' ), |
|
| 401 | - 'KGS' => __( 'Kyrgyzstani Som', 'invoicing' ), |
|
| 402 | - 'KHR' => __( 'Cambodian Riel', 'invoicing' ), |
|
| 403 | - 'KMF' => __( 'Comorian Franc', 'invoicing' ), |
|
| 404 | - 'KPW' => __( 'North Korean Won', 'invoicing' ), |
|
| 405 | - 'KRW' => __( 'South Korean Won', 'invoicing' ), |
|
| 406 | - 'KWD' => __( 'Kuwaiti Dinar', 'invoicing' ), |
|
| 407 | - 'KYD' => __( 'Cayman Islands Dollar', 'invoicing' ), |
|
| 408 | - 'KZT' => __( 'Kazakhstani Tenge', 'invoicing' ), |
|
| 409 | - 'LAK' => __( 'Lao Kip', 'invoicing' ), |
|
| 410 | - 'LBP' => __( 'Lebanese Pound', 'invoicing' ), |
|
| 411 | - 'LKR' => __( 'Sri Lankan Rupee', 'invoicing' ), |
|
| 412 | - 'LRD' => __( 'Liberian Dollar', 'invoicing' ), |
|
| 413 | - 'LSL' => __( 'Lesotho Loti', 'invoicing' ), |
|
| 414 | - 'LYD' => __( 'Libyan Dinar', 'invoicing' ), |
|
| 415 | - 'MAD' => __( 'Moroccan Dirham', 'invoicing' ), |
|
| 416 | - 'MDL' => __( 'Moldovan Leu', 'invoicing' ), |
|
| 417 | - 'MGA' => __( 'Malagasy Ariary', 'invoicing' ), |
|
| 418 | - 'MKD' => __( 'Macedonian Denar', 'invoicing' ), |
|
| 419 | - 'MMK' => __( 'Burmese Kyat', 'invoicing' ), |
|
| 420 | - 'MNT' => __( 'Mongolian Tughrik', 'invoicing' ), |
|
| 421 | - 'MOP' => __( 'Macanese Pataca', 'invoicing' ), |
|
| 422 | - 'MRO' => __( 'Mauritanian Ouguiya', 'invoicing' ), |
|
| 423 | - 'MUR' => __( 'Mauritian Rupee', 'invoicing' ), |
|
| 424 | - 'MVR' => __( 'Maldivian Rufiyaa', 'invoicing' ), |
|
| 425 | - 'MWK' => __( 'Malawian Kwacha', 'invoicing' ), |
|
| 426 | - 'MXN' => __( 'Mexican Peso', 'invoicing' ), |
|
| 427 | - 'MYR' => __( 'Malaysian Ringgit', 'invoicing' ), |
|
| 428 | - 'MZN' => __( 'Mozambican Metical', 'invoicing' ), |
|
| 429 | - 'NAD' => __( 'Namibian Dollar', 'invoicing' ), |
|
| 430 | - 'NGN' => __( 'Nigerian Naira', 'invoicing' ), |
|
| 431 | - 'NIO' => __( 'Nicaraguan Cordoba', 'invoicing' ), |
|
| 432 | - 'NOK' => __( 'Norwegian Krone', 'invoicing' ), |
|
| 433 | - 'NPR' => __( 'Nepalese Rupee', 'invoicing' ), |
|
| 434 | - 'NZD' => __( 'New Zealand Dollar', 'invoicing' ), |
|
| 435 | - 'OMR' => __( 'Omani Rial', 'invoicing' ), |
|
| 436 | - 'PAB' => __( 'Panamanian Balboa', 'invoicing' ), |
|
| 437 | - 'PEN' => __( 'Peruvian Nuevo Sol', 'invoicing' ), |
|
| 438 | - 'PGK' => __( 'Papua New Guinean Kina', 'invoicing' ), |
|
| 439 | - 'PHP' => __( 'Philippine Peso', 'invoicing' ), |
|
| 440 | - 'PKR' => __( 'Pakistani Rupee', 'invoicing' ), |
|
| 441 | - 'PLN' => __( 'Polish Zloty', 'invoicing' ), |
|
| 442 | - 'PRB' => __( 'Transnistrian Ruble', 'invoicing' ), |
|
| 443 | - 'PYG' => __( 'Paraguayan Guarani', 'invoicing' ), |
|
| 444 | - 'QAR' => __( 'Qatari Riyal', 'invoicing' ), |
|
| 445 | - 'RON' => __( 'Romanian Leu', 'invoicing' ), |
|
| 446 | - 'RSD' => __( 'Serbian Dinar', 'invoicing' ), |
|
| 447 | - 'RUB' => __( 'Russian Ruble', 'invoicing' ), |
|
| 448 | - 'RWF' => __( 'Rwandan Franc', 'invoicing' ), |
|
| 449 | - 'SAR' => __( 'Saudi Riyal', 'invoicing' ), |
|
| 450 | - 'SBD' => __( 'Solomon Islands Dollar', 'invoicing' ), |
|
| 451 | - 'SCR' => __( 'Seychellois Rupee', 'invoicing' ), |
|
| 452 | - 'SDG' => __( 'Sudanese Pound', 'invoicing' ), |
|
| 453 | - 'SEK' => __( 'Swedish Krona', 'invoicing' ), |
|
| 454 | - 'SGD' => __( 'Singapore Dollar', 'invoicing' ), |
|
| 455 | - 'SHP' => __( 'Saint Helena Pound', 'invoicing' ), |
|
| 456 | - 'SLL' => __( 'Sierra Leonean Leone', 'invoicing' ), |
|
| 457 | - 'SOS' => __( 'Somali Shilling', 'invoicing' ), |
|
| 458 | - 'SRD' => __( 'Surinamese Dollar', 'invoicing' ), |
|
| 459 | - 'SSP' => __( 'South Sudanese Pound', 'invoicing' ), |
|
| 460 | - 'STD' => __( 'Sao Tomean Dobra', 'invoicing' ), |
|
| 461 | - 'SYP' => __( 'Syrian Pound', 'invoicing' ), |
|
| 462 | - 'SZL' => __( 'Swazi Lilangeni', 'invoicing' ), |
|
| 463 | - 'THB' => __( 'Thai Baht', 'invoicing' ), |
|
| 464 | - 'TJS' => __( 'Tajikistani Somoni', 'invoicing' ), |
|
| 465 | - 'TMT' => __( 'Turkmenistan Manat', 'invoicing' ), |
|
| 466 | - 'TND' => __( 'Tunisian Dinar', 'invoicing' ), |
|
| 467 | - 'TOP' => __( 'Tongan Paʻanga', 'invoicing' ), |
|
| 468 | - 'TRY' => __( 'Turkish Lira', 'invoicing' ), |
|
| 469 | - 'TTD' => __( 'Trinidad and Tobago Dollar', 'invoicing' ), |
|
| 470 | - 'TWD' => __( 'New Taiwan Dollar', 'invoicing' ), |
|
| 471 | - 'TZS' => __( 'Tanzanian Shilling', 'invoicing' ), |
|
| 472 | - 'UAH' => __( 'Ukrainian Hryvnia', 'invoicing' ), |
|
| 473 | - 'UGX' => __( 'Ugandan Shilling', 'invoicing' ), |
|
| 474 | - 'UYU' => __( 'Uruguayan Peso', 'invoicing' ), |
|
| 475 | - 'UZS' => __( 'Uzbekistani Som', 'invoicing' ), |
|
| 476 | - 'VEF' => __( 'Venezuelan Bolívar', 'invoicing' ), |
|
| 477 | - 'VND' => __( 'Vietnamese Dong', 'invoicing' ), |
|
| 478 | - 'VUV' => __( 'Vanuatu Vatu', 'invoicing' ), |
|
| 479 | - 'WST' => __( 'Samoan Tala', 'invoicing' ), |
|
| 480 | - 'XAF' => __( 'Central African CFA Franc', 'invoicing' ), |
|
| 481 | - 'XCD' => __( 'East Caribbean Dollar', 'invoicing' ), |
|
| 482 | - 'XOF' => __( 'West African CFA Franc', 'invoicing' ), |
|
| 483 | - 'XPF' => __( 'CFP Franc', 'invoicing' ), |
|
| 484 | - 'YER' => __( 'Yemeni Rial', 'invoicing' ), |
|
| 485 | - 'ZAR' => __( 'South African Rand', 'invoicing' ), |
|
| 486 | - 'ZMW' => __( 'Zambian Kwacha', 'invoicing' ), |
|
| 327 | + 'USD' => __('US Dollar', 'invoicing'), |
|
| 328 | + 'EUR' => __('Euro', 'invoicing'), |
|
| 329 | + 'GBP' => __('Pound Sterling', 'invoicing'), |
|
| 330 | + 'AFN' => __('Afghan Afghani', 'invoicing'), |
|
| 331 | + 'ALL' => __('Albanian Lek', 'invoicing'), |
|
| 332 | + 'AMD' => __('Armenian Dram', 'invoicing'), |
|
| 333 | + 'ANG' => __('Netherlands Antillean Guilder', 'invoicing'), |
|
| 334 | + 'AOA' => __('Angolan Kwanza', 'invoicing'), |
|
| 335 | + 'ARS' => __('Argentine Peso', 'invoicing'), |
|
| 336 | + 'AUD' => __('Australian Dollar', 'invoicing'), |
|
| 337 | + 'AWG' => __('Aruban Florin', 'invoicing'), |
|
| 338 | + 'AZN' => __('Azerbaijani Manat', 'invoicing'), |
|
| 339 | + 'BAM' => __('Bosnia and Herzegovina Convertible Marka', 'invoicing'), |
|
| 340 | + 'BBD' => __('Barbadian Dollar', 'invoicing'), |
|
| 341 | + 'BDT' => __('Bangladeshi Taka', 'invoicing'), |
|
| 342 | + 'BGN' => __('Bulgarian Lev', 'invoicing'), |
|
| 343 | + 'BHD' => __('Bahraini Dinar', 'invoicing'), |
|
| 344 | + 'BIF' => __('Burundian Franc', 'invoicing'), |
|
| 345 | + 'BMD' => __('Bermudian Dollar', 'invoicing'), |
|
| 346 | + 'BND' => __('Brunei Dollar', 'invoicing'), |
|
| 347 | + 'BOB' => __('Bolivian Boliviano', 'invoicing'), |
|
| 348 | + 'BRL' => __('Brazilian Real', 'invoicing'), |
|
| 349 | + 'BSD' => __('Bahamian Dollar', 'invoicing'), |
|
| 350 | + 'BTC' => __('Bitcoin', 'invoicing'), |
|
| 351 | + 'BTN' => __('Bhutanese Ngultrum', 'invoicing'), |
|
| 352 | + 'BWP' => __('Botswana Pula', 'invoicing'), |
|
| 353 | + 'BYR' => __('Belarusian Ruble', 'invoicing'), |
|
| 354 | + 'BZD' => __('Belize Dollar', 'invoicing'), |
|
| 355 | + 'CAD' => __('Canadian Dollar', 'invoicing'), |
|
| 356 | + 'CDF' => __('Congolese Franc', 'invoicing'), |
|
| 357 | + 'CHF' => __('Swiss Franc', 'invoicing'), |
|
| 358 | + 'CLP' => __('Chilean Peso', 'invoicing'), |
|
| 359 | + 'CNY' => __('Chinese Yuan', 'invoicing'), |
|
| 360 | + 'COP' => __('Colombian Peso', 'invoicing'), |
|
| 361 | + 'CRC' => __('Costa Rican Colon', 'invoicing'), |
|
| 362 | + 'CUC' => __('Cuban Convertible Peso', 'invoicing'), |
|
| 363 | + 'CUP' => __('Cuban Peso', 'invoicing'), |
|
| 364 | + 'CVE' => __('Cape Verdean escudo', 'invoicing'), |
|
| 365 | + 'CZK' => __('Czech Koruna', 'invoicing'), |
|
| 366 | + 'DJF' => __('Djiboutian Franc', 'invoicing'), |
|
| 367 | + 'DKK' => __('Danish Krone', 'invoicing'), |
|
| 368 | + 'DOP' => __('Dominican Peso', 'invoicing'), |
|
| 369 | + 'DZD' => __('Algerian Dinar', 'invoicing'), |
|
| 370 | + 'EGP' => __('Egyptian Pound', 'invoicing'), |
|
| 371 | + 'ERN' => __('Eritrean Nakfa', 'invoicing'), |
|
| 372 | + 'ETB' => __('Ethiopian irr', 'invoicing'), |
|
| 373 | + 'FJD' => __('Fijian Dollar', 'invoicing'), |
|
| 374 | + 'FKP' => __('Falkland Islands Pound', 'invoicing'), |
|
| 375 | + 'GEL' => __('Georgian lari', 'invoicing'), |
|
| 376 | + 'GGP' => __('Guernsey Pound', 'invoicing'), |
|
| 377 | + 'GHS' => __('Ghana cedi', 'invoicing'), |
|
| 378 | + 'GIP' => __('Gibraltar Pound', 'invoicing'), |
|
| 379 | + 'GMD' => __('Gambian Dalasi', 'invoicing'), |
|
| 380 | + 'GNF' => __('Guinean Franc', 'invoicing'), |
|
| 381 | + 'GTQ' => __('Guatemalan Quetzal', 'invoicing'), |
|
| 382 | + 'GYD' => __('Guyanese Dollar', 'invoicing'), |
|
| 383 | + 'HKD' => __('Hong Kong Dollar', 'invoicing'), |
|
| 384 | + 'HNL' => __('Honduran Lempira', 'invoicing'), |
|
| 385 | + 'HRK' => __('Croatian Kuna', 'invoicing'), |
|
| 386 | + 'HTG' => __('Haitian Gourde', 'invoicing'), |
|
| 387 | + 'HUF' => __('Hungarian Forint', 'invoicing'), |
|
| 388 | + 'IDR' => __('Indonesian Rupiah', 'invoicing'), |
|
| 389 | + 'ILS' => __('Israeli New Shekel', 'invoicing'), |
|
| 390 | + 'IMP' => __('Manx Pound', 'invoicing'), |
|
| 391 | + 'INR' => __('Indian Rupee', 'invoicing'), |
|
| 392 | + 'IQD' => __('Iraqi Dinar', 'invoicing'), |
|
| 393 | + 'IRR' => __('Iranian Rial', 'invoicing'), |
|
| 394 | + 'IRT' => __('Iranian Toman', 'invoicing'), |
|
| 395 | + 'ISK' => __('Icelandic Krona', 'invoicing'), |
|
| 396 | + 'JEP' => __('Jersey Pound', 'invoicing'), |
|
| 397 | + 'JMD' => __('Jamaican Dollar', 'invoicing'), |
|
| 398 | + 'JOD' => __('Jordanian Dinar', 'invoicing'), |
|
| 399 | + 'JPY' => __('Japanese Yen', 'invoicing'), |
|
| 400 | + 'KES' => __('Kenyan Shilling', 'invoicing'), |
|
| 401 | + 'KGS' => __('Kyrgyzstani Som', 'invoicing'), |
|
| 402 | + 'KHR' => __('Cambodian Riel', 'invoicing'), |
|
| 403 | + 'KMF' => __('Comorian Franc', 'invoicing'), |
|
| 404 | + 'KPW' => __('North Korean Won', 'invoicing'), |
|
| 405 | + 'KRW' => __('South Korean Won', 'invoicing'), |
|
| 406 | + 'KWD' => __('Kuwaiti Dinar', 'invoicing'), |
|
| 407 | + 'KYD' => __('Cayman Islands Dollar', 'invoicing'), |
|
| 408 | + 'KZT' => __('Kazakhstani Tenge', 'invoicing'), |
|
| 409 | + 'LAK' => __('Lao Kip', 'invoicing'), |
|
| 410 | + 'LBP' => __('Lebanese Pound', 'invoicing'), |
|
| 411 | + 'LKR' => __('Sri Lankan Rupee', 'invoicing'), |
|
| 412 | + 'LRD' => __('Liberian Dollar', 'invoicing'), |
|
| 413 | + 'LSL' => __('Lesotho Loti', 'invoicing'), |
|
| 414 | + 'LYD' => __('Libyan Dinar', 'invoicing'), |
|
| 415 | + 'MAD' => __('Moroccan Dirham', 'invoicing'), |
|
| 416 | + 'MDL' => __('Moldovan Leu', 'invoicing'), |
|
| 417 | + 'MGA' => __('Malagasy Ariary', 'invoicing'), |
|
| 418 | + 'MKD' => __('Macedonian Denar', 'invoicing'), |
|
| 419 | + 'MMK' => __('Burmese Kyat', 'invoicing'), |
|
| 420 | + 'MNT' => __('Mongolian Tughrik', 'invoicing'), |
|
| 421 | + 'MOP' => __('Macanese Pataca', 'invoicing'), |
|
| 422 | + 'MRO' => __('Mauritanian Ouguiya', 'invoicing'), |
|
| 423 | + 'MUR' => __('Mauritian Rupee', 'invoicing'), |
|
| 424 | + 'MVR' => __('Maldivian Rufiyaa', 'invoicing'), |
|
| 425 | + 'MWK' => __('Malawian Kwacha', 'invoicing'), |
|
| 426 | + 'MXN' => __('Mexican Peso', 'invoicing'), |
|
| 427 | + 'MYR' => __('Malaysian Ringgit', 'invoicing'), |
|
| 428 | + 'MZN' => __('Mozambican Metical', 'invoicing'), |
|
| 429 | + 'NAD' => __('Namibian Dollar', 'invoicing'), |
|
| 430 | + 'NGN' => __('Nigerian Naira', 'invoicing'), |
|
| 431 | + 'NIO' => __('Nicaraguan Cordoba', 'invoicing'), |
|
| 432 | + 'NOK' => __('Norwegian Krone', 'invoicing'), |
|
| 433 | + 'NPR' => __('Nepalese Rupee', 'invoicing'), |
|
| 434 | + 'NZD' => __('New Zealand Dollar', 'invoicing'), |
|
| 435 | + 'OMR' => __('Omani Rial', 'invoicing'), |
|
| 436 | + 'PAB' => __('Panamanian Balboa', 'invoicing'), |
|
| 437 | + 'PEN' => __('Peruvian Nuevo Sol', 'invoicing'), |
|
| 438 | + 'PGK' => __('Papua New Guinean Kina', 'invoicing'), |
|
| 439 | + 'PHP' => __('Philippine Peso', 'invoicing'), |
|
| 440 | + 'PKR' => __('Pakistani Rupee', 'invoicing'), |
|
| 441 | + 'PLN' => __('Polish Zloty', 'invoicing'), |
|
| 442 | + 'PRB' => __('Transnistrian Ruble', 'invoicing'), |
|
| 443 | + 'PYG' => __('Paraguayan Guarani', 'invoicing'), |
|
| 444 | + 'QAR' => __('Qatari Riyal', 'invoicing'), |
|
| 445 | + 'RON' => __('Romanian Leu', 'invoicing'), |
|
| 446 | + 'RSD' => __('Serbian Dinar', 'invoicing'), |
|
| 447 | + 'RUB' => __('Russian Ruble', 'invoicing'), |
|
| 448 | + 'RWF' => __('Rwandan Franc', 'invoicing'), |
|
| 449 | + 'SAR' => __('Saudi Riyal', 'invoicing'), |
|
| 450 | + 'SBD' => __('Solomon Islands Dollar', 'invoicing'), |
|
| 451 | + 'SCR' => __('Seychellois Rupee', 'invoicing'), |
|
| 452 | + 'SDG' => __('Sudanese Pound', 'invoicing'), |
|
| 453 | + 'SEK' => __('Swedish Krona', 'invoicing'), |
|
| 454 | + 'SGD' => __('Singapore Dollar', 'invoicing'), |
|
| 455 | + 'SHP' => __('Saint Helena Pound', 'invoicing'), |
|
| 456 | + 'SLL' => __('Sierra Leonean Leone', 'invoicing'), |
|
| 457 | + 'SOS' => __('Somali Shilling', 'invoicing'), |
|
| 458 | + 'SRD' => __('Surinamese Dollar', 'invoicing'), |
|
| 459 | + 'SSP' => __('South Sudanese Pound', 'invoicing'), |
|
| 460 | + 'STD' => __('Sao Tomean Dobra', 'invoicing'), |
|
| 461 | + 'SYP' => __('Syrian Pound', 'invoicing'), |
|
| 462 | + 'SZL' => __('Swazi Lilangeni', 'invoicing'), |
|
| 463 | + 'THB' => __('Thai Baht', 'invoicing'), |
|
| 464 | + 'TJS' => __('Tajikistani Somoni', 'invoicing'), |
|
| 465 | + 'TMT' => __('Turkmenistan Manat', 'invoicing'), |
|
| 466 | + 'TND' => __('Tunisian Dinar', 'invoicing'), |
|
| 467 | + 'TOP' => __('Tongan Paʻanga', 'invoicing'), |
|
| 468 | + 'TRY' => __('Turkish Lira', 'invoicing'), |
|
| 469 | + 'TTD' => __('Trinidad and Tobago Dollar', 'invoicing'), |
|
| 470 | + 'TWD' => __('New Taiwan Dollar', 'invoicing'), |
|
| 471 | + 'TZS' => __('Tanzanian Shilling', 'invoicing'), |
|
| 472 | + 'UAH' => __('Ukrainian Hryvnia', 'invoicing'), |
|
| 473 | + 'UGX' => __('Ugandan Shilling', 'invoicing'), |
|
| 474 | + 'UYU' => __('Uruguayan Peso', 'invoicing'), |
|
| 475 | + 'UZS' => __('Uzbekistani Som', 'invoicing'), |
|
| 476 | + 'VEF' => __('Venezuelan Bolívar', 'invoicing'), |
|
| 477 | + 'VND' => __('Vietnamese Dong', 'invoicing'), |
|
| 478 | + 'VUV' => __('Vanuatu Vatu', 'invoicing'), |
|
| 479 | + 'WST' => __('Samoan Tala', 'invoicing'), |
|
| 480 | + 'XAF' => __('Central African CFA Franc', 'invoicing'), |
|
| 481 | + 'XCD' => __('East Caribbean Dollar', 'invoicing'), |
|
| 482 | + 'XOF' => __('West African CFA Franc', 'invoicing'), |
|
| 483 | + 'XPF' => __('CFP Franc', 'invoicing'), |
|
| 484 | + 'YER' => __('Yemeni Rial', 'invoicing'), |
|
| 485 | + 'ZAR' => __('South African Rand', 'invoicing'), |
|
| 486 | + 'ZMW' => __('Zambian Kwacha', 'invoicing'), |
|
| 487 | 487 | ); |
| 488 | 488 | |
| 489 | 489 | //asort( $currencies ); // this |
| 490 | 490 | |
| 491 | - return apply_filters( 'wpinv_currencies', $currencies ); |
|
| 491 | + return apply_filters('wpinv_currencies', $currencies); |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | -function wpinv_price( $amount = '', $currency = '' ) { |
|
| 495 | - if( empty( $currency ) ) { |
|
| 494 | +function wpinv_price($amount = '', $currency = '') { |
|
| 495 | + if (empty($currency)) { |
|
| 496 | 496 | $currency = wpinv_get_currency(); |
| 497 | 497 | } |
| 498 | 498 | |
@@ -500,14 +500,14 @@ discard block |
||
| 500 | 500 | |
| 501 | 501 | $negative = $amount < 0; |
| 502 | 502 | |
| 503 | - if ( $negative ) { |
|
| 504 | - $amount = substr( $amount, 1 ); |
|
| 503 | + if ($negative) { |
|
| 504 | + $amount = substr($amount, 1); |
|
| 505 | 505 | } |
| 506 | 506 | |
| 507 | - $symbol = wpinv_currency_symbol( $currency ); |
|
| 507 | + $symbol = wpinv_currency_symbol($currency); |
|
| 508 | 508 | |
| 509 | - if ( $position == 'left' || $position == 'left_space' ) { |
|
| 510 | - switch ( $currency ) { |
|
| 509 | + if ($position == 'left' || $position == 'left_space') { |
|
| 510 | + switch ($currency) { |
|
| 511 | 511 | case "GBP" : |
| 512 | 512 | case "BRL" : |
| 513 | 513 | case "EUR" : |
@@ -519,15 +519,15 @@ discard block |
||
| 519 | 519 | case "NZD" : |
| 520 | 520 | case "SGD" : |
| 521 | 521 | case "JPY" : |
| 522 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 522 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 523 | 523 | break; |
| 524 | 524 | default : |
| 525 | 525 | //$price = $currency . ' ' . $amount; |
| 526 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 526 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
| 527 | 527 | break; |
| 528 | 528 | } |
| 529 | 529 | } else { |
| 530 | - switch ( $currency ) { |
|
| 530 | + switch ($currency) { |
|
| 531 | 531 | case "GBP" : |
| 532 | 532 | case "BRL" : |
| 533 | 533 | case "EUR" : |
@@ -538,83 +538,83 @@ discard block |
||
| 538 | 538 | case "MXN" : |
| 539 | 539 | case "SGD" : |
| 540 | 540 | case "JPY" : |
| 541 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 541 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 542 | 542 | break; |
| 543 | 543 | default : |
| 544 | 544 | //$price = $amount . ' ' . $currency; |
| 545 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 545 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
| 546 | 546 | break; |
| 547 | 547 | } |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | - if ( $negative ) { |
|
| 550 | + if ($negative) { |
|
| 551 | 551 | $price = '-' . $price; |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | - $price = apply_filters( 'wpinv_' . strtolower( $currency ) . '_currency_filter_' . $position, $price, $currency, $amount ); |
|
| 554 | + $price = apply_filters('wpinv_' . strtolower($currency) . '_currency_filter_' . $position, $price, $currency, $amount); |
|
| 555 | 555 | |
| 556 | 556 | return $price; |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | -function wpinv_format_amount( $amount, $decimals = NULL, $calculate = false ) { |
|
| 559 | +function wpinv_format_amount($amount, $decimals = NULL, $calculate = false) { |
|
| 560 | 560 | $thousands_sep = wpinv_thousands_separator(); |
| 561 | 561 | $decimal_sep = wpinv_decimal_separator(); |
| 562 | 562 | |
| 563 | - if ( $decimals === NULL ) { |
|
| 563 | + if ($decimals === NULL) { |
|
| 564 | 564 | $decimals = wpinv_decimals(); |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | - if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) { |
|
| 568 | - $whole = substr( $amount, 0, $sep_found ); |
|
| 569 | - $part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) ); |
|
| 567 | + if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) { |
|
| 568 | + $whole = substr($amount, 0, $sep_found); |
|
| 569 | + $part = substr($amount, $sep_found + 1, (strlen($amount) - 1)); |
|
| 570 | 570 | $amount = $whole . '.' . $part; |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | - if ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 574 | - $amount = str_replace( ',', '', $amount ); |
|
| 573 | + if ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 574 | + $amount = str_replace(',', '', $amount); |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | - if ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
| 578 | - $amount = str_replace( ' ', '', $amount ); |
|
| 577 | + if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
| 578 | + $amount = str_replace(' ', '', $amount); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | - if ( empty( $amount ) ) { |
|
| 581 | + if (empty($amount)) { |
|
| 582 | 582 | $amount = 0; |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | - $decimals = apply_filters( 'wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate ); |
|
| 586 | - $formatted = number_format( (float)$amount, $decimals, $decimal_sep, $thousands_sep ); |
|
| 585 | + $decimals = apply_filters('wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate); |
|
| 586 | + $formatted = number_format((float)$amount, $decimals, $decimal_sep, $thousands_sep); |
|
| 587 | 587 | |
| 588 | - if ( $calculate ) { |
|
| 589 | - if ( $thousands_sep === "," ) { |
|
| 590 | - $formatted = str_replace( ",", "", $formatted ); |
|
| 588 | + if ($calculate) { |
|
| 589 | + if ($thousands_sep === ",") { |
|
| 590 | + $formatted = str_replace(",", "", $formatted); |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | - if ( $decimal_sep === "," ) { |
|
| 594 | - $formatted = str_replace( ",", ".", $formatted ); |
|
| 593 | + if ($decimal_sep === ",") { |
|
| 594 | + $formatted = str_replace(",", ".", $formatted); |
|
| 595 | 595 | } |
| 596 | 596 | } |
| 597 | 597 | |
| 598 | - return apply_filters( 'wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate ); |
|
| 598 | + return apply_filters('wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate); |
|
| 599 | 599 | } |
| 600 | -add_filter( 'wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1 ); |
|
| 600 | +add_filter('wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1); |
|
| 601 | 601 | |
| 602 | -function wpinv_sanitize_key( $key ) { |
|
| 602 | +function wpinv_sanitize_key($key) { |
|
| 603 | 603 | $raw_key = $key; |
| 604 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
| 604 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
| 605 | 605 | |
| 606 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
| 606 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
| 607 | 607 | } |
| 608 | 608 | |
| 609 | -function wpinv_get_file_extension( $str ) { |
|
| 610 | - $parts = explode( '.', $str ); |
|
| 611 | - return end( $parts ); |
|
| 609 | +function wpinv_get_file_extension($str) { |
|
| 610 | + $parts = explode('.', $str); |
|
| 611 | + return end($parts); |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | -function wpinv_string_is_image_url( $str ) { |
|
| 615 | - $ext = wpinv_get_file_extension( $str ); |
|
| 614 | +function wpinv_string_is_image_url($str) { |
|
| 615 | + $ext = wpinv_get_file_extension($str); |
|
| 616 | 616 | |
| 617 | - switch ( strtolower( $ext ) ) { |
|
| 617 | + switch (strtolower($ext)) { |
|
| 618 | 618 | case 'jpeg'; |
| 619 | 619 | case 'jpg'; |
| 620 | 620 | $return = true; |
@@ -630,32 +630,32 @@ discard block |
||
| 630 | 630 | break; |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | - return (bool)apply_filters( 'wpinv_string_is_image', $return, $str ); |
|
| 633 | + return (bool)apply_filters('wpinv_string_is_image', $return, $str); |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | -function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) { |
|
| 637 | - $should_log = apply_filters( 'wpinv_log_errors', WP_DEBUG ); |
|
| 636 | +function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) { |
|
| 637 | + $should_log = apply_filters('wpinv_log_errors', WP_DEBUG); |
|
| 638 | 638 | |
| 639 | - if ( true === $should_log ) { |
|
| 639 | + if (true === $should_log) { |
|
| 640 | 640 | $label = ''; |
| 641 | - if ( $file && $file !== '' ) { |
|
| 642 | - $label .= basename( $file ) . ( $line ? '(' . $line . ')' : '' ); |
|
| 641 | + if ($file && $file !== '') { |
|
| 642 | + $label .= basename($file) . ($line ? '(' . $line . ')' : ''); |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | - if ( $title && $title !== '' ) { |
|
| 645 | + if ($title && $title !== '') { |
|
| 646 | 646 | $label = $label !== '' ? $label . ' ' : ''; |
| 647 | 647 | $label .= $title . ' '; |
| 648 | 648 | } |
| 649 | 649 | |
| 650 | - $label = $label !== '' ? trim( $label ) . ' : ' : ''; |
|
| 650 | + $label = $label !== '' ? trim($label) . ' : ' : ''; |
|
| 651 | 651 | |
| 652 | - if ( is_array( $log ) || is_object( $log ) ) { |
|
| 653 | - error_log( $label . print_r( $log, true ) ); |
|
| 652 | + if (is_array($log) || is_object($log)) { |
|
| 653 | + error_log($label . print_r($log, true)); |
|
| 654 | 654 | } else { |
| 655 | - error_log( $label . $log ); |
|
| 655 | + error_log($label . $log); |
|
| 656 | 656 | } |
| 657 | 657 | |
| 658 | - if ( $exit ) { |
|
| 658 | + if ($exit) { |
|
| 659 | 659 | exit; |
| 660 | 660 | } |
| 661 | 661 | } |
@@ -663,65 +663,65 @@ discard block |
||
| 663 | 663 | |
| 664 | 664 | function wpinv_is_ajax_disabled() { |
| 665 | 665 | $retval = false; |
| 666 | - return apply_filters( 'wpinv_is_ajax_disabled', $retval ); |
|
| 666 | + return apply_filters('wpinv_is_ajax_disabled', $retval); |
|
| 667 | 667 | } |
| 668 | 668 | |
| 669 | -function wpinv_get_current_page_url( $nocache = false ) { |
|
| 669 | +function wpinv_get_current_page_url($nocache = false) { |
|
| 670 | 670 | global $wp; |
| 671 | 671 | |
| 672 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 673 | - $base = trailingslashit( home_url( $wp->request ) ); |
|
| 672 | + if (get_option('permalink_structure')) { |
|
| 673 | + $base = trailingslashit(home_url($wp->request)); |
|
| 674 | 674 | } else { |
| 675 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); |
|
| 676 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); |
|
| 675 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); |
|
| 676 | + $base = remove_query_arg(array('post_type', 'name'), $base); |
|
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | $scheme = is_ssl() ? 'https' : 'http'; |
| 680 | - $uri = set_url_scheme( $base, $scheme ); |
|
| 680 | + $uri = set_url_scheme($base, $scheme); |
|
| 681 | 681 | |
| 682 | - if ( is_front_page() ) { |
|
| 683 | - $uri = home_url( '/' ); |
|
| 684 | - } elseif ( wpinv_is_checkout( array(), false ) ) { |
|
| 682 | + if (is_front_page()) { |
|
| 683 | + $uri = home_url('/'); |
|
| 684 | + } elseif (wpinv_is_checkout(array(), false)) { |
|
| 685 | 685 | $uri = wpinv_get_checkout_uri(); |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | - $uri = apply_filters( 'wpinv_get_current_page_url', $uri ); |
|
| 688 | + $uri = apply_filters('wpinv_get_current_page_url', $uri); |
|
| 689 | 689 | |
| 690 | - if ( $nocache ) { |
|
| 691 | - $uri = wpinv_add_cache_busting( $uri ); |
|
| 690 | + if ($nocache) { |
|
| 691 | + $uri = wpinv_add_cache_busting($uri); |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | return $uri; |
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | function wpinv_get_php_arg_separator_output() { |
| 698 | - return ini_get( 'arg_separator.output' ); |
|
| 698 | + return ini_get('arg_separator.output'); |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | -function wpinv_rgb_from_hex( $color ) { |
|
| 702 | - $color = str_replace( '#', '', $color ); |
|
| 701 | +function wpinv_rgb_from_hex($color) { |
|
| 702 | + $color = str_replace('#', '', $color); |
|
| 703 | 703 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
| 704 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
| 704 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
| 705 | 705 | |
| 706 | 706 | $rgb = array(); |
| 707 | - $rgb['R'] = hexdec( $color{0}.$color{1} ); |
|
| 708 | - $rgb['G'] = hexdec( $color{2}.$color{3} ); |
|
| 709 | - $rgb['B'] = hexdec( $color{4}.$color{5} ); |
|
| 707 | + $rgb['R'] = hexdec($color{0} . $color{1} ); |
|
| 708 | + $rgb['G'] = hexdec($color{2} . $color{3} ); |
|
| 709 | + $rgb['B'] = hexdec($color{4} . $color{5} ); |
|
| 710 | 710 | |
| 711 | 711 | return $rgb; |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
| 715 | - $base = wpinv_rgb_from_hex( $color ); |
|
| 714 | +function wpinv_hex_darker($color, $factor = 30) { |
|
| 715 | + $base = wpinv_rgb_from_hex($color); |
|
| 716 | 716 | $color = '#'; |
| 717 | 717 | |
| 718 | - foreach ( $base as $k => $v ) { |
|
| 718 | + foreach ($base as $k => $v) { |
|
| 719 | 719 | $amount = $v / 100; |
| 720 | - $amount = round( $amount * $factor ); |
|
| 720 | + $amount = round($amount * $factor); |
|
| 721 | 721 | $new_decimal = $v - $amount; |
| 722 | 722 | |
| 723 | - $new_hex_component = dechex( $new_decimal ); |
|
| 724 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
| 723 | + $new_hex_component = dechex($new_decimal); |
|
| 724 | + if (strlen($new_hex_component) < 2) { |
|
| 725 | 725 | $new_hex_component = "0" . $new_hex_component; |
| 726 | 726 | } |
| 727 | 727 | $color .= $new_hex_component; |
@@ -730,18 +730,18 @@ discard block |
||
| 730 | 730 | return $color; |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
| 734 | - $base = wpinv_rgb_from_hex( $color ); |
|
| 733 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
| 734 | + $base = wpinv_rgb_from_hex($color); |
|
| 735 | 735 | $color = '#'; |
| 736 | 736 | |
| 737 | - foreach ( $base as $k => $v ) { |
|
| 737 | + foreach ($base as $k => $v) { |
|
| 738 | 738 | $amount = 255 - $v; |
| 739 | 739 | $amount = $amount / 100; |
| 740 | - $amount = round( $amount * $factor ); |
|
| 740 | + $amount = round($amount * $factor); |
|
| 741 | 741 | $new_decimal = $v + $amount; |
| 742 | 742 | |
| 743 | - $new_hex_component = dechex( $new_decimal ); |
|
| 744 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
| 743 | + $new_hex_component = dechex($new_decimal); |
|
| 744 | + if (strlen($new_hex_component) < 2) { |
|
| 745 | 745 | $new_hex_component = "0" . $new_hex_component; |
| 746 | 746 | } |
| 747 | 747 | $color .= $new_hex_component; |
@@ -750,22 +750,22 @@ discard block |
||
| 750 | 750 | return $color; |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
| 754 | - $hex = str_replace( '#', '', $color ); |
|
| 753 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
| 754 | + $hex = str_replace('#', '', $color); |
|
| 755 | 755 | |
| 756 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
| 757 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
| 758 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
| 756 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
| 757 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
| 758 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
| 759 | 759 | |
| 760 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
| 760 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
| 761 | 761 | |
| 762 | 762 | return $brightness > 155 ? $dark : $light; |
| 763 | 763 | } |
| 764 | 764 | |
| 765 | -function wpinv_format_hex( $hex ) { |
|
| 766 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
| 765 | +function wpinv_format_hex($hex) { |
|
| 766 | + $hex = trim(str_replace('#', '', $hex)); |
|
| 767 | 767 | |
| 768 | - if ( strlen( $hex ) == 3 ) { |
|
| 768 | + if (strlen($hex) == 3) { |
|
| 769 | 769 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
| 770 | 770 | } |
| 771 | 771 | |
@@ -785,12 +785,12 @@ discard block |
||
| 785 | 785 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 786 | 786 | * @return string |
| 787 | 787 | */ |
| 788 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
| 789 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
| 790 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
| 788 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
| 789 | + if (function_exists('mb_strimwidth')) { |
|
| 790 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
| 791 | 791 | } |
| 792 | 792 | |
| 793 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
| 793 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | /** |
@@ -802,28 +802,28 @@ discard block |
||
| 802 | 802 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 803 | 803 | * @return int Returns the number of characters in string. |
| 804 | 804 | */ |
| 805 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
| 806 | - if ( function_exists( 'mb_strlen' ) ) { |
|
| 807 | - return mb_strlen( $str, $encoding ); |
|
| 805 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
| 806 | + if (function_exists('mb_strlen')) { |
|
| 807 | + return mb_strlen($str, $encoding); |
|
| 808 | 808 | } |
| 809 | 809 | |
| 810 | - return strlen( $str ); |
|
| 810 | + return strlen($str); |
|
| 811 | 811 | } |
| 812 | 812 | |
| 813 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
| 814 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
| 815 | - return mb_strtolower( $str, $encoding ); |
|
| 813 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
| 814 | + if (function_exists('mb_strtolower')) { |
|
| 815 | + return mb_strtolower($str, $encoding); |
|
| 816 | 816 | } |
| 817 | 817 | |
| 818 | - return strtolower( $str ); |
|
| 818 | + return strtolower($str); |
|
| 819 | 819 | } |
| 820 | 820 | |
| 821 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
| 822 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
| 823 | - return mb_strtoupper( $str, $encoding ); |
|
| 821 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
| 822 | + if (function_exists('mb_strtoupper')) { |
|
| 823 | + return mb_strtoupper($str, $encoding); |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | - return strtoupper( $str ); |
|
| 826 | + return strtoupper($str); |
|
| 827 | 827 | } |
| 828 | 828 | |
| 829 | 829 | /** |
@@ -837,12 +837,12 @@ discard block |
||
| 837 | 837 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 838 | 838 | * @return int Returns the position of the first occurrence of search in the string. |
| 839 | 839 | */ |
| 840 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
| 841 | - if ( function_exists( 'mb_strpos' ) ) { |
|
| 842 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
| 840 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
| 841 | + if (function_exists('mb_strpos')) { |
|
| 842 | + return mb_strpos($str, $find, $offset, $encoding); |
|
| 843 | 843 | } |
| 844 | 844 | |
| 845 | - return strpos( $str, $find, $offset ); |
|
| 845 | + return strpos($str, $find, $offset); |
|
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | /** |
@@ -856,12 +856,12 @@ discard block |
||
| 856 | 856 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 857 | 857 | * @return int Returns the position of the last occurrence of search. |
| 858 | 858 | */ |
| 859 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
| 860 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
| 861 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
| 859 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
| 860 | + if (function_exists('mb_strrpos')) { |
|
| 861 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
| 862 | 862 | } |
| 863 | 863 | |
| 864 | - return strrpos( $str, $find, $offset ); |
|
| 864 | + return strrpos($str, $find, $offset); |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | /** |
@@ -876,16 +876,16 @@ discard block |
||
| 876 | 876 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 877 | 877 | * @return string |
| 878 | 878 | */ |
| 879 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
| 880 | - if ( function_exists( 'mb_substr' ) ) { |
|
| 881 | - if ( $length === null ) { |
|
| 882 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
| 879 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
| 880 | + if (function_exists('mb_substr')) { |
|
| 881 | + if ($length === null) { |
|
| 882 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
| 883 | 883 | } else { |
| 884 | - return mb_substr( $str, $start, $length, $encoding ); |
|
| 884 | + return mb_substr($str, $start, $length, $encoding); |
|
| 885 | 885 | } |
| 886 | 886 | } |
| 887 | 887 | |
| 888 | - return substr( $str, $start, $length ); |
|
| 888 | + return substr($str, $start, $length); |
|
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | /** |
@@ -897,48 +897,48 @@ discard block |
||
| 897 | 897 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
| 898 | 898 | * @return string The width of string. |
| 899 | 899 | */ |
| 900 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
| 901 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
| 902 | - return mb_strwidth( $str, $encoding ); |
|
| 900 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
| 901 | + if (function_exists('mb_strwidth')) { |
|
| 902 | + return mb_strwidth($str, $encoding); |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
| 905 | + return wpinv_utf8_strlen($str, $encoding); |
|
| 906 | 906 | } |
| 907 | 907 | |
| 908 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
| 909 | - if ( function_exists( 'mb_strlen' ) ) { |
|
| 910 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
| 908 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
| 909 | + if (function_exists('mb_strlen')) { |
|
| 910 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
| 911 | 911 | $str_end = ""; |
| 912 | 912 | |
| 913 | - if ( $lower_str_end ) { |
|
| 914 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
| 913 | + if ($lower_str_end) { |
|
| 914 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
| 915 | 915 | } else { |
| 916 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
| 916 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
| 917 | 917 | } |
| 918 | 918 | |
| 919 | 919 | return $first_letter . $str_end; |
| 920 | 920 | } |
| 921 | 921 | |
| 922 | - return ucfirst( $str ); |
|
| 922 | + return ucfirst($str); |
|
| 923 | 923 | } |
| 924 | 924 | |
| 925 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
| 926 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
| 927 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
| 925 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
| 926 | + if (function_exists('mb_convert_case')) { |
|
| 927 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
| 928 | 928 | } |
| 929 | 929 | |
| 930 | - return ucwords( $str ); |
|
| 930 | + return ucwords($str); |
|
| 931 | 931 | } |
| 932 | 932 | |
| 933 | -function wpinv_period_in_days( $period, $unit ) { |
|
| 934 | - $period = absint( $period ); |
|
| 933 | +function wpinv_period_in_days($period, $unit) { |
|
| 934 | + $period = absint($period); |
|
| 935 | 935 | |
| 936 | - if ( $period > 0 ) { |
|
| 937 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
| 936 | + if ($period > 0) { |
|
| 937 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
| 938 | 938 | $period = $period * 7; |
| 939 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
| 939 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
| 940 | 940 | $period = $period * 30; |
| 941 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
| 941 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
| 942 | 942 | $period = $period * 365; |
| 943 | 943 | } |
| 944 | 944 | } |
@@ -946,10 +946,10 @@ discard block |
||
| 946 | 946 | return $period; |
| 947 | 947 | } |
| 948 | 948 | |
| 949 | -if ( ! function_exists( 'cal_days_in_month' ) ) { |
|
| 949 | +if (!function_exists('cal_days_in_month')) { |
|
| 950 | 950 | // Fallback in case the calendar extension is not loaded in PHP |
| 951 | 951 | // Only supports Gregorian calendar |
| 952 | - function cal_days_in_month( $calendar, $month, $year ) { |
|
| 953 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
| 952 | + function cal_days_in_month($calendar, $month, $year) { |
|
| 953 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
| 954 | 954 | } |
| 955 | 955 | } |
| 956 | 956 | \ No newline at end of file |
@@ -1,6 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly. |
| 3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if (!defined( 'ABSPATH' ) ) { |
|
| 4 | + exit; |
|
| 5 | +} |
|
| 4 | 6 | |
| 5 | 7 | /** |
| 6 | 8 | * The Subscriptions DB Class |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly. |
| 3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if (!defined('ABSPATH')) exit; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * The Subscriptions DB Class |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | 'transaction_id' => '', |
| 69 | 69 | 'parent_payment_id' => 0, |
| 70 | 70 | 'product_id' => 0, |
| 71 | - 'created' => date( 'Y-m-d H:i:s' ), |
|
| 72 | - 'expiration' => date( 'Y-m-d H:i:s' ), |
|
| 71 | + 'created' => date('Y-m-d H:i:s'), |
|
| 72 | + 'expiration' => date('Y-m-d H:i:s'), |
|
| 73 | 73 | 'trial_period' => '', |
| 74 | 74 | 'status' => '', |
| 75 | 75 | 'profile_id' => '', |
@@ -82,11 +82,11 @@ discard block |
||
| 82 | 82 | * @access public |
| 83 | 83 | * @since 1.0.0 |
| 84 | 84 | */ |
| 85 | - public function get_subscriptions( $args = array() ) { |
|
| 85 | + public function get_subscriptions($args = array()) { |
|
| 86 | 86 | global $wpdb; |
| 87 | 87 | |
| 88 | 88 | $defaults = array( |
| 89 | - 'number' => get_option( 'posts_per_page' ), |
|
| 89 | + 'number' => get_option('posts_per_page'), |
|
| 90 | 90 | 'offset' => 0, |
| 91 | 91 | 'search' => '', |
| 92 | 92 | 'customer_id' => 0, |
@@ -94,21 +94,21 @@ discard block |
||
| 94 | 94 | 'order' => 'DESC' |
| 95 | 95 | ); |
| 96 | 96 | |
| 97 | - $args = wp_parse_args( $args, $defaults ); |
|
| 97 | + $args = wp_parse_args($args, $defaults); |
|
| 98 | 98 | |
| 99 | - if( $args['number'] < 1 ) { |
|
| 99 | + if ($args['number'] < 1) { |
|
| 100 | 100 | $args['number'] = 999999999999; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | $where = ' WHERE 1=1 '; |
| 104 | 104 | |
| 105 | 105 | // specific customers |
| 106 | - if( ! empty( $args['id'] ) ) { |
|
| 106 | + if (!empty($args['id'])) { |
|
| 107 | 107 | |
| 108 | - if( is_array( $args['id'] ) ) { |
|
| 109 | - $ids = implode( ',', array_map('intval', $args['id'] ) ); |
|
| 108 | + if (is_array($args['id'])) { |
|
| 109 | + $ids = implode(',', array_map('intval', $args['id'])); |
|
| 110 | 110 | } else { |
| 111 | - $ids = intval( $args['id'] ); |
|
| 111 | + $ids = intval($args['id']); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | $where .= " AND `id` IN( {$ids} ) "; |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | // Specific products |
| 119 | - if( ! empty( $args['product_id'] ) ) { |
|
| 119 | + if (!empty($args['product_id'])) { |
|
| 120 | 120 | |
| 121 | - if( is_array( $args['product_id'] ) ) { |
|
| 122 | - $product_ids = implode( ',', array_map('intval', $args['product_id'] ) ); |
|
| 121 | + if (is_array($args['product_id'])) { |
|
| 122 | + $product_ids = implode(',', array_map('intval', $args['product_id'])); |
|
| 123 | 123 | } else { |
| 124 | - $product_ids = intval( $args['product_id'] ); |
|
| 124 | + $product_ids = intval($args['product_id']); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | $where .= " AND `product_id` IN( {$product_ids} ) "; |
@@ -129,12 +129,12 @@ discard block |
||
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | // Specific parent payments |
| 132 | - if( ! empty( $args['parent_payment_id'] ) ) { |
|
| 132 | + if (!empty($args['parent_payment_id'])) { |
|
| 133 | 133 | |
| 134 | - if( is_array( $args['parent_payment_id'] ) ) { |
|
| 135 | - $parent_payment_ids = implode( ',', array_map('intval', $args['parent_payment_id'] ) ); |
|
| 134 | + if (is_array($args['parent_payment_id'])) { |
|
| 135 | + $parent_payment_ids = implode(',', array_map('intval', $args['parent_payment_id'])); |
|
| 136 | 136 | } else { |
| 137 | - $parent_payment_ids = intval( $args['parent_payment_id'] ); |
|
| 137 | + $parent_payment_ids = intval($args['parent_payment_id']); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | $where .= " AND `parent_payment_id` IN( {$parent_payment_ids} ) "; |
@@ -142,12 +142,12 @@ discard block |
||
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | // Specific transaction IDs |
| 145 | - if( ! empty( $args['transaction_id'] ) ) { |
|
| 145 | + if (!empty($args['transaction_id'])) { |
|
| 146 | 146 | |
| 147 | - if( is_array( $args['transaction_id'] ) ) { |
|
| 148 | - $transaction_ids = implode( "','", array_map('sanitize_text_field', $args['transaction_id'] ) ); |
|
| 147 | + if (is_array($args['transaction_id'])) { |
|
| 148 | + $transaction_ids = implode("','", array_map('sanitize_text_field', $args['transaction_id'])); |
|
| 149 | 149 | } else { |
| 150 | - $transaction_ids = sanitize_text_field( $args['transaction_id'] ); |
|
| 150 | + $transaction_ids = sanitize_text_field($args['transaction_id']); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | $where .= " AND `transaction_id` IN ( '{$transaction_ids}' ) "; |
@@ -155,12 +155,12 @@ discard block |
||
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | // Subscriptoins for specific customers |
| 158 | - if( ! empty( $args['customer_id'] ) ) { |
|
| 158 | + if (!empty($args['customer_id'])) { |
|
| 159 | 159 | |
| 160 | - if( is_array( $args['customer_id'] ) ) { |
|
| 161 | - $customer_ids = implode( ',', array_map('intval', $args['customer_id'] ) ); |
|
| 160 | + if (is_array($args['customer_id'])) { |
|
| 161 | + $customer_ids = implode(',', array_map('intval', $args['customer_id'])); |
|
| 162 | 162 | } else { |
| 163 | - $customer_ids = intval( $args['customer_id'] ); |
|
| 163 | + $customer_ids = intval($args['customer_id']); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | $where .= " AND `customer_id` IN( {$customer_ids} ) "; |
@@ -168,12 +168,12 @@ discard block |
||
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | // Subscriptions for specific profile IDs |
| 171 | - if( ! empty( $args['profile_id'] ) ) { |
|
| 171 | + if (!empty($args['profile_id'])) { |
|
| 172 | 172 | |
| 173 | - if( is_array( $args['profile_id'] ) ) { |
|
| 174 | - $profile_ids = implode( "','", array_map('sanitize_text_field', $args['profile_id'] ) ); |
|
| 173 | + if (is_array($args['profile_id'])) { |
|
| 174 | + $profile_ids = implode("','", array_map('sanitize_text_field', $args['profile_id'])); |
|
| 175 | 175 | } else { |
| 176 | - $profile_ids = sanitize_text_field( $args['profile_id'] ); |
|
| 176 | + $profile_ids = sanitize_text_field($args['profile_id']); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | $where .= " AND `profile_id` IN( '{$profile_ids}' ) "; |
@@ -181,12 +181,12 @@ discard block |
||
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | // Subscriptions for specific statuses |
| 184 | - if( ! empty( $args['status'] ) ) { |
|
| 184 | + if (!empty($args['status'])) { |
|
| 185 | 185 | |
| 186 | - if( is_array( $args['status'] ) ) { |
|
| 187 | - $statuses = implode( "','", array_map( 'sanitize_text_field', $args['status'] ) ); |
|
| 186 | + if (is_array($args['status'])) { |
|
| 187 | + $statuses = implode("','", array_map('sanitize_text_field', $args['status'])); |
|
| 188 | 188 | } else { |
| 189 | - $statuses = sanitize_text_field( $args['status'] ); |
|
| 189 | + $statuses = sanitize_text_field($args['status']); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | $where .= " AND `status` IN( '{$statuses}' ) "; |
@@ -194,21 +194,21 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | // Subscriptions created for a specific date or in a date range |
| 197 | - if( ! empty( $args['date'] ) ) { |
|
| 197 | + if (!empty($args['date'])) { |
|
| 198 | 198 | |
| 199 | - if( is_array( $args['date'] ) ) { |
|
| 199 | + if (is_array($args['date'])) { |
|
| 200 | 200 | |
| 201 | - if( ! empty( $args['date']['start'] ) ) { |
|
| 201 | + if (!empty($args['date']['start'])) { |
|
| 202 | 202 | |
| 203 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
| 203 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
| 204 | 204 | |
| 205 | 205 | $where .= " AND `created` >= '{$start}'"; |
| 206 | 206 | |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - if( ! empty( $args['date']['end'] ) ) { |
|
| 209 | + if (!empty($args['date']['end'])) { |
|
| 210 | 210 | |
| 211 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
| 211 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
| 212 | 212 | |
| 213 | 213 | $where .= " AND `created` <= '{$end}'"; |
| 214 | 214 | |
@@ -216,9 +216,9 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | } else { |
| 218 | 218 | |
| 219 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
| 220 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
| 221 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
| 219 | + $year = date('Y', strtotime($args['date'])); |
|
| 220 | + $month = date('m', strtotime($args['date'])); |
|
| 221 | + $day = date('d', strtotime($args['date'])); |
|
| 222 | 222 | |
| 223 | 223 | $where .= " AND $year = YEAR ( created ) AND $month = MONTH ( created ) AND $day = DAY ( created )"; |
| 224 | 224 | } |
@@ -226,21 +226,21 @@ discard block |
||
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | // Subscriptions with a specific expiration date or in an expiration date range |
| 229 | - if( ! empty( $args['expiration'] ) ) { |
|
| 229 | + if (!empty($args['expiration'])) { |
|
| 230 | 230 | |
| 231 | - if( is_array( $args['expiration'] ) ) { |
|
| 231 | + if (is_array($args['expiration'])) { |
|
| 232 | 232 | |
| 233 | - if( ! empty( $args['expiration']['start'] ) ) { |
|
| 233 | + if (!empty($args['expiration']['start'])) { |
|
| 234 | 234 | |
| 235 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['start'] ) ); |
|
| 235 | + $start = date('Y-m-d H:i:s', strtotime($args['expiration']['start'])); |
|
| 236 | 236 | |
| 237 | 237 | $where .= " AND `expiration` >= '{$start}'"; |
| 238 | 238 | |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - if( ! empty( $args['expiration']['end'] ) ) { |
|
| 241 | + if (!empty($args['expiration']['end'])) { |
|
| 242 | 242 | |
| 243 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['end'] ) ); |
|
| 243 | + $end = date('Y-m-d H:i:s', strtotime($args['expiration']['end'])); |
|
| 244 | 244 | |
| 245 | 245 | $where .= " AND `expiration` <= '{$end}'"; |
| 246 | 246 | |
@@ -248,73 +248,73 @@ discard block |
||
| 248 | 248 | |
| 249 | 249 | } else { |
| 250 | 250 | |
| 251 | - $year = date( 'Y', strtotime( $args['expiration'] ) ); |
|
| 252 | - $month = date( 'm', strtotime( $args['expiration'] ) ); |
|
| 253 | - $day = date( 'd', strtotime( $args['expiration'] ) ); |
|
| 251 | + $year = date('Y', strtotime($args['expiration'])); |
|
| 252 | + $month = date('m', strtotime($args['expiration'])); |
|
| 253 | + $day = date('d', strtotime($args['expiration'])); |
|
| 254 | 254 | |
| 255 | 255 | $where .= " AND $year = YEAR ( expiration ) AND $month = MONTH ( expiration ) AND $day = DAY ( expiration )"; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - if ( ! empty( $args['search'] ) ) { |
|
| 260 | + if (!empty($args['search'])) { |
|
| 261 | 261 | |
| 262 | - if( false !== strpos( 'id:', $args['search'] ) ) { |
|
| 262 | + if (false !== strpos('id:', $args['search'])) { |
|
| 263 | 263 | |
| 264 | - $args['search'] = trim( str_replace( 'id:', '', $args['search'] ) ); |
|
| 265 | - $where .= " AND `id` = '" . esc_sql( $args['search'] ) . "'"; |
|
| 264 | + $args['search'] = trim(str_replace('id:', '', $args['search'])); |
|
| 265 | + $where .= " AND `id` = '" . esc_sql($args['search']) . "'"; |
|
| 266 | 266 | |
| 267 | - } else if( false !== strpos( $args['search'], 'txn:' ) ) { |
|
| 267 | + } else if (false !== strpos($args['search'], 'txn:')) { |
|
| 268 | 268 | |
| 269 | - $args['search'] = trim( str_replace( 'txn:', '', $args['search'] ) ); |
|
| 270 | - $where .= " AND `transaction_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
| 269 | + $args['search'] = trim(str_replace('txn:', '', $args['search'])); |
|
| 270 | + $where .= " AND `transaction_id` = '" . esc_sql($args['search']) . "'"; |
|
| 271 | 271 | |
| 272 | - } else if( false !== strpos( $args['search'], 'profile_id:' ) ) { |
|
| 272 | + } else if (false !== strpos($args['search'], 'profile_id:')) { |
|
| 273 | 273 | |
| 274 | - $args['search'] = trim( str_replace( 'profile_id:', '', $args['search'] ) ); |
|
| 275 | - $where .= " AND `profile_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
| 274 | + $args['search'] = trim(str_replace('profile_id:', '', $args['search'])); |
|
| 275 | + $where .= " AND `profile_id` = '" . esc_sql($args['search']) . "'"; |
|
| 276 | 276 | |
| 277 | - } else if( false !== strpos( $args['search'], 'product_id:' ) ) { |
|
| 277 | + } else if (false !== strpos($args['search'], 'product_id:')) { |
|
| 278 | 278 | |
| 279 | - $args['search'] = trim( str_replace( 'product_id:', '', $args['search'] ) ); |
|
| 280 | - $where .= " AND `product_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
| 279 | + $args['search'] = trim(str_replace('product_id:', '', $args['search'])); |
|
| 280 | + $where .= " AND `product_id` = '" . esc_sql($args['search']) . "'"; |
|
| 281 | 281 | |
| 282 | - } else if( false !== strpos( $args['search'], 'customer_id:' ) ) { |
|
| 282 | + } else if (false !== strpos($args['search'], 'customer_id:')) { |
|
| 283 | 283 | |
| 284 | - $args['search'] = trim( str_replace( 'customer_id:', '', $args['search'] ) ); |
|
| 285 | - $where .= " AND `customer_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
| 284 | + $args['search'] = trim(str_replace('customer_id:', '', $args['search'])); |
|
| 285 | + $where .= " AND `customer_id` = '" . esc_sql($args['search']) . "'"; |
|
| 286 | 286 | |
| 287 | 287 | } else { |
| 288 | 288 | |
| 289 | - $where .= " AND ( `parent_payment_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `profile_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `transaction_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `product_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `id` = '" . esc_sql( $args['search'] ) . "' )"; |
|
| 289 | + $where .= " AND ( `parent_payment_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `profile_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `transaction_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `product_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `id` = '" . esc_sql($args['search']) . "' )"; |
|
| 290 | 290 | |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - $args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'id' : $args['orderby']; |
|
| 295 | + $args['orderby'] = !array_key_exists($args['orderby'], $this->get_columns()) ? 'id' : $args['orderby']; |
|
| 296 | 296 | |
| 297 | - if( 'amount' == $args['orderby'] ) { |
|
| 297 | + if ('amount' == $args['orderby']) { |
|
| 298 | 298 | $args['orderby'] = 'amount+0'; |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - $cache_key = md5( 'wpinv_subscriptions_' . serialize( $args ) ); |
|
| 301 | + $cache_key = md5('wpinv_subscriptions_' . serialize($args)); |
|
| 302 | 302 | |
| 303 | - $subscriptions = wp_cache_get( $cache_key, 'subscriptions' ); |
|
| 303 | + $subscriptions = wp_cache_get($cache_key, 'subscriptions'); |
|
| 304 | 304 | |
| 305 | - $args['orderby'] = esc_sql( $args['orderby'] ); |
|
| 306 | - $args['order'] = esc_sql( $args['order'] ); |
|
| 305 | + $args['orderby'] = esc_sql($args['orderby']); |
|
| 306 | + $args['order'] = esc_sql($args['order']); |
|
| 307 | 307 | |
| 308 | - if( $subscriptions === false ) { |
|
| 309 | - $subscriptions = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint( $args['offset'] ), absint( $args['number'] ) ), OBJECT ); |
|
| 308 | + if ($subscriptions === false) { |
|
| 309 | + $subscriptions = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint($args['offset']), absint($args['number'])), OBJECT); |
|
| 310 | 310 | |
| 311 | - if( ! empty( $subscriptions ) ) { |
|
| 311 | + if (!empty($subscriptions)) { |
|
| 312 | 312 | |
| 313 | - foreach( $subscriptions as $key => $subscription ) { |
|
| 314 | - $subscriptions[ $key ] = new WPInv_Subscription( $subscription ); |
|
| 313 | + foreach ($subscriptions as $key => $subscription) { |
|
| 314 | + $subscriptions[$key] = new WPInv_Subscription($subscription); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - wp_cache_set( $cache_key, $subscriptions, 'subscriptions', 3600 ); |
|
| 317 | + wp_cache_set($cache_key, $subscriptions, 'subscriptions', 3600); |
|
| 318 | 318 | |
| 319 | 319 | } |
| 320 | 320 | |
@@ -329,19 +329,19 @@ discard block |
||
| 329 | 329 | * @access public |
| 330 | 330 | * @since 1.0.0 |
| 331 | 331 | */ |
| 332 | - public function count( $args = array() ) { |
|
| 332 | + public function count($args = array()) { |
|
| 333 | 333 | |
| 334 | 334 | global $wpdb; |
| 335 | 335 | |
| 336 | 336 | $where = ' WHERE 1=1 '; |
| 337 | 337 | |
| 338 | 338 | // specific customers |
| 339 | - if( ! empty( $args['id'] ) ) { |
|
| 339 | + if (!empty($args['id'])) { |
|
| 340 | 340 | |
| 341 | - if( is_array( $args['id'] ) ) { |
|
| 342 | - $ids = implode( ',', array_map('intval', $args['id'] ) ); |
|
| 341 | + if (is_array($args['id'])) { |
|
| 342 | + $ids = implode(',', array_map('intval', $args['id'])); |
|
| 343 | 343 | } else { |
| 344 | - $ids = intval( $args['id'] ); |
|
| 344 | + $ids = intval($args['id']); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | $where .= " AND `id` IN( {$ids} ) "; |
@@ -349,12 +349,12 @@ discard block |
||
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | // Specific products |
| 352 | - if( ! empty( $args['product_id'] ) ) { |
|
| 352 | + if (!empty($args['product_id'])) { |
|
| 353 | 353 | |
| 354 | - if( is_array( $args['product_id'] ) ) { |
|
| 355 | - $product_ids = implode( ',', array_map('intval', $args['product_id'] ) ); |
|
| 354 | + if (is_array($args['product_id'])) { |
|
| 355 | + $product_ids = implode(',', array_map('intval', $args['product_id'])); |
|
| 356 | 356 | } else { |
| 357 | - $product_ids = intval( $args['product_id'] ); |
|
| 357 | + $product_ids = intval($args['product_id']); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | $where .= " AND `product_id` IN( {$product_ids} ) "; |
@@ -362,12 +362,12 @@ discard block |
||
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | // Specific parent payments |
| 365 | - if( ! empty( $args['parent_payment_id'] ) ) { |
|
| 365 | + if (!empty($args['parent_payment_id'])) { |
|
| 366 | 366 | |
| 367 | - if( is_array( $args['parent_payment_id'] ) ) { |
|
| 368 | - $parent_payment_ids = implode( ',', array_map('intval', $args['parent_payment_id'] ) ); |
|
| 367 | + if (is_array($args['parent_payment_id'])) { |
|
| 368 | + $parent_payment_ids = implode(',', array_map('intval', $args['parent_payment_id'])); |
|
| 369 | 369 | } else { |
| 370 | - $parent_payment_ids = intval( $args['parent_payment_id'] ); |
|
| 370 | + $parent_payment_ids = intval($args['parent_payment_id']); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | $where .= " AND `parent_payment_id` IN( {$parent_payment_ids} ) "; |
@@ -375,12 +375,12 @@ discard block |
||
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | // Subscriptoins for specific customers |
| 378 | - if( ! empty( $args['customer_id'] ) ) { |
|
| 378 | + if (!empty($args['customer_id'])) { |
|
| 379 | 379 | |
| 380 | - if( is_array( $args['customer_id'] ) ) { |
|
| 381 | - $customer_ids = implode( ',', array_map('intval', $args['customer_id'] ) ); |
|
| 380 | + if (is_array($args['customer_id'])) { |
|
| 381 | + $customer_ids = implode(',', array_map('intval', $args['customer_id'])); |
|
| 382 | 382 | } else { |
| 383 | - $customer_ids = intval( $args['customer_id'] ); |
|
| 383 | + $customer_ids = intval($args['customer_id']); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | $where .= " AND `customer_id` IN( {$customer_ids} ) "; |
@@ -388,12 +388,12 @@ discard block |
||
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | // Subscriptions for specific profile IDs |
| 391 | - if( ! empty( $args['profile_id'] ) ) { |
|
| 391 | + if (!empty($args['profile_id'])) { |
|
| 392 | 392 | |
| 393 | - if( is_array( $args['profile_id'] ) ) { |
|
| 394 | - $profile_ids = implode( ',', array_map('intval', $args['profile_id'] ) ); |
|
| 393 | + if (is_array($args['profile_id'])) { |
|
| 394 | + $profile_ids = implode(',', array_map('intval', $args['profile_id'])); |
|
| 395 | 395 | } else { |
| 396 | - $profile_ids = intval( $args['profile_id'] ); |
|
| 396 | + $profile_ids = intval($args['profile_id']); |
|
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | $where .= " AND `profile_id` IN( {$profile_ids} ) "; |
@@ -401,12 +401,12 @@ discard block |
||
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | // Specific transaction IDs |
| 404 | - if( ! empty( $args['transaction_id'] ) ) { |
|
| 404 | + if (!empty($args['transaction_id'])) { |
|
| 405 | 405 | |
| 406 | - if( is_array( $args['transaction_id'] ) ) { |
|
| 407 | - $transaction_ids = implode( ',', array_map('sanitize_text_field', $args['transaction_id'] ) ); |
|
| 406 | + if (is_array($args['transaction_id'])) { |
|
| 407 | + $transaction_ids = implode(',', array_map('sanitize_text_field', $args['transaction_id'])); |
|
| 408 | 408 | } else { |
| 409 | - $transaction_ids = sanitize_text_field( $args['transaction_id'] ); |
|
| 409 | + $transaction_ids = sanitize_text_field($args['transaction_id']); |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | $where .= " AND `transaction_id` IN( {$transaction_ids} ) "; |
@@ -414,10 +414,10 @@ discard block |
||
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | // Subscriptions for specific statuses |
| 417 | - if( ! empty( $args['status'] ) ) { |
|
| 417 | + if (!empty($args['status'])) { |
|
| 418 | 418 | |
| 419 | - if( is_array( $args['status'] ) ) { |
|
| 420 | - $statuses = implode( ',', $args['status'] ); |
|
| 419 | + if (is_array($args['status'])) { |
|
| 420 | + $statuses = implode(',', $args['status']); |
|
| 421 | 421 | $where .= " AND `status` IN( {$statuses} ) "; |
| 422 | 422 | } else { |
| 423 | 423 | $statuses = $args['status']; |
@@ -429,21 +429,21 @@ discard block |
||
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | // Subscriptions created for a specific date or in a date range |
| 432 | - if( ! empty( $args['date'] ) ) { |
|
| 432 | + if (!empty($args['date'])) { |
|
| 433 | 433 | |
| 434 | - if( is_array( $args['date'] ) ) { |
|
| 434 | + if (is_array($args['date'])) { |
|
| 435 | 435 | |
| 436 | - if( ! empty( $args['date']['start'] ) ) { |
|
| 436 | + if (!empty($args['date']['start'])) { |
|
| 437 | 437 | |
| 438 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
| 438 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
| 439 | 439 | |
| 440 | 440 | $where .= " AND `created` >= '{$start}'"; |
| 441 | 441 | |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - if( ! empty( $args['date']['end'] ) ) { |
|
| 444 | + if (!empty($args['date']['end'])) { |
|
| 445 | 445 | |
| 446 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
| 446 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
| 447 | 447 | |
| 448 | 448 | $where .= " AND `created` <= '{$end}'"; |
| 449 | 449 | |
@@ -451,9 +451,9 @@ discard block |
||
| 451 | 451 | |
| 452 | 452 | } else { |
| 453 | 453 | |
| 454 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
| 455 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
| 456 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
| 454 | + $year = date('Y', strtotime($args['date'])); |
|
| 455 | + $month = date('m', strtotime($args['date'])); |
|
| 456 | + $day = date('d', strtotime($args['date'])); |
|
| 457 | 457 | |
| 458 | 458 | $where .= " AND $year = YEAR ( created ) AND $month = MONTH ( created ) AND $day = DAY ( created )"; |
| 459 | 459 | } |
@@ -461,21 +461,21 @@ discard block |
||
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | // Subscriptions with a specific expiration date or in an expiration date range |
| 464 | - if( ! empty( $args['expiration'] ) ) { |
|
| 464 | + if (!empty($args['expiration'])) { |
|
| 465 | 465 | |
| 466 | - if( is_array( $args['expiration'] ) ) { |
|
| 466 | + if (is_array($args['expiration'])) { |
|
| 467 | 467 | |
| 468 | - if( ! empty( $args['expiration']['start'] ) ) { |
|
| 468 | + if (!empty($args['expiration']['start'])) { |
|
| 469 | 469 | |
| 470 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['start'] ) ); |
|
| 470 | + $start = date('Y-m-d H:i:s', strtotime($args['expiration']['start'])); |
|
| 471 | 471 | |
| 472 | 472 | $where .= " AND `expiration` >= '{$start}'"; |
| 473 | 473 | |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | - if( ! empty( $args['expiration']['end'] ) ) { |
|
| 476 | + if (!empty($args['expiration']['end'])) { |
|
| 477 | 477 | |
| 478 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['end'] ) ); |
|
| 478 | + $end = date('Y-m-d H:i:s', strtotime($args['expiration']['end'])); |
|
| 479 | 479 | |
| 480 | 480 | $where .= " AND `expiration` <= '{$end}'"; |
| 481 | 481 | |
@@ -483,64 +483,64 @@ discard block |
||
| 483 | 483 | |
| 484 | 484 | } else { |
| 485 | 485 | |
| 486 | - $year = date( 'Y', strtotime( $args['expiration'] ) ); |
|
| 487 | - $month = date( 'm', strtotime( $args['expiration'] ) ); |
|
| 488 | - $day = date( 'd', strtotime( $args['expiration'] ) ); |
|
| 486 | + $year = date('Y', strtotime($args['expiration'])); |
|
| 487 | + $month = date('m', strtotime($args['expiration'])); |
|
| 488 | + $day = date('d', strtotime($args['expiration'])); |
|
| 489 | 489 | |
| 490 | 490 | $where .= " AND $year = YEAR ( expiration ) AND $month = MONTH ( expiration ) AND $day = DAY ( expiration )"; |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | - if ( ! empty( $args['search'] ) ) { |
|
| 495 | + if (!empty($args['search'])) { |
|
| 496 | 496 | |
| 497 | - if( false !== strpos( 'id:', $args['search'] ) ) { |
|
| 497 | + if (false !== strpos('id:', $args['search'])) { |
|
| 498 | 498 | |
| 499 | - $args['search'] = trim( str_replace( 'id:', '', $args['search'] ) ); |
|
| 500 | - $where .= " AND `id` = '" . esc_sql( $args['search'] ) . "'"; |
|
| 499 | + $args['search'] = trim(str_replace('id:', '', $args['search'])); |
|
| 500 | + $where .= " AND `id` = '" . esc_sql($args['search']) . "'"; |
|
| 501 | 501 | |
| 502 | - } else if( false !== strpos( $args['search'], 'txn:' ) ) { |
|
| 502 | + } else if (false !== strpos($args['search'], 'txn:')) { |
|
| 503 | 503 | |
| 504 | - $args['search'] = trim( str_replace( 'txn:', '', $args['search'] ) ); |
|
| 505 | - $where .= " AND `transaction_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
| 504 | + $args['search'] = trim(str_replace('txn:', '', $args['search'])); |
|
| 505 | + $where .= " AND `transaction_id` = '" . esc_sql($args['search']) . "'"; |
|
| 506 | 506 | |
| 507 | - } else if( false !== strpos( $args['search'], 'profile_id:' ) ) { |
|
| 507 | + } else if (false !== strpos($args['search'], 'profile_id:')) { |
|
| 508 | 508 | |
| 509 | - $args['search'] = trim( str_replace( 'profile_id:', '', $args['search'] ) ); |
|
| 510 | - $where .= " AND `profile_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
| 509 | + $args['search'] = trim(str_replace('profile_id:', '', $args['search'])); |
|
| 510 | + $where .= " AND `profile_id` = '" . esc_sql($args['search']) . "'"; |
|
| 511 | 511 | |
| 512 | - } else if( false !== strpos( $args['search'], 'product_id:' ) ) { |
|
| 512 | + } else if (false !== strpos($args['search'], 'product_id:')) { |
|
| 513 | 513 | |
| 514 | - $args['search'] = trim( str_replace( 'product_id:', '', $args['search'] ) ); |
|
| 515 | - $where .= " AND `product_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
| 514 | + $args['search'] = trim(str_replace('product_id:', '', $args['search'])); |
|
| 515 | + $where .= " AND `product_id` = '" . esc_sql($args['search']) . "'"; |
|
| 516 | 516 | |
| 517 | - } else if( false !== strpos( $args['search'], 'customer_id:' ) ) { |
|
| 517 | + } else if (false !== strpos($args['search'], 'customer_id:')) { |
|
| 518 | 518 | |
| 519 | - $args['search'] = trim( str_replace( 'customer_id:', '', $args['search'] ) ); |
|
| 520 | - $where .= " AND `customer_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
| 519 | + $args['search'] = trim(str_replace('customer_id:', '', $args['search'])); |
|
| 520 | + $where .= " AND `customer_id` = '" . esc_sql($args['search']) . "'"; |
|
| 521 | 521 | |
| 522 | 522 | } else { |
| 523 | 523 | |
| 524 | - $where .= " AND ( `parent_payment_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `profile_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `transaction_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `product_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `id` = '" . esc_sql( $args['search'] ) . "' )"; |
|
| 524 | + $where .= " AND ( `parent_payment_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `profile_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `transaction_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `product_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `id` = '" . esc_sql($args['search']) . "' )"; |
|
| 525 | 525 | |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | - $cache_key = md5( 'wpinv_subscriptions_count' . serialize( $args ) ); |
|
| 530 | + $cache_key = md5('wpinv_subscriptions_count' . serialize($args)); |
|
| 531 | 531 | |
| 532 | - $count = wp_cache_get( $cache_key, 'subscriptions' ); |
|
| 532 | + $count = wp_cache_get($cache_key, 'subscriptions'); |
|
| 533 | 533 | |
| 534 | - if( $count === false ) { |
|
| 534 | + if ($count === false) { |
|
| 535 | 535 | |
| 536 | 536 | $sql = "SELECT COUNT($this->primary_key) FROM " . $this->table_name . "{$where};"; |
| 537 | - $count = $wpdb->get_var( $sql ); |
|
| 537 | + $count = $wpdb->get_var($sql); |
|
| 538 | 538 | |
| 539 | - wp_cache_set( $cache_key, $count, 'subscriptions', 3600 ); |
|
| 539 | + wp_cache_set($cache_key, $count, 'subscriptions', 3600); |
|
| 540 | 540 | |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | - return absint( $count ); |
|
| 543 | + return absint($count); |
|
| 544 | 544 | |
| 545 | 545 | } |
| 546 | 546 | |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | |
| 555 | 555 | global $wpdb; |
| 556 | 556 | |
| 557 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 557 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
| 558 | 558 | |
| 559 | 559 | $sql = "CREATE TABLE " . $this->table_name . " ( |
| 560 | 560 | id bigint(20) NOT NULL AUTO_INCREMENT, |
@@ -579,10 +579,10 @@ discard block |
||
| 579 | 579 | KEY customer_and_status ( customer_id, status) |
| 580 | 580 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
| 581 | 581 | |
| 582 | - dbDelta( $sql ); |
|
| 582 | + dbDelta($sql); |
|
| 583 | 583 | |
| 584 | - update_option( $this->table_name . '_wpinv_db_version', $this->version ); |
|
| 585 | - update_option( 'wpinv_db_version', WPINV_VERSION ); |
|
| 584 | + update_option($this->table_name . '_wpinv_db_version', $this->version); |
|
| 585 | + update_option('wpinv_db_version', WPINV_VERSION); |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | } |
| 589 | 589 | \ No newline at end of file |
@@ -8,7 +8,9 @@ |
||
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | // Exit if accessed directly |
| 11 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 11 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | + exit; |
|
| 13 | +} |
|
| 12 | 14 | |
| 13 | 15 | |
| 14 | 16 | // Load WP_List_Table if not loaded |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | // Load WP_List_Table if not loaded |
| 15 | 15 | if( ! class_exists( 'WP_List_Table' ) ) { |
| 16 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
| 16 | + require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -23,102 +23,102 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | class WPInv_Subscription_Reports_Table extends WP_List_Table { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Number of results to show per page |
|
| 28 | - * |
|
| 29 | - * @since 1.0.0 |
|
| 30 | - */ |
|
| 31 | - |
|
| 32 | - public $per_page = 30; |
|
| 33 | - public $total_count = 0; |
|
| 34 | - public $active_count = 0; |
|
| 35 | - public $pending_count = 0; |
|
| 36 | - public $expired_count = 0; |
|
| 37 | - public $completed_count = 0; |
|
| 38 | - public $trialling_count = 0; |
|
| 39 | - public $cancelled_count = 0; |
|
| 40 | - public $failing_count = 0; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Get things started |
|
| 44 | - * |
|
| 45 | - * @access private |
|
| 46 | - * @since 1.0.0 |
|
| 47 | - * @return void |
|
| 48 | - */ |
|
| 49 | - function __construct(){ |
|
| 50 | - global $status, $page; |
|
| 51 | - |
|
| 52 | - // Set parent defaults |
|
| 53 | - parent::__construct( array( |
|
| 54 | - 'singular' => 'subscription', |
|
| 55 | - 'plural' => 'subscriptions', |
|
| 56 | - 'ajax' => false |
|
| 57 | - ) ); |
|
| 58 | - |
|
| 59 | - $this->get_subscription_counts(); |
|
| 60 | - |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Retrieve the view types |
|
| 65 | - * |
|
| 66 | - * @access public |
|
| 67 | - * @since 1.0.0 |
|
| 68 | - * @return array $views All the views available |
|
| 69 | - */ |
|
| 70 | - public function get_views() { |
|
| 71 | - |
|
| 72 | - $current = isset( $_GET['status'] ) ? $_GET['status'] : ''; |
|
| 73 | - $total_count = ' <span class="count">(' . $this->total_count . ')</span>'; |
|
| 74 | - $active_count = ' <span class="count">(' . $this->active_count . ')</span>'; |
|
| 75 | - $pending_count = ' <span class="count">(' . $this->pending_count . ')</span>'; |
|
| 76 | - $expired_count = ' <span class="count">(' . $this->expired_count . ')</span>'; |
|
| 77 | - $completed_count = ' <span class="count">(' . $this->completed_count . ')</span>'; |
|
| 78 | - $trialling_count = ' <span class="count">(' . $this->trialling_count . ')</span>'; |
|
| 79 | - $cancelled_count = ' <span class="count">(' . $this->cancelled_count . ')</span>'; |
|
| 80 | - $failing_count = ' <span class="count">(' . $this->failing_count . ')</span>'; |
|
| 81 | - |
|
| 82 | - $views = array( |
|
| 83 | - 'all' => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( array( 'status', 'paged' ) ), $current === 'all' || $current == '' ? ' class="current"' : '', __('All','invoicing' ) . $total_count ), |
|
| 84 | - 'active' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'active', 'paged' => FALSE ) ), $current === 'active' ? ' class="current"' : '', __('Active','invoicing' ) . $active_count ), |
|
| 85 | - 'pending' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'pending', 'paged' => FALSE ) ), $current === 'pending' ? ' class="current"' : '', __('Pending','invoicing' ) . $pending_count ), |
|
| 86 | - 'expired' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'expired', 'paged' => FALSE ) ), $current === 'expired' ? ' class="current"' : '', __('Expired','invoicing' ) . $expired_count ), |
|
| 87 | - 'completed' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'completed', 'paged' => FALSE ) ), $current === 'completed' ? ' class="current"' : '', __('Completed','invoicing' ) . $completed_count ), |
|
| 88 | - 'trialling' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'trialling', 'paged' => FALSE ) ), $current === 'trialling' ? ' class="current"' : '', __('Trialling','invoicing' ) . $trialling_count ), |
|
| 89 | - 'cancelled' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'cancelled', 'paged' => FALSE ) ), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled','invoicing' ) . $cancelled_count ), |
|
| 90 | - 'failing' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'failing', 'paged' => FALSE ) ), $current === 'failing' ? ' class="current"' : '', __('Failing','invoicing' ) . $failing_count ), |
|
| 91 | - ); |
|
| 92 | - |
|
| 93 | - return apply_filters( 'wpinv_recurring_subscriptions_table_views', $views ); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * Show the search field |
|
| 98 | - * |
|
| 99 | - * @since 2.5 |
|
| 100 | - * @access public |
|
| 101 | - * |
|
| 102 | - * @param string $text Label for the search box |
|
| 103 | - * @param string $input_id ID of the search box |
|
| 104 | - * |
|
| 105 | - * @return void |
|
| 106 | - */ |
|
| 107 | - public function search_box( $text, $input_id ) { |
|
| 108 | - |
|
| 109 | - if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
|
| 110 | - return; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $input_id = $input_id . '-search-input'; |
|
| 114 | - |
|
| 115 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
| 116 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
| 120 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
| 121 | - } |
|
| 26 | + /** |
|
| 27 | + * Number of results to show per page |
|
| 28 | + * |
|
| 29 | + * @since 1.0.0 |
|
| 30 | + */ |
|
| 31 | + |
|
| 32 | + public $per_page = 30; |
|
| 33 | + public $total_count = 0; |
|
| 34 | + public $active_count = 0; |
|
| 35 | + public $pending_count = 0; |
|
| 36 | + public $expired_count = 0; |
|
| 37 | + public $completed_count = 0; |
|
| 38 | + public $trialling_count = 0; |
|
| 39 | + public $cancelled_count = 0; |
|
| 40 | + public $failing_count = 0; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Get things started |
|
| 44 | + * |
|
| 45 | + * @access private |
|
| 46 | + * @since 1.0.0 |
|
| 47 | + * @return void |
|
| 48 | + */ |
|
| 49 | + function __construct(){ |
|
| 50 | + global $status, $page; |
|
| 51 | + |
|
| 52 | + // Set parent defaults |
|
| 53 | + parent::__construct( array( |
|
| 54 | + 'singular' => 'subscription', |
|
| 55 | + 'plural' => 'subscriptions', |
|
| 56 | + 'ajax' => false |
|
| 57 | + ) ); |
|
| 58 | + |
|
| 59 | + $this->get_subscription_counts(); |
|
| 60 | + |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Retrieve the view types |
|
| 65 | + * |
|
| 66 | + * @access public |
|
| 67 | + * @since 1.0.0 |
|
| 68 | + * @return array $views All the views available |
|
| 69 | + */ |
|
| 70 | + public function get_views() { |
|
| 71 | + |
|
| 72 | + $current = isset( $_GET['status'] ) ? $_GET['status'] : ''; |
|
| 73 | + $total_count = ' <span class="count">(' . $this->total_count . ')</span>'; |
|
| 74 | + $active_count = ' <span class="count">(' . $this->active_count . ')</span>'; |
|
| 75 | + $pending_count = ' <span class="count">(' . $this->pending_count . ')</span>'; |
|
| 76 | + $expired_count = ' <span class="count">(' . $this->expired_count . ')</span>'; |
|
| 77 | + $completed_count = ' <span class="count">(' . $this->completed_count . ')</span>'; |
|
| 78 | + $trialling_count = ' <span class="count">(' . $this->trialling_count . ')</span>'; |
|
| 79 | + $cancelled_count = ' <span class="count">(' . $this->cancelled_count . ')</span>'; |
|
| 80 | + $failing_count = ' <span class="count">(' . $this->failing_count . ')</span>'; |
|
| 81 | + |
|
| 82 | + $views = array( |
|
| 83 | + 'all' => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( array( 'status', 'paged' ) ), $current === 'all' || $current == '' ? ' class="current"' : '', __('All','invoicing' ) . $total_count ), |
|
| 84 | + 'active' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'active', 'paged' => FALSE ) ), $current === 'active' ? ' class="current"' : '', __('Active','invoicing' ) . $active_count ), |
|
| 85 | + 'pending' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'pending', 'paged' => FALSE ) ), $current === 'pending' ? ' class="current"' : '', __('Pending','invoicing' ) . $pending_count ), |
|
| 86 | + 'expired' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'expired', 'paged' => FALSE ) ), $current === 'expired' ? ' class="current"' : '', __('Expired','invoicing' ) . $expired_count ), |
|
| 87 | + 'completed' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'completed', 'paged' => FALSE ) ), $current === 'completed' ? ' class="current"' : '', __('Completed','invoicing' ) . $completed_count ), |
|
| 88 | + 'trialling' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'trialling', 'paged' => FALSE ) ), $current === 'trialling' ? ' class="current"' : '', __('Trialling','invoicing' ) . $trialling_count ), |
|
| 89 | + 'cancelled' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'cancelled', 'paged' => FALSE ) ), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled','invoicing' ) . $cancelled_count ), |
|
| 90 | + 'failing' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'failing', 'paged' => FALSE ) ), $current === 'failing' ? ' class="current"' : '', __('Failing','invoicing' ) . $failing_count ), |
|
| 91 | + ); |
|
| 92 | + |
|
| 93 | + return apply_filters( 'wpinv_recurring_subscriptions_table_views', $views ); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * Show the search field |
|
| 98 | + * |
|
| 99 | + * @since 2.5 |
|
| 100 | + * @access public |
|
| 101 | + * |
|
| 102 | + * @param string $text Label for the search box |
|
| 103 | + * @param string $input_id ID of the search box |
|
| 104 | + * |
|
| 105 | + * @return void |
|
| 106 | + */ |
|
| 107 | + public function search_box( $text, $input_id ) { |
|
| 108 | + |
|
| 109 | + if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
|
| 110 | + return; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $input_id = $input_id . '-search-input'; |
|
| 114 | + |
|
| 115 | + if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
| 116 | + echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + if ( ! empty( $_REQUEST['order'] ) ) { |
|
| 120 | + echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
| 121 | + } |
|
| 122 | 122 | ?> |
| 123 | 123 | <p class="search-box"> |
| 124 | 124 | <?php do_action( 'wpinv_recurring_subscription_search_box' ); ?> |
@@ -127,18 +127,18 @@ discard block |
||
| 127 | 127 | <?php submit_button( $text, 'button', false, false, array('ID' => 'search-submit') ); ?><br/> |
| 128 | 128 | </p> |
| 129 | 129 | <?php |
| 130 | - } |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * Render most columns |
|
| 134 | - * |
|
| 135 | - * @access private |
|
| 136 | - * @since 1.0.0 |
|
| 137 | - * @return string |
|
| 138 | - */ |
|
| 139 | - function column_default( $item, $column_name ) { |
|
| 140 | - return $item->$column_name; |
|
| 141 | - } |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * Render most columns |
|
| 134 | + * |
|
| 135 | + * @access private |
|
| 136 | + * @since 1.0.0 |
|
| 137 | + * @return string |
|
| 138 | + */ |
|
| 139 | + function column_default( $item, $column_name ) { |
|
| 140 | + return $item->$column_name; |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | 143 | /** |
| 144 | 144 | * Subscription id column |
@@ -151,244 +151,244 @@ discard block |
||
| 151 | 151 | return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" target="_blank">' . $item->id . '</a>'; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - /** |
|
| 155 | - * Customer column |
|
| 156 | - * |
|
| 157 | - * @access private |
|
| 158 | - * @since 1.0.0 |
|
| 159 | - * @return string |
|
| 160 | - */ |
|
| 161 | - function column_customer_id( $item ) { |
|
| 162 | - $subscriber = get_userdata( $item->customer_id ); |
|
| 163 | - $customer = ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email; |
|
| 164 | - |
|
| 165 | - return '<a href="' . esc_url( get_edit_user_link( $item->customer_id ) ) . '" target="_blank">' . $customer . '</a>'; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * Status column |
|
| 170 | - * |
|
| 171 | - * @access private |
|
| 172 | - * @since 1.0.0 |
|
| 173 | - * @return string |
|
| 174 | - */ |
|
| 175 | - function column_status( $item ) { |
|
| 176 | - return $item->get_status_label(); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * Period column |
|
| 181 | - * |
|
| 182 | - * @access private |
|
| 183 | - * @since 1.0.0 |
|
| 184 | - * @return string |
|
| 185 | - */ |
|
| 186 | - function column_period( $item ) { |
|
| 187 | - |
|
| 188 | - $period = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->period,$item->frequency ); |
|
| 189 | - |
|
| 190 | - return wpinv_price( wpinv_format_amount( $item->recurring_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ) . ' / ' . $period; |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - /** |
|
| 194 | - * Billing Times column |
|
| 195 | - * |
|
| 196 | - * @access private |
|
| 197 | - * @since 1.0.0 |
|
| 198 | - * @return string |
|
| 199 | - */ |
|
| 200 | - function column_bill_times( $item ) { |
|
| 201 | - return $item->get_times_billed() . ' / ' . ( ( $item->bill_times == 0 ) ? 'Until Cancelled' : $item->bill_times ); |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * Initial Amount column |
|
| 206 | - * |
|
| 207 | - * @access private |
|
| 208 | - * @since 1.0.0 |
|
| 209 | - * @return string |
|
| 210 | - */ |
|
| 211 | - function column_initial_amount( $item ) { |
|
| 212 | - return wpinv_price( wpinv_format_amount( $item->initial_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ); |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * Renewal date column |
|
| 217 | - * |
|
| 218 | - * @access private |
|
| 219 | - * @since 1.0.0 |
|
| 220 | - * @return string |
|
| 221 | - */ |
|
| 222 | - function column_renewal_date( $item ) { |
|
| 223 | - return $renewal_date = ! empty( $item->expiration ) ? date_i18n( get_option( 'date_format' ), strtotime( $item->expiration ) ) : __( 'N/A', 'invoicing' ); |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * Payment column |
|
| 228 | - * |
|
| 229 | - * @access private |
|
| 230 | - * @since 1.0.0 |
|
| 231 | - * @return string |
|
| 232 | - */ |
|
| 233 | - function column_parent_payment_id( $item ) { |
|
| 234 | - return '<a href="' . get_edit_post_link( $item->parent_payment_id ) . '" target="_blank">' . $item->parent_payment_id . '</a>'; |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - /** |
|
| 238 | - * Product ID column |
|
| 239 | - * |
|
| 240 | - * @access private |
|
| 241 | - * @since 1.0.0 |
|
| 242 | - * @return string |
|
| 243 | - */ |
|
| 244 | - function column_product_id( $item ) { |
|
| 245 | - return '<a href="' . esc_url( admin_url( 'post.php?action=edit&post=' . $item->product_id ) ) . '" target="_blank">' . get_the_title( $item->product_id ) . '</a>'; |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - /** |
|
| 249 | - * Render the edit column |
|
| 250 | - * |
|
| 251 | - * @access private |
|
| 252 | - * @since 2.0 |
|
| 253 | - * @return string |
|
| 254 | - */ |
|
| 255 | - function column_actions( $item ) { |
|
| 256 | - return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" title="' . esc_attr( __( 'View or edit subscription', 'invoicing' ) ) . '" target="_blank">' . __( 'View', 'invoicing' ) . '</a>'; |
|
| 257 | - } |
|
| 258 | - |
|
| 259 | - |
|
| 260 | - /** |
|
| 261 | - * Retrieve the table columns |
|
| 262 | - * |
|
| 263 | - * @access private |
|
| 264 | - * @since 1.0.0 |
|
| 265 | - * @return array |
|
| 266 | - */ |
|
| 267 | - |
|
| 268 | - function get_columns(){ |
|
| 269 | - $columns = array( |
|
| 270 | - 'sub_id' => __( 'ID', 'invoicing' ), |
|
| 271 | - 'customer_id' => __( 'Customer', 'invoicing' ), |
|
| 272 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 273 | - 'period' => __( 'Billing Cycle', 'invoicing' ), |
|
| 274 | - 'initial_amount' => __( 'Initial Amount', 'invoicing' ), |
|
| 275 | - 'bill_times' => __( 'Times Billed', 'invoicing' ), |
|
| 276 | - 'renewal_date' => __( 'Renewal Date', 'invoicing' ), |
|
| 277 | - 'parent_payment_id' => __( 'Invoice', 'invoicing' ), |
|
| 278 | - 'product_id' => __( 'Item', 'invoicing' ), |
|
| 279 | - 'actions' => __( 'Actions', 'invoicing' ), |
|
| 280 | - ); |
|
| 281 | - |
|
| 282 | - return apply_filters( 'wpinv_report_subscription_columns', $columns ); |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - /** |
|
| 286 | - * Retrieve the current page number |
|
| 287 | - * |
|
| 288 | - * @access private |
|
| 289 | - * @since 1.0.0 |
|
| 290 | - * @return int |
|
| 291 | - */ |
|
| 292 | - function get_paged() { |
|
| 293 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - /** |
|
| 297 | - * Retrieve the subscription counts |
|
| 298 | - * |
|
| 299 | - * @access public |
|
| 300 | - * @since 1.4 |
|
| 301 | - * @return void |
|
| 302 | - */ |
|
| 303 | - public function get_subscription_counts() { |
|
| 304 | - |
|
| 305 | - global $wp_query; |
|
| 306 | - |
|
| 307 | - $db = new WPInv_Subscriptions_DB; |
|
| 308 | - |
|
| 309 | - $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
| 310 | - |
|
| 311 | - $this->total_count = $db->count(); |
|
| 312 | - $this->active_count = $db->count( array( 'status' => 'active', 'search' => $search ) ); |
|
| 313 | - $this->pending_count = $db->count( array( 'status' => 'pending', 'search' => $search ) ); |
|
| 314 | - $this->expired_count = $db->count( array( 'status' => 'expired', 'search' => $search ) ); |
|
| 315 | - $this->trialling_count = $db->count( array( 'status' => 'trialling', 'search' => $search ) ); |
|
| 316 | - $this->cancelled_count = $db->count( array( 'status' => 'cancelled', 'search' => $search ) ); |
|
| 317 | - $this->completed_count = $db->count( array( 'status' => 'completed', 'search' => $search ) ); |
|
| 318 | - $this->failing_count = $db->count( array( 'status' => 'failing', 'search' => $search ) ); |
|
| 319 | - |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - /** |
|
| 323 | - * Setup the final data for the table |
|
| 324 | - * |
|
| 325 | - * @access private |
|
| 326 | - * @since 1.0.0 |
|
| 327 | - * @uses $this->_column_headers |
|
| 328 | - * @uses $this->items |
|
| 329 | - * @uses $this->get_columns() |
|
| 330 | - * @uses $this->get_sortable_columns() |
|
| 331 | - * @uses $this->get_pagenum() |
|
| 332 | - * @uses $this->set_pagination_args() |
|
| 333 | - * @return array |
|
| 334 | - */ |
|
| 335 | - function prepare_items() { |
|
| 336 | - |
|
| 337 | - $columns = $this->get_columns(); |
|
| 338 | - $hidden = array(); // No hidden columns |
|
| 339 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : 'any'; |
|
| 340 | - $sortable = $this->get_sortable_columns(); |
|
| 341 | - |
|
| 342 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 343 | - |
|
| 344 | - $current_page = $this->get_pagenum(); |
|
| 345 | - |
|
| 346 | - $db = new WPInv_Subscriptions_DB; |
|
| 347 | - $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
| 348 | - $args = array( |
|
| 349 | - 'number' => $this->per_page, |
|
| 350 | - 'offset' => $this->per_page * ( $this->get_paged() - 1 ), |
|
| 351 | - 'search' => $search |
|
| 352 | - ); |
|
| 353 | - |
|
| 354 | - if ( 'any' !== $status ) { |
|
| 355 | - $args['status'] = $status; |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - $this->items = $db->get_subscriptions( $args ); |
|
| 359 | - |
|
| 360 | - switch ( $status ) { |
|
| 361 | - case 'active': |
|
| 362 | - $total_items = $this->active_count; |
|
| 363 | - break; |
|
| 364 | - case 'pending': |
|
| 365 | - $total_items = $this->pending_count; |
|
| 366 | - break; |
|
| 367 | - case 'expired': |
|
| 368 | - $total_items = $this->expired_count; |
|
| 369 | - break; |
|
| 370 | - case 'cancelled': |
|
| 371 | - $total_items = $this->cancelled_count; |
|
| 372 | - break; |
|
| 373 | - case 'failing': |
|
| 374 | - $total_items = $this->failing_count; |
|
| 375 | - break; |
|
| 376 | - case 'trialling': |
|
| 377 | - $total_items = $this->trialling_count; |
|
| 378 | - break; |
|
| 379 | - case 'completed': |
|
| 380 | - $total_items = $this->completed_count; |
|
| 381 | - break; |
|
| 382 | - case 'any': |
|
| 383 | - default: |
|
| 384 | - $total_items = $this->total_count; |
|
| 385 | - break; |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - $this->set_pagination_args( array( |
|
| 389 | - 'total_items' => $total_items, |
|
| 390 | - 'per_page' => $this->per_page, |
|
| 391 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
| 392 | - ) ); |
|
| 393 | - } |
|
| 154 | + /** |
|
| 155 | + * Customer column |
|
| 156 | + * |
|
| 157 | + * @access private |
|
| 158 | + * @since 1.0.0 |
|
| 159 | + * @return string |
|
| 160 | + */ |
|
| 161 | + function column_customer_id( $item ) { |
|
| 162 | + $subscriber = get_userdata( $item->customer_id ); |
|
| 163 | + $customer = ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email; |
|
| 164 | + |
|
| 165 | + return '<a href="' . esc_url( get_edit_user_link( $item->customer_id ) ) . '" target="_blank">' . $customer . '</a>'; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Status column |
|
| 170 | + * |
|
| 171 | + * @access private |
|
| 172 | + * @since 1.0.0 |
|
| 173 | + * @return string |
|
| 174 | + */ |
|
| 175 | + function column_status( $item ) { |
|
| 176 | + return $item->get_status_label(); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + /** |
|
| 180 | + * Period column |
|
| 181 | + * |
|
| 182 | + * @access private |
|
| 183 | + * @since 1.0.0 |
|
| 184 | + * @return string |
|
| 185 | + */ |
|
| 186 | + function column_period( $item ) { |
|
| 187 | + |
|
| 188 | + $period = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->period,$item->frequency ); |
|
| 189 | + |
|
| 190 | + return wpinv_price( wpinv_format_amount( $item->recurring_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ) . ' / ' . $period; |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + /** |
|
| 194 | + * Billing Times column |
|
| 195 | + * |
|
| 196 | + * @access private |
|
| 197 | + * @since 1.0.0 |
|
| 198 | + * @return string |
|
| 199 | + */ |
|
| 200 | + function column_bill_times( $item ) { |
|
| 201 | + return $item->get_times_billed() . ' / ' . ( ( $item->bill_times == 0 ) ? 'Until Cancelled' : $item->bill_times ); |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * Initial Amount column |
|
| 206 | + * |
|
| 207 | + * @access private |
|
| 208 | + * @since 1.0.0 |
|
| 209 | + * @return string |
|
| 210 | + */ |
|
| 211 | + function column_initial_amount( $item ) { |
|
| 212 | + return wpinv_price( wpinv_format_amount( $item->initial_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ); |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * Renewal date column |
|
| 217 | + * |
|
| 218 | + * @access private |
|
| 219 | + * @since 1.0.0 |
|
| 220 | + * @return string |
|
| 221 | + */ |
|
| 222 | + function column_renewal_date( $item ) { |
|
| 223 | + return $renewal_date = ! empty( $item->expiration ) ? date_i18n( get_option( 'date_format' ), strtotime( $item->expiration ) ) : __( 'N/A', 'invoicing' ); |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * Payment column |
|
| 228 | + * |
|
| 229 | + * @access private |
|
| 230 | + * @since 1.0.0 |
|
| 231 | + * @return string |
|
| 232 | + */ |
|
| 233 | + function column_parent_payment_id( $item ) { |
|
| 234 | + return '<a href="' . get_edit_post_link( $item->parent_payment_id ) . '" target="_blank">' . $item->parent_payment_id . '</a>'; |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * Product ID column |
|
| 239 | + * |
|
| 240 | + * @access private |
|
| 241 | + * @since 1.0.0 |
|
| 242 | + * @return string |
|
| 243 | + */ |
|
| 244 | + function column_product_id( $item ) { |
|
| 245 | + return '<a href="' . esc_url( admin_url( 'post.php?action=edit&post=' . $item->product_id ) ) . '" target="_blank">' . get_the_title( $item->product_id ) . '</a>'; |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + /** |
|
| 249 | + * Render the edit column |
|
| 250 | + * |
|
| 251 | + * @access private |
|
| 252 | + * @since 2.0 |
|
| 253 | + * @return string |
|
| 254 | + */ |
|
| 255 | + function column_actions( $item ) { |
|
| 256 | + return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" title="' . esc_attr( __( 'View or edit subscription', 'invoicing' ) ) . '" target="_blank">' . __( 'View', 'invoicing' ) . '</a>'; |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + |
|
| 260 | + /** |
|
| 261 | + * Retrieve the table columns |
|
| 262 | + * |
|
| 263 | + * @access private |
|
| 264 | + * @since 1.0.0 |
|
| 265 | + * @return array |
|
| 266 | + */ |
|
| 267 | + |
|
| 268 | + function get_columns(){ |
|
| 269 | + $columns = array( |
|
| 270 | + 'sub_id' => __( 'ID', 'invoicing' ), |
|
| 271 | + 'customer_id' => __( 'Customer', 'invoicing' ), |
|
| 272 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 273 | + 'period' => __( 'Billing Cycle', 'invoicing' ), |
|
| 274 | + 'initial_amount' => __( 'Initial Amount', 'invoicing' ), |
|
| 275 | + 'bill_times' => __( 'Times Billed', 'invoicing' ), |
|
| 276 | + 'renewal_date' => __( 'Renewal Date', 'invoicing' ), |
|
| 277 | + 'parent_payment_id' => __( 'Invoice', 'invoicing' ), |
|
| 278 | + 'product_id' => __( 'Item', 'invoicing' ), |
|
| 279 | + 'actions' => __( 'Actions', 'invoicing' ), |
|
| 280 | + ); |
|
| 281 | + |
|
| 282 | + return apply_filters( 'wpinv_report_subscription_columns', $columns ); |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + /** |
|
| 286 | + * Retrieve the current page number |
|
| 287 | + * |
|
| 288 | + * @access private |
|
| 289 | + * @since 1.0.0 |
|
| 290 | + * @return int |
|
| 291 | + */ |
|
| 292 | + function get_paged() { |
|
| 293 | + return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + /** |
|
| 297 | + * Retrieve the subscription counts |
|
| 298 | + * |
|
| 299 | + * @access public |
|
| 300 | + * @since 1.4 |
|
| 301 | + * @return void |
|
| 302 | + */ |
|
| 303 | + public function get_subscription_counts() { |
|
| 304 | + |
|
| 305 | + global $wp_query; |
|
| 306 | + |
|
| 307 | + $db = new WPInv_Subscriptions_DB; |
|
| 308 | + |
|
| 309 | + $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
| 310 | + |
|
| 311 | + $this->total_count = $db->count(); |
|
| 312 | + $this->active_count = $db->count( array( 'status' => 'active', 'search' => $search ) ); |
|
| 313 | + $this->pending_count = $db->count( array( 'status' => 'pending', 'search' => $search ) ); |
|
| 314 | + $this->expired_count = $db->count( array( 'status' => 'expired', 'search' => $search ) ); |
|
| 315 | + $this->trialling_count = $db->count( array( 'status' => 'trialling', 'search' => $search ) ); |
|
| 316 | + $this->cancelled_count = $db->count( array( 'status' => 'cancelled', 'search' => $search ) ); |
|
| 317 | + $this->completed_count = $db->count( array( 'status' => 'completed', 'search' => $search ) ); |
|
| 318 | + $this->failing_count = $db->count( array( 'status' => 'failing', 'search' => $search ) ); |
|
| 319 | + |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + /** |
|
| 323 | + * Setup the final data for the table |
|
| 324 | + * |
|
| 325 | + * @access private |
|
| 326 | + * @since 1.0.0 |
|
| 327 | + * @uses $this->_column_headers |
|
| 328 | + * @uses $this->items |
|
| 329 | + * @uses $this->get_columns() |
|
| 330 | + * @uses $this->get_sortable_columns() |
|
| 331 | + * @uses $this->get_pagenum() |
|
| 332 | + * @uses $this->set_pagination_args() |
|
| 333 | + * @return array |
|
| 334 | + */ |
|
| 335 | + function prepare_items() { |
|
| 336 | + |
|
| 337 | + $columns = $this->get_columns(); |
|
| 338 | + $hidden = array(); // No hidden columns |
|
| 339 | + $status = isset( $_GET['status'] ) ? $_GET['status'] : 'any'; |
|
| 340 | + $sortable = $this->get_sortable_columns(); |
|
| 341 | + |
|
| 342 | + $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 343 | + |
|
| 344 | + $current_page = $this->get_pagenum(); |
|
| 345 | + |
|
| 346 | + $db = new WPInv_Subscriptions_DB; |
|
| 347 | + $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
| 348 | + $args = array( |
|
| 349 | + 'number' => $this->per_page, |
|
| 350 | + 'offset' => $this->per_page * ( $this->get_paged() - 1 ), |
|
| 351 | + 'search' => $search |
|
| 352 | + ); |
|
| 353 | + |
|
| 354 | + if ( 'any' !== $status ) { |
|
| 355 | + $args['status'] = $status; |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + $this->items = $db->get_subscriptions( $args ); |
|
| 359 | + |
|
| 360 | + switch ( $status ) { |
|
| 361 | + case 'active': |
|
| 362 | + $total_items = $this->active_count; |
|
| 363 | + break; |
|
| 364 | + case 'pending': |
|
| 365 | + $total_items = $this->pending_count; |
|
| 366 | + break; |
|
| 367 | + case 'expired': |
|
| 368 | + $total_items = $this->expired_count; |
|
| 369 | + break; |
|
| 370 | + case 'cancelled': |
|
| 371 | + $total_items = $this->cancelled_count; |
|
| 372 | + break; |
|
| 373 | + case 'failing': |
|
| 374 | + $total_items = $this->failing_count; |
|
| 375 | + break; |
|
| 376 | + case 'trialling': |
|
| 377 | + $total_items = $this->trialling_count; |
|
| 378 | + break; |
|
| 379 | + case 'completed': |
|
| 380 | + $total_items = $this->completed_count; |
|
| 381 | + break; |
|
| 382 | + case 'any': |
|
| 383 | + default: |
|
| 384 | + $total_items = $this->total_count; |
|
| 385 | + break; |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + $this->set_pagination_args( array( |
|
| 389 | + 'total_items' => $total_items, |
|
| 390 | + 'per_page' => $this->per_page, |
|
| 391 | + 'total_pages' => ceil( $total_items / $this->per_page ) |
|
| 392 | + ) ); |
|
| 393 | + } |
|
| 394 | 394 | } |
@@ -8,11 +8,11 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | // Exit if accessed directly |
| 11 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 11 | +if (!defined('ABSPATH')) exit; |
|
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | // Load WP_List_Table if not loaded |
| 15 | -if( ! class_exists( 'WP_List_Table' ) ) { |
|
| 15 | +if (!class_exists('WP_List_Table')) { |
|
| 16 | 16 | require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | public $pending_count = 0; |
| 36 | 36 | public $expired_count = 0; |
| 37 | 37 | public $completed_count = 0; |
| 38 | - public $trialling_count = 0; |
|
| 38 | + public $trialling_count = 0; |
|
| 39 | 39 | public $cancelled_count = 0; |
| 40 | 40 | public $failing_count = 0; |
| 41 | 41 | |
@@ -46,15 +46,15 @@ discard block |
||
| 46 | 46 | * @since 1.0.0 |
| 47 | 47 | * @return void |
| 48 | 48 | */ |
| 49 | - function __construct(){ |
|
| 49 | + function __construct() { |
|
| 50 | 50 | global $status, $page; |
| 51 | 51 | |
| 52 | 52 | // Set parent defaults |
| 53 | - parent::__construct( array( |
|
| 53 | + parent::__construct(array( |
|
| 54 | 54 | 'singular' => 'subscription', |
| 55 | 55 | 'plural' => 'subscriptions', |
| 56 | 56 | 'ajax' => false |
| 57 | - ) ); |
|
| 57 | + )); |
|
| 58 | 58 | |
| 59 | 59 | $this->get_subscription_counts(); |
| 60 | 60 | |
@@ -69,28 +69,28 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function get_views() { |
| 71 | 71 | |
| 72 | - $current = isset( $_GET['status'] ) ? $_GET['status'] : ''; |
|
| 73 | - $total_count = ' <span class="count">(' . $this->total_count . ')</span>'; |
|
| 72 | + $current = isset($_GET['status']) ? $_GET['status'] : ''; |
|
| 73 | + $total_count = ' <span class="count">(' . $this->total_count . ')</span>'; |
|
| 74 | 74 | $active_count = ' <span class="count">(' . $this->active_count . ')</span>'; |
| 75 | 75 | $pending_count = ' <span class="count">(' . $this->pending_count . ')</span>'; |
| 76 | - $expired_count = ' <span class="count">(' . $this->expired_count . ')</span>'; |
|
| 76 | + $expired_count = ' <span class="count">(' . $this->expired_count . ')</span>'; |
|
| 77 | 77 | $completed_count = ' <span class="count">(' . $this->completed_count . ')</span>'; |
| 78 | - $trialling_count = ' <span class="count">(' . $this->trialling_count . ')</span>'; |
|
| 79 | - $cancelled_count = ' <span class="count">(' . $this->cancelled_count . ')</span>'; |
|
| 80 | - $failing_count = ' <span class="count">(' . $this->failing_count . ')</span>'; |
|
| 78 | + $trialling_count = ' <span class="count">(' . $this->trialling_count . ')</span>'; |
|
| 79 | + $cancelled_count = ' <span class="count">(' . $this->cancelled_count . ')</span>'; |
|
| 80 | + $failing_count = ' <span class="count">(' . $this->failing_count . ')</span>'; |
|
| 81 | 81 | |
| 82 | 82 | $views = array( |
| 83 | - 'all' => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( array( 'status', 'paged' ) ), $current === 'all' || $current == '' ? ' class="current"' : '', __('All','invoicing' ) . $total_count ), |
|
| 84 | - 'active' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'active', 'paged' => FALSE ) ), $current === 'active' ? ' class="current"' : '', __('Active','invoicing' ) . $active_count ), |
|
| 85 | - 'pending' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'pending', 'paged' => FALSE ) ), $current === 'pending' ? ' class="current"' : '', __('Pending','invoicing' ) . $pending_count ), |
|
| 86 | - 'expired' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'expired', 'paged' => FALSE ) ), $current === 'expired' ? ' class="current"' : '', __('Expired','invoicing' ) . $expired_count ), |
|
| 87 | - 'completed' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'completed', 'paged' => FALSE ) ), $current === 'completed' ? ' class="current"' : '', __('Completed','invoicing' ) . $completed_count ), |
|
| 88 | - 'trialling' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'trialling', 'paged' => FALSE ) ), $current === 'trialling' ? ' class="current"' : '', __('Trialling','invoicing' ) . $trialling_count ), |
|
| 89 | - 'cancelled' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'cancelled', 'paged' => FALSE ) ), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled','invoicing' ) . $cancelled_count ), |
|
| 90 | - 'failing' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'failing', 'paged' => FALSE ) ), $current === 'failing' ? ' class="current"' : '', __('Failing','invoicing' ) . $failing_count ), |
|
| 83 | + 'all' => sprintf('<a href="%s"%s>%s</a>', remove_query_arg(array('status', 'paged')), $current === 'all' || $current == '' ? ' class="current"' : '', __('All', 'invoicing') . $total_count), |
|
| 84 | + 'active' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'active', 'paged' => FALSE)), $current === 'active' ? ' class="current"' : '', __('Active', 'invoicing') . $active_count), |
|
| 85 | + 'pending' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'pending', 'paged' => FALSE)), $current === 'pending' ? ' class="current"' : '', __('Pending', 'invoicing') . $pending_count), |
|
| 86 | + 'expired' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'expired', 'paged' => FALSE)), $current === 'expired' ? ' class="current"' : '', __('Expired', 'invoicing') . $expired_count), |
|
| 87 | + 'completed' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'completed', 'paged' => FALSE)), $current === 'completed' ? ' class="current"' : '', __('Completed', 'invoicing') . $completed_count), |
|
| 88 | + 'trialling' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'trialling', 'paged' => FALSE)), $current === 'trialling' ? ' class="current"' : '', __('Trialling', 'invoicing') . $trialling_count), |
|
| 89 | + 'cancelled' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'cancelled', 'paged' => FALSE)), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled', 'invoicing') . $cancelled_count), |
|
| 90 | + 'failing' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'failing', 'paged' => FALSE)), $current === 'failing' ? ' class="current"' : '', __('Failing', 'invoicing') . $failing_count), |
|
| 91 | 91 | ); |
| 92 | 92 | |
| 93 | - return apply_filters( 'wpinv_recurring_subscriptions_table_views', $views ); |
|
| 93 | + return apply_filters('wpinv_recurring_subscriptions_table_views', $views); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -104,27 +104,27 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @return void |
| 106 | 106 | */ |
| 107 | - public function search_box( $text, $input_id ) { |
|
| 107 | + public function search_box($text, $input_id) { |
|
| 108 | 108 | |
| 109 | - if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
|
| 109 | + if (empty($_REQUEST['s']) && !$this->has_items()) { |
|
| 110 | 110 | return; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | $input_id = $input_id . '-search-input'; |
| 114 | 114 | |
| 115 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
| 116 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
| 115 | + if (!empty($_REQUEST['orderby'])) { |
|
| 116 | + echo '<input type="hidden" name="orderby" value="' . esc_attr($_REQUEST['orderby']) . '" />'; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
| 120 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
| 119 | + if (!empty($_REQUEST['order'])) { |
|
| 120 | + echo '<input type="hidden" name="order" value="' . esc_attr($_REQUEST['order']) . '" />'; |
|
| 121 | 121 | } |
| 122 | 122 | ?> |
| 123 | 123 | <p class="search-box"> |
| 124 | - <?php do_action( 'wpinv_recurring_subscription_search_box' ); ?> |
|
| 124 | + <?php do_action('wpinv_recurring_subscription_search_box'); ?> |
|
| 125 | 125 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
| 126 | 126 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
| 127 | - <?php submit_button( $text, 'button', false, false, array('ID' => 'search-submit') ); ?><br/> |
|
| 127 | + <?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?><br/> |
|
| 128 | 128 | </p> |
| 129 | 129 | <?php |
| 130 | 130 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * @since 1.0.0 |
| 137 | 137 | * @return string |
| 138 | 138 | */ |
| 139 | - function column_default( $item, $column_name ) { |
|
| 139 | + function column_default($item, $column_name) { |
|
| 140 | 140 | return $item->$column_name; |
| 141 | 141 | } |
| 142 | 142 | |
@@ -147,8 +147,8 @@ discard block |
||
| 147 | 147 | * @since 1.0.0 |
| 148 | 148 | * @return string |
| 149 | 149 | */ |
| 150 | - function column_sub_id( $item ) { |
|
| 151 | - return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" target="_blank">' . $item->id . '</a>'; |
|
| 150 | + function column_sub_id($item) { |
|
| 151 | + return '<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $item->id)) . '" target="_blank">' . $item->id . '</a>'; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -158,11 +158,11 @@ discard block |
||
| 158 | 158 | * @since 1.0.0 |
| 159 | 159 | * @return string |
| 160 | 160 | */ |
| 161 | - function column_customer_id( $item ) { |
|
| 162 | - $subscriber = get_userdata( $item->customer_id ); |
|
| 163 | - $customer = ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email; |
|
| 161 | + function column_customer_id($item) { |
|
| 162 | + $subscriber = get_userdata($item->customer_id); |
|
| 163 | + $customer = !empty($subscriber->display_name) ? $subscriber->display_name : $subscriber->user_email; |
|
| 164 | 164 | |
| 165 | - return '<a href="' . esc_url( get_edit_user_link( $item->customer_id ) ) . '" target="_blank">' . $customer . '</a>'; |
|
| 165 | + return '<a href="' . esc_url(get_edit_user_link($item->customer_id)) . '" target="_blank">' . $customer . '</a>'; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * @since 1.0.0 |
| 173 | 173 | * @return string |
| 174 | 174 | */ |
| 175 | - function column_status( $item ) { |
|
| 175 | + function column_status($item) { |
|
| 176 | 176 | return $item->get_status_label(); |
| 177 | 177 | } |
| 178 | 178 | |
@@ -183,11 +183,11 @@ discard block |
||
| 183 | 183 | * @since 1.0.0 |
| 184 | 184 | * @return string |
| 185 | 185 | */ |
| 186 | - function column_period( $item ) { |
|
| 186 | + function column_period($item) { |
|
| 187 | 187 | |
| 188 | - $period = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->period,$item->frequency ); |
|
| 188 | + $period = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($item->period, $item->frequency); |
|
| 189 | 189 | |
| 190 | - return wpinv_price( wpinv_format_amount( $item->recurring_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ) . ' / ' . $period; |
|
| 190 | + return wpinv_price(wpinv_format_amount($item->recurring_amount), wpinv_get_invoice_currency_code($item->parent_payment_id)) . ' / ' . $period; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
@@ -197,8 +197,8 @@ discard block |
||
| 197 | 197 | * @since 1.0.0 |
| 198 | 198 | * @return string |
| 199 | 199 | */ |
| 200 | - function column_bill_times( $item ) { |
|
| 201 | - return $item->get_times_billed() . ' / ' . ( ( $item->bill_times == 0 ) ? 'Until Cancelled' : $item->bill_times ); |
|
| 200 | + function column_bill_times($item) { |
|
| 201 | + return $item->get_times_billed() . ' / ' . (($item->bill_times == 0) ? 'Until Cancelled' : $item->bill_times); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | * @since 1.0.0 |
| 209 | 209 | * @return string |
| 210 | 210 | */ |
| 211 | - function column_initial_amount( $item ) { |
|
| 212 | - return wpinv_price( wpinv_format_amount( $item->initial_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ); |
|
| 211 | + function column_initial_amount($item) { |
|
| 212 | + return wpinv_price(wpinv_format_amount($item->initial_amount), wpinv_get_invoice_currency_code($item->parent_payment_id)); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -219,8 +219,8 @@ discard block |
||
| 219 | 219 | * @since 1.0.0 |
| 220 | 220 | * @return string |
| 221 | 221 | */ |
| 222 | - function column_renewal_date( $item ) { |
|
| 223 | - return $renewal_date = ! empty( $item->expiration ) ? date_i18n( get_option( 'date_format' ), strtotime( $item->expiration ) ) : __( 'N/A', 'invoicing' ); |
|
| 222 | + function column_renewal_date($item) { |
|
| 223 | + return $renewal_date = !empty($item->expiration) ? date_i18n(get_option('date_format'), strtotime($item->expiration)) : __('N/A', 'invoicing'); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -230,8 +230,8 @@ discard block |
||
| 230 | 230 | * @since 1.0.0 |
| 231 | 231 | * @return string |
| 232 | 232 | */ |
| 233 | - function column_parent_payment_id( $item ) { |
|
| 234 | - return '<a href="' . get_edit_post_link( $item->parent_payment_id ) . '" target="_blank">' . $item->parent_payment_id . '</a>'; |
|
| 233 | + function column_parent_payment_id($item) { |
|
| 234 | + return '<a href="' . get_edit_post_link($item->parent_payment_id) . '" target="_blank">' . $item->parent_payment_id . '</a>'; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -241,8 +241,8 @@ discard block |
||
| 241 | 241 | * @since 1.0.0 |
| 242 | 242 | * @return string |
| 243 | 243 | */ |
| 244 | - function column_product_id( $item ) { |
|
| 245 | - return '<a href="' . esc_url( admin_url( 'post.php?action=edit&post=' . $item->product_id ) ) . '" target="_blank">' . get_the_title( $item->product_id ) . '</a>'; |
|
| 244 | + function column_product_id($item) { |
|
| 245 | + return '<a href="' . esc_url(admin_url('post.php?action=edit&post=' . $item->product_id)) . '" target="_blank">' . get_the_title($item->product_id) . '</a>'; |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | /** |
@@ -252,8 +252,8 @@ discard block |
||
| 252 | 252 | * @since 2.0 |
| 253 | 253 | * @return string |
| 254 | 254 | */ |
| 255 | - function column_actions( $item ) { |
|
| 256 | - return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" title="' . esc_attr( __( 'View or edit subscription', 'invoicing' ) ) . '" target="_blank">' . __( 'View', 'invoicing' ) . '</a>'; |
|
| 255 | + function column_actions($item) { |
|
| 256 | + return '<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $item->id)) . '" title="' . esc_attr(__('View or edit subscription', 'invoicing')) . '" target="_blank">' . __('View', 'invoicing') . '</a>'; |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | |
@@ -265,21 +265,21 @@ discard block |
||
| 265 | 265 | * @return array |
| 266 | 266 | */ |
| 267 | 267 | |
| 268 | - function get_columns(){ |
|
| 268 | + function get_columns() { |
|
| 269 | 269 | $columns = array( |
| 270 | - 'sub_id' => __( 'ID', 'invoicing' ), |
|
| 271 | - 'customer_id' => __( 'Customer', 'invoicing' ), |
|
| 272 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 273 | - 'period' => __( 'Billing Cycle', 'invoicing' ), |
|
| 274 | - 'initial_amount' => __( 'Initial Amount', 'invoicing' ), |
|
| 275 | - 'bill_times' => __( 'Times Billed', 'invoicing' ), |
|
| 276 | - 'renewal_date' => __( 'Renewal Date', 'invoicing' ), |
|
| 277 | - 'parent_payment_id' => __( 'Invoice', 'invoicing' ), |
|
| 278 | - 'product_id' => __( 'Item', 'invoicing' ), |
|
| 279 | - 'actions' => __( 'Actions', 'invoicing' ), |
|
| 270 | + 'sub_id' => __('ID', 'invoicing'), |
|
| 271 | + 'customer_id' => __('Customer', 'invoicing'), |
|
| 272 | + 'status' => __('Status', 'invoicing'), |
|
| 273 | + 'period' => __('Billing Cycle', 'invoicing'), |
|
| 274 | + 'initial_amount' => __('Initial Amount', 'invoicing'), |
|
| 275 | + 'bill_times' => __('Times Billed', 'invoicing'), |
|
| 276 | + 'renewal_date' => __('Renewal Date', 'invoicing'), |
|
| 277 | + 'parent_payment_id' => __('Invoice', 'invoicing'), |
|
| 278 | + 'product_id' => __('Item', 'invoicing'), |
|
| 279 | + 'actions' => __('Actions', 'invoicing'), |
|
| 280 | 280 | ); |
| 281 | 281 | |
| 282 | - return apply_filters( 'wpinv_report_subscription_columns', $columns ); |
|
| 282 | + return apply_filters('wpinv_report_subscription_columns', $columns); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * @return int |
| 291 | 291 | */ |
| 292 | 292 | function get_paged() { |
| 293 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
| 293 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
@@ -306,16 +306,16 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | $db = new WPInv_Subscriptions_DB; |
| 308 | 308 | |
| 309 | - $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
| 309 | + $search = !empty($_GET['s']) ? sanitize_text_field($_GET['s']) : ''; |
|
| 310 | 310 | |
| 311 | 311 | $this->total_count = $db->count(); |
| 312 | - $this->active_count = $db->count( array( 'status' => 'active', 'search' => $search ) ); |
|
| 313 | - $this->pending_count = $db->count( array( 'status' => 'pending', 'search' => $search ) ); |
|
| 314 | - $this->expired_count = $db->count( array( 'status' => 'expired', 'search' => $search ) ); |
|
| 315 | - $this->trialling_count = $db->count( array( 'status' => 'trialling', 'search' => $search ) ); |
|
| 316 | - $this->cancelled_count = $db->count( array( 'status' => 'cancelled', 'search' => $search ) ); |
|
| 317 | - $this->completed_count = $db->count( array( 'status' => 'completed', 'search' => $search ) ); |
|
| 318 | - $this->failing_count = $db->count( array( 'status' => 'failing', 'search' => $search ) ); |
|
| 312 | + $this->active_count = $db->count(array('status' => 'active', 'search' => $search)); |
|
| 313 | + $this->pending_count = $db->count(array('status' => 'pending', 'search' => $search)); |
|
| 314 | + $this->expired_count = $db->count(array('status' => 'expired', 'search' => $search)); |
|
| 315 | + $this->trialling_count = $db->count(array('status' => 'trialling', 'search' => $search)); |
|
| 316 | + $this->cancelled_count = $db->count(array('status' => 'cancelled', 'search' => $search)); |
|
| 317 | + $this->completed_count = $db->count(array('status' => 'completed', 'search' => $search)); |
|
| 318 | + $this->failing_count = $db->count(array('status' => 'failing', 'search' => $search)); |
|
| 319 | 319 | |
| 320 | 320 | } |
| 321 | 321 | |
@@ -336,28 +336,28 @@ discard block |
||
| 336 | 336 | |
| 337 | 337 | $columns = $this->get_columns(); |
| 338 | 338 | $hidden = array(); // No hidden columns |
| 339 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : 'any'; |
|
| 339 | + $status = isset($_GET['status']) ? $_GET['status'] : 'any'; |
|
| 340 | 340 | $sortable = $this->get_sortable_columns(); |
| 341 | 341 | |
| 342 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 342 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
| 343 | 343 | |
| 344 | 344 | $current_page = $this->get_pagenum(); |
| 345 | 345 | |
| 346 | 346 | $db = new WPInv_Subscriptions_DB; |
| 347 | - $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
| 347 | + $search = !empty($_GET['s']) ? sanitize_text_field($_GET['s']) : ''; |
|
| 348 | 348 | $args = array( |
| 349 | 349 | 'number' => $this->per_page, |
| 350 | - 'offset' => $this->per_page * ( $this->get_paged() - 1 ), |
|
| 350 | + 'offset' => $this->per_page * ($this->get_paged() - 1), |
|
| 351 | 351 | 'search' => $search |
| 352 | 352 | ); |
| 353 | 353 | |
| 354 | - if ( 'any' !== $status ) { |
|
| 354 | + if ('any' !== $status) { |
|
| 355 | 355 | $args['status'] = $status; |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - $this->items = $db->get_subscriptions( $args ); |
|
| 358 | + $this->items = $db->get_subscriptions($args); |
|
| 359 | 359 | |
| 360 | - switch ( $status ) { |
|
| 360 | + switch ($status) { |
|
| 361 | 361 | case 'active': |
| 362 | 362 | $total_items = $this->active_count; |
| 363 | 363 | break; |
@@ -385,10 +385,10 @@ discard block |
||
| 385 | 385 | break; |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - $this->set_pagination_args( array( |
|
| 388 | + $this->set_pagination_args(array( |
|
| 389 | 389 | 'total_items' => $total_items, |
| 390 | 390 | 'per_page' => $this->per_page, |
| 391 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
| 392 | - ) ); |
|
| 391 | + 'total_pages' => ceil($total_items / $this->per_page) |
|
| 392 | + )); |
|
| 393 | 393 | } |
| 394 | 394 | } |
@@ -179,8 +179,11 @@ discard block |
||
| 179 | 179 | <label for="tablecell"> |
| 180 | 180 | <?php if( 'trialling' == $sub->status ) : ?> |
| 181 | 181 | <?php _e( 'Trialling Until:', 'invoicing' ); ?> |
| 182 | - <?php else: ?> |
|
| 183 | - <?php _e( 'Expiration Date:', 'invoicing' ); ?> |
|
| 182 | + <?php else { |
|
| 183 | + : ?> |
|
| 184 | + <?php _e( 'Expiration Date:', 'invoicing' ); |
|
| 185 | +} |
|
| 186 | +?> |
|
| 184 | 187 | <?php endif; ?> |
| 185 | 188 | </label> |
| 186 | 189 | </td> |
@@ -268,9 +271,12 @@ discard block |
||
| 268 | 271 | </td> |
| 269 | 272 | </tr> |
| 270 | 273 | <?php endforeach; ?> |
| 271 | - <?php else: ?> |
|
| 274 | + <?php else { |
|
| 275 | + : ?> |
|
| 272 | 276 | <tr> |
| 273 | - <td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); ?></td> |
|
| 277 | + <td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); |
|
| 278 | +} |
|
| 279 | +?></td> |
|
| 274 | 280 | </tr> |
| 275 | 281 | <?php endif; ?> |
| 276 | 282 | </tbody> |
@@ -8,23 +8,23 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | function wpinv_subscriptions_page() { |
| 10 | 10 | |
| 11 | - if ( ! empty( $_GET['id'] ) ) { |
|
| 11 | + if ( ! empty( $_GET['id'] ) ) { |
|
| 12 | 12 | |
| 13 | 13 | wpinv_recurring_subscription_details(); |
| 14 | 14 | |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | |
| 17 | - } |
|
| 18 | - ?> |
|
| 17 | + } |
|
| 18 | + ?> |
|
| 19 | 19 | <div class="wrap"> |
| 20 | 20 | |
| 21 | 21 | <h1> |
| 22 | 22 | <?php _e( 'Subscriptions', 'invoicing' ); ?> |
| 23 | 23 | </h1> |
| 24 | 24 | <?php |
| 25 | - $subscribers_table = new WPInv_Subscription_Reports_Table(); |
|
| 26 | - $subscribers_table->prepare_items(); |
|
| 27 | - ?> |
|
| 25 | + $subscribers_table = new WPInv_Subscription_Reports_Table(); |
|
| 26 | + $subscribers_table->prepare_items(); |
|
| 27 | + ?> |
|
| 28 | 28 | |
| 29 | 29 | <form id="subscribers-filter" method="get"> |
| 30 | 30 | |
@@ -47,24 +47,24 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | function wpinv_recurring_subscription_details() { |
| 49 | 49 | |
| 50 | - $render = true; |
|
| 50 | + $render = true; |
|
| 51 | 51 | |
| 52 | - if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
| 53 | - die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
| 54 | - } |
|
| 52 | + if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
| 53 | + die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
| 56 | + if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
| 57 | 57 | die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
| 58 | - } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - $sub_id = (int) $_GET['id']; |
|
| 61 | - $sub = new WPInv_Subscription( $sub_id ); |
|
| 60 | + $sub_id = (int) $_GET['id']; |
|
| 61 | + $sub = new WPInv_Subscription( $sub_id ); |
|
| 62 | 62 | |
| 63 | - if ( empty( $sub ) ) { |
|
| 64 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
| 65 | - } |
|
| 63 | + if ( empty( $sub ) ) { |
|
| 64 | + die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - ?> |
|
| 67 | + ?> |
|
| 68 | 68 | <div class="wrap"> |
| 69 | 69 | <h2><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
| 70 | 70 | |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | </td> |
| 89 | 89 | <td> |
| 90 | 90 | <?php |
| 91 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
| 92 | - $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
| 93 | - $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
| 94 | - printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
| 95 | - ?> |
|
| 91 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
| 92 | + $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
| 93 | + $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
| 94 | + printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
| 95 | + ?> |
|
| 96 | 96 | </td> |
| 97 | 97 | </tr> |
| 98 | 98 | <tr> |
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | ?> |
| 135 | 135 | <a href="<?php echo esc_url( add_query_arg( array( |
| 136 | - 'post' => $sub->product_id, |
|
| 137 | - 'action' => 'edit' |
|
| 138 | - ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
| 136 | + 'post' => $sub->product_id, |
|
| 137 | + 'action' => 'edit' |
|
| 138 | + ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
| 139 | 139 | </td> |
| 140 | 140 | </tr> |
| 141 | 141 | <tr> |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | <td><?php echo wpinv_get_invoice_status( $payment->ID, true ); ?></td> |
| 262 | 262 | <td> |
| 263 | 263 | <a title="<?php _e( 'View Details for Invoice.', 'invoicing' ); |
| 264 | - echo ' ' . $payment->ID; ?>" href="<?php echo get_edit_post_link( $payment->ID ); ?>"> |
|
| 264 | + echo ' ' . $payment->ID; ?>" href="<?php echo get_edit_post_link( $payment->ID ); ?>"> |
|
| 265 | 265 | <?php _e( 'View Details', 'invoicing' ); ?> |
| 266 | 266 | </a> |
| 267 | 267 | <?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?> |
@@ -299,58 +299,58 @@ discard block |
||
| 299 | 299 | */ |
| 300 | 300 | function wpinv_recurring_process_subscription_update() { |
| 301 | 301 | |
| 302 | - if( empty( $_POST['sub_id'] ) ) { |
|
| 303 | - return; |
|
| 304 | - } |
|
| 302 | + if( empty( $_POST['sub_id'] ) ) { |
|
| 303 | + return; |
|
| 304 | + } |
|
| 305 | 305 | |
| 306 | - if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
| 307 | - return; |
|
| 308 | - } |
|
| 306 | + if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
| 307 | + return; |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
| 311 | - return; |
|
| 312 | - } |
|
| 310 | + if( ! current_user_can( 'manage_invoicing') ) { |
|
| 311 | + return; |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
| 315 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 316 | - } |
|
| 314 | + if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
| 315 | + wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 316 | + } |
|
| 317 | 317 | |
| 318 | - $expiration = date( 'Y-m-d 23:59:59', strtotime( $_POST['expiration'] ) ); |
|
| 319 | - $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
| 320 | - $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
| 321 | - $product_id = absint( $_POST['product_id'] ); |
|
| 322 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
| 323 | - $subscription->update( array( |
|
| 324 | - 'status' => sanitize_text_field( $_POST['status'] ), |
|
| 325 | - 'expiration' => $expiration, |
|
| 326 | - 'profile_id' => $profile_id, |
|
| 327 | - 'product_id' => $product_id, |
|
| 328 | - 'transaction_id' => $transaction_id, |
|
| 329 | - ) ); |
|
| 318 | + $expiration = date( 'Y-m-d 23:59:59', strtotime( $_POST['expiration'] ) ); |
|
| 319 | + $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
| 320 | + $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
| 321 | + $product_id = absint( $_POST['product_id'] ); |
|
| 322 | + $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
| 323 | + $subscription->update( array( |
|
| 324 | + 'status' => sanitize_text_field( $_POST['status'] ), |
|
| 325 | + 'expiration' => $expiration, |
|
| 326 | + 'profile_id' => $profile_id, |
|
| 327 | + 'product_id' => $product_id, |
|
| 328 | + 'transaction_id' => $transaction_id, |
|
| 329 | + ) ); |
|
| 330 | 330 | |
| 331 | - $status = sanitize_text_field( $_POST['status'] ); |
|
| 331 | + $status = sanitize_text_field( $_POST['status'] ); |
|
| 332 | 332 | |
| 333 | - switch( $status ) { |
|
| 333 | + switch( $status ) { |
|
| 334 | 334 | |
| 335 | - case 'cancelled' : |
|
| 335 | + case 'cancelled' : |
|
| 336 | 336 | |
| 337 | - $subscription->cancel(); |
|
| 338 | - break; |
|
| 337 | + $subscription->cancel(); |
|
| 338 | + break; |
|
| 339 | 339 | |
| 340 | - case 'expired' : |
|
| 340 | + case 'expired' : |
|
| 341 | 341 | |
| 342 | - $subscription->expire(); |
|
| 343 | - break; |
|
| 342 | + $subscription->expire(); |
|
| 343 | + break; |
|
| 344 | 344 | |
| 345 | - case 'completed' : |
|
| 345 | + case 'completed' : |
|
| 346 | 346 | |
| 347 | - $subscription->complete(); |
|
| 348 | - break; |
|
| 347 | + $subscription->complete(); |
|
| 348 | + break; |
|
| 349 | 349 | |
| 350 | - } |
|
| 350 | + } |
|
| 351 | 351 | |
| 352 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
| 353 | - exit; |
|
| 352 | + wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
| 353 | + exit; |
|
| 354 | 354 | |
| 355 | 355 | } |
| 356 | 356 | add_action( 'admin_init', 'wpinv_recurring_process_subscription_update', 1 ); |
@@ -364,30 +364,30 @@ discard block |
||
| 364 | 364 | */ |
| 365 | 365 | function wpinv_recurring_process_subscription_deletion() { |
| 366 | 366 | |
| 367 | - if( empty( $_POST['sub_id'] ) ) { |
|
| 368 | - return; |
|
| 369 | - } |
|
| 367 | + if( empty( $_POST['sub_id'] ) ) { |
|
| 368 | + return; |
|
| 369 | + } |
|
| 370 | 370 | |
| 371 | - if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
| 372 | - return; |
|
| 373 | - } |
|
| 371 | + if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
| 372 | + return; |
|
| 373 | + } |
|
| 374 | 374 | |
| 375 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
| 376 | - return; |
|
| 377 | - } |
|
| 375 | + if( ! current_user_can( 'manage_invoicing') ) { |
|
| 376 | + return; |
|
| 377 | + } |
|
| 378 | 378 | |
| 379 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
| 380 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 381 | - } |
|
| 379 | + if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
| 380 | + wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
| 383 | + $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
| 384 | 384 | |
| 385 | - delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
| 385 | + delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
| 386 | 386 | |
| 387 | - $subscription->delete(); |
|
| 387 | + $subscription->delete(); |
|
| 388 | 388 | |
| 389 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
| 390 | - exit; |
|
| 389 | + wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
| 390 | + exit; |
|
| 391 | 391 | |
| 392 | 392 | } |
| 393 | 393 | add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 ); |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | function wpinv_subscriptions_page() { |
| 10 | 10 | |
| 11 | - if ( ! empty( $_GET['id'] ) ) { |
|
| 11 | + if (!empty($_GET['id'])) { |
|
| 12 | 12 | |
| 13 | 13 | wpinv_recurring_subscription_details(); |
| 14 | 14 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | <div class="wrap"> |
| 20 | 20 | |
| 21 | 21 | <h1> |
| 22 | - <?php _e( 'Subscriptions', 'invoicing' ); ?> |
|
| 22 | + <?php _e('Subscriptions', 'invoicing'); ?> |
|
| 23 | 23 | </h1> |
| 24 | 24 | <?php |
| 25 | 25 | $subscribers_table = new WPInv_Subscription_Reports_Table(); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | <input type="hidden" name="post_type" value="download" /> |
| 32 | 32 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
| 33 | 33 | <?php $subscribers_table->views(); ?> |
| 34 | - <?php $subscribers_table->search_box( __( 'Search', 'wpinvoicing' ), 'subscriptions' ); ?> |
|
| 34 | + <?php $subscribers_table->search_box(__('Search', 'wpinvoicing'), 'subscriptions'); ?> |
|
| 35 | 35 | <?php $subscribers_table->display(); ?> |
| 36 | 36 | |
| 37 | 37 | </form> |
@@ -49,34 +49,34 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | $render = true; |
| 51 | 51 | |
| 52 | - if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
| 53 | - die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
| 52 | + if (!current_user_can('manage_invoicing')) { |
|
| 53 | + die(__('You are not permitted to view this data.', 'invoicing')); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
| 57 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
| 56 | + if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { |
|
| 57 | + die(__('Invalid subscription ID Provided.', 'invoicing')); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $sub_id = (int) $_GET['id']; |
|
| 61 | - $sub = new WPInv_Subscription( $sub_id ); |
|
| 60 | + $sub_id = (int)$_GET['id']; |
|
| 61 | + $sub = new WPInv_Subscription($sub_id); |
|
| 62 | 62 | |
| 63 | - if ( empty( $sub ) ) { |
|
| 64 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
| 63 | + if (empty($sub)) { |
|
| 64 | + die(__('Invalid subscription ID Provided.', 'invoicing')); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | ?> |
| 68 | 68 | <div class="wrap"> |
| 69 | - <h2><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
|
| 69 | + <h2><?php _e('Subscription Details', 'invoicing'); ?></h2> |
|
| 70 | 70 | |
| 71 | - <?php if ( $sub ) : ?> |
|
| 71 | + <?php if ($sub) : ?> |
|
| 72 | 72 | |
| 73 | 73 | <div id="wpinv-item-card-wrapper"> |
| 74 | 74 | |
| 75 | - <?php do_action( 'wpinv_subscription_card_top', $sub ); ?> |
|
| 75 | + <?php do_action('wpinv_subscription_card_top', $sub); ?> |
|
| 76 | 76 | |
| 77 | 77 | <div class="info-wrapper item-section"> |
| 78 | 78 | |
| 79 | - <form id="edit-item-info" method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $sub->id ); ?>"> |
|
| 79 | + <form id="edit-item-info" method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . $sub->id); ?>"> |
|
| 80 | 80 | |
| 81 | 81 | <div class="item-info"> |
| 82 | 82 | |
@@ -84,126 +84,126 @@ discard block |
||
| 84 | 84 | <tbody> |
| 85 | 85 | <tr> |
| 86 | 86 | <td class="row-title"> |
| 87 | - <label for="tablecell"><?php _e( 'Billing Cycle:', 'invoicing' ); ?></label> |
|
| 87 | + <label for="tablecell"><?php _e('Billing Cycle:', 'invoicing'); ?></label> |
|
| 88 | 88 | </td> |
| 89 | 89 | <td> |
| 90 | 90 | <?php |
| 91 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
| 92 | - $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
| 93 | - $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
| 94 | - printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
| 91 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($sub->period, $sub->frequency); |
|
| 92 | + $billing = wpinv_price(wpinv_format_amount($sub->recurring_amount), wpinv_get_invoice_currency_code($sub->parent_payment_id)) . ' / ' . $frequency; |
|
| 93 | + $initial = wpinv_price(wpinv_format_amount($sub->initial_amount), wpinv_get_invoice_currency_code($sub->parent_payment_id)); |
|
| 94 | + printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); |
|
| 95 | 95 | ?> |
| 96 | 96 | </td> |
| 97 | 97 | </tr> |
| 98 | 98 | <tr> |
| 99 | 99 | <td class="row-title"> |
| 100 | - <label for="tablecell"><?php _e( 'Times Billed:', 'invoicing' ); ?></label> |
|
| 100 | + <label for="tablecell"><?php _e('Times Billed:', 'invoicing'); ?></label> |
|
| 101 | 101 | </td> |
| 102 | - <td><?php echo $sub->get_times_billed() . ' / ' . ( ( $sub->bill_times == 0 ) ? 'Until Cancelled' : $sub->bill_times ); ?></td> |
|
| 102 | + <td><?php echo $sub->get_times_billed() . ' / ' . (($sub->bill_times == 0) ? 'Until Cancelled' : $sub->bill_times); ?></td> |
|
| 103 | 103 | </tr> |
| 104 | 104 | <tr> |
| 105 | 105 | <td class="row-title"> |
| 106 | - <label for="tablecell"><?php _e( 'Customer:', 'invoicing' ); ?></label> |
|
| 106 | + <label for="tablecell"><?php _e('Customer:', 'invoicing'); ?></label> |
|
| 107 | 107 | </td> |
| 108 | 108 | <td> |
| 109 | - <?php $subscriber = get_userdata( $sub->customer_id ); ?> |
|
| 110 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&view=overview&id=' . $subscriber->ID ) ); ?>" target="_blank"><?php echo ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email; ?></a> |
|
| 109 | + <?php $subscriber = get_userdata($sub->customer_id); ?> |
|
| 110 | + <a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&view=overview&id=' . $subscriber->ID)); ?>" target="_blank"><?php echo !empty($subscriber->display_name) ? $subscriber->display_name : $subscriber->user_email; ?></a> |
|
| 111 | 111 | </td> |
| 112 | 112 | </tr> |
| 113 | 113 | <tr> |
| 114 | 114 | <td class="row-title"> |
| 115 | - <label for="tablecell"><?php _e( 'Initial Purchase ID:', 'invoicing' ); ?></label> |
|
| 115 | + <label for="tablecell"><?php _e('Initial Purchase ID:', 'invoicing'); ?></label> |
|
| 116 | 116 | </td> |
| 117 | - <td><?php echo '<a href="' . get_edit_post_link( $sub->parent_payment_id ) . '" target="_blank">' . $sub->parent_payment_id . '</a>'; ?></td> |
|
| 117 | + <td><?php echo '<a href="' . get_edit_post_link($sub->parent_payment_id) . '" target="_blank">' . $sub->parent_payment_id . '</a>'; ?></td> |
|
| 118 | 118 | </tr> |
| 119 | 119 | <tr> |
| 120 | 120 | <td class="row-title"> |
| 121 | - <label for="tablecell"><?php _e( 'Item:', 'invoicing' ); ?></label> |
|
| 121 | + <label for="tablecell"><?php _e('Item:', 'invoicing'); ?></label> |
|
| 122 | 122 | </td> |
| 123 | 123 | <td> |
| 124 | 124 | <?php |
| 125 | - echo wpinv_item_dropdown( array( |
|
| 125 | + echo wpinv_item_dropdown(array( |
|
| 126 | 126 | 'name' => 'product_id', |
| 127 | 127 | 'id' => 'wpinv_invoice_item', |
| 128 | 128 | 'with_packages' => false, |
| 129 | 129 | 'show_recurring' => true, |
| 130 | 130 | 'selected' => $sub->product_id, |
| 131 | 131 | 'class' => 'wpinv-sub-product-id', |
| 132 | - ) ); |
|
| 132 | + )); |
|
| 133 | 133 | |
| 134 | 134 | ?> |
| 135 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
| 135 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
| 136 | 136 | 'post' => $sub->product_id, |
| 137 | 137 | 'action' => 'edit' |
| 138 | - ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
| 138 | + ), admin_url('post.php'))); ?>" target="_blank"><?php _e('View Item', 'invoicing'); ?></a> |
|
| 139 | 139 | </td> |
| 140 | 140 | </tr> |
| 141 | 141 | <tr> |
| 142 | 142 | <td class="row-title"> |
| 143 | - <label for="tablecell"><?php _e( 'Payment Method:', 'invoicing' ); ?></label> |
|
| 143 | + <label for="tablecell"><?php _e('Payment Method:', 'invoicing'); ?></label> |
|
| 144 | 144 | </td> |
| 145 | - <td><?php echo wpinv_get_gateway_admin_label( wpinv_get_payment_gateway( $sub->parent_payment_id ) ); ?></td> |
|
| 145 | + <td><?php echo wpinv_get_gateway_admin_label(wpinv_get_payment_gateway($sub->parent_payment_id)); ?></td> |
|
| 146 | 146 | </tr> |
| 147 | 147 | <tr> |
| 148 | 148 | <td class="row-title"> |
| 149 | - <label for="tablecell"><?php _e( 'Profile ID:', 'invoicing' ); ?></label> |
|
| 149 | + <label for="tablecell"><?php _e('Profile ID:', 'invoicing'); ?></label> |
|
| 150 | 150 | </td> |
| 151 | 151 | <td> |
| 152 | 152 | <span class="wpinv-sub-profile-id"> |
| 153 | - <?php echo apply_filters( 'wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub ); ?> |
|
| 153 | + <?php echo apply_filters('wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub); ?> |
|
| 154 | 154 | </span> |
| 155 | - <input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr( $sub->profile_id ); ?>" /> |
|
| 155 | + <input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr($sub->profile_id); ?>" /> |
|
| 156 | 156 | <span> – </span> |
| 157 | - <a href="#" class="wpinv-edit-sub-profile-id"><?php _e( 'Edit', 'invoicing' ); ?></a> |
|
| 157 | + <a href="#" class="wpinv-edit-sub-profile-id"><?php _e('Edit', 'invoicing'); ?></a> |
|
| 158 | 158 | </td> |
| 159 | 159 | </tr> |
| 160 | 160 | <tr> |
| 161 | 161 | <td class="row-title"> |
| 162 | - <label for="tablecell"><?php _e( 'Transaction ID:', 'invoicing' ); ?></label> |
|
| 162 | + <label for="tablecell"><?php _e('Transaction ID:', 'invoicing'); ?></label> |
|
| 163 | 163 | </td> |
| 164 | 164 | <td> |
| 165 | 165 | <span class="wpinv-sub-transaction-id"><?php echo $sub->get_transaction_id(); ?></span> |
| 166 | - <input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr( $sub->get_transaction_id() ); ?>" /> |
|
| 166 | + <input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr($sub->get_transaction_id()); ?>" /> |
|
| 167 | 167 | <span> – </span> |
| 168 | - <a href="#" class="wpinv-edit-sub-transaction-id"><?php _e( 'Edit', 'invoicing' ); ?></a> |
|
| 168 | + <a href="#" class="wpinv-edit-sub-transaction-id"><?php _e('Edit', 'invoicing'); ?></a> |
|
| 169 | 169 | </td> |
| 170 | 170 | </tr> |
| 171 | 171 | <tr> |
| 172 | 172 | <td class="row-title"> |
| 173 | - <label for="tablecell"><?php _e( 'Date Created:', 'invoicing' ); ?></label> |
|
| 173 | + <label for="tablecell"><?php _e('Date Created:', 'invoicing'); ?></label> |
|
| 174 | 174 | </td> |
| 175 | - <td><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->created, current_time( 'timestamp' ) ) ); ?></td> |
|
| 175 | + <td><?php echo date_i18n(get_option('date_format'), strtotime($sub->created, current_time('timestamp'))); ?></td> |
|
| 176 | 176 | </tr> |
| 177 | 177 | <tr> |
| 178 | 178 | <td class="row-title"> |
| 179 | 179 | <label for="tablecell"> |
| 180 | - <?php if( 'trialling' == $sub->status ) : ?> |
|
| 181 | - <?php _e( 'Trialling Until:', 'invoicing' ); ?> |
|
| 180 | + <?php if ('trialling' == $sub->status) : ?> |
|
| 181 | + <?php _e('Trialling Until:', 'invoicing'); ?> |
|
| 182 | 182 | <?php else: ?> |
| 183 | - <?php _e( 'Expiration Date:', 'invoicing' ); ?> |
|
| 183 | + <?php _e('Expiration Date:', 'invoicing'); ?> |
|
| 184 | 184 | <?php endif; ?> |
| 185 | 185 | </label> |
| 186 | 186 | </td> |
| 187 | 187 | <td> |
| 188 | - <span class="wpinv-sub-expiration"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->expiration, current_time( 'timestamp' ) ) ); ?></span> |
|
| 189 | - <input type="text" name="expiration" class="wpiDatepicker hidden wpinv-sub-expiration" data-dateFormat="mm/dd/yy" value="<?php echo esc_attr( $sub->expiration ); ?>" /> |
|
| 188 | + <span class="wpinv-sub-expiration"><?php echo date_i18n(get_option('date_format'), strtotime($sub->expiration, current_time('timestamp'))); ?></span> |
|
| 189 | + <input type="text" name="expiration" class="wpiDatepicker hidden wpinv-sub-expiration" data-dateFormat="mm/dd/yy" value="<?php echo esc_attr($sub->expiration); ?>" /> |
|
| 190 | 190 | <span> – </span> |
| 191 | - <a href="#" class="wpinv-edit-sub-expiration"><?php _e( 'Edit', 'invoicing' ); ?></a> |
|
| 191 | + <a href="#" class="wpinv-edit-sub-expiration"><?php _e('Edit', 'invoicing'); ?></a> |
|
| 192 | 192 | </td> |
| 193 | 193 | </tr> |
| 194 | 194 | <tr> |
| 195 | 195 | <td class="row-title"> |
| 196 | - <label for="tablecell"><?php _e( 'Subscription Status:', 'invoicing' ); ?></label> |
|
| 196 | + <label for="tablecell"><?php _e('Subscription Status:', 'invoicing'); ?></label> |
|
| 197 | 197 | </td> |
| 198 | 198 | <td> |
| 199 | 199 | <select name="status"> |
| 200 | - <option value="pending"<?php selected( 'pending', $sub->status ); ?>><?php _e( 'Pending', 'invoicing' ); ?></option> |
|
| 201 | - <option value="active"<?php selected( 'active', $sub->status ); ?>><?php _e( 'Active', 'invoicing' ); ?></option> |
|
| 202 | - <option value="cancelled"<?php selected( 'cancelled', $sub->status ); ?>><?php _e( 'Cancelled', 'invoicing' ); ?></option> |
|
| 203 | - <option value="expired"<?php selected( 'expired', $sub->status ); ?>><?php _e( 'Expired', 'invoicing' ); ?></option> |
|
| 204 | - <option value="trialling"<?php selected( 'trialling', $sub->status ); ?>><?php _e( 'Trialling', 'invoicing' ); ?></option> |
|
| 205 | - <option value="failing"<?php selected( 'failing', $sub->status ); ?>><?php _e( 'Failing', 'invoicing' ); ?></option> |
|
| 206 | - <option value="completed"<?php selected( 'completed', $sub->status ); ?>><?php _e( 'Completed', 'invoicing' ); ?></option> |
|
| 200 | + <option value="pending"<?php selected('pending', $sub->status); ?>><?php _e('Pending', 'invoicing'); ?></option> |
|
| 201 | + <option value="active"<?php selected('active', $sub->status); ?>><?php _e('Active', 'invoicing'); ?></option> |
|
| 202 | + <option value="cancelled"<?php selected('cancelled', $sub->status); ?>><?php _e('Cancelled', 'invoicing'); ?></option> |
|
| 203 | + <option value="expired"<?php selected('expired', $sub->status); ?>><?php _e('Expired', 'invoicing'); ?></option> |
|
| 204 | + <option value="trialling"<?php selected('trialling', $sub->status); ?>><?php _e('Trialling', 'invoicing'); ?></option> |
|
| 205 | + <option value="failing"<?php selected('failing', $sub->status); ?>><?php _e('Failing', 'invoicing'); ?></option> |
|
| 206 | + <option value="completed"<?php selected('completed', $sub->status); ?>><?php _e('Completed', 'invoicing'); ?></option> |
|
| 207 | 207 | </select> |
| 208 | 208 | </td> |
| 209 | 209 | </tr> |
@@ -211,77 +211,77 @@ discard block |
||
| 211 | 211 | </table> |
| 212 | 212 | </div> |
| 213 | 213 | <div id="wpinv-sub-notices"> |
| 214 | - <div class="notice notice-info inline hidden" id="wpinv-sub-expiration-update-notice"><p><?php _e( 'Changing the expiration date will not affect when renewal payments are processed.', 'invoicing' ); ?></p></div> |
|
| 215 | - <div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e( 'Changing the product assigned will not automatically adjust any pricing.', 'invoicing' ); ?></p></div> |
|
| 216 | - <div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e( 'Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing' ); ?></p></div> |
|
| 214 | + <div class="notice notice-info inline hidden" id="wpinv-sub-expiration-update-notice"><p><?php _e('Changing the expiration date will not affect when renewal payments are processed.', 'invoicing'); ?></p></div> |
|
| 215 | + <div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e('Changing the product assigned will not automatically adjust any pricing.', 'invoicing'); ?></p></div> |
|
| 216 | + <div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e('Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing'); ?></p></div> |
|
| 217 | 217 | </div> |
| 218 | 218 | <div id="item-edit-actions" class="edit-item" style="float:right; margin: 10px 0 0; display: block;"> |
| 219 | - <?php wp_nonce_field( 'wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true ); ?> |
|
| 220 | - <input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e( 'Update Subscription', 'invoicing' ); ?>"/> |
|
| 221 | - <input type="hidden" name="sub_id" value="<?php echo absint( $sub->id ); ?>" /> |
|
| 222 | - <?php if( $sub->can_cancel() ) : ?> |
|
| 223 | - <a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e( 'Cancel Subscription', 'invoicing' ); ?></a> |
|
| 219 | + <?php wp_nonce_field('wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true); ?> |
|
| 220 | + <input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e('Update Subscription', 'invoicing'); ?>"/> |
|
| 221 | + <input type="hidden" name="sub_id" value="<?php echo absint($sub->id); ?>" /> |
|
| 222 | + <?php if ($sub->can_cancel()) : ?> |
|
| 223 | + <a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e('Cancel Subscription', 'invoicing'); ?></a> |
|
| 224 | 224 | <?php endif; ?> |
| 225 | - <input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e( 'Delete Subscription', 'invoicing' ); ?>"/> |
|
| 225 | + <input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e('Delete Subscription', 'invoicing'); ?>"/> |
|
| 226 | 226 | </div> |
| 227 | 227 | |
| 228 | 228 | </form> |
| 229 | 229 | </div> |
| 230 | 230 | |
| 231 | - <?php do_action( 'wpinv_subscription_before_stats', $sub ); ?> |
|
| 231 | + <?php do_action('wpinv_subscription_before_stats', $sub); ?> |
|
| 232 | 232 | |
| 233 | - <?php do_action( 'wpinv_subscription_before_tables_wrapper', $sub ); ?> |
|
| 233 | + <?php do_action('wpinv_subscription_before_tables_wrapper', $sub); ?> |
|
| 234 | 234 | |
| 235 | 235 | <div id="item-tables-wrapper" class="item-section"> |
| 236 | 236 | |
| 237 | - <?php do_action( 'wpinv_subscription_before_tables', $sub ); ?> |
|
| 237 | + <?php do_action('wpinv_subscription_before_tables', $sub); ?> |
|
| 238 | 238 | |
| 239 | - <h3><?php _e( 'Renewal Invoices:', 'invoicing' ); ?></h3> |
|
| 239 | + <h3><?php _e('Renewal Invoices:', 'invoicing'); ?></h3> |
|
| 240 | 240 | <?php $payments = $sub->get_child_payments(); ?> |
| 241 | - <?php if( 'manual' == $sub->gateway ) : ?> |
|
| 242 | - <p><strong><?php _e( 'Note:', 'invoicing' ); ?></strong> <?php _e( 'Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing' ); ?></p> |
|
| 241 | + <?php if ('manual' == $sub->gateway) : ?> |
|
| 242 | + <p><strong><?php _e('Note:', 'invoicing'); ?></strong> <?php _e('Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing'); ?></p> |
|
| 243 | 243 | <?php endif; ?> |
| 244 | 244 | <table class="wp-list-table widefat striped payments"> |
| 245 | 245 | <thead> |
| 246 | 246 | <tr> |
| 247 | - <th><?php _e( 'ID', 'invoicing' ); ?></th> |
|
| 248 | - <th><?php _e( 'Amount', 'invoicing' ); ?></th> |
|
| 249 | - <th><?php _e( 'Date', 'invoicing' ); ?></th> |
|
| 250 | - <th><?php _e( 'Status', 'invoicing' ); ?></th> |
|
| 251 | - <th><?php _e( 'Actions', 'invoicing' ); ?></th> |
|
| 247 | + <th><?php _e('ID', 'invoicing'); ?></th> |
|
| 248 | + <th><?php _e('Amount', 'invoicing'); ?></th> |
|
| 249 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
| 250 | + <th><?php _e('Status', 'invoicing'); ?></th> |
|
| 251 | + <th><?php _e('Actions', 'invoicing'); ?></th> |
|
| 252 | 252 | </tr> |
| 253 | 253 | </thead> |
| 254 | 254 | <tbody> |
| 255 | - <?php if ( ! empty( $payments ) ) : ?> |
|
| 256 | - <?php foreach ( $payments as $payment ) : ?> |
|
| 255 | + <?php if (!empty($payments)) : ?> |
|
| 256 | + <?php foreach ($payments as $payment) : ?> |
|
| 257 | 257 | <tr> |
| 258 | 258 | <td><?php echo $payment->ID; ?></td> |
| 259 | - <td><?php echo wpinv_payment_total( $payment->ID ); ?></td> |
|
| 260 | - <td><?php echo date_i18n( get_option( 'date_format' ), strtotime( $payment->post_date ) ); ?></td> |
|
| 261 | - <td><?php echo wpinv_get_invoice_status( $payment->ID, true ); ?></td> |
|
| 259 | + <td><?php echo wpinv_payment_total($payment->ID); ?></td> |
|
| 260 | + <td><?php echo date_i18n(get_option('date_format'), strtotime($payment->post_date)); ?></td> |
|
| 261 | + <td><?php echo wpinv_get_invoice_status($payment->ID, true); ?></td> |
|
| 262 | 262 | <td> |
| 263 | - <a title="<?php _e( 'View Details for Invoice.', 'invoicing' ); |
|
| 264 | - echo ' ' . $payment->ID; ?>" href="<?php echo get_edit_post_link( $payment->ID ); ?>"> |
|
| 265 | - <?php _e( 'View Details', 'invoicing' ); ?> |
|
| 263 | + <a title="<?php _e('View Details for Invoice.', 'invoicing'); |
|
| 264 | + echo ' ' . $payment->ID; ?>" href="<?php echo get_edit_post_link($payment->ID); ?>"> |
|
| 265 | + <?php _e('View Details', 'invoicing'); ?> |
|
| 266 | 266 | </a> |
| 267 | - <?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?> |
|
| 267 | + <?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?> |
|
| 268 | 268 | </td> |
| 269 | 269 | </tr> |
| 270 | 270 | <?php endforeach; ?> |
| 271 | 271 | <?php else: ?> |
| 272 | 272 | <tr> |
| 273 | - <td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); ?></td> |
|
| 273 | + <td colspan="5"><?php _e('No Invoices Found.', 'invoicing'); ?></td> |
|
| 274 | 274 | </tr> |
| 275 | 275 | <?php endif; ?> |
| 276 | 276 | </tbody> |
| 277 | 277 | <tfoot></tfoot> |
| 278 | 278 | </table> |
| 279 | 279 | |
| 280 | - <?php do_action( 'wpinv_subscription_after_tables', $sub ); ?> |
|
| 280 | + <?php do_action('wpinv_subscription_after_tables', $sub); ?> |
|
| 281 | 281 | |
| 282 | 282 | </div> |
| 283 | 283 | |
| 284 | - <?php do_action( 'wpinv_subscription_card_bottom', $sub ); ?> |
|
| 284 | + <?php do_action('wpinv_subscription_card_bottom', $sub); ?> |
|
| 285 | 285 | </div> |
| 286 | 286 | |
| 287 | 287 | <?php endif; ?> |
@@ -299,38 +299,38 @@ discard block |
||
| 299 | 299 | */ |
| 300 | 300 | function wpinv_recurring_process_subscription_update() { |
| 301 | 301 | |
| 302 | - if( empty( $_POST['sub_id'] ) ) { |
|
| 302 | + if (empty($_POST['sub_id'])) { |
|
| 303 | 303 | return; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
| 306 | + if (empty($_POST['wpinv_update_subscription'])) { |
|
| 307 | 307 | return; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
| 310 | + if (!current_user_can('manage_invoicing')) { |
|
| 311 | 311 | return; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
| 315 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 314 | + if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) { |
|
| 315 | + wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - $expiration = date( 'Y-m-d 23:59:59', strtotime( $_POST['expiration'] ) ); |
|
| 319 | - $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
| 320 | - $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
| 321 | - $product_id = absint( $_POST['product_id'] ); |
|
| 322 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
| 323 | - $subscription->update( array( |
|
| 324 | - 'status' => sanitize_text_field( $_POST['status'] ), |
|
| 318 | + $expiration = date('Y-m-d 23:59:59', strtotime($_POST['expiration'])); |
|
| 319 | + $profile_id = sanitize_text_field($_POST['profile_id']); |
|
| 320 | + $transaction_id = sanitize_text_field($_POST['transaction_id']); |
|
| 321 | + $product_id = absint($_POST['product_id']); |
|
| 322 | + $subscription = new WPInv_Subscription(absint($_POST['sub_id'])); |
|
| 323 | + $subscription->update(array( |
|
| 324 | + 'status' => sanitize_text_field($_POST['status']), |
|
| 325 | 325 | 'expiration' => $expiration, |
| 326 | 326 | 'profile_id' => $profile_id, |
| 327 | 327 | 'product_id' => $product_id, |
| 328 | 328 | 'transaction_id' => $transaction_id, |
| 329 | - ) ); |
|
| 329 | + )); |
|
| 330 | 330 | |
| 331 | - $status = sanitize_text_field( $_POST['status'] ); |
|
| 331 | + $status = sanitize_text_field($_POST['status']); |
|
| 332 | 332 | |
| 333 | - switch( $status ) { |
|
| 333 | + switch ($status) { |
|
| 334 | 334 | |
| 335 | 335 | case 'cancelled' : |
| 336 | 336 | |
@@ -349,11 +349,11 @@ discard block |
||
| 349 | 349 | |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
| 352 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id)); |
|
| 353 | 353 | exit; |
| 354 | 354 | |
| 355 | 355 | } |
| 356 | -add_action( 'admin_init', 'wpinv_recurring_process_subscription_update', 1 ); |
|
| 356 | +add_action('admin_init', 'wpinv_recurring_process_subscription_update', 1); |
|
| 357 | 357 | |
| 358 | 358 | /** |
| 359 | 359 | * Handles subscription deletion |
@@ -364,30 +364,30 @@ discard block |
||
| 364 | 364 | */ |
| 365 | 365 | function wpinv_recurring_process_subscription_deletion() { |
| 366 | 366 | |
| 367 | - if( empty( $_POST['sub_id'] ) ) { |
|
| 367 | + if (empty($_POST['sub_id'])) { |
|
| 368 | 368 | return; |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
| 371 | + if (empty($_POST['wpinv_delete_subscription'])) { |
|
| 372 | 372 | return; |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
| 375 | + if (!current_user_can('manage_invoicing')) { |
|
| 376 | 376 | return; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
| 380 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 379 | + if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) { |
|
| 380 | + wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
| 383 | + $subscription = new WPInv_Subscription(absint($_POST['sub_id'])); |
|
| 384 | 384 | |
| 385 | - delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
| 385 | + delete_post_meta($subscription->parent_payment_id, '_wpinv_subscription_payment'); |
|
| 386 | 386 | |
| 387 | 387 | $subscription->delete(); |
| 388 | 388 | |
| 389 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
| 389 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=deleted')); |
|
| 390 | 390 | exit; |
| 391 | 391 | |
| 392 | 392 | } |
| 393 | -add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 ); |
|
| 393 | +add_action('admin_init', 'wpinv_recurring_process_subscription_deletion', 2); |
|
@@ -1,6 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly. |
| 3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if (!defined( 'ABSPATH' ) ) { |
|
| 4 | + exit; |
|
| 5 | +} |
|
| 4 | 6 | |
| 5 | 7 | function wpinv_subscription_init() { |
| 6 | 8 | return WPInv_Subscriptions::instance(); |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly. |
| 3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if (!defined('ABSPATH')) exit; |
|
| 4 | 4 | |
| 5 | 5 | function wpinv_subscription_init() { |
| 6 | 6 | return WPInv_Subscriptions::instance(); |
| 7 | 7 | } |
| 8 | -add_action( 'plugins_loaded', 'wpinv_subscription_init', 100 ); |
|
| 8 | +add_action('plugins_loaded', 'wpinv_subscription_init', 100); |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * WPInv_Subscriptions Class. |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * Main WPInv_Subscriptions Instance |
| 21 | 21 | */ |
| 22 | 22 | public static function instance() { |
| 23 | - if ( ! isset( self::$instance ) ) { |
|
| 23 | + if (!isset(self::$instance)) { |
|
| 24 | 24 | self::$instance = new WPInv_Subscriptions; |
| 25 | 25 | |
| 26 | 26 | self::$instance->init(); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @since 1.0.0 |
| 36 | 36 | */ |
| 37 | - private function __construct(){ |
|
| 37 | + private function __construct() { |
|
| 38 | 38 | |
| 39 | 39 | } |
| 40 | 40 | |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | private function setup_constants() { |
| 64 | 64 | |
| 65 | 65 | // Make sure CAL_GREGORIAN is defined. |
| 66 | - if ( ! defined( 'CAL_GREGORIAN' ) ) { |
|
| 67 | - define( 'CAL_GREGORIAN', 1 ); |
|
| 66 | + if (!defined('CAL_GREGORIAN')) { |
|
| 67 | + define('CAL_GREGORIAN', 1); |
|
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
@@ -76,13 +76,13 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | private function actions() { |
| 78 | 78 | |
| 79 | - add_action( 'admin_menu', array( $this, 'wpinv_subscriptions_list' ), 10 ); |
|
| 80 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
| 81 | - add_action( 'init', array( $this, 'wpinv_post_actions' ) ); |
|
| 82 | - add_action( 'init', array( $this, 'wpinv_get_actions' ) ); |
|
| 83 | - add_action( 'wpinv_cancel_subscription', array( $this, 'wpinv_process_cancellation' ) ); |
|
| 84 | - add_action( 'wpi-pending_wpi_invoice', array( $this, 'wpinv_add_update_subscription' ), 10, 2 ); |
|
| 85 | - add_action( 'wpinv_subscriptions_front_notices', array( $this, 'notices' ) ); |
|
| 79 | + add_action('admin_menu', array($this, 'wpinv_subscriptions_list'), 10); |
|
| 80 | + add_action('admin_notices', array($this, 'notices')); |
|
| 81 | + add_action('init', array($this, 'wpinv_post_actions')); |
|
| 82 | + add_action('init', array($this, 'wpinv_get_actions')); |
|
| 83 | + add_action('wpinv_cancel_subscription', array($this, 'wpinv_process_cancellation')); |
|
| 84 | + add_action('wpi-pending_wpi_invoice', array($this, 'wpinv_add_update_subscription'), 10, 2); |
|
| 85 | + add_action('wpinv_subscriptions_front_notices', array($this, 'notices')); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | public function wpinv_subscriptions_list() { |
| 105 | 105 | add_submenu_page( |
| 106 | 106 | 'wpinv', |
| 107 | - __( 'Subscriptions', 'invoicing' ), |
|
| 108 | - __( 'Subscriptions', 'invoicing' ), |
|
| 107 | + __('Subscriptions', 'invoicing'), |
|
| 108 | + __('Subscriptions', 'invoicing'), |
|
| 109 | 109 | 'manage_invoicing', |
| 110 | 110 | 'wpinv-subscriptions', |
| 111 | 111 | 'wpinv_subscriptions_page' |
@@ -114,37 +114,37 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | public function notices() { |
| 116 | 116 | |
| 117 | - if( empty( $_GET['wpinv-message'] ) ) { |
|
| 117 | + if (empty($_GET['wpinv-message'])) { |
|
| 118 | 118 | return; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | $type = 'updated'; |
| 122 | 122 | $message = ''; |
| 123 | 123 | |
| 124 | - switch( strtolower( $_GET['wpinv-message'] ) ) { |
|
| 124 | + switch (strtolower($_GET['wpinv-message'])) { |
|
| 125 | 125 | |
| 126 | 126 | case 'updated' : |
| 127 | 127 | |
| 128 | - $message = __( 'Subscription updated successfully.', 'invoicing' ); |
|
| 128 | + $message = __('Subscription updated successfully.', 'invoicing'); |
|
| 129 | 129 | |
| 130 | 130 | break; |
| 131 | 131 | |
| 132 | 132 | case 'deleted' : |
| 133 | 133 | |
| 134 | - $message = __( 'Subscription deleted successfully.', 'invoicing' ); |
|
| 134 | + $message = __('Subscription deleted successfully.', 'invoicing'); |
|
| 135 | 135 | |
| 136 | 136 | break; |
| 137 | 137 | |
| 138 | 138 | case 'cancelled' : |
| 139 | 139 | |
| 140 | - $message = __( 'Subscription cancelled successfully.', 'invoicing' ); |
|
| 140 | + $message = __('Subscription cancelled successfully.', 'invoicing'); |
|
| 141 | 141 | |
| 142 | 142 | break; |
| 143 | 143 | |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - if ( ! empty( $message ) ) { |
|
| 147 | - echo '<div class="' . esc_attr( $type ) . '"><p>' . $message . '</p></div>'; |
|
| 146 | + if (!empty($message)) { |
|
| 147 | + echo '<div class="' . esc_attr($type) . '"><p>' . $message . '</p></div>'; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | } |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | * @return void |
| 158 | 158 | */ |
| 159 | 159 | function wpinv_get_actions() { |
| 160 | - if ( isset( $_GET['wpinv_action'] ) ) { |
|
| 161 | - do_action( 'wpinv_' . $_GET['wpinv_action'], $_GET ); |
|
| 160 | + if (isset($_GET['wpinv_action'])) { |
|
| 161 | + do_action('wpinv_' . $_GET['wpinv_action'], $_GET); |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | * @return void |
| 171 | 171 | */ |
| 172 | 172 | function wpinv_post_actions() { |
| 173 | - if ( isset( $_POST['wpinv_action'] ) ) { |
|
| 174 | - do_action( 'wpinv_' . $_POST['wpinv_action'], $_POST ); |
|
| 173 | + if (isset($_POST['wpinv_action'])) { |
|
| 174 | + do_action('wpinv_' . $_POST['wpinv_action'], $_POST); |
|
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | |
@@ -182,24 +182,24 @@ discard block |
||
| 182 | 182 | * @param int $frequency_count The frequency of the period. |
| 183 | 183 | * @return mixed|string|void |
| 184 | 184 | */ |
| 185 | - public static function wpinv_get_pretty_subscription_frequency( $period, $frequency_count = 1) { |
|
| 185 | + public static function wpinv_get_pretty_subscription_frequency($period, $frequency_count = 1) { |
|
| 186 | 186 | $frequency = ''; |
| 187 | 187 | //Format period details |
| 188 | - switch ( $period ) { |
|
| 188 | + switch ($period) { |
|
| 189 | 189 | case 'day' : |
| 190 | - $frequency = sprintf( _n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count); |
|
| 190 | + $frequency = sprintf(_n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count); |
|
| 191 | 191 | break; |
| 192 | 192 | case 'week' : |
| 193 | - $frequency = sprintf( _n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count); |
|
| 193 | + $frequency = sprintf(_n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count); |
|
| 194 | 194 | break; |
| 195 | 195 | case 'month' : |
| 196 | - $frequency = sprintf( _n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count); |
|
| 196 | + $frequency = sprintf(_n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count); |
|
| 197 | 197 | break; |
| 198 | 198 | case 'year' : |
| 199 | - $frequency = sprintf( _n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count); |
|
| 199 | + $frequency = sprintf(_n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count); |
|
| 200 | 200 | break; |
| 201 | 201 | default : |
| 202 | - $frequency = apply_filters( 'wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count ); |
|
| 202 | + $frequency = apply_filters('wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count); |
|
| 203 | 203 | break; |
| 204 | 204 | } |
| 205 | 205 | |
@@ -214,50 +214,50 @@ discard block |
||
| 214 | 214 | * @since 1.0.0 |
| 215 | 215 | * @return void |
| 216 | 216 | */ |
| 217 | - public function wpinv_process_cancellation( $data ) { |
|
| 217 | + public function wpinv_process_cancellation($data) { |
|
| 218 | 218 | |
| 219 | 219 | |
| 220 | - if( empty( $data['sub_id'] ) ) { |
|
| 220 | + if (empty($data['sub_id'])) { |
|
| 221 | 221 | return; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - if( ! is_user_logged_in() ) { |
|
| 224 | + if (!is_user_logged_in()) { |
|
| 225 | 225 | return; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - if( ! wp_verify_nonce( $data['_wpnonce'], 'wpinv-recurring-cancel' ) ) { |
|
| 229 | - wp_die( __( 'Error', 'invoicing' ), __( 'Nonce verification failed', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 228 | + if (!wp_verify_nonce($data['_wpnonce'], 'wpinv-recurring-cancel')) { |
|
| 229 | + wp_die(__('Error', 'invoicing'), __('Nonce verification failed', 'invoicing'), array('response' => 403)); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - $data['sub_id'] = absint( $data['sub_id'] ); |
|
| 233 | - $subscription = new WPInv_Subscription( $data['sub_id'] ); |
|
| 232 | + $data['sub_id'] = absint($data['sub_id']); |
|
| 233 | + $subscription = new WPInv_Subscription($data['sub_id']); |
|
| 234 | 234 | |
| 235 | - if( ! $subscription->can_cancel() ) { |
|
| 236 | - wp_die( __( 'Error', 'invoicing' ), __( 'This subscription cannot be cancelled', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 235 | + if (!$subscription->can_cancel()) { |
|
| 236 | + wp_die(__('Error', 'invoicing'), __('This subscription cannot be cancelled', 'invoicing'), array('response' => 403)); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | try { |
| 240 | 240 | |
| 241 | - do_action( 'wpinv_recurring_cancel_' . $subscription->gateway . '_subscription', $subscription, true ); |
|
| 241 | + do_action('wpinv_recurring_cancel_' . $subscription->gateway . '_subscription', $subscription, true); |
|
| 242 | 242 | |
| 243 | 243 | $subscription->cancel(); |
| 244 | 244 | |
| 245 | - if( is_admin() ) { |
|
| 245 | + if (is_admin()) { |
|
| 246 | 246 | |
| 247 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=cancelled&id=' . $subscription->id ) ); |
|
| 247 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=cancelled&id=' . $subscription->id)); |
|
| 248 | 248 | exit; |
| 249 | 249 | |
| 250 | 250 | } else { |
| 251 | 251 | |
| 252 | - $redirect = remove_query_arg( array( '_wpnonce', 'wpinv_action', 'sub_id' ), add_query_arg( array( 'wpinv-message' => 'cancelled' ) ) ); |
|
| 253 | - $redirect = apply_filters( 'wpinv_recurring_cancellation_redirect', $redirect, $subscription ); |
|
| 254 | - wp_safe_redirect( $redirect ); |
|
| 252 | + $redirect = remove_query_arg(array('_wpnonce', 'wpinv_action', 'sub_id'), add_query_arg(array('wpinv-message' => 'cancelled'))); |
|
| 253 | + $redirect = apply_filters('wpinv_recurring_cancellation_redirect', $redirect, $subscription); |
|
| 254 | + wp_safe_redirect($redirect); |
|
| 255 | 255 | exit; |
| 256 | 256 | |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - } catch ( Exception $e ) { |
|
| 260 | - wp_die( __( 'Error', 'invoicing' ), $e->getMessage(), array( 'response' => 403 ) ); |
|
| 259 | + } catch (Exception $e) { |
|
| 260 | + wp_die(__('Error', 'invoicing'), $e->getMessage(), array('response' => 403)); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | } |
@@ -269,46 +269,46 @@ discard block |
||
| 269 | 269 | * @since 1.0.0 |
| 270 | 270 | * @return void |
| 271 | 271 | */ |
| 272 | - public function wpinv_add_update_subscription( $invoice_id, $invoice ) { |
|
| 272 | + public function wpinv_add_update_subscription($invoice_id, $invoice) { |
|
| 273 | 273 | |
| 274 | - remove_action( 'save_post', __FUNCTION__ ); |
|
| 274 | + remove_action('save_post', __FUNCTION__); |
|
| 275 | 275 | |
| 276 | - if(empty($invoice_id) || 'wpi_invoice' != get_post_type($invoice_id)){ |
|
| 276 | + if (empty($invoice_id) || 'wpi_invoice' != get_post_type($invoice_id)) { |
|
| 277 | 277 | return; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - if ( defined( 'DOING_AUTOSAVE' ) ) { |
|
| 280 | + if (defined('DOING_AUTOSAVE')) { |
|
| 281 | 281 | return; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
| 284 | + if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
| 285 | 285 | return; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | $invoice_obj = new WPInv_Invoice($invoice_id); |
| 289 | 289 | |
| 290 | - if ( !$invoice_obj->is_recurring() ) { |
|
| 290 | + if (!$invoice_obj->is_recurring()) { |
|
| 291 | 291 | return; |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | $item_id = $invoice_obj->get_recurring(); |
| 295 | - $item = new WPInv_Item( $item_id ); |
|
| 295 | + $item = new WPInv_Item($item_id); |
|
| 296 | 296 | |
| 297 | 297 | $period = $item->get_recurring_period(true); |
| 298 | 298 | $interval = $item->get_recurring_interval(); |
| 299 | 299 | $bill_times = (int)$item->get_recurring_limit(); |
| 300 | - $initial_amount = wpinv_sanitize_amount( $invoice_obj->get_total(), 2 ); |
|
| 301 | - $recurring_amount = wpinv_sanitize_amount( $invoice_obj->get_recurring_details( 'total' ), 2 ); |
|
| 300 | + $initial_amount = wpinv_sanitize_amount($invoice_obj->get_total(), 2); |
|
| 301 | + $recurring_amount = wpinv_sanitize_amount($invoice_obj->get_recurring_details('total'), 2); |
|
| 302 | 302 | $status = 'pending'; |
| 303 | - $expiration = date( 'Y-m-d H:i:s', strtotime( '+' . $interval . ' ' . $period . ' 23:59:59', current_time( 'timestamp' ) ) ); |
|
| 303 | + $expiration = date('Y-m-d H:i:s', strtotime('+' . $interval . ' ' . $period . ' 23:59:59', current_time('timestamp'))); |
|
| 304 | 304 | |
| 305 | 305 | |
| 306 | 306 | $trial_period = ''; |
| 307 | - if ( $invoice_obj->is_free_trial() && $item->has_free_trial() ) { |
|
| 307 | + if ($invoice_obj->is_free_trial() && $item->has_free_trial()) { |
|
| 308 | 308 | $trial_period = $item->get_trial_period(true); |
| 309 | 309 | $free_trial = $item->get_free_trial(); |
| 310 | - $trial_period = ! empty( $invoice_obj->is_free_trial() ) ? $free_trial . ' ' . $trial_period : ''; |
|
| 311 | - $expiration = date( 'Y-m-d H:i:s', strtotime( '+' . $trial_period . ' 23:59:59', current_time( 'timestamp' ) ) ); |
|
| 310 | + $trial_period = !empty($invoice_obj->is_free_trial()) ? $free_trial . ' ' . $trial_period : ''; |
|
| 311 | + $expiration = date('Y-m-d H:i:s', strtotime('+' . $trial_period . ' 23:59:59', current_time('timestamp'))); |
|
| 312 | 312 | $status = 'trialling'; |
| 313 | 313 | } |
| 314 | 314 | |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | 'initial_amount' => $initial_amount, |
| 323 | 323 | 'recurring_amount' => $recurring_amount, |
| 324 | 324 | 'bill_times' => $bill_times, |
| 325 | - 'created' => date( 'Y-m-d H:i:s' ), |
|
| 325 | + 'created' => date('Y-m-d H:i:s'), |
|
| 326 | 326 | 'expiration' => $expiration, |
| 327 | 327 | 'trial_period' => $trial_period, |
| 328 | 328 | 'profile_id' => '', |
@@ -330,13 +330,13 @@ discard block |
||
| 330 | 330 | ); |
| 331 | 331 | |
| 332 | 332 | $subs_db = new WPInv_Subscriptions_DB; |
| 333 | - $subs = $subs_db->get_subscriptions( array( 'parent_payment_id' => $invoice_obj->ID, 'number' => 1 ) ); |
|
| 334 | - $subscription = reset( $subs ); |
|
| 333 | + $subs = $subs_db->get_subscriptions(array('parent_payment_id' => $invoice_obj->ID, 'number' => 1)); |
|
| 334 | + $subscription = reset($subs); |
|
| 335 | 335 | |
| 336 | - if( !$subscription || $subscription->id <= 0 ) { |
|
| 336 | + if (!$subscription || $subscription->id <= 0) { |
|
| 337 | 337 | |
| 338 | 338 | $subscription = new WPInv_Subscription(); |
| 339 | - $subscription->create( $args ); |
|
| 339 | + $subscription->create($args); |
|
| 340 | 340 | |
| 341 | 341 | } |
| 342 | 342 | |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | * |
| 258 | 258 | * @since 2.4 |
| 259 | 259 | * @param array $args Array of values for the payment, including amount and transaction ID |
| 260 | - * @return bool |
|
| 260 | + * @return false|string |
|
| 261 | 261 | */ |
| 262 | 262 | public function add_payment( $args = array() ) { |
| 263 | 263 | |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | * Retrieves the transaction ID from the subscription |
| 287 | 287 | * |
| 288 | 288 | * @since 1.0.0 |
| 289 | - * @return bool |
|
| 289 | + * @return string |
|
| 290 | 290 | */ |
| 291 | 291 | public function get_transaction_id() { |
| 292 | 292 | |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | * Stores the transaction ID for the subscription purchase |
| 309 | 309 | * |
| 310 | 310 | * @since 1.0.0.4 |
| 311 | - * @return bool |
|
| 311 | + * @return boolean|null |
|
| 312 | 312 | */ |
| 313 | 313 | public function set_transaction_id( $txn_id = '' ) { |
| 314 | 314 | $this->update( array( 'transaction_id' => $txn_id ) ); |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | * Renews a subscription |
| 320 | 320 | * |
| 321 | 321 | * @since 1.0.0 |
| 322 | - * @return bool |
|
| 322 | + * @return boolean|null |
|
| 323 | 323 | */ |
| 324 | 324 | public function renew() { |
| 325 | 325 | |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | * |
| 409 | 409 | * @since 1.0.0 |
| 410 | 410 | * @param $check_expiration bool True if expiration date should be checked with merchant processor before expiring |
| 411 | - * @return void |
|
| 411 | + * @return false|null |
|
| 412 | 412 | */ |
| 413 | 413 | public function expire( $check_expiration = false ) { |
| 414 | 414 | |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | * Retrieves the subscription status |
| 656 | 656 | * |
| 657 | 657 | * @since 1.0.0 |
| 658 | - * @return int |
|
| 658 | + * @return string |
|
| 659 | 659 | */ |
| 660 | 660 | public function get_status() { |
| 661 | 661 | |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly |
| 4 | 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 5 | - exit; |
|
| 5 | + exit; |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | |
@@ -13,252 +13,252 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | class WPInv_Subscription { |
| 15 | 15 | |
| 16 | - private $subs_db; |
|
| 16 | + private $subs_db; |
|
| 17 | + |
|
| 18 | + public $id = 0; |
|
| 19 | + public $customer_id = 0; |
|
| 20 | + public $period = ''; |
|
| 21 | + public $initial_amount = ''; |
|
| 22 | + public $recurring_amount = ''; |
|
| 23 | + public $bill_times = 0; |
|
| 24 | + public $transaction_id = ''; |
|
| 25 | + public $parent_payment_id = 0; |
|
| 26 | + public $product_id = 0; |
|
| 27 | + public $created = '0000-00-00 00:00:00'; |
|
| 28 | + public $expiration = '0000-00-00 00:00:00'; |
|
| 29 | + public $trial_period = ''; |
|
| 30 | + public $status = 'pending'; |
|
| 31 | + public $profile_id = ''; |
|
| 32 | + public $gateway = ''; |
|
| 33 | + public $customer; |
|
| 17 | 34 | |
| 18 | - public $id = 0; |
|
| 19 | - public $customer_id = 0; |
|
| 20 | - public $period = ''; |
|
| 21 | - public $initial_amount = ''; |
|
| 22 | - public $recurring_amount = ''; |
|
| 23 | - public $bill_times = 0; |
|
| 24 | - public $transaction_id = ''; |
|
| 25 | - public $parent_payment_id = 0; |
|
| 26 | - public $product_id = 0; |
|
| 27 | - public $created = '0000-00-00 00:00:00'; |
|
| 28 | - public $expiration = '0000-00-00 00:00:00'; |
|
| 29 | - public $trial_period = ''; |
|
| 30 | - public $status = 'pending'; |
|
| 31 | - public $profile_id = ''; |
|
| 32 | - public $gateway = ''; |
|
| 33 | - public $customer; |
|
| 35 | + /** |
|
| 36 | + * Get us started |
|
| 37 | + * |
|
| 38 | + * @since 1.0.0 |
|
| 39 | + * @return void |
|
| 40 | + */ |
|
| 41 | + function __construct( $_id_or_object = 0, $_by_profile_id = false ) { |
|
| 34 | 42 | |
| 35 | - /** |
|
| 36 | - * Get us started |
|
| 37 | - * |
|
| 38 | - * @since 1.0.0 |
|
| 39 | - * @return void |
|
| 40 | - */ |
|
| 41 | - function __construct( $_id_or_object = 0, $_by_profile_id = false ) { |
|
| 43 | + $this->subs_db = new WPInv_Subscriptions_DB; |
|
| 42 | 44 | |
| 43 | - $this->subs_db = new WPInv_Subscriptions_DB; |
|
| 45 | + if( $_by_profile_id ) { |
|
| 44 | 46 | |
| 45 | - if( $_by_profile_id ) { |
|
| 47 | + $_sub = $this->subs_db->get_by( 'profile_id', $_id_or_object ); |
|
| 46 | 48 | |
| 47 | - $_sub = $this->subs_db->get_by( 'profile_id', $_id_or_object ); |
|
| 49 | + if( empty( $_sub ) ) { |
|
| 50 | + return false; |
|
| 51 | + } |
|
| 48 | 52 | |
| 49 | - if( empty( $_sub ) ) { |
|
| 50 | - return false; |
|
| 51 | - } |
|
| 53 | + $_id_or_object = $_sub; |
|
| 52 | 54 | |
| 53 | - $_id_or_object = $_sub; |
|
| 55 | + } |
|
| 54 | 56 | |
| 55 | - } |
|
| 57 | + return $this->setup_subscription( $_id_or_object ); |
|
| 58 | + } |
|
| 56 | 59 | |
| 57 | - return $this->setup_subscription( $_id_or_object ); |
|
| 58 | - } |
|
| 60 | + /** |
|
| 61 | + * Setup the subscription object |
|
| 62 | + * |
|
| 63 | + * @since 1.0.0 |
|
| 64 | + * @return void |
|
| 65 | + */ |
|
| 66 | + private function setup_subscription( $id_or_object = 0 ) { |
|
| 59 | 67 | |
| 60 | - /** |
|
| 61 | - * Setup the subscription object |
|
| 62 | - * |
|
| 63 | - * @since 1.0.0 |
|
| 64 | - * @return void |
|
| 65 | - */ |
|
| 66 | - private function setup_subscription( $id_or_object = 0 ) { |
|
| 68 | + if( empty( $id_or_object ) ) { |
|
| 69 | + return false; |
|
| 70 | + } |
|
| 67 | 71 | |
| 68 | - if( empty( $id_or_object ) ) { |
|
| 69 | - return false; |
|
| 70 | - } |
|
| 72 | + if( is_numeric( $id_or_object ) ) { |
|
| 71 | 73 | |
| 72 | - if( is_numeric( $id_or_object ) ) { |
|
| 74 | + $sub = $this->subs_db->get( $id_or_object ); |
|
| 73 | 75 | |
| 74 | - $sub = $this->subs_db->get( $id_or_object ); |
|
| 76 | + } elseif( is_object( $id_or_object ) ) { |
|
| 75 | 77 | |
| 76 | - } elseif( is_object( $id_or_object ) ) { |
|
| 78 | + $sub = $id_or_object; |
|
| 77 | 79 | |
| 78 | - $sub = $id_or_object; |
|
| 80 | + } |
|
| 79 | 81 | |
| 80 | - } |
|
| 82 | + if( empty( $sub ) ) { |
|
| 83 | + return false; |
|
| 84 | + } |
|
| 81 | 85 | |
| 82 | - if( empty( $sub ) ) { |
|
| 83 | - return false; |
|
| 84 | - } |
|
| 86 | + foreach( $sub as $key => $value ) { |
|
| 87 | + $this->$key = $value; |
|
| 88 | + } |
|
| 85 | 89 | |
| 86 | - foreach( $sub as $key => $value ) { |
|
| 87 | - $this->$key = $value; |
|
| 88 | - } |
|
| 90 | + $this->customer = get_userdata( $this->customer_id ); |
|
| 91 | + $this->gateway = wpinv_get_payment_gateway( $this->parent_payment_id ); |
|
| 89 | 92 | |
| 90 | - $this->customer = get_userdata( $this->customer_id ); |
|
| 91 | - $this->gateway = wpinv_get_payment_gateway( $this->parent_payment_id ); |
|
| 93 | + do_action( 'wpinv_recurring_setup_subscription', $this ); |
|
| 92 | 94 | |
| 93 | - do_action( 'wpinv_recurring_setup_subscription', $this ); |
|
| 95 | + return $this; |
|
| 96 | + } |
|
| 94 | 97 | |
| 95 | - return $this; |
|
| 96 | - } |
|
| 98 | + /** |
|
| 99 | + * Magic __get function to dispatch a call to retrieve a private property |
|
| 100 | + * |
|
| 101 | + * @since 1.0.0 |
|
| 102 | + */ |
|
| 103 | + public function __get( $key ) { |
|
| 97 | 104 | |
| 98 | - /** |
|
| 99 | - * Magic __get function to dispatch a call to retrieve a private property |
|
| 100 | - * |
|
| 101 | - * @since 1.0.0 |
|
| 102 | - */ |
|
| 103 | - public function __get( $key ) { |
|
| 105 | + if( method_exists( $this, 'get_' . $key ) ) { |
|
| 104 | 106 | |
| 105 | - if( method_exists( $this, 'get_' . $key ) ) { |
|
| 107 | + return call_user_func( array( $this, 'get_' . $key ) ); |
|
| 106 | 108 | |
| 107 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
| 109 | + } else { |
|
| 108 | 110 | |
| 109 | - } else { |
|
| 111 | + return new WP_Error( 'wpinv-subscription-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) ); |
|
| 110 | 112 | |
| 111 | - return new WP_Error( 'wpinv-subscription-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) ); |
|
| 113 | + } |
|
| 112 | 114 | |
| 113 | - } |
|
| 115 | + } |
|
| 114 | 116 | |
| 115 | - } |
|
| 117 | + /** |
|
| 118 | + * Creates a subscription |
|
| 119 | + * |
|
| 120 | + * @since 1.0.0 |
|
| 121 | + * @param array $data Array of attributes for a subscription |
|
| 122 | + * @return mixed false if data isn't passed and class not instantiated for creation |
|
| 123 | + */ |
|
| 124 | + public function create( $data = array() ) { |
|
| 116 | 125 | |
| 117 | - /** |
|
| 118 | - * Creates a subscription |
|
| 119 | - * |
|
| 120 | - * @since 1.0.0 |
|
| 121 | - * @param array $data Array of attributes for a subscription |
|
| 122 | - * @return mixed false if data isn't passed and class not instantiated for creation |
|
| 123 | - */ |
|
| 124 | - public function create( $data = array() ) { |
|
| 126 | + if ( $this->id != 0 ) { |
|
| 127 | + return false; |
|
| 128 | + } |
|
| 125 | 129 | |
| 126 | - if ( $this->id != 0 ) { |
|
| 127 | - return false; |
|
| 128 | - } |
|
| 130 | + $defaults = array( |
|
| 131 | + 'customer_id' => 0, |
|
| 132 | + 'frequency' => '', |
|
| 133 | + 'period' => '', |
|
| 134 | + 'initial_amount' => '', |
|
| 135 | + 'recurring_amount' => '', |
|
| 136 | + 'bill_times' => 0, |
|
| 137 | + 'parent_payment_id' => 0, |
|
| 138 | + 'product_id' => 0, |
|
| 139 | + 'created' => '', |
|
| 140 | + 'expiration' => '', |
|
| 141 | + 'status' => '', |
|
| 142 | + 'profile_id' => '', |
|
| 143 | + ); |
|
| 129 | 144 | |
| 130 | - $defaults = array( |
|
| 131 | - 'customer_id' => 0, |
|
| 132 | - 'frequency' => '', |
|
| 133 | - 'period' => '', |
|
| 134 | - 'initial_amount' => '', |
|
| 135 | - 'recurring_amount' => '', |
|
| 136 | - 'bill_times' => 0, |
|
| 137 | - 'parent_payment_id' => 0, |
|
| 138 | - 'product_id' => 0, |
|
| 139 | - 'created' => '', |
|
| 140 | - 'expiration' => '', |
|
| 141 | - 'status' => '', |
|
| 142 | - 'profile_id' => '', |
|
| 143 | - ); |
|
| 145 | + $args = wp_parse_args( $data, $defaults ); |
|
| 144 | 146 | |
| 145 | - $args = wp_parse_args( $data, $defaults ); |
|
| 147 | + if( $args['expiration'] && strtotime( 'NOW', current_time( 'timestamp' ) ) > strtotime( $args['expiration'], current_time( 'timestamp' ) ) ) { |
|
| 146 | 148 | |
| 147 | - if( $args['expiration'] && strtotime( 'NOW', current_time( 'timestamp' ) ) > strtotime( $args['expiration'], current_time( 'timestamp' ) ) ) { |
|
| 149 | + if( 'active' == $args['status'] || 'trialling' == $args['status'] ) { |
|
| 148 | 150 | |
| 149 | - if( 'active' == $args['status'] || 'trialling' == $args['status'] ) { |
|
| 151 | + // Force an active subscription to expired if expiration date is in the past |
|
| 152 | + $args['status'] = 'expired'; |
|
| 150 | 153 | |
| 151 | - // Force an active subscription to expired if expiration date is in the past |
|
| 152 | - $args['status'] = 'expired'; |
|
| 154 | + } |
|
| 155 | + } |
|
| 153 | 156 | |
| 154 | - } |
|
| 155 | - } |
|
| 157 | + do_action( 'wpinv_subscription_pre_create', $args ); |
|
| 156 | 158 | |
| 157 | - do_action( 'wpinv_subscription_pre_create', $args ); |
|
| 159 | + $id = $this->subs_db->insert( $args, 'subscription' ); |
|
| 158 | 160 | |
| 159 | - $id = $this->subs_db->insert( $args, 'subscription' ); |
|
| 161 | + do_action( 'wpinv_subscription_post_create', $id, $args ); |
|
| 160 | 162 | |
| 161 | - do_action( 'wpinv_subscription_post_create', $id, $args ); |
|
| 163 | + return $this->setup_subscription( $id ); |
|
| 162 | 164 | |
| 163 | - return $this->setup_subscription( $id ); |
|
| 165 | + } |
|
| 164 | 166 | |
| 165 | - } |
|
| 167 | + /** |
|
| 168 | + * Updates a subscription |
|
| 169 | + * |
|
| 170 | + * @since 1.0.0 |
|
| 171 | + * @param array $args Array of fields to update |
|
| 172 | + * @return bool |
|
| 173 | + */ |
|
| 174 | + public function update( $args = array() ) { |
|
| 175 | + |
|
| 176 | + $ret = $this->subs_db->update( $this->id, $args ); |
|
| 166 | 177 | |
| 167 | - /** |
|
| 168 | - * Updates a subscription |
|
| 169 | - * |
|
| 170 | - * @since 1.0.0 |
|
| 171 | - * @param array $args Array of fields to update |
|
| 172 | - * @return bool |
|
| 173 | - */ |
|
| 174 | - public function update( $args = array() ) { |
|
| 178 | + do_action( 'wpinv_recurring_update_subscription', $this->id, $args, $this ); |
|
| 175 | 179 | |
| 176 | - $ret = $this->subs_db->update( $this->id, $args ); |
|
| 180 | + return $ret; |
|
| 181 | + |
|
| 182 | + } |
|
| 177 | 183 | |
| 178 | - do_action( 'wpinv_recurring_update_subscription', $this->id, $args, $this ); |
|
| 184 | + /** |
|
| 185 | + * Delete the subscription |
|
| 186 | + * |
|
| 187 | + * @since 1.0.0 |
|
| 188 | + * @return bool |
|
| 189 | + */ |
|
| 190 | + public function delete() { |
|
| 191 | + return $this->subs_db->delete( $this->id ); |
|
| 192 | + } |
|
| 179 | 193 | |
| 180 | - return $ret; |
|
| 194 | + /** |
|
| 195 | + * Retrieves the parent payment ID |
|
| 196 | + * |
|
| 197 | + * @since 1.0.0 |
|
| 198 | + * @return int |
|
| 199 | + */ |
|
| 200 | + public function get_original_payment_id() { |
|
| 181 | 201 | |
| 182 | - } |
|
| 202 | + return $this->parent_payment_id; |
|
| 183 | 203 | |
| 184 | - /** |
|
| 185 | - * Delete the subscription |
|
| 186 | - * |
|
| 187 | - * @since 1.0.0 |
|
| 188 | - * @return bool |
|
| 189 | - */ |
|
| 190 | - public function delete() { |
|
| 191 | - return $this->subs_db->delete( $this->id ); |
|
| 192 | - } |
|
| 204 | + } |
|
| 193 | 205 | |
| 194 | - /** |
|
| 195 | - * Retrieves the parent payment ID |
|
| 196 | - * |
|
| 197 | - * @since 1.0.0 |
|
| 198 | - * @return int |
|
| 199 | - */ |
|
| 200 | - public function get_original_payment_id() { |
|
| 206 | + /** |
|
| 207 | + * Retrieve renewal payments for a subscription |
|
| 208 | + * |
|
| 209 | + * @since 1.0.0 |
|
| 210 | + * @return array |
|
| 211 | + */ |
|
| 212 | + public function get_child_payments() { |
|
| 201 | 213 | |
| 202 | - return $this->parent_payment_id; |
|
| 214 | + $payments = get_posts( array( |
|
| 215 | + 'post_parent' => (int) $this->parent_payment_id, |
|
| 216 | + 'posts_per_page' => '999', |
|
| 217 | + 'post_status' => array( 'publish', 'wpi-processing', 'wpi-renewal' ), |
|
| 218 | + 'post_type' => 'wpi_invoice' |
|
| 219 | + ) ); |
|
| 203 | 220 | |
| 204 | - } |
|
| 221 | + return $payments; |
|
| 205 | 222 | |
| 206 | - /** |
|
| 207 | - * Retrieve renewal payments for a subscription |
|
| 208 | - * |
|
| 209 | - * @since 1.0.0 |
|
| 210 | - * @return array |
|
| 211 | - */ |
|
| 212 | - public function get_child_payments() { |
|
| 213 | - |
|
| 214 | - $payments = get_posts( array( |
|
| 215 | - 'post_parent' => (int) $this->parent_payment_id, |
|
| 216 | - 'posts_per_page' => '999', |
|
| 217 | - 'post_status' => array( 'publish', 'wpi-processing', 'wpi-renewal' ), |
|
| 218 | - 'post_type' => 'wpi_invoice' |
|
| 219 | - ) ); |
|
| 220 | - |
|
| 221 | - return $payments; |
|
| 222 | - |
|
| 223 | - } |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - /** |
|
| 226 | - * Counts the number of payments made to the subscription |
|
| 227 | - * |
|
| 228 | - * @since 2.4 |
|
| 229 | - * @return int |
|
| 230 | - */ |
|
| 231 | - public function get_total_payments() { |
|
| 225 | + /** |
|
| 226 | + * Counts the number of payments made to the subscription |
|
| 227 | + * |
|
| 228 | + * @since 2.4 |
|
| 229 | + * @return int |
|
| 230 | + */ |
|
| 231 | + public function get_total_payments() { |
|
| 232 | 232 | |
| 233 | - if('pending' != $this->status){ |
|
| 233 | + if('pending' != $this->status){ |
|
| 234 | 234 | return count( $this->get_child_payments() ) + 1; |
| 235 | 235 | } else { |
| 236 | 236 | return count($this->get_child_payments()); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - } |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | - /** |
|
| 242 | - * Returns the number of times the subscription has been billed |
|
| 243 | - * |
|
| 244 | - * @since 2.6 |
|
| 245 | - * @return int |
|
| 246 | - */ |
|
| 247 | - public function get_times_billed() { |
|
| 241 | + /** |
|
| 242 | + * Returns the number of times the subscription has been billed |
|
| 243 | + * |
|
| 244 | + * @since 2.6 |
|
| 245 | + * @return int |
|
| 246 | + */ |
|
| 247 | + public function get_times_billed() { |
|
| 248 | 248 | |
| 249 | - $times_billed = $this->get_total_payments(); |
|
| 249 | + $times_billed = $this->get_total_payments(); |
|
| 250 | 250 | |
| 251 | - if( ! empty( $this->trial_period ) ) { |
|
| 251 | + if( ! empty( $this->trial_period ) ) { |
|
| 252 | 252 | if('pending' != $this->status){ |
| 253 | 253 | $times_billed = 0; |
| 254 | 254 | } else { |
| 255 | 255 | $times_billed -= 1; |
| 256 | 256 | } |
| 257 | - } |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - return $times_billed; |
|
| 259 | + return $times_billed; |
|
| 260 | 260 | |
| 261 | - } |
|
| 261 | + } |
|
| 262 | 262 | |
| 263 | 263 | /** |
| 264 | 264 | * Records a new payment on the subscription |
@@ -294,203 +294,203 @@ discard block |
||
| 294 | 294 | return $invoice->ID; |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - /** |
|
| 298 | - * Retrieves the transaction ID from the subscription |
|
| 299 | - * |
|
| 300 | - * @since 1.0.0 |
|
| 301 | - * @return bool |
|
| 302 | - */ |
|
| 303 | - public function get_transaction_id() { |
|
| 297 | + /** |
|
| 298 | + * Retrieves the transaction ID from the subscription |
|
| 299 | + * |
|
| 300 | + * @since 1.0.0 |
|
| 301 | + * @return bool |
|
| 302 | + */ |
|
| 303 | + public function get_transaction_id() { |
|
| 304 | 304 | |
| 305 | - if( empty( $this->transaction_id ) ) { |
|
| 305 | + if( empty( $this->transaction_id ) ) { |
|
| 306 | 306 | |
| 307 | - $txn_id = wpinv_get_payment_transaction_id( $this->parent_payment_id ); |
|
| 307 | + $txn_id = wpinv_get_payment_transaction_id( $this->parent_payment_id ); |
|
| 308 | 308 | |
| 309 | - if( ! empty( $txn_id ) && (int) $this->parent_payment_id !== (int) $txn_id ) { |
|
| 310 | - $this->set_transaction_id( $txn_id ); |
|
| 311 | - } |
|
| 309 | + if( ! empty( $txn_id ) && (int) $this->parent_payment_id !== (int) $txn_id ) { |
|
| 310 | + $this->set_transaction_id( $txn_id ); |
|
| 311 | + } |
|
| 312 | 312 | |
| 313 | - } |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | - return $this->transaction_id; |
|
| 315 | + return $this->transaction_id; |
|
| 316 | 316 | |
| 317 | - } |
|
| 317 | + } |
|
| 318 | 318 | |
| 319 | - /** |
|
| 320 | - * Stores the transaction ID for the subscription purchase |
|
| 321 | - * |
|
| 322 | - * @since 1.0.0.4 |
|
| 323 | - * @return bool |
|
| 324 | - */ |
|
| 325 | - public function set_transaction_id( $txn_id = '' ) { |
|
| 326 | - $this->update( array( 'transaction_id' => $txn_id ) ); |
|
| 327 | - $this->transaction_id = $txn_id; |
|
| 328 | - } |
|
| 319 | + /** |
|
| 320 | + * Stores the transaction ID for the subscription purchase |
|
| 321 | + * |
|
| 322 | + * @since 1.0.0.4 |
|
| 323 | + * @return bool |
|
| 324 | + */ |
|
| 325 | + public function set_transaction_id( $txn_id = '' ) { |
|
| 326 | + $this->update( array( 'transaction_id' => $txn_id ) ); |
|
| 327 | + $this->transaction_id = $txn_id; |
|
| 328 | + } |
|
| 329 | 329 | |
| 330 | - /** |
|
| 331 | - * Renews a subscription |
|
| 332 | - * |
|
| 333 | - * @since 1.0.0 |
|
| 334 | - * @return bool |
|
| 335 | - */ |
|
| 336 | - public function renew() { |
|
| 330 | + /** |
|
| 331 | + * Renews a subscription |
|
| 332 | + * |
|
| 333 | + * @since 1.0.0 |
|
| 334 | + * @return bool |
|
| 335 | + */ |
|
| 336 | + public function renew() { |
|
| 337 | 337 | |
| 338 | - $expires = $this->get_expiration_time(); |
|
| 338 | + $expires = $this->get_expiration_time(); |
|
| 339 | 339 | |
| 340 | 340 | |
| 341 | - // Determine what date to use as the start for the new expiration calculation |
|
| 342 | - if( $expires > current_time( 'timestamp' ) && $this->is_active() ) { |
|
| 341 | + // Determine what date to use as the start for the new expiration calculation |
|
| 342 | + if( $expires > current_time( 'timestamp' ) && $this->is_active() ) { |
|
| 343 | 343 | |
| 344 | - $base_date = $expires; |
|
| 344 | + $base_date = $expires; |
|
| 345 | 345 | |
| 346 | - } else { |
|
| 346 | + } else { |
|
| 347 | 347 | |
| 348 | - $base_date = current_time( 'timestamp' ); |
|
| 348 | + $base_date = current_time( 'timestamp' ); |
|
| 349 | 349 | |
| 350 | - } |
|
| 350 | + } |
|
| 351 | 351 | |
| 352 | - $last_day = cal_days_in_month( CAL_GREGORIAN, date( 'n', $base_date ), date( 'Y', $base_date ) ); |
|
| 352 | + $last_day = cal_days_in_month( CAL_GREGORIAN, date( 'n', $base_date ), date( 'Y', $base_date ) ); |
|
| 353 | 353 | |
| 354 | 354 | |
| 355 | - $frequency = isset($this->frequency) ? $this->frequency : 1; |
|
| 356 | - $expiration = date( 'Y-m-d H:i:s', strtotime( '+' . $frequency . ' ' . $this->period . ' 23:59:59', $base_date ) ); |
|
| 355 | + $frequency = isset($this->frequency) ? $this->frequency : 1; |
|
| 356 | + $expiration = date( 'Y-m-d H:i:s', strtotime( '+' . $frequency . ' ' . $this->period . ' 23:59:59', $base_date ) ); |
|
| 357 | 357 | |
| 358 | - if( date( 'j', $base_date ) == $last_day && 'day' != $this->period ) { |
|
| 359 | - $expiration = date( 'Y-m-d H:i:s', strtotime( $expiration . ' +2 days' ) ); |
|
| 360 | - } |
|
| 358 | + if( date( 'j', $base_date ) == $last_day && 'day' != $this->period ) { |
|
| 359 | + $expiration = date( 'Y-m-d H:i:s', strtotime( $expiration . ' +2 days' ) ); |
|
| 360 | + } |
|
| 361 | 361 | |
| 362 | - $expiration = apply_filters( 'wpinv_subscription_renewal_expiration', $expiration, $this->id, $this ); |
|
| 362 | + $expiration = apply_filters( 'wpinv_subscription_renewal_expiration', $expiration, $this->id, $this ); |
|
| 363 | 363 | |
| 364 | - do_action( 'wpinv_subscription_pre_renew', $this->id, $expiration, $this ); |
|
| 364 | + do_action( 'wpinv_subscription_pre_renew', $this->id, $expiration, $this ); |
|
| 365 | 365 | |
| 366 | - $this->status = 'active'; |
|
| 367 | - $times_billed = $this->get_times_billed(); |
|
| 366 | + $this->status = 'active'; |
|
| 367 | + $times_billed = $this->get_times_billed(); |
|
| 368 | 368 | |
| 369 | - // Complete subscription if applicable |
|
| 370 | - if ( $this->bill_times > 0 && $times_billed >= $this->bill_times ) { |
|
| 371 | - $this->complete(); |
|
| 372 | - $this->status = 'completed'; |
|
| 373 | - } |
|
| 369 | + // Complete subscription if applicable |
|
| 370 | + if ( $this->bill_times > 0 && $times_billed >= $this->bill_times ) { |
|
| 371 | + $this->complete(); |
|
| 372 | + $this->status = 'completed'; |
|
| 373 | + } |
|
| 374 | 374 | |
| 375 | - $args = array( |
|
| 376 | - 'expiration' => $expiration, |
|
| 377 | - 'status' => $this->status, |
|
| 378 | - ); |
|
| 375 | + $args = array( |
|
| 376 | + 'expiration' => $expiration, |
|
| 377 | + 'status' => $this->status, |
|
| 378 | + ); |
|
| 379 | 379 | |
| 380 | 380 | $this->subs_db->update( $this->id, $args ); |
| 381 | 381 | |
| 382 | - do_action( 'wpinv_subscription_post_renew', $this->id, $expiration, $this ); |
|
| 383 | - do_action( 'wpinv_recurring_set_subscription_status', $this->id, $this->status, $this ); |
|
| 382 | + do_action( 'wpinv_subscription_post_renew', $this->id, $expiration, $this ); |
|
| 383 | + do_action( 'wpinv_recurring_set_subscription_status', $this->id, $this->status, $this ); |
|
| 384 | 384 | |
| 385 | - } |
|
| 385 | + } |
|
| 386 | 386 | |
| 387 | - /** |
|
| 388 | - * Marks a subscription as completed |
|
| 389 | - * |
|
| 390 | - * Subscription is completed when the number of payments matches the billing_times field |
|
| 391 | - * |
|
| 392 | - * @since 1.0.0 |
|
| 393 | - * @return void |
|
| 394 | - */ |
|
| 395 | - public function complete() { |
|
| 387 | + /** |
|
| 388 | + * Marks a subscription as completed |
|
| 389 | + * |
|
| 390 | + * Subscription is completed when the number of payments matches the billing_times field |
|
| 391 | + * |
|
| 392 | + * @since 1.0.0 |
|
| 393 | + * @return void |
|
| 394 | + */ |
|
| 395 | + public function complete() { |
|
| 396 | 396 | |
| 397 | - // Only mark a subscription as complete if it's not already cancelled. |
|
| 398 | - if ( 'cancelled' === $this->status ) { |
|
| 399 | - return; |
|
| 400 | - } |
|
| 397 | + // Only mark a subscription as complete if it's not already cancelled. |
|
| 398 | + if ( 'cancelled' === $this->status ) { |
|
| 399 | + return; |
|
| 400 | + } |
|
| 401 | 401 | |
| 402 | - $args = array( |
|
| 403 | - 'status' => 'completed' |
|
| 404 | - ); |
|
| 402 | + $args = array( |
|
| 403 | + 'status' => 'completed' |
|
| 404 | + ); |
|
| 405 | 405 | |
| 406 | - if( $this->subs_db->update( $this->id, $args ) ) { |
|
| 406 | + if( $this->subs_db->update( $this->id, $args ) ) { |
|
| 407 | 407 | |
| 408 | - $this->status = 'completed'; |
|
| 408 | + $this->status = 'completed'; |
|
| 409 | 409 | |
| 410 | - do_action( 'wpinv_subscription_completed', $this->id, $this ); |
|
| 410 | + do_action( 'wpinv_subscription_completed', $this->id, $this ); |
|
| 411 | 411 | |
| 412 | - } |
|
| 412 | + } |
|
| 413 | 413 | |
| 414 | - } |
|
| 414 | + } |
|
| 415 | 415 | |
| 416 | - /** |
|
| 417 | - * Marks a subscription as expired |
|
| 418 | - * |
|
| 419 | - * Subscription is completed when the billing times is reached |
|
| 420 | - * |
|
| 421 | - * @since 1.0.0 |
|
| 422 | - * @param $check_expiration bool True if expiration date should be checked with merchant processor before expiring |
|
| 423 | - * @return void |
|
| 424 | - */ |
|
| 425 | - public function expire( $check_expiration = false ) { |
|
| 416 | + /** |
|
| 417 | + * Marks a subscription as expired |
|
| 418 | + * |
|
| 419 | + * Subscription is completed when the billing times is reached |
|
| 420 | + * |
|
| 421 | + * @since 1.0.0 |
|
| 422 | + * @param $check_expiration bool True if expiration date should be checked with merchant processor before expiring |
|
| 423 | + * @return void |
|
| 424 | + */ |
|
| 425 | + public function expire( $check_expiration = false ) { |
|
| 426 | 426 | |
| 427 | - $expiration = $this->expiration; |
|
| 427 | + $expiration = $this->expiration; |
|
| 428 | 428 | |
| 429 | - if( $check_expiration && $this->check_expiration() ) { |
|
| 429 | + if( $check_expiration && $this->check_expiration() ) { |
|
| 430 | 430 | |
| 431 | - // check_expiration() updates $this->expiration so compare to $expiration above |
|
| 431 | + // check_expiration() updates $this->expiration so compare to $expiration above |
|
| 432 | 432 | |
| 433 | - if( $expiration < $this->get_expiration() && current_time( 'timestamp' ) < $this->get_expiration_time() ) { |
|
| 433 | + if( $expiration < $this->get_expiration() && current_time( 'timestamp' ) < $this->get_expiration_time() ) { |
|
| 434 | 434 | |
| 435 | - return false; // Do not mark as expired since real expiration date is in the future |
|
| 436 | - } |
|
| 435 | + return false; // Do not mark as expired since real expiration date is in the future |
|
| 436 | + } |
|
| 437 | 437 | |
| 438 | - } |
|
| 438 | + } |
|
| 439 | 439 | |
| 440 | - $args = array( |
|
| 441 | - 'status' => 'expired' |
|
| 442 | - ); |
|
| 440 | + $args = array( |
|
| 441 | + 'status' => 'expired' |
|
| 442 | + ); |
|
| 443 | 443 | |
| 444 | - if( $this->subs_db->update( $this->id, $args ) ) { |
|
| 444 | + if( $this->subs_db->update( $this->id, $args ) ) { |
|
| 445 | 445 | |
| 446 | - $this->status = 'expired'; |
|
| 446 | + $this->status = 'expired'; |
|
| 447 | 447 | |
| 448 | - do_action( 'wpinv_subscription_expired', $this->id, $this ); |
|
| 448 | + do_action( 'wpinv_subscription_expired', $this->id, $this ); |
|
| 449 | 449 | |
| 450 | - } |
|
| 450 | + } |
|
| 451 | 451 | |
| 452 | - } |
|
| 452 | + } |
|
| 453 | 453 | |
| 454 | - /** |
|
| 455 | - * Marks a subscription as failing |
|
| 456 | - * |
|
| 457 | - * @since 2.4.2 |
|
| 458 | - * @return void |
|
| 459 | - */ |
|
| 460 | - public function failing() { |
|
| 454 | + /** |
|
| 455 | + * Marks a subscription as failing |
|
| 456 | + * |
|
| 457 | + * @since 2.4.2 |
|
| 458 | + * @return void |
|
| 459 | + */ |
|
| 460 | + public function failing() { |
|
| 461 | 461 | |
| 462 | - $args = array( |
|
| 463 | - 'status' => 'failing' |
|
| 464 | - ); |
|
| 462 | + $args = array( |
|
| 463 | + 'status' => 'failing' |
|
| 464 | + ); |
|
| 465 | 465 | |
| 466 | - if( $this->subs_db->update( $this->id, $args ) ) { |
|
| 466 | + if( $this->subs_db->update( $this->id, $args ) ) { |
|
| 467 | 467 | |
| 468 | - $this->status = 'failing'; |
|
| 468 | + $this->status = 'failing'; |
|
| 469 | 469 | |
| 470 | - do_action( 'wpinv_subscription_failing', $this->id, $this ); |
|
| 470 | + do_action( 'wpinv_subscription_failing', $this->id, $this ); |
|
| 471 | 471 | |
| 472 | 472 | |
| 473 | - } |
|
| 473 | + } |
|
| 474 | 474 | |
| 475 | - } |
|
| 475 | + } |
|
| 476 | 476 | |
| 477 | - /** |
|
| 478 | - * Marks a subscription as cancelled |
|
| 479 | - * |
|
| 480 | - * @since 1.0.0 |
|
| 481 | - * @return void |
|
| 482 | - */ |
|
| 483 | - public function cancel() { |
|
| 477 | + /** |
|
| 478 | + * Marks a subscription as cancelled |
|
| 479 | + * |
|
| 480 | + * @since 1.0.0 |
|
| 481 | + * @return void |
|
| 482 | + */ |
|
| 483 | + public function cancel() { |
|
| 484 | 484 | |
| 485 | - if( 'cancelled' === $this->status ) { |
|
| 486 | - return; // Already cancelled |
|
| 487 | - } |
|
| 485 | + if( 'cancelled' === $this->status ) { |
|
| 486 | + return; // Already cancelled |
|
| 487 | + } |
|
| 488 | 488 | |
| 489 | - $args = array( |
|
| 490 | - 'status' => 'cancelled' |
|
| 491 | - ); |
|
| 489 | + $args = array( |
|
| 490 | + 'status' => 'cancelled' |
|
| 491 | + ); |
|
| 492 | 492 | |
| 493 | - if( $this->subs_db->update( $this->id, $args ) ) { |
|
| 493 | + if( $this->subs_db->update( $this->id, $args ) ) { |
|
| 494 | 494 | |
| 495 | 495 | if( is_user_logged_in() ) { |
| 496 | 496 | |
@@ -506,31 +506,31 @@ discard block |
||
| 506 | 506 | $note = sprintf( __( 'Subscription for Invoice #%d cancelled by %s', 'invoicing' ), $this->parent_payment_id, $user ); |
| 507 | 507 | wpinv_insert_payment_note( $this->parent_payment_id, $note, '', '', true ); |
| 508 | 508 | |
| 509 | - $this->status = 'cancelled'; |
|
| 509 | + $this->status = 'cancelled'; |
|
| 510 | 510 | |
| 511 | - do_action( 'wpinv_subscription_cancelled', $this->id, $this ); |
|
| 511 | + do_action( 'wpinv_subscription_cancelled', $this->id, $this ); |
|
| 512 | 512 | |
| 513 | 513 | |
| 514 | - } |
|
| 514 | + } |
|
| 515 | 515 | |
| 516 | - } |
|
| 516 | + } |
|
| 517 | 517 | |
| 518 | - /** |
|
| 519 | - * Determines if subscription can be cancelled |
|
| 520 | - * |
|
| 521 | - * This method is filtered by payment gateways in order to return true on subscriptions |
|
| 522 | - * that can be cancelled with a profile ID through the merchant processor |
|
| 523 | - * |
|
| 524 | - * @since 1.0.0 |
|
| 525 | - * @return bool |
|
| 526 | - */ |
|
| 527 | - public function can_cancel() { |
|
| 518 | + /** |
|
| 519 | + * Determines if subscription can be cancelled |
|
| 520 | + * |
|
| 521 | + * This method is filtered by payment gateways in order to return true on subscriptions |
|
| 522 | + * that can be cancelled with a profile ID through the merchant processor |
|
| 523 | + * |
|
| 524 | + * @since 1.0.0 |
|
| 525 | + * @return bool |
|
| 526 | + */ |
|
| 527 | + public function can_cancel() { |
|
| 528 | 528 | $ret = false; |
| 529 | - if( $this->gateway === 'manual' || in_array( $this->status, $this->get_cancellable_statuses() ) ) { |
|
| 529 | + if( $this->gateway === 'manual' || in_array( $this->status, $this->get_cancellable_statuses() ) ) { |
|
| 530 | 530 | $ret = true; |
| 531 | 531 | } |
| 532 | - return apply_filters( 'wpinv_subscription_can_cancel', $ret, $this ); |
|
| 533 | - } |
|
| 532 | + return apply_filters( 'wpinv_subscription_can_cancel', $ret, $this ); |
|
| 533 | + } |
|
| 534 | 534 | |
| 535 | 535 | /** |
| 536 | 536 | * Returns an array of subscription statuses that can be cancelled |
@@ -543,197 +543,197 @@ discard block |
||
| 543 | 543 | return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) ); |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - /** |
|
| 547 | - * Retrieves the URL to cancel subscription |
|
| 548 | - * |
|
| 549 | - * @since 1.0.0 |
|
| 550 | - * @return string |
|
| 551 | - */ |
|
| 552 | - public function get_cancel_url() { |
|
| 546 | + /** |
|
| 547 | + * Retrieves the URL to cancel subscription |
|
| 548 | + * |
|
| 549 | + * @since 1.0.0 |
|
| 550 | + * @return string |
|
| 551 | + */ |
|
| 552 | + public function get_cancel_url() { |
|
| 553 | + |
|
| 554 | + $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'cancel_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-cancel' ); |
|
| 553 | 555 | |
| 554 | - $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'cancel_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-cancel' ); |
|
| 556 | + return apply_filters( 'wpinv_subscription_cancel_url', $url, $this ); |
|
| 557 | + } |
|
| 558 | + |
|
| 559 | + /** |
|
| 560 | + * Determines if subscription can be manually renewed |
|
| 561 | + * |
|
| 562 | + * This method is filtered by payment gateways in order to return true on subscriptions |
|
| 563 | + * that can be renewed manually |
|
| 564 | + * |
|
| 565 | + * @since 2.5 |
|
| 566 | + * @return bool |
|
| 567 | + */ |
|
| 568 | + public function can_renew() { |
|
| 569 | + |
|
| 570 | + return apply_filters( 'wpinv_subscription_can_renew', true, $this ); |
|
| 571 | + } |
|
| 572 | + |
|
| 573 | + /** |
|
| 574 | + * Retrieves the URL to renew a subscription |
|
| 575 | + * |
|
| 576 | + * @since 2.5 |
|
| 577 | + * @return string |
|
| 578 | + */ |
|
| 579 | + public function get_renew_url() { |
|
| 580 | + |
|
| 581 | + $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'renew_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-renew' ); |
|
| 582 | + |
|
| 583 | + return apply_filters( 'wpinv_subscription_renew_url', $url, $this ); |
|
| 584 | + } |
|
| 585 | + |
|
| 586 | + /** |
|
| 587 | + * Determines if subscription can have their payment method updated |
|
| 588 | + * |
|
| 589 | + * @since 1.0.0 |
|
| 590 | + * @return bool |
|
| 591 | + */ |
|
| 592 | + public function can_update() { |
|
| 593 | + return apply_filters( 'wpinv_subscription_can_update', false, $this ); |
|
| 594 | + } |
|
| 595 | + |
|
| 596 | + /** |
|
| 597 | + * Retrieves the URL to update subscription |
|
| 598 | + * |
|
| 599 | + * @since 1.0.0 |
|
| 600 | + * @return void |
|
| 601 | + */ |
|
| 602 | + public function get_update_url() { |
|
| 555 | 603 | |
| 556 | - return apply_filters( 'wpinv_subscription_cancel_url', $url, $this ); |
|
| 557 | - } |
|
| 604 | + $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->id ) ); |
|
| 605 | + |
|
| 606 | + return apply_filters( 'wpinv_subscription_update_url', $url, $this ); |
|
| 607 | + } |
|
| 608 | + |
|
| 609 | + /** |
|
| 610 | + * Determines if subscription is active |
|
| 611 | + * |
|
| 612 | + * @since 1.0.0 |
|
| 613 | + * @return void |
|
| 614 | + */ |
|
| 615 | + public function is_active() { |
|
| 616 | + |
|
| 617 | + $ret = false; |
|
| 618 | + |
|
| 619 | + if( ! $this->is_expired() && ( $this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling' ) ) { |
|
| 620 | + $ret = true; |
|
| 621 | + } |
|
| 622 | + |
|
| 623 | + return apply_filters( 'wpinv_subscription_is_active', $ret, $this->id, $this ); |
|
| 624 | + |
|
| 625 | + } |
|
| 626 | + |
|
| 627 | + /** |
|
| 628 | + * Determines if subscription is expired |
|
| 629 | + * |
|
| 630 | + * @since 1.0.0 |
|
| 631 | + * @return void |
|
| 632 | + */ |
|
| 633 | + public function is_expired() { |
|
| 634 | + |
|
| 635 | + $ret = false; |
|
| 636 | + |
|
| 637 | + if ( $this->status == 'expired' ) { |
|
| 638 | + |
|
| 639 | + $ret = true; |
|
| 640 | + |
|
| 641 | + } elseif( 'active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling' ) { |
|
| 642 | + |
|
| 643 | + $ret = false; |
|
| 644 | + $expiration = $this->get_expiration_time(); |
|
| 645 | + |
|
| 646 | + if( $expiration && strtotime( 'NOW', current_time( 'timestamp' ) ) > $expiration ) { |
|
| 647 | + $ret = true; |
|
| 648 | + |
|
| 649 | + if ( 'active' === $this->status || $this->status == 'trialling' ) { |
|
| 650 | + $this->expire(); |
|
| 651 | + } |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + } |
|
| 558 | 655 | |
| 559 | - /** |
|
| 560 | - * Determines if subscription can be manually renewed |
|
| 561 | - * |
|
| 562 | - * This method is filtered by payment gateways in order to return true on subscriptions |
|
| 563 | - * that can be renewed manually |
|
| 564 | - * |
|
| 565 | - * @since 2.5 |
|
| 566 | - * @return bool |
|
| 567 | - */ |
|
| 568 | - public function can_renew() { |
|
| 656 | + return apply_filters( 'wpinv_subscription_is_expired', $ret, $this->id, $this ); |
|
| 569 | 657 | |
| 570 | - return apply_filters( 'wpinv_subscription_can_renew', true, $this ); |
|
| 571 | - } |
|
| 572 | - |
|
| 573 | - /** |
|
| 574 | - * Retrieves the URL to renew a subscription |
|
| 575 | - * |
|
| 576 | - * @since 2.5 |
|
| 577 | - * @return string |
|
| 578 | - */ |
|
| 579 | - public function get_renew_url() { |
|
| 580 | - |
|
| 581 | - $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'renew_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-renew' ); |
|
| 582 | - |
|
| 583 | - return apply_filters( 'wpinv_subscription_renew_url', $url, $this ); |
|
| 584 | - } |
|
| 585 | - |
|
| 586 | - /** |
|
| 587 | - * Determines if subscription can have their payment method updated |
|
| 588 | - * |
|
| 589 | - * @since 1.0.0 |
|
| 590 | - * @return bool |
|
| 591 | - */ |
|
| 592 | - public function can_update() { |
|
| 593 | - return apply_filters( 'wpinv_subscription_can_update', false, $this ); |
|
| 594 | - } |
|
| 595 | - |
|
| 596 | - /** |
|
| 597 | - * Retrieves the URL to update subscription |
|
| 598 | - * |
|
| 599 | - * @since 1.0.0 |
|
| 600 | - * @return void |
|
| 601 | - */ |
|
| 602 | - public function get_update_url() { |
|
| 603 | - |
|
| 604 | - $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->id ) ); |
|
| 605 | - |
|
| 606 | - return apply_filters( 'wpinv_subscription_update_url', $url, $this ); |
|
| 607 | - } |
|
| 608 | - |
|
| 609 | - /** |
|
| 610 | - * Determines if subscription is active |
|
| 611 | - * |
|
| 612 | - * @since 1.0.0 |
|
| 613 | - * @return void |
|
| 614 | - */ |
|
| 615 | - public function is_active() { |
|
| 616 | - |
|
| 617 | - $ret = false; |
|
| 618 | - |
|
| 619 | - if( ! $this->is_expired() && ( $this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling' ) ) { |
|
| 620 | - $ret = true; |
|
| 621 | - } |
|
| 622 | - |
|
| 623 | - return apply_filters( 'wpinv_subscription_is_active', $ret, $this->id, $this ); |
|
| 624 | - |
|
| 625 | - } |
|
| 626 | - |
|
| 627 | - /** |
|
| 628 | - * Determines if subscription is expired |
|
| 629 | - * |
|
| 630 | - * @since 1.0.0 |
|
| 631 | - * @return void |
|
| 632 | - */ |
|
| 633 | - public function is_expired() { |
|
| 634 | - |
|
| 635 | - $ret = false; |
|
| 636 | - |
|
| 637 | - if ( $this->status == 'expired' ) { |
|
| 638 | - |
|
| 639 | - $ret = true; |
|
| 640 | - |
|
| 641 | - } elseif( 'active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling' ) { |
|
| 642 | - |
|
| 643 | - $ret = false; |
|
| 644 | - $expiration = $this->get_expiration_time(); |
|
| 645 | - |
|
| 646 | - if( $expiration && strtotime( 'NOW', current_time( 'timestamp' ) ) > $expiration ) { |
|
| 647 | - $ret = true; |
|
| 648 | - |
|
| 649 | - if ( 'active' === $this->status || $this->status == 'trialling' ) { |
|
| 650 | - $this->expire(); |
|
| 651 | - } |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - } |
|
| 655 | - |
|
| 656 | - return apply_filters( 'wpinv_subscription_is_expired', $ret, $this->id, $this ); |
|
| 657 | - |
|
| 658 | - } |
|
| 659 | - |
|
| 660 | - /** |
|
| 661 | - * Retrieves the expiration date |
|
| 662 | - * |
|
| 663 | - * @since 1.0.0 |
|
| 664 | - * @return string |
|
| 665 | - */ |
|
| 666 | - public function get_expiration() { |
|
| 667 | - return $this->expiration; |
|
| 668 | - } |
|
| 669 | - |
|
| 670 | - /** |
|
| 671 | - * Retrieves the expiration date in a timestamp |
|
| 672 | - * |
|
| 673 | - * @since 1.0.0 |
|
| 674 | - * @return int |
|
| 675 | - */ |
|
| 676 | - public function get_expiration_time() { |
|
| 677 | - return strtotime( $this->expiration, current_time( 'timestamp' ) ); |
|
| 678 | - } |
|
| 679 | - |
|
| 680 | - /** |
|
| 681 | - * Retrieves the subscription status |
|
| 682 | - * |
|
| 683 | - * @since 1.0.0 |
|
| 684 | - * @return int |
|
| 685 | - */ |
|
| 686 | - public function get_status() { |
|
| 687 | - |
|
| 688 | - // Monitor for page load delays on pages with large subscription lists (IE: Subscriptions table in admin) |
|
| 689 | - $this->is_expired(); |
|
| 690 | - return $this->status; |
|
| 691 | - } |
|
| 692 | - |
|
| 693 | - /** |
|
| 694 | - * Retrieves the subscription status label |
|
| 695 | - * |
|
| 696 | - * @since 1.0.0 |
|
| 697 | - * @return int |
|
| 698 | - */ |
|
| 699 | - public function get_status_label() { |
|
| 700 | - |
|
| 701 | - switch( $this->get_status() ) { |
|
| 702 | - case 'active' : |
|
| 703 | - $status = __( 'Active', 'invoicing' ); |
|
| 704 | - break; |
|
| 705 | - |
|
| 706 | - case 'cancelled' : |
|
| 707 | - $status = __( 'Cancelled', 'invoicing' ); |
|
| 708 | - break; |
|
| 709 | - |
|
| 710 | - case 'expired' : |
|
| 711 | - $status = __( 'Expired', 'invoicing' ); |
|
| 712 | - break; |
|
| 713 | - |
|
| 714 | - case 'pending' : |
|
| 715 | - $status = __( 'Pending', 'invoicing' ); |
|
| 716 | - break; |
|
| 717 | - |
|
| 718 | - case 'failing' : |
|
| 719 | - $status = __( 'Failing', 'invoicing' ); |
|
| 720 | - break; |
|
| 721 | - |
|
| 722 | - case 'trialling' : |
|
| 723 | - $status = __( 'Trialling', 'invoicing' ); |
|
| 724 | - break; |
|
| 725 | - |
|
| 726 | - case 'completed' : |
|
| 727 | - $status = __( 'Completed', 'invoicing' ); |
|
| 728 | - break; |
|
| 729 | - |
|
| 730 | - default: |
|
| 731 | - $status = ucfirst( $this->get_status() ); |
|
| 732 | - break; |
|
| 733 | - } |
|
| 734 | - |
|
| 735 | - return $status; |
|
| 736 | - } |
|
| 658 | + } |
|
| 659 | + |
|
| 660 | + /** |
|
| 661 | + * Retrieves the expiration date |
|
| 662 | + * |
|
| 663 | + * @since 1.0.0 |
|
| 664 | + * @return string |
|
| 665 | + */ |
|
| 666 | + public function get_expiration() { |
|
| 667 | + return $this->expiration; |
|
| 668 | + } |
|
| 669 | + |
|
| 670 | + /** |
|
| 671 | + * Retrieves the expiration date in a timestamp |
|
| 672 | + * |
|
| 673 | + * @since 1.0.0 |
|
| 674 | + * @return int |
|
| 675 | + */ |
|
| 676 | + public function get_expiration_time() { |
|
| 677 | + return strtotime( $this->expiration, current_time( 'timestamp' ) ); |
|
| 678 | + } |
|
| 679 | + |
|
| 680 | + /** |
|
| 681 | + * Retrieves the subscription status |
|
| 682 | + * |
|
| 683 | + * @since 1.0.0 |
|
| 684 | + * @return int |
|
| 685 | + */ |
|
| 686 | + public function get_status() { |
|
| 687 | + |
|
| 688 | + // Monitor for page load delays on pages with large subscription lists (IE: Subscriptions table in admin) |
|
| 689 | + $this->is_expired(); |
|
| 690 | + return $this->status; |
|
| 691 | + } |
|
| 692 | + |
|
| 693 | + /** |
|
| 694 | + * Retrieves the subscription status label |
|
| 695 | + * |
|
| 696 | + * @since 1.0.0 |
|
| 697 | + * @return int |
|
| 698 | + */ |
|
| 699 | + public function get_status_label() { |
|
| 700 | + |
|
| 701 | + switch( $this->get_status() ) { |
|
| 702 | + case 'active' : |
|
| 703 | + $status = __( 'Active', 'invoicing' ); |
|
| 704 | + break; |
|
| 705 | + |
|
| 706 | + case 'cancelled' : |
|
| 707 | + $status = __( 'Cancelled', 'invoicing' ); |
|
| 708 | + break; |
|
| 709 | + |
|
| 710 | + case 'expired' : |
|
| 711 | + $status = __( 'Expired', 'invoicing' ); |
|
| 712 | + break; |
|
| 713 | + |
|
| 714 | + case 'pending' : |
|
| 715 | + $status = __( 'Pending', 'invoicing' ); |
|
| 716 | + break; |
|
| 717 | + |
|
| 718 | + case 'failing' : |
|
| 719 | + $status = __( 'Failing', 'invoicing' ); |
|
| 720 | + break; |
|
| 721 | + |
|
| 722 | + case 'trialling' : |
|
| 723 | + $status = __( 'Trialling', 'invoicing' ); |
|
| 724 | + break; |
|
| 725 | + |
|
| 726 | + case 'completed' : |
|
| 727 | + $status = __( 'Completed', 'invoicing' ); |
|
| 728 | + break; |
|
| 729 | + |
|
| 730 | + default: |
|
| 731 | + $status = ucfirst( $this->get_status() ); |
|
| 732 | + break; |
|
| 733 | + } |
|
| 734 | + |
|
| 735 | + return $status; |
|
| 736 | + } |
|
| 737 | 737 | |
| 738 | 738 | /** |
| 739 | 739 | * Retrieves the subscription status label |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly |
| 4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | +if (!defined('ABSPATH')) { |
|
| 5 | 5 | exit; |
| 6 | 6 | } |
| 7 | 7 | |
@@ -38,15 +38,15 @@ discard block |
||
| 38 | 38 | * @since 1.0.0 |
| 39 | 39 | * @return void |
| 40 | 40 | */ |
| 41 | - function __construct( $_id_or_object = 0, $_by_profile_id = false ) { |
|
| 41 | + function __construct($_id_or_object = 0, $_by_profile_id = false) { |
|
| 42 | 42 | |
| 43 | 43 | $this->subs_db = new WPInv_Subscriptions_DB; |
| 44 | 44 | |
| 45 | - if( $_by_profile_id ) { |
|
| 45 | + if ($_by_profile_id) { |
|
| 46 | 46 | |
| 47 | - $_sub = $this->subs_db->get_by( 'profile_id', $_id_or_object ); |
|
| 47 | + $_sub = $this->subs_db->get_by('profile_id', $_id_or_object); |
|
| 48 | 48 | |
| 49 | - if( empty( $_sub ) ) { |
|
| 49 | + if (empty($_sub)) { |
|
| 50 | 50 | return false; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - return $this->setup_subscription( $_id_or_object ); |
|
| 57 | + return $this->setup_subscription($_id_or_object); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -63,34 +63,34 @@ discard block |
||
| 63 | 63 | * @since 1.0.0 |
| 64 | 64 | * @return void |
| 65 | 65 | */ |
| 66 | - private function setup_subscription( $id_or_object = 0 ) { |
|
| 66 | + private function setup_subscription($id_or_object = 0) { |
|
| 67 | 67 | |
| 68 | - if( empty( $id_or_object ) ) { |
|
| 68 | + if (empty($id_or_object)) { |
|
| 69 | 69 | return false; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if( is_numeric( $id_or_object ) ) { |
|
| 72 | + if (is_numeric($id_or_object)) { |
|
| 73 | 73 | |
| 74 | - $sub = $this->subs_db->get( $id_or_object ); |
|
| 74 | + $sub = $this->subs_db->get($id_or_object); |
|
| 75 | 75 | |
| 76 | - } elseif( is_object( $id_or_object ) ) { |
|
| 76 | + } elseif (is_object($id_or_object)) { |
|
| 77 | 77 | |
| 78 | 78 | $sub = $id_or_object; |
| 79 | 79 | |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if( empty( $sub ) ) { |
|
| 82 | + if (empty($sub)) { |
|
| 83 | 83 | return false; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - foreach( $sub as $key => $value ) { |
|
| 86 | + foreach ($sub as $key => $value) { |
|
| 87 | 87 | $this->$key = $value; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $this->customer = get_userdata( $this->customer_id ); |
|
| 91 | - $this->gateway = wpinv_get_payment_gateway( $this->parent_payment_id ); |
|
| 90 | + $this->customer = get_userdata($this->customer_id); |
|
| 91 | + $this->gateway = wpinv_get_payment_gateway($this->parent_payment_id); |
|
| 92 | 92 | |
| 93 | - do_action( 'wpinv_recurring_setup_subscription', $this ); |
|
| 93 | + do_action('wpinv_recurring_setup_subscription', $this); |
|
| 94 | 94 | |
| 95 | 95 | return $this; |
| 96 | 96 | } |
@@ -100,15 +100,15 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @since 1.0.0 |
| 102 | 102 | */ |
| 103 | - public function __get( $key ) { |
|
| 103 | + public function __get($key) { |
|
| 104 | 104 | |
| 105 | - if( method_exists( $this, 'get_' . $key ) ) { |
|
| 105 | + if (method_exists($this, 'get_' . $key)) { |
|
| 106 | 106 | |
| 107 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
| 107 | + return call_user_func(array($this, 'get_' . $key)); |
|
| 108 | 108 | |
| 109 | 109 | } else { |
| 110 | 110 | |
| 111 | - return new WP_Error( 'wpinv-subscription-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) ); |
|
| 111 | + return new WP_Error('wpinv-subscription-invalid-property', sprintf(__('Can\'t get property %s', 'invoicing'), $key)); |
|
| 112 | 112 | |
| 113 | 113 | } |
| 114 | 114 | |
@@ -121,9 +121,9 @@ discard block |
||
| 121 | 121 | * @param array $data Array of attributes for a subscription |
| 122 | 122 | * @return mixed false if data isn't passed and class not instantiated for creation |
| 123 | 123 | */ |
| 124 | - public function create( $data = array() ) { |
|
| 124 | + public function create($data = array()) { |
|
| 125 | 125 | |
| 126 | - if ( $this->id != 0 ) { |
|
| 126 | + if ($this->id != 0) { |
|
| 127 | 127 | return false; |
| 128 | 128 | } |
| 129 | 129 | |
@@ -142,11 +142,11 @@ discard block |
||
| 142 | 142 | 'profile_id' => '', |
| 143 | 143 | ); |
| 144 | 144 | |
| 145 | - $args = wp_parse_args( $data, $defaults ); |
|
| 145 | + $args = wp_parse_args($data, $defaults); |
|
| 146 | 146 | |
| 147 | - if( $args['expiration'] && strtotime( 'NOW', current_time( 'timestamp' ) ) > strtotime( $args['expiration'], current_time( 'timestamp' ) ) ) { |
|
| 147 | + if ($args['expiration'] && strtotime('NOW', current_time('timestamp')) > strtotime($args['expiration'], current_time('timestamp'))) { |
|
| 148 | 148 | |
| 149 | - if( 'active' == $args['status'] || 'trialling' == $args['status'] ) { |
|
| 149 | + if ('active' == $args['status'] || 'trialling' == $args['status']) { |
|
| 150 | 150 | |
| 151 | 151 | // Force an active subscription to expired if expiration date is in the past |
| 152 | 152 | $args['status'] = 'expired'; |
@@ -154,13 +154,13 @@ discard block |
||
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - do_action( 'wpinv_subscription_pre_create', $args ); |
|
| 157 | + do_action('wpinv_subscription_pre_create', $args); |
|
| 158 | 158 | |
| 159 | - $id = $this->subs_db->insert( $args, 'subscription' ); |
|
| 159 | + $id = $this->subs_db->insert($args, 'subscription'); |
|
| 160 | 160 | |
| 161 | - do_action( 'wpinv_subscription_post_create', $id, $args ); |
|
| 161 | + do_action('wpinv_subscription_post_create', $id, $args); |
|
| 162 | 162 | |
| 163 | - return $this->setup_subscription( $id ); |
|
| 163 | + return $this->setup_subscription($id); |
|
| 164 | 164 | |
| 165 | 165 | } |
| 166 | 166 | |
@@ -171,11 +171,11 @@ discard block |
||
| 171 | 171 | * @param array $args Array of fields to update |
| 172 | 172 | * @return bool |
| 173 | 173 | */ |
| 174 | - public function update( $args = array() ) { |
|
| 174 | + public function update($args = array()) { |
|
| 175 | 175 | |
| 176 | - $ret = $this->subs_db->update( $this->id, $args ); |
|
| 176 | + $ret = $this->subs_db->update($this->id, $args); |
|
| 177 | 177 | |
| 178 | - do_action( 'wpinv_recurring_update_subscription', $this->id, $args, $this ); |
|
| 178 | + do_action('wpinv_recurring_update_subscription', $this->id, $args, $this); |
|
| 179 | 179 | |
| 180 | 180 | return $ret; |
| 181 | 181 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * @return bool |
| 189 | 189 | */ |
| 190 | 190 | public function delete() { |
| 191 | - return $this->subs_db->delete( $this->id ); |
|
| 191 | + return $this->subs_db->delete($this->id); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** |
@@ -211,12 +211,12 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | public function get_child_payments() { |
| 213 | 213 | |
| 214 | - $payments = get_posts( array( |
|
| 215 | - 'post_parent' => (int) $this->parent_payment_id, |
|
| 214 | + $payments = get_posts(array( |
|
| 215 | + 'post_parent' => (int)$this->parent_payment_id, |
|
| 216 | 216 | 'posts_per_page' => '999', |
| 217 | - 'post_status' => array( 'publish', 'wpi-processing', 'wpi-renewal' ), |
|
| 217 | + 'post_status' => array('publish', 'wpi-processing', 'wpi-renewal'), |
|
| 218 | 218 | 'post_type' => 'wpi_invoice' |
| 219 | - ) ); |
|
| 219 | + )); |
|
| 220 | 220 | |
| 221 | 221 | return $payments; |
| 222 | 222 | |
@@ -230,8 +230,8 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | public function get_total_payments() { |
| 232 | 232 | |
| 233 | - if('pending' != $this->status){ |
|
| 234 | - return count( $this->get_child_payments() ) + 1; |
|
| 233 | + if ('pending' != $this->status) { |
|
| 234 | + return count($this->get_child_payments()) + 1; |
|
| 235 | 235 | } else { |
| 236 | 236 | return count($this->get_child_payments()); |
| 237 | 237 | } |
@@ -248,8 +248,8 @@ discard block |
||
| 248 | 248 | |
| 249 | 249 | $times_billed = $this->get_total_payments(); |
| 250 | 250 | |
| 251 | - if( ! empty( $this->trial_period ) ) { |
|
| 252 | - if('pending' != $this->status){ |
|
| 251 | + if (!empty($this->trial_period)) { |
|
| 252 | + if ('pending' != $this->status) { |
|
| 253 | 253 | $times_billed = 0; |
| 254 | 254 | } else { |
| 255 | 255 | $times_billed -= 1; |
@@ -267,29 +267,29 @@ discard block |
||
| 267 | 267 | * @param array $args Array of values for the payment, including amount and transaction ID |
| 268 | 268 | * @return bool |
| 269 | 269 | */ |
| 270 | - public function add_payment( $args = array() ) { |
|
| 270 | + public function add_payment($args = array()) { |
|
| 271 | 271 | |
| 272 | - $args = wp_parse_args( $args, array( |
|
| 272 | + $args = wp_parse_args($args, array( |
|
| 273 | 273 | 'amount' => '', |
| 274 | 274 | 'transaction_id' => '', |
| 275 | 275 | 'gateway' => '' |
| 276 | - ) ); |
|
| 276 | + )); |
|
| 277 | 277 | |
| 278 | - if ( $this->payment_exists( $args['transaction_id'] ) ) { |
|
| 278 | + if ($this->payment_exists($args['transaction_id'])) { |
|
| 279 | 279 | return false; |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - if(!$this->parent_payment_id){ |
|
| 282 | + if (!$this->parent_payment_id) { |
|
| 283 | 283 | return false; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | $invoice = new WPInv_Invoice($this->parent_payment_id); |
| 287 | - $invoice->ID = $invoice->title = $invoice->number =''; |
|
| 287 | + $invoice->ID = $invoice->title = $invoice->number = ''; |
|
| 288 | 288 | $invoice->parent_invoice = $this->parent_payment_id; |
| 289 | 289 | $invoice->save(); |
| 290 | 290 | |
| 291 | - do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this ); |
|
| 292 | - do_action( 'wpinv_recurring_record_payment', $invoice->ID, $this->parent_payment_id, $args['amount'], $args['transaction_id'] ); |
|
| 291 | + do_action('wpinv_recurring_add_subscription_payment', $invoice, $this); |
|
| 292 | + do_action('wpinv_recurring_record_payment', $invoice->ID, $this->parent_payment_id, $args['amount'], $args['transaction_id']); |
|
| 293 | 293 | |
| 294 | 294 | return $invoice->ID; |
| 295 | 295 | } |
@@ -302,12 +302,12 @@ discard block |
||
| 302 | 302 | */ |
| 303 | 303 | public function get_transaction_id() { |
| 304 | 304 | |
| 305 | - if( empty( $this->transaction_id ) ) { |
|
| 305 | + if (empty($this->transaction_id)) { |
|
| 306 | 306 | |
| 307 | - $txn_id = wpinv_get_payment_transaction_id( $this->parent_payment_id ); |
|
| 307 | + $txn_id = wpinv_get_payment_transaction_id($this->parent_payment_id); |
|
| 308 | 308 | |
| 309 | - if( ! empty( $txn_id ) && (int) $this->parent_payment_id !== (int) $txn_id ) { |
|
| 310 | - $this->set_transaction_id( $txn_id ); |
|
| 309 | + if (!empty($txn_id) && (int)$this->parent_payment_id !== (int)$txn_id) { |
|
| 310 | + $this->set_transaction_id($txn_id); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | } |
@@ -322,8 +322,8 @@ discard block |
||
| 322 | 322 | * @since 1.0.0.4 |
| 323 | 323 | * @return bool |
| 324 | 324 | */ |
| 325 | - public function set_transaction_id( $txn_id = '' ) { |
|
| 326 | - $this->update( array( 'transaction_id' => $txn_id ) ); |
|
| 325 | + public function set_transaction_id($txn_id = '') { |
|
| 326 | + $this->update(array('transaction_id' => $txn_id)); |
|
| 327 | 327 | $this->transaction_id = $txn_id; |
| 328 | 328 | } |
| 329 | 329 | |
@@ -339,35 +339,35 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | |
| 341 | 341 | // Determine what date to use as the start for the new expiration calculation |
| 342 | - if( $expires > current_time( 'timestamp' ) && $this->is_active() ) { |
|
| 342 | + if ($expires > current_time('timestamp') && $this->is_active()) { |
|
| 343 | 343 | |
| 344 | - $base_date = $expires; |
|
| 344 | + $base_date = $expires; |
|
| 345 | 345 | |
| 346 | 346 | } else { |
| 347 | 347 | |
| 348 | - $base_date = current_time( 'timestamp' ); |
|
| 348 | + $base_date = current_time('timestamp'); |
|
| 349 | 349 | |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - $last_day = cal_days_in_month( CAL_GREGORIAN, date( 'n', $base_date ), date( 'Y', $base_date ) ); |
|
| 352 | + $last_day = cal_days_in_month(CAL_GREGORIAN, date('n', $base_date), date('Y', $base_date)); |
|
| 353 | 353 | |
| 354 | 354 | |
| 355 | 355 | $frequency = isset($this->frequency) ? $this->frequency : 1; |
| 356 | - $expiration = date( 'Y-m-d H:i:s', strtotime( '+' . $frequency . ' ' . $this->period . ' 23:59:59', $base_date ) ); |
|
| 356 | + $expiration = date('Y-m-d H:i:s', strtotime('+' . $frequency . ' ' . $this->period . ' 23:59:59', $base_date)); |
|
| 357 | 357 | |
| 358 | - if( date( 'j', $base_date ) == $last_day && 'day' != $this->period ) { |
|
| 359 | - $expiration = date( 'Y-m-d H:i:s', strtotime( $expiration . ' +2 days' ) ); |
|
| 358 | + if (date('j', $base_date) == $last_day && 'day' != $this->period) { |
|
| 359 | + $expiration = date('Y-m-d H:i:s', strtotime($expiration . ' +2 days')); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - $expiration = apply_filters( 'wpinv_subscription_renewal_expiration', $expiration, $this->id, $this ); |
|
| 362 | + $expiration = apply_filters('wpinv_subscription_renewal_expiration', $expiration, $this->id, $this); |
|
| 363 | 363 | |
| 364 | - do_action( 'wpinv_subscription_pre_renew', $this->id, $expiration, $this ); |
|
| 364 | + do_action('wpinv_subscription_pre_renew', $this->id, $expiration, $this); |
|
| 365 | 365 | |
| 366 | 366 | $this->status = 'active'; |
| 367 | 367 | $times_billed = $this->get_times_billed(); |
| 368 | 368 | |
| 369 | 369 | // Complete subscription if applicable |
| 370 | - if ( $this->bill_times > 0 && $times_billed >= $this->bill_times ) { |
|
| 370 | + if ($this->bill_times > 0 && $times_billed >= $this->bill_times) { |
|
| 371 | 371 | $this->complete(); |
| 372 | 372 | $this->status = 'completed'; |
| 373 | 373 | } |
@@ -377,10 +377,10 @@ discard block |
||
| 377 | 377 | 'status' => $this->status, |
| 378 | 378 | ); |
| 379 | 379 | |
| 380 | - $this->subs_db->update( $this->id, $args ); |
|
| 380 | + $this->subs_db->update($this->id, $args); |
|
| 381 | 381 | |
| 382 | - do_action( 'wpinv_subscription_post_renew', $this->id, $expiration, $this ); |
|
| 383 | - do_action( 'wpinv_recurring_set_subscription_status', $this->id, $this->status, $this ); |
|
| 382 | + do_action('wpinv_subscription_post_renew', $this->id, $expiration, $this); |
|
| 383 | + do_action('wpinv_recurring_set_subscription_status', $this->id, $this->status, $this); |
|
| 384 | 384 | |
| 385 | 385 | } |
| 386 | 386 | |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | public function complete() { |
| 396 | 396 | |
| 397 | 397 | // Only mark a subscription as complete if it's not already cancelled. |
| 398 | - if ( 'cancelled' === $this->status ) { |
|
| 398 | + if ('cancelled' === $this->status) { |
|
| 399 | 399 | return; |
| 400 | 400 | } |
| 401 | 401 | |
@@ -403,11 +403,11 @@ discard block |
||
| 403 | 403 | 'status' => 'completed' |
| 404 | 404 | ); |
| 405 | 405 | |
| 406 | - if( $this->subs_db->update( $this->id, $args ) ) { |
|
| 406 | + if ($this->subs_db->update($this->id, $args)) { |
|
| 407 | 407 | |
| 408 | 408 | $this->status = 'completed'; |
| 409 | 409 | |
| 410 | - do_action( 'wpinv_subscription_completed', $this->id, $this ); |
|
| 410 | + do_action('wpinv_subscription_completed', $this->id, $this); |
|
| 411 | 411 | |
| 412 | 412 | } |
| 413 | 413 | |
@@ -422,15 +422,15 @@ discard block |
||
| 422 | 422 | * @param $check_expiration bool True if expiration date should be checked with merchant processor before expiring |
| 423 | 423 | * @return void |
| 424 | 424 | */ |
| 425 | - public function expire( $check_expiration = false ) { |
|
| 425 | + public function expire($check_expiration = false) { |
|
| 426 | 426 | |
| 427 | 427 | $expiration = $this->expiration; |
| 428 | 428 | |
| 429 | - if( $check_expiration && $this->check_expiration() ) { |
|
| 429 | + if ($check_expiration && $this->check_expiration()) { |
|
| 430 | 430 | |
| 431 | 431 | // check_expiration() updates $this->expiration so compare to $expiration above |
| 432 | 432 | |
| 433 | - if( $expiration < $this->get_expiration() && current_time( 'timestamp' ) < $this->get_expiration_time() ) { |
|
| 433 | + if ($expiration < $this->get_expiration() && current_time('timestamp') < $this->get_expiration_time()) { |
|
| 434 | 434 | |
| 435 | 435 | return false; // Do not mark as expired since real expiration date is in the future |
| 436 | 436 | } |
@@ -441,11 +441,11 @@ discard block |
||
| 441 | 441 | 'status' => 'expired' |
| 442 | 442 | ); |
| 443 | 443 | |
| 444 | - if( $this->subs_db->update( $this->id, $args ) ) { |
|
| 444 | + if ($this->subs_db->update($this->id, $args)) { |
|
| 445 | 445 | |
| 446 | 446 | $this->status = 'expired'; |
| 447 | 447 | |
| 448 | - do_action( 'wpinv_subscription_expired', $this->id, $this ); |
|
| 448 | + do_action('wpinv_subscription_expired', $this->id, $this); |
|
| 449 | 449 | |
| 450 | 450 | } |
| 451 | 451 | |
@@ -463,11 +463,11 @@ discard block |
||
| 463 | 463 | 'status' => 'failing' |
| 464 | 464 | ); |
| 465 | 465 | |
| 466 | - if( $this->subs_db->update( $this->id, $args ) ) { |
|
| 466 | + if ($this->subs_db->update($this->id, $args)) { |
|
| 467 | 467 | |
| 468 | 468 | $this->status = 'failing'; |
| 469 | 469 | |
| 470 | - do_action( 'wpinv_subscription_failing', $this->id, $this ); |
|
| 470 | + do_action('wpinv_subscription_failing', $this->id, $this); |
|
| 471 | 471 | |
| 472 | 472 | |
| 473 | 473 | } |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | */ |
| 483 | 483 | public function cancel() { |
| 484 | 484 | |
| 485 | - if( 'cancelled' === $this->status ) { |
|
| 485 | + if ('cancelled' === $this->status) { |
|
| 486 | 486 | return; // Already cancelled |
| 487 | 487 | } |
| 488 | 488 | |
@@ -490,25 +490,25 @@ discard block |
||
| 490 | 490 | 'status' => 'cancelled' |
| 491 | 491 | ); |
| 492 | 492 | |
| 493 | - if( $this->subs_db->update( $this->id, $args ) ) { |
|
| 493 | + if ($this->subs_db->update($this->id, $args)) { |
|
| 494 | 494 | |
| 495 | - if( is_user_logged_in() ) { |
|
| 495 | + if (is_user_logged_in()) { |
|
| 496 | 496 | |
| 497 | - $userdata = get_userdata( get_current_user_id() ); |
|
| 497 | + $userdata = get_userdata(get_current_user_id()); |
|
| 498 | 498 | $user = $userdata->display_name; |
| 499 | 499 | |
| 500 | 500 | } else { |
| 501 | 501 | |
| 502 | - $user = __( 'gateway', 'invoicing' ); |
|
| 502 | + $user = __('gateway', 'invoicing'); |
|
| 503 | 503 | |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | - $note = sprintf( __( 'Subscription for Invoice #%d cancelled by %s', 'invoicing' ), $this->parent_payment_id, $user ); |
|
| 507 | - wpinv_insert_payment_note( $this->parent_payment_id, $note, '', '', true ); |
|
| 506 | + $note = sprintf(__('Subscription for Invoice #%d cancelled by %s', 'invoicing'), $this->parent_payment_id, $user); |
|
| 507 | + wpinv_insert_payment_note($this->parent_payment_id, $note, '', '', true); |
|
| 508 | 508 | |
| 509 | 509 | $this->status = 'cancelled'; |
| 510 | 510 | |
| 511 | - do_action( 'wpinv_subscription_cancelled', $this->id, $this ); |
|
| 511 | + do_action('wpinv_subscription_cancelled', $this->id, $this); |
|
| 512 | 512 | |
| 513 | 513 | |
| 514 | 514 | } |
@@ -526,10 +526,10 @@ discard block |
||
| 526 | 526 | */ |
| 527 | 527 | public function can_cancel() { |
| 528 | 528 | $ret = false; |
| 529 | - if( $this->gateway === 'manual' || in_array( $this->status, $this->get_cancellable_statuses() ) ) { |
|
| 529 | + if ($this->gateway === 'manual' || in_array($this->status, $this->get_cancellable_statuses())) { |
|
| 530 | 530 | $ret = true; |
| 531 | 531 | } |
| 532 | - return apply_filters( 'wpinv_subscription_can_cancel', $ret, $this ); |
|
| 532 | + return apply_filters('wpinv_subscription_can_cancel', $ret, $this); |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | /** |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | * @return array |
| 541 | 541 | */ |
| 542 | 542 | public function get_cancellable_statuses() { |
| 543 | - return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) ); |
|
| 543 | + return apply_filters('wpinv_recurring_cancellable_statuses', array('active', 'trialling', 'failing')); |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | /** |
@@ -551,9 +551,9 @@ discard block |
||
| 551 | 551 | */ |
| 552 | 552 | public function get_cancel_url() { |
| 553 | 553 | |
| 554 | - $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'cancel_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-cancel' ); |
|
| 554 | + $url = wp_nonce_url(add_query_arg(array('wpinv_action' => 'cancel_subscription', 'sub_id' => $this->id)), 'wpinv-recurring-cancel'); |
|
| 555 | 555 | |
| 556 | - return apply_filters( 'wpinv_subscription_cancel_url', $url, $this ); |
|
| 556 | + return apply_filters('wpinv_subscription_cancel_url', $url, $this); |
|
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | /** |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | */ |
| 568 | 568 | public function can_renew() { |
| 569 | 569 | |
| 570 | - return apply_filters( 'wpinv_subscription_can_renew', true, $this ); |
|
| 570 | + return apply_filters('wpinv_subscription_can_renew', true, $this); |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | /** |
@@ -578,9 +578,9 @@ discard block |
||
| 578 | 578 | */ |
| 579 | 579 | public function get_renew_url() { |
| 580 | 580 | |
| 581 | - $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'renew_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-renew' ); |
|
| 581 | + $url = wp_nonce_url(add_query_arg(array('wpinv_action' => 'renew_subscription', 'sub_id' => $this->id)), 'wpinv-recurring-renew'); |
|
| 582 | 582 | |
| 583 | - return apply_filters( 'wpinv_subscription_renew_url', $url, $this ); |
|
| 583 | + return apply_filters('wpinv_subscription_renew_url', $url, $this); |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | /** |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | * @return bool |
| 591 | 591 | */ |
| 592 | 592 | public function can_update() { |
| 593 | - return apply_filters( 'wpinv_subscription_can_update', false, $this ); |
|
| 593 | + return apply_filters('wpinv_subscription_can_update', false, $this); |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | /** |
@@ -601,9 +601,9 @@ discard block |
||
| 601 | 601 | */ |
| 602 | 602 | public function get_update_url() { |
| 603 | 603 | |
| 604 | - $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->id ) ); |
|
| 604 | + $url = add_query_arg(array('action' => 'update', 'subscription_id' => $this->id)); |
|
| 605 | 605 | |
| 606 | - return apply_filters( 'wpinv_subscription_update_url', $url, $this ); |
|
| 606 | + return apply_filters('wpinv_subscription_update_url', $url, $this); |
|
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | /** |
@@ -616,11 +616,11 @@ discard block |
||
| 616 | 616 | |
| 617 | 617 | $ret = false; |
| 618 | 618 | |
| 619 | - if( ! $this->is_expired() && ( $this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling' ) ) { |
|
| 619 | + if (!$this->is_expired() && ($this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling')) { |
|
| 620 | 620 | $ret = true; |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | - return apply_filters( 'wpinv_subscription_is_active', $ret, $this->id, $this ); |
|
| 623 | + return apply_filters('wpinv_subscription_is_active', $ret, $this->id, $this); |
|
| 624 | 624 | |
| 625 | 625 | } |
| 626 | 626 | |
@@ -634,26 +634,26 @@ discard block |
||
| 634 | 634 | |
| 635 | 635 | $ret = false; |
| 636 | 636 | |
| 637 | - if ( $this->status == 'expired' ) { |
|
| 637 | + if ($this->status == 'expired') { |
|
| 638 | 638 | |
| 639 | 639 | $ret = true; |
| 640 | 640 | |
| 641 | - } elseif( 'active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling' ) { |
|
| 641 | + } elseif ('active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling') { |
|
| 642 | 642 | |
| 643 | 643 | $ret = false; |
| 644 | 644 | $expiration = $this->get_expiration_time(); |
| 645 | 645 | |
| 646 | - if( $expiration && strtotime( 'NOW', current_time( 'timestamp' ) ) > $expiration ) { |
|
| 646 | + if ($expiration && strtotime('NOW', current_time('timestamp')) > $expiration) { |
|
| 647 | 647 | $ret = true; |
| 648 | 648 | |
| 649 | - if ( 'active' === $this->status || $this->status == 'trialling' ) { |
|
| 649 | + if ('active' === $this->status || $this->status == 'trialling') { |
|
| 650 | 650 | $this->expire(); |
| 651 | 651 | } |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | - return apply_filters( 'wpinv_subscription_is_expired', $ret, $this->id, $this ); |
|
| 656 | + return apply_filters('wpinv_subscription_is_expired', $ret, $this->id, $this); |
|
| 657 | 657 | |
| 658 | 658 | } |
| 659 | 659 | |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | * @return int |
| 675 | 675 | */ |
| 676 | 676 | public function get_expiration_time() { |
| 677 | - return strtotime( $this->expiration, current_time( 'timestamp' ) ); |
|
| 677 | + return strtotime($this->expiration, current_time('timestamp')); |
|
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | /** |
@@ -698,37 +698,37 @@ discard block |
||
| 698 | 698 | */ |
| 699 | 699 | public function get_status_label() { |
| 700 | 700 | |
| 701 | - switch( $this->get_status() ) { |
|
| 701 | + switch ($this->get_status()) { |
|
| 702 | 702 | case 'active' : |
| 703 | - $status = __( 'Active', 'invoicing' ); |
|
| 703 | + $status = __('Active', 'invoicing'); |
|
| 704 | 704 | break; |
| 705 | 705 | |
| 706 | 706 | case 'cancelled' : |
| 707 | - $status = __( 'Cancelled', 'invoicing' ); |
|
| 707 | + $status = __('Cancelled', 'invoicing'); |
|
| 708 | 708 | break; |
| 709 | 709 | |
| 710 | 710 | case 'expired' : |
| 711 | - $status = __( 'Expired', 'invoicing' ); |
|
| 711 | + $status = __('Expired', 'invoicing'); |
|
| 712 | 712 | break; |
| 713 | 713 | |
| 714 | 714 | case 'pending' : |
| 715 | - $status = __( 'Pending', 'invoicing' ); |
|
| 715 | + $status = __('Pending', 'invoicing'); |
|
| 716 | 716 | break; |
| 717 | 717 | |
| 718 | 718 | case 'failing' : |
| 719 | - $status = __( 'Failing', 'invoicing' ); |
|
| 719 | + $status = __('Failing', 'invoicing'); |
|
| 720 | 720 | break; |
| 721 | 721 | |
| 722 | 722 | case 'trialling' : |
| 723 | - $status = __( 'Trialling', 'invoicing' ); |
|
| 723 | + $status = __('Trialling', 'invoicing'); |
|
| 724 | 724 | break; |
| 725 | 725 | |
| 726 | 726 | case 'completed' : |
| 727 | - $status = __( 'Completed', 'invoicing' ); |
|
| 727 | + $status = __('Completed', 'invoicing'); |
|
| 728 | 728 | break; |
| 729 | 729 | |
| 730 | 730 | default: |
| 731 | - $status = ucfirst( $this->get_status() ); |
|
| 731 | + $status = ucfirst($this->get_status()); |
|
| 732 | 732 | break; |
| 733 | 733 | } |
| 734 | 734 | |
@@ -743,51 +743,51 @@ discard block |
||
| 743 | 743 | */ |
| 744 | 744 | public function get_status_label_html() { |
| 745 | 745 | |
| 746 | - switch( $get_status = $this->get_status() ) { |
|
| 746 | + switch ($get_status = $this->get_status()) { |
|
| 747 | 747 | case 'active' : |
| 748 | - $status = __( 'Active', 'invoicing' ); |
|
| 748 | + $status = __('Active', 'invoicing'); |
|
| 749 | 749 | $class = 'label-info'; |
| 750 | 750 | break; |
| 751 | 751 | |
| 752 | 752 | case 'cancelled' : |
| 753 | - $status = __( 'Cancelled', 'invoicing' ); |
|
| 753 | + $status = __('Cancelled', 'invoicing'); |
|
| 754 | 754 | $class = 'label-danger'; |
| 755 | 755 | break; |
| 756 | 756 | |
| 757 | 757 | case 'expired' : |
| 758 | - $status = __( 'Expired', 'invoicing' ); |
|
| 758 | + $status = __('Expired', 'invoicing'); |
|
| 759 | 759 | $class = 'label-default'; |
| 760 | 760 | break; |
| 761 | 761 | |
| 762 | 762 | case 'pending' : |
| 763 | - $status = __( 'Pending', 'invoicing' ); |
|
| 763 | + $status = __('Pending', 'invoicing'); |
|
| 764 | 764 | $class = 'label-primary'; |
| 765 | 765 | break; |
| 766 | 766 | |
| 767 | 767 | case 'failing' : |
| 768 | - $status = __( 'Failing', 'invoicing' ); |
|
| 768 | + $status = __('Failing', 'invoicing'); |
|
| 769 | 769 | $class = 'label-danger'; |
| 770 | 770 | break; |
| 771 | 771 | |
| 772 | 772 | case 'trialling' : |
| 773 | - $status = __( 'Trialling', 'invoicing' ); |
|
| 773 | + $status = __('Trialling', 'invoicing'); |
|
| 774 | 774 | $class = 'label-info'; |
| 775 | 775 | break; |
| 776 | 776 | |
| 777 | 777 | case 'completed' : |
| 778 | - $status = __( 'Completed', 'invoicing' ); |
|
| 778 | + $status = __('Completed', 'invoicing'); |
|
| 779 | 779 | $class = 'label-success'; |
| 780 | 780 | break; |
| 781 | 781 | |
| 782 | 782 | default: |
| 783 | - $status = ucfirst( $this->get_status() ); |
|
| 783 | + $status = ucfirst($this->get_status()); |
|
| 784 | 784 | $class = 'label-default'; |
| 785 | 785 | break; |
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | $label = '<span class="sub-status label label-sub-' . $get_status . ' ' . $class . '">' . $status . '</span>'; |
| 789 | 789 | |
| 790 | - return apply_filters( 'wpinv_subscription_status_label_html', $label, $get_status, $status ); |
|
| 790 | + return apply_filters('wpinv_subscription_status_label_html', $label, $get_status, $status); |
|
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | /** |
@@ -797,18 +797,18 @@ discard block |
||
| 797 | 797 | * @param string $txn_id The transaction ID from the merchant processor |
| 798 | 798 | * @return bool |
| 799 | 799 | */ |
| 800 | - public function payment_exists( $txn_id = '' ) { |
|
| 800 | + public function payment_exists($txn_id = '') { |
|
| 801 | 801 | global $wpdb; |
| 802 | 802 | |
| 803 | - if ( empty( $txn_id ) ) { |
|
| 803 | + if (empty($txn_id)) { |
|
| 804 | 804 | return false; |
| 805 | 805 | } |
| 806 | 806 | |
| 807 | - $txn_id = esc_sql( $txn_id ); |
|
| 807 | + $txn_id = esc_sql($txn_id); |
|
| 808 | 808 | |
| 809 | - $purchase = $wpdb->get_var( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = '{$txn_id}' LIMIT 1" ); |
|
| 809 | + $purchase = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = '{$txn_id}' LIMIT 1"); |
|
| 810 | 810 | |
| 811 | - if ( $purchase != null ) { |
|
| 811 | + if ($purchase != null) { |
|
| 812 | 812 | return true; |
| 813 | 813 | } |
| 814 | 814 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; // Exit if accessed directly |
| 4 | 4 | } |
| 5 | 5 | |
@@ -16,11 +16,11 @@ discard block |
||
| 16 | 16 | 'wpinv_subscriptions' => __CLASS__ . '::subscriptions', |
| 17 | 17 | ); |
| 18 | 18 | |
| 19 | - foreach ( $shortcodes as $shortcode => $function ) { |
|
| 20 | - add_shortcode( apply_filters( "{$shortcode}_shortcode_tag", $shortcode ), $function ); |
|
| 19 | + foreach ($shortcodes as $shortcode => $function) { |
|
| 20 | + add_shortcode(apply_filters("{$shortcode}_shortcode_tag", $shortcode), $function); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - add_shortcode( 'wpinv_messages', __CLASS__ . '::messages' ); |
|
| 23 | + add_shortcode('wpinv_messages', __CLASS__ . '::messages'); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | public static function shortcode_wrapper( |
@@ -34,25 +34,25 @@ discard block |
||
| 34 | 34 | ) { |
| 35 | 35 | ob_start(); |
| 36 | 36 | |
| 37 | - echo empty( $wrapper['before'] ) ? '<div class="' . esc_attr( $wrapper['class'] ) . '">' : $wrapper['before']; |
|
| 38 | - call_user_func( $function, $atts ); |
|
| 39 | - echo empty( $wrapper['after'] ) ? '</div>' : $wrapper['after']; |
|
| 37 | + echo empty($wrapper['before']) ? '<div class="' . esc_attr($wrapper['class']) . '">' : $wrapper['before']; |
|
| 38 | + call_user_func($function, $atts); |
|
| 39 | + echo empty($wrapper['after']) ? '</div>' : $wrapper['after']; |
|
| 40 | 40 | |
| 41 | 41 | return ob_get_clean(); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public static function checkout( $atts = array(), $content = null ) { |
|
| 45 | - return wpinv_checkout_form( $atts, $content ); |
|
| 44 | + public static function checkout($atts = array(), $content = null) { |
|
| 45 | + return wpinv_checkout_form($atts, $content); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - public static function messages( $atts, $content = null ) { |
|
| 48 | + public static function messages($atts, $content = null) { |
|
| 49 | 49 | ob_start(); |
| 50 | 50 | wpinv_print_errors(); |
| 51 | 51 | return '<div class="wpinv">' . ob_get_clean() . '</div>'; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - public static function history( $atts, $content = null ) { |
|
| 55 | - return self::shortcode_wrapper( array( __CLASS__, 'history_output' ), $atts ); |
|
| 54 | + public static function history($atts, $content = null) { |
|
| 55 | + return self::shortcode_wrapper(array(__CLASS__, 'history_output'), $atts); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -60,28 +60,28 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @param array $atts |
| 62 | 62 | */ |
| 63 | - public static function history_output( $atts ) { |
|
| 64 | - do_action( 'wpinv_before_user_invoice_history' ); |
|
| 65 | - wpinv_get_template_part( 'wpinv-invoice-history', $atts ); |
|
| 66 | - do_action( 'wpinv_after_user_invoice_history' ); |
|
| 63 | + public static function history_output($atts) { |
|
| 64 | + do_action('wpinv_before_user_invoice_history'); |
|
| 65 | + wpinv_get_template_part('wpinv-invoice-history', $atts); |
|
| 66 | + do_action('wpinv_after_user_invoice_history'); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - public static function receipt( $atts, $content = null ) { |
|
| 70 | - return wpinv_payment_receipt( $atts, $content ); |
|
| 69 | + public static function receipt($atts, $content = null) { |
|
| 70 | + return wpinv_payment_receipt($atts, $content); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public static function buy( $atts, $content = null ) { |
|
| 74 | - $a = shortcode_atts( array( |
|
| 73 | + public static function buy($atts, $content = null) { |
|
| 74 | + $a = shortcode_atts(array( |
|
| 75 | 75 | 'items' => '', // should be used like: item_id|quantity,item_id|quantity,item_id|quantity |
| 76 | - 'title' => __('Buy Now', 'invoicing' ), // the button title |
|
| 76 | + 'title' => __('Buy Now', 'invoicing'), // the button title |
|
| 77 | 77 | 'post_id' => '', // any related post_id |
| 78 | - ), $atts ); |
|
| 78 | + ), $atts); |
|
| 79 | 79 | |
| 80 | 80 | $post_id = isset($a['post_id']) ? (int)$a['post_id'] : ''; |
| 81 | 81 | |
| 82 | 82 | $html = '<div class="wpi-buy-button-wrapper">'; |
| 83 | - $html .= '<input type="submit" name="submit" class="button button-primary wpi-buy-button" value="'.$a['title'].'" onclick="wpi_buy(\''.$a['items'].'\','.$post_id.');" />'; |
|
| 84 | - $html .= wp_nonce_field( 'wpinv_buy_items', 'wpinv_buy_nonce', true, false ); |
|
| 83 | + $html .= '<input type="submit" name="submit" class="button button-primary wpi-buy-button" value="' . $a['title'] . '" onclick="wpi_buy(\'' . $a['items'] . '\',' . $post_id . ');" />'; |
|
| 84 | + $html .= wp_nonce_field('wpinv_buy_items', 'wpinv_buy_nonce', true, false); |
|
| 85 | 85 | $html .= '</div>'; |
| 86 | 86 | |
| 87 | 87 | |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - public static function subscriptions( $atts, $content = null ) { |
|
| 93 | - return self::shortcode_wrapper( array( __CLASS__, 'subscriptions_output' ), $atts ); |
|
| 92 | + public static function subscriptions($atts, $content = null) { |
|
| 93 | + return self::shortcode_wrapper(array(__CLASS__, 'subscriptions_output'), $atts); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @param array $atts |
| 100 | 100 | */ |
| 101 | - public static function subscriptions_output( $atts ) { |
|
| 102 | - do_action( 'wpinv_before_user_subscriptions' ); |
|
| 103 | - wpinv_get_template_part( 'wpinv-subscriptions-history', $atts ); |
|
| 104 | - do_action( 'wpinv_after_user_subscriptions' ); |
|
| 101 | + public static function subscriptions_output($atts) { |
|
| 102 | + do_action('wpinv_before_user_subscriptions'); |
|
| 103 | + wpinv_get_template_part('wpinv-subscriptions-history', $atts); |
|
| 104 | + do_action('wpinv_after_user_subscriptions'); |
|
| 105 | 105 | } |
| 106 | 106 | } |
@@ -9,58 +9,58 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | // If uninstall not called from WordPress, then exit. |
| 12 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
| 12 | +if (!defined('WP_UNINSTALL_PLUGIN')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | global $wpdb, $wp_version; |
| 17 | 17 | |
| 18 | -$remove_data = get_option( 'wpinv_remove_data_on_invoice_unistall' ); |
|
| 18 | +$remove_data = get_option('wpinv_remove_data_on_invoice_unistall'); |
|
| 19 | 19 | |
| 20 | 20 | /* |
| 21 | 21 | * Only remove ALL product and page data if WPINV_REMOVE_ALL_DATA constant is set to true in user's |
| 22 | 22 | * wp-config.php. This is to prevent data loss when deleting the plugin from the backend |
| 23 | 23 | * and to ensure only the site owner can perform this action. |
| 24 | 24 | */ |
| 25 | -if ( defined( 'WPINV_REMOVE_ALL_DATA' ) ) { |
|
| 25 | +if (defined('WPINV_REMOVE_ALL_DATA')) { |
|
| 26 | 26 | $remove_data = true === WPINV_REMOVE_ALL_DATA ? true : false; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | -if ( $remove_data ) { |
|
| 29 | +if ($remove_data) { |
|
| 30 | 30 | // Load Invoicing file. |
| 31 | - include_once( 'invoicing.php' ); |
|
| 31 | + include_once('invoicing.php'); |
|
| 32 | 32 | |
| 33 | 33 | // Roles + caps. |
| 34 | - include_once( dirname( __FILE__ ) . '/includes/admin/install.php' ); |
|
| 34 | + include_once(dirname(__FILE__) . '/includes/admin/install.php'); |
|
| 35 | 35 | wpinv_remove_admin_caps(); |
| 36 | 36 | |
| 37 | - $settings = get_option( 'wpinv_settings' ); |
|
| 37 | + $settings = get_option('wpinv_settings'); |
|
| 38 | 38 | |
| 39 | 39 | // Delete pages. |
| 40 | - $wpi_pages = array( 'checkout_page', 'success_page', 'failure_page', 'invoice_history_page', 'quote_history_page', 'invoice_subscription_page' ); |
|
| 41 | - foreach ( $wpi_pages as $page ) { |
|
| 42 | - if ( !empty( $page ) && !empty( $settings[ $page ] ) ) { |
|
| 43 | - wp_delete_post( $settings[ $page ], true ); |
|
| 40 | + $wpi_pages = array('checkout_page', 'success_page', 'failure_page', 'invoice_history_page', 'quote_history_page', 'invoice_subscription_page'); |
|
| 41 | + foreach ($wpi_pages as $page) { |
|
| 42 | + if (!empty($page) && !empty($settings[$page])) { |
|
| 43 | + wp_delete_post($settings[$page], true); |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | // Delete posts + data. |
| 48 | - $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'wpi_invoice', 'wpi_item', 'wpi_discount', 'wpi_quote' );" ); |
|
| 49 | - $wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" ); |
|
| 48 | + $wpdb->query("DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'wpi_invoice', 'wpi_item', 'wpi_discount', 'wpi_quote' );"); |
|
| 49 | + $wpdb->query("DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;"); |
|
| 50 | 50 | |
| 51 | 51 | // Delete comments. |
| 52 | - $wpdb->query( "DELETE FROM {$wpdb->comments} WHERE comment_type LIKE 'wpinv_note';" ); |
|
| 53 | - $wpdb->query( "DELETE meta FROM {$wpdb->commentmeta} meta LEFT JOIN {$wpdb->comments} comments ON comments.comment_ID = meta.comment_id WHERE comments.comment_ID IS NULL;" ); |
|
| 52 | + $wpdb->query("DELETE FROM {$wpdb->comments} WHERE comment_type LIKE 'wpinv_note';"); |
|
| 53 | + $wpdb->query("DELETE meta FROM {$wpdb->commentmeta} meta LEFT JOIN {$wpdb->comments} comments ON comments.comment_ID = meta.comment_id WHERE comments.comment_ID IS NULL;"); |
|
| 54 | 54 | |
| 55 | 55 | // Delete user meta. |
| 56 | - $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%_wpinv_%' OR meta_key LIKE '%_wpi_invoice%' OR meta_key LIKE '%_wpi_item%' OR meta_key LIKE '%_wpi_discount%' OR meta_key LIKE '_wpi_stripe%' OR meta_key LIKE '%_wpi_quote%';" ); |
|
| 56 | + $wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%_wpinv_%' OR meta_key LIKE '%_wpi_invoice%' OR meta_key LIKE '%_wpi_item%' OR meta_key LIKE '%_wpi_discount%' OR meta_key LIKE '_wpi_stripe%' OR meta_key LIKE '%_wpi_quote%';"); |
|
| 57 | 57 | |
| 58 | 58 | // Cleanup Cron Schedule |
| 59 | - wp_clear_scheduled_hook( 'wp_session_garbage_collection' ); |
|
| 60 | - wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' ); |
|
| 59 | + wp_clear_scheduled_hook('wp_session_garbage_collection'); |
|
| 60 | + wp_clear_scheduled_hook('wpinv_register_schedule_event_twicedaily'); |
|
| 61 | 61 | |
| 62 | 62 | // Delete options. |
| 63 | - $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wpinv_%' OR option_name LIKE '_wpinv_%' OR option_name LIKE '\_transient\_wpinv\_%';" ); |
|
| 63 | + $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wpinv_%' OR option_name LIKE '_wpinv_%' OR option_name LIKE '\_transient\_wpinv\_%';"); |
|
| 64 | 64 | |
| 65 | 65 | // Clear any cached data that has been removed |
| 66 | 66 | wp_cache_flush(); |
@@ -1,66 +1,66 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // MUST have WordPress. |
| 3 | -if ( !defined( 'WPINC' ) ) { |
|
| 4 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 3 | +if (!defined('WPINC')) { |
|
| 4 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | -function wpinv_get_option( $key = '', $default = false ) { |
|
| 7 | +function wpinv_get_option($key = '', $default = false) { |
|
| 8 | 8 | global $wpinv_options; |
| 9 | 9 | |
| 10 | - $value = isset( $wpinv_options[ $key ] ) ? $wpinv_options[ $key ] : $default; |
|
| 11 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
| 10 | + $value = isset($wpinv_options[$key]) ? $wpinv_options[$key] : $default; |
|
| 11 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
| 12 | 12 | |
| 13 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
| 13 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -function wpinv_update_option( $key = '', $value = false ) { |
|
| 16 | +function wpinv_update_option($key = '', $value = false) { |
|
| 17 | 17 | // If no key, exit |
| 18 | - if ( empty( $key ) ) { |
|
| 18 | + if (empty($key)) { |
|
| 19 | 19 | return false; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - if ( empty( $value ) ) { |
|
| 23 | - $remove_option = wpinv_delete_option( $key ); |
|
| 22 | + if (empty($value)) { |
|
| 23 | + $remove_option = wpinv_delete_option($key); |
|
| 24 | 24 | return $remove_option; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | // First let's grab the current settings |
| 28 | - $options = get_option( 'wpinv_settings' ); |
|
| 28 | + $options = get_option('wpinv_settings'); |
|
| 29 | 29 | |
| 30 | 30 | // Let other plugin alter the value |
| 31 | - $value = apply_filters( 'wpinv_update_option', $value, $key ); |
|
| 31 | + $value = apply_filters('wpinv_update_option', $value, $key); |
|
| 32 | 32 | |
| 33 | 33 | // Next let's try to update the value |
| 34 | - $options[ $key ] = $value; |
|
| 35 | - $did_update = update_option( 'wpinv_settings', $options ); |
|
| 34 | + $options[$key] = $value; |
|
| 35 | + $did_update = update_option('wpinv_settings', $options); |
|
| 36 | 36 | |
| 37 | 37 | // If it's updated, let's update the global variable |
| 38 | - if ( $did_update ) { |
|
| 38 | + if ($did_update) { |
|
| 39 | 39 | global $wpinv_options; |
| 40 | - $wpinv_options[ $key ] = $value; |
|
| 40 | + $wpinv_options[$key] = $value; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | return $did_update; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | -function wpinv_delete_option( $key = '' ) { |
|
| 46 | +function wpinv_delete_option($key = '') { |
|
| 47 | 47 | // If no key, exit |
| 48 | - if ( empty( $key ) ) { |
|
| 48 | + if (empty($key)) { |
|
| 49 | 49 | return false; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // First let's grab the current settings |
| 53 | - $options = get_option( 'wpinv_settings' ); |
|
| 53 | + $options = get_option('wpinv_settings'); |
|
| 54 | 54 | |
| 55 | 55 | // Next let's try to update the value |
| 56 | - if( isset( $options[ $key ] ) ) { |
|
| 57 | - unset( $options[ $key ] ); |
|
| 56 | + if (isset($options[$key])) { |
|
| 57 | + unset($options[$key]); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $did_update = update_option( 'wpinv_settings', $options ); |
|
| 60 | + $did_update = update_option('wpinv_settings', $options); |
|
| 61 | 61 | |
| 62 | 62 | // If it updated, let's update the global variable |
| 63 | - if ( $did_update ){ |
|
| 63 | + if ($did_update) { |
|
| 64 | 64 | global $wpinv_options; |
| 65 | 65 | $wpinv_options = $options; |
| 66 | 66 | } |
@@ -69,37 +69,37 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | function wpinv_get_settings() { |
| 72 | - $settings = get_option( 'wpinv_settings' ); |
|
| 72 | + $settings = get_option('wpinv_settings'); |
|
| 73 | 73 | |
| 74 | - if ( empty( $settings ) ) { |
|
| 74 | + if (empty($settings)) { |
|
| 75 | 75 | // Update old settings with new single option |
| 76 | - $general_settings = is_array( get_option( 'wpinv_settings_general' ) ) ? get_option( 'wpinv_settings_general' ) : array(); |
|
| 77 | - $gateways_settings = is_array( get_option( 'wpinv_settings_gateways' ) ) ? get_option( 'wpinv_settings_gateways' ) : array(); |
|
| 78 | - $email_settings = is_array( get_option( 'wpinv_settings_emails' ) ) ? get_option( 'wpinv_settings_emails' ) : array(); |
|
| 79 | - $tax_settings = is_array( get_option( 'wpinv_settings_taxes' ) ) ? get_option( 'wpinv_settings_taxes' ) : array(); |
|
| 80 | - $misc_settings = is_array( get_option( 'wpinv_settings_misc' ) ) ? get_option( 'wpinv_settings_misc' ) : array(); |
|
| 81 | - $tool_settings = is_array( get_option( 'wpinv_settings_tools' ) ) ? get_option( 'wpinv_settings_tools' ) : array(); |
|
| 76 | + $general_settings = is_array(get_option('wpinv_settings_general')) ? get_option('wpinv_settings_general') : array(); |
|
| 77 | + $gateways_settings = is_array(get_option('wpinv_settings_gateways')) ? get_option('wpinv_settings_gateways') : array(); |
|
| 78 | + $email_settings = is_array(get_option('wpinv_settings_emails')) ? get_option('wpinv_settings_emails') : array(); |
|
| 79 | + $tax_settings = is_array(get_option('wpinv_settings_taxes')) ? get_option('wpinv_settings_taxes') : array(); |
|
| 80 | + $misc_settings = is_array(get_option('wpinv_settings_misc')) ? get_option('wpinv_settings_misc') : array(); |
|
| 81 | + $tool_settings = is_array(get_option('wpinv_settings_tools')) ? get_option('wpinv_settings_tools') : array(); |
|
| 82 | 82 | |
| 83 | - $settings = array_merge( $general_settings, $gateways_settings, $tax_settings, $tool_settings ); |
|
| 83 | + $settings = array_merge($general_settings, $gateways_settings, $tax_settings, $tool_settings); |
|
| 84 | 84 | |
| 85 | - update_option( 'wpinv_settings', $settings ); |
|
| 85 | + update_option('wpinv_settings', $settings); |
|
| 86 | 86 | |
| 87 | 87 | } |
| 88 | - return apply_filters( 'wpinv_get_settings', $settings ); |
|
| 88 | + return apply_filters('wpinv_get_settings', $settings); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | function wpinv_register_settings() { |
| 92 | - if ( false == get_option( 'wpinv_settings' ) ) { |
|
| 93 | - add_option( 'wpinv_settings' ); |
|
| 92 | + if (false == get_option('wpinv_settings')) { |
|
| 93 | + add_option('wpinv_settings'); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | $register_settings = wpinv_get_registered_settings(); |
| 97 | 97 | |
| 98 | - foreach ( $register_settings as $tab => $sections ) { |
|
| 99 | - foreach ( $sections as $section => $settings) { |
|
| 98 | + foreach ($register_settings as $tab => $sections) { |
|
| 99 | + foreach ($sections as $section => $settings) { |
|
| 100 | 100 | // Check for backwards compatibility |
| 101 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
| 102 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
| 101 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
| 102 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
| 103 | 103 | $section = 'main'; |
| 104 | 104 | $settings = $sections; |
| 105 | 105 | } |
@@ -111,42 +111,42 @@ discard block |
||
| 111 | 111 | 'wpinv_settings_' . $tab . '_' . $section |
| 112 | 112 | ); |
| 113 | 113 | |
| 114 | - foreach ( $settings as $option ) { |
|
| 114 | + foreach ($settings as $option) { |
|
| 115 | 115 | // For backwards compatibility |
| 116 | - if ( empty( $option['id'] ) ) { |
|
| 116 | + if (empty($option['id'])) { |
|
| 117 | 117 | continue; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
| 120 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
| 121 | 121 | |
| 122 | 122 | add_settings_field( |
| 123 | 123 | 'wpinv_settings[' . $option['id'] . ']', |
| 124 | 124 | $name, |
| 125 | - function_exists( 'wpinv_' . $option['type'] . '_callback' ) ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback', |
|
| 125 | + function_exists('wpinv_' . $option['type'] . '_callback') ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback', |
|
| 126 | 126 | 'wpinv_settings_' . $tab . '_' . $section, |
| 127 | 127 | 'wpinv_settings_' . $tab . '_' . $section, |
| 128 | 128 | array( |
| 129 | 129 | 'section' => $section, |
| 130 | - 'id' => isset( $option['id'] ) ? $option['id'] : null, |
|
| 131 | - 'desc' => ! empty( $option['desc'] ) ? $option['desc'] : '', |
|
| 132 | - 'name' => isset( $option['name'] ) ? $option['name'] : null, |
|
| 133 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
| 134 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
| 135 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
| 136 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
| 137 | - 'min' => isset( $option['min'] ) ? $option['min'] : null, |
|
| 138 | - 'max' => isset( $option['max'] ) ? $option['max'] : null, |
|
| 139 | - 'step' => isset( $option['step'] ) ? $option['step'] : null, |
|
| 140 | - 'chosen' => isset( $option['chosen'] ) ? $option['chosen'] : null, |
|
| 141 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
| 142 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
| 143 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
| 144 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
| 145 | - 'onchange' => !empty( $option['onchange'] ) ? $option['onchange'] : '', |
|
| 146 | - 'custom' => !empty( $option['custom'] ) ? $option['custom'] : '', |
|
| 147 | - 'class' => !empty( $option['class'] ) ? $option['class'] : '', |
|
| 148 | - 'cols' => !empty( $option['cols'] ) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50, |
|
| 149 | - 'rows' => !empty( $option['rows'] ) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5, |
|
| 130 | + 'id' => isset($option['id']) ? $option['id'] : null, |
|
| 131 | + 'desc' => !empty($option['desc']) ? $option['desc'] : '', |
|
| 132 | + 'name' => isset($option['name']) ? $option['name'] : null, |
|
| 133 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
| 134 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
| 135 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
| 136 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
| 137 | + 'min' => isset($option['min']) ? $option['min'] : null, |
|
| 138 | + 'max' => isset($option['max']) ? $option['max'] : null, |
|
| 139 | + 'step' => isset($option['step']) ? $option['step'] : null, |
|
| 140 | + 'chosen' => isset($option['chosen']) ? $option['chosen'] : null, |
|
| 141 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
| 142 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
| 143 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
| 144 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
| 145 | + 'onchange' => !empty($option['onchange']) ? $option['onchange'] : '', |
|
| 146 | + 'custom' => !empty($option['custom']) ? $option['custom'] : '', |
|
| 147 | + 'class' => !empty($option['class']) ? $option['class'] : '', |
|
| 148 | + 'cols' => !empty($option['cols']) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50, |
|
| 149 | + 'rows' => !empty($option['rows']) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5, |
|
| 150 | 150 | ) |
| 151 | 151 | ); |
| 152 | 152 | } |
@@ -154,189 +154,189 @@ discard block |
||
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | // Creates our settings in the options table |
| 157 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
| 157 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
| 158 | 158 | } |
| 159 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
| 159 | +add_action('admin_init', 'wpinv_register_settings'); |
|
| 160 | 160 | |
| 161 | 161 | function wpinv_get_registered_settings() { |
| 162 | - $pages = wpinv_get_pages( true ); |
|
| 162 | + $pages = wpinv_get_pages(true); |
|
| 163 | 163 | |
| 164 | 164 | $currencies = wpinv_get_currencies(); |
| 165 | 165 | |
| 166 | 166 | $currency_code_options = array(); |
| 167 | - foreach ( $currencies as $code => $name ) { |
|
| 168 | - $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')'; |
|
| 167 | + foreach ($currencies as $code => $name) { |
|
| 168 | + $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')'; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | $due_payment_options = array(); |
| 172 | - $due_payment_options[0] = __( 'Now', 'invoicing' ); |
|
| 173 | - for ( $i = 1; $i <= 30; $i++ ) { |
|
| 172 | + $due_payment_options[0] = __('Now', 'invoicing'); |
|
| 173 | + for ($i = 1; $i <= 30; $i++) { |
|
| 174 | 174 | $due_payment_options[$i] = $i; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | $invoice_number_padd_options = array(); |
| 178 | - for ( $i = 0; $i <= 20; $i++ ) { |
|
| 178 | + for ($i = 0; $i <= 20; $i++) { |
|
| 179 | 179 | $invoice_number_padd_options[$i] = $i; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | $currency_symbol = wpinv_currency_symbol(); |
| 183 | 183 | |
| 184 | 184 | $last_number = ''; |
| 185 | - if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) { |
|
| 186 | - $last_invoice_number = is_numeric( $last_invoice_number ) ? $last_invoice_number : wpinv_clean_invoice_number( $last_invoice_number ); |
|
| 185 | + if ($last_invoice_number = get_option('wpinv_last_invoice_number')) { |
|
| 186 | + $last_invoice_number = is_numeric($last_invoice_number) ? $last_invoice_number : wpinv_clean_invoice_number($last_invoice_number); |
|
| 187 | 187 | |
| 188 | - if ( !empty( $last_invoice_number ) ) { |
|
| 189 | - $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number ); |
|
| 188 | + if (!empty($last_invoice_number)) { |
|
| 189 | + $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number); |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | $alert_wrapper_start = '<p style="color: #F00">'; |
| 194 | 194 | $alert_wrapper_close = '</p>'; |
| 195 | 195 | $wpinv_settings = array( |
| 196 | - 'general' => apply_filters( 'wpinv_settings_general', |
|
| 196 | + 'general' => apply_filters('wpinv_settings_general', |
|
| 197 | 197 | array( |
| 198 | 198 | 'main' => array( |
| 199 | 199 | 'location_settings' => array( |
| 200 | 200 | 'id' => 'location_settings', |
| 201 | - 'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>', |
|
| 201 | + 'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>', |
|
| 202 | 202 | 'desc' => '', |
| 203 | 203 | 'type' => 'header', |
| 204 | 204 | ), |
| 205 | 205 | 'default_country' => array( |
| 206 | 206 | 'id' => 'default_country', |
| 207 | - 'name' => __( 'Default Country', 'invoicing' ), |
|
| 208 | - 'desc' => __( 'Where does your store operate from?', 'invoicing' ), |
|
| 207 | + 'name' => __('Default Country', 'invoicing'), |
|
| 208 | + 'desc' => __('Where does your store operate from?', 'invoicing'), |
|
| 209 | 209 | 'type' => 'select', |
| 210 | 210 | 'options' => wpinv_get_country_list(), |
| 211 | 211 | 'std' => 'GB', |
| 212 | 212 | 'chosen' => true, |
| 213 | - 'placeholder' => __( 'Select a country', 'invoicing' ), |
|
| 213 | + 'placeholder' => __('Select a country', 'invoicing'), |
|
| 214 | 214 | ), |
| 215 | 215 | 'default_state' => array( |
| 216 | 216 | 'id' => 'default_state', |
| 217 | - 'name' => __( 'Default State / Province', 'invoicing' ), |
|
| 218 | - 'desc' => __( 'What state / province does your store operate from?', 'invoicing' ), |
|
| 217 | + 'name' => __('Default State / Province', 'invoicing'), |
|
| 218 | + 'desc' => __('What state / province does your store operate from?', 'invoicing'), |
|
| 219 | 219 | 'type' => 'country_states', |
| 220 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
| 220 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
| 221 | 221 | ), |
| 222 | 222 | 'store_name' => array( |
| 223 | 223 | 'id' => 'store_name', |
| 224 | - 'name' => __( 'Store Name', 'invoicing' ), |
|
| 225 | - 'desc' => __( 'Store name to print on invoices.', 'invoicing' ), |
|
| 224 | + 'name' => __('Store Name', 'invoicing'), |
|
| 225 | + 'desc' => __('Store name to print on invoices.', 'invoicing'), |
|
| 226 | 226 | 'std' => get_option('blogname'), |
| 227 | 227 | 'type' => 'text', |
| 228 | 228 | ), |
| 229 | 229 | 'logo' => array( |
| 230 | 230 | 'id' => 'logo', |
| 231 | - 'name' => __( 'Logo URL', 'invoicing' ), |
|
| 232 | - 'desc' => __( 'Store logo to print on invoices.', 'invoicing' ), |
|
| 231 | + 'name' => __('Logo URL', 'invoicing'), |
|
| 232 | + 'desc' => __('Store logo to print on invoices.', 'invoicing'), |
|
| 233 | 233 | 'type' => 'text', |
| 234 | 234 | ), |
| 235 | 235 | 'store_address' => array( |
| 236 | 236 | 'id' => 'store_address', |
| 237 | - 'name' => __( 'Store Address', 'invoicing' ), |
|
| 238 | - 'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ), |
|
| 237 | + 'name' => __('Store Address', 'invoicing'), |
|
| 238 | + 'desc' => __('Enter the store address to display on invoice', 'invoicing'), |
|
| 239 | 239 | 'type' => 'textarea', |
| 240 | 240 | ), |
| 241 | 241 | 'page_settings' => array( |
| 242 | 242 | 'id' => 'page_settings', |
| 243 | - 'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>', |
|
| 243 | + 'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>', |
|
| 244 | 244 | 'desc' => '', |
| 245 | 245 | 'type' => 'header', |
| 246 | 246 | ), |
| 247 | 247 | 'checkout_page' => array( |
| 248 | 248 | 'id' => 'checkout_page', |
| 249 | - 'name' => __( 'Checkout Page', 'invoicing' ), |
|
| 250 | - 'desc' => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ), |
|
| 249 | + 'name' => __('Checkout Page', 'invoicing'), |
|
| 250 | + 'desc' => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'), |
|
| 251 | 251 | 'type' => 'select', |
| 252 | 252 | 'options' => $pages, |
| 253 | 253 | 'chosen' => true, |
| 254 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 254 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 255 | 255 | ), |
| 256 | 256 | 'success_page' => array( |
| 257 | 257 | 'id' => 'success_page', |
| 258 | - 'name' => __( 'Success Page', 'invoicing' ), |
|
| 259 | - 'desc' => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ), |
|
| 258 | + 'name' => __('Success Page', 'invoicing'), |
|
| 259 | + 'desc' => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'), |
|
| 260 | 260 | 'type' => 'select', |
| 261 | 261 | 'options' => $pages, |
| 262 | 262 | 'chosen' => true, |
| 263 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 263 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 264 | 264 | ), |
| 265 | 265 | 'failure_page' => array( |
| 266 | 266 | 'id' => 'failure_page', |
| 267 | - 'name' => __( 'Failed Transaction Page', 'invoicing' ), |
|
| 268 | - 'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ), |
|
| 267 | + 'name' => __('Failed Transaction Page', 'invoicing'), |
|
| 268 | + 'desc' => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'), |
|
| 269 | 269 | 'type' => 'select', |
| 270 | 270 | 'options' => $pages, |
| 271 | 271 | 'chosen' => true, |
| 272 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 272 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 273 | 273 | ), |
| 274 | 274 | 'invoice_history_page' => array( |
| 275 | 275 | 'id' => 'invoice_history_page', |
| 276 | - 'name' => __( 'Invoice History Page', 'invoicing' ), |
|
| 277 | - 'desc' => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ), |
|
| 276 | + 'name' => __('Invoice History Page', 'invoicing'), |
|
| 277 | + 'desc' => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'), |
|
| 278 | 278 | 'type' => 'select', |
| 279 | 279 | 'options' => $pages, |
| 280 | 280 | 'chosen' => true, |
| 281 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 281 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 282 | 282 | ), |
| 283 | 283 | 'invoice_subscription_page' => array( |
| 284 | 284 | 'id' => 'invoice_subscription_page', |
| 285 | - 'name' => __( 'Invoice Subscriptions Page', 'invoicing' ), |
|
| 286 | - 'desc' => __( 'This page shows an subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ), |
|
| 285 | + 'name' => __('Invoice Subscriptions Page', 'invoicing'), |
|
| 286 | + 'desc' => __('This page shows an subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'), |
|
| 287 | 287 | 'type' => 'select', |
| 288 | 288 | 'options' => $pages, |
| 289 | 289 | 'chosen' => true, |
| 290 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 290 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 291 | 291 | ) |
| 292 | 292 | ), |
| 293 | 293 | 'currency_section' => array( |
| 294 | 294 | 'currency_settings' => array( |
| 295 | 295 | 'id' => 'currency_settings', |
| 296 | - 'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>', |
|
| 296 | + 'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>', |
|
| 297 | 297 | 'desc' => '', |
| 298 | 298 | 'type' => 'header', |
| 299 | 299 | ), |
| 300 | 300 | 'currency' => array( |
| 301 | 301 | 'id' => 'currency', |
| 302 | - 'name' => __( 'Currency', 'invoicing' ), |
|
| 303 | - 'desc' => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ), |
|
| 302 | + 'name' => __('Currency', 'invoicing'), |
|
| 303 | + 'desc' => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'), |
|
| 304 | 304 | 'type' => 'select', |
| 305 | 305 | 'options' => $currency_code_options, |
| 306 | 306 | 'chosen' => true, |
| 307 | 307 | ), |
| 308 | 308 | 'currency_position' => array( |
| 309 | 309 | 'id' => 'currency_position', |
| 310 | - 'name' => __( 'Currency Position', 'invoicing' ), |
|
| 311 | - 'desc' => __( 'Choose the location of the currency sign.', 'invoicing' ), |
|
| 310 | + 'name' => __('Currency Position', 'invoicing'), |
|
| 311 | + 'desc' => __('Choose the location of the currency sign.', 'invoicing'), |
|
| 312 | 312 | 'type' => 'select', |
| 313 | 313 | 'options' => array( |
| 314 | - 'left' => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')', |
|
| 315 | - 'right' => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')', |
|
| 316 | - 'left_space' => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')', |
|
| 317 | - 'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')' |
|
| 314 | + 'left' => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')', |
|
| 315 | + 'right' => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')', |
|
| 316 | + 'left_space' => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')', |
|
| 317 | + 'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')' |
|
| 318 | 318 | ) |
| 319 | 319 | ), |
| 320 | 320 | 'thousands_separator' => array( |
| 321 | 321 | 'id' => 'thousands_separator', |
| 322 | - 'name' => __( 'Thousands Separator', 'invoicing' ), |
|
| 323 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ), |
|
| 322 | + 'name' => __('Thousands Separator', 'invoicing'), |
|
| 323 | + 'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'), |
|
| 324 | 324 | 'type' => 'text', |
| 325 | 325 | 'size' => 'small', |
| 326 | 326 | 'std' => ',', |
| 327 | 327 | ), |
| 328 | 328 | 'decimal_separator' => array( |
| 329 | 329 | 'id' => 'decimal_separator', |
| 330 | - 'name' => __( 'Decimal Separator', 'invoicing' ), |
|
| 331 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ), |
|
| 330 | + 'name' => __('Decimal Separator', 'invoicing'), |
|
| 331 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'), |
|
| 332 | 332 | 'type' => 'text', |
| 333 | 333 | 'size' => 'small', |
| 334 | 334 | 'std' => '.', |
| 335 | 335 | ), |
| 336 | 336 | 'decimals' => array( |
| 337 | 337 | 'id' => 'decimals', |
| 338 | - 'name' => __( 'Number of Decimals', 'invoicing' ), |
|
| 339 | - 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ), |
|
| 338 | + 'name' => __('Number of Decimals', 'invoicing'), |
|
| 339 | + 'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'), |
|
| 340 | 340 | 'type' => 'number', |
| 341 | 341 | 'size' => 'small', |
| 342 | 342 | 'std' => '2', |
@@ -348,29 +348,29 @@ discard block |
||
| 348 | 348 | 'labels' => array( |
| 349 | 349 | 'labels' => array( |
| 350 | 350 | 'id' => 'labels_settings', |
| 351 | - 'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>', |
|
| 351 | + 'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>', |
|
| 352 | 352 | 'desc' => '', |
| 353 | 353 | 'type' => 'header', |
| 354 | 354 | ), |
| 355 | 355 | 'vat_name' => array( |
| 356 | 356 | 'id' => 'vat_name', |
| 357 | - 'name' => __( 'VAT Name', 'invoicing' ), |
|
| 358 | - 'desc' => __( 'Enter the VAT name', 'invoicing' ), |
|
| 357 | + 'name' => __('VAT Name', 'invoicing'), |
|
| 358 | + 'desc' => __('Enter the VAT name', 'invoicing'), |
|
| 359 | 359 | 'type' => 'text', |
| 360 | 360 | 'size' => 'regular', |
| 361 | 361 | 'std' => 'VAT' |
| 362 | 362 | ), |
| 363 | 363 | 'vat_invoice_notice_label' => array( |
| 364 | 364 | 'id' => 'vat_invoice_notice_label', |
| 365 | - 'name' => __( 'Invoice Notice Label', 'invoicing' ), |
|
| 366 | - 'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ), |
|
| 365 | + 'name' => __('Invoice Notice Label', 'invoicing'), |
|
| 366 | + 'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'), |
|
| 367 | 367 | 'type' => 'text', |
| 368 | 368 | 'size' => 'regular', |
| 369 | 369 | ), |
| 370 | 370 | 'vat_invoice_notice' => array( |
| 371 | 371 | 'id' => 'vat_invoice_notice', |
| 372 | - 'name' => __( 'Invoice notice', 'invoicing' ), |
|
| 373 | - 'desc' => __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ), |
|
| 372 | + 'name' => __('Invoice notice', 'invoicing'), |
|
| 373 | + 'desc' => __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'), |
|
| 374 | 374 | 'type' => 'text', |
| 375 | 375 | 'size' => 'regular', |
| 376 | 376 | ) |
@@ -382,22 +382,22 @@ discard block |
||
| 382 | 382 | 'main' => array( |
| 383 | 383 | 'gateway_settings' => array( |
| 384 | 384 | 'id' => 'api_header', |
| 385 | - 'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>', |
|
| 385 | + 'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>', |
|
| 386 | 386 | 'desc' => '', |
| 387 | 387 | 'type' => 'header', |
| 388 | 388 | ), |
| 389 | 389 | 'gateways' => array( |
| 390 | 390 | 'id' => 'gateways', |
| 391 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
| 392 | - 'desc' => __( 'Choose the payment gateways you want to enable.', 'invoicing' ), |
|
| 391 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
| 392 | + 'desc' => __('Choose the payment gateways you want to enable.', 'invoicing'), |
|
| 393 | 393 | 'type' => 'gateways', |
| 394 | 394 | 'std' => array('manual'=>1), |
| 395 | 395 | 'options' => wpinv_get_payment_gateways(), |
| 396 | 396 | ), |
| 397 | 397 | 'default_gateway' => array( |
| 398 | 398 | 'id' => 'default_gateway', |
| 399 | - 'name' => __( 'Default Gateway', 'invoicing' ), |
|
| 400 | - 'desc' => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ), |
|
| 399 | + 'name' => __('Default Gateway', 'invoicing'), |
|
| 400 | + 'desc' => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'), |
|
| 401 | 401 | 'type' => 'gateway_select', |
| 402 | 402 | 'std' => 'manual', |
| 403 | 403 | 'options' => wpinv_get_payment_gateways(), |
@@ -411,19 +411,19 @@ discard block |
||
| 411 | 411 | 'main' => array( |
| 412 | 412 | 'tax_settings' => array( |
| 413 | 413 | 'id' => 'tax_settings', |
| 414 | - 'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>', |
|
| 414 | + 'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>', |
|
| 415 | 415 | 'type' => 'header', |
| 416 | 416 | ), |
| 417 | 417 | 'enable_taxes' => array( |
| 418 | 418 | 'id' => 'enable_taxes', |
| 419 | - 'name' => __( 'Enable Taxes', 'invoicing' ), |
|
| 420 | - 'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ), |
|
| 419 | + 'name' => __('Enable Taxes', 'invoicing'), |
|
| 420 | + 'desc' => __('Check this to enable taxes on invoices.', 'invoicing'), |
|
| 421 | 421 | 'type' => 'checkbox', |
| 422 | 422 | ), |
| 423 | 423 | 'tax_rate' => array( |
| 424 | 424 | 'id' => 'tax_rate', |
| 425 | - 'name' => __( 'Fallback Tax Rate', 'invoicing' ), |
|
| 426 | - 'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ), |
|
| 425 | + 'name' => __('Fallback Tax Rate', 'invoicing'), |
|
| 426 | + 'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'), |
|
| 427 | 427 | 'type' => 'number', |
| 428 | 428 | 'size' => 'small', |
| 429 | 429 | 'min' => '0', |
@@ -435,8 +435,8 @@ discard block |
||
| 435 | 435 | 'rates' => array( |
| 436 | 436 | 'tax_rates' => array( |
| 437 | 437 | 'id' => 'tax_rates', |
| 438 | - 'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>', |
|
| 439 | - 'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ), |
|
| 438 | + 'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>', |
|
| 439 | + 'desc' => __('Enter tax rates for specific regions.', 'invoicing'), |
|
| 440 | 440 | 'type' => 'tax_rates', |
| 441 | 441 | ), |
| 442 | 442 | ) |
@@ -448,62 +448,62 @@ discard block |
||
| 448 | 448 | 'main' => array( |
| 449 | 449 | 'email_settings_header' => array( |
| 450 | 450 | 'id' => 'email_settings_header', |
| 451 | - 'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>', |
|
| 451 | + 'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>', |
|
| 452 | 452 | 'type' => 'header', |
| 453 | 453 | ), |
| 454 | 454 | 'email_from_name' => array( |
| 455 | 455 | 'id' => 'email_from_name', |
| 456 | - 'name' => __( 'From Name', 'invoicing' ), |
|
| 457 | - 'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ), |
|
| 458 | - 'std' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
|
| 456 | + 'name' => __('From Name', 'invoicing'), |
|
| 457 | + 'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'), |
|
| 458 | + 'std' => esc_attr(get_bloginfo('name', 'display')), |
|
| 459 | 459 | 'type' => 'text', |
| 460 | 460 | ), |
| 461 | 461 | 'email_from' => array( |
| 462 | 462 | 'id' => 'email_from', |
| 463 | - 'name' => __( 'From Email', 'invoicing' ), |
|
| 464 | - 'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close), |
|
| 465 | - 'std' => get_option( 'admin_email' ), |
|
| 463 | + 'name' => __('From Email', 'invoicing'), |
|
| 464 | + 'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close), |
|
| 465 | + 'std' => get_option('admin_email'), |
|
| 466 | 466 | 'type' => 'text', |
| 467 | 467 | ), |
| 468 | 468 | 'overdue_settings_header' => array( |
| 469 | 469 | 'id' => 'overdue_settings_header', |
| 470 | - 'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>', |
|
| 470 | + 'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>', |
|
| 471 | 471 | 'type' => 'header', |
| 472 | 472 | ), |
| 473 | 473 | 'overdue_active' => array( |
| 474 | 474 | 'id' => 'overdue_active', |
| 475 | - 'name' => __( 'Enable Due Date', 'invoicing' ), |
|
| 476 | - 'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ), |
|
| 475 | + 'name' => __('Enable Due Date', 'invoicing'), |
|
| 476 | + 'desc' => __('Check this to enable due date option for invoices.', 'invoicing'), |
|
| 477 | 477 | 'type' => 'checkbox', |
| 478 | 478 | 'std' => false, |
| 479 | 479 | ), |
| 480 | 480 | 'overdue_days' => array( |
| 481 | 481 | 'id' => 'overdue_days', |
| 482 | - 'name' => __( 'Default Due Date', 'invoicing' ), |
|
| 483 | - 'desc' => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ), |
|
| 482 | + 'name' => __('Default Due Date', 'invoicing'), |
|
| 483 | + 'desc' => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'), |
|
| 484 | 484 | 'type' => 'select', |
| 485 | 485 | 'options' => $due_payment_options, |
| 486 | 486 | 'chosen' => true, |
| 487 | 487 | 'std' => 0, |
| 488 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
| 488 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
| 489 | 489 | ), |
| 490 | 490 | 'email_template_header' => array( |
| 491 | 491 | 'id' => 'email_template_header', |
| 492 | - 'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>', |
|
| 492 | + 'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>', |
|
| 493 | 493 | 'type' => 'header', |
| 494 | 494 | ), |
| 495 | 495 | 'email_header_image' => array( |
| 496 | 496 | 'id' => 'email_header_image', |
| 497 | - 'name' => __( 'Header Image', 'invoicing' ), |
|
| 498 | - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ), |
|
| 497 | + 'name' => __('Header Image', 'invoicing'), |
|
| 498 | + 'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'), |
|
| 499 | 499 | 'std' => '', |
| 500 | 500 | 'type' => 'text', |
| 501 | 501 | ), |
| 502 | 502 | 'email_footer_text' => array( |
| 503 | 503 | 'id' => 'email_footer_text', |
| 504 | - 'name' => __( 'Footer Text', 'invoicing' ), |
|
| 505 | - 'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ), |
|
| 506 | - 'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ), |
|
| 504 | + 'name' => __('Footer Text', 'invoicing'), |
|
| 505 | + 'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'), |
|
| 506 | + 'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'), |
|
| 507 | 507 | 'type' => 'textarea', |
| 508 | 508 | 'class' => 'regular-text', |
| 509 | 509 | 'rows' => 2, |
@@ -511,29 +511,29 @@ discard block |
||
| 511 | 511 | ), |
| 512 | 512 | 'email_base_color' => array( |
| 513 | 513 | 'id' => 'email_base_color', |
| 514 | - 'name' => __( 'Base Color', 'invoicing' ), |
|
| 515 | - 'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ), |
|
| 514 | + 'name' => __('Base Color', 'invoicing'), |
|
| 515 | + 'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'), |
|
| 516 | 516 | 'std' => '#557da2', |
| 517 | 517 | 'type' => 'color', |
| 518 | 518 | ), |
| 519 | 519 | 'email_background_color' => array( |
| 520 | 520 | 'id' => 'email_background_color', |
| 521 | - 'name' => __( 'Background Color', 'invoicing' ), |
|
| 522 | - 'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ), |
|
| 521 | + 'name' => __('Background Color', 'invoicing'), |
|
| 522 | + 'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'), |
|
| 523 | 523 | 'std' => '#f5f5f5', |
| 524 | 524 | 'type' => 'color', |
| 525 | 525 | ), |
| 526 | 526 | 'email_body_background_color' => array( |
| 527 | 527 | 'id' => 'email_body_background_color', |
| 528 | - 'name' => __( 'Body Background Color', 'invoicing' ), |
|
| 529 | - 'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ), |
|
| 528 | + 'name' => __('Body Background Color', 'invoicing'), |
|
| 529 | + 'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'), |
|
| 530 | 530 | 'std' => '#fdfdfd', |
| 531 | 531 | 'type' => 'color', |
| 532 | 532 | ), |
| 533 | 533 | 'email_text_color' => array( |
| 534 | 534 | 'id' => 'email_text_color', |
| 535 | - 'name' => __( 'Body Text Color', 'invoicing' ), |
|
| 536 | - 'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ), |
|
| 535 | + 'name' => __('Body Text Color', 'invoicing'), |
|
| 536 | + 'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'), |
|
| 537 | 537 | 'std' => '#505050', |
| 538 | 538 | 'type' => 'color', |
| 539 | 539 | ), |
@@ -552,19 +552,19 @@ discard block |
||
| 552 | 552 | 'main' => array( |
| 553 | 553 | 'invoice_number_format_settings' => array( |
| 554 | 554 | 'id' => 'invoice_number_format_settings', |
| 555 | - 'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>', |
|
| 555 | + 'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>', |
|
| 556 | 556 | 'type' => 'header', |
| 557 | 557 | ), |
| 558 | 558 | 'sequential_invoice_number' => array( |
| 559 | 559 | 'id' => 'sequential_invoice_number', |
| 560 | - 'name' => __( 'Sequential Invoice Numbers', 'invoicing' ), |
|
| 561 | - 'desc' => __( 'Check this box to enable sequential invoice numbers.', 'invoicing' ), |
|
| 560 | + 'name' => __('Sequential Invoice Numbers', 'invoicing'), |
|
| 561 | + 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing'), |
|
| 562 | 562 | 'type' => 'checkbox', |
| 563 | 563 | ), |
| 564 | 564 | 'invoice_sequence_start' => array( |
| 565 | 565 | 'id' => 'invoice_sequence_start', |
| 566 | - 'name' => __( 'Sequential Starting Number', 'invoicing' ), |
|
| 567 | - 'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number, |
|
| 566 | + 'name' => __('Sequential Starting Number', 'invoicing'), |
|
| 567 | + 'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number, |
|
| 568 | 568 | 'type' => 'number', |
| 569 | 569 | 'size' => 'small', |
| 570 | 570 | 'std' => '1', |
@@ -572,8 +572,8 @@ discard block |
||
| 572 | 572 | ), |
| 573 | 573 | 'invoice_number_padd' => array( |
| 574 | 574 | 'id' => 'invoice_number_padd', |
| 575 | - 'name' => __( 'Minimum Digits', 'invoicing' ), |
|
| 576 | - 'desc' => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ), |
|
| 575 | + 'name' => __('Minimum Digits', 'invoicing'), |
|
| 576 | + 'desc' => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'), |
|
| 577 | 577 | 'type' => 'select', |
| 578 | 578 | 'options' => $invoice_number_padd_options, |
| 579 | 579 | 'std' => 5, |
@@ -581,8 +581,8 @@ discard block |
||
| 581 | 581 | ), |
| 582 | 582 | 'invoice_number_prefix' => array( |
| 583 | 583 | 'id' => 'invoice_number_prefix', |
| 584 | - 'name' => __( 'Invoice Number Prefix', 'invoicing' ), |
|
| 585 | - 'desc' => __( 'Prefix for all invoice numbers. Ex: WPINV-', 'invoicing' ), |
|
| 584 | + 'name' => __('Invoice Number Prefix', 'invoicing'), |
|
| 585 | + 'desc' => __('Prefix for all invoice numbers. Ex: WPINV-', 'invoicing'), |
|
| 586 | 586 | 'type' => 'text', |
| 587 | 587 | 'size' => 'regular', |
| 588 | 588 | 'std' => 'WPINV-', |
@@ -590,32 +590,32 @@ discard block |
||
| 590 | 590 | ), |
| 591 | 591 | 'invoice_number_postfix' => array( |
| 592 | 592 | 'id' => 'invoice_number_postfix', |
| 593 | - 'name' => __( 'Invoice Number Postfix', 'invoicing' ), |
|
| 594 | - 'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ), |
|
| 593 | + 'name' => __('Invoice Number Postfix', 'invoicing'), |
|
| 594 | + 'desc' => __('Postfix for all invoice numbers.', 'invoicing'), |
|
| 595 | 595 | 'type' => 'text', |
| 596 | 596 | 'size' => 'regular', |
| 597 | 597 | 'std' => '' |
| 598 | 598 | ), |
| 599 | 599 | 'checkout_settings' => array( |
| 600 | 600 | 'id' => 'checkout_settings', |
| 601 | - 'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>', |
|
| 601 | + 'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>', |
|
| 602 | 602 | 'type' => 'header', |
| 603 | 603 | ), |
| 604 | 604 | 'login_to_checkout' => array( |
| 605 | 605 | 'id' => 'login_to_checkout', |
| 606 | - 'name' => __( 'Require Login To Checkout', 'invoicing' ), |
|
| 607 | - 'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ), |
|
| 606 | + 'name' => __('Require Login To Checkout', 'invoicing'), |
|
| 607 | + 'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'), |
|
| 608 | 608 | 'type' => 'checkbox', |
| 609 | 609 | ), |
| 610 | 610 | 'uninstall_settings' => array( |
| 611 | 611 | 'id' => 'uninstall_settings', |
| 612 | - 'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>', |
|
| 612 | + 'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>', |
|
| 613 | 613 | 'type' => 'header', |
| 614 | 614 | ), |
| 615 | 615 | 'remove_data_on_unistall' => array( |
| 616 | 616 | 'id' => 'remove_data_on_unistall', |
| 617 | - 'name' => __( 'Remove Data on Uninstall?', 'invoicing' ), |
|
| 618 | - 'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ), |
|
| 617 | + 'name' => __('Remove Data on Uninstall?', 'invoicing'), |
|
| 618 | + 'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'), |
|
| 619 | 619 | 'type' => 'checkbox', |
| 620 | 620 | 'std' => '' |
| 621 | 621 | ), |
@@ -623,74 +623,74 @@ discard block |
||
| 623 | 623 | 'fields' => array( |
| 624 | 624 | 'fields_settings' => array( |
| 625 | 625 | 'id' => 'fields_settings', |
| 626 | - 'name' => '<h3>' . __( 'Address Fields', 'invoicing' ) . '</h3>', |
|
| 627 | - 'desc' => __( 'Tick fields which are mandatory in invoice address fields.', 'invoicing' ), |
|
| 626 | + 'name' => '<h3>' . __('Address Fields', 'invoicing') . '</h3>', |
|
| 627 | + 'desc' => __('Tick fields which are mandatory in invoice address fields.', 'invoicing'), |
|
| 628 | 628 | 'type' => 'header', |
| 629 | 629 | ), |
| 630 | 630 | 'fname_mandatory' => array( |
| 631 | 631 | 'id' => 'fname_mandatory', |
| 632 | - 'name' => __( 'First Name', 'invoicing' ), |
|
| 632 | + 'name' => __('First Name', 'invoicing'), |
|
| 633 | 633 | 'type' => 'checkbox', |
| 634 | 634 | 'std' => true, |
| 635 | 635 | ), |
| 636 | 636 | 'lname_mandatory' => array( |
| 637 | 637 | 'id' => 'lname_mandatory', |
| 638 | - 'name' => __( 'Last Name', 'invoicing' ), |
|
| 638 | + 'name' => __('Last Name', 'invoicing'), |
|
| 639 | 639 | 'type' => 'checkbox', |
| 640 | 640 | 'std' => true, |
| 641 | 641 | ), |
| 642 | 642 | 'address_mandatory' => array( |
| 643 | 643 | 'id' => 'address_mandatory', |
| 644 | - 'name' => __( 'Address', 'invoicing' ), |
|
| 644 | + 'name' => __('Address', 'invoicing'), |
|
| 645 | 645 | 'type' => 'checkbox', |
| 646 | 646 | 'std' => true, |
| 647 | 647 | ), |
| 648 | 648 | 'city_mandatory' => array( |
| 649 | 649 | 'id' => 'city_mandatory', |
| 650 | - 'name' => __( 'City', 'invoicing' ), |
|
| 650 | + 'name' => __('City', 'invoicing'), |
|
| 651 | 651 | 'type' => 'checkbox', |
| 652 | 652 | 'std' => true, |
| 653 | 653 | ), |
| 654 | 654 | 'country_mandatory' => array( |
| 655 | 655 | 'id' => 'country_mandatory', |
| 656 | - 'name' => __( 'Country', 'invoicing' ), |
|
| 656 | + 'name' => __('Country', 'invoicing'), |
|
| 657 | 657 | 'type' => 'checkbox', |
| 658 | 658 | 'std' => true, |
| 659 | 659 | ), |
| 660 | 660 | 'state_mandatory' => array( |
| 661 | 661 | 'id' => 'state_mandatory', |
| 662 | - 'name' => __( 'State / Province', 'invoicing' ), |
|
| 662 | + 'name' => __('State / Province', 'invoicing'), |
|
| 663 | 663 | 'type' => 'checkbox', |
| 664 | 664 | 'std' => true, |
| 665 | 665 | ), |
| 666 | 666 | 'zip_mandatory' => array( |
| 667 | 667 | 'id' => 'zip_mandatory', |
| 668 | - 'name' => __( 'ZIP / Postcode', 'invoicing' ), |
|
| 668 | + 'name' => __('ZIP / Postcode', 'invoicing'), |
|
| 669 | 669 | 'type' => 'checkbox', |
| 670 | 670 | 'std' => true, |
| 671 | 671 | ), |
| 672 | 672 | 'phone_mandatory' => array( |
| 673 | 673 | 'id' => 'phone_mandatory', |
| 674 | - 'name' => __( 'Phone Number', 'invoicing' ), |
|
| 674 | + 'name' => __('Phone Number', 'invoicing'), |
|
| 675 | 675 | 'type' => 'checkbox', |
| 676 | 676 | 'std' => true, |
| 677 | 677 | ), |
| 678 | 678 | 'address_autofill_settings' => array( |
| 679 | 679 | 'id' => 'address_autofill_settings', |
| 680 | - 'name' => '<h3>' . __( 'Google Address Auto Complete', 'invoicing' ) . '</h3>', |
|
| 680 | + 'name' => '<h3>' . __('Google Address Auto Complete', 'invoicing') . '</h3>', |
|
| 681 | 681 | 'type' => 'header', |
| 682 | 682 | ), |
| 683 | 683 | 'address_autofill_active' => array( |
| 684 | 684 | 'id' => 'address_autofill_active', |
| 685 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 686 | - 'desc' => __( 'Enable google address auto complete', 'invoicing' ), |
|
| 685 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 686 | + 'desc' => __('Enable google address auto complete', 'invoicing'), |
|
| 687 | 687 | 'type' => 'checkbox', |
| 688 | 688 | 'std' => 0 |
| 689 | 689 | ), |
| 690 | 690 | 'address_autofill_api' => array( |
| 691 | 691 | 'id' => 'address_autofill_api', |
| 692 | - 'name' => __( 'Google Place API Key', 'invoicing' ), |
|
| 693 | - 'desc' => wp_sprintf(__( 'Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing' ), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>' ), |
|
| 692 | + 'name' => __('Google Place API Key', 'invoicing'), |
|
| 693 | + 'desc' => wp_sprintf(__('Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing'), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>'), |
|
| 694 | 694 | 'type' => 'text', |
| 695 | 695 | 'size' => 'regular', |
| 696 | 696 | 'std' => '' |
@@ -704,8 +704,8 @@ discard block |
||
| 704 | 704 | 'main' => array( |
| 705 | 705 | 'tool_settings' => array( |
| 706 | 706 | 'id' => 'tool_settings', |
| 707 | - 'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>', |
|
| 708 | - 'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ), |
|
| 707 | + 'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>', |
|
| 708 | + 'desc' => __('Invoicing diagnostic tools', 'invoicing'), |
|
| 709 | 709 | 'type' => 'tools', |
| 710 | 710 | ), |
| 711 | 711 | ), |
@@ -713,135 +713,135 @@ discard block |
||
| 713 | 713 | ) |
| 714 | 714 | ); |
| 715 | 715 | |
| 716 | - return apply_filters( 'wpinv_registered_settings', $wpinv_settings ); |
|
| 716 | + return apply_filters('wpinv_registered_settings', $wpinv_settings); |
|
| 717 | 717 | } |
| 718 | 718 | |
| 719 | -function wpinv_settings_sanitize( $input = array() ) { |
|
| 719 | +function wpinv_settings_sanitize($input = array()) { |
|
| 720 | 720 | global $wpinv_options; |
| 721 | 721 | |
| 722 | - if ( empty( $_POST['_wp_http_referer'] ) ) { |
|
| 722 | + if (empty($_POST['_wp_http_referer'])) { |
|
| 723 | 723 | return $input; |
| 724 | 724 | } |
| 725 | 725 | |
| 726 | - parse_str( $_POST['_wp_http_referer'], $referrer ); |
|
| 726 | + parse_str($_POST['_wp_http_referer'], $referrer); |
|
| 727 | 727 | |
| 728 | 728 | $settings = wpinv_get_registered_settings(); |
| 729 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
| 730 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
| 729 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
| 730 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
| 731 | 731 | |
| 732 | 732 | $input = $input ? $input : array(); |
| 733 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
| 734 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
| 733 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
| 734 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
| 735 | 735 | |
| 736 | 736 | // Loop through each setting being saved and pass it through a sanitization filter |
| 737 | - foreach ( $input as $key => $value ) { |
|
| 737 | + foreach ($input as $key => $value) { |
|
| 738 | 738 | // Get the setting type (checkbox, select, etc) |
| 739 | - $type = isset( $settings[ $tab ][ $key ]['type'] ) ? $settings[ $tab ][ $key ]['type'] : false; |
|
| 739 | + $type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false; |
|
| 740 | 740 | |
| 741 | - if ( $type ) { |
|
| 741 | + if ($type) { |
|
| 742 | 742 | // Field type specific filter |
| 743 | - $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key ); |
|
| 743 | + $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key); |
|
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | // General filter |
| 747 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
| 747 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | // Loop through the whitelist and unset any that are empty for the tab being saved |
| 751 | - $main_settings = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
| 752 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
| 751 | + $main_settings = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
| 752 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
| 753 | 753 | |
| 754 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
| 754 | + $found_settings = array_merge($main_settings, $section_settings); |
|
| 755 | 755 | |
| 756 | - if ( ! empty( $found_settings ) ) { |
|
| 757 | - foreach ( $found_settings as $key => $value ) { |
|
| 756 | + if (!empty($found_settings)) { |
|
| 757 | + foreach ($found_settings as $key => $value) { |
|
| 758 | 758 | |
| 759 | 759 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
| 760 | - if ( is_numeric( $key ) ) { |
|
| 760 | + if (is_numeric($key)) { |
|
| 761 | 761 | $key = $value['id']; |
| 762 | 762 | } |
| 763 | 763 | |
| 764 | - if ( empty( $input[ $key ] ) ) { |
|
| 765 | - unset( $wpinv_options[ $key ] ); |
|
| 764 | + if (empty($input[$key])) { |
|
| 765 | + unset($wpinv_options[$key]); |
|
| 766 | 766 | } |
| 767 | 767 | } |
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | // Merge our new settings with the existing |
| 771 | - $output = array_merge( $wpinv_options, $input ); |
|
| 771 | + $output = array_merge($wpinv_options, $input); |
|
| 772 | 772 | |
| 773 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
| 773 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
| 774 | 774 | |
| 775 | 775 | return $output; |
| 776 | 776 | } |
| 777 | 777 | |
| 778 | -function wpinv_settings_sanitize_misc_accounting( $input ) { |
|
| 778 | +function wpinv_settings_sanitize_misc_accounting($input) { |
|
| 779 | 779 | global $wpinv_options, $wpi_session; |
| 780 | 780 | |
| 781 | - if ( !current_user_can( 'manage_options' ) ) { |
|
| 781 | + if (!current_user_can('manage_options')) { |
|
| 782 | 782 | return $input; |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | - if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) { |
|
| 785 | + if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) { |
|
| 786 | 786 | // Shows an admin notice about upgrading previous order numbers |
| 787 | - $wpi_session->set( 'upgrade_sequential', '1' ); |
|
| 787 | + $wpi_session->set('upgrade_sequential', '1'); |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | return $input; |
| 791 | 791 | } |
| 792 | -add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' ); |
|
| 792 | +add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting'); |
|
| 793 | 793 | |
| 794 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
| 795 | - if( !current_user_can( 'manage_options' ) ) { |
|
| 794 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
| 795 | + if (!current_user_can('manage_options')) { |
|
| 796 | 796 | return $input; |
| 797 | 797 | } |
| 798 | 798 | |
| 799 | - $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array(); |
|
| 799 | + $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array(); |
|
| 800 | 800 | |
| 801 | 801 | $tax_rates = array(); |
| 802 | 802 | |
| 803 | - if ( !empty( $new_rates ) ) { |
|
| 804 | - foreach ( $new_rates as $rate ) { |
|
| 805 | - if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) { |
|
| 803 | + if (!empty($new_rates)) { |
|
| 804 | + foreach ($new_rates as $rate) { |
|
| 805 | + if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) { |
|
| 806 | 806 | continue; |
| 807 | 807 | } |
| 808 | 808 | |
| 809 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'], 4 ); |
|
| 809 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4); |
|
| 810 | 810 | |
| 811 | 811 | $tax_rates[] = $rate; |
| 812 | 812 | } |
| 813 | 813 | } |
| 814 | 814 | |
| 815 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
| 815 | + update_option('wpinv_tax_rates', $tax_rates); |
|
| 816 | 816 | |
| 817 | 817 | return $input; |
| 818 | 818 | } |
| 819 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
| 819 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
| 820 | 820 | |
| 821 | -function wpinv_sanitize_text_field( $input ) { |
|
| 822 | - return trim( $input ); |
|
| 821 | +function wpinv_sanitize_text_field($input) { |
|
| 822 | + return trim($input); |
|
| 823 | 823 | } |
| 824 | -add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' ); |
|
| 824 | +add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field'); |
|
| 825 | 825 | |
| 826 | 826 | function wpinv_get_settings_tabs() { |
| 827 | 827 | $tabs = array(); |
| 828 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
| 829 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
| 830 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
| 831 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
| 832 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
| 833 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
| 834 | - |
|
| 835 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
| 828 | + $tabs['general'] = __('General', 'invoicing'); |
|
| 829 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
| 830 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
| 831 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
| 832 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
| 833 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
| 834 | + |
|
| 835 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
| 838 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
| 839 | 839 | $tabs = false; |
| 840 | 840 | $sections = wpinv_get_registered_settings_sections(); |
| 841 | 841 | |
| 842 | - if( $tab && ! empty( $sections[ $tab ] ) ) { |
|
| 843 | - $tabs = $sections[ $tab ]; |
|
| 844 | - } else if ( $tab ) { |
|
| 842 | + if ($tab && !empty($sections[$tab])) { |
|
| 843 | + $tabs = $sections[$tab]; |
|
| 844 | + } else if ($tab) { |
|
| 845 | 845 | $tabs = false; |
| 846 | 846 | } |
| 847 | 847 | |
@@ -851,136 +851,136 @@ discard block |
||
| 851 | 851 | function wpinv_get_registered_settings_sections() { |
| 852 | 852 | static $sections = false; |
| 853 | 853 | |
| 854 | - if ( false !== $sections ) { |
|
| 854 | + if (false !== $sections) { |
|
| 855 | 855 | return $sections; |
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | $sections = array( |
| 859 | - 'general' => apply_filters( 'wpinv_settings_sections_general', array( |
|
| 860 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
| 861 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
| 862 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
| 863 | - ) ), |
|
| 864 | - 'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array( |
|
| 865 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
| 866 | - ) ), |
|
| 867 | - 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
|
| 868 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
| 869 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
| 870 | - ) ), |
|
| 871 | - 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
|
| 872 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
| 873 | - ) ), |
|
| 874 | - 'misc' => apply_filters( 'wpinv_settings_sections_misc', array( |
|
| 875 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
| 876 | - 'fields' => __( 'Fields Settings', 'invoicing' ), |
|
| 877 | - ) ), |
|
| 878 | - 'tools' => apply_filters( 'wpinv_settings_sections_tools', array( |
|
| 879 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
| 880 | - ) ), |
|
| 859 | + 'general' => apply_filters('wpinv_settings_sections_general', array( |
|
| 860 | + 'main' => __('General Settings', 'invoicing'), |
|
| 861 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
| 862 | + 'labels' => __('Label Texts', 'invoicing'), |
|
| 863 | + )), |
|
| 864 | + 'gateways' => apply_filters('wpinv_settings_sections_gateways', array( |
|
| 865 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
| 866 | + )), |
|
| 867 | + 'taxes' => apply_filters('wpinv_settings_sections_taxes', array( |
|
| 868 | + 'main' => __('Tax Settings', 'invoicing'), |
|
| 869 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
| 870 | + )), |
|
| 871 | + 'emails' => apply_filters('wpinv_settings_sections_emails', array( |
|
| 872 | + 'main' => __('Email Settings', 'invoicing'), |
|
| 873 | + )), |
|
| 874 | + 'misc' => apply_filters('wpinv_settings_sections_misc', array( |
|
| 875 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
| 876 | + 'fields' => __('Fields Settings', 'invoicing'), |
|
| 877 | + )), |
|
| 878 | + 'tools' => apply_filters('wpinv_settings_sections_tools', array( |
|
| 879 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
| 880 | + )), |
|
| 881 | 881 | ); |
| 882 | 882 | |
| 883 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
| 883 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
| 884 | 884 | |
| 885 | 885 | return $sections; |
| 886 | 886 | } |
| 887 | 887 | |
| 888 | -function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
|
| 888 | +function wpinv_get_pages($with_slug = false, $default_label = NULL) { |
|
| 889 | 889 | $pages_options = array(); |
| 890 | 890 | |
| 891 | - if( $default_label !== NULL && $default_label !== false ) { |
|
| 892 | - $pages_options = array( '' => $default_label ); // Blank option |
|
| 891 | + if ($default_label !== NULL && $default_label !== false) { |
|
| 892 | + $pages_options = array('' => $default_label); // Blank option |
|
| 893 | 893 | } |
| 894 | 894 | |
| 895 | 895 | $pages = get_pages(); |
| 896 | - if ( $pages ) { |
|
| 897 | - foreach ( $pages as $page ) { |
|
| 896 | + if ($pages) { |
|
| 897 | + foreach ($pages as $page) { |
|
| 898 | 898 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
| 899 | - $pages_options[ $page->ID ] = $title; |
|
| 899 | + $pages_options[$page->ID] = $title; |
|
| 900 | 900 | } |
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | return $pages_options; |
| 904 | 904 | } |
| 905 | 905 | |
| 906 | -function wpinv_header_callback( $args ) { |
|
| 907 | - if ( !empty( $args['desc'] ) ) { |
|
| 906 | +function wpinv_header_callback($args) { |
|
| 907 | + if (!empty($args['desc'])) { |
|
| 908 | 908 | echo $args['desc']; |
| 909 | 909 | } |
| 910 | 910 | } |
| 911 | 911 | |
| 912 | -function wpinv_hidden_callback( $args ) { |
|
| 912 | +function wpinv_hidden_callback($args) { |
|
| 913 | 913 | global $wpinv_options; |
| 914 | 914 | |
| 915 | - if ( isset( $args['set_value'] ) ) { |
|
| 915 | + if (isset($args['set_value'])) { |
|
| 916 | 916 | $value = $args['set_value']; |
| 917 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 918 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 917 | + } elseif (isset($wpinv_options[$args['id']])) { |
|
| 918 | + $value = $wpinv_options[$args['id']]; |
|
| 919 | 919 | } else { |
| 920 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 920 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 923 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 924 | 924 | $args['readonly'] = true; |
| 925 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 925 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 926 | 926 | $name = ''; |
| 927 | 927 | } else { |
| 928 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 928 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
| 929 | 929 | } |
| 930 | 930 | |
| 931 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 931 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
| 932 | 932 | |
| 933 | 933 | echo $html; |
| 934 | 934 | } |
| 935 | 935 | |
| 936 | -function wpinv_checkbox_callback( $args ) { |
|
| 936 | +function wpinv_checkbox_callback($args) { |
|
| 937 | 937 | global $wpinv_options; |
| 938 | 938 | |
| 939 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 939 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 940 | 940 | |
| 941 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 941 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 942 | 942 | $name = ''; |
| 943 | 943 | } else { |
| 944 | 944 | $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
| 945 | 945 | } |
| 946 | 946 | |
| 947 | - $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
| 947 | + $checked = isset($wpinv_options[$args['id']]) ? checked(1, $wpinv_options[$args['id']], false) : ''; |
|
| 948 | 948 | $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
| 949 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 949 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 950 | 950 | |
| 951 | 951 | echo $html; |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | -function wpinv_multicheck_callback( $args ) { |
|
| 954 | +function wpinv_multicheck_callback($args) { |
|
| 955 | 955 | global $wpinv_options; |
| 956 | 956 | |
| 957 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 957 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 958 | 958 | |
| 959 | - if ( ! empty( $args['options'] ) ) { |
|
| 960 | - foreach( $args['options'] as $key => $option ): |
|
| 961 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 962 | - if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
| 959 | + if (!empty($args['options'])) { |
|
| 960 | + foreach ($args['options'] as $key => $option): |
|
| 961 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 962 | + if (isset($wpinv_options[$args['id']][$sanitize_key])) { |
|
| 963 | 963 | $enabled = $sanitize_key; |
| 964 | 964 | } else { |
| 965 | 965 | $enabled = NULL; |
| 966 | 966 | } |
| 967 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
| 968 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>'; |
|
| 967 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
| 968 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label><br/>'; |
|
| 969 | 969 | endforeach; |
| 970 | 970 | echo '<p class="description">' . $args['desc'] . '</p>'; |
| 971 | 971 | } |
| 972 | 972 | } |
| 973 | 973 | |
| 974 | -function wpinv_payment_icons_callback( $args ) { |
|
| 974 | +function wpinv_payment_icons_callback($args) { |
|
| 975 | 975 | global $wpinv_options; |
| 976 | 976 | |
| 977 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 977 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 978 | 978 | |
| 979 | - if ( ! empty( $args['options'] ) ) { |
|
| 980 | - foreach( $args['options'] as $key => $option ) { |
|
| 981 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 979 | + if (!empty($args['options'])) { |
|
| 980 | + foreach ($args['options'] as $key => $option) { |
|
| 981 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 982 | 982 | |
| 983 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
| 983 | + if (isset($wpinv_options[$args['id']][$key])) { |
|
| 984 | 984 | $enabled = $option; |
| 985 | 985 | } else { |
| 986 | 986 | $enabled = NULL; |
@@ -988,196 +988,196 @@ discard block |
||
| 988 | 988 | |
| 989 | 989 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
| 990 | 990 | |
| 991 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
| 991 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
| 992 | 992 | |
| 993 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
| 994 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 993 | + if (wpinv_string_is_image_url($key)) { |
|
| 994 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 995 | 995 | } else { |
| 996 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 996 | + $card = strtolower(str_replace(' ', '', $option)); |
|
| 997 | 997 | |
| 998 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 999 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 998 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
| 999 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
| 1000 | 1000 | } else { |
| 1001 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 1001 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
| 1002 | 1002 | $content_dir = WP_CONTENT_DIR; |
| 1003 | 1003 | |
| 1004 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 1004 | + if (function_exists('wp_normalize_path')) { |
|
| 1005 | 1005 | // Replaces backslashes with forward slashes for Windows systems |
| 1006 | - $image = wp_normalize_path( $image ); |
|
| 1007 | - $content_dir = wp_normalize_path( $content_dir ); |
|
| 1006 | + $image = wp_normalize_path($image); |
|
| 1007 | + $content_dir = wp_normalize_path($content_dir); |
|
| 1008 | 1008 | } |
| 1009 | 1009 | |
| 1010 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
| 1010 | + $image = str_replace($content_dir, content_url(), $image); |
|
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 1013 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 1014 | 1014 | } |
| 1015 | 1015 | echo $option . '</label>'; |
| 1016 | 1016 | } |
| 1017 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 1017 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
| 1018 | 1018 | } |
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | -function wpinv_radio_callback( $args ) { |
|
| 1021 | +function wpinv_radio_callback($args) { |
|
| 1022 | 1022 | global $wpinv_options; |
| 1023 | 1023 | |
| 1024 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1024 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1025 | 1025 | |
| 1026 | - foreach ( $args['options'] as $key => $option ) : |
|
| 1027 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 1026 | + foreach ($args['options'] as $key => $option) : |
|
| 1027 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 1028 | 1028 | |
| 1029 | 1029 | $checked = false; |
| 1030 | 1030 | |
| 1031 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
| 1031 | + if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key) |
|
| 1032 | 1032 | $checked = true; |
| 1033 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
| 1033 | + elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']])) |
|
| 1034 | 1034 | $checked = true; |
| 1035 | 1035 | |
| 1036 | 1036 | echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
| 1037 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
| 1037 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>'; |
|
| 1038 | 1038 | endforeach; |
| 1039 | 1039 | |
| 1040 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 1040 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | -function wpinv_gateways_callback( $args ) { |
|
| 1043 | +function wpinv_gateways_callback($args) { |
|
| 1044 | 1044 | global $wpinv_options; |
| 1045 | 1045 | |
| 1046 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1046 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1047 | 1047 | |
| 1048 | - foreach ( $args['options'] as $key => $option ) : |
|
| 1049 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 1048 | + foreach ($args['options'] as $key => $option) : |
|
| 1049 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 1050 | 1050 | |
| 1051 | - if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
|
| 1051 | + if (isset($wpinv_options['gateways'][$key])) |
|
| 1052 | 1052 | $enabled = '1'; |
| 1053 | 1053 | else |
| 1054 | 1054 | $enabled = null; |
| 1055 | 1055 | |
| 1056 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
| 1057 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
| 1056 | + echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
| 1057 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>'; |
|
| 1058 | 1058 | endforeach; |
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | 1061 | function wpinv_gateway_select_callback($args) { |
| 1062 | 1062 | global $wpinv_options; |
| 1063 | 1063 | |
| 1064 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1064 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1065 | 1065 | |
| 1066 | 1066 | echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">'; |
| 1067 | 1067 | |
| 1068 | - foreach ( $args['options'] as $key => $option ) : |
|
| 1069 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 1070 | - $selected = selected( $key, $args['selected'], false ); |
|
| 1068 | + foreach ($args['options'] as $key => $option) : |
|
| 1069 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
| 1070 | + $selected = selected($key, $args['selected'], false); |
|
| 1071 | 1071 | } else { |
| 1072 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
|
| 1072 | + $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : ''; |
|
| 1073 | 1073 | } |
| 1074 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 1074 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
| 1075 | 1075 | endforeach; |
| 1076 | 1076 | |
| 1077 | 1077 | echo '</select>'; |
| 1078 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1078 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | -function wpinv_text_callback( $args ) { |
|
| 1081 | +function wpinv_text_callback($args) { |
|
| 1082 | 1082 | global $wpinv_options; |
| 1083 | 1083 | |
| 1084 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1084 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1085 | 1085 | |
| 1086 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1087 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1086 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1087 | + $value = $wpinv_options[$args['id']]; |
|
| 1088 | 1088 | } else { |
| 1089 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1089 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1092 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 1093 | 1093 | $args['readonly'] = true; |
| 1094 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1094 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1095 | 1095 | $name = ''; |
| 1096 | 1096 | } else { |
| 1097 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 1097 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
| 1098 | 1098 | } |
| 1099 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
| 1099 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
| 1100 | 1100 | |
| 1101 | 1101 | $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
| 1102 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1103 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
| 1104 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1102 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1103 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>'; |
|
| 1104 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1105 | 1105 | |
| 1106 | 1106 | echo $html; |
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | -function wpinv_number_callback( $args ) { |
|
| 1109 | +function wpinv_number_callback($args) { |
|
| 1110 | 1110 | global $wpinv_options; |
| 1111 | 1111 | |
| 1112 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1112 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1113 | 1113 | |
| 1114 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1115 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1114 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1115 | + $value = $wpinv_options[$args['id']]; |
|
| 1116 | 1116 | } else { |
| 1117 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1117 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1118 | 1118 | } |
| 1119 | 1119 | |
| 1120 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1120 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 1121 | 1121 | $args['readonly'] = true; |
| 1122 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1122 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1123 | 1123 | $name = ''; |
| 1124 | 1124 | } else { |
| 1125 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 1125 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
| 1129 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
| 1130 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
| 1131 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
| 1128 | + $max = isset($args['max']) ? $args['max'] : 999999; |
|
| 1129 | + $min = isset($args['min']) ? $args['min'] : 0; |
|
| 1130 | + $step = isset($args['step']) ? $args['step'] : 1; |
|
| 1131 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
| 1132 | 1132 | |
| 1133 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1134 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1135 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1133 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1134 | + $html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
| 1135 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1136 | 1136 | |
| 1137 | 1137 | echo $html; |
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | -function wpinv_textarea_callback( $args ) { |
|
| 1140 | +function wpinv_textarea_callback($args) { |
|
| 1141 | 1141 | global $wpinv_options; |
| 1142 | 1142 | |
| 1143 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1143 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1144 | 1144 | |
| 1145 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1146 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1145 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1146 | + $value = $wpinv_options[$args['id']]; |
|
| 1147 | 1147 | } else { |
| 1148 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1148 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1149 | 1149 | } |
| 1150 | 1150 | |
| 1151 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1152 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
| 1151 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1152 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
| 1153 | 1153 | |
| 1154 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1155 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1154 | + $html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
| 1155 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1156 | 1156 | |
| 1157 | 1157 | echo $html; |
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | -function wpinv_password_callback( $args ) { |
|
| 1160 | +function wpinv_password_callback($args) { |
|
| 1161 | 1161 | global $wpinv_options; |
| 1162 | 1162 | |
| 1163 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1163 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1164 | 1164 | |
| 1165 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1166 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1165 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1166 | + $value = $wpinv_options[$args['id']]; |
|
| 1167 | 1167 | } else { |
| 1168 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1168 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1172 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
| 1173 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1171 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1172 | + $html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
| 1173 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1174 | 1174 | |
| 1175 | 1175 | echo $html; |
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | 1178 | function wpinv_missing_callback($args) { |
| 1179 | 1179 | printf( |
| 1180 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 1180 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
| 1181 | 1181 | '<strong>' . $args['id'] . '</strong>' |
| 1182 | 1182 | ); |
| 1183 | 1183 | } |
@@ -1185,137 +1185,137 @@ discard block |
||
| 1185 | 1185 | function wpinv_select_callback($args) { |
| 1186 | 1186 | global $wpinv_options; |
| 1187 | 1187 | |
| 1188 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1188 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1189 | 1189 | |
| 1190 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1191 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1190 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1191 | + $value = $wpinv_options[$args['id']]; |
|
| 1192 | 1192 | } else { |
| 1193 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1193 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1194 | 1194 | } |
| 1195 | 1195 | |
| 1196 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 1196 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
| 1197 | 1197 | $value = $args['selected']; |
| 1198 | 1198 | } |
| 1199 | 1199 | |
| 1200 | - if ( isset( $args['placeholder'] ) ) { |
|
| 1200 | + if (isset($args['placeholder'])) { |
|
| 1201 | 1201 | $placeholder = $args['placeholder']; |
| 1202 | 1202 | } else { |
| 1203 | 1203 | $placeholder = ''; |
| 1204 | 1204 | } |
| 1205 | 1205 | |
| 1206 | - if ( isset( $args['chosen'] ) ) { |
|
| 1206 | + if (isset($args['chosen'])) { |
|
| 1207 | 1207 | $chosen = 'class="wpinv-chosen"'; |
| 1208 | 1208 | } else { |
| 1209 | 1209 | $chosen = ''; |
| 1210 | 1210 | } |
| 1211 | 1211 | |
| 1212 | - if( !empty( $args['onchange'] ) ) { |
|
| 1213 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
| 1212 | + if (!empty($args['onchange'])) { |
|
| 1213 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
| 1214 | 1214 | } else { |
| 1215 | 1215 | $onchange = ''; |
| 1216 | 1216 | } |
| 1217 | 1217 | |
| 1218 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
| 1218 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" ' . $chosen . 'data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />'; |
|
| 1219 | 1219 | |
| 1220 | - foreach ( $args['options'] as $option => $name ) { |
|
| 1221 | - $selected = selected( $option, $value, false ); |
|
| 1222 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1220 | + foreach ($args['options'] as $option => $name) { |
|
| 1221 | + $selected = selected($option, $value, false); |
|
| 1222 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
| 1223 | 1223 | } |
| 1224 | 1224 | |
| 1225 | 1225 | $html .= '</select>'; |
| 1226 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1226 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1227 | 1227 | |
| 1228 | 1228 | echo $html; |
| 1229 | 1229 | } |
| 1230 | 1230 | |
| 1231 | -function wpinv_color_select_callback( $args ) { |
|
| 1231 | +function wpinv_color_select_callback($args) { |
|
| 1232 | 1232 | global $wpinv_options; |
| 1233 | 1233 | |
| 1234 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1234 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1235 | 1235 | |
| 1236 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1237 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1236 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1237 | + $value = $wpinv_options[$args['id']]; |
|
| 1238 | 1238 | } else { |
| 1239 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1239 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1240 | 1240 | } |
| 1241 | 1241 | |
| 1242 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 1242 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
| 1243 | 1243 | |
| 1244 | - foreach ( $args['options'] as $option => $color ) { |
|
| 1245 | - $selected = selected( $option, $value, false ); |
|
| 1246 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 1244 | + foreach ($args['options'] as $option => $color) { |
|
| 1245 | + $selected = selected($option, $value, false); |
|
| 1246 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>'; |
|
| 1247 | 1247 | } |
| 1248 | 1248 | |
| 1249 | 1249 | $html .= '</select>'; |
| 1250 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1250 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1251 | 1251 | |
| 1252 | 1252 | echo $html; |
| 1253 | 1253 | } |
| 1254 | 1254 | |
| 1255 | -function wpinv_rich_editor_callback( $args ) { |
|
| 1255 | +function wpinv_rich_editor_callback($args) { |
|
| 1256 | 1256 | global $wpinv_options, $wp_version; |
| 1257 | 1257 | |
| 1258 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1258 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1259 | 1259 | |
| 1260 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1261 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1260 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1261 | + $value = $wpinv_options[$args['id']]; |
|
| 1262 | 1262 | |
| 1263 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 1264 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1263 | + if (empty($args['allow_blank']) && empty($value)) { |
|
| 1264 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1265 | 1265 | } |
| 1266 | 1266 | } else { |
| 1267 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1267 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1268 | 1268 | } |
| 1269 | 1269 | |
| 1270 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 1270 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
| 1271 | 1271 | |
| 1272 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 1272 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
| 1273 | 1273 | ob_start(); |
| 1274 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) ); |
|
| 1274 | + wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows))); |
|
| 1275 | 1275 | $html = ob_get_clean(); |
| 1276 | 1276 | } else { |
| 1277 | - $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1277 | + $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | - $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1280 | + $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1281 | 1281 | |
| 1282 | 1282 | echo $html; |
| 1283 | 1283 | } |
| 1284 | 1284 | |
| 1285 | -function wpinv_upload_callback( $args ) { |
|
| 1285 | +function wpinv_upload_callback($args) { |
|
| 1286 | 1286 | global $wpinv_options; |
| 1287 | 1287 | |
| 1288 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1288 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1289 | 1289 | |
| 1290 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1290 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1291 | 1291 | $value = $wpinv_options[$args['id']]; |
| 1292 | 1292 | } else { |
| 1293 | 1293 | $value = isset($args['std']) ? $args['std'] : ''; |
| 1294 | 1294 | } |
| 1295 | 1295 | |
| 1296 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1297 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1298 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 1299 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1296 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 1297 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
| 1298 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
| 1299 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1300 | 1300 | |
| 1301 | 1301 | echo $html; |
| 1302 | 1302 | } |
| 1303 | 1303 | |
| 1304 | -function wpinv_color_callback( $args ) { |
|
| 1304 | +function wpinv_color_callback($args) { |
|
| 1305 | 1305 | global $wpinv_options; |
| 1306 | 1306 | |
| 1307 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1307 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1308 | 1308 | |
| 1309 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1310 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1309 | + if (isset($wpinv_options[$args['id']])) { |
|
| 1310 | + $value = $wpinv_options[$args['id']]; |
|
| 1311 | 1311 | } else { |
| 1312 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1312 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1313 | 1313 | } |
| 1314 | 1314 | |
| 1315 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1315 | + $default = isset($args['std']) ? $args['std'] : ''; |
|
| 1316 | 1316 | |
| 1317 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
| 1318 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1317 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />'; |
|
| 1318 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1319 | 1319 | |
| 1320 | 1320 | echo $html; |
| 1321 | 1321 | } |
@@ -1323,9 +1323,9 @@ discard block |
||
| 1323 | 1323 | function wpinv_country_states_callback($args) { |
| 1324 | 1324 | global $wpinv_options; |
| 1325 | 1325 | |
| 1326 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 1326 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 1327 | 1327 | |
| 1328 | - if ( isset( $args['placeholder'] ) ) { |
|
| 1328 | + if (isset($args['placeholder'])) { |
|
| 1329 | 1329 | $placeholder = $args['placeholder']; |
| 1330 | 1330 | } else { |
| 1331 | 1331 | $placeholder = ''; |
@@ -1333,17 +1333,17 @@ discard block |
||
| 1333 | 1333 | |
| 1334 | 1334 | $states = wpinv_get_country_states(); |
| 1335 | 1335 | |
| 1336 | - $chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' ); |
|
| 1337 | - $class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
| 1338 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 1336 | + $chosen = ($args['chosen'] ? ' wpinv-chosen' : ''); |
|
| 1337 | + $class = empty($states) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
| 1338 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
| 1339 | 1339 | |
| 1340 | - foreach ( $states as $option => $name ) { |
|
| 1341 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
| 1342 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1340 | + foreach ($states as $option => $name) { |
|
| 1341 | + $selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : ''; |
|
| 1342 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
| 1343 | 1343 | } |
| 1344 | 1344 | |
| 1345 | 1345 | $html .= '</select>'; |
| 1346 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1346 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 1347 | 1347 | |
| 1348 | 1348 | echo $html; |
| 1349 | 1349 | } |
@@ -1358,25 +1358,25 @@ discard block |
||
| 1358 | 1358 | <table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts"> |
| 1359 | 1359 | <thead> |
| 1360 | 1360 | <tr> |
| 1361 | - <th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th> |
|
| 1362 | - <th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th> |
|
| 1363 | - <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e( 'Apply rate to whole country, regardless of state / province', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th> |
|
| 1364 | - <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> |
|
| 1365 | - <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th> |
|
| 1366 | - <th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th> |
|
| 1361 | + <th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th> |
|
| 1362 | + <th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th> |
|
| 1363 | + <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e('Apply rate to whole country, regardless of state / province', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th> |
|
| 1364 | + <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> |
|
| 1365 | + <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th> |
|
| 1366 | + <th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th> |
|
| 1367 | 1367 | </tr> |
| 1368 | 1368 | </thead> |
| 1369 | 1369 | <tbody> |
| 1370 | - <?php if( !empty( $rates ) ) : ?> |
|
| 1371 | - <?php foreach( $rates as $key => $rate ) : ?> |
|
| 1370 | + <?php if (!empty($rates)) : ?> |
|
| 1371 | + <?php foreach ($rates as $key => $rate) : ?> |
|
| 1372 | 1372 | <?php |
| 1373 | - $sanitized_key = wpinv_sanitize_key( $key ); |
|
| 1373 | + $sanitized_key = wpinv_sanitize_key($key); |
|
| 1374 | 1374 | ?> |
| 1375 | 1375 | <tr> |
| 1376 | 1376 | <td class="wpinv_tax_country"> |
| 1377 | 1377 | <?php |
| 1378 | - echo wpinv_html_select( array( |
|
| 1379 | - 'options' => wpinv_get_country_list( true ), |
|
| 1378 | + echo wpinv_html_select(array( |
|
| 1379 | + 'options' => wpinv_get_country_list(true), |
|
| 1380 | 1380 | 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
| 1381 | 1381 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
| 1382 | 1382 | 'selected' => $rate['country'], |
@@ -1384,72 +1384,72 @@ discard block |
||
| 1384 | 1384 | 'show_option_none' => false, |
| 1385 | 1385 | 'class' => 'wpinv-tax-country', |
| 1386 | 1386 | 'chosen' => false, |
| 1387 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1388 | - ) ); |
|
| 1387 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
| 1388 | + )); |
|
| 1389 | 1389 | ?> |
| 1390 | 1390 | </td> |
| 1391 | 1391 | <td class="wpinv_tax_state"> |
| 1392 | 1392 | <?php |
| 1393 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
| 1394 | - if( !empty( $states ) ) { |
|
| 1395 | - echo wpinv_html_select( array( |
|
| 1396 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
| 1393 | + $states = wpinv_get_country_states($rate['country']); |
|
| 1394 | + if (!empty($states)) { |
|
| 1395 | + echo wpinv_html_select(array( |
|
| 1396 | + 'options' => array_merge(array('' => ''), $states), |
|
| 1397 | 1397 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1398 | 1398 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1399 | 1399 | 'selected' => $rate['state'], |
| 1400 | 1400 | 'show_option_all' => false, |
| 1401 | 1401 | 'show_option_none' => false, |
| 1402 | 1402 | 'chosen' => false, |
| 1403 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
| 1404 | - ) ); |
|
| 1403 | + 'placeholder' => __('Choose a state', 'invoicing') |
|
| 1404 | + )); |
|
| 1405 | 1405 | } else { |
| 1406 | - echo wpinv_html_text( array( |
|
| 1406 | + echo wpinv_html_text(array( |
|
| 1407 | 1407 | 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
| 1408 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
| 1408 | + 'value' => !empty($rate['state']) ? $rate['state'] : '', |
|
| 1409 | 1409 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1410 | - ) ); |
|
| 1410 | + )); |
|
| 1411 | 1411 | } |
| 1412 | 1412 | ?> |
| 1413 | 1413 | </td> |
| 1414 | 1414 | <td class="wpinv_tax_global"> |
| 1415 | - <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/> |
|
| 1416 | - <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
| 1415 | + <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked(true, !empty($rate['global'])); ?>/> |
|
| 1416 | + <label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
| 1417 | 1417 | </td> |
| 1418 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html( $rate['rate'] ); ?>"/></td> |
|
| 1419 | - <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html( $rate['name'] ); ?>"/></td> |
|
| 1420 | - <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
| 1418 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html($rate['rate']); ?>"/></td> |
|
| 1419 | + <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html($rate['name']); ?>"/></td> |
|
| 1420 | + <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
| 1421 | 1421 | </tr> |
| 1422 | 1422 | <?php endforeach; ?> |
| 1423 | 1423 | <?php else : ?> |
| 1424 | 1424 | <tr> |
| 1425 | 1425 | <td class="wpinv_tax_country"> |
| 1426 | 1426 | <?php |
| 1427 | - echo wpinv_html_select( array( |
|
| 1428 | - 'options' => wpinv_get_country_list( true ), |
|
| 1427 | + echo wpinv_html_select(array( |
|
| 1428 | + 'options' => wpinv_get_country_list(true), |
|
| 1429 | 1429 | 'name' => 'tax_rates[0][country]', |
| 1430 | 1430 | 'show_option_all' => false, |
| 1431 | 1431 | 'show_option_none' => false, |
| 1432 | 1432 | 'class' => 'wpinv-tax-country', |
| 1433 | 1433 | 'chosen' => false, |
| 1434 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1435 | - ) ); ?> |
|
| 1434 | + 'placeholder' => __('Choose a country', 'invoicing') |
|
| 1435 | + )); ?> |
|
| 1436 | 1436 | </td> |
| 1437 | 1437 | <td class="wpinv_tax_state"> |
| 1438 | - <?php echo wpinv_html_text( array( |
|
| 1438 | + <?php echo wpinv_html_text(array( |
|
| 1439 | 1439 | 'name' => 'tax_rates[0][state]' |
| 1440 | - ) ); ?> |
|
| 1440 | + )); ?> |
|
| 1441 | 1441 | </td> |
| 1442 | 1442 | <td class="wpinv_tax_global"> |
| 1443 | 1443 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
| 1444 | - <label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label> |
|
| 1444 | + <label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label> |
|
| 1445 | 1445 | </td> |
| 1446 | - <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>" value="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>"/></td> |
|
| 1446 | + <td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>" value="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>"/></td> |
|
| 1447 | 1447 | <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td> |
| 1448 | - <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
|
| 1448 | + <td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td> |
|
| 1449 | 1449 | </tr> |
| 1450 | 1450 | <?php endif; ?> |
| 1451 | 1451 | </tbody> |
| 1452 | - <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot> |
|
| 1452 | + <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e('Add Tax Rate', 'invoicing'); ?></span></td></tr></tfoot> |
|
| 1453 | 1453 | </table> |
| 1454 | 1454 | <?php |
| 1455 | 1455 | echo ob_get_clean(); |
@@ -1460,54 +1460,54 @@ discard block |
||
| 1460 | 1460 | ob_start(); ?> |
| 1461 | 1461 | </td><tr> |
| 1462 | 1462 | <td colspan="2" class="wpinv_tools_tdbox"> |
| 1463 | - <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
| 1464 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
| 1463 | + <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
| 1464 | + <?php do_action('wpinv_tools_before'); ?> |
|
| 1465 | 1465 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
| 1466 | 1466 | <thead> |
| 1467 | 1467 | <tr> |
| 1468 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
| 1469 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
| 1470 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
| 1468 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
| 1469 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
| 1470 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
| 1471 | 1471 | </tr> |
| 1472 | 1472 | </thead> |
| 1473 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
| 1473 | + <?php do_action('wpinv_tools_row'); ?> |
|
| 1474 | 1474 | <tbody> |
| 1475 | 1475 | </tbody> |
| 1476 | 1476 | </table> |
| 1477 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
| 1477 | + <?php do_action('wpinv_tools_after'); ?> |
|
| 1478 | 1478 | <?php |
| 1479 | 1479 | echo ob_get_clean(); |
| 1480 | 1480 | } |
| 1481 | 1481 | |
| 1482 | -function wpinv_descriptive_text_callback( $args ) { |
|
| 1483 | - echo wp_kses_post( $args['desc'] ); |
|
| 1482 | +function wpinv_descriptive_text_callback($args) { |
|
| 1483 | + echo wp_kses_post($args['desc']); |
|
| 1484 | 1484 | } |
| 1485 | 1485 | |
| 1486 | -function wpinv_hook_callback( $args ) { |
|
| 1487 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1486 | +function wpinv_hook_callback($args) { |
|
| 1487 | + do_action('wpinv_' . $args['id'], $args); |
|
| 1488 | 1488 | } |
| 1489 | 1489 | |
| 1490 | 1490 | function wpinv_set_settings_cap() { |
| 1491 | 1491 | return 'manage_options'; |
| 1492 | 1492 | } |
| 1493 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
| 1493 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
| 1494 | 1494 | |
| 1495 | -function wpinv_settings_sanitize_input( $value, $key ) { |
|
| 1496 | - if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) { |
|
| 1497 | - $value = wpinv_sanitize_amount( $value, 4 ); |
|
| 1495 | +function wpinv_settings_sanitize_input($value, $key) { |
|
| 1496 | + if ($key == 'tax_rate' || $key == 'eu_fallback_rate') { |
|
| 1497 | + $value = wpinv_sanitize_amount($value, 4); |
|
| 1498 | 1498 | $value = $value >= 100 ? 99 : $value; |
| 1499 | 1499 | } |
| 1500 | 1500 | |
| 1501 | 1501 | return $value; |
| 1502 | 1502 | } |
| 1503 | -add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 ); |
|
| 1503 | +add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2); |
|
| 1504 | 1504 | |
| 1505 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
| 1506 | - $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
| 1507 | - $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
| 1505 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
| 1506 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
| 1507 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
| 1508 | 1508 | |
| 1509 | - if ( $old != $new ) { |
|
| 1510 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
| 1509 | + if ($old != $new) { |
|
| 1510 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
| 1511 | 1511 | } |
| 1512 | 1512 | } |
| 1513 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
| 1514 | 1513 | \ No newline at end of file |
| 1514 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
| 1515 | 1515 | \ No newline at end of file |