@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
10 | +if (!defined('WPINC')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
@@ -24,40 +24,40 @@ discard block |
||
24 | 24 | * @param Array $assoc_args Key value arguments stored in associated array format. |
25 | 25 | * @since 1.0.13 |
26 | 26 | */ |
27 | - public function insert_invoice( $args, $assoc_args ) { |
|
27 | + public function insert_invoice($args, $assoc_args) { |
|
28 | 28 | |
29 | 29 | // Fetch invoice data from the args |
30 | - $invoice_data = wp_unslash( $assoc_args ); |
|
30 | + $invoice_data = wp_unslash($assoc_args); |
|
31 | 31 | |
32 | 32 | // Abort if no invoice data is provided |
33 | - if( empty( $invoice_data ) ) { |
|
34 | - return WP_CLI::error( __( 'Invoice data not provided', 'invoicing' ) ); |
|
33 | + if (empty($invoice_data)) { |
|
34 | + return WP_CLI::error(__('Invoice data not provided', 'invoicing')); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | //Cart details |
38 | - if( !empty( $invoice_data['cart_details'] ) ) { |
|
39 | - $invoice_data['cart_details'] = json_decode( $invoice_data['cart_details'], true ); |
|
38 | + if (!empty($invoice_data['cart_details'])) { |
|
39 | + $invoice_data['cart_details'] = json_decode($invoice_data['cart_details'], true); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | //User details |
43 | - if( !empty( $invoice_data['user_info'] ) ) { |
|
44 | - $invoice_data['user_info'] = json_decode( $invoice_data['user_info'], true ); |
|
43 | + if (!empty($invoice_data['user_info'])) { |
|
44 | + $invoice_data['user_info'] = json_decode($invoice_data['user_info'], true); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | //Payment info |
48 | - if( !empty( $invoice_data['payment_details'] ) ) { |
|
49 | - $invoice_data['payment_details'] = json_decode( $invoice_data['payment_details'], true ); |
|
48 | + if (!empty($invoice_data['payment_details'])) { |
|
49 | + $invoice_data['payment_details'] = json_decode($invoice_data['payment_details'], true); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | // Try creating the invoice |
53 | - $invoice = wpinv_insert_invoice( $invoice_data, true ); |
|
53 | + $invoice = wpinv_insert_invoice($invoice_data, true); |
|
54 | 54 | |
55 | - if ( is_wp_error( $invoice ) ) { |
|
56 | - return WP_CLI::error( $invoice->get_error_message() ); |
|
55 | + if (is_wp_error($invoice)) { |
|
56 | + return WP_CLI::error($invoice->get_error_message()); |
|
57 | 57 | } |
58 | 58 | |
59 | - $message = sprintf( __( 'Invoice %s created', 'invoicing' ), $invoice->ID ); |
|
60 | - WP_CLI::success( $message ); |
|
59 | + $message = sprintf(__('Invoice %s created', 'invoicing'), $invoice->ID); |
|
60 | + WP_CLI::success($message); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 |
@@ -46,25 +46,25 @@ |
||
46 | 46 | parent::__construct( $options ); |
47 | 47 | } |
48 | 48 | |
49 | - /** |
|
50 | - * The Super block output function. |
|
51 | - * |
|
52 | - * @param array $args |
|
53 | - * @param array $widget_args |
|
54 | - * @param string $content |
|
55 | - * |
|
56 | - * @return mixed|string|bool |
|
57 | - */ |
|
49 | + /** |
|
50 | + * The Super block output function. |
|
51 | + * |
|
52 | + * @param array $args |
|
53 | + * @param array $widget_args |
|
54 | + * @param string $content |
|
55 | + * |
|
56 | + * @return mixed|string|bool |
|
57 | + */ |
|
58 | 58 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
59 | 59 | |
60 | - ob_start(); |
|
60 | + ob_start(); |
|
61 | 61 | |
62 | - do_action( 'wpinv_before_user_invoice_history' ); |
|
63 | - wpinv_get_template_part( 'wpinv-invoice-history' ); |
|
64 | - do_action( 'wpinv_after_user_invoice_history' ); |
|
62 | + do_action( 'wpinv_before_user_invoice_history' ); |
|
63 | + wpinv_get_template_part( 'wpinv-invoice-history' ); |
|
64 | + do_action( 'wpinv_after_user_invoice_history' ); |
|
65 | 65 | |
66 | - $output = ob_get_clean(); |
|
67 | - return trim($output); |
|
66 | + $output = ob_get_clean(); |
|
67 | + return trim($output); |
|
68 | 68 | |
69 | 69 | } |
70 | 70 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -22,15 +22,15 @@ discard block |
||
22 | 22 | 'block-keywords'=> "['invoicing','history']", |
23 | 23 | 'class_name' => __CLASS__, |
24 | 24 | 'base_id' => 'wpinv_history', |
25 | - 'name' => __('Invoicing > Invoice History','invoicing'), |
|
25 | + 'name' => __('Invoicing > Invoice History', 'invoicing'), |
|
26 | 26 | 'widget_ops' => array( |
27 | 27 | 'classname' => 'wpinv-history-class wpi-g', |
28 | - 'description' => esc_html__('Displays invoice history.','invoicing'), |
|
28 | + 'description' => esc_html__('Displays invoice history.', 'invoicing'), |
|
29 | 29 | ), |
30 | 30 | 'arguments' => array( |
31 | 31 | 'title' => array( |
32 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
33 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
32 | + 'title' => __('Widget title', 'invoicing'), |
|
33 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
34 | 34 | 'type' => 'text', |
35 | 35 | 'desc_tip' => true, |
36 | 36 | 'default' => '', |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | ); |
42 | 42 | |
43 | 43 | |
44 | - parent::__construct( $options ); |
|
44 | + parent::__construct($options); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return mixed|string|bool |
55 | 55 | */ |
56 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
56 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
57 | 57 | |
58 | 58 | ob_start(); |
59 | 59 | |
60 | - do_action( 'wpinv_before_user_invoice_history' ); |
|
61 | - wpinv_get_template_part( 'wpinv-invoice-history' ); |
|
62 | - do_action( 'wpinv_after_user_invoice_history' ); |
|
60 | + do_action('wpinv_before_user_invoice_history'); |
|
61 | + wpinv_get_template_part('wpinv-invoice-history'); |
|
62 | + do_action('wpinv_after_user_invoice_history'); |
|
63 | 63 | |
64 | 64 | $output = ob_get_clean(); |
65 | 65 | return trim($output); |
@@ -44,22 +44,22 @@ |
||
44 | 44 | parent::__construct( $options ); |
45 | 45 | } |
46 | 46 | |
47 | - /** |
|
48 | - * The Super block output function. |
|
49 | - * |
|
50 | - * @param array $args |
|
51 | - * @param array $widget_args |
|
52 | - * @param string $content |
|
53 | - * |
|
54 | - * @return mixed|string|bool |
|
55 | - */ |
|
47 | + /** |
|
48 | + * The Super block output function. |
|
49 | + * |
|
50 | + * @param array $args |
|
51 | + * @param array $widget_args |
|
52 | + * @param string $content |
|
53 | + * |
|
54 | + * @return mixed|string|bool |
|
55 | + */ |
|
56 | 56 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
57 | 57 | |
58 | - ob_start(); |
|
58 | + ob_start(); |
|
59 | 59 | |
60 | - wpinv_print_errors(); |
|
60 | + wpinv_print_errors(); |
|
61 | 61 | |
62 | - return '<div class="wpinv">' . ob_get_clean() . '</div>'; |
|
62 | + return '<div class="wpinv">' . ob_get_clean() . '</div>'; |
|
63 | 63 | |
64 | 64 | } |
65 | 65 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -22,15 +22,15 @@ discard block |
||
22 | 22 | 'block-keywords'=> "['invoicing','history']", |
23 | 23 | 'class_name' => __CLASS__, |
24 | 24 | 'base_id' => 'wpinv_messages', |
25 | - 'name' => __('Invoicing > Invoice Messages','invoicing'), |
|
25 | + 'name' => __('Invoicing > Invoice Messages', 'invoicing'), |
|
26 | 26 | 'widget_ops' => array( |
27 | 27 | 'classname' => 'wpinv-messages-class wpi-g', |
28 | - 'description' => esc_html__('Displays invoice error and warning messages on checkout page.','invoicing'), |
|
28 | + 'description' => esc_html__('Displays invoice error and warning messages on checkout page.', 'invoicing'), |
|
29 | 29 | ), |
30 | 30 | 'arguments' => array( |
31 | 31 | 'title' => array( |
32 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
33 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
32 | + 'title' => __('Widget title', 'invoicing'), |
|
33 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
34 | 34 | 'type' => 'text', |
35 | 35 | 'desc_tip' => true, |
36 | 36 | 'default' => '', |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | ); |
42 | 42 | |
43 | 43 | |
44 | - parent::__construct( $options ); |
|
44 | + parent::__construct($options); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return mixed|string|bool |
55 | 55 | */ |
56 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
56 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
57 | 57 | |
58 | 58 | ob_start(); |
59 | 59 |
@@ -46,18 +46,18 @@ |
||
46 | 46 | parent::__construct( $options ); |
47 | 47 | } |
48 | 48 | |
49 | - /** |
|
50 | - * The Super block output function. |
|
51 | - * |
|
52 | - * @param array $args |
|
53 | - * @param array $widget_args |
|
54 | - * @param string $content |
|
55 | - * |
|
56 | - * @return mixed|string|bool |
|
57 | - */ |
|
49 | + /** |
|
50 | + * The Super block output function. |
|
51 | + * |
|
52 | + * @param array $args |
|
53 | + * @param array $widget_args |
|
54 | + * @param string $content |
|
55 | + * |
|
56 | + * @return mixed|string|bool |
|
57 | + */ |
|
58 | 58 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
59 | 59 | |
60 | - return wpinv_checkout_form(); |
|
60 | + return wpinv_checkout_form(); |
|
61 | 61 | |
62 | 62 | } |
63 | 63 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | 'block-keywords'=> "['invoicing','checkout']", |
24 | 24 | 'class_name' => __CLASS__, |
25 | 25 | 'base_id' => 'wpinv_checkout', |
26 | - 'name' => __('Invoicing > Checkout','invoicing'), |
|
26 | + 'name' => __('Invoicing > Checkout', 'invoicing'), |
|
27 | 27 | 'widget_ops' => array( |
28 | 28 | 'classname' => 'wpinv-checkout-class wpi-g', |
29 | - 'description' => esc_html__('Displays checkout form.','invoicing'), |
|
29 | + 'description' => esc_html__('Displays checkout form.', 'invoicing'), |
|
30 | 30 | ), |
31 | 31 | 'arguments' => array( |
32 | 32 | 'title' => array( |
33 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
34 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
33 | + 'title' => __('Widget title', 'invoicing'), |
|
34 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
35 | 35 | 'type' => 'text', |
36 | 36 | 'desc_tip' => true, |
37 | 37 | 'default' => '', |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | ); |
43 | 43 | |
44 | 44 | |
45 | - parent::__construct( $options ); |
|
45 | + parent::__construct($options); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return mixed|string|bool |
56 | 56 | */ |
57 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
57 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
58 | 58 | |
59 | 59 | return wpinv_checkout_form(); |
60 | 60 |
@@ -46,25 +46,25 @@ |
||
46 | 46 | parent::__construct( $options ); |
47 | 47 | } |
48 | 48 | |
49 | - /** |
|
50 | - * The Super block output function. |
|
51 | - * |
|
52 | - * @param array $args |
|
53 | - * @param array $widget_args |
|
54 | - * @param string $content |
|
55 | - * |
|
56 | - * @return mixed|string|bool |
|
57 | - */ |
|
49 | + /** |
|
50 | + * The Super block output function. |
|
51 | + * |
|
52 | + * @param array $args |
|
53 | + * @param array $widget_args |
|
54 | + * @param string $content |
|
55 | + * |
|
56 | + * @return mixed|string|bool |
|
57 | + */ |
|
58 | 58 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
59 | 59 | |
60 | - ob_start(); |
|
60 | + ob_start(); |
|
61 | 61 | |
62 | - do_action( 'wpinv_before_user_subscriptions' ); |
|
63 | - wpinv_get_template_part( 'wpinv-subscriptions-history' ); |
|
64 | - do_action( 'wpinv_after_user_subscriptions' ); |
|
62 | + do_action( 'wpinv_before_user_subscriptions' ); |
|
63 | + wpinv_get_template_part( 'wpinv-subscriptions-history' ); |
|
64 | + do_action( 'wpinv_after_user_subscriptions' ); |
|
65 | 65 | |
66 | - $output = ob_get_clean(); |
|
67 | - return trim($output); |
|
66 | + $output = ob_get_clean(); |
|
67 | + return trim($output); |
|
68 | 68 | |
69 | 69 | } |
70 | 70 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -22,15 +22,15 @@ discard block |
||
22 | 22 | 'block-keywords'=> "['invoicing','subscriptions']", |
23 | 23 | 'class_name' => __CLASS__, |
24 | 24 | 'base_id' => 'wpinv_subscriptions', |
25 | - 'name' => __('Invoicing > Subscriptions History','invoicing'), |
|
25 | + 'name' => __('Invoicing > Subscriptions History', 'invoicing'), |
|
26 | 26 | 'widget_ops' => array( |
27 | 27 | 'classname' => 'wpinv-checkout-class wpi-g', |
28 | - 'description' => esc_html__('Displays subscriptions history.','invoicing'), |
|
28 | + 'description' => esc_html__('Displays subscriptions history.', 'invoicing'), |
|
29 | 29 | ), |
30 | 30 | 'arguments' => array( |
31 | 31 | 'title' => array( |
32 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
33 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
32 | + 'title' => __('Widget title', 'invoicing'), |
|
33 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
34 | 34 | 'type' => 'text', |
35 | 35 | 'desc_tip' => true, |
36 | 36 | 'default' => '', |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | ); |
42 | 42 | |
43 | 43 | |
44 | - parent::__construct( $options ); |
|
44 | + parent::__construct($options); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return mixed|string|bool |
55 | 55 | */ |
56 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
56 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
57 | 57 | |
58 | 58 | ob_start(); |
59 | 59 | |
60 | - do_action( 'wpinv_before_user_subscriptions' ); |
|
61 | - wpinv_get_template_part( 'wpinv-subscriptions-history' ); |
|
62 | - do_action( 'wpinv_after_user_subscriptions' ); |
|
60 | + do_action('wpinv_before_user_subscriptions'); |
|
61 | + wpinv_get_template_part('wpinv-subscriptions-history'); |
|
62 | + do_action('wpinv_after_user_subscriptions'); |
|
63 | 63 | |
64 | 64 | $output = ob_get_clean(); |
65 | 65 | return trim($output); |
@@ -44,25 +44,25 @@ |
||
44 | 44 | parent::__construct( $options ); |
45 | 45 | } |
46 | 46 | |
47 | - /** |
|
48 | - * The Super block output function. |
|
49 | - * |
|
50 | - * @param array $args |
|
51 | - * @param array $widget_args |
|
52 | - * @param string $content |
|
53 | - * |
|
54 | - * @return mixed|string|bool |
|
55 | - */ |
|
47 | + /** |
|
48 | + * The Super block output function. |
|
49 | + * |
|
50 | + * @param array $args |
|
51 | + * @param array $widget_args |
|
52 | + * @param string $content |
|
53 | + * |
|
54 | + * @return mixed|string|bool |
|
55 | + */ |
|
56 | 56 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
57 | 57 | |
58 | - ob_start(); |
|
58 | + ob_start(); |
|
59 | 59 | |
60 | - do_action( 'wpinv_success_content_before' ); |
|
61 | - echo wpinv_payment_receipt( $args ); |
|
62 | - do_action( 'wpinv_success_content_after' ); |
|
60 | + do_action( 'wpinv_success_content_before' ); |
|
61 | + echo wpinv_payment_receipt( $args ); |
|
62 | + do_action( 'wpinv_success_content_after' ); |
|
63 | 63 | |
64 | - $output = ob_get_clean(); |
|
65 | - return trim($output); |
|
64 | + $output = ob_get_clean(); |
|
65 | + return trim($output); |
|
66 | 66 | |
67 | 67 | } |
68 | 68 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -22,15 +22,15 @@ discard block |
||
22 | 22 | 'block-keywords'=> "['invoicing','receipt']", |
23 | 23 | 'class_name' => __CLASS__, |
24 | 24 | 'base_id' => 'wpinv_receipt', |
25 | - 'name' => __('Invoicing > Invoice Receipt','invoicing'), |
|
25 | + 'name' => __('Invoicing > Invoice Receipt', 'invoicing'), |
|
26 | 26 | 'widget_ops' => array( |
27 | 27 | 'classname' => 'wpinv-receipt-class wpi-g', |
28 | - 'description' => esc_html__('Displays invoice receipt after checkout.','invoicing'), |
|
28 | + 'description' => esc_html__('Displays invoice receipt after checkout.', 'invoicing'), |
|
29 | 29 | ), |
30 | 30 | 'arguments' => array( |
31 | 31 | 'title' => array( |
32 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
33 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
32 | + 'title' => __('Widget title', 'invoicing'), |
|
33 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
34 | 34 | 'type' => 'text', |
35 | 35 | 'desc_tip' => true, |
36 | 36 | 'default' => '', |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | ); |
42 | 42 | |
43 | 43 | |
44 | - parent::__construct( $options ); |
|
44 | + parent::__construct($options); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return mixed|string|bool |
55 | 55 | */ |
56 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
56 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
57 | 57 | |
58 | 58 | ob_start(); |
59 | 59 | |
60 | - do_action( 'wpinv_success_content_before' ); |
|
61 | - echo wpinv_payment_receipt( $args ); |
|
62 | - do_action( 'wpinv_success_content_after' ); |
|
60 | + do_action('wpinv_success_content_before'); |
|
61 | + echo wpinv_payment_receipt($args); |
|
62 | + do_action('wpinv_success_content_after'); |
|
63 | 63 | |
64 | 64 | $output = ob_get_clean(); |
65 | 65 | return trim($output); |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
140 | 140 | require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
141 | 141 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
142 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
143 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
144 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
145 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
146 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
147 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
142 | + require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
143 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
144 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
145 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
146 | + require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
147 | + require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
148 | 148 | |
149 | 149 | if ( !class_exists( 'WPInv_EUVat' ) ) { |
150 | 150 | require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
@@ -420,16 +420,16 @@ discard block |
||
420 | 420 | require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
421 | 421 | } |
422 | 422 | |
423 | - /** |
|
424 | - * Register widgets |
|
425 | - * |
|
426 | - */ |
|
427 | - public function register_widgets() { |
|
428 | - register_widget( "WPInv_Checkout_Widget" ); |
|
429 | - register_widget( "WPInv_History_Widget" ); |
|
430 | - register_widget( "WPInv_Receipt_Widget" ); |
|
431 | - register_widget( "WPInv_Subscriptions_Widget" ); |
|
432 | - register_widget( "WPInv_Buy_Item_Widget" ); |
|
433 | - register_widget( "WPInv_Messages_Widget" ); |
|
434 | - } |
|
423 | + /** |
|
424 | + * Register widgets |
|
425 | + * |
|
426 | + */ |
|
427 | + public function register_widgets() { |
|
428 | + register_widget( "WPInv_Checkout_Widget" ); |
|
429 | + register_widget( "WPInv_History_Widget" ); |
|
430 | + register_widget( "WPInv_Receipt_Widget" ); |
|
431 | + register_widget( "WPInv_Subscriptions_Widget" ); |
|
432 | + register_widget( "WPInv_Buy_Item_Widget" ); |
|
433 | + register_widget( "WPInv_Messages_Widget" ); |
|
434 | + } |
|
435 | 435 | } |
436 | 436 | \ No newline at end of file |
@@ -7,15 +7,15 @@ 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 | class WPInv_Plugin { |
15 | 15 | private static $instance; |
16 | 16 | |
17 | 17 | public static function run() { |
18 | - if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) { |
|
18 | + if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) { |
|
19 | 19 | self::$instance = new WPInv_Plugin; |
20 | 20 | self::$instance->includes(); |
21 | 21 | self::$instance->actions(); |
@@ -32,31 +32,31 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | public function define_constants() { |
35 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
36 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
35 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
36 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | private function actions() { |
40 | 40 | /* Internationalize the text strings used. */ |
41 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
41 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
42 | 42 | |
43 | 43 | /* Perform actions on admin initialization. */ |
44 | - add_action( 'admin_init', array( &$this, 'admin_init') ); |
|
45 | - add_action( 'init', array( &$this, 'init' ), 3 ); |
|
46 | - add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
44 | + add_action('admin_init', array(&$this, 'admin_init')); |
|
45 | + add_action('init', array(&$this, 'init'), 3); |
|
46 | + add_action('init', array(&$this, 'wpinv_actions')); |
|
47 | 47 | |
48 | - if ( class_exists( 'BuddyPress' ) ) { |
|
49 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
48 | + if (class_exists('BuddyPress')) { |
|
49 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
50 | 50 | } |
51 | 51 | |
52 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
53 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
52 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
53 | + add_action('widgets_init', array(&$this, 'register_widgets')); |
|
54 | 54 | |
55 | - if ( is_admin() ) { |
|
56 | - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); |
|
57 | - add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) ); |
|
55 | + if (is_admin()) { |
|
56 | + add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts')); |
|
57 | + add_action('admin_body_class', array(&$this, 'admin_body_class')); |
|
58 | 58 | } else { |
59 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
59 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -66,19 +66,19 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference. |
68 | 68 | */ |
69 | - do_action_ref_array( 'wpinv_actions', array( &$this ) ); |
|
69 | + do_action_ref_array('wpinv_actions', array(&$this)); |
|
70 | 70 | |
71 | - add_action( 'admin_init', array( &$this, 'activation_redirect') ); |
|
71 | + add_action('admin_init', array(&$this, 'activation_redirect')); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | public function plugins_loaded() { |
75 | 75 | /* Internationalize the text strings used. */ |
76 | 76 | $this->load_textdomain(); |
77 | 77 | |
78 | - do_action( 'wpinv_loaded' ); |
|
78 | + do_action('wpinv_loaded'); |
|
79 | 79 | |
80 | 80 | // Fix oxygen page builder conflict |
81 | - if ( function_exists( 'ct_css_output' ) ) { |
|
81 | + if (function_exists('ct_css_output')) { |
|
82 | 82 | wpinv_oxygen_fix_conflict(); |
83 | 83 | } |
84 | 84 | } |
@@ -88,228 +88,228 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @since 1.0 |
90 | 90 | */ |
91 | - public function load_textdomain( $locale = NULL ) { |
|
92 | - if ( empty( $locale ) ) { |
|
93 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
91 | + public function load_textdomain($locale = NULL) { |
|
92 | + if (empty($locale)) { |
|
93 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
94 | 94 | } |
95 | 95 | |
96 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
96 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
97 | 97 | |
98 | - unload_textdomain( 'invoicing' ); |
|
99 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
100 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
98 | + unload_textdomain('invoicing'); |
|
99 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
100 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
101 | 101 | |
102 | 102 | /** |
103 | 103 | * Define language constants. |
104 | 104 | */ |
105 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
105 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | public function includes() { |
109 | 109 | global $wpinv_options; |
110 | 110 | |
111 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
111 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
112 | 112 | $wpinv_options = wpinv_get_settings(); |
113 | 113 | |
114 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
115 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
116 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
117 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
118 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
119 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
120 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
121 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' ); |
|
122 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
123 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
124 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
125 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
126 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
127 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); |
|
128 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' ); |
|
129 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); |
|
130 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); |
|
131 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); |
|
132 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
133 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
134 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
135 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
136 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
137 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
138 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
139 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
140 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
141 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' ); |
|
142 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
143 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' ); |
|
144 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
145 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
146 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
147 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
148 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
149 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
150 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
151 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
152 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
153 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
154 | - |
|
155 | - if ( !class_exists( 'WPInv_EUVat' ) ) { |
|
156 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
114 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
115 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
116 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
117 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
118 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
119 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
120 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
121 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php'); |
|
122 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
123 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
124 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
125 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
126 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
127 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php'); |
|
128 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php'); |
|
129 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); |
|
130 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); |
|
131 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); |
|
132 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
133 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
134 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
135 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
136 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
137 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
138 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
139 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
140 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
141 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php'); |
|
142 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
143 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php'); |
|
144 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
145 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
146 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
147 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
148 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
149 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
150 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
151 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
152 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
153 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
154 | + |
|
155 | + if (!class_exists('WPInv_EUVat')) { |
|
156 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
157 | 157 | } |
158 | 158 | |
159 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
160 | - if ( !empty( $gateways ) ) { |
|
161 | - foreach ( $gateways as $gateway ) { |
|
162 | - if ( $gateway == 'manual' ) { |
|
159 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
160 | + if (!empty($gateways)) { |
|
161 | + foreach ($gateways as $gateway) { |
|
162 | + if ($gateway == 'manual') { |
|
163 | 163 | continue; |
164 | 164 | } |
165 | 165 | |
166 | 166 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
167 | 167 | |
168 | - if ( file_exists( $gateway_file ) ) { |
|
169 | - require_once( $gateway_file ); |
|
168 | + if (file_exists($gateway_file)) { |
|
169 | + require_once($gateway_file); |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | } |
173 | - require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
173 | + require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
|
174 | 174 | |
175 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
176 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
177 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
178 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); |
|
175 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
176 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
177 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
178 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); |
|
179 | 179 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
180 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); |
|
181 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); |
|
182 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
183 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); |
|
184 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
185 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
186 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
180 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); |
|
181 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); |
|
182 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
183 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); |
|
184 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
185 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
186 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
187 | 187 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
188 | 188 | // load the user class only on the users.php page |
189 | 189 | global $pagenow; |
190 | - if($pagenow=='users.php'){ |
|
190 | + if ($pagenow == 'users.php') { |
|
191 | 191 | new WPInv_Admin_Users(); |
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | 195 | // Register cli commands |
196 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
197 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
198 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
196 | + if (defined('WP_CLI') && WP_CLI) { |
|
197 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
198 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | // include css inliner |
202 | - if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
|
203 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
202 | + if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
203 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
204 | 204 | } |
205 | 205 | |
206 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
206 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | public function init() { |
210 | 210 | } |
211 | 211 | |
212 | 212 | public function admin_init() { |
213 | - add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
213 | + add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | public function activation_redirect() { |
217 | 217 | // Bail if no activation redirect |
218 | - if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
218 | + if (!get_transient('_wpinv_activation_redirect')) { |
|
219 | 219 | return; |
220 | 220 | } |
221 | 221 | |
222 | 222 | // Delete the redirect transient |
223 | - delete_transient( '_wpinv_activation_redirect' ); |
|
223 | + delete_transient('_wpinv_activation_redirect'); |
|
224 | 224 | |
225 | 225 | // Bail if activating from network, or bulk |
226 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
226 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
227 | 227 | return; |
228 | 228 | } |
229 | 229 | |
230 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
230 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
231 | 231 | exit; |
232 | 232 | } |
233 | 233 | |
234 | 234 | public function enqueue_scripts() { |
235 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
235 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
236 | 236 | |
237 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); |
|
238 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
237 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); |
|
238 | + wp_enqueue_style('wpinv_front_style'); |
|
239 | 239 | |
240 | 240 | // Register scripts |
241 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
242 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), WPINV_VERSION ); |
|
241 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
242 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), WPINV_VERSION); |
|
243 | 243 | |
244 | 244 | $localize = array(); |
245 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
246 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
245 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
246 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
247 | 247 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
248 | 248 | $localize['currency_pos'] = wpinv_currency_position(); |
249 | 249 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
250 | 250 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
251 | 251 | $localize['decimals'] = wpinv_decimals(); |
252 | - $localize['txtComplete'] = __( 'Complete', 'invoicing' ); |
|
252 | + $localize['txtComplete'] = __('Complete', 'invoicing'); |
|
253 | 253 | $localize['UseTaxes'] = wpinv_use_taxes(); |
254 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
254 | + $localize['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
255 | 255 | |
256 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
256 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
257 | 257 | |
258 | - wp_enqueue_script( 'jquery-blockui' ); |
|
258 | + wp_enqueue_script('jquery-blockui'); |
|
259 | 259 | $autofill_api = wpinv_get_option('address_autofill_api'); |
260 | 260 | $autofill_active = wpinv_get_option('address_autofill_active'); |
261 | - if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
262 | - if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
263 | - wp_dequeue_script( 'google-maps-api' ); |
|
261 | + if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
|
262 | + if (wp_script_is('google-maps-api', 'enqueued')) { |
|
263 | + wp_dequeue_script('google-maps-api'); |
|
264 | 264 | } |
265 | - wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
266 | - wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
265 | + wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
|
266 | + wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
|
267 | 267 | } |
268 | 268 | |
269 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
270 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
269 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
270 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
271 | 271 | |
272 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
273 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
272 | + wp_enqueue_script('wpinv-front-script'); |
|
273 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | public function admin_enqueue_scripts() { |
277 | 277 | global $post, $pagenow; |
278 | 278 | |
279 | 279 | $post_type = wpinv_admin_post_type(); |
280 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
281 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : ''; |
|
280 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
281 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : ''; |
|
282 | 282 | |
283 | 283 | $jquery_ui_css = false; |
284 | - if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
284 | + if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
285 | 285 | $jquery_ui_css = true; |
286 | - } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) { |
|
286 | + } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') { |
|
287 | 287 | $jquery_ui_css = true; |
288 | 288 | } |
289 | - if ( $jquery_ui_css ) { |
|
290 | - wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
|
291 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
289 | + if ($jquery_ui_css) { |
|
290 | + wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
291 | + wp_enqueue_style('jquery-ui-css'); |
|
292 | 292 | } |
293 | 293 | |
294 | - wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
295 | - wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
294 | + wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
295 | + wp_enqueue_style('wpinv_meta_box_style'); |
|
296 | 296 | |
297 | - wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION ); |
|
298 | - wp_enqueue_style( 'wpinv_admin_style' ); |
|
297 | + wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION); |
|
298 | + wp_enqueue_style('wpinv_admin_style'); |
|
299 | 299 | |
300 | - $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ); |
|
301 | - if ( $page == 'wpinv-subscriptions' ) { |
|
302 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
300 | + $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')); |
|
301 | + if ($page == 'wpinv-subscriptions') { |
|
302 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
303 | 303 | } |
304 | 304 | |
305 | - if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) { |
|
306 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
305 | + if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) { |
|
306 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
307 | 307 | } |
308 | 308 | |
309 | - wp_enqueue_style( 'wp-color-picker' ); |
|
310 | - wp_enqueue_script( 'wp-color-picker' ); |
|
309 | + wp_enqueue_style('wp-color-picker'); |
|
310 | + wp_enqueue_script('wp-color-picker'); |
|
311 | 311 | |
312 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
312 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
313 | 313 | |
314 | 314 | if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
315 | 315 | $autofill_api = wpinv_get_option('address_autofill_api'); |
@@ -320,20 +320,20 @@ discard block |
||
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
324 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
323 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
324 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
325 | 325 | |
326 | - wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ), WPINV_VERSION ); |
|
327 | - wp_enqueue_script( 'wpinv-admin-script' ); |
|
326 | + wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION); |
|
327 | + wp_enqueue_script('wpinv-admin-script'); |
|
328 | 328 | |
329 | 329 | $localize = array(); |
330 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
331 | - $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
|
332 | - $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
333 | - $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
|
334 | - $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
|
335 | - $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
|
336 | - $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
330 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
331 | + $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
332 | + $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
333 | + $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
334 | + $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
335 | + $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
336 | + $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
|
337 | 337 | $localize['tax'] = wpinv_tax_amount(); |
338 | 338 | $localize['discount'] = wpinv_discount_amount(); |
339 | 339 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
@@ -341,69 +341,69 @@ discard block |
||
341 | 341 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
342 | 342 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
343 | 343 | $localize['decimals'] = wpinv_decimals(); |
344 | - $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
|
345 | - $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
|
346 | - $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
|
347 | - $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
|
348 | - $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
|
349 | - $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
|
350 | - $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
|
351 | - $localize['confirmCalcTotals'] = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ); |
|
352 | - $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
|
353 | - $localize['emptyInvoice'] = __( 'Add at least one item to save invoice!', 'invoicing' ); |
|
354 | - $localize['errDeleteItem'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
|
355 | - $localize['delete_subscription'] = __( 'Are you sure you want to delete this subscription?', 'invoicing' ); |
|
356 | - $localize['action_edit'] = __( 'Edit', 'invoicing' ); |
|
357 | - $localize['action_cancel'] = __( 'Cancel', 'invoicing' ); |
|
358 | - |
|
359 | - $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
360 | - |
|
361 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
362 | - |
|
363 | - if ( $page == 'wpinv-subscriptions' ) { |
|
364 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
365 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
344 | + $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
345 | + $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
346 | + $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
347 | + $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
348 | + $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
349 | + $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
350 | + $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
351 | + $localize['confirmCalcTotals'] = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'); |
|
352 | + $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
|
353 | + $localize['emptyInvoice'] = __('Add at least one item to save invoice!', 'invoicing'); |
|
354 | + $localize['errDeleteItem'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
|
355 | + $localize['delete_subscription'] = __('Are you sure you want to delete this subscription?', 'invoicing'); |
|
356 | + $localize['action_edit'] = __('Edit', 'invoicing'); |
|
357 | + $localize['action_cancel'] = __('Cancel', 'invoicing'); |
|
358 | + |
|
359 | + $localize = apply_filters('wpinv_admin_js_localize', $localize); |
|
360 | + |
|
361 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
|
362 | + |
|
363 | + if ($page == 'wpinv-subscriptions') { |
|
364 | + wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION); |
|
365 | + wp_enqueue_script('wpinv-sub-admin-script'); |
|
366 | 366 | } |
367 | 367 | } |
368 | 368 | |
369 | - public function admin_body_class( $classes ) { |
|
369 | + public function admin_body_class($classes) { |
|
370 | 370 | global $pagenow, $post, $current_screen; |
371 | 371 | |
372 | - if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
372 | + if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) { |
|
373 | 373 | $classes .= ' wpinv-cpt'; |
374 | 374 | } |
375 | 375 | |
376 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
376 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
377 | 377 | |
378 | - $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false; |
|
379 | - if ( $add_class ) { |
|
380 | - $classes .= ' wpi-' . wpinv_sanitize_key( $page ); |
|
378 | + $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false; |
|
379 | + if ($add_class) { |
|
380 | + $classes .= ' wpi-' . wpinv_sanitize_key($page); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | $settings_class = array(); |
384 | - if ( $page == 'wpinv-settings' ) { |
|
385 | - if ( !empty( $_REQUEST['tab'] ) ) { |
|
386 | - $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
384 | + if ($page == 'wpinv-settings') { |
|
385 | + if (!empty($_REQUEST['tab'])) { |
|
386 | + $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
|
387 | 387 | } |
388 | 388 | |
389 | - if ( !empty( $_REQUEST['section'] ) ) { |
|
390 | - $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
389 | + if (!empty($_REQUEST['section'])) { |
|
390 | + $settings_class[] = sanitize_text_field($_REQUEST['section']); |
|
391 | 391 | } |
392 | 392 | |
393 | - $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
393 | + $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
|
394 | 394 | } |
395 | 395 | |
396 | - if ( !empty( $settings_class ) ) { |
|
397 | - $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
396 | + if (!empty($settings_class)) { |
|
397 | + $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | $post_type = wpinv_admin_post_type(); |
401 | 401 | |
402 | - if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
402 | + if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
|
403 | 403 | return $classes .= ' wpinv'; |
404 | 404 | } |
405 | 405 | |
406 | - if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
406 | + if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
|
407 | 407 | $classes .= ' wpi-editable-n'; |
408 | 408 | } |
409 | 409 | |
@@ -415,21 +415,21 @@ discard block |
||
415 | 415 | } |
416 | 416 | |
417 | 417 | public function wpinv_actions() { |
418 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
419 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
418 | + if (isset($_REQUEST['wpi_action'])) { |
|
419 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
420 | 420 | } |
421 | 421 | } |
422 | 422 | |
423 | - public function pre_get_posts( $wp_query ) { |
|
424 | - if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
425 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
423 | + public function pre_get_posts($wp_query) { |
|
424 | + if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
425 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | return $wp_query; |
429 | 429 | } |
430 | 430 | |
431 | 431 | public function bp_invoicing_init() { |
432 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
432 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | /** |
@@ -437,11 +437,11 @@ discard block |
||
437 | 437 | * |
438 | 438 | */ |
439 | 439 | public function register_widgets() { |
440 | - register_widget( "WPInv_Checkout_Widget" ); |
|
441 | - register_widget( "WPInv_History_Widget" ); |
|
442 | - register_widget( "WPInv_Receipt_Widget" ); |
|
443 | - register_widget( "WPInv_Subscriptions_Widget" ); |
|
444 | - register_widget( "WPInv_Buy_Item_Widget" ); |
|
445 | - register_widget( "WPInv_Messages_Widget" ); |
|
440 | + register_widget("WPInv_Checkout_Widget"); |
|
441 | + register_widget("WPInv_History_Widget"); |
|
442 | + register_widget("WPInv_Receipt_Widget"); |
|
443 | + register_widget("WPInv_Subscriptions_Widget"); |
|
444 | + register_widget("WPInv_Buy_Item_Widget"); |
|
445 | + register_widget("WPInv_Messages_Widget"); |
|
446 | 446 | } |
447 | 447 | } |
448 | 448 | \ No newline at end of file |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | } |
701 | 701 | |
702 | 702 | function wpinv_get_php_arg_separator_output() { |
703 | - return ini_get( 'arg_separator.output' ); |
|
703 | + return ini_get( 'arg_separator.output' ); |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | function wpinv_rgb_from_hex( $color ) { |
@@ -1038,9 +1038,9 @@ discard block |
||
1038 | 1038 | * @return array Sanitized array of values. |
1039 | 1039 | */ |
1040 | 1040 | function wpinv_parse_list( $list ) { |
1041 | - if ( ! is_array( $list ) ) { |
|
1042 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
1043 | - } |
|
1041 | + if ( ! is_array( $list ) ) { |
|
1042 | + return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
1043 | + } |
|
1044 | 1044 | |
1045 | - return $list; |
|
1045 | + return $list; |
|
1046 | 1046 | } |
1047 | 1047 | \ No newline at end of file |
@@ -7,132 +7,132 @@ 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( $draft = false, $trashed = false, $invoice = false ) { |
|
92 | +function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) { |
|
93 | 93 | global $post; |
94 | 94 | |
95 | 95 | $invoice_statuses = array( |
96 | - 'wpi-pending' => __( 'Pending Payment', 'invoicing' ), |
|
97 | - 'publish' => __( 'Paid', 'invoicing'), |
|
98 | - 'wpi-processing' => __( 'Processing', 'invoicing' ), |
|
99 | - 'wpi-onhold' => __( 'On Hold', 'invoicing' ), |
|
100 | - 'wpi-refunded' => __( 'Refunded', 'invoicing' ), |
|
101 | - 'wpi-cancelled' => __( 'Cancelled', 'invoicing' ), |
|
102 | - 'wpi-failed' => __( 'Failed', 'invoicing' ), |
|
103 | - 'wpi-renewal' => __( 'Renewal Payment', 'invoicing' ) |
|
96 | + 'wpi-pending' => __('Pending Payment', 'invoicing'), |
|
97 | + 'publish' => __('Paid', 'invoicing'), |
|
98 | + 'wpi-processing' => __('Processing', 'invoicing'), |
|
99 | + 'wpi-onhold' => __('On Hold', 'invoicing'), |
|
100 | + 'wpi-refunded' => __('Refunded', 'invoicing'), |
|
101 | + 'wpi-cancelled' => __('Cancelled', 'invoicing'), |
|
102 | + 'wpi-failed' => __('Failed', 'invoicing'), |
|
103 | + 'wpi-renewal' => __('Renewal Payment', 'invoicing') |
|
104 | 104 | ); |
105 | 105 | |
106 | - if ( $draft ) { |
|
107 | - $invoice_statuses['draft'] = __( 'Draft', 'invoicing' ); |
|
106 | + if ($draft) { |
|
107 | + $invoice_statuses['draft'] = __('Draft', 'invoicing'); |
|
108 | 108 | } |
109 | 109 | |
110 | - if ( $trashed ) { |
|
111 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
110 | + if ($trashed) { |
|
111 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
112 | 112 | } |
113 | 113 | |
114 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
114 | + return apply_filters('wpinv_statuses', $invoice_statuses, $invoice); |
|
115 | 115 | } |
116 | 116 | |
117 | -function wpinv_status_nicename( $status ) { |
|
118 | - $statuses = wpinv_get_invoice_statuses( true, true ); |
|
119 | - $status = isset( $statuses[$status] ) ? $statuses[$status] : __( $status, 'invoicing' ); |
|
117 | +function wpinv_status_nicename($status) { |
|
118 | + $statuses = wpinv_get_invoice_statuses(true, true); |
|
119 | + $status = isset($statuses[$status]) ? $statuses[$status] : __($status, 'invoicing'); |
|
120 | 120 | |
121 | 121 | return $status; |
122 | 122 | } |
123 | 123 | |
124 | 124 | function wpinv_get_currency() { |
125 | - $currency = wpinv_get_option( 'currency', 'USD' ); |
|
125 | + $currency = wpinv_get_option('currency', 'USD'); |
|
126 | 126 | |
127 | - return apply_filters( 'wpinv_currency', $currency ); |
|
127 | + return apply_filters('wpinv_currency', $currency); |
|
128 | 128 | } |
129 | 129 | |
130 | -function wpinv_currency_symbol( $currency = '' ) { |
|
131 | - if ( empty( $currency ) ) { |
|
130 | +function wpinv_currency_symbol($currency = '') { |
|
131 | + if (empty($currency)) { |
|
132 | 132 | $currency = wpinv_get_currency(); |
133 | 133 | } |
134 | 134 | |
135 | - $symbols = apply_filters( 'wpinv_currency_symbols', array( |
|
135 | + $symbols = apply_filters('wpinv_currency_symbols', array( |
|
136 | 136 | 'AED' => 'د.إ', |
137 | 137 | 'AFN' => '؋', |
138 | 138 | 'ALL' => 'L', |
@@ -295,209 +295,209 @@ discard block |
||
295 | 295 | 'YER' => '﷼', |
296 | 296 | 'ZAR' => 'R', |
297 | 297 | 'ZMW' => 'ZK', |
298 | - ) ); |
|
298 | + )); |
|
299 | 299 | |
300 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency; |
|
300 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
301 | 301 | |
302 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
302 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | function wpinv_currency_position() { |
306 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
306 | + $position = wpinv_get_option('currency_position', 'left'); |
|
307 | 307 | |
308 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
308 | + return apply_filters('wpinv_currency_position', $position); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | function wpinv_thousands_separator() { |
312 | - $thousand_sep = wpinv_get_option( 'thousands_separator', ',' ); |
|
312 | + $thousand_sep = wpinv_get_option('thousands_separator', ','); |
|
313 | 313 | |
314 | - return apply_filters( 'wpinv_thousands_separator', $thousand_sep ); |
|
314 | + return apply_filters('wpinv_thousands_separator', $thousand_sep); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | function wpinv_decimal_separator() { |
318 | - $decimal_sep = wpinv_get_option( 'decimal_separator', '.' ); |
|
318 | + $decimal_sep = wpinv_get_option('decimal_separator', '.'); |
|
319 | 319 | |
320 | - return apply_filters( 'wpinv_decimal_separator', $decimal_sep ); |
|
320 | + return apply_filters('wpinv_decimal_separator', $decimal_sep); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | function wpinv_decimals() { |
324 | - $decimals = apply_filters( 'wpinv_decimals', wpinv_get_option( 'decimals', 2 ) ); |
|
324 | + $decimals = apply_filters('wpinv_decimals', wpinv_get_option('decimals', 2)); |
|
325 | 325 | |
326 | - return absint( $decimals ); |
|
326 | + return absint($decimals); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | function wpinv_get_currencies() { |
330 | 330 | $currencies = array( |
331 | - 'USD' => __( 'US Dollar', 'invoicing' ), |
|
332 | - 'EUR' => __( 'Euro', 'invoicing' ), |
|
333 | - 'GBP' => __( 'Pound Sterling', 'invoicing' ), |
|
334 | - 'AED' => __( 'United Arab Emirates', 'invoicing' ), |
|
335 | - 'AFN' => __( 'Afghan Afghani', 'invoicing' ), |
|
336 | - 'ALL' => __( 'Albanian Lek', 'invoicing' ), |
|
337 | - 'AMD' => __( 'Armenian Dram', 'invoicing' ), |
|
338 | - 'ANG' => __( 'Netherlands Antillean Guilder', 'invoicing' ), |
|
339 | - 'AOA' => __( 'Angolan Kwanza', 'invoicing' ), |
|
340 | - 'ARS' => __( 'Argentine Peso', 'invoicing' ), |
|
341 | - 'AUD' => __( 'Australian Dollar', 'invoicing' ), |
|
342 | - 'AWG' => __( 'Aruban Florin', 'invoicing' ), |
|
343 | - 'AZN' => __( 'Azerbaijani Manat', 'invoicing' ), |
|
344 | - 'BAM' => __( 'Bosnia and Herzegovina Convertible Marka', 'invoicing' ), |
|
345 | - 'BBD' => __( 'Barbadian Dollar', 'invoicing' ), |
|
346 | - 'BDT' => __( 'Bangladeshi Taka', 'invoicing' ), |
|
347 | - 'BGN' => __( 'Bulgarian Lev', 'invoicing' ), |
|
348 | - 'BHD' => __( 'Bahraini Dinar', 'invoicing' ), |
|
349 | - 'BIF' => __( 'Burundian Franc', 'invoicing' ), |
|
350 | - 'BMD' => __( 'Bermudian Dollar', 'invoicing' ), |
|
351 | - 'BND' => __( 'Brunei Dollar', 'invoicing' ), |
|
352 | - 'BOB' => __( 'Bolivian Boliviano', 'invoicing' ), |
|
353 | - 'BRL' => __( 'Brazilian Real', 'invoicing' ), |
|
354 | - 'BSD' => __( 'Bahamian Dollar', 'invoicing' ), |
|
355 | - 'BTC' => __( 'Bitcoin', 'invoicing' ), |
|
356 | - 'BTN' => __( 'Bhutanese Ngultrum', 'invoicing' ), |
|
357 | - 'BWP' => __( 'Botswana Pula', 'invoicing' ), |
|
358 | - 'BYN' => __( 'Belarusian Ruble', 'invoicing' ), |
|
359 | - 'BZD' => __( 'Belize Dollar', 'invoicing' ), |
|
360 | - 'CAD' => __( 'Canadian Dollar', 'invoicing' ), |
|
361 | - 'CDF' => __( 'Congolese Franc', 'invoicing' ), |
|
362 | - 'CHF' => __( 'Swiss Franc', 'invoicing' ), |
|
363 | - 'CLP' => __( 'Chilean Peso', 'invoicing' ), |
|
364 | - 'CNY' => __( 'Chinese Yuan', 'invoicing' ), |
|
365 | - 'COP' => __( 'Colombian Peso', 'invoicing' ), |
|
366 | - 'CRC' => __( 'Costa Rican Colon', 'invoicing' ), |
|
367 | - 'CUC' => __( 'Cuban Convertible Peso', 'invoicing' ), |
|
368 | - 'CUP' => __( 'Cuban Peso', 'invoicing' ), |
|
369 | - 'CVE' => __( 'Cape Verdean escudo', 'invoicing' ), |
|
370 | - 'CZK' => __( 'Czech Koruna', 'invoicing' ), |
|
371 | - 'DJF' => __( 'Djiboutian Franc', 'invoicing' ), |
|
372 | - 'DKK' => __( 'Danish Krone', 'invoicing' ), |
|
373 | - 'DOP' => __( 'Dominican Peso', 'invoicing' ), |
|
374 | - 'DZD' => __( 'Algerian Dinar', 'invoicing' ), |
|
375 | - 'EGP' => __( 'Egyptian Pound', 'invoicing' ), |
|
376 | - 'ERN' => __( 'Eritrean Nakfa', 'invoicing' ), |
|
377 | - 'ETB' => __( 'Ethiopian Irr', 'invoicing' ), |
|
378 | - 'FJD' => __( 'Fijian Dollar', 'invoicing' ), |
|
379 | - 'FKP' => __( 'Falkland Islands Pound', 'invoicing' ), |
|
380 | - 'GEL' => __( 'Georgian Lari', 'invoicing' ), |
|
381 | - 'GGP' => __( 'Guernsey Pound', 'invoicing' ), |
|
382 | - 'GHS' => __( 'Ghana Cedi', 'invoicing' ), |
|
383 | - 'GIP' => __( 'Gibraltar Pound', 'invoicing' ), |
|
384 | - 'GMD' => __( 'Gambian Dalasi', 'invoicing' ), |
|
385 | - 'GNF' => __( 'Guinean Franc', 'invoicing' ), |
|
386 | - 'GTQ' => __( 'Guatemalan Quetzal', 'invoicing' ), |
|
387 | - 'GYD' => __( 'Guyanese Dollar', 'invoicing' ), |
|
388 | - 'HKD' => __( 'Hong Kong Dollar', 'invoicing' ), |
|
389 | - 'HNL' => __( 'Honduran Lempira', 'invoicing' ), |
|
390 | - 'HRK' => __( 'Croatian Kuna', 'invoicing' ), |
|
391 | - 'HTG' => __( 'Haitian Gourde', 'invoicing' ), |
|
392 | - 'HUF' => __( 'Hungarian Forint', 'invoicing' ), |
|
393 | - 'IDR' => __( 'Indonesian Rupiah', 'invoicing' ), |
|
394 | - 'ILS' => __( 'Israeli New Shekel', 'invoicing' ), |
|
395 | - 'IMP' => __( 'Manx Pound', 'invoicing' ), |
|
396 | - 'INR' => __( 'Indian Rupee', 'invoicing' ), |
|
397 | - 'IQD' => __( 'Iraqi Dinar', 'invoicing' ), |
|
398 | - 'IRR' => __( 'Iranian Rial', 'invoicing' ), |
|
399 | - 'IRT' => __( 'Iranian Toman', 'invoicing' ), |
|
400 | - 'ISK' => __( 'Icelandic Krona', 'invoicing' ), |
|
401 | - 'JEP' => __( 'Jersey Pound', 'invoicing' ), |
|
402 | - 'JMD' => __( 'Jamaican Dollar', 'invoicing' ), |
|
403 | - 'JOD' => __( 'Jordanian Dinar', 'invoicing' ), |
|
404 | - 'JPY' => __( 'Japanese Yen', 'invoicing' ), |
|
405 | - 'KES' => __( 'Kenyan Shilling', 'invoicing' ), |
|
406 | - 'KGS' => __( 'Kyrgyzstani Som', 'invoicing' ), |
|
407 | - 'KHR' => __( 'Cambodian Riel', 'invoicing' ), |
|
408 | - 'KMF' => __( 'Comorian Franc', 'invoicing' ), |
|
409 | - 'KPW' => __( 'North Korean Won', 'invoicing' ), |
|
410 | - 'KRW' => __( 'South Korean Won', 'invoicing' ), |
|
411 | - 'KWD' => __( 'Kuwaiti Dinar', 'invoicing' ), |
|
412 | - 'KYD' => __( 'Cayman Islands Dollar', 'invoicing' ), |
|
413 | - 'KZT' => __( 'Kazakhstani Tenge', 'invoicing' ), |
|
414 | - 'LAK' => __( 'Lao Kip', 'invoicing' ), |
|
415 | - 'LBP' => __( 'Lebanese Pound', 'invoicing' ), |
|
416 | - 'LKR' => __( 'Sri Lankan Rupee', 'invoicing' ), |
|
417 | - 'LRD' => __( 'Liberian Dollar', 'invoicing' ), |
|
418 | - 'LSL' => __( 'Lesotho Loti', 'invoicing' ), |
|
419 | - 'LYD' => __( 'Libyan Dinar', 'invoicing' ), |
|
420 | - 'MAD' => __( 'Moroccan Dirham', 'invoicing' ), |
|
421 | - 'MDL' => __( 'Moldovan Leu', 'invoicing' ), |
|
422 | - 'MGA' => __( 'Malagasy Ariary', 'invoicing' ), |
|
423 | - 'MKD' => __( 'Macedonian Denar', 'invoicing' ), |
|
424 | - 'MMK' => __( 'Burmese Kyat', 'invoicing' ), |
|
425 | - 'MNT' => __( 'Mongolian Tughrik', 'invoicing' ), |
|
426 | - 'MOP' => __( 'Macanese Pataca', 'invoicing' ), |
|
427 | - 'MRO' => __( 'Mauritanian Ouguiya', 'invoicing' ), |
|
428 | - 'MUR' => __( 'Mauritian Rupee', 'invoicing' ), |
|
429 | - 'MVR' => __( 'Maldivian Rufiyaa', 'invoicing' ), |
|
430 | - 'MWK' => __( 'Malawian Kwacha', 'invoicing' ), |
|
431 | - 'MXN' => __( 'Mexican Peso', 'invoicing' ), |
|
432 | - 'MYR' => __( 'Malaysian Ringgit', 'invoicing' ), |
|
433 | - 'MZN' => __( 'Mozambican Metical', 'invoicing' ), |
|
434 | - 'NAD' => __( 'Namibian Dollar', 'invoicing' ), |
|
435 | - 'NGN' => __( 'Nigerian Naira', 'invoicing' ), |
|
436 | - 'NIO' => __( 'Nicaraguan Cordoba', 'invoicing' ), |
|
437 | - 'NOK' => __( 'Norwegian Krone', 'invoicing' ), |
|
438 | - 'NPR' => __( 'Nepalese Rupee', 'invoicing' ), |
|
439 | - 'NZD' => __( 'New Zealand Dollar', 'invoicing' ), |
|
440 | - 'OMR' => __( 'Omani Rial', 'invoicing' ), |
|
441 | - 'PAB' => __( 'Panamanian Balboa', 'invoicing' ), |
|
442 | - 'PEN' => __( 'Peruvian Nuevo Sol', 'invoicing' ), |
|
443 | - 'PGK' => __( 'Papua New Guinean Kina', 'invoicing' ), |
|
444 | - 'PHP' => __( 'Philippine Peso', 'invoicing' ), |
|
445 | - 'PKR' => __( 'Pakistani Rupee', 'invoicing' ), |
|
446 | - 'PLN' => __( 'Polish Zloty', 'invoicing' ), |
|
447 | - 'PRB' => __( 'Transnistrian Ruble', 'invoicing' ), |
|
448 | - 'PYG' => __( 'Paraguayan Guarani', 'invoicing' ), |
|
449 | - 'QAR' => __( 'Qatari Riyal', 'invoicing' ), |
|
450 | - 'RON' => __( 'Romanian Leu', 'invoicing' ), |
|
451 | - 'RSD' => __( 'Serbian Dinar', 'invoicing' ), |
|
452 | - 'RUB' => __( 'Russian Ruble', 'invoicing' ), |
|
453 | - 'RWF' => __( 'Rwandan Franc', 'invoicing' ), |
|
454 | - 'SAR' => __( 'Saudi Riyal', 'invoicing' ), |
|
455 | - 'SBD' => __( 'Solomon Islands Dollar', 'invoicing' ), |
|
456 | - 'SCR' => __( 'Seychellois Rupee', 'invoicing' ), |
|
457 | - 'SDG' => __( 'Sudanese Pound', 'invoicing' ), |
|
458 | - 'SEK' => __( 'Swedish Krona', 'invoicing' ), |
|
459 | - 'SGD' => __( 'Singapore Dollar', 'invoicing' ), |
|
460 | - 'SHP' => __( 'Saint Helena Pound', 'invoicing' ), |
|
461 | - 'SLL' => __( 'Sierra Leonean Leone', 'invoicing' ), |
|
462 | - 'SOS' => __( 'Somali Shilling', 'invoicing' ), |
|
463 | - 'SRD' => __( 'Surinamese Dollar', 'invoicing' ), |
|
464 | - 'SSP' => __( 'South Sudanese Pound', 'invoicing' ), |
|
465 | - 'STD' => __( 'Sao Tomean Dobra', 'invoicing' ), |
|
466 | - 'SYP' => __( 'Syrian Pound', 'invoicing' ), |
|
467 | - 'SZL' => __( 'Swazi Lilangeni', 'invoicing' ), |
|
468 | - 'THB' => __( 'Thai Baht', 'invoicing' ), |
|
469 | - 'TJS' => __( 'Tajikistani Somoni', 'invoicing' ), |
|
470 | - 'TMT' => __( 'Turkmenistan Manat', 'invoicing' ), |
|
471 | - 'TND' => __( 'Tunisian Dinar', 'invoicing' ), |
|
472 | - 'TOP' => __( 'Tongan Paʻanga', 'invoicing' ), |
|
473 | - 'TRY' => __( 'Turkish Lira', 'invoicing' ), |
|
474 | - 'TTD' => __( 'Trinidad and Tobago Dollar', 'invoicing' ), |
|
475 | - 'TWD' => __( 'New Taiwan Dollar', 'invoicing' ), |
|
476 | - 'TZS' => __( 'Tanzanian Shilling', 'invoicing' ), |
|
477 | - 'UAH' => __( 'Ukrainian Hryvnia', 'invoicing' ), |
|
478 | - 'UGX' => __( 'Ugandan Shilling', 'invoicing' ), |
|
479 | - 'UYU' => __( 'Uruguayan Peso', 'invoicing' ), |
|
480 | - 'UZS' => __( 'Uzbekistani Som', 'invoicing' ), |
|
481 | - 'VEF' => __( 'Venezuelan Bolívar', 'invoicing' ), |
|
482 | - 'VND' => __( 'Vietnamese Dong', 'invoicing' ), |
|
483 | - 'VUV' => __( 'Vanuatu Vatu', 'invoicing' ), |
|
484 | - 'WST' => __( 'Samoan Tala', 'invoicing' ), |
|
485 | - 'XAF' => __( 'Central African CFA Franc', 'invoicing' ), |
|
486 | - 'XCD' => __( 'East Caribbean Dollar', 'invoicing' ), |
|
487 | - 'XOF' => __( 'West African CFA Franc', 'invoicing' ), |
|
488 | - 'XPF' => __( 'CFP Franc', 'invoicing' ), |
|
489 | - 'YER' => __( 'Yemeni Rial', 'invoicing' ), |
|
490 | - 'ZAR' => __( 'South African Rand', 'invoicing' ), |
|
491 | - 'ZMW' => __( 'Zambian Kwacha', 'invoicing' ), |
|
331 | + 'USD' => __('US Dollar', 'invoicing'), |
|
332 | + 'EUR' => __('Euro', 'invoicing'), |
|
333 | + 'GBP' => __('Pound Sterling', 'invoicing'), |
|
334 | + 'AED' => __('United Arab Emirates', 'invoicing'), |
|
335 | + 'AFN' => __('Afghan Afghani', 'invoicing'), |
|
336 | + 'ALL' => __('Albanian Lek', 'invoicing'), |
|
337 | + 'AMD' => __('Armenian Dram', 'invoicing'), |
|
338 | + 'ANG' => __('Netherlands Antillean Guilder', 'invoicing'), |
|
339 | + 'AOA' => __('Angolan Kwanza', 'invoicing'), |
|
340 | + 'ARS' => __('Argentine Peso', 'invoicing'), |
|
341 | + 'AUD' => __('Australian Dollar', 'invoicing'), |
|
342 | + 'AWG' => __('Aruban Florin', 'invoicing'), |
|
343 | + 'AZN' => __('Azerbaijani Manat', 'invoicing'), |
|
344 | + 'BAM' => __('Bosnia and Herzegovina Convertible Marka', 'invoicing'), |
|
345 | + 'BBD' => __('Barbadian Dollar', 'invoicing'), |
|
346 | + 'BDT' => __('Bangladeshi Taka', 'invoicing'), |
|
347 | + 'BGN' => __('Bulgarian Lev', 'invoicing'), |
|
348 | + 'BHD' => __('Bahraini Dinar', 'invoicing'), |
|
349 | + 'BIF' => __('Burundian Franc', 'invoicing'), |
|
350 | + 'BMD' => __('Bermudian Dollar', 'invoicing'), |
|
351 | + 'BND' => __('Brunei Dollar', 'invoicing'), |
|
352 | + 'BOB' => __('Bolivian Boliviano', 'invoicing'), |
|
353 | + 'BRL' => __('Brazilian Real', 'invoicing'), |
|
354 | + 'BSD' => __('Bahamian Dollar', 'invoicing'), |
|
355 | + 'BTC' => __('Bitcoin', 'invoicing'), |
|
356 | + 'BTN' => __('Bhutanese Ngultrum', 'invoicing'), |
|
357 | + 'BWP' => __('Botswana Pula', 'invoicing'), |
|
358 | + 'BYN' => __('Belarusian Ruble', 'invoicing'), |
|
359 | + 'BZD' => __('Belize Dollar', 'invoicing'), |
|
360 | + 'CAD' => __('Canadian Dollar', 'invoicing'), |
|
361 | + 'CDF' => __('Congolese Franc', 'invoicing'), |
|
362 | + 'CHF' => __('Swiss Franc', 'invoicing'), |
|
363 | + 'CLP' => __('Chilean Peso', 'invoicing'), |
|
364 | + 'CNY' => __('Chinese Yuan', 'invoicing'), |
|
365 | + 'COP' => __('Colombian Peso', 'invoicing'), |
|
366 | + 'CRC' => __('Costa Rican Colon', 'invoicing'), |
|
367 | + 'CUC' => __('Cuban Convertible Peso', 'invoicing'), |
|
368 | + 'CUP' => __('Cuban Peso', 'invoicing'), |
|
369 | + 'CVE' => __('Cape Verdean escudo', 'invoicing'), |
|
370 | + 'CZK' => __('Czech Koruna', 'invoicing'), |
|
371 | + 'DJF' => __('Djiboutian Franc', 'invoicing'), |
|
372 | + 'DKK' => __('Danish Krone', 'invoicing'), |
|
373 | + 'DOP' => __('Dominican Peso', 'invoicing'), |
|
374 | + 'DZD' => __('Algerian Dinar', 'invoicing'), |
|
375 | + 'EGP' => __('Egyptian Pound', 'invoicing'), |
|
376 | + 'ERN' => __('Eritrean Nakfa', 'invoicing'), |
|
377 | + 'ETB' => __('Ethiopian Irr', 'invoicing'), |
|
378 | + 'FJD' => __('Fijian Dollar', 'invoicing'), |
|
379 | + 'FKP' => __('Falkland Islands Pound', 'invoicing'), |
|
380 | + 'GEL' => __('Georgian Lari', 'invoicing'), |
|
381 | + 'GGP' => __('Guernsey Pound', 'invoicing'), |
|
382 | + 'GHS' => __('Ghana Cedi', 'invoicing'), |
|
383 | + 'GIP' => __('Gibraltar Pound', 'invoicing'), |
|
384 | + 'GMD' => __('Gambian Dalasi', 'invoicing'), |
|
385 | + 'GNF' => __('Guinean Franc', 'invoicing'), |
|
386 | + 'GTQ' => __('Guatemalan Quetzal', 'invoicing'), |
|
387 | + 'GYD' => __('Guyanese Dollar', 'invoicing'), |
|
388 | + 'HKD' => __('Hong Kong Dollar', 'invoicing'), |
|
389 | + 'HNL' => __('Honduran Lempira', 'invoicing'), |
|
390 | + 'HRK' => __('Croatian Kuna', 'invoicing'), |
|
391 | + 'HTG' => __('Haitian Gourde', 'invoicing'), |
|
392 | + 'HUF' => __('Hungarian Forint', 'invoicing'), |
|
393 | + 'IDR' => __('Indonesian Rupiah', 'invoicing'), |
|
394 | + 'ILS' => __('Israeli New Shekel', 'invoicing'), |
|
395 | + 'IMP' => __('Manx Pound', 'invoicing'), |
|
396 | + 'INR' => __('Indian Rupee', 'invoicing'), |
|
397 | + 'IQD' => __('Iraqi Dinar', 'invoicing'), |
|
398 | + 'IRR' => __('Iranian Rial', 'invoicing'), |
|
399 | + 'IRT' => __('Iranian Toman', 'invoicing'), |
|
400 | + 'ISK' => __('Icelandic Krona', 'invoicing'), |
|
401 | + 'JEP' => __('Jersey Pound', 'invoicing'), |
|
402 | + 'JMD' => __('Jamaican Dollar', 'invoicing'), |
|
403 | + 'JOD' => __('Jordanian Dinar', 'invoicing'), |
|
404 | + 'JPY' => __('Japanese Yen', 'invoicing'), |
|
405 | + 'KES' => __('Kenyan Shilling', 'invoicing'), |
|
406 | + 'KGS' => __('Kyrgyzstani Som', 'invoicing'), |
|
407 | + 'KHR' => __('Cambodian Riel', 'invoicing'), |
|
408 | + 'KMF' => __('Comorian Franc', 'invoicing'), |
|
409 | + 'KPW' => __('North Korean Won', 'invoicing'), |
|
410 | + 'KRW' => __('South Korean Won', 'invoicing'), |
|
411 | + 'KWD' => __('Kuwaiti Dinar', 'invoicing'), |
|
412 | + 'KYD' => __('Cayman Islands Dollar', 'invoicing'), |
|
413 | + 'KZT' => __('Kazakhstani Tenge', 'invoicing'), |
|
414 | + 'LAK' => __('Lao Kip', 'invoicing'), |
|
415 | + 'LBP' => __('Lebanese Pound', 'invoicing'), |
|
416 | + 'LKR' => __('Sri Lankan Rupee', 'invoicing'), |
|
417 | + 'LRD' => __('Liberian Dollar', 'invoicing'), |
|
418 | + 'LSL' => __('Lesotho Loti', 'invoicing'), |
|
419 | + 'LYD' => __('Libyan Dinar', 'invoicing'), |
|
420 | + 'MAD' => __('Moroccan Dirham', 'invoicing'), |
|
421 | + 'MDL' => __('Moldovan Leu', 'invoicing'), |
|
422 | + 'MGA' => __('Malagasy Ariary', 'invoicing'), |
|
423 | + 'MKD' => __('Macedonian Denar', 'invoicing'), |
|
424 | + 'MMK' => __('Burmese Kyat', 'invoicing'), |
|
425 | + 'MNT' => __('Mongolian Tughrik', 'invoicing'), |
|
426 | + 'MOP' => __('Macanese Pataca', 'invoicing'), |
|
427 | + 'MRO' => __('Mauritanian Ouguiya', 'invoicing'), |
|
428 | + 'MUR' => __('Mauritian Rupee', 'invoicing'), |
|
429 | + 'MVR' => __('Maldivian Rufiyaa', 'invoicing'), |
|
430 | + 'MWK' => __('Malawian Kwacha', 'invoicing'), |
|
431 | + 'MXN' => __('Mexican Peso', 'invoicing'), |
|
432 | + 'MYR' => __('Malaysian Ringgit', 'invoicing'), |
|
433 | + 'MZN' => __('Mozambican Metical', 'invoicing'), |
|
434 | + 'NAD' => __('Namibian Dollar', 'invoicing'), |
|
435 | + 'NGN' => __('Nigerian Naira', 'invoicing'), |
|
436 | + 'NIO' => __('Nicaraguan Cordoba', 'invoicing'), |
|
437 | + 'NOK' => __('Norwegian Krone', 'invoicing'), |
|
438 | + 'NPR' => __('Nepalese Rupee', 'invoicing'), |
|
439 | + 'NZD' => __('New Zealand Dollar', 'invoicing'), |
|
440 | + 'OMR' => __('Omani Rial', 'invoicing'), |
|
441 | + 'PAB' => __('Panamanian Balboa', 'invoicing'), |
|
442 | + 'PEN' => __('Peruvian Nuevo Sol', 'invoicing'), |
|
443 | + 'PGK' => __('Papua New Guinean Kina', 'invoicing'), |
|
444 | + 'PHP' => __('Philippine Peso', 'invoicing'), |
|
445 | + 'PKR' => __('Pakistani Rupee', 'invoicing'), |
|
446 | + 'PLN' => __('Polish Zloty', 'invoicing'), |
|
447 | + 'PRB' => __('Transnistrian Ruble', 'invoicing'), |
|
448 | + 'PYG' => __('Paraguayan Guarani', 'invoicing'), |
|
449 | + 'QAR' => __('Qatari Riyal', 'invoicing'), |
|
450 | + 'RON' => __('Romanian Leu', 'invoicing'), |
|
451 | + 'RSD' => __('Serbian Dinar', 'invoicing'), |
|
452 | + 'RUB' => __('Russian Ruble', 'invoicing'), |
|
453 | + 'RWF' => __('Rwandan Franc', 'invoicing'), |
|
454 | + 'SAR' => __('Saudi Riyal', 'invoicing'), |
|
455 | + 'SBD' => __('Solomon Islands Dollar', 'invoicing'), |
|
456 | + 'SCR' => __('Seychellois Rupee', 'invoicing'), |
|
457 | + 'SDG' => __('Sudanese Pound', 'invoicing'), |
|
458 | + 'SEK' => __('Swedish Krona', 'invoicing'), |
|
459 | + 'SGD' => __('Singapore Dollar', 'invoicing'), |
|
460 | + 'SHP' => __('Saint Helena Pound', 'invoicing'), |
|
461 | + 'SLL' => __('Sierra Leonean Leone', 'invoicing'), |
|
462 | + 'SOS' => __('Somali Shilling', 'invoicing'), |
|
463 | + 'SRD' => __('Surinamese Dollar', 'invoicing'), |
|
464 | + 'SSP' => __('South Sudanese Pound', 'invoicing'), |
|
465 | + 'STD' => __('Sao Tomean Dobra', 'invoicing'), |
|
466 | + 'SYP' => __('Syrian Pound', 'invoicing'), |
|
467 | + 'SZL' => __('Swazi Lilangeni', 'invoicing'), |
|
468 | + 'THB' => __('Thai Baht', 'invoicing'), |
|
469 | + 'TJS' => __('Tajikistani Somoni', 'invoicing'), |
|
470 | + 'TMT' => __('Turkmenistan Manat', 'invoicing'), |
|
471 | + 'TND' => __('Tunisian Dinar', 'invoicing'), |
|
472 | + 'TOP' => __('Tongan Paʻanga', 'invoicing'), |
|
473 | + 'TRY' => __('Turkish Lira', 'invoicing'), |
|
474 | + 'TTD' => __('Trinidad and Tobago Dollar', 'invoicing'), |
|
475 | + 'TWD' => __('New Taiwan Dollar', 'invoicing'), |
|
476 | + 'TZS' => __('Tanzanian Shilling', 'invoicing'), |
|
477 | + 'UAH' => __('Ukrainian Hryvnia', 'invoicing'), |
|
478 | + 'UGX' => __('Ugandan Shilling', 'invoicing'), |
|
479 | + 'UYU' => __('Uruguayan Peso', 'invoicing'), |
|
480 | + 'UZS' => __('Uzbekistani Som', 'invoicing'), |
|
481 | + 'VEF' => __('Venezuelan Bolívar', 'invoicing'), |
|
482 | + 'VND' => __('Vietnamese Dong', 'invoicing'), |
|
483 | + 'VUV' => __('Vanuatu Vatu', 'invoicing'), |
|
484 | + 'WST' => __('Samoan Tala', 'invoicing'), |
|
485 | + 'XAF' => __('Central African CFA Franc', 'invoicing'), |
|
486 | + 'XCD' => __('East Caribbean Dollar', 'invoicing'), |
|
487 | + 'XOF' => __('West African CFA Franc', 'invoicing'), |
|
488 | + 'XPF' => __('CFP Franc', 'invoicing'), |
|
489 | + 'YER' => __('Yemeni Rial', 'invoicing'), |
|
490 | + 'ZAR' => __('South African Rand', 'invoicing'), |
|
491 | + 'ZMW' => __('Zambian Kwacha', 'invoicing'), |
|
492 | 492 | ); |
493 | 493 | |
494 | 494 | //asort( $currencies ); // this |
495 | 495 | |
496 | - return apply_filters( 'wpinv_currencies', $currencies ); |
|
496 | + return apply_filters('wpinv_currencies', $currencies); |
|
497 | 497 | } |
498 | 498 | |
499 | -function wpinv_price( $amount = '', $currency = '' ) { |
|
500 | - if( empty( $currency ) ) { |
|
499 | +function wpinv_price($amount = '', $currency = '') { |
|
500 | + if (empty($currency)) { |
|
501 | 501 | $currency = wpinv_get_currency(); |
502 | 502 | } |
503 | 503 | |
@@ -505,14 +505,14 @@ discard block |
||
505 | 505 | |
506 | 506 | $negative = $amount < 0; |
507 | 507 | |
508 | - if ( $negative ) { |
|
509 | - $amount = substr( $amount, 1 ); |
|
508 | + if ($negative) { |
|
509 | + $amount = substr($amount, 1); |
|
510 | 510 | } |
511 | 511 | |
512 | - $symbol = wpinv_currency_symbol( $currency ); |
|
512 | + $symbol = wpinv_currency_symbol($currency); |
|
513 | 513 | |
514 | - if ( $position == 'left' || $position == 'left_space' ) { |
|
515 | - switch ( $currency ) { |
|
514 | + if ($position == 'left' || $position == 'left_space') { |
|
515 | + switch ($currency) { |
|
516 | 516 | case "GBP" : |
517 | 517 | case "BRL" : |
518 | 518 | case "EUR" : |
@@ -524,15 +524,15 @@ discard block |
||
524 | 524 | case "NZD" : |
525 | 525 | case "SGD" : |
526 | 526 | case "JPY" : |
527 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
527 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
528 | 528 | break; |
529 | 529 | default : |
530 | 530 | //$price = $currency . ' ' . $amount; |
531 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
531 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
532 | 532 | break; |
533 | 533 | } |
534 | 534 | } else { |
535 | - switch ( $currency ) { |
|
535 | + switch ($currency) { |
|
536 | 536 | case "GBP" : |
537 | 537 | case "BRL" : |
538 | 538 | case "EUR" : |
@@ -543,83 +543,83 @@ discard block |
||
543 | 543 | case "MXN" : |
544 | 544 | case "SGD" : |
545 | 545 | case "JPY" : |
546 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
546 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
547 | 547 | break; |
548 | 548 | default : |
549 | 549 | //$price = $amount . ' ' . $currency; |
550 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
550 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
551 | 551 | break; |
552 | 552 | } |
553 | 553 | } |
554 | 554 | |
555 | - if ( $negative ) { |
|
555 | + if ($negative) { |
|
556 | 556 | $price = '-' . $price; |
557 | 557 | } |
558 | 558 | |
559 | - $price = apply_filters( 'wpinv_' . strtolower( $currency ) . '_currency_filter_' . $position, $price, $currency, $amount ); |
|
559 | + $price = apply_filters('wpinv_' . strtolower($currency) . '_currency_filter_' . $position, $price, $currency, $amount); |
|
560 | 560 | |
561 | 561 | return $price; |
562 | 562 | } |
563 | 563 | |
564 | -function wpinv_format_amount( $amount, $decimals = NULL, $calculate = false ) { |
|
564 | +function wpinv_format_amount($amount, $decimals = NULL, $calculate = false) { |
|
565 | 565 | $thousands_sep = wpinv_thousands_separator(); |
566 | 566 | $decimal_sep = wpinv_decimal_separator(); |
567 | 567 | |
568 | - if ( $decimals === NULL ) { |
|
568 | + if ($decimals === NULL) { |
|
569 | 569 | $decimals = wpinv_decimals(); |
570 | 570 | } |
571 | 571 | |
572 | - if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) { |
|
573 | - $whole = substr( $amount, 0, $sep_found ); |
|
574 | - $part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) ); |
|
572 | + if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) { |
|
573 | + $whole = substr($amount, 0, $sep_found); |
|
574 | + $part = substr($amount, $sep_found + 1, (strlen($amount) - 1)); |
|
575 | 575 | $amount = $whole . '.' . $part; |
576 | 576 | } |
577 | 577 | |
578 | - if ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
579 | - $amount = str_replace( ',', '', $amount ); |
|
578 | + if ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
579 | + $amount = str_replace(',', '', $amount); |
|
580 | 580 | } |
581 | 581 | |
582 | - if ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
583 | - $amount = str_replace( ' ', '', $amount ); |
|
582 | + if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
583 | + $amount = str_replace(' ', '', $amount); |
|
584 | 584 | } |
585 | 585 | |
586 | - if ( empty( $amount ) ) { |
|
586 | + if (empty($amount)) { |
|
587 | 587 | $amount = 0; |
588 | 588 | } |
589 | 589 | |
590 | - $decimals = apply_filters( 'wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate ); |
|
591 | - $formatted = number_format( (float)$amount, $decimals, $decimal_sep, $thousands_sep ); |
|
590 | + $decimals = apply_filters('wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate); |
|
591 | + $formatted = number_format((float) $amount, $decimals, $decimal_sep, $thousands_sep); |
|
592 | 592 | |
593 | - if ( $calculate ) { |
|
594 | - if ( $thousands_sep === "," ) { |
|
595 | - $formatted = str_replace( ",", "", $formatted ); |
|
593 | + if ($calculate) { |
|
594 | + if ($thousands_sep === ",") { |
|
595 | + $formatted = str_replace(",", "", $formatted); |
|
596 | 596 | } |
597 | 597 | |
598 | - if ( $decimal_sep === "," ) { |
|
599 | - $formatted = str_replace( ",", ".", $formatted ); |
|
598 | + if ($decimal_sep === ",") { |
|
599 | + $formatted = str_replace(",", ".", $formatted); |
|
600 | 600 | } |
601 | 601 | } |
602 | 602 | |
603 | - return apply_filters( 'wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate ); |
|
603 | + return apply_filters('wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate); |
|
604 | 604 | } |
605 | -add_filter( 'wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1 ); |
|
605 | +add_filter('wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1); |
|
606 | 606 | |
607 | -function wpinv_sanitize_key( $key ) { |
|
607 | +function wpinv_sanitize_key($key) { |
|
608 | 608 | $raw_key = $key; |
609 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
609 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
610 | 610 | |
611 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
611 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
612 | 612 | } |
613 | 613 | |
614 | -function wpinv_get_file_extension( $str ) { |
|
615 | - $parts = explode( '.', $str ); |
|
616 | - return end( $parts ); |
|
614 | +function wpinv_get_file_extension($str) { |
|
615 | + $parts = explode('.', $str); |
|
616 | + return end($parts); |
|
617 | 617 | } |
618 | 618 | |
619 | -function wpinv_string_is_image_url( $str ) { |
|
620 | - $ext = wpinv_get_file_extension( $str ); |
|
619 | +function wpinv_string_is_image_url($str) { |
|
620 | + $ext = wpinv_get_file_extension($str); |
|
621 | 621 | |
622 | - switch ( strtolower( $ext ) ) { |
|
622 | + switch (strtolower($ext)) { |
|
623 | 623 | case 'jpeg'; |
624 | 624 | case 'jpg'; |
625 | 625 | $return = true; |
@@ -635,32 +635,32 @@ discard block |
||
635 | 635 | break; |
636 | 636 | } |
637 | 637 | |
638 | - return (bool)apply_filters( 'wpinv_string_is_image', $return, $str ); |
|
638 | + return (bool) apply_filters('wpinv_string_is_image', $return, $str); |
|
639 | 639 | } |
640 | 640 | |
641 | -function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) { |
|
642 | - $should_log = apply_filters( 'wpinv_log_errors', WP_DEBUG ); |
|
641 | +function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) { |
|
642 | + $should_log = apply_filters('wpinv_log_errors', WP_DEBUG); |
|
643 | 643 | |
644 | - if ( true === $should_log ) { |
|
644 | + if (true === $should_log) { |
|
645 | 645 | $label = ''; |
646 | - if ( $file && $file !== '' ) { |
|
647 | - $label .= basename( $file ) . ( $line ? '(' . $line . ')' : '' ); |
|
646 | + if ($file && $file !== '') { |
|
647 | + $label .= basename($file) . ($line ? '(' . $line . ')' : ''); |
|
648 | 648 | } |
649 | 649 | |
650 | - if ( $title && $title !== '' ) { |
|
650 | + if ($title && $title !== '') { |
|
651 | 651 | $label = $label !== '' ? $label . ' ' : ''; |
652 | 652 | $label .= $title . ' '; |
653 | 653 | } |
654 | 654 | |
655 | - $label = $label !== '' ? trim( $label ) . ' : ' : ''; |
|
655 | + $label = $label !== '' ? trim($label) . ' : ' : ''; |
|
656 | 656 | |
657 | - if ( is_array( $log ) || is_object( $log ) ) { |
|
658 | - error_log( $label . print_r( $log, true ) ); |
|
657 | + if (is_array($log) || is_object($log)) { |
|
658 | + error_log($label . print_r($log, true)); |
|
659 | 659 | } else { |
660 | - error_log( $label . $log ); |
|
660 | + error_log($label . $log); |
|
661 | 661 | } |
662 | 662 | |
663 | - if ( $exit ) { |
|
663 | + if ($exit) { |
|
664 | 664 | exit; |
665 | 665 | } |
666 | 666 | } |
@@ -668,65 +668,65 @@ discard block |
||
668 | 668 | |
669 | 669 | function wpinv_is_ajax_disabled() { |
670 | 670 | $retval = false; |
671 | - return apply_filters( 'wpinv_is_ajax_disabled', $retval ); |
|
671 | + return apply_filters('wpinv_is_ajax_disabled', $retval); |
|
672 | 672 | } |
673 | 673 | |
674 | -function wpinv_get_current_page_url( $nocache = false ) { |
|
674 | +function wpinv_get_current_page_url($nocache = false) { |
|
675 | 675 | global $wp; |
676 | 676 | |
677 | - if ( get_option( 'permalink_structure' ) ) { |
|
678 | - $base = trailingslashit( home_url( $wp->request ) ); |
|
677 | + if (get_option('permalink_structure')) { |
|
678 | + $base = trailingslashit(home_url($wp->request)); |
|
679 | 679 | } else { |
680 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); |
|
681 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); |
|
680 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); |
|
681 | + $base = remove_query_arg(array('post_type', 'name'), $base); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | $scheme = is_ssl() ? 'https' : 'http'; |
685 | - $uri = set_url_scheme( $base, $scheme ); |
|
685 | + $uri = set_url_scheme($base, $scheme); |
|
686 | 686 | |
687 | - if ( is_front_page() ) { |
|
688 | - $uri = home_url( '/' ); |
|
689 | - } elseif ( wpinv_is_checkout( array(), false ) ) { |
|
687 | + if (is_front_page()) { |
|
688 | + $uri = home_url('/'); |
|
689 | + } elseif (wpinv_is_checkout(array(), false)) { |
|
690 | 690 | $uri = wpinv_get_checkout_uri(); |
691 | 691 | } |
692 | 692 | |
693 | - $uri = apply_filters( 'wpinv_get_current_page_url', $uri ); |
|
693 | + $uri = apply_filters('wpinv_get_current_page_url', $uri); |
|
694 | 694 | |
695 | - if ( $nocache ) { |
|
696 | - $uri = wpinv_add_cache_busting( $uri ); |
|
695 | + if ($nocache) { |
|
696 | + $uri = wpinv_add_cache_busting($uri); |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | return $uri; |
700 | 700 | } |
701 | 701 | |
702 | 702 | function wpinv_get_php_arg_separator_output() { |
703 | - return ini_get( 'arg_separator.output' ); |
|
703 | + return ini_get('arg_separator.output'); |
|
704 | 704 | } |
705 | 705 | |
706 | -function wpinv_rgb_from_hex( $color ) { |
|
707 | - $color = str_replace( '#', '', $color ); |
|
706 | +function wpinv_rgb_from_hex($color) { |
|
707 | + $color = str_replace('#', '', $color); |
|
708 | 708 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
709 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
709 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
710 | 710 | |
711 | 711 | $rgb = array(); |
712 | - $rgb['R'] = hexdec( $color{0}.$color{1} ); |
|
713 | - $rgb['G'] = hexdec( $color{2}.$color{3} ); |
|
714 | - $rgb['B'] = hexdec( $color{4}.$color{5} ); |
|
712 | + $rgb['R'] = hexdec($color{0} . $color{1} ); |
|
713 | + $rgb['G'] = hexdec($color{2} . $color{3} ); |
|
714 | + $rgb['B'] = hexdec($color{4} . $color{5} ); |
|
715 | 715 | |
716 | 716 | return $rgb; |
717 | 717 | } |
718 | 718 | |
719 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
720 | - $base = wpinv_rgb_from_hex( $color ); |
|
719 | +function wpinv_hex_darker($color, $factor = 30) { |
|
720 | + $base = wpinv_rgb_from_hex($color); |
|
721 | 721 | $color = '#'; |
722 | 722 | |
723 | - foreach ( $base as $k => $v ) { |
|
723 | + foreach ($base as $k => $v) { |
|
724 | 724 | $amount = $v / 100; |
725 | - $amount = round( $amount * $factor ); |
|
725 | + $amount = round($amount * $factor); |
|
726 | 726 | $new_decimal = $v - $amount; |
727 | 727 | |
728 | - $new_hex_component = dechex( $new_decimal ); |
|
729 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
728 | + $new_hex_component = dechex($new_decimal); |
|
729 | + if (strlen($new_hex_component) < 2) { |
|
730 | 730 | $new_hex_component = "0" . $new_hex_component; |
731 | 731 | } |
732 | 732 | $color .= $new_hex_component; |
@@ -735,18 +735,18 @@ discard block |
||
735 | 735 | return $color; |
736 | 736 | } |
737 | 737 | |
738 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
739 | - $base = wpinv_rgb_from_hex( $color ); |
|
738 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
739 | + $base = wpinv_rgb_from_hex($color); |
|
740 | 740 | $color = '#'; |
741 | 741 | |
742 | - foreach ( $base as $k => $v ) { |
|
742 | + foreach ($base as $k => $v) { |
|
743 | 743 | $amount = 255 - $v; |
744 | 744 | $amount = $amount / 100; |
745 | - $amount = round( $amount * $factor ); |
|
745 | + $amount = round($amount * $factor); |
|
746 | 746 | $new_decimal = $v + $amount; |
747 | 747 | |
748 | - $new_hex_component = dechex( $new_decimal ); |
|
749 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
748 | + $new_hex_component = dechex($new_decimal); |
|
749 | + if (strlen($new_hex_component) < 2) { |
|
750 | 750 | $new_hex_component = "0" . $new_hex_component; |
751 | 751 | } |
752 | 752 | $color .= $new_hex_component; |
@@ -755,22 +755,22 @@ discard block |
||
755 | 755 | return $color; |
756 | 756 | } |
757 | 757 | |
758 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
759 | - $hex = str_replace( '#', '', $color ); |
|
758 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
759 | + $hex = str_replace('#', '', $color); |
|
760 | 760 | |
761 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
762 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
763 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
761 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
762 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
763 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
764 | 764 | |
765 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
765 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
766 | 766 | |
767 | 767 | return $brightness > 155 ? $dark : $light; |
768 | 768 | } |
769 | 769 | |
770 | -function wpinv_format_hex( $hex ) { |
|
771 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
770 | +function wpinv_format_hex($hex) { |
|
771 | + $hex = trim(str_replace('#', '', $hex)); |
|
772 | 772 | |
773 | - if ( strlen( $hex ) == 3 ) { |
|
773 | + if (strlen($hex) == 3) { |
|
774 | 774 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
775 | 775 | } |
776 | 776 | |
@@ -790,12 +790,12 @@ discard block |
||
790 | 790 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
791 | 791 | * @return string |
792 | 792 | */ |
793 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
794 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
795 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
793 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
794 | + if (function_exists('mb_strimwidth')) { |
|
795 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
796 | 796 | } |
797 | 797 | |
798 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
798 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
799 | 799 | } |
800 | 800 | |
801 | 801 | /** |
@@ -807,28 +807,28 @@ discard block |
||
807 | 807 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
808 | 808 | * @return int Returns the number of characters in string. |
809 | 809 | */ |
810 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
811 | - if ( function_exists( 'mb_strlen' ) ) { |
|
812 | - return mb_strlen( $str, $encoding ); |
|
810 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
811 | + if (function_exists('mb_strlen')) { |
|
812 | + return mb_strlen($str, $encoding); |
|
813 | 813 | } |
814 | 814 | |
815 | - return strlen( $str ); |
|
815 | + return strlen($str); |
|
816 | 816 | } |
817 | 817 | |
818 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
819 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
820 | - return mb_strtolower( $str, $encoding ); |
|
818 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
819 | + if (function_exists('mb_strtolower')) { |
|
820 | + return mb_strtolower($str, $encoding); |
|
821 | 821 | } |
822 | 822 | |
823 | - return strtolower( $str ); |
|
823 | + return strtolower($str); |
|
824 | 824 | } |
825 | 825 | |
826 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
827 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
828 | - return mb_strtoupper( $str, $encoding ); |
|
826 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
827 | + if (function_exists('mb_strtoupper')) { |
|
828 | + return mb_strtoupper($str, $encoding); |
|
829 | 829 | } |
830 | 830 | |
831 | - return strtoupper( $str ); |
|
831 | + return strtoupper($str); |
|
832 | 832 | } |
833 | 833 | |
834 | 834 | /** |
@@ -842,12 +842,12 @@ discard block |
||
842 | 842 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
843 | 843 | * @return int Returns the position of the first occurrence of search in the string. |
844 | 844 | */ |
845 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
846 | - if ( function_exists( 'mb_strpos' ) ) { |
|
847 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
845 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
846 | + if (function_exists('mb_strpos')) { |
|
847 | + return mb_strpos($str, $find, $offset, $encoding); |
|
848 | 848 | } |
849 | 849 | |
850 | - return strpos( $str, $find, $offset ); |
|
850 | + return strpos($str, $find, $offset); |
|
851 | 851 | } |
852 | 852 | |
853 | 853 | /** |
@@ -861,12 +861,12 @@ discard block |
||
861 | 861 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
862 | 862 | * @return int Returns the position of the last occurrence of search. |
863 | 863 | */ |
864 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
865 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
866 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
864 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
865 | + if (function_exists('mb_strrpos')) { |
|
866 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
867 | 867 | } |
868 | 868 | |
869 | - return strrpos( $str, $find, $offset ); |
|
869 | + return strrpos($str, $find, $offset); |
|
870 | 870 | } |
871 | 871 | |
872 | 872 | /** |
@@ -881,16 +881,16 @@ discard block |
||
881 | 881 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
882 | 882 | * @return string |
883 | 883 | */ |
884 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
885 | - if ( function_exists( 'mb_substr' ) ) { |
|
886 | - if ( $length === null ) { |
|
887 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
884 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
885 | + if (function_exists('mb_substr')) { |
|
886 | + if ($length === null) { |
|
887 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
888 | 888 | } else { |
889 | - return mb_substr( $str, $start, $length, $encoding ); |
|
889 | + return mb_substr($str, $start, $length, $encoding); |
|
890 | 890 | } |
891 | 891 | } |
892 | 892 | |
893 | - return substr( $str, $start, $length ); |
|
893 | + return substr($str, $start, $length); |
|
894 | 894 | } |
895 | 895 | |
896 | 896 | /** |
@@ -902,48 +902,48 @@ discard block |
||
902 | 902 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
903 | 903 | * @return string The width of string. |
904 | 904 | */ |
905 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
906 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
907 | - return mb_strwidth( $str, $encoding ); |
|
905 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
906 | + if (function_exists('mb_strwidth')) { |
|
907 | + return mb_strwidth($str, $encoding); |
|
908 | 908 | } |
909 | 909 | |
910 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
910 | + return wpinv_utf8_strlen($str, $encoding); |
|
911 | 911 | } |
912 | 912 | |
913 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
914 | - if ( function_exists( 'mb_strlen' ) ) { |
|
915 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
913 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
914 | + if (function_exists('mb_strlen')) { |
|
915 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
916 | 916 | $str_end = ""; |
917 | 917 | |
918 | - if ( $lower_str_end ) { |
|
919 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
918 | + if ($lower_str_end) { |
|
919 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
920 | 920 | } else { |
921 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
921 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
922 | 922 | } |
923 | 923 | |
924 | 924 | return $first_letter . $str_end; |
925 | 925 | } |
926 | 926 | |
927 | - return ucfirst( $str ); |
|
927 | + return ucfirst($str); |
|
928 | 928 | } |
929 | 929 | |
930 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
931 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
932 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
930 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
931 | + if (function_exists('mb_convert_case')) { |
|
932 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
933 | 933 | } |
934 | 934 | |
935 | - return ucwords( $str ); |
|
935 | + return ucwords($str); |
|
936 | 936 | } |
937 | 937 | |
938 | -function wpinv_period_in_days( $period, $unit ) { |
|
939 | - $period = absint( $period ); |
|
938 | +function wpinv_period_in_days($period, $unit) { |
|
939 | + $period = absint($period); |
|
940 | 940 | |
941 | - if ( $period > 0 ) { |
|
942 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
941 | + if ($period > 0) { |
|
942 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
943 | 943 | $period = $period * 7; |
944 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
944 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
945 | 945 | $period = $period * 30; |
946 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
946 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
947 | 947 | $period = $period * 365; |
948 | 948 | } |
949 | 949 | } |
@@ -951,14 +951,14 @@ discard block |
||
951 | 951 | return $period; |
952 | 952 | } |
953 | 953 | |
954 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
955 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
956 | - return cal_days_in_month( $calendar, $month, $year ); |
|
954 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
955 | + if (function_exists('cal_days_in_month')) { |
|
956 | + return cal_days_in_month($calendar, $month, $year); |
|
957 | 957 | } |
958 | 958 | |
959 | 959 | // Fallback in case the calendar extension is not loaded in PHP |
960 | 960 | // Only supports Gregorian calendar |
961 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
961 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | /** |
@@ -969,11 +969,11 @@ discard block |
||
969 | 969 | * |
970 | 970 | * @return string |
971 | 971 | */ |
972 | -function wpi_help_tip( $tip, $allow_html = false ) { |
|
973 | - if ( $allow_html ) { |
|
974 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
972 | +function wpi_help_tip($tip, $allow_html = false) { |
|
973 | + if ($allow_html) { |
|
974 | + $tip = wpi_sanitize_tooltip($tip); |
|
975 | 975 | } else { |
976 | - $tip = esc_attr( $tip ); |
|
976 | + $tip = esc_attr($tip); |
|
977 | 977 | } |
978 | 978 | |
979 | 979 | return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -987,8 +987,8 @@ discard block |
||
987 | 987 | * @param string $var |
988 | 988 | * @return string |
989 | 989 | */ |
990 | -function wpi_sanitize_tooltip( $var ) { |
|
991 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
990 | +function wpi_sanitize_tooltip($var) { |
|
991 | + return htmlspecialchars(wp_kses(html_entity_decode($var), array( |
|
992 | 992 | 'br' => array(), |
993 | 993 | 'em' => array(), |
994 | 994 | 'strong' => array(), |
@@ -998,7 +998,7 @@ discard block |
||
998 | 998 | 'li' => array(), |
999 | 999 | 'ol' => array(), |
1000 | 1000 | 'p' => array(), |
1001 | - ) ) ); |
|
1001 | + ))); |
|
1002 | 1002 | } |
1003 | 1003 | |
1004 | 1004 | /** |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | */ |
1009 | 1009 | function wpinv_get_screen_ids() { |
1010 | 1010 | |
1011 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
1011 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
1012 | 1012 | |
1013 | 1013 | $screen_ids = array( |
1014 | 1014 | 'toplevel_page_' . $screen_id, |
@@ -1026,7 +1026,7 @@ discard block |
||
1026 | 1026 | 'invoicing_page_wpi-addons', |
1027 | 1027 | ); |
1028 | 1028 | |
1029 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
1029 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
1030 | 1030 | } |
1031 | 1031 | |
1032 | 1032 | /** |
@@ -1037,9 +1037,9 @@ discard block |
||
1037 | 1037 | * @param array|string $list List of values. |
1038 | 1038 | * @return array Sanitized array of values. |
1039 | 1039 | */ |
1040 | -function wpinv_parse_list( $list ) { |
|
1041 | - if ( ! is_array( $list ) ) { |
|
1042 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
1040 | +function wpinv_parse_list($list) { |
|
1041 | + if (!is_array($list)) { |
|
1042 | + return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY); |
|
1043 | 1043 | } |
1044 | 1044 | |
1045 | 1045 | return $list; |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | case 'status' : |
102 | 102 | $value = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' ); |
103 | 103 | $is_viewed = wpinv_is_invoice_viewed( $wpi_invoice->ID ); |
104 | - $gateway_title = wpinv_get_gateway_admin_label( $wpi_invoice->get_gateway() ); |
|
105 | - $offline_gateways = apply_filters('wpinv_offline_payments', array('bank_transfer', 'cheque', 'cod')); |
|
106 | - $is_offline_payment = in_array($wpi_invoice->get_gateway(), $offline_gateways) ? true : false; |
|
104 | + $gateway_title = wpinv_get_gateway_admin_label( $wpi_invoice->get_gateway() ); |
|
105 | + $offline_gateways = apply_filters('wpinv_offline_payments', array('bank_transfer', 'cheque', 'cod')); |
|
106 | + $is_offline_payment = in_array($wpi_invoice->get_gateway(), $offline_gateways) ? true : false; |
|
107 | 107 | |
108 | 108 | if ( 1 == $is_viewed ) { |
109 | 109 | $value .= ' <i class="fa fa-eye" title="'.__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
@@ -174,69 +174,69 @@ discard block |
||
174 | 174 | } |
175 | 175 | |
176 | 176 | function wpinv_admin_messages() { |
177 | - global $wpinv_options, $pagenow, $post; |
|
177 | + global $wpinv_options, $pagenow, $post; |
|
178 | 178 | |
179 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
180 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
181 | - } |
|
179 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
180 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
181 | + } |
|
182 | 182 | |
183 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
184 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
185 | - } |
|
183 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
184 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
185 | + } |
|
186 | 186 | |
187 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
188 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
189 | - } |
|
187 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
188 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
189 | + } |
|
190 | 190 | |
191 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
192 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
193 | - } |
|
191 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
192 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
193 | + } |
|
194 | 194 | |
195 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
196 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
197 | - } |
|
195 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
196 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
197 | + } |
|
198 | 198 | |
199 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
200 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
201 | - } |
|
199 | + if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
200 | + add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
201 | + } |
|
202 | 202 | |
203 | - if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
204 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' ); |
|
205 | - } |
|
203 | + if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
204 | + add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' ); |
|
205 | + } |
|
206 | 206 | |
207 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
208 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
207 | + if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
208 | + add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
212 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
212 | + add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
216 | 216 | add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
217 | 217 | } |
218 | 218 | |
219 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
220 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
221 | - } |
|
219 | + if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
220 | + add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
221 | + } |
|
222 | 222 | |
223 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
224 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
225 | - } |
|
223 | + if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
224 | + add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
225 | + } |
|
226 | 226 | |
227 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
228 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
229 | - } |
|
227 | + if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
228 | + add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
229 | + } |
|
230 | 230 | |
231 | - if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
232 | - $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
231 | + if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
232 | + $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
233 | 233 | |
234 | - if ( !empty( $message ) ) { |
|
235 | - add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
236 | - } |
|
237 | - } |
|
234 | + if ( !empty( $message ) ) { |
|
235 | + add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
236 | + } |
|
237 | + } |
|
238 | 238 | |
239 | - settings_errors( 'wpinv-notices' ); |
|
239 | + settings_errors( 'wpinv-notices' ); |
|
240 | 240 | } |
241 | 241 | add_action( 'admin_notices', 'wpinv_admin_messages' ); |
242 | 242 | |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | break; |
327 | 327 | case 'id' : |
328 | 328 | echo $post->ID; |
329 | - echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
|
329 | + echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
|
330 | 330 | <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
331 | 331 | if ( $wpinv_euvat->allow_vat_rules() ) { |
332 | 332 | echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
@@ -7,245 +7,245 @@ 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 | -function wpinv_columns( $columns ) { |
|
14 | +function wpinv_columns($columns) { |
|
15 | 15 | $columns = array( |
16 | 16 | 'cb' => $columns['cb'], |
17 | - 'number' => __( 'Number', 'invoicing' ), |
|
18 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
19 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
20 | - 'invoice_date' => __( 'Created Date', 'invoicing' ), |
|
21 | - 'payment_date' => __( 'Payment Date', 'invoicing' ), |
|
22 | - 'status' => __( 'Status', 'invoicing' ), |
|
23 | - 'ID' => __( 'ID', 'invoicing' ), |
|
24 | - 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
17 | + 'number' => __('Number', 'invoicing'), |
|
18 | + 'customer' => __('Customer', 'invoicing'), |
|
19 | + 'amount' => __('Amount', 'invoicing'), |
|
20 | + 'invoice_date' => __('Created Date', 'invoicing'), |
|
21 | + 'payment_date' => __('Payment Date', 'invoicing'), |
|
22 | + 'status' => __('Status', 'invoicing'), |
|
23 | + 'ID' => __('ID', 'invoicing'), |
|
24 | + 'wpi_actions' => __('Actions', 'invoicing'), |
|
25 | 25 | ); |
26 | 26 | |
27 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
27 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
28 | 28 | } |
29 | -add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' ); |
|
29 | +add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns'); |
|
30 | 30 | |
31 | -function wpinv_bulk_actions( $actions ) { |
|
32 | - if ( isset( $actions['edit'] ) ) { |
|
33 | - unset( $actions['edit'] ); |
|
31 | +function wpinv_bulk_actions($actions) { |
|
32 | + if (isset($actions['edit'])) { |
|
33 | + unset($actions['edit']); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | return $actions; |
37 | 37 | } |
38 | -add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' ); |
|
39 | -add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' ); |
|
38 | +add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions'); |
|
39 | +add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions'); |
|
40 | 40 | |
41 | -function wpinv_sortable_columns( $columns ) { |
|
41 | +function wpinv_sortable_columns($columns) { |
|
42 | 42 | $columns = array( |
43 | - 'ID' => array( 'ID', true ), |
|
44 | - 'number' => array( 'number', false ), |
|
45 | - 'amount' => array( 'amount', false ), |
|
46 | - 'invoice_date' => array( 'date', false ), |
|
47 | - 'payment_date' => array( 'payment_date', true ), |
|
48 | - 'customer' => array( 'customer', false ), |
|
49 | - 'status' => array( 'status', false ), |
|
43 | + 'ID' => array('ID', true), |
|
44 | + 'number' => array('number', false), |
|
45 | + 'amount' => array('amount', false), |
|
46 | + 'invoice_date' => array('date', false), |
|
47 | + 'payment_date' => array('payment_date', true), |
|
48 | + 'customer' => array('customer', false), |
|
49 | + 'status' => array('status', false), |
|
50 | 50 | ); |
51 | 51 | |
52 | - return apply_filters( 'wpi_invoice_table_sortable_columns', $columns ); |
|
52 | + return apply_filters('wpi_invoice_table_sortable_columns', $columns); |
|
53 | 53 | } |
54 | -add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' ); |
|
54 | +add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns'); |
|
55 | 55 | |
56 | -add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
57 | -function wpinv_posts_custom_column( $column_name, $post_id = 0 ) { |
|
56 | +add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
57 | +function wpinv_posts_custom_column($column_name, $post_id = 0) { |
|
58 | 58 | global $post, $wpi_invoice; |
59 | 59 | |
60 | - if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) { |
|
61 | - $wpi_invoice = new WPInv_Invoice( $post->ID ); |
|
60 | + if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) { |
|
61 | + $wpi_invoice = new WPInv_Invoice($post->ID); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | $value = NULL; |
65 | 65 | |
66 | - switch ( $column_name ) { |
|
66 | + switch ($column_name) { |
|
67 | 67 | case 'email' : |
68 | - $value = $wpi_invoice->get_email(); |
|
68 | + $value = $wpi_invoice->get_email(); |
|
69 | 69 | break; |
70 | 70 | case 'customer' : |
71 | 71 | $customer_name = $wpi_invoice->get_user_full_name(); |
72 | - $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' ); |
|
73 | - $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>'; |
|
74 | - if ( $email = $wpi_invoice->get_email() ) { |
|
72 | + $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing'); |
|
73 | + $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>'; |
|
74 | + if ($email = $wpi_invoice->get_email()) { |
|
75 | 75 | $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>'; |
76 | 76 | } |
77 | 77 | break; |
78 | 78 | case 'amount' : |
79 | - echo $wpi_invoice->get_total( true ); |
|
79 | + echo $wpi_invoice->get_total(true); |
|
80 | 80 | break; |
81 | 81 | case 'invoice_date' : |
82 | - $date_format = get_option( 'date_format' ); |
|
82 | + $date_format = get_option('date_format'); |
|
83 | 83 | |
84 | 84 | $m_time = $post->post_date; |
85 | - $h_time = mysql2date( $date_format, $m_time ); |
|
85 | + $h_time = mysql2date($date_format, $m_time); |
|
86 | 86 | |
87 | - $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>'; |
|
87 | + $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>'; |
|
88 | 88 | break; |
89 | 89 | case 'payment_date' : |
90 | - if ( $date_completed = $wpi_invoice->get_meta( '_wpinv_completed_date', true ) ) { |
|
91 | - $date_format = get_option( 'date_format' ); |
|
90 | + if ($date_completed = $wpi_invoice->get_meta('_wpinv_completed_date', true)) { |
|
91 | + $date_format = get_option('date_format'); |
|
92 | 92 | |
93 | 93 | $m_time = $date_completed; |
94 | - $h_time = mysql2date( $date_format, $m_time ); |
|
94 | + $h_time = mysql2date($date_format, $m_time); |
|
95 | 95 | |
96 | - $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>'; |
|
96 | + $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>'; |
|
97 | 97 | } else { |
98 | 98 | $value = '-'; |
99 | 99 | } |
100 | 100 | break; |
101 | 101 | case 'status' : |
102 | - $value = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' ); |
|
103 | - $is_viewed = wpinv_is_invoice_viewed( $wpi_invoice->ID ); |
|
104 | - $gateway_title = wpinv_get_gateway_admin_label( $wpi_invoice->get_gateway() ); |
|
102 | + $value = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : ''); |
|
103 | + $is_viewed = wpinv_is_invoice_viewed($wpi_invoice->ID); |
|
104 | + $gateway_title = wpinv_get_gateway_admin_label($wpi_invoice->get_gateway()); |
|
105 | 105 | $offline_gateways = apply_filters('wpinv_offline_payments', array('bank_transfer', 'cheque', 'cod')); |
106 | 106 | $is_offline_payment = in_array($wpi_invoice->get_gateway(), $offline_gateways) ? true : false; |
107 | 107 | |
108 | - if ( 1 == $is_viewed ) { |
|
109 | - $value .= ' <i class="fa fa-eye" title="'.__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
108 | + if (1 == $is_viewed) { |
|
109 | + $value .= ' <i class="fa fa-eye" title="' . __('Viewed by Customer', 'invoicing') . '"></i>'; |
|
110 | 110 | } |
111 | - if ( ( $wpi_invoice->is_paid() || $wpi_invoice->is_refunded() || $is_offline_payment ) && ( isset( $gateway_title ) ) ) { |
|
112 | - $value .= '<br><small class="meta gateway">' . wp_sprintf( __( 'Via %s', 'invoicing' ), $gateway_title ) . '</small>'; |
|
111 | + if (($wpi_invoice->is_paid() || $wpi_invoice->is_refunded() || $is_offline_payment) && (isset($gateway_title))) { |
|
112 | + $value .= '<br><small class="meta gateway">' . wp_sprintf(__('Via %s', 'invoicing'), $gateway_title) . '</small>'; |
|
113 | 113 | } |
114 | 114 | break; |
115 | 115 | case 'number' : |
116 | - $edit_link = get_edit_post_link( $post->ID ); |
|
117 | - $value = '<a title="' . esc_attr__( 'View Invoice Details', 'invoicing' ) . '" href="' . esc_url( $edit_link ) . '">' . $wpi_invoice->get_number() . '</a>'; |
|
116 | + $edit_link = get_edit_post_link($post->ID); |
|
117 | + $value = '<a title="' . esc_attr__('View Invoice Details', 'invoicing') . '" href="' . esc_url($edit_link) . '">' . $wpi_invoice->get_number() . '</a>'; |
|
118 | 118 | break; |
119 | 119 | case 'wpi_actions' : |
120 | 120 | $value = ''; |
121 | - if ( !empty( $post->post_name ) ) { |
|
122 | - $value .= '<a title="' . esc_attr__( 'Print invoice', 'invoicing' ) . '" href="' . esc_url( get_permalink( $post->ID ) ) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
121 | + if (!empty($post->post_name)) { |
|
122 | + $value .= '<a title="' . esc_attr__('Print invoice', 'invoicing') . '" href="' . esc_url(get_permalink($post->ID)) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
123 | 123 | } |
124 | 124 | |
125 | - if ( $email = $wpi_invoice->get_email() ) { |
|
126 | - $value .= '<a title="' . esc_attr__( 'Send invoice to customer', 'invoicing' ) . '" href="' . esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
125 | + if ($email = $wpi_invoice->get_email()) { |
|
126 | + $value .= '<a title="' . esc_attr__('Send invoice to customer', 'invoicing') . '" href="' . esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | break; |
130 | 130 | default: |
131 | - $value = isset( $post->$column_name ) ? $post->$column_name : ''; |
|
131 | + $value = isset($post->$column_name) ? $post->$column_name : ''; |
|
132 | 132 | break; |
133 | 133 | |
134 | 134 | } |
135 | - $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name ); |
|
135 | + $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name); |
|
136 | 136 | |
137 | - if ( $value !== NULL ) { |
|
137 | + if ($value !== NULL) { |
|
138 | 138 | echo $value; |
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | -function wpinv_admin_post_id( $id = 0 ) { |
|
142 | +function wpinv_admin_post_id($id = 0) { |
|
143 | 143 | global $post; |
144 | 144 | |
145 | - if ( isset( $id ) && ! empty( $id ) ) { |
|
146 | - return (int)$id; |
|
147 | - } else if ( get_the_ID() ) { |
|
145 | + if (isset($id) && !empty($id)) { |
|
146 | + return (int) $id; |
|
147 | + } else if (get_the_ID()) { |
|
148 | 148 | return (int) get_the_ID(); |
149 | - } else if ( isset( $post->ID ) && !empty( $post->ID ) ) { |
|
149 | + } else if (isset($post->ID) && !empty($post->ID)) { |
|
150 | 150 | return (int) $post->ID; |
151 | - } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) { |
|
151 | + } else if (isset($_GET['post']) && !empty($_GET['post'])) { |
|
152 | 152 | return (int) $_GET['post']; |
153 | - } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) { |
|
153 | + } else if (isset($_GET['id']) && !empty($_GET['id'])) { |
|
154 | 154 | return (int) $_GET['id']; |
155 | - } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) { |
|
155 | + } else if (isset($_POST['id']) && !empty($_POST['id'])) { |
|
156 | 156 | return (int) $_POST['id']; |
157 | 157 | } |
158 | 158 | |
159 | 159 | return null; |
160 | 160 | } |
161 | 161 | |
162 | -function wpinv_admin_post_type( $id = 0 ) { |
|
163 | - if ( !$id ) { |
|
162 | +function wpinv_admin_post_type($id = 0) { |
|
163 | + if (!$id) { |
|
164 | 164 | $id = wpinv_admin_post_id(); |
165 | 165 | } |
166 | 166 | |
167 | - $type = get_post_type( $id ); |
|
167 | + $type = get_post_type($id); |
|
168 | 168 | |
169 | - if ( !$type ) { |
|
170 | - $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null; |
|
169 | + if (!$type) { |
|
170 | + $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null; |
|
171 | 171 | } |
172 | 172 | |
173 | - return apply_filters( 'wpinv_admin_post_type', $type, $id ); |
|
173 | + return apply_filters('wpinv_admin_post_type', $type, $id); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | function wpinv_admin_messages() { |
177 | 177 | global $wpinv_options, $pagenow, $post; |
178 | 178 | |
179 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
180 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
179 | + if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
180 | + add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated'); |
|
181 | 181 | } |
182 | 182 | |
183 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
184 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
183 | + if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
184 | + add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error'); |
|
185 | 185 | } |
186 | 186 | |
187 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
188 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
187 | + if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
188 | + add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error'); |
|
189 | 189 | } |
190 | 190 | |
191 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
192 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
191 | + if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
192 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated'); |
|
193 | 193 | } |
194 | 194 | |
195 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
196 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
195 | + if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
196 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error'); |
|
197 | 197 | } |
198 | 198 | |
199 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
200 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
199 | + if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
200 | + add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated'); |
|
201 | 201 | } |
202 | 202 | |
203 | - if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
204 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' ); |
|
203 | + if (isset($_GET['wpinv-message']) && 'email_disabled' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
204 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Email notification is disabled. Please check settings.', 'invoicing'), 'error'); |
|
205 | 205 | } |
206 | 206 | |
207 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
208 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
207 | + if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
208 | + add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated'); |
|
209 | 209 | } |
210 | 210 | |
211 | - if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
212 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
211 | + if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
212 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error'); |
|
213 | 213 | } |
214 | 214 | |
215 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
216 | - add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
|
215 | + if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
216 | + add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated'); |
|
217 | 217 | } |
218 | 218 | |
219 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
220 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
219 | + if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
220 | + add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated'); |
|
221 | 221 | } |
222 | 222 | |
223 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
224 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
223 | + if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
224 | + add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated'); |
|
225 | 225 | } |
226 | 226 | |
227 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) { |
|
228 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
227 | + if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) { |
|
228 | + add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated'); |
|
229 | 229 | } |
230 | 230 | |
231 | - if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
232 | - $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
231 | + if ($pagenow == 'post.php' && !empty($post->post_type) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable($post)) { |
|
232 | + $message = apply_filters('wpinv_item_non_editable_message', __('This item in not editable.', 'invoicing'), $post->ID); |
|
233 | 233 | |
234 | - if ( !empty( $message ) ) { |
|
235 | - add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
234 | + if (!empty($message)) { |
|
235 | + add_settings_error('wpinv-notices', 'wpinv-edit-n', $message, 'updated'); |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | - settings_errors( 'wpinv-notices' ); |
|
239 | + settings_errors('wpinv-notices'); |
|
240 | 240 | } |
241 | -add_action( 'admin_notices', 'wpinv_admin_messages' ); |
|
241 | +add_action('admin_notices', 'wpinv_admin_messages'); |
|
242 | 242 | |
243 | -add_action( 'admin_init', 'wpinv_show_test_payment_gateway_notice' ); |
|
244 | -function wpinv_show_test_payment_gateway_notice(){ |
|
245 | - add_action( 'admin_notices', 'wpinv_test_payment_gateway_messages' ); |
|
243 | +add_action('admin_init', 'wpinv_show_test_payment_gateway_notice'); |
|
244 | +function wpinv_show_test_payment_gateway_notice() { |
|
245 | + add_action('admin_notices', 'wpinv_test_payment_gateway_messages'); |
|
246 | 246 | } |
247 | 247 | |
248 | -function wpinv_test_payment_gateway_messages(){ |
|
248 | +function wpinv_test_payment_gateway_messages() { |
|
249 | 249 | $gateways = wpinv_get_enabled_payment_gateways(); |
250 | 250 | $name = array(); $test_gateways = ''; |
251 | 251 | if ($gateways) { |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | } |
257 | 257 | $test_gateways = implode(', ', $name); |
258 | 258 | } |
259 | - if(isset($test_gateways) && !empty($test_gateways)){ |
|
259 | + if (isset($test_gateways) && !empty($test_gateways)) { |
|
260 | 260 | $link = admin_url('admin.php?page=wpinv-settings&tab=gateways'); |
261 | - $notice = wp_sprintf( __('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link ); |
|
261 | + $notice = wp_sprintf(__('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link); |
|
262 | 262 | ?> |
263 | 263 | <div class="notice notice-warning is-dismissible"> |
264 | 264 | <p><?php echo $notice; ?></p> |
@@ -267,29 +267,29 @@ discard block |
||
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
270 | -function wpinv_items_columns( $existing_columns ) { |
|
270 | +function wpinv_items_columns($existing_columns) { |
|
271 | 271 | global $wpinv_euvat; |
272 | 272 | |
273 | 273 | $columns = array(); |
274 | 274 | $columns['cb'] = $existing_columns['cb']; |
275 | - $columns['title'] = __( 'Title', 'invoicing' ); |
|
276 | - $columns['price'] = __( 'Price', 'invoicing' ); |
|
277 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
278 | - $columns['vat_rule'] = __( 'VAT rule type', 'invoicing' ); |
|
275 | + $columns['title'] = __('Title', 'invoicing'); |
|
276 | + $columns['price'] = __('Price', 'invoicing'); |
|
277 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
278 | + $columns['vat_rule'] = __('VAT rule type', 'invoicing'); |
|
279 | 279 | } |
280 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
281 | - $columns['vat_class'] = __( 'VAT class', 'invoicing' ); |
|
280 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
281 | + $columns['vat_class'] = __('VAT class', 'invoicing'); |
|
282 | 282 | } |
283 | - $columns['type'] = __( 'Type', 'invoicing' ); |
|
284 | - $columns['recurring'] = __( 'Recurring', 'invoicing' ); |
|
285 | - $columns['date'] = __( 'Date', 'invoicing' ); |
|
286 | - $columns['id'] = __( 'ID', 'invoicing' ); |
|
283 | + $columns['type'] = __('Type', 'invoicing'); |
|
284 | + $columns['recurring'] = __('Recurring', 'invoicing'); |
|
285 | + $columns['date'] = __('Date', 'invoicing'); |
|
286 | + $columns['id'] = __('ID', 'invoicing'); |
|
287 | 287 | |
288 | - return apply_filters( 'wpinv_items_columns', $columns ); |
|
288 | + return apply_filters('wpinv_items_columns', $columns); |
|
289 | 289 | } |
290 | -add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' ); |
|
290 | +add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns'); |
|
291 | 291 | |
292 | -function wpinv_items_sortable_columns( $columns ) { |
|
292 | +function wpinv_items_sortable_columns($columns) { |
|
293 | 293 | $columns['price'] = 'price'; |
294 | 294 | $columns['vat_rule'] = 'vat_rule'; |
295 | 295 | $columns['vat_class'] = 'vat_class'; |
@@ -299,175 +299,175 @@ discard block |
||
299 | 299 | |
300 | 300 | return $columns; |
301 | 301 | } |
302 | -add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' ); |
|
302 | +add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns'); |
|
303 | 303 | |
304 | -function wpinv_items_table_custom_column( $column ) { |
|
304 | +function wpinv_items_table_custom_column($column) { |
|
305 | 305 | global $wpinv_euvat, $post, $wpi_item; |
306 | 306 | |
307 | - if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) { |
|
308 | - $wpi_item = new WPInv_Item( $post->ID ); |
|
307 | + if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) { |
|
308 | + $wpi_item = new WPInv_Item($post->ID); |
|
309 | 309 | } |
310 | 310 | |
311 | - switch ( $column ) { |
|
311 | + switch ($column) { |
|
312 | 312 | case 'price' : |
313 | - echo wpinv_item_price( $post->ID ); |
|
313 | + echo wpinv_item_price($post->ID); |
|
314 | 314 | break; |
315 | 315 | case 'vat_rule' : |
316 | - echo $wpinv_euvat->item_rule_label( $post->ID ); |
|
316 | + echo $wpinv_euvat->item_rule_label($post->ID); |
|
317 | 317 | break; |
318 | 318 | case 'vat_class' : |
319 | - echo $wpinv_euvat->item_class_label( $post->ID ); |
|
319 | + echo $wpinv_euvat->item_class_label($post->ID); |
|
320 | 320 | break; |
321 | 321 | case 'type' : |
322 | - echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
322 | + echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
323 | 323 | break; |
324 | 324 | case 'recurring' : |
325 | - echo ( wpinv_is_recurring_item( $post->ID ) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>' ); |
|
325 | + echo (wpinv_is_recurring_item($post->ID) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>'); |
|
326 | 326 | break; |
327 | 327 | case 'id' : |
328 | 328 | echo $post->ID; |
329 | 329 | echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
330 | - <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
|
331 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
332 | - echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
|
330 | + <div class="price">' . wpinv_get_item_price($post->ID) . '</div>'; |
|
331 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
332 | + echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>'; |
|
333 | 333 | } |
334 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
335 | - echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>'; |
|
334 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
335 | + echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>'; |
|
336 | 336 | } |
337 | - echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div> |
|
337 | + echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div> |
|
338 | 338 | </div>'; |
339 | 339 | break; |
340 | 340 | } |
341 | 341 | |
342 | - do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post ); |
|
342 | + do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post); |
|
343 | 343 | } |
344 | -add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' ); |
|
344 | +add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column'); |
|
345 | 345 | |
346 | 346 | function wpinv_add_items_filters() { |
347 | 347 | global $wpinv_euvat, $typenow; |
348 | 348 | |
349 | 349 | // Checks if the current post type is 'item' |
350 | - if ( $typenow == 'wpi_item') { |
|
351 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
350 | + if ($typenow == 'wpi_item') { |
|
351 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
352 | 352 | |
353 | 353 | // Sanitize selected vat rule. |
354 | - $vat_rule = ''; |
|
355 | - if( isset( $_GET['vat_rule'] ) && array_key_exists( $_GET['type'], $wpinv_euvat->get_rules() ) ) { |
|
356 | - $class = $_GET['type']; |
|
354 | + $vat_rule = ''; |
|
355 | + if (isset($_GET['vat_rule']) && array_key_exists($_GET['type'], $wpinv_euvat->get_rules())) { |
|
356 | + $class = $_GET['type']; |
|
357 | 357 | } |
358 | 358 | |
359 | - echo wpinv_html_select( array( |
|
360 | - 'options' => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ), |
|
359 | + echo wpinv_html_select(array( |
|
360 | + 'options' => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()), |
|
361 | 361 | 'name' => 'vat_rule', |
362 | 362 | 'id' => 'vat_rule', |
363 | - 'selected' => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ), |
|
363 | + 'selected' => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''), |
|
364 | 364 | 'show_option_all' => false, |
365 | 365 | 'show_option_none' => false, |
366 | 366 | 'class' => 'gdmbx2-text-medium wpi_select2', |
367 | - 'placeholder' => __( 'Select VAT rule', 'invoicing' ), |
|
368 | - ) ); |
|
367 | + 'placeholder' => __('Select VAT rule', 'invoicing'), |
|
368 | + )); |
|
369 | 369 | } |
370 | 370 | |
371 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
371 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
372 | 372 | |
373 | 373 | $classes = $wpinv_euvat->get_all_classes(); |
374 | 374 | |
375 | 375 | // Sanitize selected vat class. |
376 | 376 | $class = ''; |
377 | - if( isset( $_GET['vat_class'] ) && array_key_exists( $_GET['vat_class'], $classes ) ) { |
|
378 | - $class = $_GET['vat_class']; |
|
377 | + if (isset($_GET['vat_class']) && array_key_exists($_GET['vat_class'], $classes)) { |
|
378 | + $class = $_GET['vat_class']; |
|
379 | 379 | } |
380 | 380 | |
381 | - echo wpinv_html_select( array( |
|
382 | - 'options' => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $classes ), |
|
381 | + echo wpinv_html_select(array( |
|
382 | + 'options' => array_merge(array('' => __('All VAT classes', 'invoicing')), $classes), |
|
383 | 383 | 'name' => 'vat_class', |
384 | 384 | 'id' => 'vat_class', |
385 | 385 | 'selected' => $class, |
386 | 386 | 'show_option_all' => false, |
387 | 387 | 'show_option_none' => false, |
388 | 388 | 'class' => 'gdmbx2-text-medium wpi_select2', |
389 | - 'placeholder' => __( 'Select VAT class', 'invoicing' ), |
|
390 | - ) ); |
|
389 | + 'placeholder' => __('Select VAT class', 'invoicing'), |
|
390 | + )); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | // Sanitize selected item type. |
394 | - $type = ''; |
|
395 | - if( isset( $_GET['type'] ) && array_key_exists( $_GET['type'], wpinv_get_item_types() ) ) { |
|
396 | - $class = $_GET['type']; |
|
394 | + $type = ''; |
|
395 | + if (isset($_GET['type']) && array_key_exists($_GET['type'], wpinv_get_item_types())) { |
|
396 | + $class = $_GET['type']; |
|
397 | 397 | } |
398 | 398 | |
399 | - echo wpinv_html_select( array( |
|
400 | - 'options' => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ), |
|
399 | + echo wpinv_html_select(array( |
|
400 | + 'options' => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()), |
|
401 | 401 | 'name' => 'type', |
402 | 402 | 'id' => 'type', |
403 | 403 | 'selected' => $type, |
404 | 404 | 'show_option_all' => false, |
405 | 405 | 'show_option_none' => false, |
406 | 406 | 'class' => 'gdmbx2-text-medium', |
407 | - ) ); |
|
407 | + )); |
|
408 | 408 | |
409 | - if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) { |
|
409 | + if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) { |
|
410 | 410 | echo '<input type="hidden" name="all_posts" value="1" />'; |
411 | 411 | } |
412 | 412 | } |
413 | 413 | } |
414 | -add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 ); |
|
414 | +add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100); |
|
415 | 415 | |
416 | -function wpinv_send_invoice_after_save( $invoice ) { |
|
417 | - if ( empty( $_POST['wpi_save_send'] ) ) { |
|
416 | +function wpinv_send_invoice_after_save($invoice) { |
|
417 | + if (empty($_POST['wpi_save_send'])) { |
|
418 | 418 | return; |
419 | 419 | } |
420 | 420 | |
421 | - if ( !empty( $invoice->ID ) && !empty( $invoice->post_type ) && 'wpi_invoice' == $invoice->post_type ) { |
|
422 | - wpinv_user_invoice_notification( $invoice->ID ); |
|
421 | + if (!empty($invoice->ID) && !empty($invoice->post_type) && 'wpi_invoice' == $invoice->post_type) { |
|
422 | + wpinv_user_invoice_notification($invoice->ID); |
|
423 | 423 | } |
424 | 424 | } |
425 | -add_action( 'wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1 ); |
|
425 | +add_action('wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1); |
|
426 | 426 | |
427 | -function wpinv_send_register_new_user( $data, $postarr ) { |
|
428 | - if ( wpinv_current_user_can_manage_invoicing() && !empty( $data['post_type'] ) && ( 'wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'] ) ) { |
|
429 | - $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false; |
|
430 | - $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL; |
|
427 | +function wpinv_send_register_new_user($data, $postarr) { |
|
428 | + if (wpinv_current_user_can_manage_invoicing() && !empty($data['post_type']) && ('wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'])) { |
|
429 | + $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false; |
|
430 | + $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL; |
|
431 | 431 | |
432 | - if ( $is_new_user && $email && !email_exists( $email ) ) { |
|
433 | - $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : ''; |
|
434 | - $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : ''; |
|
435 | - $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : ''; |
|
436 | - $user_nicename = $display_name ? trim( $display_name ) : $email; |
|
437 | - $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : ''; |
|
432 | + if ($is_new_user && $email && !email_exists($email)) { |
|
433 | + $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : ''; |
|
434 | + $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : ''; |
|
435 | + $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : ''; |
|
436 | + $user_nicename = $display_name ? trim($display_name) : $email; |
|
437 | + $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : ''; |
|
438 | 438 | |
439 | - $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true ); |
|
440 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
439 | + $user_login = sanitize_user(str_replace(' ', '', $display_name), true); |
|
440 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
441 | 441 | $new_user_login = strstr($email, '@', true); |
442 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
443 | - $user_login = sanitize_user($new_user_login, true ); |
|
442 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
443 | + $user_login = sanitize_user($new_user_login, true); |
|
444 | 444 | } |
445 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
446 | - $user_append_text = rand(10,1000); |
|
447 | - $user_login = sanitize_user($new_user_login.$user_append_text, true ); |
|
445 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
446 | + $user_append_text = rand(10, 1000); |
|
447 | + $user_login = sanitize_user($new_user_login . $user_append_text, true); |
|
448 | 448 | } |
449 | 449 | |
450 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
450 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
451 | 451 | $user_login = $email; |
452 | 452 | } |
453 | 453 | } |
454 | 454 | |
455 | 455 | $userdata = array( |
456 | 456 | 'user_login' => $user_login, |
457 | - 'user_pass' => wp_generate_password( 12, false ), |
|
458 | - 'user_email' => sanitize_text_field( $email ), |
|
457 | + 'user_pass' => wp_generate_password(12, false), |
|
458 | + 'user_email' => sanitize_text_field($email), |
|
459 | 459 | 'first_name' => $first_name, |
460 | 460 | 'last_name' => $last_name, |
461 | - 'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ), |
|
461 | + 'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50), |
|
462 | 462 | 'nickname' => $display_name, |
463 | 463 | 'display_name' => $display_name, |
464 | 464 | ); |
465 | 465 | |
466 | - $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata ); |
|
466 | + $userdata = apply_filters('wpinv_register_new_user_data', $userdata); |
|
467 | 467 | |
468 | - $new_user_id = wp_insert_user( $userdata ); |
|
468 | + $new_user_id = wp_insert_user($userdata); |
|
469 | 469 | |
470 | - if ( !is_wp_error( $new_user_id ) ) { |
|
470 | + if (!is_wp_error($new_user_id)) { |
|
471 | 471 | $data['post_author'] = $new_user_id; |
472 | 472 | $_POST['post_author'] = $new_user_id; |
473 | 473 | $_POST['post_author_override'] = $new_user_id; |
@@ -488,72 +488,72 @@ discard block |
||
488 | 488 | |
489 | 489 | $meta = array(); |
490 | 490 | ///$meta['_wpinv_user_id'] = $new_user_id; |
491 | - foreach ( $meta_fields as $field ) { |
|
492 | - $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : ''; |
|
491 | + foreach ($meta_fields as $field) { |
|
492 | + $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : ''; |
|
493 | 493 | } |
494 | 494 | |
495 | - $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id ); |
|
495 | + $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id); |
|
496 | 496 | |
497 | 497 | // Update user meta. |
498 | - foreach ( $meta as $key => $value ) { |
|
499 | - update_user_meta( $new_user_id, $key, $value ); |
|
498 | + foreach ($meta as $key => $value) { |
|
499 | + update_user_meta($new_user_id, $key, $value); |
|
500 | 500 | } |
501 | 501 | |
502 | - if ( function_exists( 'wp_send_new_user_notifications' ) ) { |
|
502 | + if (function_exists('wp_send_new_user_notifications')) { |
|
503 | 503 | // Send email notifications related to the creation of new user. |
504 | - wp_send_new_user_notifications( $new_user_id, 'user' ); |
|
504 | + wp_send_new_user_notifications($new_user_id, 'user'); |
|
505 | 505 | } |
506 | 506 | } else { |
507 | - wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ ); |
|
507 | + wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__); |
|
508 | 508 | } |
509 | 509 | } |
510 | 510 | } |
511 | 511 | |
512 | 512 | return $data; |
513 | 513 | } |
514 | -add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 ); |
|
514 | +add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2); |
|
515 | 515 | |
516 | -function wpinv_show_recurring_supported_gateways( $item_ID ) { |
|
516 | +function wpinv_show_recurring_supported_gateways($item_ID) { |
|
517 | 517 | $all_gateways = wpinv_get_payment_gateways(); |
518 | 518 | |
519 | - if ( !empty( $all_gateways ) ) { |
|
519 | + if (!empty($all_gateways)) { |
|
520 | 520 | $gateways = array(); |
521 | 521 | |
522 | - foreach ( $all_gateways as $key => $gateway ) { |
|
523 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
522 | + foreach ($all_gateways as $key => $gateway) { |
|
523 | + if (wpinv_gateway_support_subscription($key)) { |
|
524 | 524 | $gateways[] = $gateway['admin_label']; |
525 | 525 | } |
526 | 526 | } |
527 | 527 | |
528 | - if ( !empty( $gateways ) ) { |
|
528 | + if (!empty($gateways)) { |
|
529 | 529 | ?> |
530 | - <span class="description"><?php echo wp_sprintf( __( 'Recurring payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ); ?></span> |
|
530 | + <span class="description"><?php echo wp_sprintf(__('Recurring payments only supported by: %s', 'invoicing'), implode(', ', $gateways)); ?></span> |
|
531 | 531 | <?php |
532 | 532 | } |
533 | 533 | } |
534 | 534 | } |
535 | -add_action( 'wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1 ); |
|
535 | +add_action('wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1); |
|
536 | 536 | |
537 | -function wpinv_post_updated_messages( $messages ) { |
|
537 | +function wpinv_post_updated_messages($messages) { |
|
538 | 538 | global $post, $post_ID; |
539 | 539 | |
540 | 540 | $messages['wpi_discount'] = array( |
541 | 541 | 0 => '', |
542 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
543 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
544 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
545 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
546 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
547 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
548 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
549 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
550 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
551 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
542 | + 1 => __('Discount updated.', 'invoicing'), |
|
543 | + 2 => __('Custom field updated.', 'invoicing'), |
|
544 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
545 | + 4 => __('Discount updated.', 'invoicing'), |
|
546 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
547 | + 6 => __('Discount updated.', 'invoicing'), |
|
548 | + 7 => __('Discount saved.', 'invoicing'), |
|
549 | + 8 => __('Discount submitted.', 'invoicing'), |
|
550 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
551 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
552 | 552 | ); |
553 | 553 | |
554 | 554 | return $messages; |
555 | 555 | } |
556 | -add_filter( 'post_updated_messages', 'wpinv_post_updated_messages', 10, 1 ); |
|
556 | +add_filter('post_updated_messages', 'wpinv_post_updated_messages', 10, 1); |
|
557 | 557 | |
558 | 558 | add_action('admin_init', 'admin_init_example_type'); |
559 | 559 | |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | function admin_init_example_type() { |
564 | 564 | global $typenow; |
565 | 565 | |
566 | - if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote' ) { |
|
566 | + if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote') { |
|
567 | 567 | add_filter('posts_search', 'posts_search_example_type', 10, 2); |
568 | 568 | } |
569 | 569 | } |
@@ -578,9 +578,9 @@ discard block |
||
578 | 578 | global $wpdb; |
579 | 579 | |
580 | 580 | if ($query->is_main_query() && !empty($query->query['s'])) { |
581 | - $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql( $query->query['s'] ) . "%' )"; |
|
582 | - if ( ! empty( $search ) ) { |
|
583 | - $search = preg_replace( '/^ AND /', '', $search ); |
|
581 | + $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql($query->query['s']) . "%' )"; |
|
582 | + if (!empty($search)) { |
|
583 | + $search = preg_replace('/^ AND /', '', $search); |
|
584 | 584 | $search = " AND ( {$search} OR ( {$conditions_str} ) )"; |
585 | 585 | } else { |
586 | 586 | $search = " AND ( {$conditions_str} )"; |
@@ -590,9 +590,9 @@ discard block |
||
590 | 590 | return $search; |
591 | 591 | } |
592 | 592 | |
593 | -add_action( 'admin_init', 'wpinv_reset_invoice_count' ); |
|
594 | -function wpinv_reset_invoice_count(){ |
|
595 | - if(isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) { |
|
593 | +add_action('admin_init', 'wpinv_reset_invoice_count'); |
|
594 | +function wpinv_reset_invoice_count() { |
|
595 | + if (isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) { |
|
596 | 596 | wpinv_update_option('invoice_sequence_start', 1); |
597 | 597 | delete_option('wpinv_last_invoice_number'); |
598 | 598 | $url = add_query_arg(array('reset_invoice_done' => 1)); |
@@ -603,8 +603,8 @@ discard block |
||
603 | 603 | } |
604 | 604 | |
605 | 605 | add_action('admin_notices', 'wpinv_invoice_count_reset_message'); |
606 | -function wpinv_invoice_count_reset_message(){ |
|
607 | - if(isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) { |
|
606 | +function wpinv_invoice_count_reset_message() { |
|
607 | + if (isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) { |
|
608 | 608 | $notice = __('Invoice number sequence reset successfully.', 'invoicing'); |
609 | 609 | ?> |
610 | 610 | <div class="notice notice-success is-dismissible"> |