@@ -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 | } |
@@ -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' ); |
|
| 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'); |
|
| 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(); |
@@ -7,12 +7,12 @@ 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_init_transactional_emails() { |
| 15 | - $email_actions = apply_filters( 'wpinv_email_actions', array( |
|
| 15 | + $email_actions = apply_filters('wpinv_email_actions', array( |
|
| 16 | 16 | 'wpinv_status_wpi-pending_to_wpi-processing', |
| 17 | 17 | 'wpinv_status_wpi-pending_to_publish', |
| 18 | 18 | 'wpinv_status_wpi-pending_to_wpi-cancelled', |
@@ -28,79 +28,79 @@ discard block |
||
| 28 | 28 | 'wpinv_fully_refunded', |
| 29 | 29 | 'wpinv_partially_refunded', |
| 30 | 30 | 'wpinv_new_invoice_note' |
| 31 | - ) ); |
|
| 31 | + )); |
|
| 32 | 32 | |
| 33 | - foreach ( $email_actions as $action ) { |
|
| 34 | - add_action( $action, 'wpinv_send_transactional_email', 10, 10 ); |
|
| 33 | + foreach ($email_actions as $action) { |
|
| 34 | + add_action($action, 'wpinv_send_transactional_email', 10, 10); |
|
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | -add_action( 'init', 'wpinv_init_transactional_emails' ); |
|
| 37 | +add_action('init', 'wpinv_init_transactional_emails'); |
|
| 38 | 38 | |
| 39 | 39 | // New invoice email |
| 40 | -add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification' ); |
|
| 41 | -add_action( 'wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification' ); |
|
| 42 | -add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' ); |
|
| 43 | -add_action( 'wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification' ); |
|
| 44 | -add_action( 'wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification' ); |
|
| 45 | -add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' ); |
|
| 40 | +add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification'); |
|
| 41 | +add_action('wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification'); |
|
| 42 | +add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification'); |
|
| 43 | +add_action('wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification'); |
|
| 44 | +add_action('wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification'); |
|
| 45 | +add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification'); |
|
| 46 | 46 | |
| 47 | 47 | // Cancelled invoice email |
| 48 | -add_action( 'wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' ); |
|
| 49 | -add_action( 'wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' ); |
|
| 48 | +add_action('wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification'); |
|
| 49 | +add_action('wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification'); |
|
| 50 | 50 | |
| 51 | 51 | // Failed invoice email |
| 52 | -add_action( 'wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' ); |
|
| 53 | -add_action( 'wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' ); |
|
| 52 | +add_action('wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification'); |
|
| 53 | +add_action('wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification'); |
|
| 54 | 54 | |
| 55 | 55 | // On hold invoice email |
| 56 | -add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' ); |
|
| 57 | -add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' ); |
|
| 56 | +add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification'); |
|
| 57 | +add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification'); |
|
| 58 | 58 | |
| 59 | 59 | // Processing invoice email |
| 60 | -add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification' ); |
|
| 60 | +add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification'); |
|
| 61 | 61 | |
| 62 | 62 | // Paid invoice email |
| 63 | -add_action( 'wpinv_status_publish_notification', 'wpinv_completed_invoice_notification' ); |
|
| 63 | +add_action('wpinv_status_publish_notification', 'wpinv_completed_invoice_notification'); |
|
| 64 | 64 | |
| 65 | 65 | // Refunded invoice email |
| 66 | -add_action( 'wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification' ); |
|
| 67 | -add_action( 'wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification' ); |
|
| 66 | +add_action('wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification'); |
|
| 67 | +add_action('wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification'); |
|
| 68 | 68 | |
| 69 | 69 | // Invoice note |
| 70 | -add_action( 'wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification' ); |
|
| 70 | +add_action('wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification'); |
|
| 71 | 71 | |
| 72 | -add_action( 'wpinv_email_header', 'wpinv_email_header' ); |
|
| 73 | -add_action( 'wpinv_email_footer', 'wpinv_email_footer' ); |
|
| 74 | -add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 ); |
|
| 75 | -add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 ); |
|
| 76 | -add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 ); |
|
| 77 | -add_action( 'wpinv_email_before_note_details', 'wpinv_email_before_note_details', 10, 4 ); |
|
| 72 | +add_action('wpinv_email_header', 'wpinv_email_header'); |
|
| 73 | +add_action('wpinv_email_footer', 'wpinv_email_footer'); |
|
| 74 | +add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3); |
|
| 75 | +add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3); |
|
| 76 | +add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3); |
|
| 77 | +add_action('wpinv_email_before_note_details', 'wpinv_email_before_note_details', 10, 4); |
|
| 78 | 78 | |
| 79 | 79 | function wpinv_send_transactional_email() { |
| 80 | 80 | $args = func_get_args(); |
| 81 | 81 | $function = current_filter() . '_notification'; |
| 82 | - do_action_ref_array( $function, $args ); |
|
| 82 | + do_action_ref_array($function, $args); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | -function wpinv_new_invoice_notification( $invoice_id, $new_status = '' ) { |
|
| 85 | +function wpinv_new_invoice_notification($invoice_id, $new_status = '') { |
|
| 86 | 86 | global $wpinv_email_search, $wpinv_email_replace; |
| 87 | 87 | |
| 88 | 88 | $email_type = 'new_invoice'; |
| 89 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 89 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 90 | 90 | return false; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 94 | - if ( empty( $invoice ) ) { |
|
| 93 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 94 | + if (empty($invoice)) { |
|
| 95 | 95 | return false; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
| 98 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
| 99 | 99 | return false; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 103 | - if ( !is_email( $recipient ) ) { |
|
| 102 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 103 | + if (!is_email($recipient)) { |
|
| 104 | 104 | return false; |
| 105 | 105 | } |
| 106 | 106 | |
@@ -117,41 +117,41 @@ discard block |
||
| 117 | 117 | $wpinv_email_search = $search; |
| 118 | 118 | $wpinv_email_replace = $replace; |
| 119 | 119 | |
| 120 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 121 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 122 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 123 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 120 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 121 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 122 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 123 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 124 | 124 | |
| 125 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 125 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 126 | 126 | 'invoice' => $invoice, |
| 127 | 127 | 'email_type' => $email_type, |
| 128 | 128 | 'email_heading' => $email_heading, |
| 129 | 129 | 'sent_to_admin' => true, |
| 130 | 130 | 'plain_text' => false, |
| 131 | - ) ); |
|
| 131 | + )); |
|
| 132 | 132 | |
| 133 | - return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 133 | + return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | -function wpinv_cancelled_invoice_notification( $invoice_id, $new_status = '' ) { |
|
| 136 | +function wpinv_cancelled_invoice_notification($invoice_id, $new_status = '') { |
|
| 137 | 137 | global $wpinv_email_search, $wpinv_email_replace; |
| 138 | 138 | |
| 139 | 139 | $email_type = 'cancelled_invoice'; |
| 140 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 140 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 141 | 141 | return false; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 145 | - if ( empty( $invoice ) ) { |
|
| 144 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 145 | + if (empty($invoice)) { |
|
| 146 | 146 | return false; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
| 149 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
| 150 | 150 | return false; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 154 | - if ( !is_email( $recipient ) ) { |
|
| 153 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 154 | + if (!is_email($recipient)) { |
|
| 155 | 155 | return false; |
| 156 | 156 | } |
| 157 | 157 | |
@@ -168,41 +168,41 @@ discard block |
||
| 168 | 168 | $wpinv_email_search = $search; |
| 169 | 169 | $wpinv_email_replace = $replace; |
| 170 | 170 | |
| 171 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 172 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 173 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 174 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 171 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 172 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 173 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 174 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 175 | 175 | |
| 176 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 176 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 177 | 177 | 'invoice' => $invoice, |
| 178 | 178 | 'email_type' => $email_type, |
| 179 | 179 | 'email_heading' => $email_heading, |
| 180 | 180 | 'sent_to_admin' => true, |
| 181 | 181 | 'plain_text' => false, |
| 182 | - ) ); |
|
| 182 | + )); |
|
| 183 | 183 | |
| 184 | - return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 184 | + return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | -function wpinv_failed_invoice_notification( $invoice_id, $new_status = '' ) { |
|
| 187 | +function wpinv_failed_invoice_notification($invoice_id, $new_status = '') { |
|
| 188 | 188 | global $wpinv_email_search, $wpinv_email_replace; |
| 189 | 189 | |
| 190 | 190 | $email_type = 'failed_invoice'; |
| 191 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 191 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 192 | 192 | return false; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 196 | - if ( empty( $invoice ) ) { |
|
| 195 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 196 | + if (empty($invoice)) { |
|
| 197 | 197 | return false; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
| 200 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
| 201 | 201 | return false; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 205 | - if ( !is_email( $recipient ) ) { |
|
| 204 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 205 | + if (!is_email($recipient)) { |
|
| 206 | 206 | return false; |
| 207 | 207 | } |
| 208 | 208 | |
@@ -219,41 +219,41 @@ discard block |
||
| 219 | 219 | $wpinv_email_search = $search; |
| 220 | 220 | $wpinv_email_replace = $replace; |
| 221 | 221 | |
| 222 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 223 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 224 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 225 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 222 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 223 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 224 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 225 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 226 | 226 | |
| 227 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 227 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 228 | 228 | 'invoice' => $invoice, |
| 229 | 229 | 'email_type' => $email_type, |
| 230 | 230 | 'email_heading' => $email_heading, |
| 231 | 231 | 'sent_to_admin' => true, |
| 232 | 232 | 'plain_text' => false, |
| 233 | - ) ); |
|
| 233 | + )); |
|
| 234 | 234 | |
| 235 | - return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 235 | + return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | -function wpinv_onhold_invoice_notification( $invoice_id, $new_status = '' ) { |
|
| 238 | +function wpinv_onhold_invoice_notification($invoice_id, $new_status = '') { |
|
| 239 | 239 | global $wpinv_email_search, $wpinv_email_replace; |
| 240 | 240 | |
| 241 | 241 | $email_type = 'onhold_invoice'; |
| 242 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 242 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 243 | 243 | return false; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 247 | - if ( empty( $invoice ) ) { |
|
| 246 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 247 | + if (empty($invoice)) { |
|
| 248 | 248 | return false; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
| 251 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
| 252 | 252 | return false; |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 256 | - if ( !is_email( $recipient ) ) { |
|
| 255 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 256 | + if (!is_email($recipient)) { |
|
| 257 | 257 | return false; |
| 258 | 258 | } |
| 259 | 259 | |
@@ -270,49 +270,49 @@ discard block |
||
| 270 | 270 | $wpinv_email_search = $search; |
| 271 | 271 | $wpinv_email_replace = $replace; |
| 272 | 272 | |
| 273 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 274 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 275 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 276 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 273 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 274 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 275 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 276 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 277 | 277 | |
| 278 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 278 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 279 | 279 | 'invoice' => $invoice, |
| 280 | 280 | 'email_type' => $email_type, |
| 281 | 281 | 'email_heading' => $email_heading, |
| 282 | 282 | 'sent_to_admin' => false, |
| 283 | 283 | 'plain_text' => false, |
| 284 | - ) ); |
|
| 284 | + )); |
|
| 285 | 285 | |
| 286 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 286 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 287 | 287 | |
| 288 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
| 289 | - $recipient = wpinv_get_admin_email(); |
|
| 290 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 291 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 288 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
| 289 | + $recipient = wpinv_get_admin_email(); |
|
| 290 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 291 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | return $sent; |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | -function wpinv_processing_invoice_notification( $invoice_id, $new_status = '' ) { |
|
| 297 | +function wpinv_processing_invoice_notification($invoice_id, $new_status = '') { |
|
| 298 | 298 | global $wpinv_email_search, $wpinv_email_replace; |
| 299 | 299 | |
| 300 | 300 | $email_type = 'processing_invoice'; |
| 301 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 301 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 302 | 302 | return false; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 306 | - if ( empty( $invoice ) ) { |
|
| 305 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 306 | + if (empty($invoice)) { |
|
| 307 | 307 | return false; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
| 310 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
| 311 | 311 | return false; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 315 | - if ( !is_email( $recipient ) ) { |
|
| 314 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 315 | + if (!is_email($recipient)) { |
|
| 316 | 316 | return false; |
| 317 | 317 | } |
| 318 | 318 | |
@@ -329,49 +329,49 @@ discard block |
||
| 329 | 329 | $wpinv_email_search = $search; |
| 330 | 330 | $wpinv_email_replace = $replace; |
| 331 | 331 | |
| 332 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 333 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 334 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 335 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 332 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 333 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 334 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 335 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 336 | 336 | |
| 337 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 337 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 338 | 338 | 'invoice' => $invoice, |
| 339 | 339 | 'email_type' => $email_type, |
| 340 | 340 | 'email_heading' => $email_heading, |
| 341 | 341 | 'sent_to_admin' => false, |
| 342 | 342 | 'plain_text' => false, |
| 343 | - ) ); |
|
| 343 | + )); |
|
| 344 | 344 | |
| 345 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 345 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 346 | 346 | |
| 347 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
| 348 | - $recipient = wpinv_get_admin_email(); |
|
| 349 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 350 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 347 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
| 348 | + $recipient = wpinv_get_admin_email(); |
|
| 349 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 350 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | return $sent; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | -function wpinv_completed_invoice_notification( $invoice_id, $new_status = '' ) { |
|
| 356 | +function wpinv_completed_invoice_notification($invoice_id, $new_status = '') { |
|
| 357 | 357 | global $wpinv_email_search, $wpinv_email_replace; |
| 358 | 358 | |
| 359 | 359 | $email_type = 'completed_invoice'; |
| 360 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 360 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 361 | 361 | return false; |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 365 | - if ( empty( $invoice ) ) { |
|
| 364 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 365 | + if (empty($invoice)) { |
|
| 366 | 366 | return false; |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
| 369 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
| 370 | 370 | return false; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 374 | - if ( !is_email( $recipient ) ) { |
|
| 373 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 374 | + if (!is_email($recipient)) { |
|
| 375 | 375 | return false; |
| 376 | 376 | } |
| 377 | 377 | |
@@ -388,49 +388,49 @@ discard block |
||
| 388 | 388 | $wpinv_email_search = $search; |
| 389 | 389 | $wpinv_email_replace = $replace; |
| 390 | 390 | |
| 391 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 392 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 393 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 394 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 391 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 392 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 393 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 394 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 395 | 395 | |
| 396 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 396 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 397 | 397 | 'invoice' => $invoice, |
| 398 | 398 | 'email_type' => $email_type, |
| 399 | 399 | 'email_heading' => $email_heading, |
| 400 | 400 | 'sent_to_admin' => false, |
| 401 | 401 | 'plain_text' => false, |
| 402 | - ) ); |
|
| 402 | + )); |
|
| 403 | 403 | |
| 404 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 404 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 405 | 405 | |
| 406 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
| 407 | - $recipient = wpinv_get_admin_email(); |
|
| 408 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 409 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 406 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
| 407 | + $recipient = wpinv_get_admin_email(); |
|
| 408 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 409 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | return $sent; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | -function wpinv_fully_refunded_notification( $invoice_id, $new_status = '' ) { |
|
| 415 | +function wpinv_fully_refunded_notification($invoice_id, $new_status = '') { |
|
| 416 | 416 | global $wpinv_email_search, $wpinv_email_replace; |
| 417 | 417 | |
| 418 | 418 | $email_type = 'refunded_invoice'; |
| 419 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 419 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 420 | 420 | return false; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 424 | - if ( empty( $invoice ) ) { |
|
| 423 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 424 | + if (empty($invoice)) { |
|
| 425 | 425 | return false; |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
| 428 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
| 429 | 429 | return false; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 433 | - if ( !is_email( $recipient ) ) { |
|
| 432 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 433 | + if (!is_email($recipient)) { |
|
| 434 | 434 | return false; |
| 435 | 435 | } |
| 436 | 436 | |
@@ -447,50 +447,50 @@ discard block |
||
| 447 | 447 | $wpinv_email_search = $search; |
| 448 | 448 | $wpinv_email_replace = $replace; |
| 449 | 449 | |
| 450 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 451 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 452 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 453 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 450 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 451 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 452 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 453 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 454 | 454 | |
| 455 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 455 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 456 | 456 | 'invoice' => $invoice, |
| 457 | 457 | 'email_type' => $email_type, |
| 458 | 458 | 'email_heading' => $email_heading, |
| 459 | 459 | 'sent_to_admin' => false, |
| 460 | 460 | 'plain_text' => false, |
| 461 | 461 | 'partial_refund' => false |
| 462 | - ) ); |
|
| 462 | + )); |
|
| 463 | 463 | |
| 464 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 464 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 465 | 465 | |
| 466 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
| 467 | - $recipient = wpinv_get_admin_email(); |
|
| 468 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 469 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 466 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
| 467 | + $recipient = wpinv_get_admin_email(); |
|
| 468 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 469 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | return $sent; |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | -function wpinv_partially_refunded_notification( $invoice_id, $new_status = '' ) { |
|
| 475 | +function wpinv_partially_refunded_notification($invoice_id, $new_status = '') { |
|
| 476 | 476 | global $wpinv_email_search, $wpinv_email_replace; |
| 477 | 477 | |
| 478 | 478 | $email_type = 'refunded_invoice'; |
| 479 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 479 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 480 | 480 | return false; |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 484 | - if ( empty( $invoice ) ) { |
|
| 483 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 484 | + if (empty($invoice)) { |
|
| 485 | 485 | return false; |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
| 488 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
| 489 | 489 | return false; |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 493 | - if ( !is_email( $recipient ) ) { |
|
| 492 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 493 | + if (!is_email($recipient)) { |
|
| 494 | 494 | return false; |
| 495 | 495 | } |
| 496 | 496 | |
@@ -507,53 +507,53 @@ discard block |
||
| 507 | 507 | $wpinv_email_search = $search; |
| 508 | 508 | $wpinv_email_replace = $replace; |
| 509 | 509 | |
| 510 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 511 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 512 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 513 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 510 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 511 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 512 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 513 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 514 | 514 | |
| 515 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 515 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 516 | 516 | 'invoice' => $invoice, |
| 517 | 517 | 'email_type' => $email_type, |
| 518 | 518 | 'email_heading' => $email_heading, |
| 519 | 519 | 'sent_to_admin' => false, |
| 520 | 520 | 'plain_text' => false, |
| 521 | 521 | 'partial_refund' => true |
| 522 | - ) ); |
|
| 522 | + )); |
|
| 523 | 523 | |
| 524 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 524 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 525 | 525 | |
| 526 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
| 527 | - $recipient = wpinv_get_admin_email(); |
|
| 528 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 529 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 526 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
| 527 | + $recipient = wpinv_get_admin_email(); |
|
| 528 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 529 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | return $sent; |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | -function wpinv_new_invoice_note_notification( $invoice_id, $new_status = '' ) { |
|
| 535 | +function wpinv_new_invoice_note_notification($invoice_id, $new_status = '') { |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | -function wpinv_user_invoice_notification( $invoice_id ) { |
|
| 538 | +function wpinv_user_invoice_notification($invoice_id) { |
|
| 539 | 539 | global $wpinv_email_search, $wpinv_email_replace; |
| 540 | 540 | |
| 541 | 541 | $email_type = 'user_invoice'; |
| 542 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 542 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 543 | 543 | return false; |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 547 | - if ( empty( $invoice ) ) { |
|
| 546 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 547 | + if (empty($invoice)) { |
|
| 548 | 548 | return false; |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
| 551 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
| 552 | 552 | return false; |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 556 | - if ( !is_email( $recipient ) ) { |
|
| 555 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 556 | + if (!is_email($recipient)) { |
|
| 557 | 557 | return false; |
| 558 | 558 | } |
| 559 | 559 | |
@@ -570,53 +570,53 @@ discard block |
||
| 570 | 570 | $wpinv_email_search = $search; |
| 571 | 571 | $wpinv_email_replace = $replace; |
| 572 | 572 | |
| 573 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 574 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 575 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 576 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 573 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 574 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 575 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 576 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 577 | 577 | |
| 578 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 578 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 579 | 579 | 'invoice' => $invoice, |
| 580 | 580 | 'email_type' => $email_type, |
| 581 | 581 | 'email_heading' => $email_heading, |
| 582 | 582 | 'sent_to_admin' => false, |
| 583 | 583 | 'plain_text' => false, |
| 584 | - ) ); |
|
| 584 | + )); |
|
| 585 | 585 | |
| 586 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 586 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 587 | 587 | |
| 588 | - if ( $sent ) { |
|
| 589 | - $note = __( 'Invoice has been emailed to the user.', 'invoicing' ); |
|
| 588 | + if ($sent) { |
|
| 589 | + $note = __('Invoice has been emailed to the user.', 'invoicing'); |
|
| 590 | 590 | } else { |
| 591 | - $note = __( 'Fail to send invoice to the user!', 'invoicing' ); |
|
| 591 | + $note = __('Fail to send invoice to the user!', 'invoicing'); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | - $invoice->add_note( $note, '', '', true ); // Add system note. |
|
| 594 | + $invoice->add_note($note, '', '', true); // Add system note. |
|
| 595 | 595 | |
| 596 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
| 597 | - $recipient = wpinv_get_admin_email(); |
|
| 598 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 599 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 596 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
| 597 | + $recipient = wpinv_get_admin_email(); |
|
| 598 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 599 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | return $sent; |
| 603 | 603 | } |
| 604 | 604 | |
| 605 | -function wpinv_user_note_notification( $invoice_id, $args = array() ) { |
|
| 605 | +function wpinv_user_note_notification($invoice_id, $args = array()) { |
|
| 606 | 606 | global $wpinv_email_search, $wpinv_email_replace; |
| 607 | 607 | |
| 608 | 608 | $email_type = 'user_note'; |
| 609 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 609 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 610 | 610 | return false; |
| 611 | 611 | } |
| 612 | 612 | |
| 613 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 614 | - if ( empty( $invoice ) ) { |
|
| 613 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 614 | + if (empty($invoice)) { |
|
| 615 | 615 | return false; |
| 616 | 616 | } |
| 617 | 617 | |
| 618 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 619 | - if ( !is_email( $recipient ) ) { |
|
| 618 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 619 | + if (!is_email($recipient)) { |
|
| 620 | 620 | return false; |
| 621 | 621 | } |
| 622 | 622 | |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | 'user_note' => '' |
| 625 | 625 | ); |
| 626 | 626 | |
| 627 | - $args = wp_parse_args( $args, $defaults ); |
|
| 627 | + $args = wp_parse_args($args, $defaults); |
|
| 628 | 628 | |
| 629 | 629 | $search = array(); |
| 630 | 630 | $search['invoice_number'] = '{invoice_number}'; |
@@ -643,46 +643,46 @@ discard block |
||
| 643 | 643 | $wpinv_email_search = $search; |
| 644 | 644 | $wpinv_email_replace = $replace; |
| 645 | 645 | |
| 646 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 647 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 648 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 649 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 646 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 647 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 648 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 649 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 650 | 650 | |
| 651 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 651 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 652 | 652 | 'invoice' => $invoice, |
| 653 | 653 | 'email_type' => $email_type, |
| 654 | 654 | 'email_heading' => $email_heading, |
| 655 | 655 | 'sent_to_admin' => false, |
| 656 | 656 | 'plain_text' => false, |
| 657 | 657 | 'customer_note' => $args['user_note'] |
| 658 | - ) ); |
|
| 658 | + )); |
|
| 659 | 659 | |
| 660 | - $content = wpinv_email_format_text( $content ); |
|
| 660 | + $content = wpinv_email_format_text($content); |
|
| 661 | 661 | |
| 662 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 662 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 663 | 663 | |
| 664 | 664 | return $sent; |
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | function wpinv_mail_get_from_address() { |
| 668 | - $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) ); |
|
| 669 | - return sanitize_email( $from_address ); |
|
| 668 | + $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from')); |
|
| 669 | + return sanitize_email($from_address); |
|
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | function wpinv_mail_get_from_name() { |
| 673 | - $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name' ) ); |
|
| 674 | - return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES ); |
|
| 673 | + $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name')); |
|
| 674 | + return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES); |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | -function wpinv_mail_admin_bcc_active( $mail_type = '' ) { |
|
| 678 | - $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) ); |
|
| 679 | - return ( $active ? true : false ); |
|
| 677 | +function wpinv_mail_admin_bcc_active($mail_type = '') { |
|
| 678 | + $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc')); |
|
| 679 | + return ($active ? true : false); |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | -function wpinv_mail_get_content_type( $content_type = 'text/html', $email_type = 'html' ) { |
|
| 683 | - $email_type = apply_filters( 'wpinv_mail_content_type', $email_type ); |
|
| 682 | +function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') { |
|
| 683 | + $email_type = apply_filters('wpinv_mail_content_type', $email_type); |
|
| 684 | 684 | |
| 685 | - switch ( $email_type ) { |
|
| 685 | + switch ($email_type) { |
|
| 686 | 686 | case 'html' : |
| 687 | 687 | $content_type = 'text/html'; |
| 688 | 688 | break; |
@@ -697,35 +697,35 @@ discard block |
||
| 697 | 697 | return $content_type; |
| 698 | 698 | } |
| 699 | 699 | |
| 700 | -function wpinv_mail_send( $to, $subject, $message, $headers, $attachments ) { |
|
| 701 | - add_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' ); |
|
| 702 | - add_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' ); |
|
| 703 | - add_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' ); |
|
| 700 | +function wpinv_mail_send($to, $subject, $message, $headers, $attachments) { |
|
| 701 | + add_filter('wp_mail_from', 'wpinv_mail_get_from_address'); |
|
| 702 | + add_filter('wp_mail_from_name', 'wpinv_mail_get_from_name'); |
|
| 703 | + add_filter('wp_mail_content_type', 'wpinv_mail_get_content_type'); |
|
| 704 | 704 | |
| 705 | - $message = wpinv_email_style_body( $message ); |
|
| 706 | - $message = apply_filters( 'wpinv_mail_content', $message ); |
|
| 705 | + $message = wpinv_email_style_body($message); |
|
| 706 | + $message = apply_filters('wpinv_mail_content', $message); |
|
| 707 | 707 | |
| 708 | - $sent = wp_mail( $to, $subject, $message, $headers, $attachments ); |
|
| 708 | + $sent = wp_mail($to, $subject, $message, $headers, $attachments); |
|
| 709 | 709 | |
| 710 | - if ( !$sent ) { |
|
| 711 | - $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), ( is_array( $to ) ? implode( ', ', $to ) : $to ), $subject ); |
|
| 712 | - wpinv_error_log( $log_message, __( "Email from Invoicing plugin failed to send", 'invoicing' ), __FILE__, __LINE__ ); |
|
| 710 | + if (!$sent) { |
|
| 711 | + $log_message = wp_sprintf(__("\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing'), date_i18n('F j Y H:i:s', current_time('timestamp')), (is_array($to) ? implode(', ', $to) : $to), $subject); |
|
| 712 | + wpinv_error_log($log_message, __("Email from Invoicing plugin failed to send", 'invoicing'), __FILE__, __LINE__); |
|
| 713 | 713 | } |
| 714 | 714 | |
| 715 | - remove_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' ); |
|
| 716 | - remove_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' ); |
|
| 717 | - remove_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' ); |
|
| 715 | + remove_filter('wp_mail_from', 'wpinv_mail_get_from_address'); |
|
| 716 | + remove_filter('wp_mail_from_name', 'wpinv_mail_get_from_name'); |
|
| 717 | + remove_filter('wp_mail_content_type', 'wpinv_mail_get_content_type'); |
|
| 718 | 718 | |
| 719 | 719 | return $sent; |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | function wpinv_get_emails() { |
| 723 | 723 | $overdue_days_options = array(); |
| 724 | - $overdue_days_options[0] = __( 'On the Due Date', 'invoicing' ); |
|
| 725 | - $overdue_days_options[1] = __( '1 day after Due Date', 'invoicing' ); |
|
| 724 | + $overdue_days_options[0] = __('On the Due Date', 'invoicing'); |
|
| 725 | + $overdue_days_options[1] = __('1 day after Due Date', 'invoicing'); |
|
| 726 | 726 | |
| 727 | - for ( $i = 2; $i <= 10; $i++ ) { |
|
| 728 | - $overdue_days_options[$i] = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i ); |
|
| 727 | + for ($i = 2; $i <= 10; $i++) { |
|
| 728 | + $overdue_days_options[$i] = wp_sprintf(__('%d days after Due Date', 'invoicing'), $i); |
|
| 729 | 729 | } |
| 730 | 730 | |
| 731 | 731 | // Default, built-in gateways |
@@ -733,130 +733,130 @@ discard block |
||
| 733 | 733 | 'new_invoice' => array( |
| 734 | 734 | 'email_new_invoice_header' => array( |
| 735 | 735 | 'id' => 'email_new_invoice_header', |
| 736 | - 'name' => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>', |
|
| 737 | - 'desc' => __( 'New invoice emails are sent to admin when a new invoice is received.', 'invoicing' ), |
|
| 736 | + 'name' => '<h3>' . __('New Invoice', 'invoicing') . '</h3>', |
|
| 737 | + 'desc' => __('New invoice emails are sent to admin when a new invoice is received.', 'invoicing'), |
|
| 738 | 738 | 'type' => 'header', |
| 739 | 739 | ), |
| 740 | 740 | 'email_new_invoice_active' => array( |
| 741 | 741 | 'id' => 'email_new_invoice_active', |
| 742 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 743 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 742 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 743 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 744 | 744 | 'type' => 'checkbox', |
| 745 | 745 | 'std' => 1 |
| 746 | 746 | ), |
| 747 | 747 | 'email_new_invoice_subject' => array( |
| 748 | 748 | 'id' => 'email_new_invoice_subject', |
| 749 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 750 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
| 749 | + 'name' => __('Subject', 'invoicing'), |
|
| 750 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
| 751 | 751 | 'type' => 'text', |
| 752 | - 'std' => __( '[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing' ), |
|
| 752 | + 'std' => __('[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing'), |
|
| 753 | 753 | 'size' => 'large' |
| 754 | 754 | ), |
| 755 | 755 | 'email_new_invoice_heading' => array( |
| 756 | 756 | 'id' => 'email_new_invoice_heading', |
| 757 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 758 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
| 757 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 758 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
| 759 | 759 | 'type' => 'text', |
| 760 | - 'std' => __( 'New payment invoice', 'invoicing' ), |
|
| 760 | + 'std' => __('New payment invoice', 'invoicing'), |
|
| 761 | 761 | 'size' => 'large' |
| 762 | 762 | ), |
| 763 | 763 | ), |
| 764 | 764 | 'cancelled_invoice' => array( |
| 765 | 765 | 'email_cancelled_invoice_header' => array( |
| 766 | 766 | 'id' => 'email_cancelled_invoice_header', |
| 767 | - 'name' => '<h3>' . __( 'Cancelled Invoice', 'invoicing' ) . '</h3>', |
|
| 768 | - 'desc' => __( 'Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing' ), |
|
| 767 | + 'name' => '<h3>' . __('Cancelled Invoice', 'invoicing') . '</h3>', |
|
| 768 | + 'desc' => __('Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing'), |
|
| 769 | 769 | 'type' => 'header', |
| 770 | 770 | ), |
| 771 | 771 | 'email_cancelled_invoice_active' => array( |
| 772 | 772 | 'id' => 'email_cancelled_invoice_active', |
| 773 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 774 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 773 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 774 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 775 | 775 | 'type' => 'checkbox', |
| 776 | 776 | 'std' => 1 |
| 777 | 777 | ), |
| 778 | 778 | 'email_cancelled_invoice_subject' => array( |
| 779 | 779 | 'id' => 'email_cancelled_invoice_subject', |
| 780 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 781 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
| 780 | + 'name' => __('Subject', 'invoicing'), |
|
| 781 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
| 782 | 782 | 'type' => 'text', |
| 783 | - 'std' => __( '[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing' ), |
|
| 783 | + 'std' => __('[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing'), |
|
| 784 | 784 | 'size' => 'large' |
| 785 | 785 | ), |
| 786 | 786 | 'email_cancelled_invoice_heading' => array( |
| 787 | 787 | 'id' => 'email_cancelled_invoice_heading', |
| 788 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 789 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
| 788 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 789 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
| 790 | 790 | 'type' => 'text', |
| 791 | - 'std' => __( 'Cancelled invoice', 'invoicing' ), |
|
| 791 | + 'std' => __('Cancelled invoice', 'invoicing'), |
|
| 792 | 792 | 'size' => 'large' |
| 793 | 793 | ), |
| 794 | 794 | ), |
| 795 | 795 | 'failed_invoice' => array( |
| 796 | 796 | 'email_failed_invoice_header' => array( |
| 797 | 797 | 'id' => 'email_failed_invoice_header', |
| 798 | - 'name' => '<h3>' . __( 'Failed Invoice', 'invoicing' ) . '</h3>', |
|
| 799 | - 'desc' => __( 'Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing' ), |
|
| 798 | + 'name' => '<h3>' . __('Failed Invoice', 'invoicing') . '</h3>', |
|
| 799 | + 'desc' => __('Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing'), |
|
| 800 | 800 | 'type' => 'header', |
| 801 | 801 | ), |
| 802 | 802 | 'email_failed_invoice_active' => array( |
| 803 | 803 | 'id' => 'email_failed_invoice_active', |
| 804 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 805 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 804 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 805 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 806 | 806 | 'type' => 'checkbox', |
| 807 | 807 | 'std' => 1 |
| 808 | 808 | ), |
| 809 | 809 | 'email_failed_invoice_subject' => array( |
| 810 | 810 | 'id' => 'email_failed_invoice_subject', |
| 811 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 812 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
| 811 | + 'name' => __('Subject', 'invoicing'), |
|
| 812 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
| 813 | 813 | 'type' => 'text', |
| 814 | - 'std' => __( '[{site_title}] Failed invoice ({invoice_number})', 'invoicing' ), |
|
| 814 | + 'std' => __('[{site_title}] Failed invoice ({invoice_number})', 'invoicing'), |
|
| 815 | 815 | 'size' => 'large' |
| 816 | 816 | ), |
| 817 | 817 | 'email_failed_invoice_heading' => array( |
| 818 | 818 | 'id' => 'email_failed_invoice_heading', |
| 819 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 820 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
| 819 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 820 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
| 821 | 821 | 'type' => 'text', |
| 822 | - 'std' => __( 'Failed invoice', 'invoicing' ), |
|
| 822 | + 'std' => __('Failed invoice', 'invoicing'), |
|
| 823 | 823 | 'size' => 'large' |
| 824 | 824 | ) |
| 825 | 825 | ), |
| 826 | 826 | 'onhold_invoice' => array( |
| 827 | 827 | 'email_onhold_invoice_header' => array( |
| 828 | 828 | 'id' => 'email_onhold_invoice_header', |
| 829 | - 'name' => '<h3>' . __( 'On Hold Invoice', 'invoicing' ) . '</h3>', |
|
| 830 | - 'desc' => __( 'This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing' ), |
|
| 829 | + 'name' => '<h3>' . __('On Hold Invoice', 'invoicing') . '</h3>', |
|
| 830 | + 'desc' => __('This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing'), |
|
| 831 | 831 | 'type' => 'header', |
| 832 | 832 | ), |
| 833 | 833 | 'email_onhold_invoice_active' => array( |
| 834 | 834 | 'id' => 'email_onhold_invoice_active', |
| 835 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 836 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 835 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 836 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 837 | 837 | 'type' => 'checkbox', |
| 838 | 838 | 'std' => 1 |
| 839 | 839 | ), |
| 840 | 840 | 'email_onhold_invoice_subject' => array( |
| 841 | 841 | 'id' => 'email_onhold_invoice_subject', |
| 842 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 843 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
| 842 | + 'name' => __('Subject', 'invoicing'), |
|
| 843 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
| 844 | 844 | 'type' => 'text', |
| 845 | - 'std' => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ), |
|
| 845 | + 'std' => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'), |
|
| 846 | 846 | 'size' => 'large' |
| 847 | 847 | ), |
| 848 | 848 | 'email_onhold_invoice_heading' => array( |
| 849 | 849 | 'id' => 'email_onhold_invoice_heading', |
| 850 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 851 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
| 850 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 851 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
| 852 | 852 | 'type' => 'text', |
| 853 | - 'std' => __( 'Thank you for your invoice', 'invoicing' ), |
|
| 853 | + 'std' => __('Thank you for your invoice', 'invoicing'), |
|
| 854 | 854 | 'size' => 'large' |
| 855 | 855 | ), |
| 856 | 856 | 'email_onhold_invoice_admin_bcc' => array( |
| 857 | 857 | 'id' => 'email_onhold_invoice_admin_bcc', |
| 858 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
| 859 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
| 858 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
| 859 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
| 860 | 860 | 'type' => 'checkbox', |
| 861 | 861 | 'std' => 1 |
| 862 | 862 | ), |
@@ -864,37 +864,37 @@ discard block |
||
| 864 | 864 | 'processing_invoice' => array( |
| 865 | 865 | 'email_processing_invoice_header' => array( |
| 866 | 866 | 'id' => 'email_processing_invoice_header', |
| 867 | - 'name' => '<h3>' . __( 'Processing Invoice', 'invoicing' ) . '</h3>', |
|
| 868 | - 'desc' => __( 'This is an invoice notification sent to users containing invoice details after payment.', 'invoicing' ), |
|
| 867 | + 'name' => '<h3>' . __('Processing Invoice', 'invoicing') . '</h3>', |
|
| 868 | + 'desc' => __('This is an invoice notification sent to users containing invoice details after payment.', 'invoicing'), |
|
| 869 | 869 | 'type' => 'header', |
| 870 | 870 | ), |
| 871 | 871 | 'email_processing_invoice_active' => array( |
| 872 | 872 | 'id' => 'email_processing_invoice_active', |
| 873 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 874 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 873 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 874 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 875 | 875 | 'type' => 'checkbox', |
| 876 | 876 | 'std' => 1 |
| 877 | 877 | ), |
| 878 | 878 | 'email_processing_invoice_subject' => array( |
| 879 | 879 | 'id' => 'email_processing_invoice_subject', |
| 880 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 881 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
| 880 | + 'name' => __('Subject', 'invoicing'), |
|
| 881 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
| 882 | 882 | 'type' => 'text', |
| 883 | - 'std' => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ), |
|
| 883 | + 'std' => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'), |
|
| 884 | 884 | 'size' => 'large' |
| 885 | 885 | ), |
| 886 | 886 | 'email_processing_invoice_heading' => array( |
| 887 | 887 | 'id' => 'email_processing_invoice_heading', |
| 888 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 889 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
| 888 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 889 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
| 890 | 890 | 'type' => 'text', |
| 891 | - 'std' => __( 'Thank you for your invoice', 'invoicing' ), |
|
| 891 | + 'std' => __('Thank you for your invoice', 'invoicing'), |
|
| 892 | 892 | 'size' => 'large' |
| 893 | 893 | ), |
| 894 | 894 | 'email_processing_invoice_admin_bcc' => array( |
| 895 | 895 | 'id' => 'email_processing_invoice_admin_bcc', |
| 896 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
| 897 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
| 896 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
| 897 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
| 898 | 898 | 'type' => 'checkbox', |
| 899 | 899 | 'std' => 1 |
| 900 | 900 | ), |
@@ -902,37 +902,37 @@ discard block |
||
| 902 | 902 | 'completed_invoice' => array( |
| 903 | 903 | 'email_completed_invoice_header' => array( |
| 904 | 904 | 'id' => 'email_completed_invoice_header', |
| 905 | - 'name' => '<h3>' . __( 'Paid Invoice', 'invoicing' ) . '</h3>', |
|
| 906 | - 'desc' => __( 'Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing' ), |
|
| 905 | + 'name' => '<h3>' . __('Paid Invoice', 'invoicing') . '</h3>', |
|
| 906 | + 'desc' => __('Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing'), |
|
| 907 | 907 | 'type' => 'header', |
| 908 | 908 | ), |
| 909 | 909 | 'email_completed_invoice_active' => array( |
| 910 | 910 | 'id' => 'email_completed_invoice_active', |
| 911 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 912 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 911 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 912 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 913 | 913 | 'type' => 'checkbox', |
| 914 | 914 | 'std' => 1 |
| 915 | 915 | ), |
| 916 | 916 | 'email_completed_invoice_subject' => array( |
| 917 | 917 | 'id' => 'email_completed_invoice_subject', |
| 918 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 919 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
| 918 | + 'name' => __('Subject', 'invoicing'), |
|
| 919 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
| 920 | 920 | 'type' => 'text', |
| 921 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing' ), |
|
| 921 | + 'std' => __('[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing'), |
|
| 922 | 922 | 'size' => 'large' |
| 923 | 923 | ), |
| 924 | 924 | 'email_completed_invoice_heading' => array( |
| 925 | 925 | 'id' => 'email_completed_invoice_heading', |
| 926 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 927 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
| 926 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 927 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
| 928 | 928 | 'type' => 'text', |
| 929 | - 'std' => __( 'Your invoice has been paid', 'invoicing' ), |
|
| 929 | + 'std' => __('Your invoice has been paid', 'invoicing'), |
|
| 930 | 930 | 'size' => 'large' |
| 931 | 931 | ), |
| 932 | 932 | 'email_completed_invoice_admin_bcc' => array( |
| 933 | 933 | 'id' => 'email_completed_invoice_admin_bcc', |
| 934 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
| 935 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
| 934 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
| 935 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
| 936 | 936 | 'type' => 'checkbox', |
| 937 | 937 | ), |
| 938 | 938 | 'std' => 1 |
@@ -940,37 +940,37 @@ discard block |
||
| 940 | 940 | 'refunded_invoice' => array( |
| 941 | 941 | 'email_refunded_invoice_header' => array( |
| 942 | 942 | 'id' => 'email_refunded_invoice_header', |
| 943 | - 'name' => '<h3>' . __( 'Refunded Invoice', 'invoicing' ) . '</h3>', |
|
| 944 | - 'desc' => __( 'Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing' ), |
|
| 943 | + 'name' => '<h3>' . __('Refunded Invoice', 'invoicing') . '</h3>', |
|
| 944 | + 'desc' => __('Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing'), |
|
| 945 | 945 | 'type' => 'header', |
| 946 | 946 | ), |
| 947 | 947 | 'email_refunded_invoice_active' => array( |
| 948 | 948 | 'id' => 'email_refunded_invoice_active', |
| 949 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 950 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 949 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 950 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 951 | 951 | 'type' => 'checkbox', |
| 952 | 952 | 'std' => 1 |
| 953 | 953 | ), |
| 954 | 954 | 'email_refunded_invoice_subject' => array( |
| 955 | 955 | 'id' => 'email_refunded_invoice_subject', |
| 956 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 957 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
| 956 | + 'name' => __('Subject', 'invoicing'), |
|
| 957 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
| 958 | 958 | 'type' => 'text', |
| 959 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing' ), |
|
| 959 | + 'std' => __('[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing'), |
|
| 960 | 960 | 'size' => 'large' |
| 961 | 961 | ), |
| 962 | 962 | 'email_refunded_invoice_heading' => array( |
| 963 | 963 | 'id' => 'email_refunded_invoice_heading', |
| 964 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 965 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
| 964 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 965 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
| 966 | 966 | 'type' => 'text', |
| 967 | - 'std' => __( 'Your invoice has been refunded', 'invoicing' ), |
|
| 967 | + 'std' => __('Your invoice has been refunded', 'invoicing'), |
|
| 968 | 968 | 'size' => 'large' |
| 969 | 969 | ), |
| 970 | 970 | 'email_refunded_invoice_admin_bcc' => array( |
| 971 | 971 | 'id' => 'email_refunded_invoice_admin_bcc', |
| 972 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
| 973 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
| 972 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
| 973 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
| 974 | 974 | 'type' => 'checkbox', |
| 975 | 975 | 'std' => 1 |
| 976 | 976 | ), |
@@ -978,37 +978,37 @@ discard block |
||
| 978 | 978 | 'user_invoice' => array( |
| 979 | 979 | 'email_user_invoice_header' => array( |
| 980 | 980 | 'id' => 'email_user_invoice_header', |
| 981 | - 'name' => '<h3>' . __( 'Customer Invoice', 'invoicing' ) . '</h3>', |
|
| 982 | - 'desc' => __( 'Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing' ), |
|
| 981 | + 'name' => '<h3>' . __('Customer Invoice', 'invoicing') . '</h3>', |
|
| 982 | + 'desc' => __('Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing'), |
|
| 983 | 983 | 'type' => 'header', |
| 984 | 984 | ), |
| 985 | 985 | 'email_user_invoice_active' => array( |
| 986 | 986 | 'id' => 'email_user_invoice_active', |
| 987 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 988 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 987 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 988 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 989 | 989 | 'type' => 'checkbox', |
| 990 | 990 | 'std' => 1 |
| 991 | 991 | ), |
| 992 | 992 | 'email_user_invoice_subject' => array( |
| 993 | 993 | 'id' => 'email_user_invoice_subject', |
| 994 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 995 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
| 994 | + 'name' => __('Subject', 'invoicing'), |
|
| 995 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
| 996 | 996 | 'type' => 'text', |
| 997 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date}', 'invoicing' ), |
|
| 997 | + 'std' => __('[{site_title}] Your invoice from {invoice_date}', 'invoicing'), |
|
| 998 | 998 | 'size' => 'large' |
| 999 | 999 | ), |
| 1000 | 1000 | 'email_user_invoice_heading' => array( |
| 1001 | 1001 | 'id' => 'email_user_invoice_heading', |
| 1002 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 1003 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
| 1002 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 1003 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
| 1004 | 1004 | 'type' => 'text', |
| 1005 | - 'std' => __( 'Your invoice {invoice_number} details', 'invoicing' ), |
|
| 1005 | + 'std' => __('Your invoice {invoice_number} details', 'invoicing'), |
|
| 1006 | 1006 | 'size' => 'large' |
| 1007 | 1007 | ), |
| 1008 | 1008 | 'email_user_invoice_admin_bcc' => array( |
| 1009 | 1009 | 'id' => 'email_user_invoice_admin_bcc', |
| 1010 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
| 1011 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
| 1010 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
| 1011 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
| 1012 | 1012 | 'type' => 'checkbox', |
| 1013 | 1013 | 'std' => 1 |
| 1014 | 1014 | ), |
@@ -1016,177 +1016,177 @@ discard block |
||
| 1016 | 1016 | 'user_note' => array( |
| 1017 | 1017 | 'email_user_note_header' => array( |
| 1018 | 1018 | 'id' => 'email_user_note_header', |
| 1019 | - 'name' => '<h3>' . __( 'Customer Note', 'invoicing' ) . '</h3>', |
|
| 1020 | - 'desc' => __( 'Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing' ), |
|
| 1019 | + 'name' => '<h3>' . __('Customer Note', 'invoicing') . '</h3>', |
|
| 1020 | + 'desc' => __('Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing'), |
|
| 1021 | 1021 | 'type' => 'header', |
| 1022 | 1022 | ), |
| 1023 | 1023 | 'email_user_note_active' => array( |
| 1024 | 1024 | 'id' => 'email_user_note_active', |
| 1025 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 1026 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 1025 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 1026 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 1027 | 1027 | 'type' => 'checkbox', |
| 1028 | 1028 | 'std' => 1 |
| 1029 | 1029 | ), |
| 1030 | 1030 | 'email_user_note_subject' => array( |
| 1031 | 1031 | 'id' => 'email_user_note_subject', |
| 1032 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 1033 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
| 1032 | + 'name' => __('Subject', 'invoicing'), |
|
| 1033 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
| 1034 | 1034 | 'type' => 'text', |
| 1035 | - 'std' => __( '[{site_title}] Note added to your {invoice_quote} #{invoice_number} from {invoice_date}', 'invoicing' ), |
|
| 1035 | + 'std' => __('[{site_title}] Note added to your {invoice_quote} #{invoice_number} from {invoice_date}', 'invoicing'), |
|
| 1036 | 1036 | 'size' => 'large' |
| 1037 | 1037 | ), |
| 1038 | 1038 | 'email_user_note_heading' => array( |
| 1039 | 1039 | 'id' => 'email_user_note_heading', |
| 1040 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 1041 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
| 1040 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 1041 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
| 1042 | 1042 | 'type' => 'text', |
| 1043 | - 'std' => __( 'A note has been added to your {invoice_quote}', 'invoicing' ), |
|
| 1043 | + 'std' => __('A note has been added to your {invoice_quote}', 'invoicing'), |
|
| 1044 | 1044 | 'size' => 'large' |
| 1045 | 1045 | ), |
| 1046 | 1046 | ), |
| 1047 | 1047 | 'overdue' => array( |
| 1048 | 1048 | 'email_overdue_header' => array( |
| 1049 | 1049 | 'id' => 'email_overdue_header', |
| 1050 | - 'name' => '<h3>' . __( 'Payment Reminder', 'invoicing' ) . '</h3>', |
|
| 1051 | - 'desc' => __( 'Payment reminder emails are sent to user automatically.', 'invoicing' ), |
|
| 1050 | + 'name' => '<h3>' . __('Payment Reminder', 'invoicing') . '</h3>', |
|
| 1051 | + 'desc' => __('Payment reminder emails are sent to user automatically.', 'invoicing'), |
|
| 1052 | 1052 | 'type' => 'header', |
| 1053 | 1053 | ), |
| 1054 | 1054 | 'email_overdue_active' => array( |
| 1055 | 1055 | 'id' => 'email_overdue_active', |
| 1056 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
| 1057 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
| 1056 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
| 1057 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
| 1058 | 1058 | 'type' => 'checkbox', |
| 1059 | 1059 | 'std' => 1 |
| 1060 | 1060 | ), |
| 1061 | 1061 | 'email_due_reminder_days' => array( |
| 1062 | 1062 | 'id' => 'email_due_reminder_days', |
| 1063 | - 'name' => __( 'When to Send', 'sliced-invoices' ), |
|
| 1064 | - 'desc' => __( 'Check when you would like payment reminders sent out.', 'invoicing' ), |
|
| 1063 | + 'name' => __('When to Send', 'sliced-invoices'), |
|
| 1064 | + 'desc' => __('Check when you would like payment reminders sent out.', 'invoicing'), |
|
| 1065 | 1065 | 'default' => '', |
| 1066 | 1066 | 'type' => 'multicheck', |
| 1067 | 1067 | 'options' => $overdue_days_options, |
| 1068 | 1068 | ), |
| 1069 | 1069 | 'email_overdue_subject' => array( |
| 1070 | 1070 | 'id' => 'email_overdue_subject', |
| 1071 | - 'name' => __( 'Subject', 'invoicing' ), |
|
| 1072 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
| 1071 | + 'name' => __('Subject', 'invoicing'), |
|
| 1072 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
| 1073 | 1073 | 'type' => 'text', |
| 1074 | - 'std' => __( '[{site_title}] Payment Reminder', 'invoicing' ), |
|
| 1074 | + 'std' => __('[{site_title}] Payment Reminder', 'invoicing'), |
|
| 1075 | 1075 | 'size' => 'large' |
| 1076 | 1076 | ), |
| 1077 | 1077 | 'email_overdue_heading' => array( |
| 1078 | 1078 | 'id' => 'email_overdue_heading', |
| 1079 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
| 1080 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
| 1079 | + 'name' => __('Email Heading', 'invoicing'), |
|
| 1080 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
| 1081 | 1081 | 'type' => 'text', |
| 1082 | - 'std' => __( 'Payment reminder for your invoice', 'invoicing' ), |
|
| 1082 | + 'std' => __('Payment reminder for your invoice', 'invoicing'), |
|
| 1083 | 1083 | 'size' => 'large' |
| 1084 | 1084 | ), |
| 1085 | 1085 | 'email_overdue_body' => array( |
| 1086 | 1086 | 'id' => 'email_overdue_body', |
| 1087 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
| 1088 | - 'desc' => __( 'The content of the email.', 'invoicing' ), |
|
| 1087 | + 'name' => __('Email Content', 'invoicing'), |
|
| 1088 | + 'desc' => __('The content of the email.', 'invoicing'), |
|
| 1089 | 1089 | 'type' => 'rich_editor', |
| 1090 | - 'std' => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ), |
|
| 1090 | + 'std' => __('<p>Hi {full_name},</p><p>This is just a friendly reminder your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'), |
|
| 1091 | 1091 | 'class' => 'large', |
| 1092 | 1092 | 'size' => 10, |
| 1093 | 1093 | ), |
| 1094 | 1094 | ), |
| 1095 | 1095 | ); |
| 1096 | 1096 | |
| 1097 | - return apply_filters( 'wpinv_get_emails', $emails ); |
|
| 1097 | + return apply_filters('wpinv_get_emails', $emails); |
|
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | -function wpinv_settings_emails( $settings = array() ) { |
|
| 1100 | +function wpinv_settings_emails($settings = array()) { |
|
| 1101 | 1101 | $emails = wpinv_get_emails(); |
| 1102 | 1102 | |
| 1103 | - if ( !empty( $emails ) ) { |
|
| 1104 | - foreach ( $emails as $key => $email ) { |
|
| 1103 | + if (!empty($emails)) { |
|
| 1104 | + foreach ($emails as $key => $email) { |
|
| 1105 | 1105 | $settings[$key] = $email; |
| 1106 | 1106 | } |
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | - return apply_filters( 'wpinv_settings_get_emails', $settings ); |
|
| 1109 | + return apply_filters('wpinv_settings_get_emails', $settings); |
|
| 1110 | 1110 | } |
| 1111 | -add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 ); |
|
| 1111 | +add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1); |
|
| 1112 | 1112 | |
| 1113 | -function wpinv_settings_sections_emails( $settings ) { |
|
| 1113 | +function wpinv_settings_sections_emails($settings) { |
|
| 1114 | 1114 | $emails = wpinv_get_emails(); |
| 1115 | 1115 | |
| 1116 | 1116 | if (!empty($emails)) { |
| 1117 | - foreach ($emails as $key => $email) { |
|
| 1118 | - $settings[$key] = !empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : $key; |
|
| 1117 | + foreach ($emails as $key => $email) { |
|
| 1118 | + $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : $key; |
|
| 1119 | 1119 | } |
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | 1122 | return $settings; |
| 1123 | 1123 | } |
| 1124 | -add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 ); |
|
| 1124 | +add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1); |
|
| 1125 | 1125 | |
| 1126 | -function wpinv_email_is_enabled( $email_type ) { |
|
| 1126 | +function wpinv_email_is_enabled($email_type) { |
|
| 1127 | 1127 | $emails = wpinv_get_emails(); |
| 1128 | - $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false; |
|
| 1128 | + $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false; |
|
| 1129 | 1129 | |
| 1130 | - return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type ); |
|
| 1130 | + return apply_filters('wpinv_email_is_enabled', $enabled, $email_type); |
|
| 1131 | 1131 | } |
| 1132 | 1132 | |
| 1133 | -function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 1134 | - switch ( $email_type ) { |
|
| 1133 | +function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 1134 | + switch ($email_type) { |
|
| 1135 | 1135 | case 'new_invoice': |
| 1136 | 1136 | case 'cancelled_invoice': |
| 1137 | 1137 | case 'failed_invoice': |
| 1138 | 1138 | $recipient = wpinv_get_admin_email(); |
| 1139 | 1139 | break; |
| 1140 | 1140 | default: |
| 1141 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
| 1142 | - $recipient = !empty( $invoice ) ? $invoice->get_email() : ''; |
|
| 1141 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
| 1142 | + $recipient = !empty($invoice) ? $invoice->get_email() : ''; |
|
| 1143 | 1143 | break; |
| 1144 | 1144 | } |
| 1145 | 1145 | |
| 1146 | - return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice ); |
|
| 1146 | + return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice); |
|
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | -function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 1150 | - $subject = wpinv_get_option( 'email_' . $email_type . '_subject' ); |
|
| 1149 | +function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 1150 | + $subject = wpinv_get_option('email_' . $email_type . '_subject'); |
|
| 1151 | 1151 | |
| 1152 | - $subject = wpinv_email_format_text( $subject ); |
|
| 1152 | + $subject = wpinv_email_format_text($subject); |
|
| 1153 | 1153 | |
| 1154 | - return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice ); |
|
| 1154 | + return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice); |
|
| 1155 | 1155 | } |
| 1156 | 1156 | |
| 1157 | -function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 1158 | - $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' ); |
|
| 1157 | +function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 1158 | + $email_heading = wpinv_get_option('email_' . $email_type . '_heading'); |
|
| 1159 | 1159 | |
| 1160 | - $email_heading = wpinv_email_format_text( $email_heading ); |
|
| 1160 | + $email_heading = wpinv_email_format_text($email_heading); |
|
| 1161 | 1161 | |
| 1162 | - return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice ); |
|
| 1162 | + return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice); |
|
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | -function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 1166 | - $content = wpinv_get_option( 'email_' . $email_type . '_body' ); |
|
| 1165 | +function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 1166 | + $content = wpinv_get_option('email_' . $email_type . '_body'); |
|
| 1167 | 1167 | |
| 1168 | - $content = wpinv_email_format_text( $content ); |
|
| 1168 | + $content = wpinv_email_format_text($content); |
|
| 1169 | 1169 | |
| 1170 | - return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice ); |
|
| 1170 | + return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice); |
|
| 1171 | 1171 | } |
| 1172 | 1172 | |
| 1173 | -function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 1173 | +function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 1174 | 1174 | $from_name = wpinv_mail_get_from_address(); |
| 1175 | 1175 | $from_email = wpinv_mail_get_from_address(); |
| 1176 | 1176 | |
| 1177 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
| 1177 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
| 1178 | 1178 | |
| 1179 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
| 1180 | - $headers .= "Reply-To: ". $from_email . "\r\n"; |
|
| 1179 | + $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n"; |
|
| 1180 | + $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
| 1181 | 1181 | $headers .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n"; |
| 1182 | 1182 | |
| 1183 | - return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice ); |
|
| 1183 | + return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice); |
|
| 1184 | 1184 | } |
| 1185 | 1185 | |
| 1186 | -function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
| 1186 | +function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
| 1187 | 1187 | $attachments = array(); |
| 1188 | 1188 | |
| 1189 | - return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice ); |
|
| 1189 | + return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice); |
|
| 1190 | 1190 | } |
| 1191 | 1191 | |
| 1192 | 1192 | function wpinv_email_global_vars() { |
@@ -1203,73 +1203,73 @@ discard block |
||
| 1203 | 1203 | $replace['sitename'] = $blogname; |
| 1204 | 1204 | $replace['site-title'] = $blogname; |
| 1205 | 1205 | |
| 1206 | - return apply_filters( 'wpinv_email_global_vars', array( $search, $replace ) ); |
|
| 1206 | + return apply_filters('wpinv_email_global_vars', array($search, $replace)); |
|
| 1207 | 1207 | } |
| 1208 | 1208 | |
| 1209 | -function wpinv_email_format_text( $content ) { |
|
| 1209 | +function wpinv_email_format_text($content) { |
|
| 1210 | 1210 | global $wpinv_email_search, $wpinv_email_replace; |
| 1211 | 1211 | |
| 1212 | - if ( empty( $wpinv_email_search ) ) { |
|
| 1212 | + if (empty($wpinv_email_search)) { |
|
| 1213 | 1213 | $wpinv_email_search = array(); |
| 1214 | 1214 | } |
| 1215 | 1215 | |
| 1216 | - if ( empty( $wpinv_email_replace ) ) { |
|
| 1216 | + if (empty($wpinv_email_replace)) { |
|
| 1217 | 1217 | $wpinv_email_replace = array(); |
| 1218 | 1218 | } |
| 1219 | 1219 | |
| 1220 | - $wpinv_email_search = (array)apply_filters( 'wpinv_email_format_text_search', $wpinv_email_search ); |
|
| 1221 | - $wpinv_email_replace = (array)apply_filters( 'wpinv_email_format_text_replace', $wpinv_email_replace ); |
|
| 1220 | + $wpinv_email_search = (array)apply_filters('wpinv_email_format_text_search', $wpinv_email_search); |
|
| 1221 | + $wpinv_email_replace = (array)apply_filters('wpinv_email_format_text_replace', $wpinv_email_replace); |
|
| 1222 | 1222 | |
| 1223 | 1223 | $global_vars = wpinv_email_global_vars(); |
| 1224 | 1224 | |
| 1225 | - $search = array_merge( $global_vars[0], $wpinv_email_search ); |
|
| 1226 | - $replace = array_merge( $global_vars[1], $wpinv_email_replace ); |
|
| 1225 | + $search = array_merge($global_vars[0], $wpinv_email_search); |
|
| 1226 | + $replace = array_merge($global_vars[1], $wpinv_email_replace); |
|
| 1227 | 1227 | |
| 1228 | - if ( empty( $search ) || empty( $replace ) || !is_array( $search ) || !is_array( $replace ) ) { |
|
| 1228 | + if (empty($search) || empty($replace) || !is_array($search) || !is_array($replace)) { |
|
| 1229 | 1229 | return $content; |
| 1230 | 1230 | } |
| 1231 | 1231 | |
| 1232 | - return str_replace( $search, $replace, $content ); |
|
| 1232 | + return str_replace($search, $replace, $content); |
|
| 1233 | 1233 | } |
| 1234 | 1234 | |
| 1235 | -function wpinv_email_style_body( $content ) { |
|
| 1235 | +function wpinv_email_style_body($content) { |
|
| 1236 | 1236 | // make sure we only inline CSS for html emails |
| 1237 | - if ( in_array( wpinv_mail_get_content_type(), array( 'text/html', 'multipart/alternative' ) ) && class_exists( 'DOMDocument' ) ) { |
|
| 1237 | + if (in_array(wpinv_mail_get_content_type(), array('text/html', 'multipart/alternative')) && class_exists('DOMDocument')) { |
|
| 1238 | 1238 | ob_start(); |
| 1239 | - wpinv_get_template( 'emails/wpinv-email-styles.php' ); |
|
| 1240 | - $css = apply_filters( 'wpinv_email_styles', ob_get_clean() ); |
|
| 1239 | + wpinv_get_template('emails/wpinv-email-styles.php'); |
|
| 1240 | + $css = apply_filters('wpinv_email_styles', ob_get_clean()); |
|
| 1241 | 1241 | |
| 1242 | 1242 | // apply CSS styles inline for picky email clients |
| 1243 | 1243 | try { |
| 1244 | - $emogrifier = new Emogrifier( $content, $css ); |
|
| 1244 | + $emogrifier = new Emogrifier($content, $css); |
|
| 1245 | 1245 | $content = $emogrifier->emogrify(); |
| 1246 | - } catch ( Exception $e ) { |
|
| 1247 | - wpinv_error_log( $e->getMessage(), 'emogrifier' ); |
|
| 1246 | + } catch (Exception $e) { |
|
| 1247 | + wpinv_error_log($e->getMessage(), 'emogrifier'); |
|
| 1248 | 1248 | } |
| 1249 | 1249 | } |
| 1250 | 1250 | return $content; |
| 1251 | 1251 | } |
| 1252 | 1252 | |
| 1253 | -function wpinv_email_header( $email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false ) { |
|
| 1254 | - wpinv_get_template( 'emails/wpinv-email-header.php', array( 'email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
| 1253 | +function wpinv_email_header($email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false) { |
|
| 1254 | + wpinv_get_template('emails/wpinv-email-header.php', array('email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
| 1255 | 1255 | } |
| 1256 | 1256 | |
| 1257 | 1257 | /** |
| 1258 | 1258 | * Get the email footer. |
| 1259 | 1259 | */ |
| 1260 | -function wpinv_email_footer( $invoice = array(), $email_type = '', $sent_to_admin = false ) { |
|
| 1261 | - wpinv_get_template( 'emails/wpinv-email-footer.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
| 1260 | +function wpinv_email_footer($invoice = array(), $email_type = '', $sent_to_admin = false) { |
|
| 1261 | + wpinv_get_template('emails/wpinv-email-footer.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
| 1262 | 1262 | } |
| 1263 | 1263 | |
| 1264 | -function wpinv_email_wrap_message( $message ) { |
|
| 1264 | +function wpinv_email_wrap_message($message) { |
|
| 1265 | 1265 | // Buffer |
| 1266 | 1266 | ob_start(); |
| 1267 | 1267 | |
| 1268 | - do_action( 'wpinv_email_header' ); |
|
| 1268 | + do_action('wpinv_email_header'); |
|
| 1269 | 1269 | |
| 1270 | - echo wpautop( wptexturize( $message ) ); |
|
| 1270 | + echo wpautop(wptexturize($message)); |
|
| 1271 | 1271 | |
| 1272 | - do_action( 'wpinv_email_footer' ); |
|
| 1272 | + do_action('wpinv_email_footer'); |
|
| 1273 | 1273 | |
| 1274 | 1274 | // Get contents |
| 1275 | 1275 | $message = ob_get_clean(); |
@@ -1277,86 +1277,86 @@ discard block |
||
| 1277 | 1277 | return $message; |
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | -function wpinv_email_invoice_details( $invoice, $email_type = '', $sent_to_admin = false ) { |
|
| 1281 | - wpinv_get_template( 'emails/wpinv-email-invoice-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
| 1280 | +function wpinv_email_invoice_details($invoice, $email_type = '', $sent_to_admin = false) { |
|
| 1281 | + wpinv_get_template('emails/wpinv-email-invoice-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
| 1282 | 1282 | } |
| 1283 | 1283 | |
| 1284 | -function wpinv_email_invoice_items( $invoice, $email_type = '', $sent_to_admin = false ) { |
|
| 1285 | - wpinv_get_template( 'emails/wpinv-email-invoice-items.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
| 1284 | +function wpinv_email_invoice_items($invoice, $email_type = '', $sent_to_admin = false) { |
|
| 1285 | + wpinv_get_template('emails/wpinv-email-invoice-items.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
| 1286 | 1286 | } |
| 1287 | 1287 | |
| 1288 | -function wpinv_email_billing_details( $invoice, $email_type = '', $sent_to_admin = false ) { |
|
| 1289 | - wpinv_get_template( 'emails/wpinv-email-billing-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
| 1288 | +function wpinv_email_billing_details($invoice, $email_type = '', $sent_to_admin = false) { |
|
| 1289 | + wpinv_get_template('emails/wpinv-email-billing-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
| 1290 | 1290 | } |
| 1291 | 1291 | |
| 1292 | -function wpinv_send_customer_invoice( $data = array() ) { |
|
| 1293 | - $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL; |
|
| 1292 | +function wpinv_send_customer_invoice($data = array()) { |
|
| 1293 | + $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL; |
|
| 1294 | 1294 | |
| 1295 | - if ( empty( $invoice_id ) ) { |
|
| 1295 | + if (empty($invoice_id)) { |
|
| 1296 | 1296 | return; |
| 1297 | 1297 | } |
| 1298 | 1298 | |
| 1299 | - if ( !current_user_can( 'manage_options' ) ) { |
|
| 1300 | - wp_die( __( 'You do not have permission to send invoice notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 1299 | + if (!current_user_can('manage_options')) { |
|
| 1300 | + wp_die(__('You do not have permission to send invoice notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
| 1301 | 1301 | } |
| 1302 | 1302 | |
| 1303 | - $sent = wpinv_user_invoice_notification( $invoice_id ); |
|
| 1303 | + $sent = wpinv_user_invoice_notification($invoice_id); |
|
| 1304 | 1304 | |
| 1305 | 1305 | $status = $sent ? 'email_sent' : 'email_fail'; |
| 1306 | 1306 | |
| 1307 | - $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) ); |
|
| 1308 | - wp_redirect( $redirect ); |
|
| 1307 | + $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false)); |
|
| 1308 | + wp_redirect($redirect); |
|
| 1309 | 1309 | exit; |
| 1310 | 1310 | } |
| 1311 | -add_action( 'wpinv_send_invoice', 'wpinv_send_customer_invoice' ); |
|
| 1311 | +add_action('wpinv_send_invoice', 'wpinv_send_customer_invoice'); |
|
| 1312 | 1312 | |
| 1313 | -function wpinv_send_overdue_reminder( $data = array() ) { |
|
| 1314 | - $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL; |
|
| 1313 | +function wpinv_send_overdue_reminder($data = array()) { |
|
| 1314 | + $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL; |
|
| 1315 | 1315 | |
| 1316 | - if ( empty( $invoice_id ) ) { |
|
| 1316 | + if (empty($invoice_id)) { |
|
| 1317 | 1317 | return; |
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | - if ( !current_user_can( 'manage_options' ) ) { |
|
| 1321 | - wp_die( __( 'You do not have permission to send reminder notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 1320 | + if (!current_user_can('manage_options')) { |
|
| 1321 | + wp_die(__('You do not have permission to send reminder notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
| 1322 | 1322 | } |
| 1323 | 1323 | |
| 1324 | - $sent = wpinv_send_payment_reminder_notification( $invoice_id ); |
|
| 1324 | + $sent = wpinv_send_payment_reminder_notification($invoice_id); |
|
| 1325 | 1325 | |
| 1326 | 1326 | $status = $sent ? 'email_sent' : 'email_fail'; |
| 1327 | 1327 | |
| 1328 | - $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) ); |
|
| 1329 | - wp_redirect( $redirect ); |
|
| 1328 | + $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false)); |
|
| 1329 | + wp_redirect($redirect); |
|
| 1330 | 1330 | exit; |
| 1331 | 1331 | } |
| 1332 | -add_action( 'wpinv_send_reminder', 'wpinv_send_overdue_reminder' ); |
|
| 1332 | +add_action('wpinv_send_reminder', 'wpinv_send_overdue_reminder'); |
|
| 1333 | 1333 | |
| 1334 | -function wpinv_send_customer_note_email( $data ) { |
|
| 1335 | - $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL; |
|
| 1334 | +function wpinv_send_customer_note_email($data) { |
|
| 1335 | + $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL; |
|
| 1336 | 1336 | |
| 1337 | - if ( empty( $invoice_id ) ) { |
|
| 1337 | + if (empty($invoice_id)) { |
|
| 1338 | 1338 | return; |
| 1339 | 1339 | } |
| 1340 | 1340 | |
| 1341 | - $sent = wpinv_user_note_notification( $invoice_id, $data ); |
|
| 1341 | + $sent = wpinv_user_note_notification($invoice_id, $data); |
|
| 1342 | 1342 | } |
| 1343 | -add_action( 'wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1 ); |
|
| 1343 | +add_action('wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1); |
|
| 1344 | 1344 | |
| 1345 | -function wpinv_add_notes_to_invoice_email( $invoice, $email_type, $sent_to_admin ) { |
|
| 1346 | - if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->ID, true ) ) { |
|
| 1347 | - $date_format = get_option( 'date_format' ); |
|
| 1348 | - $time_format = get_option( 'time_format' ); |
|
| 1345 | +function wpinv_add_notes_to_invoice_email($invoice, $email_type, $sent_to_admin) { |
|
| 1346 | + if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->ID, true)) { |
|
| 1347 | + $date_format = get_option('date_format'); |
|
| 1348 | + $time_format = get_option('time_format'); |
|
| 1349 | 1349 | ?> |
| 1350 | 1350 | <div id="wpinv-email-notes"> |
| 1351 | - <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3> |
|
| 1351 | + <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3> |
|
| 1352 | 1352 | <ol class="wpinv-notes-lists"> |
| 1353 | 1353 | <?php |
| 1354 | - foreach ( $invoice_notes as $note ) { |
|
| 1355 | - $note_time = strtotime( $note->comment_date ); |
|
| 1354 | + foreach ($invoice_notes as $note) { |
|
| 1355 | + $note_time = strtotime($note->comment_date); |
|
| 1356 | 1356 | ?> |
| 1357 | 1357 | <li class="comment wpinv-note"> |
| 1358 | - <p class="wpinv-note-date meta"><?php printf( __( '%2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( $date_format, $note_time ), date_i18n( $time_format, $note_time ), $note_time ); ?></p> |
|
| 1359 | - <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div> |
|
| 1358 | + <p class="wpinv-note-date meta"><?php printf(__('%2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n($date_format, $note_time), date_i18n($time_format, $note_time), $note_time); ?></p> |
|
| 1359 | + <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div> |
|
| 1360 | 1360 | </li> |
| 1361 | 1361 | <?php |
| 1362 | 1362 | } |
@@ -1365,21 +1365,21 @@ discard block |
||
| 1365 | 1365 | <?php |
| 1366 | 1366 | } |
| 1367 | 1367 | } |
| 1368 | -add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 ); |
|
| 1368 | +add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3); |
|
| 1369 | 1369 | |
| 1370 | 1370 | function wpinv_email_payment_reminders() { |
| 1371 | 1371 | global $wpi_auto_reminder; |
| 1372 | - if ( !wpinv_get_option( 'email_overdue_active' ) ) { |
|
| 1372 | + if (!wpinv_get_option('email_overdue_active')) { |
|
| 1373 | 1373 | return; |
| 1374 | 1374 | } |
| 1375 | 1375 | |
| 1376 | - if ( $reminder_days = wpinv_get_option( 'email_due_reminder_days' ) ) { |
|
| 1377 | - $reminder_days = is_array( $reminder_days ) ? array_values( $reminder_days ) : ''; |
|
| 1376 | + if ($reminder_days = wpinv_get_option('email_due_reminder_days')) { |
|
| 1377 | + $reminder_days = is_array($reminder_days) ? array_values($reminder_days) : ''; |
|
| 1378 | 1378 | |
| 1379 | - if ( empty( $reminder_days ) ) { |
|
| 1379 | + if (empty($reminder_days)) { |
|
| 1380 | 1380 | return; |
| 1381 | 1381 | } |
| 1382 | - $reminder_days = array_unique( array_map( 'absint', $reminder_days ) ); |
|
| 1382 | + $reminder_days = array_unique(array_map('absint', $reminder_days)); |
|
| 1383 | 1383 | |
| 1384 | 1384 | $args = array( |
| 1385 | 1385 | 'post_type' => 'wpi_invoice', |
@@ -1389,7 +1389,7 @@ discard block |
||
| 1389 | 1389 | 'meta_query' => array( |
| 1390 | 1390 | array( |
| 1391 | 1391 | 'key' => '_wpinv_due_date', |
| 1392 | - 'value' => array( '', 'none' ), |
|
| 1392 | + 'value' => array('', 'none'), |
|
| 1393 | 1393 | 'compare' => 'NOT IN', |
| 1394 | 1394 | ) |
| 1395 | 1395 | ), |
@@ -1398,64 +1398,64 @@ discard block |
||
| 1398 | 1398 | 'order' => 'ASC', |
| 1399 | 1399 | ); |
| 1400 | 1400 | |
| 1401 | - $invoices = get_posts( $args ); |
|
| 1401 | + $invoices = get_posts($args); |
|
| 1402 | 1402 | |
| 1403 | - if ( empty( $invoices ) ) { |
|
| 1403 | + if (empty($invoices)) { |
|
| 1404 | 1404 | return; |
| 1405 | 1405 | } |
| 1406 | 1406 | |
| 1407 | - $date_to_send = array(); |
|
| 1407 | + $date_to_send = array(); |
|
| 1408 | 1408 | |
| 1409 | - foreach ( $invoices as $id ) { |
|
| 1410 | - $due_date = get_post_meta( $id, '_wpinv_due_date', true ); |
|
| 1409 | + foreach ($invoices as $id) { |
|
| 1410 | + $due_date = get_post_meta($id, '_wpinv_due_date', true); |
|
| 1411 | 1411 | |
| 1412 | - foreach ( $reminder_days as $key => $days ) { |
|
| 1413 | - if ( $days !== '' ) { |
|
| 1414 | - $date_to_send[$id][] = date_i18n( 'Y-m-d', strtotime( $due_date ) + ( $days * DAY_IN_SECONDS ) ); |
|
| 1412 | + foreach ($reminder_days as $key => $days) { |
|
| 1413 | + if ($days !== '') { |
|
| 1414 | + $date_to_send[$id][] = date_i18n('Y-m-d', strtotime($due_date) + ($days * DAY_IN_SECONDS)); |
|
| 1415 | 1415 | } |
| 1416 | 1416 | } |
| 1417 | 1417 | } |
| 1418 | 1418 | |
| 1419 | - $today = date_i18n( 'Y-m-d' ); |
|
| 1419 | + $today = date_i18n('Y-m-d'); |
|
| 1420 | 1420 | $wpi_auto_reminder = true; |
| 1421 | 1421 | |
| 1422 | - foreach ( $date_to_send as $id => $values ) { |
|
| 1423 | - if ( in_array( $today, $values ) ) { |
|
| 1424 | - $sent = get_post_meta( $id, '_wpinv_reminder_sent', true ); |
|
| 1422 | + foreach ($date_to_send as $id => $values) { |
|
| 1423 | + if (in_array($today, $values)) { |
|
| 1424 | + $sent = get_post_meta($id, '_wpinv_reminder_sent', true); |
|
| 1425 | 1425 | |
| 1426 | - if ( isset( $sent ) && !empty( $sent ) ) { |
|
| 1427 | - if ( !in_array( $today, $sent ) ) { |
|
| 1428 | - do_action( 'wpinv_send_payment_reminder_notification', $id ); |
|
| 1426 | + if (isset($sent) && !empty($sent)) { |
|
| 1427 | + if (!in_array($today, $sent)) { |
|
| 1428 | + do_action('wpinv_send_payment_reminder_notification', $id); |
|
| 1429 | 1429 | } |
| 1430 | 1430 | } else { |
| 1431 | - do_action( 'wpinv_send_payment_reminder_notification', $id ); |
|
| 1431 | + do_action('wpinv_send_payment_reminder_notification', $id); |
|
| 1432 | 1432 | } |
| 1433 | 1433 | } |
| 1434 | 1434 | } |
| 1435 | 1435 | |
| 1436 | - $wpi_auto_reminder = false; |
|
| 1436 | + $wpi_auto_reminder = false; |
|
| 1437 | 1437 | } |
| 1438 | 1438 | } |
| 1439 | 1439 | |
| 1440 | -function wpinv_send_payment_reminder_notification( $invoice_id ) { |
|
| 1440 | +function wpinv_send_payment_reminder_notification($invoice_id) { |
|
| 1441 | 1441 | global $wpinv_email_search, $wpinv_email_replace; |
| 1442 | 1442 | |
| 1443 | 1443 | $email_type = 'overdue'; |
| 1444 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
| 1444 | + if (!wpinv_email_is_enabled($email_type)) { |
|
| 1445 | 1445 | return false; |
| 1446 | 1446 | } |
| 1447 | 1447 | |
| 1448 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1449 | - if ( empty( $invoice ) ) { |
|
| 1448 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1449 | + if (empty($invoice)) { |
|
| 1450 | 1450 | return false; |
| 1451 | 1451 | } |
| 1452 | 1452 | |
| 1453 | - if ( !$invoice->needs_payment() ) { |
|
| 1453 | + if (!$invoice->needs_payment()) { |
|
| 1454 | 1454 | return false; |
| 1455 | 1455 | } |
| 1456 | 1456 | |
| 1457 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
| 1458 | - if ( !is_email( $recipient ) ) { |
|
| 1457 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
| 1458 | + if (!is_email($recipient)) { |
|
| 1459 | 1459 | return false; |
| 1460 | 1460 | } |
| 1461 | 1461 | |
@@ -1471,70 +1471,70 @@ discard block |
||
| 1471 | 1471 | $replace = array(); |
| 1472 | 1472 | $replace['full_name'] = $invoice->get_user_full_name(); |
| 1473 | 1473 | $replace['invoice_number'] = $invoice->get_number(); |
| 1474 | - $replace['invoice_due_date']= $invoice->get_due_date( true ); |
|
| 1475 | - $replace['invoice_total'] = $invoice->get_total( true ); |
|
| 1476 | - $replace['invoice_link'] = $invoice->get_view_url( true ); |
|
| 1477 | - $replace['invoice_pay_link']= $replace['invoice_link']; |
|
| 1478 | - $replace['is_was'] = strtotime( $invoice->get_due_date() ) < strtotime( date_i18n( 'Y-m-d' ) ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ); |
|
| 1474 | + $replace['invoice_due_date'] = $invoice->get_due_date(true); |
|
| 1475 | + $replace['invoice_total'] = $invoice->get_total(true); |
|
| 1476 | + $replace['invoice_link'] = $invoice->get_view_url(true); |
|
| 1477 | + $replace['invoice_pay_link'] = $replace['invoice_link']; |
|
| 1478 | + $replace['is_was'] = strtotime($invoice->get_due_date()) < strtotime(date_i18n('Y-m-d')) ? __('was', 'invoicing') : __('is', 'invoicing'); |
|
| 1479 | 1479 | |
| 1480 | 1480 | $wpinv_email_search = $search; |
| 1481 | 1481 | $wpinv_email_replace = $replace; |
| 1482 | 1482 | |
| 1483 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
| 1484 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
| 1485 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
| 1486 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
| 1483 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
| 1484 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
| 1485 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
| 1486 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
| 1487 | 1487 | |
| 1488 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
| 1488 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
| 1489 | 1489 | |
| 1490 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
| 1490 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
| 1491 | 1491 | 'invoice' => $invoice, |
| 1492 | 1492 | 'email_type' => $email_type, |
| 1493 | 1493 | 'email_heading' => $email_heading, |
| 1494 | 1494 | 'sent_to_admin' => false, |
| 1495 | 1495 | 'plain_text' => false, |
| 1496 | 1496 | 'message_body' => $message_body |
| 1497 | - ) ); |
|
| 1497 | + )); |
|
| 1498 | 1498 | |
| 1499 | - $content = wpinv_email_format_text( $content ); |
|
| 1499 | + $content = wpinv_email_format_text($content); |
|
| 1500 | 1500 | |
| 1501 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
| 1502 | - if ( $sent ) { |
|
| 1503 | - do_action( 'wpinv_payment_reminder_sent', $invoice_id, $invoice ); |
|
| 1501 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
| 1502 | + if ($sent) { |
|
| 1503 | + do_action('wpinv_payment_reminder_sent', $invoice_id, $invoice); |
|
| 1504 | 1504 | } |
| 1505 | 1505 | |
| 1506 | 1506 | return $sent; |
| 1507 | 1507 | } |
| 1508 | -add_action( 'wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1 ); |
|
| 1508 | +add_action('wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1); |
|
| 1509 | 1509 | |
| 1510 | -function wpinv_payment_reminder_sent( $invoice_id, $invoice ) { |
|
| 1510 | +function wpinv_payment_reminder_sent($invoice_id, $invoice) { |
|
| 1511 | 1511 | global $wpi_auto_reminder; |
| 1512 | 1512 | |
| 1513 | - $sent = get_post_meta( $invoice_id, '_wpinv_reminder_sent', true ); |
|
| 1513 | + $sent = get_post_meta($invoice_id, '_wpinv_reminder_sent', true); |
|
| 1514 | 1514 | |
| 1515 | - if ( empty( $sent ) ) { |
|
| 1515 | + if (empty($sent)) { |
|
| 1516 | 1516 | $sent = array(); |
| 1517 | 1517 | } |
| 1518 | - $sent[] = date_i18n( 'Y-m-d' ); |
|
| 1518 | + $sent[] = date_i18n('Y-m-d'); |
|
| 1519 | 1519 | |
| 1520 | - update_post_meta( $invoice_id, '_wpinv_reminder_sent', $sent ); |
|
| 1520 | + update_post_meta($invoice_id, '_wpinv_reminder_sent', $sent); |
|
| 1521 | 1521 | |
| 1522 | - if ( $wpi_auto_reminder ) { // Auto reminder note. |
|
| 1523 | - $note = __( 'Manual reminder sent to the user.', 'invoicing' ); |
|
| 1524 | - $invoice->add_note( $note, false, false, true ); |
|
| 1522 | + if ($wpi_auto_reminder) { // Auto reminder note. |
|
| 1523 | + $note = __('Manual reminder sent to the user.', 'invoicing'); |
|
| 1524 | + $invoice->add_note($note, false, false, true); |
|
| 1525 | 1525 | } else { // Menual reminder note. |
| 1526 | - $note = __( 'Manual reminder sent to the user.', 'invoicing' ); |
|
| 1527 | - $invoice->add_note( $note ); |
|
| 1526 | + $note = __('Manual reminder sent to the user.', 'invoicing'); |
|
| 1527 | + $invoice->add_note($note); |
|
| 1528 | 1528 | } |
| 1529 | 1529 | } |
| 1530 | -add_action( 'wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2 ); |
|
| 1530 | +add_action('wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2); |
|
| 1531 | 1531 | |
| 1532 | -function wpinv_email_before_note_details( $invoice, $email_type, $sent_to_admin, $customer_note ) { |
|
| 1532 | +function wpinv_email_before_note_details($invoice, $email_type, $sent_to_admin, $customer_note) { |
|
| 1533 | 1533 | if ("wpi_invoice" === $invoice->post_type && !empty($customer_note)) { |
| 1534 | 1534 | $before_note = ''; |
| 1535 | - $before_note .= __( 'Hello, a note has just been added to your invoice:', 'invoicing' ); |
|
| 1536 | - $before_note .= '<blockquote class="wpinv-note">'.wpautop( wptexturize( $customer_note ) ).'</blockquote>'; |
|
| 1537 | - $before_note .= __( 'For your reference, your invoice details are shown below.', 'invoicing' ); |
|
| 1535 | + $before_note .= __('Hello, a note has just been added to your invoice:', 'invoicing'); |
|
| 1536 | + $before_note .= '<blockquote class="wpinv-note">' . wpautop(wptexturize($customer_note)) . '</blockquote>'; |
|
| 1537 | + $before_note .= __('For your reference, your invoice details are shown below.', 'invoicing'); |
|
| 1538 | 1538 | echo $before_note; |
| 1539 | 1539 | } |
| 1540 | 1540 | } |
| 1541 | 1541 | \ No newline at end of file |
@@ -1,25 +1,25 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | 6 | // Load colours |
| 7 | -$bg = wpinv_get_option( 'email_background_color', '#f5f5f5' ); |
|
| 8 | -$body = wpinv_get_option( 'email_body_background_color', '#fdfdfd' ); |
|
| 9 | -$base = wpinv_get_option( 'email_base_color', '#557da2' ); |
|
| 10 | -$base_text = wpinv_light_or_dark( $base, '#202020', '#ffffff' ); |
|
| 11 | -$text = wpinv_get_option( 'email_text_color', '#505050' ); |
|
| 7 | +$bg = wpinv_get_option('email_background_color', '#f5f5f5'); |
|
| 8 | +$body = wpinv_get_option('email_body_background_color', '#fdfdfd'); |
|
| 9 | +$base = wpinv_get_option('email_base_color', '#557da2'); |
|
| 10 | +$base_text = wpinv_light_or_dark($base, '#202020', '#ffffff'); |
|
| 11 | +$text = wpinv_get_option('email_text_color', '#505050'); |
|
| 12 | 12 | |
| 13 | -$bg_darker_10 = wpinv_hex_darker( $bg, 10 ); |
|
| 14 | -$body_darker_10 = wpinv_hex_darker( $body, 10 ); |
|
| 15 | -$base_lighter_20 = wpinv_hex_lighter( $base, 20 ); |
|
| 16 | -$base_lighter_40 = wpinv_hex_lighter( $base, 40 ); |
|
| 17 | -$text_lighter_20 = wpinv_hex_lighter( $text, 20 ); |
|
| 13 | +$bg_darker_10 = wpinv_hex_darker($bg, 10); |
|
| 14 | +$body_darker_10 = wpinv_hex_darker($body, 10); |
|
| 15 | +$base_lighter_20 = wpinv_hex_lighter($base, 20); |
|
| 16 | +$base_lighter_40 = wpinv_hex_lighter($base, 40); |
|
| 17 | +$text_lighter_20 = wpinv_hex_lighter($text, 20); |
|
| 18 | 18 | |
| 19 | 19 | // !important; is a gmail hack to prevent styles being stripped if it doesn't like something. |
| 20 | 20 | ?> |
| 21 | 21 | #wrapper { |
| 22 | - background-color: <?php echo esc_attr( $bg ); ?>; |
|
| 22 | + background-color: <?php echo esc_attr($bg); ?>; |
|
| 23 | 23 | margin: 0; |
| 24 | 24 | -webkit-text-size-adjust: none !important; |
| 25 | 25 | padding: 3%; |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | #template_container { |
| 42 | 42 | box-shadow: 0 1px 4px rgba(0,0,0,0.1) !important; |
| 43 | - background-color: <?php echo esc_attr( $body ); ?>; |
|
| 44 | - border: 1px solid <?php echo esc_attr( $bg_darker_10 ); ?>; |
|
| 43 | + background-color: <?php echo esc_attr($body); ?>; |
|
| 44 | + border: 1px solid <?php echo esc_attr($bg_darker_10); ?>; |
|
| 45 | 45 | border-radius: 3px !important; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | #template_header { |
| 49 | - background-color: <?php echo esc_attr( $base ); ?>; |
|
| 49 | + background-color: <?php echo esc_attr($base); ?>; |
|
| 50 | 50 | border-radius: 3px 3px 0 0 !important; |
| 51 | - color: <?php echo esc_attr( $base_text ); ?>; |
|
| 51 | + color: <?php echo esc_attr($base_text); ?>; |
|
| 52 | 52 | border-bottom: 0; |
| 53 | 53 | font-weight: bold; |
| 54 | 54 | line-height: 100%; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | #template_header h1 { |
| 64 | - color: <?php echo esc_attr( $base_text ); ?>; |
|
| 64 | + color: <?php echo esc_attr($base_text); ?>; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | #template_footer td { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | #template_footer #credit { |
| 74 | 74 | border:0; |
| 75 | - color: <?php echo esc_attr( $base_lighter_40 ); ?>; |
|
| 75 | + color: <?php echo esc_attr($base_lighter_40); ?>; |
|
| 76 | 76 | font-family: Arial; |
| 77 | 77 | font-size:12px; |
| 78 | 78 | line-height:125%; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | #body_content { |
| 84 | - background-color: <?php echo esc_attr( $body ); ?>; |
|
| 84 | + background-color: <?php echo esc_attr($body); ?>; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | #body_content table td { |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | #body_content_inner { |
| 104 | - color: <?php echo esc_attr( $text_lighter_20 ); ?>; |
|
| 104 | + color: <?php echo esc_attr($text_lighter_20); ?>; |
|
| 105 | 105 | font-family: Arial,Helvetica,sans-serif; |
| 106 | 106 | font-size: 14px; |
| 107 | 107 | line-height: 150%; |
@@ -109,17 +109,17 @@ discard block |
||
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | .td { |
| 112 | - color: <?php echo esc_attr( $text_lighter_20 ); ?>; |
|
| 113 | - border: 1px solid <?php echo esc_attr( $body_darker_10 ); ?>; |
|
| 112 | + color: <?php echo esc_attr($text_lighter_20); ?>; |
|
| 113 | + border: 1px solid <?php echo esc_attr($body_darker_10); ?>; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | .text { |
| 117 | - color: <?php echo esc_attr( $text ); ?>; |
|
| 117 | + color: <?php echo esc_attr($text); ?>; |
|
| 118 | 118 | font-family: Arial,Helvetica,sans-serif; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | .link { |
| 122 | - color: <?php echo esc_attr( $base ); ?>; |
|
| 122 | + color: <?php echo esc_attr($base); ?>; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | #header_wrapper { |
@@ -128,19 +128,19 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | h1 { |
| 131 | - color: <?php echo esc_attr( $base ); ?>; |
|
| 131 | + color: <?php echo esc_attr($base); ?>; |
|
| 132 | 132 | font-family: Arial,Helvetica,sans-serif; |
| 133 | 133 | font-size: 30px; |
| 134 | 134 | font-weight: 300; |
| 135 | 135 | line-height: 150%; |
| 136 | 136 | margin: 0; |
| 137 | 137 | text-align: <?php echo is_rtl() ? 'right' : 'left'; ?>; |
| 138 | - text-shadow: 0 1px 0 <?php echo esc_attr( $base_lighter_20 ); ?>; |
|
| 138 | + text-shadow: 0 1px 0 <?php echo esc_attr($base_lighter_20); ?>; |
|
| 139 | 139 | -webkit-font-smoothing: antialiased; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | h2 { |
| 143 | - color: <?php echo esc_attr( $base ); ?>; |
|
| 143 | + color: <?php echo esc_attr($base); ?>; |
|
| 144 | 144 | display: block; |
| 145 | 145 | font-family: Arial,Helvetica,sans-serif; |
| 146 | 146 | font-size: 18px; |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | h3 { |
| 154 | - color: <?php echo esc_attr( $base ); ?>; |
|
| 154 | + color: <?php echo esc_attr($base); ?>; |
|
| 155 | 155 | display: block; |
| 156 | 156 | font-family: Arial,Helvetica,sans-serif; |
| 157 | 157 | font-size: 16px; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | a { |
| 165 | - color: <?php echo esc_attr( $base ); ?>; |
|
| 165 | + color: <?php echo esc_attr($base); ?>; |
|
| 166 | 166 | font-weight: normal; |
| 167 | 167 | text-decoration: underline; |
| 168 | 168 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | .table-bordered { |
| 183 | - border: 1px solid <?php echo esc_attr( $body_darker_10 ); ?>; |
|
| 183 | + border: 1px solid <?php echo esc_attr($body_darker_10); ?>; |
|
| 184 | 184 | border-collapse: collapse; |
| 185 | 185 | border-spacing: 0; |
| 186 | 186 | width: 100%; |
@@ -188,8 +188,8 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | .table-bordered th, |
| 190 | 190 | .table-bordered td { |
| 191 | - border: 1px solid <?php echo esc_attr( $body_darker_10 ); ?>; |
|
| 192 | - color: <?php echo esc_attr( $text_lighter_20 ); ?>; |
|
| 191 | + border: 1px solid <?php echo esc_attr($body_darker_10); ?>; |
|
| 192 | + color: <?php echo esc_attr($text_lighter_20); ?>; |
|
| 193 | 193 | font-size: 14px; |
| 194 | 194 | } |
| 195 | 195 | .small { |
@@ -288,9 +288,9 @@ discard block |
||
| 288 | 288 | text-decoration: none; |
| 289 | 289 | } |
| 290 | 290 | .btn-default { |
| 291 | - color: <?php echo esc_attr( $base_text ); ?>; |
|
| 292 | - background-color: <?php echo esc_attr( $base ); ?>; |
|
| 293 | - border-color: <?php echo esc_attr( $base ); ?>; |
|
| 291 | + color: <?php echo esc_attr($base_text); ?>; |
|
| 292 | + background-color: <?php echo esc_attr($base); ?>; |
|
| 293 | + border-color: <?php echo esc_attr($base); ?>; |
|
| 294 | 294 | } |
| 295 | 295 | .btn-primary { |
| 296 | 296 | color: #fff; |
@@ -1,20 +1,20 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 7 | 7 | |
| 8 | -if ( $invoice->needs_payment() ) { |
|
| 8 | +if ($invoice->needs_payment()) { |
|
| 9 | 9 | ?> |
| 10 | - <p><?php printf( __( 'An invoice has been created for you on %s. To view / pay for this invoice please use the following link: %s', 'invoicing' ), wpinv_get_business_name(), '<a class="btn btn-success" href="' . esc_url( $invoice->get_view_url( true ) ) . '">' . __( 'View / Pay', 'invoicing' ) . '</a>' ); ?></p> |
|
| 10 | + <p><?php printf(__('An invoice has been created for you on %s. To view / pay for this invoice please use the following link: %s', 'invoicing'), wpinv_get_business_name(), '<a class="btn btn-success" href="' . esc_url($invoice->get_view_url(true)) . '">' . __('View / Pay', 'invoicing') . '</a>'); ?></p> |
|
| 11 | 11 | <?php |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
| 14 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
| 15 | 15 | |
| 16 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 18 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 19 | 19 | |
| 20 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 21 | 20 | \ No newline at end of file |
| 21 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
| 22 | 22 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -function wpinv_get_subscriptions( $args = array() ) { |
|
| 3 | - if ( empty( $args['parent_invoice_id'] ) ) { |
|
| 2 | +function wpinv_get_subscriptions($args = array()) { |
|
| 3 | + if (empty($args['parent_invoice_id'])) { |
|
| 4 | 4 | return false; |
| 5 | 5 | } |
| 6 | 6 | |
@@ -14,18 +14,18 @@ discard block |
||
| 14 | 14 | ); |
| 15 | 15 | |
| 16 | 16 | $args['post_parent'] = $args['parent_invoice_id']; |
| 17 | - $args = wp_parse_args( $args, $defaults ); |
|
| 17 | + $args = wp_parse_args($args, $defaults); |
|
| 18 | 18 | |
| 19 | - if( $args['numberposts'] < 1 ) { |
|
| 19 | + if ($args['numberposts'] < 1) { |
|
| 20 | 20 | $args['numberposts'] = 999999999999; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - $posts = get_posts( $args ); |
|
| 23 | + $posts = get_posts($args); |
|
| 24 | 24 | $subscriptions = array(); |
| 25 | - if ( !empty( $posts ) ) { |
|
| 26 | - foreach ( $posts as $post ) { |
|
| 27 | - if ( !empty( $post->ID ) ) { |
|
| 28 | - $subscriptions[] = wpinv_get_invoice( $post->ID ); |
|
| 25 | + if (!empty($posts)) { |
|
| 26 | + foreach ($posts as $post) { |
|
| 27 | + if (!empty($post->ID)) { |
|
| 28 | + $subscriptions[] = wpinv_get_invoice($post->ID); |
|
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | } |
@@ -33,19 +33,19 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | return $subscriptions; |
| 35 | 35 | } |
| 36 | -function wpinv_get_subscription( $id = 0, $by_profile_id = false ) { |
|
| 36 | +function wpinv_get_subscription($id = 0, $by_profile_id = false) { |
|
| 37 | 37 | global $wpdb; |
| 38 | 38 | |
| 39 | - if ( empty( $id ) ) { |
|
| 39 | + if (empty($id)) { |
|
| 40 | 40 | return false; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - $id = esc_sql( $id ); |
|
| 43 | + $id = esc_sql($id); |
|
| 44 | 44 | |
| 45 | - $invoice_id = $wpdb->get_var( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_profile_id' AND meta_value = '{$id}' LIMIT 1" ); |
|
| 45 | + $invoice_id = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_profile_id' AND meta_value = '{$id}' LIMIT 1"); |
|
| 46 | 46 | |
| 47 | - if ( $invoice_id != null ) { |
|
| 48 | - return wpinv_get_invoice( $invoice_id ); |
|
| 47 | + if ($invoice_id != null) { |
|
| 48 | + return wpinv_get_invoice($invoice_id); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | return false; |
@@ -55,47 +55,47 @@ discard block |
||
| 55 | 55 | * Records a new payment on the subscription |
| 56 | 56 | * |
| 57 | 57 | */ |
| 58 | -function wpinv_recurring_add_subscription_payment( $parent_invoice_id, $subscription_args = array() ) { |
|
| 59 | - $args = wp_parse_args( $subscription_args, array( |
|
| 58 | +function wpinv_recurring_add_subscription_payment($parent_invoice_id, $subscription_args = array()) { |
|
| 59 | + $args = wp_parse_args($subscription_args, array( |
|
| 60 | 60 | 'amount' => '', |
| 61 | 61 | 'transaction_id' => '', |
| 62 | 62 | 'gateway' => '' |
| 63 | - ) ); |
|
| 63 | + )); |
|
| 64 | 64 | |
| 65 | - if ( wpinv_payment_exists( $args['transaction_id'] ) ) { |
|
| 65 | + if (wpinv_payment_exists($args['transaction_id'])) { |
|
| 66 | 66 | return false; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - $parent_invoice = wpinv_get_invoice( $parent_invoice_id ); |
|
| 70 | - if ( empty( $parent_invoice ) ) { |
|
| 69 | + $parent_invoice = wpinv_get_invoice($parent_invoice_id); |
|
| 70 | + if (empty($parent_invoice)) { |
|
| 71 | 71 | return; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | $invoice = new WPInv_Invoice(); |
| 75 | - $invoice->set( 'post_type', 'wpi_invoice' ); |
|
| 76 | - $invoice->set( 'parent_invoice', $parent_invoice_id ); |
|
| 77 | - $invoice->set( 'currency', $parent_invoice->get_currency() ); |
|
| 78 | - $invoice->set( 'transaction_id', $args['transaction_id'] ); |
|
| 79 | - $invoice->set( 'key', $parent_invoice->generate_key() ); |
|
| 80 | - $invoice->set( 'ip', $parent_invoice->ip ); |
|
| 81 | - $invoice->set( 'user_id', $parent_invoice->get_user_id() ); |
|
| 82 | - $invoice->set( 'first_name', $parent_invoice->get_first_name() ); |
|
| 83 | - $invoice->set( 'last_name', $parent_invoice->get_last_name() ); |
|
| 84 | - $invoice->set( 'phone', $parent_invoice->phone ); |
|
| 85 | - $invoice->set( 'address', $parent_invoice->address ); |
|
| 86 | - $invoice->set( 'city', $parent_invoice->city ); |
|
| 87 | - $invoice->set( 'country', $parent_invoice->country ); |
|
| 88 | - $invoice->set( 'state', $parent_invoice->state ); |
|
| 89 | - $invoice->set( 'zip', $parent_invoice->zip ); |
|
| 90 | - $invoice->set( 'company', $parent_invoice->company ); |
|
| 91 | - $invoice->set( 'vat_number', $parent_invoice->vat_number ); |
|
| 92 | - $invoice->set( 'vat_rate', $parent_invoice->vat_rate ); |
|
| 93 | - $invoice->set( 'adddress_confirmed', $parent_invoice->adddress_confirmed ); |
|
| 94 | - |
|
| 95 | - if ( empty( $args['gateway'] ) ) { |
|
| 96 | - $invoice->set( 'gateway', $parent_invoice->get_gateway() ); |
|
| 75 | + $invoice->set('post_type', 'wpi_invoice'); |
|
| 76 | + $invoice->set('parent_invoice', $parent_invoice_id); |
|
| 77 | + $invoice->set('currency', $parent_invoice->get_currency()); |
|
| 78 | + $invoice->set('transaction_id', $args['transaction_id']); |
|
| 79 | + $invoice->set('key', $parent_invoice->generate_key()); |
|
| 80 | + $invoice->set('ip', $parent_invoice->ip); |
|
| 81 | + $invoice->set('user_id', $parent_invoice->get_user_id()); |
|
| 82 | + $invoice->set('first_name', $parent_invoice->get_first_name()); |
|
| 83 | + $invoice->set('last_name', $parent_invoice->get_last_name()); |
|
| 84 | + $invoice->set('phone', $parent_invoice->phone); |
|
| 85 | + $invoice->set('address', $parent_invoice->address); |
|
| 86 | + $invoice->set('city', $parent_invoice->city); |
|
| 87 | + $invoice->set('country', $parent_invoice->country); |
|
| 88 | + $invoice->set('state', $parent_invoice->state); |
|
| 89 | + $invoice->set('zip', $parent_invoice->zip); |
|
| 90 | + $invoice->set('company', $parent_invoice->company); |
|
| 91 | + $invoice->set('vat_number', $parent_invoice->vat_number); |
|
| 92 | + $invoice->set('vat_rate', $parent_invoice->vat_rate); |
|
| 93 | + $invoice->set('adddress_confirmed', $parent_invoice->adddress_confirmed); |
|
| 94 | + |
|
| 95 | + if (empty($args['gateway'])) { |
|
| 96 | + $invoice->set('gateway', $parent_invoice->get_gateway()); |
|
| 97 | 97 | } else { |
| 98 | - $invoice->set( 'gateway', $args['gateway'] ); |
|
| 98 | + $invoice->set('gateway', $args['gateway']); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | $recurring_details = $parent_invoice->get_recurring_details(); |
@@ -103,11 +103,11 @@ discard block |
||
| 103 | 103 | // increase the earnings for each item in the subscription |
| 104 | 104 | $items = $recurring_details['cart_details']; |
| 105 | 105 | |
| 106 | - if ( $items ) { |
|
| 106 | + if ($items) { |
|
| 107 | 107 | $add_items = array(); |
| 108 | 108 | $cart_details = array(); |
| 109 | 109 | |
| 110 | - foreach ( $items as $item ) { |
|
| 110 | + foreach ($items as $item) { |
|
| 111 | 111 | $add_item = array(); |
| 112 | 112 | $add_item['id'] = $item['id']; |
| 113 | 113 | $add_item['quantity'] = $item['quantity']; |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | break; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $invoice->set( 'items', $add_items ); |
|
| 120 | + $invoice->set('items', $add_items); |
|
| 121 | 121 | $invoice->cart_details = $cart_details; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -127,277 +127,277 @@ discard block |
||
| 127 | 127 | $tax = $recurring_details['tax']; |
| 128 | 128 | $discount = $recurring_details['discount']; |
| 129 | 129 | |
| 130 | - if ( $discount > 0 ) { |
|
| 131 | - $invoice->set( 'discount_code', $parent_invoice->discount_code ); |
|
| 130 | + if ($discount > 0) { |
|
| 131 | + $invoice->set('discount_code', $parent_invoice->discount_code); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - $invoice->subtotal = wpinv_round_amount( $subtotal ); |
|
| 135 | - $invoice->tax = wpinv_round_amount( $tax ); |
|
| 136 | - $invoice->discount = wpinv_round_amount( $discount ); |
|
| 137 | - $invoice->total = wpinv_round_amount( $total ); |
|
| 134 | + $invoice->subtotal = wpinv_round_amount($subtotal); |
|
| 135 | + $invoice->tax = wpinv_round_amount($tax); |
|
| 136 | + $invoice->discount = wpinv_round_amount($discount); |
|
| 137 | + $invoice->total = wpinv_round_amount($total); |
|
| 138 | 138 | $invoice->save(); |
| 139 | 139 | |
| 140 | - wpinv_update_payment_status( $invoice->ID, 'publish' ); |
|
| 140 | + wpinv_update_payment_status($invoice->ID, 'publish'); |
|
| 141 | 141 | sleep(1); |
| 142 | - wpinv_update_payment_status( $invoice->ID, 'wpi-renewal' ); |
|
| 142 | + wpinv_update_payment_status($invoice->ID, 'wpi-renewal'); |
|
| 143 | 143 | |
| 144 | - $invoice = wpinv_get_invoice( $invoice->ID ); |
|
| 144 | + $invoice = wpinv_get_invoice($invoice->ID); |
|
| 145 | 145 | |
| 146 | - $subscription_data = wpinv_payment_subscription_data( $parent_invoice ); |
|
| 146 | + $subscription_data = wpinv_payment_subscription_data($parent_invoice); |
|
| 147 | 147 | $subscription_data['recurring_amount'] = $invoice->get_total(); |
| 148 | - $subscription_data['created'] = current_time( 'mysql', 0 ); |
|
| 149 | - $subscription_data['expiration'] = $invoice->get_new_expiration( $subscription_data['item_id'] ); |
|
| 148 | + $subscription_data['created'] = current_time('mysql', 0); |
|
| 149 | + $subscription_data['expiration'] = $invoice->get_new_expiration($subscription_data['item_id']); |
|
| 150 | 150 | |
| 151 | 151 | // Retrieve pending subscription from database and update it's status to active and set proper profile ID |
| 152 | - $invoice->update_subscription( $subscription_data ); |
|
| 152 | + $invoice->update_subscription($subscription_data); |
|
| 153 | 153 | |
| 154 | - do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $parent_invoice, $subscription_args ); |
|
| 155 | - do_action( 'wpinv_recurring_record_payment', $invoice->ID, $parent_invoice_id, $subscription_args ); |
|
| 154 | + do_action('wpinv_recurring_add_subscription_payment', $invoice, $parent_invoice, $subscription_args); |
|
| 155 | + do_action('wpinv_recurring_record_payment', $invoice->ID, $parent_invoice_id, $subscription_args); |
|
| 156 | 156 | |
| 157 | 157 | return $invoice; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | -function wpinv_payment_exists( $txn_id = '' ) { |
|
| 160 | +function wpinv_payment_exists($txn_id = '') { |
|
| 161 | 161 | global $wpdb; |
| 162 | 162 | |
| 163 | - if ( empty( $txn_id ) ) { |
|
| 163 | + if (empty($txn_id)) { |
|
| 164 | 164 | return false; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - $txn_id = esc_sql( $txn_id ); |
|
| 167 | + $txn_id = esc_sql($txn_id); |
|
| 168 | 168 | |
| 169 | - $invoice = $wpdb->get_var( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = '{$txn_id}' LIMIT 1" ); |
|
| 169 | + $invoice = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = '{$txn_id}' LIMIT 1"); |
|
| 170 | 170 | |
| 171 | - if ( $invoice != null ) { |
|
| 171 | + if ($invoice != null) { |
|
| 172 | 172 | return true; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | return false; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | -function wpinv_is_subscription_payment( $invoice = '' ) { |
|
| 179 | - if ( empty( $invoice ) ) { |
|
| 178 | +function wpinv_is_subscription_payment($invoice = '') { |
|
| 179 | + if (empty($invoice)) { |
|
| 180 | 180 | return false; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - if ( !is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
| 184 | - $invoice = wpinv_get_invoice( $invoice ); |
|
| 183 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
| 184 | + $invoice = wpinv_get_invoice($invoice); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if ( empty( $invoice ) ) { |
|
| 187 | + if (empty($invoice)) { |
|
| 188 | 188 | return false; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if ( $invoice->is_renewal() ) { |
|
| 191 | + if ($invoice->is_renewal()) { |
|
| 192 | 192 | return true; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | return false; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | -function wpinv_payment_subscription_data( $invoice = '' ) { |
|
| 199 | - if ( empty( $invoice ) ) { |
|
| 198 | +function wpinv_payment_subscription_data($invoice = '') { |
|
| 199 | + if (empty($invoice)) { |
|
| 200 | 200 | return false; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - if ( !is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
| 204 | - $invoice = wpinv_get_invoice( $invoice ); |
|
| 203 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
| 204 | + $invoice = wpinv_get_invoice($invoice); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - if ( empty( $invoice ) ) { |
|
| 207 | + if (empty($invoice)) { |
|
| 208 | 208 | return false; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | return $invoice->get_subscription_data(); |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | -function wpinv_payment_link_transaction_id( $invoice = '' ) { |
|
| 215 | - if ( empty( $invoice ) ) { |
|
| 214 | +function wpinv_payment_link_transaction_id($invoice = '') { |
|
| 215 | + if (empty($invoice)) { |
|
| 216 | 216 | return false; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - if ( !is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
| 220 | - $invoice = wpinv_get_invoice( $invoice ); |
|
| 219 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
| 220 | + $invoice = wpinv_get_invoice($invoice); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - if ( empty( $invoice ) ) { |
|
| 223 | + if (empty($invoice)) { |
|
| 224 | 224 | return false; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - return apply_filters( 'wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice ); |
|
| 227 | + return apply_filters('wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | -function wpinv_get_pretty_subscription_period( $period ) { |
|
| 230 | +function wpinv_get_pretty_subscription_period($period) { |
|
| 231 | 231 | $frequency = ''; |
| 232 | 232 | //Format period details |
| 233 | - switch ( $period ) { |
|
| 233 | + switch ($period) { |
|
| 234 | 234 | case 'D' : |
| 235 | 235 | case 'day' : |
| 236 | - $frequency = __( 'Daily', 'invoicing' ); |
|
| 236 | + $frequency = __('Daily', 'invoicing'); |
|
| 237 | 237 | break; |
| 238 | 238 | case 'W' : |
| 239 | 239 | case 'week' : |
| 240 | - $frequency = __( 'Weekly', 'invoicing' ); |
|
| 240 | + $frequency = __('Weekly', 'invoicing'); |
|
| 241 | 241 | break; |
| 242 | 242 | case 'M' : |
| 243 | 243 | case 'month' : |
| 244 | - $frequency = __( 'Monthly', 'invoicing' ); |
|
| 244 | + $frequency = __('Monthly', 'invoicing'); |
|
| 245 | 245 | break; |
| 246 | 246 | case 'Y' : |
| 247 | 247 | case 'year' : |
| 248 | - $frequency = __( 'Yearly', 'invoicing' ); |
|
| 248 | + $frequency = __('Yearly', 'invoicing'); |
|
| 249 | 249 | break; |
| 250 | 250 | default : |
| 251 | - $frequency = apply_filters( 'wpinv_pretty_subscription_period', $frequency, $period ); |
|
| 251 | + $frequency = apply_filters('wpinv_pretty_subscription_period', $frequency, $period); |
|
| 252 | 252 | break; |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | return $frequency; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | -function wpinv_get_pretty_subscription_period_name( $period ) { |
|
| 258 | +function wpinv_get_pretty_subscription_period_name($period) { |
|
| 259 | 259 | $frequency = ''; |
| 260 | 260 | //Format period details |
| 261 | - switch ( $period ) { |
|
| 261 | + switch ($period) { |
|
| 262 | 262 | case 'D' : |
| 263 | 263 | case 'day' : |
| 264 | - $frequency = __( 'Day', 'invoicing' ); |
|
| 264 | + $frequency = __('Day', 'invoicing'); |
|
| 265 | 265 | break; |
| 266 | 266 | case 'W' : |
| 267 | 267 | case 'week' : |
| 268 | - $frequency = __( 'Week', 'invoicing' ); |
|
| 268 | + $frequency = __('Week', 'invoicing'); |
|
| 269 | 269 | break; |
| 270 | 270 | case 'M' : |
| 271 | 271 | case 'month' : |
| 272 | - $frequency = __( 'Month', 'invoicing' ); |
|
| 272 | + $frequency = __('Month', 'invoicing'); |
|
| 273 | 273 | break; |
| 274 | 274 | case 'Y' : |
| 275 | 275 | case 'year' : |
| 276 | - $frequency = __( 'Year', 'invoicing' ); |
|
| 276 | + $frequency = __('Year', 'invoicing'); |
|
| 277 | 277 | break; |
| 278 | 278 | default : |
| 279 | - $frequency = apply_filters( 'wpinv_pretty_subscription_period_name', $frequency, $period ); |
|
| 279 | + $frequency = apply_filters('wpinv_pretty_subscription_period_name', $frequency, $period); |
|
| 280 | 280 | break; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | return $frequency; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | -function wpinv_subscription_initial_payment_desc( $amount, $period, $interval, $trial_period = '', $trial_interval = 0 ) { |
|
| 286 | +function wpinv_subscription_initial_payment_desc($amount, $period, $interval, $trial_period = '', $trial_interval = 0) { |
|
| 287 | 287 | $interval = (int)$interval > 0 ? (int)$interval : 1; |
| 288 | 288 | |
| 289 | - if ( $trial_interval > 0 && !empty( $trial_period ) ) { |
|
| 290 | - $amount = __( 'Free', 'invoicing' ); |
|
| 289 | + if ($trial_interval > 0 && !empty($trial_period)) { |
|
| 290 | + $amount = __('Free', 'invoicing'); |
|
| 291 | 291 | $interval = $trial_interval; |
| 292 | 292 | $period = $trial_period; |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | $description = ''; |
| 296 | - switch ( $period ) { |
|
| 296 | + switch ($period) { |
|
| 297 | 297 | case 'D' : |
| 298 | 298 | case 'day' : |
| 299 | - $description = wp_sprintf( _n( '%s for the first day.', '%s for the first %d days.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 299 | + $description = wp_sprintf(_n('%s for the first day.', '%s for the first %d days.', $interval, 'invoicing'), $amount, $interval); |
|
| 300 | 300 | break; |
| 301 | 301 | case 'W' : |
| 302 | 302 | case 'week' : |
| 303 | - $description = wp_sprintf( _n( '%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 303 | + $description = wp_sprintf(_n('%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing'), $amount, $interval); |
|
| 304 | 304 | break; |
| 305 | 305 | case 'M' : |
| 306 | 306 | case 'month' : |
| 307 | - $description = wp_sprintf( _n( '%s for the first month.', '%s for the first %d months.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 307 | + $description = wp_sprintf(_n('%s for the first month.', '%s for the first %d months.', $interval, 'invoicing'), $amount, $interval); |
|
| 308 | 308 | break; |
| 309 | 309 | case 'Y' : |
| 310 | 310 | case 'year' : |
| 311 | - $description = wp_sprintf( _n( '%s for the first year.', '%s for the first %d years.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 311 | + $description = wp_sprintf(_n('%s for the first year.', '%s for the first %d years.', $interval, 'invoicing'), $amount, $interval); |
|
| 312 | 312 | break; |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - return apply_filters( 'wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval ); |
|
| 315 | + return apply_filters('wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | -function wpinv_subscription_recurring_payment_desc( $amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0 ) { |
|
| 318 | +function wpinv_subscription_recurring_payment_desc($amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0) { |
|
| 319 | 319 | $interval = (int)$interval > 0 ? (int)$interval : 1; |
| 320 | 320 | $bill_times = (int)$bill_times > 0 ? (int)$bill_times : 0; |
| 321 | 321 | |
| 322 | 322 | $description = ''; |
| 323 | - switch ( $period ) { |
|
| 323 | + switch ($period) { |
|
| 324 | 324 | case 'D' : |
| 325 | 325 | case 'day' : |
| 326 | - if ( (int)$bill_times > 0 ) { |
|
| 327 | - if ( $interval > 1 ) { |
|
| 328 | - if ( $bill_times > 1 ) { |
|
| 329 | - $description = wp_sprintf( __( '%s for each %d days, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
| 326 | + if ((int)$bill_times > 0) { |
|
| 327 | + if ($interval > 1) { |
|
| 328 | + if ($bill_times > 1) { |
|
| 329 | + $description = wp_sprintf(__('%s for each %d days, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
| 330 | 330 | } else { |
| 331 | - $description = wp_sprintf( __( '%s for %d days.', 'invoicing' ), $amount, $interval ); |
|
| 331 | + $description = wp_sprintf(__('%s for %d days.', 'invoicing'), $amount, $interval); |
|
| 332 | 332 | } |
| 333 | 333 | } else { |
| 334 | - $description = wp_sprintf( _n( '%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
| 334 | + $description = wp_sprintf(_n('%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
| 335 | 335 | } |
| 336 | 336 | } else { |
| 337 | - $description = wp_sprintf( _n( '%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval ); |
|
| 337 | + $description = wp_sprintf(_n('%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval); |
|
| 338 | 338 | } |
| 339 | 339 | break; |
| 340 | 340 | case 'W' : |
| 341 | 341 | case 'week' : |
| 342 | - if ( (int)$bill_times > 0 ) { |
|
| 343 | - if ( $interval > 1 ) { |
|
| 344 | - if ( $bill_times > 1 ) { |
|
| 345 | - $description = wp_sprintf( __( '%s for each %d weeks, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
| 342 | + if ((int)$bill_times > 0) { |
|
| 343 | + if ($interval > 1) { |
|
| 344 | + if ($bill_times > 1) { |
|
| 345 | + $description = wp_sprintf(__('%s for each %d weeks, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
| 346 | 346 | } else { |
| 347 | - $description = wp_sprintf( __( '%s for %d weeks.', 'invoicing' ), $amount, $interval ); |
|
| 347 | + $description = wp_sprintf(__('%s for %d weeks.', 'invoicing'), $amount, $interval); |
|
| 348 | 348 | } |
| 349 | 349 | } else { |
| 350 | - $description = wp_sprintf( _n( '%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
| 350 | + $description = wp_sprintf(_n('%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
| 351 | 351 | } |
| 352 | 352 | } else { |
| 353 | - $description = wp_sprintf( _n( '%s for each week.', '%s for each %d weeks.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 353 | + $description = wp_sprintf(_n('%s for each week.', '%s for each %d weeks.', $interval, 'invoicing'), $amount, $interval); |
|
| 354 | 354 | } |
| 355 | 355 | break; |
| 356 | 356 | case 'M' : |
| 357 | 357 | case 'month' : |
| 358 | - if ( (int)$bill_times > 0 ) { |
|
| 359 | - if ( $interval > 1 ) { |
|
| 360 | - if ( $bill_times > 1 ) { |
|
| 361 | - $description = wp_sprintf( __( '%s for each %d months, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
| 358 | + if ((int)$bill_times > 0) { |
|
| 359 | + if ($interval > 1) { |
|
| 360 | + if ($bill_times > 1) { |
|
| 361 | + $description = wp_sprintf(__('%s for each %d months, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
| 362 | 362 | } else { |
| 363 | - $description = wp_sprintf( __( '%s for %d months.', 'invoicing' ), $amount, $interval ); |
|
| 363 | + $description = wp_sprintf(__('%s for %d months.', 'invoicing'), $amount, $interval); |
|
| 364 | 364 | } |
| 365 | 365 | } else { |
| 366 | - $description = wp_sprintf( _n( '%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
| 366 | + $description = wp_sprintf(_n('%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
| 367 | 367 | } |
| 368 | 368 | } else { |
| 369 | - $description = wp_sprintf( _n( '%s for each month.', '%s for each %d months.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 369 | + $description = wp_sprintf(_n('%s for each month.', '%s for each %d months.', $interval, 'invoicing'), $amount, $interval); |
|
| 370 | 370 | } |
| 371 | 371 | break; |
| 372 | 372 | case 'Y' : |
| 373 | 373 | case 'year' : |
| 374 | - if ( (int)$bill_times > 0 ) { |
|
| 375 | - if ( $interval > 1 ) { |
|
| 376 | - if ( $bill_times > 1 ) { |
|
| 377 | - $description = wp_sprintf( __( '%s for each %d years, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
| 374 | + if ((int)$bill_times > 0) { |
|
| 375 | + if ($interval > 1) { |
|
| 376 | + if ($bill_times > 1) { |
|
| 377 | + $description = wp_sprintf(__('%s for each %d years, for %d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
| 378 | 378 | } else { |
| 379 | - $description = wp_sprintf( __( '%s for %d years.', 'invoicing'), $amount, $interval ); |
|
| 379 | + $description = wp_sprintf(__('%s for %d years.', 'invoicing'), $amount, $interval); |
|
| 380 | 380 | } |
| 381 | 381 | } else { |
| 382 | - $description = wp_sprintf( _n( '%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
| 382 | + $description = wp_sprintf(_n('%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
| 383 | 383 | } |
| 384 | 384 | } else { |
| 385 | - $description = wp_sprintf( _n( '%s for each year.', '%s for each %d years.', $interval, 'invoicing' ), $amount, $interval ); |
|
| 385 | + $description = wp_sprintf(_n('%s for each year.', '%s for each %d years.', $interval, 'invoicing'), $amount, $interval); |
|
| 386 | 386 | } |
| 387 | 387 | break; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - return apply_filters( 'wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval ); |
|
| 390 | + return apply_filters('wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval); |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | -function wpinv_subscription_payment_desc( $invoice ) { |
|
| 394 | - if ( empty( $invoice ) ) { |
|
| 393 | +function wpinv_subscription_payment_desc($invoice) { |
|
| 394 | + if (empty($invoice)) { |
|
| 395 | 395 | return NULL; |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | $description = ''; |
| 399 | - if ( $invoice->is_parent() && $item = $invoice->get_recurring( true ) ) { |
|
| 400 | - if ( $item->has_free_trial() ) { |
|
| 399 | + if ($invoice->is_parent() && $item = $invoice->get_recurring(true)) { |
|
| 400 | + if ($item->has_free_trial()) { |
|
| 401 | 401 | $trial_period = $item->get_trial_period(); |
| 402 | 402 | $trial_interval = $item->get_trial_interval(); |
| 403 | 403 | } else { |
@@ -405,45 +405,45 @@ discard block |
||
| 405 | 405 | $trial_interval = 0; |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - $description = wpinv_get_billing_cycle( $invoice->get_total(), $invoice->get_recurring_details( 'total' ), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency() ); |
|
| 408 | + $description = wpinv_get_billing_cycle($invoice->get_total(), $invoice->get_recurring_details('total'), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency()); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - return apply_filters( 'wpinv_subscription_payment_desc', $description, $invoice ); |
|
| 411 | + return apply_filters('wpinv_subscription_payment_desc', $description, $invoice); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | -function wpinv_get_billing_cycle( $initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '' ) { |
|
| 415 | - $initial_total = wpinv_round_amount( $initial ); |
|
| 416 | - $recurring_total = wpinv_round_amount( $recurring ); |
|
| 414 | +function wpinv_get_billing_cycle($initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '') { |
|
| 415 | + $initial_total = wpinv_round_amount($initial); |
|
| 416 | + $recurring_total = wpinv_round_amount($recurring); |
|
| 417 | 417 | |
| 418 | - if ( $trial_interval > 0 && !empty( $trial_period ) ) { |
|
| 418 | + if ($trial_interval > 0 && !empty($trial_period)) { |
|
| 419 | 419 | // Free trial |
| 420 | 420 | } else { |
| 421 | - if ( $bill_times == 1 ) { |
|
| 421 | + if ($bill_times == 1) { |
|
| 422 | 422 | $recurring_total = $initial_total; |
| 423 | - } else if ( $bill_times > 1 && $initial_total != $recurring_total ) { |
|
| 423 | + } else if ($bill_times > 1 && $initial_total != $recurring_total) { |
|
| 424 | 424 | $bill_times--; |
| 425 | 425 | } |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - $initial_amount = wpinv_price( wpinv_format_amount( $initial_total ), $currency ); |
|
| 429 | - $recurring_amount = wpinv_price( wpinv_format_amount( $recurring_total ), $currency ); |
|
| 428 | + $initial_amount = wpinv_price(wpinv_format_amount($initial_total), $currency); |
|
| 429 | + $recurring_amount = wpinv_price(wpinv_format_amount($recurring_total), $currency); |
|
| 430 | 430 | |
| 431 | - $recurring = wpinv_subscription_recurring_payment_desc( $recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval ); |
|
| 431 | + $recurring = wpinv_subscription_recurring_payment_desc($recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval); |
|
| 432 | 432 | |
| 433 | - if ( $initial_total != $recurring_total ) { |
|
| 434 | - $initial = wpinv_subscription_initial_payment_desc( $initial_amount, $period, $interval, $trial_period, $trial_interval ); |
|
| 433 | + if ($initial_total != $recurring_total) { |
|
| 434 | + $initial = wpinv_subscription_initial_payment_desc($initial_amount, $period, $interval, $trial_period, $trial_interval); |
|
| 435 | 435 | |
| 436 | - $description = wp_sprintf( __( '%s Then %s', 'invoicing' ), $initial, $recurring ); |
|
| 436 | + $description = wp_sprintf(__('%s Then %s', 'invoicing'), $initial, $recurring); |
|
| 437 | 437 | } else { |
| 438 | 438 | $description = $recurring; |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | - return apply_filters( 'wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency ); |
|
| 441 | + return apply_filters('wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency); |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | -function wpinv_recurring_send_payment_failed( $invoice ) { |
|
| 445 | - if ( !empty( $invoice->ID ) ) { |
|
| 446 | - wpinv_failed_invoice_notification( $invoice->ID ); |
|
| 444 | +function wpinv_recurring_send_payment_failed($invoice) { |
|
| 445 | + if (!empty($invoice->ID)) { |
|
| 446 | + wpinv_failed_invoice_notification($invoice->ID); |
|
| 447 | 447 | } |
| 448 | 448 | } |
| 449 | -add_action( 'wpinv_recurring_payment_failed', 'wpinv_recurring_send_payment_failed', 10, 1 ); |
|
| 450 | 449 | \ No newline at end of file |
| 450 | +add_action('wpinv_recurring_payment_failed', 'wpinv_recurring_send_payment_failed', 10, 1); |
|
| 451 | 451 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | 6 | global $wpinv_euvat, $ajax_cart_details; |
@@ -11,152 +11,152 @@ discard block |
||
| 11 | 11 | $quantities_enabled = wpinv_item_quantities_enabled(); |
| 12 | 12 | $use_taxes = wpinv_use_taxes(); |
| 13 | 13 | $zero_tax = !(float)$invoice->get_tax() > 0 ? true : false; |
| 14 | -$tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' ); |
|
| 15 | -$tax_title = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
| 14 | +$tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing'); |
|
| 15 | +$tax_title = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
| 16 | 16 | |
| 17 | -do_action( 'wpinv_before_email_items', $invoice ); ?> |
|
| 17 | +do_action('wpinv_before_email_items', $invoice); ?> |
|
| 18 | 18 | <div id="wpinv-email-items"> |
| 19 | - <h3 class="wpinv-items-t"><?php echo apply_filters( 'wpinv_email_items_title', __( 'Items', 'invoicing' ) ); ?></h3> |
|
| 19 | + <h3 class="wpinv-items-t"><?php echo apply_filters('wpinv_email_items_title', __('Items', 'invoicing')); ?></h3> |
|
| 20 | 20 | <table id="wpinv_checkout_cart" class="table table-bordered table-hover"> |
| 21 | 21 | <thead> |
| 22 | 22 | <tr class="wpinv_cart_header_row"> |
| 23 | - <?php do_action( 'wpinv_email_items_table_header_first' ); ?> |
|
| 24 | - <th class="wpinv_cart_item_name text-left"><?php _e( 'Item Name', 'invoicing' ); ?></th> |
|
| 25 | - <th class="wpinv_cart_item_price text-right"><?php _e( 'Item Price', 'invoicing' ); ?></th> |
|
| 26 | - <?php if ( $quantities_enabled ) { ?> |
|
| 27 | - <th class="wpinv_cart_item_qty text-right"><?php _e( 'Qty', 'invoicing' ); ?></th> |
|
| 23 | + <?php do_action('wpinv_email_items_table_header_first'); ?> |
|
| 24 | + <th class="wpinv_cart_item_name text-left"><?php _e('Item Name', 'invoicing'); ?></th> |
|
| 25 | + <th class="wpinv_cart_item_price text-right"><?php _e('Item Price', 'invoicing'); ?></th> |
|
| 26 | + <?php if ($quantities_enabled) { ?> |
|
| 27 | + <th class="wpinv_cart_item_qty text-right"><?php _e('Qty', 'invoicing'); ?></th> |
|
| 28 | 28 | <?php } ?> |
| 29 | - <?php if ( !$zero_tax && $use_taxes ) { ?> |
|
| 29 | + <?php if (!$zero_tax && $use_taxes) { ?> |
|
| 30 | 30 | <th class="wpinv_cart_item_tax text-right"><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></th> |
| 31 | 31 | <?php } ?> |
| 32 | - <th class="wpinv_cart_item_subtotal text-right"><?php echo __( 'Item Total', 'invoicing' ) . ' <span class="normal small">' . $tax_title . '<span>'; ?></th> |
|
| 33 | - <?php do_action( 'wpinv_email_items_table_header_last' ); ?> |
|
| 32 | + <th class="wpinv_cart_item_subtotal text-right"><?php echo __('Item Total', 'invoicing') . ' <span class="normal small">' . $tax_title . '<span>'; ?></th> |
|
| 33 | + <?php do_action('wpinv_email_items_table_header_last'); ?> |
|
| 34 | 34 | </tr> |
| 35 | 35 | </thead> |
| 36 | 36 | <tbody> |
| 37 | 37 | <?php |
| 38 | - do_action( 'wpinv_email_items_before' ); |
|
| 39 | - if ( $cart_items ) { |
|
| 40 | - foreach ( $cart_items as $key => $item ) { |
|
| 41 | - $wpi_item = $item['id'] ? new WPInv_Item( $item['id'] ) : NULL; |
|
| 38 | + do_action('wpinv_email_items_before'); |
|
| 39 | + if ($cart_items) { |
|
| 40 | + foreach ($cart_items as $key => $item) { |
|
| 41 | + $wpi_item = $item['id'] ? new WPInv_Item($item['id']) : NULL; |
|
| 42 | 42 | ?> |
| 43 | - <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr( $key ) . '_' . esc_attr( $item['id'] ); ?>" data-item-id="<?php echo esc_attr( $item['id'] ); ?>"> |
|
| 44 | - <?php do_action( 'wpinv_email_items_table_body_first', $item ); ?> |
|
| 43 | + <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr($key) . '_' . esc_attr($item['id']); ?>" data-item-id="<?php echo esc_attr($item['id']); ?>"> |
|
| 44 | + <?php do_action('wpinv_email_items_table_body_first', $item); ?> |
|
| 45 | 45 | <td class="wpinv_cart_item_name text-left"> |
| 46 | 46 | <?php |
| 47 | - if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $item['id'] ) ) { |
|
| 47 | + if (current_theme_supports('post-thumbnails') && has_post_thumbnail($item['id'])) { |
|
| 48 | 48 | echo '<div class="wpinv_cart_item_image">'; |
| 49 | - echo get_the_post_thumbnail( $item['id'], apply_filters( 'wpinv_checkout_image_size', array( 25,25 ) ) ); |
|
| 49 | + echo get_the_post_thumbnail($item['id'], apply_filters('wpinv_checkout_image_size', array(25, 25))); |
|
| 50 | 50 | echo '</div>'; |
| 51 | 51 | } |
| 52 | - $item_title = esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $wpi_item ); |
|
| 52 | + $item_title = esc_html(wpinv_get_cart_item_name($item)) . wpinv_get_item_suffix($wpi_item); |
|
| 53 | 53 | echo '<span class="wpinv_email_cart_item_title">' . $item_title . '</span>'; |
| 54 | 54 | |
| 55 | - $summary = apply_filters( 'wpinv_email_invoice_line_item_summary', '', $item, $wpi_item, $invoice ); |
|
| 56 | - if ( !empty( $summary ) ) { |
|
| 55 | + $summary = apply_filters('wpinv_email_invoice_line_item_summary', '', $item, $wpi_item, $invoice); |
|
| 56 | + if (!empty($summary)) { |
|
| 57 | 57 | echo '<p class="small">' . $summary . '</p>'; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - do_action( 'wpinv_email_cart_item_title_after', $item, $key ); |
|
| 60 | + do_action('wpinv_email_cart_item_title_after', $item, $key); |
|
| 61 | 61 | ?> |
| 62 | 62 | </td> |
| 63 | 63 | <td class="wpinv_cart_item_price text-right"> |
| 64 | 64 | <?php |
| 65 | - echo wpinv_cart_item_price( $item ); |
|
| 66 | - do_action( 'wpinv_email_cart_item_price_after', $item, $key ); |
|
| 65 | + echo wpinv_cart_item_price($item); |
|
| 66 | + do_action('wpinv_email_cart_item_price_after', $item, $key); |
|
| 67 | 67 | ?> |
| 68 | 68 | </td> |
| 69 | - <?php if ( $quantities_enabled ) { ?> |
|
| 69 | + <?php if ($quantities_enabled) { ?> |
|
| 70 | 70 | <td class="wpinv_cart_item_qty text-right"> |
| 71 | 71 | <?php |
| 72 | - echo wpinv_get_cart_item_quantity( $item ); |
|
| 73 | - do_action( 'wpinv_email_item_quantitiy', $item, $key ); |
|
| 72 | + echo wpinv_get_cart_item_quantity($item); |
|
| 73 | + do_action('wpinv_email_item_quantitiy', $item, $key); |
|
| 74 | 74 | ?> |
| 75 | 75 | </td> |
| 76 | 76 | <?php } ?> |
| 77 | - <?php if ( !$zero_tax && $use_taxes ) { ?> |
|
| 77 | + <?php if (!$zero_tax && $use_taxes) { ?> |
|
| 78 | 78 | <td class="wpinv_cart_item_tax text-right"> |
| 79 | 79 | <?php |
| 80 | - echo wpinv_cart_item_tax( $item ); |
|
| 81 | - do_action( 'wpinv_email_item_tax', $item, $key ); |
|
| 80 | + echo wpinv_cart_item_tax($item); |
|
| 81 | + do_action('wpinv_email_item_tax', $item, $key); |
|
| 82 | 82 | ?> |
| 83 | 83 | </td> |
| 84 | 84 | <?php } ?> |
| 85 | 85 | <td class="wpinv_cart_item_subtotal text-right"> |
| 86 | 86 | <?php |
| 87 | - echo wpinv_cart_item_subtotal( $item ); |
|
| 88 | - do_action( 'wpinv_email_item_subtotal', $item, $key ); |
|
| 87 | + echo wpinv_cart_item_subtotal($item); |
|
| 88 | + do_action('wpinv_email_item_subtotal', $item, $key); |
|
| 89 | 89 | ?> |
| 90 | 90 | </td> |
| 91 | - <?php do_action( 'wpinv_email_items_table_body_last', $item, $key ); ?> |
|
| 91 | + <?php do_action('wpinv_email_items_table_body_last', $item, $key); ?> |
|
| 92 | 92 | </tr> |
| 93 | 93 | <?php } ?> |
| 94 | 94 | <?php } ?> |
| 95 | - <?php do_action( 'wpinv_email_items_middle' ); ?> |
|
| 96 | - <?php do_action( 'wpinv_email_items_after' ); ?> |
|
| 95 | + <?php do_action('wpinv_email_items_middle'); ?> |
|
| 96 | + <?php do_action('wpinv_email_items_after'); ?> |
|
| 97 | 97 | </tbody> |
| 98 | 98 | <tfoot> |
| 99 | - <?php $cart_columns = wpinv_checkout_cart_columns(); if ( $zero_tax && $use_taxes ) { $cart_columns--; } ?> |
|
| 100 | - <?php if ( has_action( 'wpinv_email_footer_buttons' ) ) { ?> |
|
| 99 | + <?php $cart_columns = wpinv_checkout_cart_columns(); if ($zero_tax && $use_taxes) { $cart_columns--; } ?> |
|
| 100 | + <?php if (has_action('wpinv_email_footer_buttons')) { ?> |
|
| 101 | 101 | <tr class="wpinv_cart_footer_row"> |
| 102 | - <?php do_action( 'wpinv_email_items_table_buttons_first', $cart_items ); ?> |
|
| 103 | - <td colspan="<?php echo ( $cart_columns ); ?>"> |
|
| 104 | - <?php do_action( 'wpinv_email_footer_buttons' ); ?> |
|
| 102 | + <?php do_action('wpinv_email_items_table_buttons_first', $cart_items); ?> |
|
| 103 | + <td colspan="<?php echo ($cart_columns); ?>"> |
|
| 104 | + <?php do_action('wpinv_email_footer_buttons'); ?> |
|
| 105 | 105 | </td> |
| 106 | - <?php do_action( 'wpinv_email_items_table_buttons_first', $cart_items ); ?> |
|
| 106 | + <?php do_action('wpinv_email_items_table_buttons_first', $cart_items); ?> |
|
| 107 | 107 | </tr> |
| 108 | 108 | <?php } ?> |
| 109 | 109 | |
| 110 | - <?php if ( !$zero_tax && $use_taxes && !wpinv_prices_include_tax() && wpinv_is_cart_taxed() ) { ?> |
|
| 110 | + <?php if (!$zero_tax && $use_taxes && !wpinv_prices_include_tax() && wpinv_is_cart_taxed()) { ?> |
|
| 111 | 111 | <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"> |
| 112 | - <?php do_action( 'wpinv_email_items_table_subtotal_first', $cart_items ); ?> |
|
| 113 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_subtotal_label text-right"> |
|
| 114 | - <strong><?php _e( 'Sub-Total', 'invoicing' ); ?>:</strong> |
|
| 112 | + <?php do_action('wpinv_email_items_table_subtotal_first', $cart_items); ?> |
|
| 113 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_subtotal_label text-right"> |
|
| 114 | + <strong><?php _e('Sub-Total', 'invoicing'); ?>:</strong> |
|
| 115 | 115 | </td> |
| 116 | 116 | <td class="wpinv_cart_subtotal text-right"> |
| 117 | - <span class="wpinv_cart_subtotal_amount bold"><?php echo $invoice->get_subtotal( true ); ?></span> |
|
| 117 | + <span class="wpinv_cart_subtotal_amount bold"><?php echo $invoice->get_subtotal(true); ?></span> |
|
| 118 | 118 | </td> |
| 119 | - <?php do_action( 'wpinv_email_items_table_subtotal_last', $cart_items, $invoice ); ?> |
|
| 119 | + <?php do_action('wpinv_email_items_table_subtotal_last', $cart_items, $invoice); ?> |
|
| 120 | 120 | </tr> |
| 121 | 121 | <?php } ?> |
| 122 | 122 | |
| 123 | - <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?> |
|
| 123 | + <?php if (wpinv_discount($invoice_id, false) > 0) { ?> |
|
| 124 | 124 | <tr class="wpinv_cart_footer_row wpinv_cart_discount_row"> |
| 125 | - <?php do_action( 'wpinv_receipt_items_table_discount_first', $cart_items, $invoice ); ?> |
|
| 126 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_discount_label text-right"> |
|
| 127 | - <strong><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</strong> |
|
| 125 | + <?php do_action('wpinv_receipt_items_table_discount_first', $cart_items, $invoice); ?> |
|
| 126 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_discount_label text-right"> |
|
| 127 | + <strong><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</strong> |
|
| 128 | 128 | </td> |
| 129 | 129 | <td class="wpinv_cart_discount text-right"> |
| 130 | - <span class="wpinv_cart_discount_amount"><?php echo wpinv_discount( $invoice_id, true, true ); ?></span> |
|
| 130 | + <span class="wpinv_cart_discount_amount"><?php echo wpinv_discount($invoice_id, true, true); ?></span> |
|
| 131 | 131 | </td> |
| 132 | - <?php do_action( 'wpinv_receipt_items_table_discount_last', $cart_items, $invoice ); ?> |
|
| 132 | + <?php do_action('wpinv_receipt_items_table_discount_last', $cart_items, $invoice); ?> |
|
| 133 | 133 | </tr> |
| 134 | 134 | <?php } ?> |
| 135 | 135 | |
| 136 | - <?php if ( !$zero_tax && $use_taxes && wpinv_is_cart_taxed() ) { ?> |
|
| 136 | + <?php if (!$zero_tax && $use_taxes && wpinv_is_cart_taxed()) { ?> |
|
| 137 | 137 | <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"> |
| 138 | - <?php do_action( 'wpinv_email_items_table_tax_first', $cart_items, $invoice ); ?> |
|
| 139 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_tax_label text-right"> |
|
| 138 | + <?php do_action('wpinv_email_items_table_tax_first', $cart_items, $invoice); ?> |
|
| 139 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_tax_label text-right"> |
|
| 140 | 140 | <strong><?php echo $tax_label; ?>:</strong> |
| 141 | 141 | </td> |
| 142 | 142 | <td class="wpinv_cart_tax text-right"> |
| 143 | - <span class="wpinv_cart_tax_amount"><?php echo $invoice->get_tax( true ); ?></span> |
|
| 143 | + <span class="wpinv_cart_tax_amount"><?php echo $invoice->get_tax(true); ?></span> |
|
| 144 | 144 | </td> |
| 145 | - <?php do_action( 'wpinv_email_items_table_tax_last', $cart_items, $invoice ); ?> |
|
| 145 | + <?php do_action('wpinv_email_items_table_tax_last', $cart_items, $invoice); ?> |
|
| 146 | 146 | </tr> |
| 147 | 147 | <?php } ?> |
| 148 | 148 | |
| 149 | 149 | <tr class="wpinv_cart_footer_row"> |
| 150 | - <?php do_action( 'wpinv_email_items_table_footer_first', $cart_items, $invoice ); ?> |
|
| 151 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_total_label text-right"> |
|
| 152 | - <?php echo apply_filters( 'wpinv_email_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?> |
|
| 150 | + <?php do_action('wpinv_email_items_table_footer_first', $cart_items, $invoice); ?> |
|
| 151 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_total_label text-right"> |
|
| 152 | + <?php echo apply_filters('wpinv_email_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?> |
|
| 153 | 153 | </td> |
| 154 | 154 | <td class="wpinv_cart_total text-right"> |
| 155 | - <span class="wpinv_cart_amount bold"><?php echo $invoice->get_total( true ); ?></span> |
|
| 155 | + <span class="wpinv_cart_amount bold"><?php echo $invoice->get_total(true); ?></span> |
|
| 156 | 156 | </td> |
| 157 | - <?php do_action( 'wpinv_email_items_table_footer_last', $cart_items, $invoice ); ?> |
|
| 157 | + <?php do_action('wpinv_email_items_table_footer_last', $cart_items, $invoice); ?> |
|
| 158 | 158 | </tr> |
| 159 | 159 | </tfoot> |
| 160 | 160 | </table> |
| 161 | 161 | </div> |
| 162 | -<?php do_action( 'wpinv_after_email_items', $invoice ); ?> |
|
| 163 | 162 | \ No newline at end of file |
| 163 | +<?php do_action('wpinv_after_email_items', $invoice); ?> |
|
| 164 | 164 | \ No newline at end of file |
@@ -5,138 +5,138 @@ |
||
| 5 | 5 | |
| 6 | 6 | global $wpinv_euvat, $post, $ajax_cart_details, $wpi_cart_columns, $wpi_session; |
| 7 | 7 | $invoice = wpinv_get_invoice_cart(); |
| 8 | -$cart_items = !empty( $ajax_cart_details ) ? $ajax_cart_details : wpinv_get_cart_content_details(); |
|
| 8 | +$cart_items = !empty($ajax_cart_details) ? $ajax_cart_details : wpinv_get_cart_content_details(); |
|
| 9 | 9 | $quantities_enabled = wpinv_item_quantities_enabled(); |
| 10 | 10 | $use_taxes = wpinv_use_taxes(); |
| 11 | 11 | $tax_label = $wpinv_euvat->tax_label(); |
| 12 | -$tax_title = $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
| 12 | +$tax_title = $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
| 13 | 13 | ?> |
| 14 | 14 | <table id="wpinv_checkout_cart" class="table table-bordered table-hover"> |
| 15 | 15 | <thead> |
| 16 | 16 | <tr class="wpinv_cart_header_row"> |
| 17 | - <?php do_action( 'wpinv_checkout_table_header_first' ); ?> |
|
| 18 | - <th class="wpinv_cart_item_name text-left"><?php _e( 'Item Name', 'invoicing' ); ?></th> |
|
| 19 | - <th class="wpinv_cart_item_price text-right"><?php _e( 'Item Price', 'invoicing' ); ?></th> |
|
| 20 | - <?php if ( $quantities_enabled ) { ?> |
|
| 21 | - <th class="wpinv_cart_item_qty text-right"><?php _e( 'Qty', 'invoicing' ); ?></th> |
|
| 17 | + <?php do_action('wpinv_checkout_table_header_first'); ?> |
|
| 18 | + <th class="wpinv_cart_item_name text-left"><?php _e('Item Name', 'invoicing'); ?></th> |
|
| 19 | + <th class="wpinv_cart_item_price text-right"><?php _e('Item Price', 'invoicing'); ?></th> |
|
| 20 | + <?php if ($quantities_enabled) { ?> |
|
| 21 | + <th class="wpinv_cart_item_qty text-right"><?php _e('Qty', 'invoicing'); ?></th> |
|
| 22 | 22 | <?php } ?> |
| 23 | - <?php if ( $use_taxes ) { ?> |
|
| 23 | + <?php if ($use_taxes) { ?> |
|
| 24 | 24 | <th class="wpinv_cart_item_tax text-right"><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></th> |
| 25 | 25 | <?php } ?> |
| 26 | - <th class="wpinv_cart_item_subtotal text-right"><?php echo __( 'Item Total', 'invoicing' ) . ' <span class="normal small">' . $tax_title . '<span>'; ?></th> |
|
| 27 | - <?php do_action( 'wpinv_checkout_table_header_last' ); ?> |
|
| 26 | + <th class="wpinv_cart_item_subtotal text-right"><?php echo __('Item Total', 'invoicing') . ' <span class="normal small">' . $tax_title . '<span>'; ?></th> |
|
| 27 | + <?php do_action('wpinv_checkout_table_header_last'); ?> |
|
| 28 | 28 | </tr> |
| 29 | 29 | </thead> |
| 30 | 30 | <tbody> |
| 31 | 31 | <?php |
| 32 | - do_action( 'wpinv_cart_items_before' ); |
|
| 32 | + do_action('wpinv_cart_items_before'); |
|
| 33 | 33 | |
| 34 | - if ( $cart_items ) { |
|
| 35 | - foreach ( $cart_items as $key => $item ) { |
|
| 36 | - $wpi_item = !empty( $item['id'] ) ? new WPInv_Item( $item['id'] ) : NULL; |
|
| 34 | + if ($cart_items) { |
|
| 35 | + foreach ($cart_items as $key => $item) { |
|
| 36 | + $wpi_item = !empty($item['id']) ? new WPInv_Item($item['id']) : NULL; |
|
| 37 | 37 | ?> |
| 38 | - <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr( $key ) . '_' . esc_attr( $item['id'] ); ?>" data-item-id="<?php echo esc_attr( $item['id'] ); ?>"> |
|
| 39 | - <?php do_action( 'wpinv_checkout_table_body_first', $item ); ?> |
|
| 38 | + <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr($key) . '_' . esc_attr($item['id']); ?>" data-item-id="<?php echo esc_attr($item['id']); ?>"> |
|
| 39 | + <?php do_action('wpinv_checkout_table_body_first', $item); ?> |
|
| 40 | 40 | <td class="wpinv_cart_item_name text-left"> |
| 41 | 41 | <?php |
| 42 | - if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $item['id'] ) ) { |
|
| 42 | + if (current_theme_supports('post-thumbnails') && has_post_thumbnail($item['id'])) { |
|
| 43 | 43 | echo '<div class="wpinv_cart_item_image">'; |
| 44 | - echo get_the_post_thumbnail( $item['id'], apply_filters( 'wpinv_checkout_image_size', array( 25,25 ) ) ); |
|
| 44 | + echo get_the_post_thumbnail($item['id'], apply_filters('wpinv_checkout_image_size', array(25, 25))); |
|
| 45 | 45 | echo '</div>'; |
| 46 | 46 | } |
| 47 | - $item_title = esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $wpi_item ); |
|
| 47 | + $item_title = esc_html(wpinv_get_cart_item_name($item)) . wpinv_get_item_suffix($wpi_item); |
|
| 48 | 48 | echo '<span class="wpinv_checkout_cart_item_title">' . $item_title . '</span>'; |
| 49 | - $summary = apply_filters( 'wpinv_checkout_cart_line_item_summary', '', $item, $wpi_item, $invoice ); |
|
| 50 | - if ( !empty( $summary ) ) { |
|
| 49 | + $summary = apply_filters('wpinv_checkout_cart_line_item_summary', '', $item, $wpi_item, $invoice); |
|
| 50 | + if (!empty($summary)) { |
|
| 51 | 51 | echo $summary; |
| 52 | 52 | } |
| 53 | 53 | ?> |
| 54 | 54 | </td> |
| 55 | 55 | <td class="wpinv_cart_item_price text-right"> |
| 56 | 56 | <?php |
| 57 | - echo wpinv_cart_item_price( $item ); |
|
| 58 | - do_action( 'wpinv_checkout_cart_item_price_after', $item, $key ); |
|
| 57 | + echo wpinv_cart_item_price($item); |
|
| 58 | + do_action('wpinv_checkout_cart_item_price_after', $item, $key); |
|
| 59 | 59 | ?> |
| 60 | 60 | </td> |
| 61 | - <?php if ( $quantities_enabled ) { ?> |
|
| 61 | + <?php if ($quantities_enabled) { ?> |
|
| 62 | 62 | <td class="wpinv_cart_item_qty text-right"> |
| 63 | 63 | <?php |
| 64 | - echo wpinv_get_cart_item_quantity( $item ); |
|
| 65 | - do_action( 'wpinv_cart_item_quantitiy', $item, $key ); |
|
| 64 | + echo wpinv_get_cart_item_quantity($item); |
|
| 65 | + do_action('wpinv_cart_item_quantitiy', $item, $key); |
|
| 66 | 66 | ?> |
| 67 | 67 | </td> |
| 68 | 68 | <?php } ?> |
| 69 | - <?php if ( $use_taxes ) { ?> |
|
| 69 | + <?php if ($use_taxes) { ?> |
|
| 70 | 70 | <td class="wpinv_cart_item_tax text-right"> |
| 71 | 71 | <?php |
| 72 | - echo wpinv_cart_item_tax( $item ); |
|
| 72 | + echo wpinv_cart_item_tax($item); |
|
| 73 | 73 | //echo wpinv_get_cart_item_tax( $wpi_item->ID, $subtotal = '', $options = array() ); |
| 74 | - do_action( 'wpinv_cart_item_tax', $item, $key ); |
|
| 74 | + do_action('wpinv_cart_item_tax', $item, $key); |
|
| 75 | 75 | ?> |
| 76 | 76 | </td> |
| 77 | 77 | <?php } ?> |
| 78 | 78 | <td class="wpinv_cart_item_subtotal text-right"> |
| 79 | 79 | <?php |
| 80 | - echo wpinv_cart_item_subtotal( $item ); |
|
| 81 | - do_action( 'wpinv_cart_item_subtotal', $item, $key ); |
|
| 80 | + echo wpinv_cart_item_subtotal($item); |
|
| 81 | + do_action('wpinv_cart_item_subtotal', $item, $key); |
|
| 82 | 82 | ?> |
| 83 | 83 | </td> |
| 84 | - <?php do_action( 'wpinv_checkout_table_body_last', $item, $key ); ?> |
|
| 84 | + <?php do_action('wpinv_checkout_table_body_last', $item, $key); ?> |
|
| 85 | 85 | </tr> |
| 86 | 86 | <?php } ?> |
| 87 | 87 | <?php } ?> |
| 88 | - <?php do_action( 'wpinv_cart_items_middle' ); ?> |
|
| 89 | - <?php do_action( 'wpinv_cart_items_after' ); ?> |
|
| 88 | + <?php do_action('wpinv_cart_items_middle'); ?> |
|
| 89 | + <?php do_action('wpinv_cart_items_after'); ?> |
|
| 90 | 90 | </tbody> |
| 91 | 91 | <tfoot> |
| 92 | 92 | <?php $cart_columns = wpinv_checkout_cart_columns(); ?> |
| 93 | - <?php if ( has_action( 'wpinv_cart_footer_buttons' ) ) { ?> |
|
| 93 | + <?php if (has_action('wpinv_cart_footer_buttons')) { ?> |
|
| 94 | 94 | <tr class="wpinv_cart_footer_row"> |
| 95 | - <?php do_action( 'wpinv_checkout_table_buttons_first', $cart_items ); ?> |
|
| 96 | - <td colspan="<?php echo ( $cart_columns ); ?>"> |
|
| 97 | - <?php do_action( 'wpinv_cart_footer_buttons' ); ?> |
|
| 95 | + <?php do_action('wpinv_checkout_table_buttons_first', $cart_items); ?> |
|
| 96 | + <td colspan="<?php echo ($cart_columns); ?>"> |
|
| 97 | + <?php do_action('wpinv_cart_footer_buttons'); ?> |
|
| 98 | 98 | </td> |
| 99 | - <?php do_action( 'wpinv_checkout_table_buttons_first', $cart_items ); ?> |
|
| 99 | + <?php do_action('wpinv_checkout_table_buttons_first', $cart_items); ?> |
|
| 100 | 100 | </tr> |
| 101 | 101 | <?php } ?> |
| 102 | 102 | |
| 103 | - <?php if ( $use_taxes && !wpinv_prices_include_tax() ) { ?> |
|
| 104 | - <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if ( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>> |
|
| 105 | - <?php do_action( 'wpinv_checkout_table_subtotal_first', $cart_items ); ?> |
|
| 106 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_subtotal_label text-right"> |
|
| 107 | - <strong><?php _e( 'Sub-Total', 'invoicing' ); ?>:</strong> |
|
| 103 | + <?php if ($use_taxes && !wpinv_prices_include_tax()) { ?> |
|
| 104 | + <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if (!wpinv_is_cart_taxed()) echo ' style="display:none;"'; ?>> |
|
| 105 | + <?php do_action('wpinv_checkout_table_subtotal_first', $cart_items); ?> |
|
| 106 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_subtotal_label text-right"> |
|
| 107 | + <strong><?php _e('Sub-Total', 'invoicing'); ?>:</strong> |
|
| 108 | 108 | </td> |
| 109 | 109 | <td class="wpinv_cart_subtotal text-right"> |
| 110 | - <span class="wpinv_cart_subtotal_amount bold"><?php echo wpinv_cart_subtotal( $cart_items ); ?></span> |
|
| 110 | + <span class="wpinv_cart_subtotal_amount bold"><?php echo wpinv_cart_subtotal($cart_items); ?></span> |
|
| 111 | 111 | </td> |
| 112 | - <?php do_action( 'wpinv_checkout_table_subtotal_last', $cart_items ); ?> |
|
| 112 | + <?php do_action('wpinv_checkout_table_subtotal_last', $cart_items); ?> |
|
| 113 | 113 | </tr> |
| 114 | 114 | <?php } ?> |
| 115 | 115 | |
| 116 | - <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html( $cart_items ); ?> |
|
| 116 | + <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html($cart_items); ?> |
|
| 117 | 117 | |
| 118 | - <?php if ( $use_taxes ) { ?> |
|
| 119 | - <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>> |
|
| 120 | - <?php do_action( 'wpinv_checkout_table_tax_first' ); ?> |
|
| 121 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_tax_label text-right"> |
|
| 118 | + <?php if ($use_taxes) { ?> |
|
| 119 | + <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if (!wpinv_is_cart_taxed()) echo ' style="display:none;"'; ?>> |
|
| 120 | + <?php do_action('wpinv_checkout_table_tax_first'); ?> |
|
| 121 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_tax_label text-right"> |
|
| 122 | 122 | <strong><?php echo $tax_label; ?>:</strong> |
| 123 | 123 | </td> |
| 124 | 124 | <td class="wpinv_cart_tax text-right"> |
| 125 | - <span class="wpinv_cart_tax_amount" data-tax="<?php echo wpinv_get_cart_tax( $cart_items ); ?>"><?php echo esc_html( wpinv_cart_tax( $cart_items ) ); ?></span> |
|
| 125 | + <span class="wpinv_cart_tax_amount" data-tax="<?php echo wpinv_get_cart_tax($cart_items); ?>"><?php echo esc_html(wpinv_cart_tax($cart_items)); ?></span> |
|
| 126 | 126 | </td> |
| 127 | - <?php do_action( 'wpinv_checkout_table_tax_last' ); ?> |
|
| 127 | + <?php do_action('wpinv_checkout_table_tax_last'); ?> |
|
| 128 | 128 | </tr> |
| 129 | 129 | <?php } ?> |
| 130 | 130 | |
| 131 | 131 | <tr class="wpinv_cart_footer_row wpinv_cart_total_row"> |
| 132 | - <?php do_action( 'wpinv_checkout_table_footer_first' ); ?> |
|
| 133 | - <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_total_label text-right"> |
|
| 134 | - <?php echo apply_filters( 'wpinv_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?> |
|
| 132 | + <?php do_action('wpinv_checkout_table_footer_first'); ?> |
|
| 133 | + <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_total_label text-right"> |
|
| 134 | + <?php echo apply_filters('wpinv_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?> |
|
| 135 | 135 | </td> |
| 136 | 136 | <td class="wpinv_cart_total text-right"> |
| 137 | - <span class="wpinv_cart_amount bold" data-subtotal="<?php echo wpinv_get_cart_total( $cart_items ); ?>" data-total="<?php echo wpinv_get_cart_total( NULL, NULL, $invoice ); ?>"><?php wpinv_cart_total( $cart_items, true, $invoice ); ?></span> |
|
| 137 | + <span class="wpinv_cart_amount bold" data-subtotal="<?php echo wpinv_get_cart_total($cart_items); ?>" data-total="<?php echo wpinv_get_cart_total(NULL, NULL, $invoice); ?>"><?php wpinv_cart_total($cart_items, true, $invoice); ?></span> |
|
| 138 | 138 | </td> |
| 139 | - <?php do_action( 'wpinv_checkout_table_footer_last' ); ?> |
|
| 139 | + <?php do_action('wpinv_checkout_table_footer_last'); ?> |
|
| 140 | 140 | </tr> |
| 141 | 141 | </tfoot> |
| 142 | 142 | </table> |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly |
| 3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if (!defined('ABSPATH')) exit; |
|
| 4 | 4 | |
| 5 | 5 | class WPInv_Item { |
| 6 | 6 | public $ID = 0; |
@@ -47,26 +47,26 @@ discard block |
||
| 47 | 47 | public $filter; |
| 48 | 48 | |
| 49 | 49 | |
| 50 | - public function __construct( $_id = false, $_args = array() ) { |
|
| 51 | - $item = WP_Post::get_instance( $_id ); |
|
| 52 | - return $this->setup_item( $item ); |
|
| 50 | + public function __construct($_id = false, $_args = array()) { |
|
| 51 | + $item = WP_Post::get_instance($_id); |
|
| 52 | + return $this->setup_item($item); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - private function setup_item( $item ) { |
|
| 56 | - if( ! is_object( $item ) ) { |
|
| 55 | + private function setup_item($item) { |
|
| 56 | + if (!is_object($item)) { |
|
| 57 | 57 | return false; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if( ! is_a( $item, 'WP_Post' ) ) { |
|
| 60 | + if (!is_a($item, 'WP_Post')) { |
|
| 61 | 61 | return false; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - if( 'wpi_item' !== $item->post_type ) { |
|
| 64 | + if ('wpi_item' !== $item->post_type) { |
|
| 65 | 65 | return false; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - foreach ( $item as $key => $value ) { |
|
| 69 | - switch ( $key ) { |
|
| 68 | + foreach ($item as $key => $value) { |
|
| 69 | + switch ($key) { |
|
| 70 | 70 | default: |
| 71 | 71 | $this->$key = $value; |
| 72 | 72 | break; |
@@ -76,38 +76,38 @@ discard block |
||
| 76 | 76 | return true; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - public function __get( $key ) { |
|
| 80 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
| 81 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
| 79 | + public function __get($key) { |
|
| 80 | + if (method_exists($this, 'get_' . $key)) { |
|
| 81 | + return call_user_func(array($this, 'get_' . $key)); |
|
| 82 | 82 | } else { |
| 83 | - return new WP_Error( 'wpinv-item-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) ); |
|
| 83 | + return new WP_Error('wpinv-item-invalid-property', sprintf(__('Can\'t get property %s', 'invoicing'), $key)); |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - public function create( $data = array(), $wp_error = false ) { |
|
| 88 | - if ( $this->ID != 0 ) { |
|
| 87 | + public function create($data = array(), $wp_error = false) { |
|
| 88 | + if ($this->ID != 0) { |
|
| 89 | 89 | return false; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | $defaults = array( |
| 93 | 93 | 'post_type' => 'wpi_item', |
| 94 | 94 | 'post_status' => 'draft', |
| 95 | - 'post_title' => __( 'New Invoice Item', 'invoicing' ) |
|
| 95 | + 'post_title' => __('New Invoice Item', 'invoicing') |
|
| 96 | 96 | ); |
| 97 | 97 | |
| 98 | - $args = wp_parse_args( $data, $defaults ); |
|
| 98 | + $args = wp_parse_args($data, $defaults); |
|
| 99 | 99 | |
| 100 | - do_action( 'wpinv_item_pre_create', $args ); |
|
| 100 | + do_action('wpinv_item_pre_create', $args); |
|
| 101 | 101 | |
| 102 | - $id = wp_insert_post( $args, $wp_error ); |
|
| 102 | + $id = wp_insert_post($args, $wp_error); |
|
| 103 | 103 | if ($wp_error && is_wp_error($id)) { |
| 104 | 104 | return $id; |
| 105 | 105 | } |
| 106 | - if ( !$id ) { |
|
| 106 | + if (!$id) { |
|
| 107 | 107 | return false; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - $item = WP_Post::get_instance( $id ); |
|
| 110 | + $item = WP_Post::get_instance($id); |
|
| 111 | 111 | |
| 112 | 112 | if (!empty($item) && !empty($data['meta'])) { |
| 113 | 113 | $this->ID = $item->ID; |
@@ -115,47 +115,47 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | // Set custom id if not set. |
| 118 | - if ( empty( $data['meta']['custom_id'] ) && !$this->get_custom_id() ) { |
|
| 119 | - $this->save_metas( array( 'custom_id' => $id ) ); |
|
| 118 | + if (empty($data['meta']['custom_id']) && !$this->get_custom_id()) { |
|
| 119 | + $this->save_metas(array('custom_id' => $id)); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - do_action( 'wpinv_item_create', $id, $args ); |
|
| 122 | + do_action('wpinv_item_create', $id, $args); |
|
| 123 | 123 | |
| 124 | - return $this->setup_item( $item ); |
|
| 124 | + return $this->setup_item($item); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - public function update( $data = array(), $wp_error = false ) { |
|
| 128 | - if ( !$this->ID > 0 ) { |
|
| 127 | + public function update($data = array(), $wp_error = false) { |
|
| 128 | + if (!$this->ID > 0) { |
|
| 129 | 129 | return false; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | $data['ID'] = $this->ID; |
| 133 | 133 | |
| 134 | - do_action( 'wpinv_item_pre_update', $data ); |
|
| 134 | + do_action('wpinv_item_pre_update', $data); |
|
| 135 | 135 | |
| 136 | - $id = wp_update_post( $data, $wp_error ); |
|
| 136 | + $id = wp_update_post($data, $wp_error); |
|
| 137 | 137 | if ($wp_error && is_wp_error($id)) { |
| 138 | 138 | return $id; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if ( !$id ) { |
|
| 141 | + if (!$id) { |
|
| 142 | 142 | return false; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - $item = WP_Post::get_instance( $id ); |
|
| 145 | + $item = WP_Post::get_instance($id); |
|
| 146 | 146 | if (!empty($item) && !empty($data['meta'])) { |
| 147 | 147 | $this->ID = $item->ID; |
| 148 | 148 | $this->save_metas($data['meta']); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Set custom id if not set. |
| 152 | - if ( empty( $data['meta']['custom_id'] ) && !$this->get_custom_id() ) { |
|
| 153 | - $this->save_metas( array( 'custom_id' => $id ) ); |
|
| 152 | + if (empty($data['meta']['custom_id']) && !$this->get_custom_id()) { |
|
| 153 | + $this->save_metas(array('custom_id' => $id)); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - do_action( 'wpinv_item_update', $id, $data ); |
|
| 156 | + do_action('wpinv_item_update', $id, $data); |
|
| 157 | 157 | |
| 158 | - return $this->setup_item( $item ); |
|
| 158 | + return $this->setup_item($item); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | public function get_ID() { |
@@ -163,119 +163,119 @@ discard block |
||
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | public function get_name() { |
| 166 | - return get_the_title( $this->ID ); |
|
| 166 | + return get_the_title($this->ID); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | public function get_title() { |
| 170 | - return get_the_title( $this->ID ); |
|
| 170 | + return get_the_title($this->ID); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | public function get_status() { |
| 174 | - return get_post_status( $this->ID ); |
|
| 174 | + return get_post_status($this->ID); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | public function get_summary() { |
| 178 | - return get_the_excerpt( $this->ID ); |
|
| 178 | + return get_the_excerpt($this->ID); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | public function get_price() { |
| 182 | - if ( ! isset( $this->price ) ) { |
|
| 183 | - $this->price = get_post_meta( $this->ID, '_wpinv_price', true ); |
|
| 182 | + if (!isset($this->price)) { |
|
| 183 | + $this->price = get_post_meta($this->ID, '_wpinv_price', true); |
|
| 184 | 184 | |
| 185 | - if ( $this->price ) { |
|
| 186 | - $this->price = wpinv_sanitize_amount( $this->price ); |
|
| 185 | + if ($this->price) { |
|
| 186 | + $this->price = wpinv_sanitize_amount($this->price); |
|
| 187 | 187 | } else { |
| 188 | 188 | $this->price = 0; |
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - return apply_filters( 'wpinv_get_item_price', $this->price, $this->ID ); |
|
| 192 | + return apply_filters('wpinv_get_item_price', $this->price, $this->ID); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | public function get_vat_rule() { |
| 196 | 196 | global $wpinv_euvat; |
| 197 | 197 | |
| 198 | - if( !isset( $this->vat_rule ) ) { |
|
| 199 | - $this->vat_rule = get_post_meta( $this->ID, '_wpinv_vat_rule', true ); |
|
| 198 | + if (!isset($this->vat_rule)) { |
|
| 199 | + $this->vat_rule = get_post_meta($this->ID, '_wpinv_vat_rule', true); |
|
| 200 | 200 | |
| 201 | - if ( empty( $this->vat_rule ) ) { |
|
| 201 | + if (empty($this->vat_rule)) { |
|
| 202 | 202 | $this->vat_rule = $wpinv_euvat->allow_vat_rules() ? 'digital' : 'physical'; |
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - return apply_filters( 'wpinv_get_item_vat_rule', $this->vat_rule, $this->ID ); |
|
| 206 | + return apply_filters('wpinv_get_item_vat_rule', $this->vat_rule, $this->ID); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | public function get_vat_class() { |
| 210 | - if( !isset( $this->vat_class ) ) { |
|
| 211 | - $this->vat_class = get_post_meta( $this->ID, '_wpinv_vat_class', true ); |
|
| 210 | + if (!isset($this->vat_class)) { |
|
| 211 | + $this->vat_class = get_post_meta($this->ID, '_wpinv_vat_class', true); |
|
| 212 | 212 | |
| 213 | - if ( empty( $this->vat_class ) ) { |
|
| 213 | + if (empty($this->vat_class)) { |
|
| 214 | 214 | $this->vat_class = '_standard'; |
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - return apply_filters( 'wpinv_get_item_vat_class', $this->vat_class, $this->ID ); |
|
| 218 | + return apply_filters('wpinv_get_item_vat_class', $this->vat_class, $this->ID); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | public function get_type() { |
| 222 | - if( ! isset( $this->type ) ) { |
|
| 223 | - $this->type = get_post_meta( $this->ID, '_wpinv_type', true ); |
|
| 222 | + if (!isset($this->type)) { |
|
| 223 | + $this->type = get_post_meta($this->ID, '_wpinv_type', true); |
|
| 224 | 224 | |
| 225 | - if ( empty( $this->type ) ) { |
|
| 225 | + if (empty($this->type)) { |
|
| 226 | 226 | $this->type = 'custom'; |
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - return apply_filters( 'wpinv_get_item_type', $this->type, $this->ID ); |
|
| 230 | + return apply_filters('wpinv_get_item_type', $this->type, $this->ID); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | public function get_custom_id() { |
| 234 | - $custom_id = get_post_meta( $this->ID, '_wpinv_custom_id', true ); |
|
| 234 | + $custom_id = get_post_meta($this->ID, '_wpinv_custom_id', true); |
|
| 235 | 235 | |
| 236 | - return apply_filters( 'wpinv_get_item_custom_id', $custom_id, $this->ID ); |
|
| 236 | + return apply_filters('wpinv_get_item_custom_id', $custom_id, $this->ID); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | public function get_custom_name() { |
| 240 | - $custom_name = get_post_meta( $this->ID, '_wpinv_custom_name', true ); |
|
| 240 | + $custom_name = get_post_meta($this->ID, '_wpinv_custom_name', true); |
|
| 241 | 241 | |
| 242 | - return apply_filters( 'wpinv_get_item_custom_name', $custom_name, $this->ID ); |
|
| 242 | + return apply_filters('wpinv_get_item_custom_name', $custom_name, $this->ID); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | public function get_custom_singular_name() { |
| 246 | - $custom_singular_name = get_post_meta( $this->ID, '_wpinv_custom_singular_name', true ); |
|
| 246 | + $custom_singular_name = get_post_meta($this->ID, '_wpinv_custom_singular_name', true); |
|
| 247 | 247 | |
| 248 | - return apply_filters( 'wpinv_get_item_custom_singular_name', $custom_singular_name, $this->ID ); |
|
| 248 | + return apply_filters('wpinv_get_item_custom_singular_name', $custom_singular_name, $this->ID); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | public function get_editable() { |
| 252 | - $editable = get_post_meta( $this->ID, '_wpinv_editable', true ); |
|
| 252 | + $editable = get_post_meta($this->ID, '_wpinv_editable', true); |
|
| 253 | 253 | |
| 254 | - return apply_filters( 'wpinv_item_get_editable', $editable, $this->ID ); |
|
| 254 | + return apply_filters('wpinv_item_get_editable', $editable, $this->ID); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | public function get_excerpt() { |
| 258 | - $excerpt = get_the_excerpt( $this->ID ); |
|
| 258 | + $excerpt = get_the_excerpt($this->ID); |
|
| 259 | 259 | |
| 260 | - return apply_filters( 'wpinv_item_get_excerpt', $excerpt, $this->ID ); |
|
| 260 | + return apply_filters('wpinv_item_get_excerpt', $excerpt, $this->ID); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | public function get_is_recurring() { |
| 264 | - $is_recurring = get_post_meta( $this->ID, '_wpinv_is_recurring', true ); |
|
| 264 | + $is_recurring = get_post_meta($this->ID, '_wpinv_is_recurring', true); |
|
| 265 | 265 | |
| 266 | - return apply_filters( 'wpinv_item_get_is_recurring', $is_recurring, $this->ID ); |
|
| 266 | + return apply_filters('wpinv_item_get_is_recurring', $is_recurring, $this->ID); |
|
| 267 | 267 | |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - public function get_recurring_period( $full = false ) { |
|
| 271 | - $period = get_post_meta( $this->ID, '_wpinv_recurring_period', true ); |
|
| 270 | + public function get_recurring_period($full = false) { |
|
| 271 | + $period = get_post_meta($this->ID, '_wpinv_recurring_period', true); |
|
| 272 | 272 | |
| 273 | - if ( !in_array( $period, array( 'D', 'W', 'M', 'Y' ) ) ) { |
|
| 273 | + if (!in_array($period, array('D', 'W', 'M', 'Y'))) { |
|
| 274 | 274 | $period = 'D'; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - if ( $full ) { |
|
| 278 | - switch( $period ) { |
|
| 277 | + if ($full) { |
|
| 278 | + switch ($period) { |
|
| 279 | 279 | case 'D': |
| 280 | 280 | $period = 'day'; |
| 281 | 281 | break; |
@@ -291,40 +291,40 @@ discard block |
||
| 291 | 291 | } |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - return apply_filters( 'wpinv_item_recurring_period', $period, $full, $this->ID ); |
|
| 294 | + return apply_filters('wpinv_item_recurring_period', $period, $full, $this->ID); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | public function get_recurring_interval() { |
| 298 | - $interval = (int)get_post_meta( $this->ID, '_wpinv_recurring_interval', true ); |
|
| 298 | + $interval = (int)get_post_meta($this->ID, '_wpinv_recurring_interval', true); |
|
| 299 | 299 | |
| 300 | - if ( !$interval > 0 ) { |
|
| 300 | + if (!$interval > 0) { |
|
| 301 | 301 | $interval = 1; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - return apply_filters( 'wpinv_item_recurring_interval', $interval, $this->ID ); |
|
| 304 | + return apply_filters('wpinv_item_recurring_interval', $interval, $this->ID); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | public function get_recurring_limit() { |
| 308 | - $limit = get_post_meta( $this->ID, '_wpinv_recurring_limit', true ); |
|
| 308 | + $limit = get_post_meta($this->ID, '_wpinv_recurring_limit', true); |
|
| 309 | 309 | |
| 310 | - return (int)apply_filters( 'wpinv_item_recurring_limit', $limit, $this->ID ); |
|
| 310 | + return (int)apply_filters('wpinv_item_recurring_limit', $limit, $this->ID); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | public function get_free_trial() { |
| 314 | - $free_trial = get_post_meta( $this->ID, '_wpinv_free_trial', true ); |
|
| 314 | + $free_trial = get_post_meta($this->ID, '_wpinv_free_trial', true); |
|
| 315 | 315 | |
| 316 | - return apply_filters( 'wpinv_item_get_free_trial', $free_trial, $this->ID ); |
|
| 316 | + return apply_filters('wpinv_item_get_free_trial', $free_trial, $this->ID); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - public function get_trial_period( $full = false ) { |
|
| 320 | - $period = get_post_meta( $this->ID, '_wpinv_trial_period', true ); |
|
| 319 | + public function get_trial_period($full = false) { |
|
| 320 | + $period = get_post_meta($this->ID, '_wpinv_trial_period', true); |
|
| 321 | 321 | |
| 322 | - if ( !in_array( $period, array( 'D', 'W', 'M', 'Y' ) ) ) { |
|
| 322 | + if (!in_array($period, array('D', 'W', 'M', 'Y'))) { |
|
| 323 | 323 | $period = 'D'; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - if ( $full ) { |
|
| 327 | - switch( $period ) { |
|
| 326 | + if ($full) { |
|
| 327 | + switch ($period) { |
|
| 328 | 328 | case 'D': |
| 329 | 329 | $period = 'day'; |
| 330 | 330 | break; |
@@ -340,47 +340,47 @@ discard block |
||
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - return apply_filters( 'wpinv_item_trial_period', $period, $full, $this->ID ); |
|
| 343 | + return apply_filters('wpinv_item_trial_period', $period, $full, $this->ID); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | public function get_trial_interval() { |
| 347 | - $interval = absint( get_post_meta( $this->ID, '_wpinv_trial_interval', true ) ); |
|
| 347 | + $interval = absint(get_post_meta($this->ID, '_wpinv_trial_interval', true)); |
|
| 348 | 348 | |
| 349 | - if ( !$interval > 0 ) { |
|
| 349 | + if (!$interval > 0) { |
|
| 350 | 350 | $interval = 1; |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | - return apply_filters( 'wpinv_item_trial_interval', $interval, $this->ID ); |
|
| 353 | + return apply_filters('wpinv_item_trial_interval', $interval, $this->ID); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | public function get_the_price() { |
| 357 | - $item_price = wpinv_price( wpinv_format_amount( $this->price ) ); |
|
| 357 | + $item_price = wpinv_price(wpinv_format_amount($this->price)); |
|
| 358 | 358 | |
| 359 | - return apply_filters( 'wpinv_get_the_item_price', $item_price, $this->ID ); |
|
| 359 | + return apply_filters('wpinv_get_the_item_price', $item_price, $this->ID); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | public function is_recurring() { |
| 363 | 363 | $is_recurring = $this->get_is_recurring(); |
| 364 | 364 | |
| 365 | - return (bool)apply_filters( 'wpinv_is_recurring_item', $is_recurring, $this->ID ); |
|
| 365 | + return (bool)apply_filters('wpinv_is_recurring_item', $is_recurring, $this->ID); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | public function has_free_trial() { |
| 369 | 369 | $free_trial = $this->is_recurring() && $this->get_free_trial() ? true : false; |
| 370 | 370 | |
| 371 | - return (bool)apply_filters( 'wpinv_item_has_free_trial', $free_trial, $this->ID ); |
|
| 371 | + return (bool)apply_filters('wpinv_item_has_free_trial', $free_trial, $this->ID); |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | public function is_free() { |
| 375 | 375 | $is_free = false; |
| 376 | 376 | |
| 377 | - $price = get_post_meta( $this->ID, '_wpinv_price', true ); |
|
| 377 | + $price = get_post_meta($this->ID, '_wpinv_price', true); |
|
| 378 | 378 | |
| 379 | - if ( (float)$price == 0 ) { |
|
| 379 | + if ((float)$price == 0) { |
|
| 380 | 380 | $is_free = true; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID ); |
|
| 383 | + return (bool)apply_filters('wpinv_is_free_item', $is_free, $this->ID); |
|
| 384 | 384 | |
| 385 | 385 | } |
| 386 | 386 | |
@@ -389,15 +389,15 @@ discard block |
||
| 389 | 389 | |
| 390 | 390 | $is_editable = $editable === 0 || $editable === '0' ? false : true; |
| 391 | 391 | |
| 392 | - return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID ); |
|
| 392 | + return (bool)apply_filters('wpinv_item_is_editable', $is_editable, $this->ID); |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - public function save_metas( $metas = array() ) { |
|
| 396 | - if ( empty( $metas ) ) { |
|
| 395 | + public function save_metas($metas = array()) { |
|
| 396 | + if (empty($metas)) { |
|
| 397 | 397 | return false; |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - foreach ( $metas as $meta_key => $meta_value ) { |
|
| 400 | + foreach ($metas as $meta_key => $meta_value) { |
|
| 401 | 401 | $meta_key = strpos($meta_key, '_wpinv_') !== 0 ? '_wpinv_' . $meta_key : $meta_key; |
| 402 | 402 | |
| 403 | 403 | $this->update_meta($meta_key, $meta_value); |
@@ -406,66 +406,66 @@ discard block |
||
| 406 | 406 | return true; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
| 410 | - if ( empty( $meta_key ) ) { |
|
| 409 | + public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') { |
|
| 410 | + if (empty($meta_key)) { |
|
| 411 | 411 | return false; |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - $meta_value = apply_filters( 'wpinv_update_item_meta_' . $meta_key, $meta_value, $this->ID ); |
|
| 414 | + $meta_value = apply_filters('wpinv_update_item_meta_' . $meta_key, $meta_value, $this->ID); |
|
| 415 | 415 | |
| 416 | - return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value ); |
|
| 416 | + return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value); |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - public function get_fees( $type = 'fee', $item_id = 0 ) { |
|
| 419 | + public function get_fees($type = 'fee', $item_id = 0) { |
|
| 420 | 420 | global $wpi_session; |
| 421 | 421 | |
| 422 | - $fees = $wpi_session->get( 'wpi_cart_fees' ); |
|
| 422 | + $fees = $wpi_session->get('wpi_cart_fees'); |
|
| 423 | 423 | |
| 424 | - if ( ! wpinv_get_cart_contents() ) { |
|
| 424 | + if (!wpinv_get_cart_contents()) { |
|
| 425 | 425 | // We can only get item type fees when the cart is empty |
| 426 | 426 | $type = 'custom'; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - if ( ! empty( $fees ) && ! empty( $type ) && 'all' !== $type ) { |
|
| 430 | - foreach( $fees as $key => $fee ) { |
|
| 431 | - if( ! empty( $fee['type'] ) && $type != $fee['type'] ) { |
|
| 432 | - unset( $fees[ $key ] ); |
|
| 429 | + if (!empty($fees) && !empty($type) && 'all' !== $type) { |
|
| 430 | + foreach ($fees as $key => $fee) { |
|
| 431 | + if (!empty($fee['type']) && $type != $fee['type']) { |
|
| 432 | + unset($fees[$key]); |
|
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | - if ( ! empty( $fees ) && ! empty( $item_id ) ) { |
|
| 437 | + if (!empty($fees) && !empty($item_id)) { |
|
| 438 | 438 | // Remove fees that don't belong to the specified Item |
| 439 | - foreach ( $fees as $key => $fee ) { |
|
| 440 | - if ( (int) $item_id !== (int)$fee['custom_id'] ) { |
|
| 441 | - unset( $fees[ $key ] ); |
|
| 439 | + foreach ($fees as $key => $fee) { |
|
| 440 | + if ((int)$item_id !== (int)$fee['custom_id']) { |
|
| 441 | + unset($fees[$key]); |
|
| 442 | 442 | } |
| 443 | 443 | } |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | - if ( ! empty( $fees ) ) { |
|
| 446 | + if (!empty($fees)) { |
|
| 447 | 447 | // Remove fees that belong to a specific item but are not in the cart |
| 448 | - foreach( $fees as $key => $fee ) { |
|
| 449 | - if( empty( $fee['custom_id'] ) ) { |
|
| 448 | + foreach ($fees as $key => $fee) { |
|
| 449 | + if (empty($fee['custom_id'])) { |
|
| 450 | 450 | continue; |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | - if ( !wpinv_item_in_cart( $fee['custom_id'] ) ) { |
|
| 454 | - unset( $fees[ $key ] ); |
|
| 453 | + if (!wpinv_item_in_cart($fee['custom_id'])) { |
|
| 454 | + unset($fees[$key]); |
|
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | - return ! empty( $fees ) ? $fees : array(); |
|
| 459 | + return !empty($fees) ? $fees : array(); |
|
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | public function can_purchase() { |
| 463 | 463 | $can_purchase = true; |
| 464 | 464 | |
| 465 | - if ( !current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) { |
|
| 465 | + if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') { |
|
| 466 | 466 | $can_purchase = false; |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | - return (bool)apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this ); |
|
| 469 | + return (bool)apply_filters('wpinv_can_purchase_item', $can_purchase, $this); |
|
| 470 | 470 | } |
| 471 | 471 | } |