@@ -512,7 +512,7 @@ |
||
| 512 | 512 | |
| 513 | 513 | $response['success'] = true; |
| 514 | 514 | $response['msg'] = __( 'Discount has been applied successfully.', 'invoicing' ); |
| 515 | - } else { |
|
| 515 | + } else { |
|
| 516 | 516 | $errors = wpinv_get_errors(); |
| 517 | 517 | if ( !empty( $errors['wpinv-discount-error'] ) ) { |
| 518 | 518 | $response['msg'] = $errors['wpinv-discount-error']; |
@@ -1,6 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly. |
| 3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if (!defined( 'ABSPATH' ) ) { |
|
| 4 | + exit; |
|
| 5 | +} |
|
| 4 | 6 | |
| 5 | 7 | /** |
| 6 | 8 | * The Subscriptions DB Class |
@@ -1,7 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly |
| 4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 4 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 5 | + exit; |
|
| 6 | +} |
|
| 5 | 7 | |
| 6 | 8 | abstract class Wpinv_DB { |
| 7 | 9 | |
@@ -8,7 +8,9 @@ |
||
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | // Exit if accessed directly |
| 11 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 11 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | + exit; |
|
| 13 | +} |
|
| 12 | 14 | |
| 13 | 15 | |
| 14 | 16 | // Load WP_List_Table if not loaded |
@@ -1,6 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly. |
| 3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if (!defined( 'ABSPATH' ) ) { |
|
| 4 | + exit; |
|
| 5 | +} |
|
| 4 | 6 | |
| 5 | 7 | function wpinv_subscription_init() { |
| 6 | 8 | return WPInv_Subscriptions::instance(); |
@@ -1010,10 +1010,11 @@ discard block |
||
| 1010 | 1010 | |
| 1011 | 1011 | $checked = false; |
| 1012 | 1012 | |
| 1013 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
| 1014 | - $checked = true; |
|
| 1015 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
| 1016 | - $checked = true; |
|
| 1013 | + if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) { |
|
| 1014 | + $checked = true; |
|
| 1015 | + } elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1016 | + $checked = true; |
|
| 1017 | + } |
|
| 1017 | 1018 | |
| 1018 | 1019 | echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
| 1019 | 1020 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
@@ -1030,10 +1031,11 @@ discard block |
||
| 1030 | 1031 | foreach ( $args['options'] as $key => $option ) : |
| 1031 | 1032 | $sanitize_key = wpinv_sanitize_key( $key ); |
| 1032 | 1033 | |
| 1033 | - if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
|
| 1034 | - $enabled = '1'; |
|
| 1035 | - else |
|
| 1036 | - $enabled = null; |
|
| 1034 | + if ( isset( $wpinv_options['gateways'][ $key ] ) ) { |
|
| 1035 | + $enabled = '1'; |
|
| 1036 | + } else { |
|
| 1037 | + $enabled = null; |
|
| 1038 | + } |
|
| 1037 | 1039 | |
| 1038 | 1040 | echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
| 1039 | 1041 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
@@ -1393,7 +1395,8 @@ discard block |
||
| 1393 | 1395 | <td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td> |
| 1394 | 1396 | </tr> |
| 1395 | 1397 | <?php endforeach; ?> |
| 1396 | - <?php else : ?> |
|
| 1398 | + <?php else { |
|
| 1399 | + : ?> |
|
| 1397 | 1400 | <tr> |
| 1398 | 1401 | <td class="wpinv_tax_country"> |
| 1399 | 1402 | <?php |
@@ -1404,7 +1407,9 @@ discard block |
||
| 1404 | 1407 | 'show_option_none' => false, |
| 1405 | 1408 | 'class' => 'wpinv-tax-country', |
| 1406 | 1409 | 'placeholder' => __( 'Choose a country', 'invoicing' ) |
| 1407 | - ) ); ?> |
|
| 1410 | + ) ); |
|
| 1411 | +} |
|
| 1412 | +?> |
|
| 1408 | 1413 | </td> |
| 1409 | 1414 | <td class="wpinv_tax_state"> |
| 1410 | 1415 | <?php echo wpinv_html_text( array( |
@@ -1,6 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly |
| 3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | + exit; |
|
| 5 | +} |
|
| 4 | 6 | |
| 5 | 7 | function wpinv_get_users_invoices( $user = 0, $number = 20, $pagination = false, $status = 'publish', $orderby = 'ID', $order = 'DESC' ) { |
| 6 | 8 | if ( empty( $user ) ) { |
@@ -22,6 +22,9 @@ |
||
| 22 | 22 | add_shortcode( 'wpinv_messages', __CLASS__ . '::messages' ); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | + /** |
|
| 26 | + * @param string[] $function |
|
| 27 | + */ |
|
| 25 | 28 | public static function shortcode_wrapper( $function, $atts = array(), $content = null, $wrapper = array( 'class' => 'wpi-g', 'before' => null, 'after' => null ) ) { |
| 26 | 29 | ob_start(); |
| 27 | 30 | |
@@ -83,6 +83,9 @@ discard block |
||
| 83 | 83 | return $value; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | + /** |
|
| 87 | + * @param string $key |
|
| 88 | + */ |
|
| 86 | 89 | public function set( $key, $value ) { |
| 87 | 90 | $ignore = array( 'items', 'cart_details', 'fees', '_ID' ); |
| 88 | 91 | |
@@ -921,6 +924,9 @@ discard block |
||
| 921 | 924 | return $removed; |
| 922 | 925 | } |
| 923 | 926 | |
| 927 | + /** |
|
| 928 | + * @param string $key |
|
| 929 | + */ |
|
| 924 | 930 | public function remove_fee_by( $key, $value, $global = false ) { |
| 925 | 931 | $allowed_fee_keys = apply_filters( 'wpinv_fee_keys', array( |
| 926 | 932 | 'index', 'label', 'amount', 'type', |
@@ -1381,6 +1387,9 @@ discard block |
||
| 1381 | 1387 | return apply_filters( 'wpinv_get_invoice_final_total', $final_total, $this, $currency ); |
| 1382 | 1388 | } |
| 1383 | 1389 | |
| 1390 | + /** |
|
| 1391 | + * @return boolean |
|
| 1392 | + */ |
|
| 1384 | 1393 | public function get_discounts( $array = false ) { |
| 1385 | 1394 | $discounts = $this->discounts; |
| 1386 | 1395 | if ( $array && $discounts ) { |
@@ -1389,6 +1398,9 @@ discard block |
||
| 1389 | 1398 | return apply_filters( 'wpinv_payment_discounts', $discounts, $this->ID, $this, $array ); |
| 1390 | 1399 | } |
| 1391 | 1400 | |
| 1401 | + /** |
|
| 1402 | + * @return string |
|
| 1403 | + */ |
|
| 1392 | 1404 | public function get_discount( $currency = false, $dash = false ) { |
| 1393 | 1405 | if ( !empty( $this->discounts ) ) { |
| 1394 | 1406 | global $ajax_cart_details; |
@@ -1491,10 +1503,16 @@ discard block |
||
| 1491 | 1503 | return apply_filters( 'wpinv_user_full_name', $this->full_name, $this->ID, $this ); |
| 1492 | 1504 | } |
| 1493 | 1505 | |
| 1506 | + /** |
|
| 1507 | + * @return string |
|
| 1508 | + */ |
|
| 1494 | 1509 | public function get_user_info() { |
| 1495 | 1510 | return apply_filters( 'wpinv_user_info', $this->user_info, $this->ID, $this ); |
| 1496 | 1511 | } |
| 1497 | 1512 | |
| 1513 | + /** |
|
| 1514 | + * @return string |
|
| 1515 | + */ |
|
| 1498 | 1516 | public function get_email() { |
| 1499 | 1517 | return apply_filters( 'wpinv_user_email', $this->email, $this->ID, $this ); |
| 1500 | 1518 | } |
@@ -1537,6 +1555,9 @@ discard block |
||
| 1537 | 1555 | return apply_filters( 'wpinv_currency_code', $this->currency, $this->ID, $this ); |
| 1538 | 1556 | } |
| 1539 | 1557 | |
| 1558 | + /** |
|
| 1559 | + * @return string |
|
| 1560 | + */ |
|
| 1540 | 1561 | public function get_created_date() { |
| 1541 | 1562 | return apply_filters( 'wpinv_created_date', $this->date, $this->ID, $this ); |
| 1542 | 1563 | } |
@@ -1555,6 +1576,9 @@ discard block |
||
| 1555 | 1576 | return apply_filters( 'wpinv_completed_date', $this->completed_date, $this->ID, $this ); |
| 1556 | 1577 | } |
| 1557 | 1578 | |
| 1579 | + /** |
|
| 1580 | + * @return string |
|
| 1581 | + */ |
|
| 1558 | 1582 | public function get_invoice_date( $formatted = true ) { |
| 1559 | 1583 | $date_completed = $this->completed_date; |
| 1560 | 1584 | $invoice_date = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? $date_completed : ''; |