@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -24,15 +24,15 @@ discard block |
||
24 | 24 | 'block-keywords'=> "['invoicing','history']", |
25 | 25 | 'class_name' => __CLASS__, |
26 | 26 | 'base_id' => 'wpinv_history', |
27 | - 'name' => __('Invoicing > Invoice History','invoicing'), |
|
27 | + 'name' => __('Invoicing > Invoice History', 'invoicing'), |
|
28 | 28 | 'widget_ops' => array( |
29 | 29 | 'classname' => 'wpinv-history-class', |
30 | - 'description' => esc_html__('Displays invoice history.','invoicing'), |
|
30 | + 'description' => esc_html__('Displays invoice history.', 'invoicing'), |
|
31 | 31 | ), |
32 | 32 | 'arguments' => array( |
33 | 33 | 'title' => array( |
34 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
35 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
34 | + 'title' => __('Widget title', 'invoicing'), |
|
35 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
36 | 36 | 'type' => 'text', |
37 | 37 | 'desc_tip' => true, |
38 | 38 | 'default' => '', |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | ); |
44 | 44 | |
45 | 45 | |
46 | - parent::__construct( $options ); |
|
46 | + parent::__construct($options); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return mixed|string|bool |
57 | 57 | */ |
58 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
58 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
59 | 59 | |
60 | 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 | 66 | $output = ob_get_clean(); |
67 | 67 | return trim($output); |
@@ -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', |
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 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -24,15 +24,15 @@ discard block |
||
24 | 24 | 'block-keywords'=> "['invoicing','checkout']", |
25 | 25 | 'class_name' => __CLASS__, |
26 | 26 | 'base_id' => 'wpinv_checkout', |
27 | - 'name' => __('Invoicing > Checkout','invoicing'), |
|
27 | + 'name' => __('Invoicing > Checkout', 'invoicing'), |
|
28 | 28 | 'widget_ops' => array( |
29 | 29 | 'classname' => 'wpinv-checkout-class', |
30 | - 'description' => esc_html__('Displays checkout form.','invoicing'), |
|
30 | + 'description' => esc_html__('Displays checkout form.', 'invoicing'), |
|
31 | 31 | ), |
32 | 32 | 'arguments' => array( |
33 | 33 | 'title' => array( |
34 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
35 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
34 | + 'title' => __('Widget title', 'invoicing'), |
|
35 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
36 | 36 | 'type' => 'text', |
37 | 37 | 'desc_tip' => true, |
38 | 38 | 'default' => '', |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | ); |
44 | 44 | |
45 | 45 | |
46 | - parent::__construct( $options ); |
|
46 | + parent::__construct($options); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return mixed|string|bool |
57 | 57 | */ |
58 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
58 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
59 | 59 | |
60 | 60 | return wpinv_checkout_form(); |
61 | 61 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -24,15 +24,15 @@ discard block |
||
24 | 24 | 'block-keywords'=> "['invoicing','subscriptions']", |
25 | 25 | 'class_name' => __CLASS__, |
26 | 26 | 'base_id' => 'wpinv_subscriptions', |
27 | - 'name' => __('Invoicing > Subscriptions History','invoicing'), |
|
27 | + 'name' => __('Invoicing > Subscriptions History', 'invoicing'), |
|
28 | 28 | 'widget_ops' => array( |
29 | 29 | 'classname' => 'wpinv-checkout-class', |
30 | - 'description' => esc_html__('Displays subscriptions history.','invoicing'), |
|
30 | + 'description' => esc_html__('Displays subscriptions history.', 'invoicing'), |
|
31 | 31 | ), |
32 | 32 | 'arguments' => array( |
33 | 33 | 'title' => array( |
34 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
35 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
34 | + 'title' => __('Widget title', 'invoicing'), |
|
35 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
36 | 36 | 'type' => 'text', |
37 | 37 | 'desc_tip' => true, |
38 | 38 | 'default' => '', |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | ); |
44 | 44 | |
45 | 45 | |
46 | - parent::__construct( $options ); |
|
46 | + parent::__construct($options); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return mixed|string|bool |
57 | 57 | */ |
58 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
58 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
59 | 59 | |
60 | 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 | 66 | $output = ob_get_clean(); |
67 | 67 | return trim($output); |
@@ -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', |
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); |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Setup menus in WP admin. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * WC_Admin_Menus Class. |
@@ -13,34 +13,34 @@ discard block |
||
13 | 13 | * Hook in tabs. |
14 | 14 | */ |
15 | 15 | public function __construct() { |
16 | - add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 ); |
|
17 | - add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 99 ); |
|
18 | - add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 ); |
|
19 | - add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) ); |
|
16 | + add_action('admin_menu', array($this, 'admin_menu'), 10); |
|
17 | + add_action('admin_menu', array($this, 'add_addons_menu'), 99); |
|
18 | + add_action('admin_menu', array($this, 'remove_admin_submenus'), 10); |
|
19 | + add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes')); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public function admin_menu() { |
23 | 23 | global $menu; |
24 | 24 | |
25 | - if ( !(current_user_can( 'manage_invoicing' ) || current_user_can( 'manage_options' )) ) { |
|
25 | + if (!(current_user_can('manage_invoicing') || current_user_can('manage_options'))) { |
|
26 | 26 | return; |
27 | 27 | } |
28 | 28 | |
29 | - $capability = apply_filters( 'invoicing_capability', 'manage_invoicing' ); |
|
29 | + $capability = apply_filters('invoicing_capability', 'manage_invoicing'); |
|
30 | 30 | |
31 | - if ( current_user_can( 'manage_options' ) ) { |
|
32 | - $menu[] = array( '', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv' ); |
|
31 | + if (current_user_can('manage_options')) { |
|
32 | + $menu[] = array('', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv'); |
|
33 | 33 | } |
34 | 34 | |
35 | - $wpi_invoice = get_post_type_object( 'wpi_invoice' ); |
|
35 | + $wpi_invoice = get_post_type_object('wpi_invoice'); |
|
36 | 36 | |
37 | - add_menu_page( __( 'Invoicing', 'invoicing' ), __( 'Invoicing', 'invoicing' ), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460' ); |
|
37 | + add_menu_page(__('Invoicing', 'invoicing'), __('Invoicing', 'invoicing'), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460'); |
|
38 | 38 | |
39 | - add_submenu_page( 'wpinv', __( 'Invoice Settings', 'invoicing' ), __( 'Settings', 'invoicing' ), $capability, 'wpinv-settings', array( $this, 'options_page' )); |
|
39 | + add_submenu_page('wpinv', __('Invoice Settings', 'invoicing'), __('Settings', 'invoicing'), $capability, 'wpinv-settings', array($this, 'options_page')); |
|
40 | 40 | } |
41 | 41 | |
42 | - public function add_addons_menu(){ |
|
43 | - if ( !apply_filters( 'wpi_show_addons_page', true ) ) { |
|
42 | + public function add_addons_menu() { |
|
43 | + if (!apply_filters('wpi_show_addons_page', true)) { |
|
44 | 44 | return; |
45 | 45 | } |
46 | 46 | |
@@ -50,78 +50,78 @@ discard block |
||
50 | 50 | __('Extensions', 'invoicing'), |
51 | 51 | 'manage_options', |
52 | 52 | 'wpi-addons', |
53 | - array( $this, 'addons_page' ) |
|
53 | + array($this, 'addons_page') |
|
54 | 54 | ); |
55 | 55 | } |
56 | 56 | |
57 | - public function addons_page(){ |
|
57 | + public function addons_page() { |
|
58 | 58 | $addon_obj = new WPInv_Admin_Addons(); |
59 | 59 | $addon_obj->output(); |
60 | 60 | } |
61 | 61 | |
62 | 62 | function options_page() { |
63 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
63 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
64 | 64 | |
65 | - if ( $page !== 'wpinv-settings' ) { |
|
65 | + if ($page !== 'wpinv-settings') { |
|
66 | 66 | return; |
67 | 67 | } |
68 | 68 | |
69 | 69 | $settings_tabs = wpinv_get_settings_tabs(); |
70 | 70 | $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs; |
71 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; |
|
72 | - $sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
71 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general'; |
|
72 | + $sections = wpinv_get_settings_tab_sections($active_tab); |
|
73 | 73 | $key = 'main'; |
74 | 74 | |
75 | - if ( is_array( $sections ) ) { |
|
76 | - $key = key( $sections ); |
|
75 | + if (is_array($sections)) { |
|
76 | + $key = key($sections); |
|
77 | 77 | } |
78 | 78 | |
79 | - $registered_sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
80 | - $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key; |
|
79 | + $registered_sections = wpinv_get_settings_tab_sections($active_tab); |
|
80 | + $section = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key; |
|
81 | 81 | ob_start(); |
82 | 82 | ?> |
83 | 83 | <div class="wrap"> |
84 | 84 | <h1 class="nav-tab-wrapper"> |
85 | 85 | <?php |
86 | - foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) { |
|
87 | - $tab_url = add_query_arg( array( |
|
86 | + foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) { |
|
87 | + $tab_url = add_query_arg(array( |
|
88 | 88 | 'settings-updated' => false, |
89 | 89 | 'tab' => $tab_id, |
90 | - ) ); |
|
90 | + )); |
|
91 | 91 | |
92 | 92 | // Remove the section from the tabs so we always end up at the main section |
93 | - $tab_url = remove_query_arg( 'section', $tab_url ); |
|
94 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
93 | + $tab_url = remove_query_arg('section', $tab_url); |
|
94 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
95 | 95 | |
96 | 96 | $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
97 | 97 | |
98 | - echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">'; |
|
99 | - echo esc_html( $tab_name ); |
|
98 | + echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">'; |
|
99 | + echo esc_html($tab_name); |
|
100 | 100 | echo '</a>'; |
101 | 101 | } |
102 | 102 | ?> |
103 | 103 | </h1> |
104 | 104 | <?php |
105 | - $number_of_sections = count( $sections ); |
|
105 | + $number_of_sections = count($sections); |
|
106 | 106 | $number = 0; |
107 | - if ( $number_of_sections > 1 ) { |
|
107 | + if ($number_of_sections > 1) { |
|
108 | 108 | echo '<div><ul class="subsubsub">'; |
109 | - foreach( $sections as $section_id => $section_name ) { |
|
109 | + foreach ($sections as $section_id => $section_name) { |
|
110 | 110 | echo '<li>'; |
111 | 111 | $number++; |
112 | - $tab_url = add_query_arg( array( |
|
112 | + $tab_url = add_query_arg(array( |
|
113 | 113 | 'settings-updated' => false, |
114 | 114 | 'tab' => $active_tab, |
115 | 115 | 'section' => $section_id |
116 | - ) ); |
|
117 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
116 | + )); |
|
117 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
118 | 118 | $class = ''; |
119 | - if ( $section == $section_id ) { |
|
119 | + if ($section == $section_id) { |
|
120 | 120 | $class = 'current'; |
121 | 121 | } |
122 | - echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>'; |
|
122 | + echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>'; |
|
123 | 123 | |
124 | - if ( $number != $number_of_sections ) { |
|
124 | + if ($number != $number_of_sections) { |
|
125 | 125 | echo ' | '; |
126 | 126 | } |
127 | 127 | echo '</li>'; |
@@ -133,19 +133,19 @@ discard block |
||
133 | 133 | <form method="post" action="options.php"> |
134 | 134 | <table class="form-table"> |
135 | 135 | <?php |
136 | - settings_fields( 'wpinv_settings' ); |
|
136 | + settings_fields('wpinv_settings'); |
|
137 | 137 | |
138 | - if ( 'main' === $section ) { |
|
139 | - do_action( 'wpinv_settings_tab_top', $active_tab ); |
|
138 | + if ('main' === $section) { |
|
139 | + do_action('wpinv_settings_tab_top', $active_tab); |
|
140 | 140 | } |
141 | 141 | |
142 | - do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
143 | - do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
144 | - do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
142 | + do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section); |
|
143 | + do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section); |
|
144 | + do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section); |
|
145 | 145 | |
146 | 146 | // For backwards compatibility |
147 | - if ( 'main' === $section ) { |
|
148 | - do_action( 'wpinv_settings_tab_bottom', $active_tab ); |
|
147 | + if ('main' === $section) { |
|
148 | + do_action('wpinv_settings_tab_bottom', $active_tab); |
|
149 | 149 | } |
150 | 150 | ?> |
151 | 151 | </table> |
@@ -159,52 +159,52 @@ discard block |
||
159 | 159 | } |
160 | 160 | |
161 | 161 | public function remove_admin_submenus() { |
162 | - remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' ); |
|
162 | + remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice'); |
|
163 | 163 | } |
164 | 164 | |
165 | - public function add_nav_menu_meta_boxes(){ |
|
166 | - add_meta_box( 'wpinv_endpoints_nav_link', __( 'Invoicing Pages', 'invoicing' ), array( $this, 'nav_menu_links' ), 'nav-menus', 'side', 'low' ); |
|
165 | + public function add_nav_menu_meta_boxes() { |
|
166 | + add_meta_box('wpinv_endpoints_nav_link', __('Invoicing Pages', 'invoicing'), array($this, 'nav_menu_links'), 'nav-menus', 'side', 'low'); |
|
167 | 167 | } |
168 | 168 | |
169 | - public function nav_menu_links(){ |
|
169 | + public function nav_menu_links() { |
|
170 | 170 | $endpoints = $this->get_menu_items(); |
171 | 171 | ?> |
172 | 172 | <div id="invoicing-endpoints" class="posttypediv"> |
173 | - <?php if(!empty($endpoints['pages'])){ ?> |
|
173 | + <?php if (!empty($endpoints['pages'])) { ?> |
|
174 | 174 | <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active"> |
175 | 175 | <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear"> |
176 | 176 | <?php |
177 | 177 | $walker = new Walker_Nav_Menu_Checklist(array()); |
178 | - echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker)); |
|
178 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object)array('walker' => $walker)); |
|
179 | 179 | ?> |
180 | 180 | </ul> |
181 | 181 | </div> |
182 | 182 | <?php } ?> |
183 | 183 | <p class="button-controls"> |
184 | 184 | <span class="list-controls"> |
185 | - <a href="<?php echo admin_url( 'nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints' ); ?>" class="select-all"><?php _e( 'Select all', 'invoicing' ); ?></a> |
|
185 | + <a href="<?php echo admin_url('nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints'); ?>" class="select-all"><?php _e('Select all', 'invoicing'); ?></a> |
|
186 | 186 | </span> |
187 | 187 | <span class="add-to-menu"> |
188 | - <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints"> |
|
188 | + <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints"> |
|
189 | 189 | <span class="spinner"></span> |
190 | 190 | </span> |
191 | 191 | </p> |
192 | 192 | <?php |
193 | 193 | } |
194 | 194 | |
195 | - public function get_menu_items(){ |
|
195 | + public function get_menu_items() { |
|
196 | 196 | $items = array(); |
197 | 197 | |
198 | - $wpinv_history_page_id = (int)wpinv_get_option( 'invoice_history_page' ); |
|
199 | - if($wpinv_history_page_id > 0){ |
|
198 | + $wpinv_history_page_id = (int)wpinv_get_option('invoice_history_page'); |
|
199 | + if ($wpinv_history_page_id > 0) { |
|
200 | 200 | $item = new stdClass(); |
201 | 201 | $item->object_id = $wpinv_history_page_id; |
202 | 202 | $item->db_id = 0; |
203 | - $item->object = 'page'; |
|
203 | + $item->object = 'page'; |
|
204 | 204 | $item->menu_item_parent = 0; |
205 | 205 | $item->type = 'post_type'; |
206 | - $item->title = __('Invoice History Page','invoicing'); |
|
207 | - $item->url = get_permalink( $wpinv_history_page_id ); |
|
206 | + $item->title = __('Invoice History Page', 'invoicing'); |
|
207 | + $item->url = get_permalink($wpinv_history_page_id); |
|
208 | 208 | $item->target = ''; |
209 | 209 | $item->attr_title = ''; |
210 | 210 | $item->classes = array('wpinv-menu-item'); |
@@ -213,16 +213,16 @@ discard block |
||
213 | 213 | $items['pages'][] = $item; |
214 | 214 | } |
215 | 215 | |
216 | - $wpinv_sub_history_page_id = (int)wpinv_get_option( 'invoice_subscription_page' ); |
|
217 | - if($wpinv_sub_history_page_id > 0){ |
|
216 | + $wpinv_sub_history_page_id = (int)wpinv_get_option('invoice_subscription_page'); |
|
217 | + if ($wpinv_sub_history_page_id > 0) { |
|
218 | 218 | $item = new stdClass(); |
219 | 219 | $item->object_id = $wpinv_sub_history_page_id; |
220 | 220 | $item->db_id = 0; |
221 | - $item->object = 'page'; |
|
221 | + $item->object = 'page'; |
|
222 | 222 | $item->menu_item_parent = 0; |
223 | 223 | $item->type = 'post_type'; |
224 | - $item->title = __('Invoice Subscriptions Page','invoicing'); |
|
225 | - $item->url = get_permalink( $wpinv_sub_history_page_id ); |
|
224 | + $item->title = __('Invoice Subscriptions Page', 'invoicing'); |
|
225 | + $item->url = get_permalink($wpinv_sub_history_page_id); |
|
226 | 226 | $item->target = ''; |
227 | 227 | $item->attr_title = ''; |
228 | 228 | $item->classes = array('wpinv-menu-item'); |
@@ -231,16 +231,16 @@ discard block |
||
231 | 231 | $items['pages'][] = $item; |
232 | 232 | } |
233 | 233 | |
234 | - $wpinv_checkout_page_id = (int)wpinv_get_option( 'checkout_page' ); |
|
235 | - if($wpinv_checkout_page_id > 0){ |
|
234 | + $wpinv_checkout_page_id = (int)wpinv_get_option('checkout_page'); |
|
235 | + if ($wpinv_checkout_page_id > 0) { |
|
236 | 236 | $item = new stdClass(); |
237 | 237 | $item->object_id = $wpinv_checkout_page_id; |
238 | 238 | $item->db_id = 0; |
239 | - $item->object = 'page'; |
|
239 | + $item->object = 'page'; |
|
240 | 240 | $item->menu_item_parent = 0; |
241 | 241 | $item->type = 'post_type'; |
242 | - $item->title = __('Checkout Page','invoicing'); |
|
243 | - $item->url = get_permalink( $wpinv_checkout_page_id ); |
|
242 | + $item->title = __('Checkout Page', 'invoicing'); |
|
243 | + $item->url = get_permalink($wpinv_checkout_page_id); |
|
244 | 244 | $item->target = ''; |
245 | 245 | $item->attr_title = ''; |
246 | 246 | $item->classes = array('wpinv-menu-item'); |
@@ -249,16 +249,16 @@ discard block |
||
249 | 249 | $items['pages'][] = $item; |
250 | 250 | } |
251 | 251 | |
252 | - $wpinv_tandc_page_id = (int)wpinv_get_option( 'tandc_page' ); |
|
253 | - if($wpinv_tandc_page_id > 0){ |
|
252 | + $wpinv_tandc_page_id = (int)wpinv_get_option('tandc_page'); |
|
253 | + if ($wpinv_tandc_page_id > 0) { |
|
254 | 254 | $item = new stdClass(); |
255 | 255 | $item->object_id = $wpinv_tandc_page_id; |
256 | 256 | $item->db_id = 0; |
257 | - $item->object = 'page'; |
|
257 | + $item->object = 'page'; |
|
258 | 258 | $item->menu_item_parent = 0; |
259 | 259 | $item->type = 'post_type'; |
260 | - $item->title = __('Terms & Conditions','invoicing'); |
|
261 | - $item->url = get_permalink( $wpinv_tandc_page_id ); |
|
260 | + $item->title = __('Terms & Conditions', 'invoicing'); |
|
261 | + $item->url = get_permalink($wpinv_tandc_page_id); |
|
262 | 262 | $item->target = ''; |
263 | 263 | $item->attr_title = ''; |
264 | 264 | $item->classes = array('wpinv-menu-item'); |
@@ -267,16 +267,16 @@ discard block |
||
267 | 267 | $items['pages'][] = $item; |
268 | 268 | } |
269 | 269 | |
270 | - $wpinv_success_page_id = (int)wpinv_get_option( 'success_page' ); |
|
271 | - if($wpinv_success_page_id > 0){ |
|
270 | + $wpinv_success_page_id = (int)wpinv_get_option('success_page'); |
|
271 | + if ($wpinv_success_page_id > 0) { |
|
272 | 272 | $item = new stdClass(); |
273 | 273 | $item->object_id = $wpinv_success_page_id; |
274 | 274 | $item->db_id = 0; |
275 | - $item->object = 'page'; |
|
275 | + $item->object = 'page'; |
|
276 | 276 | $item->menu_item_parent = 0; |
277 | 277 | $item->type = 'post_type'; |
278 | - $item->title = __('Success Page','invoicing'); |
|
279 | - $item->url = get_permalink( $wpinv_success_page_id ); |
|
278 | + $item->title = __('Success Page', 'invoicing'); |
|
279 | + $item->url = get_permalink($wpinv_success_page_id); |
|
280 | 280 | $item->target = ''; |
281 | 281 | $item->attr_title = ''; |
282 | 282 | $item->classes = array('wpinv-menu-item'); |
@@ -285,16 +285,16 @@ discard block |
||
285 | 285 | $items['pages'][] = $item; |
286 | 286 | } |
287 | 287 | |
288 | - $wpinv_failure_page_id = (int)wpinv_get_option( 'failure_page' ); |
|
289 | - if($wpinv_failure_page_id > 0){ |
|
288 | + $wpinv_failure_page_id = (int)wpinv_get_option('failure_page'); |
|
289 | + if ($wpinv_failure_page_id > 0) { |
|
290 | 290 | $item = new stdClass(); |
291 | 291 | $item->object_id = $wpinv_failure_page_id; |
292 | 292 | $item->db_id = 0; |
293 | - $item->object = 'page'; |
|
293 | + $item->object = 'page'; |
|
294 | 294 | $item->menu_item_parent = 0; |
295 | 295 | $item->type = 'post_type'; |
296 | - $item->title = __('Failed Transaction Page','invoicing'); |
|
297 | - $item->url = get_permalink( $wpinv_failure_page_id ); |
|
296 | + $item->title = __('Failed Transaction Page', 'invoicing'); |
|
297 | + $item->url = get_permalink($wpinv_failure_page_id); |
|
298 | 298 | $item->target = ''; |
299 | 299 | $item->attr_title = ''; |
300 | 300 | $item->classes = array('wpinv-menu-item'); |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | $items['pages'][] = $item; |
304 | 304 | } |
305 | 305 | |
306 | - return apply_filters( 'wpinv_menu_items', $items ); |
|
306 | + return apply_filters('wpinv_menu_items', $items); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | } |
@@ -7,91 +7,91 @@ 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 | -if ( !is_admin() ) { |
|
15 | - add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
16 | - add_action( 'wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar' ); |
|
17 | - add_action( 'wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions' ); |
|
18 | - add_action( 'wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions' ); |
|
14 | +if (!is_admin()) { |
|
15 | + add_filter('template_include', 'wpinv_template', 10, 1); |
|
16 | + add_action('wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar'); |
|
17 | + add_action('wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions'); |
|
18 | + add_action('wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions'); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | function wpinv_template_path() { |
22 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
22 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
23 | 23 | } |
24 | 24 | |
25 | -function wpinv_display_invoice_top_bar( $invoice ) { |
|
26 | - if ( empty( $invoice ) ) { |
|
25 | +function wpinv_display_invoice_top_bar($invoice) { |
|
26 | + if (empty($invoice)) { |
|
27 | 27 | return; |
28 | 28 | } |
29 | 29 | ?> |
30 | 30 | <div class="row wpinv-top-bar no-print"> |
31 | 31 | <div class="container"> |
32 | 32 | <div class="col-xs-6"> |
33 | - <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?> |
|
33 | + <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?> |
|
34 | 34 | </div> |
35 | 35 | <div class="col-xs-6 text-right"> |
36 | - <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?> |
|
36 | + <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?> |
|
37 | 37 | </div> |
38 | 38 | </div> |
39 | 39 | </div> |
40 | 40 | <?php |
41 | 41 | } |
42 | 42 | |
43 | -function wpinv_invoice_display_left_actions( $invoice ) { |
|
44 | - if ( empty( $invoice ) ) { |
|
43 | +function wpinv_invoice_display_left_actions($invoice) { |
|
44 | + if (empty($invoice)) { |
|
45 | 45 | return; // Exit if invoice is not set. |
46 | 46 | } |
47 | 47 | |
48 | - if ( $invoice->post_type == 'wpi_invoice' ) { |
|
49 | - if ( $invoice->needs_payment() ) { |
|
50 | - ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e( 'Pay This Invoice', 'invoicing' ); ?>" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"><?php _e( 'Pay For Invoice', 'invoicing' ); ?></a><?php |
|
48 | + if ($invoice->post_type == 'wpi_invoice') { |
|
49 | + if ($invoice->needs_payment()) { |
|
50 | + ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e('Pay This Invoice', 'invoicing'); ?>" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"><?php _e('Pay For Invoice', 'invoicing'); ?></a><?php |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | do_action('wpinv_invoice_display_left_actions', $invoice); |
54 | 54 | } |
55 | 55 | |
56 | -function wpinv_invoice_display_right_actions( $invoice ) { |
|
57 | - if ( empty( $invoice ) ) { |
|
56 | +function wpinv_invoice_display_right_actions($invoice) { |
|
57 | + if (empty($invoice)) { |
|
58 | 58 | return; // Exit if invoice is not set. |
59 | 59 | } |
60 | 60 | |
61 | - if ( $invoice->post_type == 'wpi_invoice' ) { ?> |
|
62 | - <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a> |
|
63 | - <?php if ( is_user_logged_in() ) { ?> |
|
64 | - <a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a> |
|
61 | + if ($invoice->post_type == 'wpi_invoice') { ?> |
|
62 | + <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a> |
|
63 | + <?php if (is_user_logged_in()) { ?> |
|
64 | + <a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a> |
|
65 | 65 | <?php } |
66 | 66 | } |
67 | 67 | do_action('wpinv_invoice_display_right_actions', $invoice); |
68 | 68 | } |
69 | 69 | |
70 | -function wpinv_before_invoice_content( $content ) { |
|
70 | +function wpinv_before_invoice_content($content) { |
|
71 | 71 | global $post; |
72 | 72 | |
73 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
73 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
74 | 74 | ob_start(); |
75 | - do_action( 'wpinv_before_invoice_content', $post->ID ); |
|
75 | + do_action('wpinv_before_invoice_content', $post->ID); |
|
76 | 76 | $content = ob_get_clean() . $content; |
77 | 77 | } |
78 | 78 | |
79 | 79 | return $content; |
80 | 80 | } |
81 | -add_filter( 'the_content', 'wpinv_before_invoice_content' ); |
|
81 | +add_filter('the_content', 'wpinv_before_invoice_content'); |
|
82 | 82 | |
83 | -function wpinv_after_invoice_content( $content ) { |
|
83 | +function wpinv_after_invoice_content($content) { |
|
84 | 84 | global $post; |
85 | 85 | |
86 | - if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) { |
|
86 | + if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) { |
|
87 | 87 | ob_start(); |
88 | - do_action( 'wpinv_after_invoice_content', $post->ID ); |
|
88 | + do_action('wpinv_after_invoice_content', $post->ID); |
|
89 | 89 | $content .= ob_get_clean(); |
90 | 90 | } |
91 | 91 | |
92 | 92 | return $content; |
93 | 93 | } |
94 | -add_filter( 'the_content', 'wpinv_after_invoice_content' ); |
|
94 | +add_filter('the_content', 'wpinv_after_invoice_content'); |
|
95 | 95 | |
96 | 96 | function wpinv_get_templates_dir() { |
97 | 97 | return WPINV_PLUGIN_DIR . 'templates'; |
@@ -101,105 +101,105 @@ discard block |
||
101 | 101 | return WPINV_PLUGIN_URL . 'templates'; |
102 | 102 | } |
103 | 103 | |
104 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
105 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
106 | - extract( $args ); |
|
104 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
105 | + if (!empty($args) && is_array($args)) { |
|
106 | + extract($args); |
|
107 | 107 | } |
108 | 108 | |
109 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
109 | + $located = wpinv_locate_template($template_name, $template_path, $default_path); |
|
110 | 110 | // Allow 3rd party plugin filter template file from their plugin. |
111 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
111 | + $located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
112 | 112 | |
113 | - if ( ! file_exists( $located ) ) { |
|
114 | - _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
|
113 | + if (!file_exists($located)) { |
|
114 | + _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1'); |
|
115 | 115 | return; |
116 | 116 | } |
117 | 117 | |
118 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
118 | + do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args); |
|
119 | 119 | |
120 | - include( $located ); |
|
120 | + include($located); |
|
121 | 121 | |
122 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
122 | + do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args); |
|
123 | 123 | } |
124 | 124 | |
125 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
125 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
126 | 126 | ob_start(); |
127 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
127 | + wpinv_get_template($template_name, $args, $template_path, $default_path); |
|
128 | 128 | return ob_get_clean(); |
129 | 129 | } |
130 | 130 | |
131 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
132 | - if ( ! $template_path ) { |
|
131 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
132 | + if (!$template_path) { |
|
133 | 133 | $template_path = wpinv_template_path(); |
134 | 134 | } |
135 | 135 | |
136 | - if ( ! $default_path ) { |
|
136 | + if (!$default_path) { |
|
137 | 137 | $default_path = WPINV_PLUGIN_DIR . 'templates/'; |
138 | 138 | } |
139 | 139 | |
140 | 140 | // Look within passed path within the theme - this is priority. |
141 | 141 | $template = locate_template( |
142 | 142 | array( |
143 | - trailingslashit( $template_path ) . $template_name, |
|
143 | + trailingslashit($template_path) . $template_name, |
|
144 | 144 | $template_name |
145 | 145 | ) |
146 | 146 | ); |
147 | 147 | |
148 | 148 | // Get default templates/ |
149 | - if ( !$template && $default_path ) { |
|
150 | - $template = trailingslashit( $default_path ) . $template_name; |
|
149 | + if (!$template && $default_path) { |
|
150 | + $template = trailingslashit($default_path) . $template_name; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // Return what we found. |
154 | - return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path ); |
|
154 | + return apply_filters('wpinv_locate_template', $template, $template_name, $template_path); |
|
155 | 155 | } |
156 | 156 | |
157 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
158 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
157 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
158 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
159 | 159 | |
160 | 160 | // Setup possible parts |
161 | 161 | $templates = array(); |
162 | - if ( isset( $name ) ) |
|
162 | + if (isset($name)) |
|
163 | 163 | $templates[] = $slug . '-' . $name . '.php'; |
164 | 164 | $templates[] = $slug . '.php'; |
165 | 165 | |
166 | 166 | // Allow template parts to be filtered |
167 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
167 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
168 | 168 | |
169 | 169 | // Return the part that is found |
170 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
170 | + return wpinv_locate_tmpl($templates, $load, false); |
|
171 | 171 | } |
172 | 172 | |
173 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
173 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
174 | 174 | // No file found yet |
175 | 175 | $located = false; |
176 | 176 | |
177 | 177 | // Try to find a template file |
178 | - foreach ( (array)$template_names as $template_name ) { |
|
178 | + foreach ((array)$template_names as $template_name) { |
|
179 | 179 | |
180 | 180 | // Continue if template is empty |
181 | - if ( empty( $template_name ) ) |
|
181 | + if (empty($template_name)) |
|
182 | 182 | continue; |
183 | 183 | |
184 | 184 | // Trim off any slashes from the template name |
185 | - $template_name = ltrim( $template_name, '/' ); |
|
185 | + $template_name = ltrim($template_name, '/'); |
|
186 | 186 | |
187 | 187 | // try locating this template file by looping through the template paths |
188 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
188 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
189 | 189 | |
190 | - if( file_exists( $template_path . $template_name ) ) { |
|
190 | + if (file_exists($template_path . $template_name)) { |
|
191 | 191 | $located = $template_path . $template_name; |
192 | 192 | break; |
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
196 | - if( !empty( $located ) ) { |
|
196 | + if (!empty($located)) { |
|
197 | 197 | break; |
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
201 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
202 | - load_template( $located, $require_once ); |
|
201 | + if ((true == $load) && !empty($located)) |
|
202 | + load_template($located, $require_once); |
|
203 | 203 | |
204 | 204 | return $located; |
205 | 205 | } |
@@ -208,149 +208,149 @@ discard block |
||
208 | 208 | $template_dir = wpinv_get_theme_template_dir_name(); |
209 | 209 | |
210 | 210 | $file_paths = array( |
211 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
212 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
211 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
212 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
213 | 213 | 100 => wpinv_get_templates_dir() |
214 | 214 | ); |
215 | 215 | |
216 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
216 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
217 | 217 | |
218 | 218 | // sort the file paths based on priority |
219 | - ksort( $file_paths, SORT_NUMERIC ); |
|
219 | + ksort($file_paths, SORT_NUMERIC); |
|
220 | 220 | |
221 | - return array_map( 'trailingslashit', $file_paths ); |
|
221 | + return array_map('trailingslashit', $file_paths); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | function wpinv_get_theme_template_dir_name() { |
225 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
225 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | function wpinv_checkout_meta_tags() { |
229 | 229 | |
230 | 230 | $pages = array(); |
231 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
232 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
233 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
234 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
231 | + $pages[] = wpinv_get_option('success_page'); |
|
232 | + $pages[] = wpinv_get_option('failure_page'); |
|
233 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
234 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
235 | 235 | |
236 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
236 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
237 | 237 | return; |
238 | 238 | } |
239 | 239 | |
240 | 240 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
241 | 241 | } |
242 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
242 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
243 | 243 | |
244 | -function wpinv_add_body_classes( $class ) { |
|
244 | +function wpinv_add_body_classes($class) { |
|
245 | 245 | $classes = (array)$class; |
246 | 246 | |
247 | - if( wpinv_is_checkout() ) { |
|
247 | + if (wpinv_is_checkout()) { |
|
248 | 248 | $classes[] = 'wpinv-checkout'; |
249 | 249 | $classes[] = 'wpinv-page'; |
250 | 250 | } |
251 | 251 | |
252 | - if( wpinv_is_success_page() ) { |
|
252 | + if (wpinv_is_success_page()) { |
|
253 | 253 | $classes[] = 'wpinv-success'; |
254 | 254 | $classes[] = 'wpinv-page'; |
255 | 255 | } |
256 | 256 | |
257 | - if( wpinv_is_failed_transaction_page() ) { |
|
257 | + if (wpinv_is_failed_transaction_page()) { |
|
258 | 258 | $classes[] = 'wpinv-failed-transaction'; |
259 | 259 | $classes[] = 'wpinv-page'; |
260 | 260 | } |
261 | 261 | |
262 | - if( wpinv_is_invoice_history_page() ) { |
|
262 | + if (wpinv_is_invoice_history_page()) { |
|
263 | 263 | $classes[] = 'wpinv-history'; |
264 | 264 | $classes[] = 'wpinv-page'; |
265 | 265 | } |
266 | 266 | |
267 | - if( wpinv_is_subscriptions_history_page() ) { |
|
267 | + if (wpinv_is_subscriptions_history_page()) { |
|
268 | 268 | $classes[] = 'wpinv-subscription'; |
269 | 269 | $classes[] = 'wpinv-page'; |
270 | 270 | } |
271 | 271 | |
272 | - if( wpinv_is_test_mode() ) { |
|
272 | + if (wpinv_is_test_mode()) { |
|
273 | 273 | $classes[] = 'wpinv-test-mode'; |
274 | 274 | $classes[] = 'wpinv-page'; |
275 | 275 | } |
276 | 276 | |
277 | - return array_unique( $classes ); |
|
277 | + return array_unique($classes); |
|
278 | 278 | } |
279 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
279 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
280 | 280 | |
281 | -function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) { |
|
282 | - $args = array( 'nopaging' => true ); |
|
281 | +function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') { |
|
282 | + $args = array('nopaging' => true); |
|
283 | 283 | |
284 | - if ( ! empty( $status ) ) |
|
284 | + if (!empty($status)) |
|
285 | 285 | $args['post_status'] = $status; |
286 | 286 | |
287 | - $discounts = wpinv_get_discounts( $args ); |
|
287 | + $discounts = wpinv_get_discounts($args); |
|
288 | 288 | $options = array(); |
289 | 289 | |
290 | - if ( $discounts ) { |
|
291 | - foreach ( $discounts as $discount ) { |
|
292 | - $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) ); |
|
290 | + if ($discounts) { |
|
291 | + foreach ($discounts as $discount) { |
|
292 | + $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID)); |
|
293 | 293 | } |
294 | 294 | } else { |
295 | - $options[0] = __( 'No discounts found', 'invoicing' ); |
|
295 | + $options[0] = __('No discounts found', 'invoicing'); |
|
296 | 296 | } |
297 | 297 | |
298 | - $output = wpinv_html_select( array( |
|
298 | + $output = wpinv_html_select(array( |
|
299 | 299 | 'name' => $name, |
300 | 300 | 'selected' => $selected, |
301 | 301 | 'options' => $options, |
302 | 302 | 'show_option_all' => false, |
303 | 303 | 'show_option_none' => false, |
304 | - ) ); |
|
304 | + )); |
|
305 | 305 | |
306 | 306 | return $output; |
307 | 307 | } |
308 | 308 | |
309 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
310 | - $current = date( 'Y' ); |
|
311 | - $start_year = $current - absint( $years_before ); |
|
312 | - $end_year = $current + absint( $years_after ); |
|
313 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
309 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
310 | + $current = date('Y'); |
|
311 | + $start_year = $current - absint($years_before); |
|
312 | + $end_year = $current + absint($years_after); |
|
313 | + $selected = empty($selected) ? date('Y') : $selected; |
|
314 | 314 | $options = array(); |
315 | 315 | |
316 | - while ( $start_year <= $end_year ) { |
|
317 | - $options[ absint( $start_year ) ] = $start_year; |
|
316 | + while ($start_year <= $end_year) { |
|
317 | + $options[absint($start_year)] = $start_year; |
|
318 | 318 | $start_year++; |
319 | 319 | } |
320 | 320 | |
321 | - $output = wpinv_html_select( array( |
|
321 | + $output = wpinv_html_select(array( |
|
322 | 322 | 'name' => $name, |
323 | 323 | 'selected' => $selected, |
324 | 324 | 'options' => $options, |
325 | 325 | 'show_option_all' => false, |
326 | 326 | 'show_option_none' => false |
327 | - ) ); |
|
327 | + )); |
|
328 | 328 | |
329 | 329 | return $output; |
330 | 330 | } |
331 | 331 | |
332 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
332 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
333 | 333 | $month = 1; |
334 | 334 | $options = array(); |
335 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
335 | + $selected = empty($selected) ? date('n') : $selected; |
|
336 | 336 | |
337 | - while ( $month <= 12 ) { |
|
338 | - $options[ absint( $month ) ] = wpinv_month_num_to_name( $month ); |
|
337 | + while ($month <= 12) { |
|
338 | + $options[absint($month)] = wpinv_month_num_to_name($month); |
|
339 | 339 | $month++; |
340 | 340 | } |
341 | 341 | |
342 | - $output = wpinv_html_select( array( |
|
342 | + $output = wpinv_html_select(array( |
|
343 | 343 | 'name' => $name, |
344 | 344 | 'selected' => $selected, |
345 | 345 | 'options' => $options, |
346 | 346 | 'show_option_all' => false, |
347 | 347 | 'show_option_none' => false |
348 | - ) ); |
|
348 | + )); |
|
349 | 349 | |
350 | 350 | return $output; |
351 | 351 | } |
352 | 352 | |
353 | -function wpinv_html_select( $args = array() ) { |
|
353 | +function wpinv_html_select($args = array()) { |
|
354 | 354 | $defaults = array( |
355 | 355 | 'options' => array(), |
356 | 356 | 'name' => null, |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | 'selected' => 0, |
360 | 360 | 'placeholder' => null, |
361 | 361 | 'multiple' => false, |
362 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
363 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
362 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
363 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
364 | 364 | 'data' => array(), |
365 | 365 | 'onchange' => null, |
366 | 366 | 'required' => false, |
@@ -368,74 +368,74 @@ discard block |
||
368 | 368 | 'readonly' => false, |
369 | 369 | ); |
370 | 370 | |
371 | - $args = wp_parse_args( $args, $defaults ); |
|
371 | + $args = wp_parse_args($args, $defaults); |
|
372 | 372 | |
373 | 373 | $data_elements = ''; |
374 | - foreach ( $args['data'] as $key => $value ) { |
|
375 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
374 | + foreach ($args['data'] as $key => $value) { |
|
375 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
376 | 376 | } |
377 | 377 | |
378 | - if( $args['multiple'] ) { |
|
378 | + if ($args['multiple']) { |
|
379 | 379 | $multiple = ' MULTIPLE'; |
380 | 380 | } else { |
381 | 381 | $multiple = ''; |
382 | 382 | } |
383 | 383 | |
384 | - if( $args['placeholder'] ) { |
|
384 | + if ($args['placeholder']) { |
|
385 | 385 | $placeholder = $args['placeholder']; |
386 | 386 | } else { |
387 | 387 | $placeholder = ''; |
388 | 388 | } |
389 | 389 | |
390 | 390 | $options = ''; |
391 | - if( !empty( $args['onchange'] ) ) { |
|
392 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
391 | + if (!empty($args['onchange'])) { |
|
392 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
393 | 393 | } |
394 | 394 | |
395 | - if( !empty( $args['required'] ) ) { |
|
395 | + if (!empty($args['required'])) { |
|
396 | 396 | $options .= ' required="required"'; |
397 | 397 | } |
398 | 398 | |
399 | - if( !empty( $args['disabled'] ) ) { |
|
399 | + if (!empty($args['disabled'])) { |
|
400 | 400 | $options .= ' disabled'; |
401 | 401 | } |
402 | 402 | |
403 | - if( !empty( $args['readonly'] ) ) { |
|
403 | + if (!empty($args['readonly'])) { |
|
404 | 404 | $options .= ' readonly'; |
405 | 405 | } |
406 | 406 | |
407 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
408 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
407 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
408 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
409 | 409 | |
410 | - if ( $args['show_option_all'] ) { |
|
411 | - if( $args['multiple'] ) { |
|
412 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
410 | + if ($args['show_option_all']) { |
|
411 | + if ($args['multiple']) { |
|
412 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
413 | 413 | } else { |
414 | - $selected = selected( $args['selected'], 0, false ); |
|
414 | + $selected = selected($args['selected'], 0, false); |
|
415 | 415 | } |
416 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
416 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
417 | 417 | } |
418 | 418 | |
419 | - if ( !empty( $args['options'] ) ) { |
|
419 | + if (!empty($args['options'])) { |
|
420 | 420 | |
421 | - if ( $args['show_option_none'] ) { |
|
422 | - if( $args['multiple'] ) { |
|
423 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
421 | + if ($args['show_option_none']) { |
|
422 | + if ($args['multiple']) { |
|
423 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
424 | 424 | } else { |
425 | - $selected = selected( $args['selected'] === "", true, false ); |
|
425 | + $selected = selected($args['selected'] === "", true, false); |
|
426 | 426 | } |
427 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
427 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
428 | 428 | } |
429 | 429 | |
430 | - foreach( $args['options'] as $key => $option ) { |
|
430 | + foreach ($args['options'] as $key => $option) { |
|
431 | 431 | |
432 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
433 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
432 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
433 | + $selected = selected(true, (bool)in_array($key, $args['selected']), false); |
|
434 | 434 | } else { |
435 | - $selected = selected( $args['selected'], $key, false ); |
|
435 | + $selected = selected($args['selected'], $key, false); |
|
436 | 436 | } |
437 | 437 | |
438 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
438 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
439 | 439 | } |
440 | 440 | } |
441 | 441 | |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | return $output; |
445 | 445 | } |
446 | 446 | |
447 | -function wpinv_item_dropdown( $args = array() ) { |
|
447 | +function wpinv_item_dropdown($args = array()) { |
|
448 | 448 | $defaults = array( |
449 | 449 | 'name' => 'wpi_item', |
450 | 450 | 'id' => 'wpi_item', |
@@ -452,14 +452,14 @@ discard block |
||
452 | 452 | 'multiple' => false, |
453 | 453 | 'selected' => 0, |
454 | 454 | 'number' => 100, |
455 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
456 | - 'data' => array( 'search-type' => 'item' ), |
|
455 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
456 | + 'data' => array('search-type' => 'item'), |
|
457 | 457 | 'show_option_all' => false, |
458 | 458 | 'show_option_none' => false, |
459 | 459 | 'show_recurring' => false, |
460 | 460 | ); |
461 | 461 | |
462 | - $args = wp_parse_args( $args, $defaults ); |
|
462 | + $args = wp_parse_args($args, $defaults); |
|
463 | 463 | |
464 | 464 | $item_args = array( |
465 | 465 | 'post_type' => 'wpi_item', |
@@ -468,44 +468,44 @@ discard block |
||
468 | 468 | 'posts_per_page' => $args['number'] |
469 | 469 | ); |
470 | 470 | |
471 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
471 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
472 | 472 | |
473 | - $items = get_posts( $item_args ); |
|
473 | + $items = get_posts($item_args); |
|
474 | 474 | $options = array(); |
475 | - if ( $items ) { |
|
476 | - foreach ( $items as $item ) { |
|
477 | - $title = esc_html( $item->post_title ); |
|
475 | + if ($items) { |
|
476 | + foreach ($items as $item) { |
|
477 | + $title = esc_html($item->post_title); |
|
478 | 478 | |
479 | - if ( !empty( $args['show_recurring'] ) ) { |
|
480 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
479 | + if (!empty($args['show_recurring'])) { |
|
480 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
481 | 481 | } |
482 | 482 | |
483 | - $options[ absint( $item->ID ) ] = $title; |
|
483 | + $options[absint($item->ID)] = $title; |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
487 | 487 | // This ensures that any selected items are included in the drop down |
488 | - if( is_array( $args['selected'] ) ) { |
|
489 | - foreach( $args['selected'] as $item ) { |
|
490 | - if( ! in_array( $item, $options ) ) { |
|
491 | - $title = get_the_title( $item ); |
|
492 | - if ( !empty( $args['show_recurring'] ) ) { |
|
493 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
488 | + if (is_array($args['selected'])) { |
|
489 | + foreach ($args['selected'] as $item) { |
|
490 | + if (!in_array($item, $options)) { |
|
491 | + $title = get_the_title($item); |
|
492 | + if (!empty($args['show_recurring'])) { |
|
493 | + $title .= wpinv_get_item_suffix($item, false); |
|
494 | 494 | } |
495 | 495 | $options[$item] = $title; |
496 | 496 | } |
497 | 497 | } |
498 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
499 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
500 | - $title = get_the_title( $args['selected'] ); |
|
501 | - if ( !empty( $args['show_recurring'] ) ) { |
|
502 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
498 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
499 | + if (!in_array($args['selected'], $options)) { |
|
500 | + $title = get_the_title($args['selected']); |
|
501 | + if (!empty($args['show_recurring'])) { |
|
502 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
503 | 503 | } |
504 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
504 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
505 | 505 | } |
506 | 506 | } |
507 | 507 | |
508 | - $output = wpinv_html_select( array( |
|
508 | + $output = wpinv_html_select(array( |
|
509 | 509 | 'name' => $args['name'], |
510 | 510 | 'selected' => $args['selected'], |
511 | 511 | 'id' => $args['id'], |
@@ -516,12 +516,12 @@ discard block |
||
516 | 516 | 'show_option_all' => $args['show_option_all'], |
517 | 517 | 'show_option_none' => $args['show_option_none'], |
518 | 518 | 'data' => $args['data'], |
519 | - ) ); |
|
519 | + )); |
|
520 | 520 | |
521 | 521 | return $output; |
522 | 522 | } |
523 | 523 | |
524 | -function wpinv_html_checkbox( $args = array() ) { |
|
524 | +function wpinv_html_checkbox($args = array()) { |
|
525 | 525 | $defaults = array( |
526 | 526 | 'name' => null, |
527 | 527 | 'current' => null, |
@@ -532,38 +532,38 @@ discard block |
||
532 | 532 | ) |
533 | 533 | ); |
534 | 534 | |
535 | - $args = wp_parse_args( $args, $defaults ); |
|
535 | + $args = wp_parse_args($args, $defaults); |
|
536 | 536 | |
537 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
537 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
538 | 538 | $options = ''; |
539 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
539 | + if (!empty($args['options']['disabled'])) { |
|
540 | 540 | $options .= ' disabled="disabled"'; |
541 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
541 | + } elseif (!empty($args['options']['readonly'])) { |
|
542 | 542 | $options .= ' readonly'; |
543 | 543 | } |
544 | 544 | |
545 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
545 | + $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
546 | 546 | |
547 | 547 | return $output; |
548 | 548 | } |
549 | 549 | |
550 | -function wpinv_html_text( $args = array() ) { |
|
550 | +function wpinv_html_text($args = array()) { |
|
551 | 551 | // Backwards compatibility |
552 | - if ( func_num_args() > 1 ) { |
|
552 | + if (func_num_args() > 1) { |
|
553 | 553 | $args = func_get_args(); |
554 | 554 | |
555 | 555 | $name = $args[0]; |
556 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
557 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
558 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
556 | + $value = isset($args[1]) ? $args[1] : ''; |
|
557 | + $label = isset($args[2]) ? $args[2] : ''; |
|
558 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | $defaults = array( |
562 | 562 | 'id' => '', |
563 | - 'name' => isset( $name ) ? $name : 'text', |
|
564 | - 'value' => isset( $value ) ? $value : null, |
|
565 | - 'label' => isset( $label ) ? $label : null, |
|
566 | - 'desc' => isset( $desc ) ? $desc : null, |
|
563 | + 'name' => isset($name) ? $name : 'text', |
|
564 | + 'value' => isset($value) ? $value : null, |
|
565 | + 'label' => isset($label) ? $label : null, |
|
566 | + 'desc' => isset($desc) ? $desc : null, |
|
567 | 567 | 'placeholder' => '', |
568 | 568 | 'class' => 'regular-text', |
569 | 569 | 'disabled' => false, |
@@ -573,51 +573,51 @@ discard block |
||
573 | 573 | 'data' => false |
574 | 574 | ); |
575 | 575 | |
576 | - $args = wp_parse_args( $args, $defaults ); |
|
576 | + $args = wp_parse_args($args, $defaults); |
|
577 | 577 | |
578 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
578 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
579 | 579 | $options = ''; |
580 | - if( $args['required'] ) { |
|
580 | + if ($args['required']) { |
|
581 | 581 | $options .= ' required="required"'; |
582 | 582 | } |
583 | - if( $args['readonly'] ) { |
|
583 | + if ($args['readonly']) { |
|
584 | 584 | $options .= ' readonly'; |
585 | 585 | } |
586 | - if( $args['readonly'] ) { |
|
586 | + if ($args['readonly']) { |
|
587 | 587 | $options .= ' readonly'; |
588 | 588 | } |
589 | 589 | |
590 | 590 | $data = ''; |
591 | - if ( !empty( $args['data'] ) ) { |
|
592 | - foreach ( $args['data'] as $key => $value ) { |
|
593 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
591 | + if (!empty($args['data'])) { |
|
592 | + foreach ($args['data'] as $key => $value) { |
|
593 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
594 | 594 | } |
595 | 595 | } |
596 | 596 | |
597 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
598 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
599 | - if ( ! empty( $args['desc'] ) ) { |
|
600 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
597 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
598 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
599 | + if (!empty($args['desc'])) { |
|
600 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
601 | 601 | } |
602 | 602 | |
603 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
603 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
604 | 604 | |
605 | 605 | $output .= '</span>'; |
606 | 606 | |
607 | 607 | return $output; |
608 | 608 | } |
609 | 609 | |
610 | -function wpinv_html_date_field( $args = array() ) { |
|
611 | - if( empty( $args['class'] ) ) { |
|
610 | +function wpinv_html_date_field($args = array()) { |
|
611 | + if (empty($args['class'])) { |
|
612 | 612 | $args['class'] = 'wpiDatepicker'; |
613 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
613 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
614 | 614 | $args['class'] .= ' wpiDatepicker'; |
615 | 615 | } |
616 | 616 | |
617 | - return wpinv_html_text( $args ); |
|
617 | + return wpinv_html_text($args); |
|
618 | 618 | } |
619 | 619 | |
620 | -function wpinv_html_textarea( $args = array() ) { |
|
620 | +function wpinv_html_textarea($args = array()) { |
|
621 | 621 | $defaults = array( |
622 | 622 | 'name' => 'textarea', |
623 | 623 | 'value' => null, |
@@ -627,31 +627,31 @@ discard block |
||
627 | 627 | 'disabled' => false |
628 | 628 | ); |
629 | 629 | |
630 | - $args = wp_parse_args( $args, $defaults ); |
|
630 | + $args = wp_parse_args($args, $defaults); |
|
631 | 631 | |
632 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
632 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
633 | 633 | $disabled = ''; |
634 | - if( $args['disabled'] ) { |
|
634 | + if ($args['disabled']) { |
|
635 | 635 | $disabled = ' disabled="disabled"'; |
636 | 636 | } |
637 | 637 | |
638 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
639 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
640 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
638 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
639 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
640 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
641 | 641 | |
642 | - if ( ! empty( $args['desc'] ) ) { |
|
643 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
642 | + if (!empty($args['desc'])) { |
|
643 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
644 | 644 | } |
645 | 645 | $output .= '</span>'; |
646 | 646 | |
647 | 647 | return $output; |
648 | 648 | } |
649 | 649 | |
650 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
650 | +function wpinv_html_ajax_user_search($args = array()) { |
|
651 | 651 | $defaults = array( |
652 | 652 | 'name' => 'user_id', |
653 | 653 | 'value' => null, |
654 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
654 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
655 | 655 | 'label' => null, |
656 | 656 | 'desc' => null, |
657 | 657 | 'class' => '', |
@@ -660,13 +660,13 @@ discard block |
||
660 | 660 | 'data' => false |
661 | 661 | ); |
662 | 662 | |
663 | - $args = wp_parse_args( $args, $defaults ); |
|
663 | + $args = wp_parse_args($args, $defaults); |
|
664 | 664 | |
665 | 665 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
666 | 666 | |
667 | 667 | $output = '<span class="wpinv_user_search_wrap">'; |
668 | - $output .= wpinv_html_text( $args ); |
|
669 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
668 | + $output .= wpinv_html_text($args); |
|
669 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
670 | 670 | $output .= '</span>'; |
671 | 671 | |
672 | 672 | return $output; |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | function wpinv_ip_geolocation() { |
676 | 676 | global $wpinv_euvat; |
677 | 677 | |
678 | - $ip = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : ''; |
|
678 | + $ip = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : ''; |
|
679 | 679 | $content = ''; |
680 | 680 | $iso = ''; |
681 | 681 | $country = ''; |
@@ -686,69 +686,69 @@ discard block |
||
686 | 686 | $credit = ''; |
687 | 687 | $address = ''; |
688 | 688 | |
689 | - if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) { |
|
689 | + if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) { |
|
690 | 690 | try { |
691 | 691 | $iso = $geoip2_city->country->isoCode; |
692 | 692 | $country = $geoip2_city->country->name; |
693 | - $region = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : ''; |
|
693 | + $region = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : ''; |
|
694 | 694 | $city = $geoip2_city->city->name; |
695 | 695 | $longitude = $geoip2_city->location->longitude; |
696 | 696 | $latitude = $geoip2_city->location->latitude; |
697 | - $credit = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' ); |
|
698 | - } catch( Exception $e ) { } |
|
697 | + $credit = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing'); |
|
698 | + } catch (Exception $e) { } |
|
699 | 699 | } |
700 | 700 | |
701 | - if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) { |
|
701 | + if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) { |
|
702 | 702 | try { |
703 | - $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip ); |
|
703 | + $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip); |
|
704 | 704 | |
705 | - if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) { |
|
705 | + if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) { |
|
706 | 706 | $iso = $load_xml->geoplugin_countryCode; |
707 | 707 | $country = $load_xml->geoplugin_countryName; |
708 | - $region = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : ''; |
|
709 | - $city = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : ''; |
|
708 | + $region = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : ''; |
|
709 | + $city = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : ''; |
|
710 | 710 | $longitude = $load_xml->geoplugin_longitude; |
711 | 711 | $latitude = $load_xml->geoplugin_latitude; |
712 | 712 | $credit = $load_xml->geoplugin_credit; |
713 | - $credit = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit; |
|
713 | + $credit = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit; |
|
714 | 714 | } |
715 | - } catch( Exception $e ) { } |
|
715 | + } catch (Exception $e) { } |
|
716 | 716 | } |
717 | 717 | |
718 | - if ( $iso && $longitude && $latitude ) { |
|
719 | - if ( $city ) { |
|
718 | + if ($iso && $longitude && $latitude) { |
|
719 | + if ($city) { |
|
720 | 720 | $address .= $city . ', '; |
721 | 721 | } |
722 | 722 | |
723 | - if ( $region ) { |
|
723 | + if ($region) { |
|
724 | 724 | $address .= $region . ', '; |
725 | 725 | } |
726 | 726 | |
727 | 727 | $address .= $country . ' (' . $iso . ')'; |
728 | - $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>'; |
|
729 | - $content .= '<p>'. $credit . '</p>'; |
|
728 | + $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>'; |
|
729 | + $content .= '<p>' . $credit . '</p>'; |
|
730 | 730 | } else { |
731 | - $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>'; |
|
731 | + $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>'; |
|
732 | 732 | } |
733 | 733 | ?> |
734 | 734 | <!DOCTYPE html> |
735 | -<html><head><title><?php echo sprintf( __( 'IP: %s', 'invoicing' ), $ip );?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
735 | +<html><head><title><?php echo sprintf(__('IP: %s', 'invoicing'), $ip); ?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head> |
|
736 | 736 | <body> |
737 | - <?php if ( $latitude && $latitude ) { ?> |
|
737 | + <?php if ($latitude && $latitude) { ?> |
|
738 | 738 | <div id="map"></div> |
739 | 739 | <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script> |
740 | 740 | <script type="text/javascript"> |
741 | 741 | var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', |
742 | 742 | osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors', |
743 | 743 | osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), |
744 | - latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>); |
|
744 | + latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>); |
|
745 | 745 | |
746 | 746 | var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]}); |
747 | 747 | |
748 | 748 | var marker = new L.Marker(latlng); |
749 | 749 | map.addLayer(marker); |
750 | 750 | |
751 | - marker.bindPopup("<p><?php esc_attr_e( $address );?></p>"); |
|
751 | + marker.bindPopup("<p><?php esc_attr_e($address); ?></p>"); |
|
752 | 752 | </script> |
753 | 753 | <?php } ?> |
754 | 754 | <div style="height:100px"><?php echo $content; ?></div> |
@@ -756,18 +756,18 @@ discard block |
||
756 | 756 | <?php |
757 | 757 | exit; |
758 | 758 | } |
759 | -add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
760 | -add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' ); |
|
759 | +add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
760 | +add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation'); |
|
761 | 761 | |
762 | 762 | // Set up the template for the invoice. |
763 | -function wpinv_template( $template ) { |
|
763 | +function wpinv_template($template) { |
|
764 | 764 | global $post, $wp_query; |
765 | 765 | |
766 | - if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) { |
|
767 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
768 | - $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
766 | + if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) { |
|
767 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
768 | + $template = wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
769 | 769 | } else { |
770 | - $template = wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
770 | + $template = wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
771 | 771 | } |
772 | 772 | } |
773 | 773 | |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | |
777 | 777 | function wpinv_get_business_address() { |
778 | 778 | $business_address = wpinv_store_address(); |
779 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
779 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
780 | 780 | |
781 | 781 | /* |
782 | 782 | $default_country = wpinv_get_default_country(); |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | |
801 | 801 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
802 | 802 | |
803 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
803 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | function wpinv_display_from_address() { |
@@ -810,192 +810,192 @@ discard block |
||
810 | 810 | if (empty($from_name)) { |
811 | 811 | $from_name = wpinv_get_business_name(); |
812 | 812 | } |
813 | - ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div> |
|
813 | + ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div> |
|
814 | 814 | <div class="wrapper col-xs-10"> |
815 | - <div class="name"><?php echo esc_html( $from_name ); ?></div> |
|
816 | - <?php if ( $address = wpinv_get_business_address() ) { ?> |
|
817 | - <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div> |
|
815 | + <div class="name"><?php echo esc_html($from_name); ?></div> |
|
816 | + <?php if ($address = wpinv_get_business_address()) { ?> |
|
817 | + <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div> |
|
818 | 818 | <?php } ?> |
819 | - <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?> |
|
820 | - <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?></div> |
|
819 | + <?php if ($email_from = wpinv_mail_get_from_address()) { ?> |
|
820 | + <div class="email_from"><?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?></div> |
|
821 | 821 | <?php } ?> |
822 | 822 | </div> |
823 | 823 | <?php |
824 | 824 | } |
825 | 825 | |
826 | -function wpinv_watermark( $id = 0 ) { |
|
827 | - $output = wpinv_get_watermark( $id ); |
|
826 | +function wpinv_watermark($id = 0) { |
|
827 | + $output = wpinv_get_watermark($id); |
|
828 | 828 | |
829 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
829 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
830 | 830 | } |
831 | 831 | |
832 | -function wpinv_get_watermark( $id ) { |
|
833 | - if ( !$id > 0 ) { |
|
832 | +function wpinv_get_watermark($id) { |
|
833 | + if (!$id > 0) { |
|
834 | 834 | return NULL; |
835 | 835 | } |
836 | - $invoice = wpinv_get_invoice( $id ); |
|
836 | + $invoice = wpinv_get_invoice($id); |
|
837 | 837 | |
838 | - if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) { |
|
839 | - if ( $invoice->is_paid() ) { |
|
840 | - return __( 'Paid', 'invoicing' ); |
|
838 | + if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) { |
|
839 | + if ($invoice->is_paid()) { |
|
840 | + return __('Paid', 'invoicing'); |
|
841 | 841 | } |
842 | - if ( $invoice->is_refunded() ) { |
|
843 | - return __( 'Refunded', 'invoicing' ); |
|
842 | + if ($invoice->is_refunded()) { |
|
843 | + return __('Refunded', 'invoicing'); |
|
844 | 844 | } |
845 | - if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) { |
|
846 | - return __( 'Cancelled', 'invoicing' ); |
|
845 | + if ($invoice->has_status(array('wpi-cancelled'))) { |
|
846 | + return __('Cancelled', 'invoicing'); |
|
847 | 847 | } |
848 | 848 | } |
849 | 849 | |
850 | 850 | return NULL; |
851 | 851 | } |
852 | 852 | |
853 | -function wpinv_display_invoice_details( $invoice ) { |
|
853 | +function wpinv_display_invoice_details($invoice) { |
|
854 | 854 | global $wpinv_euvat; |
855 | 855 | |
856 | 856 | $invoice_id = $invoice->ID; |
857 | 857 | $vat_name = $wpinv_euvat->get_vat_name(); |
858 | 858 | $use_taxes = wpinv_use_taxes(); |
859 | 859 | |
860 | - $invoice_status = wpinv_get_invoice_status( $invoice_id ); |
|
860 | + $invoice_status = wpinv_get_invoice_status($invoice_id); |
|
861 | 861 | ?> |
862 | 862 | <table class="table table-bordered table-sm"> |
863 | - <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?> |
|
863 | + <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?> |
|
864 | 864 | <tr class="wpi-row-number"> |
865 | - <th><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></th> |
|
866 | - <td><?php echo esc_html( $invoice_number ); ?></td> |
|
865 | + <th><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></th> |
|
866 | + <td><?php echo esc_html($invoice_number); ?></td> |
|
867 | 867 | </tr> |
868 | 868 | <?php } ?> |
869 | 869 | <tr class="wpi-row-status"> |
870 | - <th><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></th> |
|
871 | - <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td> |
|
870 | + <th><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></th> |
|
871 | + <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td> |
|
872 | 872 | </tr> |
873 | - <?php if ( $invoice->is_renewal() ) { ?> |
|
873 | + <?php if ($invoice->is_renewal()) { ?> |
|
874 | 874 | <tr class="wpi-row-parent"> |
875 | - <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></th> |
|
876 | - <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td> |
|
875 | + <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></th> |
|
876 | + <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td> |
|
877 | 877 | </tr> |
878 | 878 | <?php } ?> |
879 | - <?php if ( ( $gateway_name = wpinv_get_payment_gateway_name( $invoice_id ) ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?> |
|
879 | + <?php if (($gateway_name = wpinv_get_payment_gateway_name($invoice_id)) && ($invoice->is_paid() || $invoice->is_refunded())) { ?> |
|
880 | 880 | <tr class="wpi-row-gateway"> |
881 | - <th><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></th> |
|
881 | + <th><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></th> |
|
882 | 882 | <td><?php echo $gateway_name; ?></td> |
883 | 883 | </tr> |
884 | 884 | <?php } ?> |
885 | - <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?> |
|
885 | + <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?> |
|
886 | 886 | <tr class="wpi-row-date"> |
887 | - <th><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></th> |
|
887 | + <th><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></th> |
|
888 | 888 | <td><?php echo $invoice_date; ?></td> |
889 | 889 | </tr> |
890 | 890 | <?php } ?> |
891 | - <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?> |
|
891 | + <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?> |
|
892 | 892 | <tr class="wpi-row-date"> |
893 | - <th><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></th> |
|
893 | + <th><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></th> |
|
894 | 894 | <td><?php echo $due_date; ?></td> |
895 | 895 | </tr> |
896 | 896 | <?php } ?> |
897 | - <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?> |
|
898 | - <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?> |
|
897 | + <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?> |
|
898 | + <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?> |
|
899 | 899 | <tr class="wpi-row-ovatno"> |
900 | - <th><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th> |
|
900 | + <th><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th> |
|
901 | 901 | <td><?php echo $owner_vat_number; ?></td> |
902 | 902 | </tr> |
903 | 903 | <?php } ?> |
904 | - <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?> |
|
905 | - <?php if ( $use_taxes && ( $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) ) { ?> |
|
904 | + <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?> |
|
905 | + <?php if ($use_taxes && ($user_vat_number = wpinv_get_invoice_vat_number($invoice_id))) { ?> |
|
906 | 906 | <tr class="wpi-row-uvatno"> |
907 | - <th><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th> |
|
907 | + <th><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th> |
|
908 | 908 | <td><?php echo $user_vat_number; ?></td> |
909 | 909 | </tr> |
910 | 910 | <?php } ?> |
911 | 911 | <tr class="table-active tr-total wpi-row-total"> |
912 | - <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th> |
|
913 | - <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td> |
|
912 | + <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th> |
|
913 | + <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td> |
|
914 | 914 | </tr> |
915 | 915 | </table> |
916 | 916 | <?php |
917 | 917 | } |
918 | 918 | |
919 | -function wpinv_display_to_address( $invoice_id = 0 ) { |
|
920 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
919 | +function wpinv_display_to_address($invoice_id = 0) { |
|
920 | + $invoice = wpinv_get_invoice($invoice_id); |
|
921 | 921 | |
922 | - if ( empty( $invoice ) ) { |
|
922 | + if (empty($invoice)) { |
|
923 | 923 | return NULL; |
924 | 924 | } |
925 | 925 | |
926 | 926 | $billing_details = $invoice->get_user_info(); |
927 | - $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>'; |
|
927 | + $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>'; |
|
928 | 928 | $output .= '<div class="wrapper col-xs-10">'; |
929 | 929 | |
930 | 930 | ob_start(); |
931 | - do_action( 'wpinv_display_to_address_top', $invoice ); |
|
931 | + do_action('wpinv_display_to_address_top', $invoice); |
|
932 | 932 | $output .= ob_get_clean(); |
933 | 933 | |
934 | - $output .= '<div class="name">' . esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) . '</div>'; |
|
935 | - if ( $company = $billing_details['company'] ) { |
|
936 | - $output .= '<div class="company">' . wpautop( wp_kses_post( $company ) ) . '</div>'; |
|
934 | + $output .= '<div class="name">' . esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])) . '</div>'; |
|
935 | + if ($company = $billing_details['company']) { |
|
936 | + $output .= '<div class="company">' . wpautop(wp_kses_post($company)) . '</div>'; |
|
937 | 937 | } |
938 | 938 | $address_row = ''; |
939 | - if ( $address = $billing_details['address'] ) { |
|
940 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
939 | + if ($address = $billing_details['address']) { |
|
940 | + $address_row .= wpautop(wp_kses_post($address)); |
|
941 | 941 | } |
942 | 942 | |
943 | 943 | $address_fields = array(); |
944 | - if ( !empty( $billing_details['city'] ) ) { |
|
944 | + if (!empty($billing_details['city'])) { |
|
945 | 945 | $address_fields[] = $billing_details['city']; |
946 | 946 | } |
947 | 947 | |
948 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
949 | - if ( !empty( $billing_details['state'] ) ) { |
|
950 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
948 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
949 | + if (!empty($billing_details['state'])) { |
|
950 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
951 | 951 | } |
952 | 952 | |
953 | - if ( !empty( $billing_country ) ) { |
|
954 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
953 | + if (!empty($billing_country)) { |
|
954 | + $address_fields[] = wpinv_country_name($billing_country); |
|
955 | 955 | } |
956 | 956 | |
957 | - if ( !empty( $address_fields ) ) { |
|
958 | - $address_fields = implode( ", ", $address_fields ); |
|
957 | + if (!empty($address_fields)) { |
|
958 | + $address_fields = implode(", ", $address_fields); |
|
959 | 959 | |
960 | - if ( !empty( $billing_details['zip'] ) ) { |
|
960 | + if (!empty($billing_details['zip'])) { |
|
961 | 961 | $address_fields .= ' ' . $billing_details['zip']; |
962 | 962 | } |
963 | 963 | |
964 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
964 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
965 | 965 | } |
966 | 966 | |
967 | - if ( $address_row ) { |
|
967 | + if ($address_row) { |
|
968 | 968 | $output .= '<div class="address">' . $address_row . '</div>'; |
969 | 969 | } |
970 | 970 | |
971 | - if ( $phone = $invoice->get_phone() ) { |
|
972 | - $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ) . '</div>'; |
|
971 | + if ($phone = $invoice->get_phone()) { |
|
972 | + $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)) . '</div>'; |
|
973 | 973 | } |
974 | - if ( $email = $invoice->get_email() ) { |
|
975 | - $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' , 'invoicing'), esc_html( $email ) ) . '</div>'; |
|
974 | + if ($email = $invoice->get_email()) { |
|
975 | + $output .= '<div class="email">' . wp_sprintf(__('Email: %s', 'invoicing'), esc_html($email)) . '</div>'; |
|
976 | 976 | } |
977 | 977 | |
978 | 978 | ob_start(); |
979 | - do_action( 'wpinv_display_to_address_bottom', $invoice ); |
|
979 | + do_action('wpinv_display_to_address_bottom', $invoice); |
|
980 | 980 | $output .= ob_get_clean(); |
981 | 981 | |
982 | 982 | $output .= '</div>'; |
983 | - $output = apply_filters( 'wpinv_display_to_address', $output, $invoice ); |
|
983 | + $output = apply_filters('wpinv_display_to_address', $output, $invoice); |
|
984 | 984 | |
985 | 985 | echo $output; |
986 | 986 | } |
987 | 987 | |
988 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
988 | +function wpinv_display_line_items($invoice_id = 0) { |
|
989 | 989 | global $wpinv_euvat, $ajax_cart_details; |
990 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
990 | + $invoice = wpinv_get_invoice($invoice_id); |
|
991 | 991 | $quantities_enabled = wpinv_item_quantities_enabled(); |
992 | 992 | $use_taxes = wpinv_use_taxes(); |
993 | - if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) { |
|
993 | + if (!$use_taxes && (float)$invoice->get_tax() > 0) { |
|
994 | 994 | $use_taxes = true; |
995 | 995 | } |
996 | 996 | $zero_tax = !(float)$invoice->get_tax() > 0 ? true : false; |
997 | - $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' ); |
|
998 | - $tax_title = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : ''; |
|
997 | + $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing'); |
|
998 | + $tax_title = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : ''; |
|
999 | 999 | |
1000 | 1000 | $cart_details = $invoice->get_cart_details(); |
1001 | 1001 | $ajax_cart_details = $cart_details; |
@@ -1004,67 +1004,67 @@ discard block |
||
1004 | 1004 | <table class="table table-sm table-bordered table-responsive"> |
1005 | 1005 | <thead> |
1006 | 1006 | <tr> |
1007 | - <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th> |
|
1008 | - <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th> |
|
1007 | + <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th> |
|
1008 | + <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th> |
|
1009 | 1009 | <?php if ($quantities_enabled) { ?> |
1010 | - <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th> |
|
1010 | + <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th> |
|
1011 | 1011 | <?php } ?> |
1012 | 1012 | <?php if ($use_taxes && !$zero_tax) { ?> |
1013 | 1013 | <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th> |
1014 | 1014 | <?php } ?> |
1015 | - <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th> |
|
1015 | + <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th> |
|
1016 | 1016 | </tr> |
1017 | 1017 | </thead> |
1018 | 1018 | <tbody> |
1019 | 1019 | <?php |
1020 | - if ( !empty( $cart_details ) ) { |
|
1021 | - do_action( 'wpinv_display_line_items_start', $invoice ); |
|
1020 | + if (!empty($cart_details)) { |
|
1021 | + do_action('wpinv_display_line_items_start', $invoice); |
|
1022 | 1022 | |
1023 | 1023 | $count = 0; |
1024 | 1024 | $cols = 3; |
1025 | - foreach ( $cart_details as $key => $cart_item ) { |
|
1026 | - $item_id = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : ''; |
|
1027 | - $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount( $cart_item["item_price"] ) : 0; |
|
1028 | - $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount( $cart_item["subtotal"] ) : 0; |
|
1029 | - $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1; |
|
1025 | + foreach ($cart_details as $key => $cart_item) { |
|
1026 | + $item_id = !empty($cart_item['id']) ? absint($cart_item['id']) : ''; |
|
1027 | + $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount($cart_item["item_price"]) : 0; |
|
1028 | + $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount($cart_item["subtotal"]) : 0; |
|
1029 | + $quantity = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1; |
|
1030 | 1030 | |
1031 | - $item = $item_id ? new WPInv_Item( $item_id ) : NULL; |
|
1031 | + $item = $item_id ? new WPInv_Item($item_id) : NULL; |
|
1032 | 1032 | $summary = ''; |
1033 | - $item_name = ''; |
|
1033 | + $item_name = ''; |
|
1034 | 1034 | $cols = 3; |
1035 | - if ( !empty($item) ) { |
|
1035 | + if (!empty($item)) { |
|
1036 | 1036 | $item_name = $item->get_name(); |
1037 | 1037 | $summary = $item->get_summary(); |
1038 | 1038 | } |
1039 | - $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
1039 | + $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name; |
|
1040 | 1040 | |
1041 | - $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice ); |
|
1041 | + $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice); |
|
1042 | 1042 | |
1043 | 1043 | $item_tax = ''; |
1044 | 1044 | $tax_rate = ''; |
1045 | - if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
1046 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() ); |
|
1047 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
1048 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
1045 | + if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
1046 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency()); |
|
1047 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
1048 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : ''; |
|
1049 | 1049 | $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : ''; |
1050 | 1050 | } |
1051 | 1051 | |
1052 | 1052 | $line_item_tax = $item_tax . $tax_rate; |
1053 | 1053 | |
1054 | - if ( $line_item_tax === '' ) { |
|
1054 | + if ($line_item_tax === '') { |
|
1055 | 1055 | $line_item_tax = 0; // Zero tax |
1056 | 1056 | } |
1057 | 1057 | |
1058 | - $action = apply_filters( 'wpinv_display_line_item_action', '', $cart_item, $invoice, $cols ); |
|
1058 | + $action = apply_filters('wpinv_display_line_item_action', '', $cart_item, $invoice, $cols); |
|
1059 | 1059 | |
1060 | - $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">'; |
|
1061 | - $line_item .= '<td class="name">' . $action. esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item ); |
|
1062 | - if ( $summary !== '' ) { |
|
1063 | - $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>'; |
|
1060 | + $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">'; |
|
1061 | + $line_item .= '<td class="name">' . $action . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item); |
|
1062 | + if ($summary !== '') { |
|
1063 | + $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>'; |
|
1064 | 1064 | } |
1065 | 1065 | $line_item .= '</td>'; |
1066 | 1066 | |
1067 | - $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>'; |
|
1067 | + $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>'; |
|
1068 | 1068 | if ($quantities_enabled) { |
1069 | 1069 | $cols++; |
1070 | 1070 | $line_item .= '<td class="qty">' . $quantity . '</td>'; |
@@ -1073,55 +1073,55 @@ discard block |
||
1073 | 1073 | $cols++; |
1074 | 1074 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1075 | 1075 | } |
1076 | - $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>'; |
|
1076 | + $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>'; |
|
1077 | 1077 | $line_item .= '</tr>'; |
1078 | 1078 | |
1079 | - echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols ); |
|
1079 | + echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols); |
|
1080 | 1080 | |
1081 | 1081 | $count++; |
1082 | 1082 | } |
1083 | 1083 | |
1084 | - do_action( 'wpinv_display_before_subtotal', $invoice, $cols ); |
|
1084 | + do_action('wpinv_display_before_subtotal', $invoice, $cols); |
|
1085 | 1085 | ?> |
1086 | 1086 | <tr class="row-sub-total row_odd"> |
1087 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
1088 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1087 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
1088 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1089 | 1089 | </tr> |
1090 | 1090 | <?php |
1091 | - do_action( 'wpinv_display_after_subtotal', $invoice, $cols ); |
|
1091 | + do_action('wpinv_display_after_subtotal', $invoice, $cols); |
|
1092 | 1092 | |
1093 | - if ( wpinv_discount( $invoice_id, false ) > 0 ) { |
|
1094 | - do_action( 'wpinv_display_before_discount', $invoice, $cols ); |
|
1093 | + if (wpinv_discount($invoice_id, false) > 0) { |
|
1094 | + do_action('wpinv_display_before_discount', $invoice, $cols); |
|
1095 | 1095 | ?> |
1096 | 1096 | <tr class="row-discount"> |
1097 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td> |
|
1098 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1097 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td> |
|
1098 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1099 | 1099 | </tr> |
1100 | 1100 | <?php |
1101 | - do_action( 'wpinv_display_after_discount', $invoice, $cols ); |
|
1101 | + do_action('wpinv_display_after_discount', $invoice, $cols); |
|
1102 | 1102 | } |
1103 | 1103 | |
1104 | - if ( $use_taxes ) { |
|
1105 | - do_action( 'wpinv_display_before_tax', $invoice, $cols ); |
|
1104 | + if ($use_taxes) { |
|
1105 | + do_action('wpinv_display_before_tax', $invoice, $cols); |
|
1106 | 1106 | ?> |
1107 | 1107 | <tr class="row-tax"> |
1108 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td> |
|
1109 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1108 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td> |
|
1109 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1110 | 1110 | </tr> |
1111 | 1111 | <?php |
1112 | - do_action( 'wpinv_display_after_tax', $invoice, $cols ); |
|
1112 | + do_action('wpinv_display_after_tax', $invoice, $cols); |
|
1113 | 1113 | } |
1114 | 1114 | |
1115 | - do_action( 'wpinv_display_before_total', $invoice, $cols ); |
|
1115 | + do_action('wpinv_display_before_total', $invoice, $cols); |
|
1116 | 1116 | ?> |
1117 | 1117 | <tr class="table-active row-total"> |
1118 | - <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td> |
|
1119 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1118 | + <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td> |
|
1119 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1120 | 1120 | </tr> |
1121 | 1121 | <?php |
1122 | - do_action( 'wpinv_display_after_total', $invoice, $cols ); |
|
1122 | + do_action('wpinv_display_after_total', $invoice, $cols); |
|
1123 | 1123 | |
1124 | - do_action( 'wpinv_display_line_end', $invoice, $cols ); |
|
1124 | + do_action('wpinv_display_line_end', $invoice, $cols); |
|
1125 | 1125 | } |
1126 | 1126 | ?> |
1127 | 1127 | </tbody> |
@@ -1130,35 +1130,35 @@ discard block |
||
1130 | 1130 | echo ob_get_clean(); |
1131 | 1131 | } |
1132 | 1132 | |
1133 | -function wpinv_display_invoice_totals( $invoice_id = 0 ) { |
|
1133 | +function wpinv_display_invoice_totals($invoice_id = 0) { |
|
1134 | 1134 | $use_taxes = wpinv_use_taxes(); |
1135 | 1135 | |
1136 | - do_action( 'wpinv_before_display_totals_table', $invoice_id ); |
|
1136 | + do_action('wpinv_before_display_totals_table', $invoice_id); |
|
1137 | 1137 | ?> |
1138 | 1138 | <table class="table table-sm table-bordered table-responsive"> |
1139 | 1139 | <tbody> |
1140 | - <?php do_action( 'wpinv_before_display_totals' ); ?> |
|
1140 | + <?php do_action('wpinv_before_display_totals'); ?> |
|
1141 | 1141 | <tr class="row-sub-total"> |
1142 | - <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td> |
|
1143 | - <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td> |
|
1142 | + <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td> |
|
1143 | + <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td> |
|
1144 | 1144 | </tr> |
1145 | - <?php do_action( 'wpinv_after_display_totals' ); ?> |
|
1146 | - <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?> |
|
1145 | + <?php do_action('wpinv_after_display_totals'); ?> |
|
1146 | + <?php if (wpinv_discount($invoice_id, false) > 0) { ?> |
|
1147 | 1147 | <tr class="row-discount"> |
1148 | - <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td> |
|
1149 | - <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td> |
|
1148 | + <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td> |
|
1149 | + <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td> |
|
1150 | 1150 | </tr> |
1151 | - <?php do_action( 'wpinv_after_display_discount' ); ?> |
|
1151 | + <?php do_action('wpinv_after_display_discount'); ?> |
|
1152 | 1152 | <?php } ?> |
1153 | - <?php if ( $use_taxes ) { ?> |
|
1153 | + <?php if ($use_taxes) { ?> |
|
1154 | 1154 | <tr class="row-tax"> |
1155 | - <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td> |
|
1156 | - <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td> |
|
1155 | + <td class="rate"><?php _e('Tax', 'invoicing'); ?></td> |
|
1156 | + <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td> |
|
1157 | 1157 | </tr> |
1158 | - <?php do_action( 'wpinv_after_display_tax' ); ?> |
|
1158 | + <?php do_action('wpinv_after_display_tax'); ?> |
|
1159 | 1159 | <?php } ?> |
1160 | - <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?> |
|
1161 | - <?php foreach ( $fees as $fee ) { ?> |
|
1160 | + <?php if ($fees = wpinv_get_fees($invoice_id)) { ?> |
|
1161 | + <?php foreach ($fees as $fee) { ?> |
|
1162 | 1162 | <tr class="row-fee"> |
1163 | 1163 | <td class="rate"><?php echo $fee['label']; ?></td> |
1164 | 1164 | <td class="total"><?php echo $fee['amount_display']; ?></td> |
@@ -1166,82 +1166,82 @@ discard block |
||
1166 | 1166 | <?php } ?> |
1167 | 1167 | <?php } ?> |
1168 | 1168 | <tr class="table-active row-total"> |
1169 | - <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td> |
|
1170 | - <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td> |
|
1169 | + <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td> |
|
1170 | + <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td> |
|
1171 | 1171 | </tr> |
1172 | - <?php do_action( 'wpinv_after_totals' ); ?> |
|
1172 | + <?php do_action('wpinv_after_totals'); ?> |
|
1173 | 1173 | </tbody> |
1174 | 1174 | |
1175 | 1175 | </table> |
1176 | 1176 | |
1177 | - <?php do_action( 'wpinv_after_totals_table' ); |
|
1177 | + <?php do_action('wpinv_after_totals_table'); |
|
1178 | 1178 | } |
1179 | 1179 | |
1180 | -function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) { |
|
1181 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1180 | +function wpinv_display_payments_info($invoice_id = 0, $echo = true) { |
|
1181 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1182 | 1182 | |
1183 | 1183 | ob_start(); |
1184 | - do_action( 'wpinv_before_display_payments_info', $invoice_id ); |
|
1185 | - if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
1184 | + do_action('wpinv_before_display_payments_info', $invoice_id); |
|
1185 | + if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) { |
|
1186 | 1186 | ?> |
1187 | 1187 | <div class="wpi-payment-info"> |
1188 | - <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p> |
|
1189 | - <?php if ( $gateway_title ) { ?> |
|
1190 | - <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p> |
|
1188 | + <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p> |
|
1189 | + <?php if ($gateway_title) { ?> |
|
1190 | + <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p> |
|
1191 | 1191 | <?php } ?> |
1192 | 1192 | </div> |
1193 | 1193 | <?php |
1194 | 1194 | } |
1195 | - do_action( 'wpinv_after_display_payments_info', $invoice_id ); |
|
1195 | + do_action('wpinv_after_display_payments_info', $invoice_id); |
|
1196 | 1196 | $outout = ob_get_clean(); |
1197 | 1197 | |
1198 | - if ( $echo ) { |
|
1198 | + if ($echo) { |
|
1199 | 1199 | echo $outout; |
1200 | 1200 | } else { |
1201 | 1201 | return $outout; |
1202 | 1202 | } |
1203 | 1203 | } |
1204 | 1204 | |
1205 | -function wpinv_display_style( $invoice ) { |
|
1206 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION ); |
|
1205 | +function wpinv_display_style($invoice) { |
|
1206 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION); |
|
1207 | 1207 | |
1208 | - wp_print_styles( 'open-sans' ); |
|
1209 | - wp_print_styles( 'wpinv-single-style' ); |
|
1208 | + wp_print_styles('open-sans'); |
|
1209 | + wp_print_styles('wpinv-single-style'); |
|
1210 | 1210 | |
1211 | 1211 | $custom_css = wpinv_get_option('template_custom_css'); |
1212 | - if(isset($custom_css) && !empty($custom_css)){ |
|
1213 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
1214 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
1212 | + if (isset($custom_css) && !empty($custom_css)) { |
|
1213 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
1214 | + $custom_css = str_replace('>', '>', $custom_css); |
|
1215 | 1215 | echo '<style type="text/css">'; |
1216 | 1216 | echo $custom_css; |
1217 | 1217 | echo '</style>'; |
1218 | 1218 | } |
1219 | 1219 | } |
1220 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
1221 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
1220 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
1221 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
1222 | 1222 | |
1223 | 1223 | function wpinv_checkout_billing_details() { |
1224 | 1224 | $invoice_id = (int)wpinv_get_invoice_cart_id(); |
1225 | 1225 | if (empty($invoice_id)) { |
1226 | - wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ ); |
|
1226 | + wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__); |
|
1227 | 1227 | return null; |
1228 | 1228 | } |
1229 | 1229 | |
1230 | - $invoice = wpinv_get_invoice_cart( $invoice_id ); |
|
1230 | + $invoice = wpinv_get_invoice_cart($invoice_id); |
|
1231 | 1231 | if (empty($invoice)) { |
1232 | - wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ ); |
|
1232 | + wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__); |
|
1233 | 1233 | return null; |
1234 | 1234 | } |
1235 | 1235 | $user_id = $invoice->get_user_id(); |
1236 | 1236 | $user_info = $invoice->get_user_info(); |
1237 | - $address_info = wpinv_get_user_address( $user_id ); |
|
1237 | + $address_info = wpinv_get_user_address($user_id); |
|
1238 | 1238 | |
1239 | - if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) { |
|
1239 | + if (empty($user_info['first_name']) && !empty($user_info['first_name'])) { |
|
1240 | 1240 | $user_info['first_name'] = $user_info['first_name']; |
1241 | 1241 | $user_info['last_name'] = $user_info['last_name']; |
1242 | 1242 | } |
1243 | 1243 | |
1244 | - if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) { |
|
1244 | + if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) { |
|
1245 | 1245 | $user_info['country'] = $address_info['country']; |
1246 | 1246 | $user_info['state'] = $address_info['state']; |
1247 | 1247 | $user_info['city'] = $address_info['city']; |
@@ -1257,98 +1257,98 @@ discard block |
||
1257 | 1257 | 'address' |
1258 | 1258 | ); |
1259 | 1259 | |
1260 | - foreach ( $address_fields as $field ) { |
|
1261 | - if ( empty( $user_info[$field] ) ) { |
|
1260 | + foreach ($address_fields as $field) { |
|
1261 | + if (empty($user_info[$field])) { |
|
1262 | 1262 | $user_info[$field] = $address_info[$field]; |
1263 | 1263 | } |
1264 | 1264 | } |
1265 | 1265 | |
1266 | - return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice ); |
|
1266 | + return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice); |
|
1267 | 1267 | } |
1268 | 1268 | |
1269 | 1269 | function wpinv_admin_get_line_items($invoice = array()) { |
1270 | 1270 | $item_quantities = wpinv_item_quantities_enabled(); |
1271 | 1271 | $use_taxes = wpinv_use_taxes(); |
1272 | 1272 | |
1273 | - if ( empty( $invoice ) ) { |
|
1273 | + if (empty($invoice)) { |
|
1274 | 1274 | return NULL; |
1275 | 1275 | } |
1276 | 1276 | |
1277 | 1277 | $cart_items = $invoice->get_cart_details(); |
1278 | - if ( empty( $cart_items ) ) { |
|
1278 | + if (empty($cart_items)) { |
|
1279 | 1279 | return NULL; |
1280 | 1280 | } |
1281 | 1281 | ob_start(); |
1282 | 1282 | |
1283 | - do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice ); |
|
1283 | + do_action('wpinv_admin_before_line_items', $cart_items, $invoice); |
|
1284 | 1284 | |
1285 | 1285 | $count = 0; |
1286 | - foreach ( $cart_items as $key => $cart_item ) { |
|
1286 | + foreach ($cart_items as $key => $cart_item) { |
|
1287 | 1287 | $item_id = $cart_item['id']; |
1288 | - $wpi_item = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL; |
|
1288 | + $wpi_item = $item_id > 0 ? new WPInv_Item($item_id) : NULL; |
|
1289 | 1289 | |
1290 | 1290 | if (empty($wpi_item)) { |
1291 | 1291 | continue; |
1292 | 1292 | } |
1293 | 1293 | |
1294 | - $item_price = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ), $invoice->get_currency() ); |
|
1295 | - $quantity = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1296 | - $item_subtotal = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ), $invoice->get_currency() ); |
|
1294 | + $item_price = wpinv_price(wpinv_format_amount($cart_item['item_price']), $invoice->get_currency()); |
|
1295 | + $quantity = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1; |
|
1296 | + $item_subtotal = wpinv_price(wpinv_format_amount($cart_item['subtotal']), $invoice->get_currency()); |
|
1297 | 1297 | $can_remove = true; |
1298 | 1298 | |
1299 | - $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice ); |
|
1299 | + $summary = apply_filters('wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice); |
|
1300 | 1300 | |
1301 | 1301 | $item_tax = ''; |
1302 | 1302 | $tax_rate = ''; |
1303 | - if ( $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) { |
|
1304 | - $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() ); |
|
1305 | - $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100; |
|
1306 | - $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : ''; |
|
1303 | + if ($cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) { |
|
1304 | + $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency()); |
|
1305 | + $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100; |
|
1306 | + $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : ''; |
|
1307 | 1307 | $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : ''; |
1308 | 1308 | } |
1309 | 1309 | $line_item_tax = $item_tax . $tax_rate; |
1310 | 1310 | |
1311 | - if ( $line_item_tax === '' ) { |
|
1311 | + if ($line_item_tax === '') { |
|
1312 | 1312 | $line_item_tax = 0; // Zero tax |
1313 | 1313 | } |
1314 | 1314 | |
1315 | - $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">'; |
|
1315 | + $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">'; |
|
1316 | 1316 | $line_item .= '<td class="id">' . $item_id . '</td>'; |
1317 | - $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item_id ) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix( $wpi_item ); |
|
1318 | - if ( $summary !== '' ) { |
|
1319 | - $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>'; |
|
1317 | + $line_item .= '<td class="title"><a href="' . get_edit_post_link($item_id) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix($wpi_item); |
|
1318 | + if ($summary !== '') { |
|
1319 | + $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>'; |
|
1320 | 1320 | } |
1321 | 1321 | $line_item .= '</td>'; |
1322 | 1322 | $line_item .= '<td class="price">' . $item_price . '</td>'; |
1323 | 1323 | |
1324 | - if ( $item_quantities ) { |
|
1325 | - if ( count( $cart_items ) == 1 && $quantity <= 1 ) { |
|
1324 | + if ($item_quantities) { |
|
1325 | + if (count($cart_items) == 1 && $quantity <= 1) { |
|
1326 | 1326 | $can_remove = false; |
1327 | 1327 | } |
1328 | 1328 | $line_item .= '<td class="qty" data-quantity="' . $quantity . '"> × ' . $quantity . '</td>'; |
1329 | 1329 | } else { |
1330 | - if ( count( $cart_items ) == 1 ) { |
|
1330 | + if (count($cart_items) == 1) { |
|
1331 | 1331 | $can_remove = false; |
1332 | 1332 | } |
1333 | 1333 | } |
1334 | 1334 | $line_item .= '<td class="total">' . $item_subtotal . '</td>'; |
1335 | 1335 | |
1336 | - if ( $use_taxes ) { |
|
1336 | + if ($use_taxes) { |
|
1337 | 1337 | $line_item .= '<td class="tax">' . $line_item_tax . '</td>'; |
1338 | 1338 | } |
1339 | 1339 | $line_item .= '<td class="action">'; |
1340 | - if ( !$invoice->is_paid() && !$invoice->is_refunded() && $can_remove ) { |
|
1340 | + if (!$invoice->is_paid() && !$invoice->is_refunded() && $can_remove) { |
|
1341 | 1341 | $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>'; |
1342 | 1342 | } |
1343 | 1343 | $line_item .= '</td>'; |
1344 | 1344 | $line_item .= '</tr>'; |
1345 | 1345 | |
1346 | - echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice ); |
|
1346 | + echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice); |
|
1347 | 1347 | |
1348 | 1348 | $count++; |
1349 | 1349 | } |
1350 | 1350 | |
1351 | - do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice ); |
|
1351 | + do_action('wpinv_admin_after_line_items', $cart_items, $invoice); |
|
1352 | 1352 | |
1353 | 1353 | return ob_get_clean(); |
1354 | 1354 | } |
@@ -1360,32 +1360,32 @@ discard block |
||
1360 | 1360 | $wpi_checkout_id = wpinv_get_invoice_cart_id(); |
1361 | 1361 | |
1362 | 1362 | //Maybe update the prices |
1363 | - if(! empty( $_GET['wpi_dynamic_item'] ) && ! empty( $_GET['wpi_dynamic_price'] ) ) { |
|
1363 | + if (!empty($_GET['wpi_dynamic_item']) && !empty($_GET['wpi_dynamic_price'])) { |
|
1364 | 1364 | |
1365 | 1365 | //If the invoice exists, update it with new pricing details |
1366 | - if (! empty( $wpi_checkout_id ) ) { |
|
1366 | + if (!empty($wpi_checkout_id)) { |
|
1367 | 1367 | |
1368 | 1368 | $_invoice = wpinv_get_invoice_cart(); |
1369 | 1369 | $_cart_details = $_invoice->get_cart_details(); |
1370 | - $_dynamic_item = sanitize_text_field( $_GET['wpi_dynamic_item'] ); |
|
1370 | + $_dynamic_item = sanitize_text_field($_GET['wpi_dynamic_item']); |
|
1371 | 1371 | |
1372 | 1372 | //First, fetch the item |
1373 | - $item = new WPInv_Item( $_dynamic_item ); |
|
1373 | + $item = new WPInv_Item($_dynamic_item); |
|
1374 | 1374 | |
1375 | 1375 | //Next, ensure it supports dynamic pricing... |
1376 | - if( $item->supports_dynamic_pricing() && $item->get_is_dynamic_pricing() ) { |
|
1376 | + if ($item->supports_dynamic_pricing() && $item->get_is_dynamic_pricing()) { |
|
1377 | 1377 | |
1378 | 1378 | //... and that the new price is not lower than the minimum price |
1379 | - $_dynamic_price = (float) wpinv_sanitize_amount( sanitize_text_field( $_GET['wpi_dynamic_price'] ) ); |
|
1380 | - if( $_dynamic_price < $item->get_minimum_price() ) { |
|
1379 | + $_dynamic_price = (float)wpinv_sanitize_amount(sanitize_text_field($_GET['wpi_dynamic_price'])); |
|
1380 | + if ($_dynamic_price < $item->get_minimum_price()) { |
|
1381 | 1381 | $_dynamic_price = $item->get_minimum_price(); |
1382 | 1382 | } |
1383 | 1383 | |
1384 | 1384 | //Finally, update our invoice with the new price |
1385 | - if ( !empty( $_cart_details ) ) { |
|
1385 | + if (!empty($_cart_details)) { |
|
1386 | 1386 | |
1387 | - foreach ( $_cart_details as $key => $item ) { |
|
1388 | - if ( !empty( $item['id'] ) && $_dynamic_item == $item['id'] ) { |
|
1387 | + foreach ($_cart_details as $key => $item) { |
|
1388 | + if (!empty($item['id']) && $_dynamic_item == $item['id']) { |
|
1389 | 1389 | $_cart_details[$key]['custom_price'] = $_dynamic_price; |
1390 | 1390 | $_cart_details[$key]['item_price'] = $_dynamic_price; |
1391 | 1391 | } |
@@ -1393,8 +1393,8 @@ discard block |
||
1393 | 1393 | |
1394 | 1394 | $_meta = $_invoice->get_meta(); |
1395 | 1395 | $_meta['cart_details'] = $_cart_details; |
1396 | - $_invoice->set( 'payment_meta', $_meta ); |
|
1397 | - $_invoice->set( 'cart_details', $_cart_details ); |
|
1396 | + $_invoice->set('payment_meta', $_meta); |
|
1397 | + $_invoice->set('cart_details', $_cart_details); |
|
1398 | 1398 | $_invoice->recalculate_totals(); |
1399 | 1399 | |
1400 | 1400 | } |
@@ -1405,60 +1405,60 @@ discard block |
||
1405 | 1405 | |
1406 | 1406 | } |
1407 | 1407 | |
1408 | - $form_action = esc_url( wpinv_get_checkout_uri() ); |
|
1408 | + $form_action = esc_url(wpinv_get_checkout_uri()); |
|
1409 | 1409 | |
1410 | 1410 | ob_start(); |
1411 | - do_action( 'wpinv_checkout_content_before' ); |
|
1411 | + do_action('wpinv_checkout_content_before'); |
|
1412 | 1412 | echo '<div id="wpinv_checkout_wrap">'; |
1413 | 1413 | |
1414 | - if ( wpinv_get_cart_contents() || wpinv_cart_has_fees() ) { |
|
1414 | + if (wpinv_get_cart_contents() || wpinv_cart_has_fees()) { |
|
1415 | 1415 | ?> |
1416 | 1416 | <div id="wpinv_checkout_form_wrap" class="wpinv_clearfix table-responsive"> |
1417 | - <?php do_action( 'wpinv_before_checkout_form' ); ?> |
|
1417 | + <?php do_action('wpinv_before_checkout_form'); ?> |
|
1418 | 1418 | <form id="wpinv_checkout_form" class="wpi-form" action="<?php echo $form_action; ?>" method="POST"> |
1419 | 1419 | <?php |
1420 | - do_action( 'wpinv_checkout_form_top' ); |
|
1421 | - do_action( 'wpinv_checkout_billing_info' ); |
|
1422 | - do_action( 'wpinv_checkout_cart' ); |
|
1423 | - do_action( 'wpinv_payment_mode_select' ); |
|
1424 | - do_action( 'wpinv_checkout_form_bottom' ) |
|
1420 | + do_action('wpinv_checkout_form_top'); |
|
1421 | + do_action('wpinv_checkout_billing_info'); |
|
1422 | + do_action('wpinv_checkout_cart'); |
|
1423 | + do_action('wpinv_payment_mode_select'); |
|
1424 | + do_action('wpinv_checkout_form_bottom') |
|
1425 | 1425 | ?> |
1426 | 1426 | </form> |
1427 | - <?php do_action( 'wpinv_after_purchase_form' ); ?> |
|
1427 | + <?php do_action('wpinv_after_purchase_form'); ?> |
|
1428 | 1428 | </div><!--end #wpinv_checkout_form_wrap--> |
1429 | 1429 | <?php |
1430 | 1430 | } else { |
1431 | - do_action( 'wpinv_cart_empty' ); |
|
1431 | + do_action('wpinv_cart_empty'); |
|
1432 | 1432 | } |
1433 | 1433 | echo '</div><!--end #wpinv_checkout_wrap-->'; |
1434 | - do_action( 'wpinv_checkout_content_after' ); |
|
1434 | + do_action('wpinv_checkout_content_after'); |
|
1435 | 1435 | return ob_get_clean(); |
1436 | 1436 | } |
1437 | 1437 | |
1438 | -function wpinv_checkout_cart( $cart_details = array(), $echo = true ) { |
|
1438 | +function wpinv_checkout_cart($cart_details = array(), $echo = true) { |
|
1439 | 1439 | global $ajax_cart_details; |
1440 | 1440 | $ajax_cart_details = $cart_details; |
1441 | 1441 | |
1442 | 1442 | ob_start(); |
1443 | - do_action( 'wpinv_before_checkout_cart' ); |
|
1443 | + do_action('wpinv_before_checkout_cart'); |
|
1444 | 1444 | echo '<div id="wpinv_checkout_cart_form" method="post">'; |
1445 | 1445 | echo '<div id="wpinv_checkout_cart_wrap">'; |
1446 | - wpinv_get_template_part( 'wpinv-checkout-cart' ); |
|
1446 | + wpinv_get_template_part('wpinv-checkout-cart'); |
|
1447 | 1447 | echo '</div>'; |
1448 | 1448 | echo '</div>'; |
1449 | - do_action( 'wpinv_after_checkout_cart' ); |
|
1449 | + do_action('wpinv_after_checkout_cart'); |
|
1450 | 1450 | $content = ob_get_clean(); |
1451 | 1451 | |
1452 | - if ( $echo ) { |
|
1452 | + if ($echo) { |
|
1453 | 1453 | echo $content; |
1454 | 1454 | } else { |
1455 | 1455 | return $content; |
1456 | 1456 | } |
1457 | 1457 | } |
1458 | -add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
|
1458 | +add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10); |
|
1459 | 1459 | |
1460 | 1460 | function wpinv_empty_cart_message() { |
1461 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1461 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1462 | 1462 | } |
1463 | 1463 | |
1464 | 1464 | /** |
@@ -1470,83 +1470,83 @@ discard block |
||
1470 | 1470 | function wpinv_empty_checkout_cart() { |
1471 | 1471 | echo wpinv_empty_cart_message(); |
1472 | 1472 | } |
1473 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1473 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1474 | 1474 | |
1475 | 1475 | function wpinv_update_cart_button() { |
1476 | - if ( !wpinv_item_quantities_enabled() ) |
|
1476 | + if (!wpinv_item_quantities_enabled()) |
|
1477 | 1477 | return; |
1478 | 1478 | ?> |
1479 | - <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/> |
|
1479 | + <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/> |
|
1480 | 1480 | <input type="hidden" name="wpi_action" value="update_cart"/> |
1481 | 1481 | <?php |
1482 | 1482 | } |
1483 | 1483 | |
1484 | 1484 | function wpinv_checkout_cart_columns() { |
1485 | 1485 | $default = 3; |
1486 | - if ( wpinv_item_quantities_enabled() ) { |
|
1486 | + if (wpinv_item_quantities_enabled()) { |
|
1487 | 1487 | $default++; |
1488 | 1488 | } |
1489 | 1489 | |
1490 | - if ( wpinv_use_taxes() ) { |
|
1490 | + if (wpinv_use_taxes()) { |
|
1491 | 1491 | $default++; |
1492 | 1492 | } |
1493 | 1493 | |
1494 | - return apply_filters( 'wpinv_checkout_cart_columns', $default ); |
|
1494 | + return apply_filters('wpinv_checkout_cart_columns', $default); |
|
1495 | 1495 | } |
1496 | 1496 | |
1497 | 1497 | function wpinv_display_cart_messages() { |
1498 | 1498 | global $wpi_session; |
1499 | 1499 | |
1500 | - $messages = $wpi_session->get( 'wpinv_cart_messages' ); |
|
1500 | + $messages = $wpi_session->get('wpinv_cart_messages'); |
|
1501 | 1501 | |
1502 | - if ( $messages ) { |
|
1503 | - foreach ( $messages as $message_id => $message ) { |
|
1502 | + if ($messages) { |
|
1503 | + foreach ($messages as $message_id => $message) { |
|
1504 | 1504 | // Try and detect what type of message this is |
1505 | - if ( strpos( strtolower( $message ), 'error' ) ) { |
|
1505 | + if (strpos(strtolower($message), 'error')) { |
|
1506 | 1506 | $type = 'error'; |
1507 | - } elseif ( strpos( strtolower( $message ), 'success' ) ) { |
|
1507 | + } elseif (strpos(strtolower($message), 'success')) { |
|
1508 | 1508 | $type = 'success'; |
1509 | 1509 | } else { |
1510 | 1510 | $type = 'info'; |
1511 | 1511 | } |
1512 | 1512 | |
1513 | - $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) ); |
|
1513 | + $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type)); |
|
1514 | 1514 | |
1515 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
1515 | + echo '<div class="' . implode(' ', $classes) . '">'; |
|
1516 | 1516 | // Loop message codes and display messages |
1517 | 1517 | echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>'; |
1518 | 1518 | echo '</div>'; |
1519 | 1519 | } |
1520 | 1520 | |
1521 | 1521 | // Remove all of the cart saving messages |
1522 | - $wpi_session->set( 'wpinv_cart_messages', null ); |
|
1522 | + $wpi_session->set('wpinv_cart_messages', null); |
|
1523 | 1523 | } |
1524 | 1524 | } |
1525 | -add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' ); |
|
1525 | +add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages'); |
|
1526 | 1526 | |
1527 | 1527 | function wpinv_discount_field() { |
1528 | - if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) { |
|
1528 | + if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) { |
|
1529 | 1529 | return; // Only show before a payment method has been selected if ajax is disabled |
1530 | 1530 | } |
1531 | 1531 | |
1532 | - if ( !wpinv_is_checkout() ) { |
|
1532 | + if (!wpinv_is_checkout()) { |
|
1533 | 1533 | return; |
1534 | 1534 | } |
1535 | 1535 | |
1536 | - if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) { |
|
1536 | + if (wpinv_has_active_discounts() && wpinv_get_cart_total()) { |
|
1537 | 1537 | ?> |
1538 | 1538 | <div id="wpinv-discount-field" class="panel panel-default"> |
1539 | 1539 | <div class="panel-body"> |
1540 | 1540 | <p> |
1541 | - <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label> |
|
1542 | - <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span> |
|
1541 | + <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label> |
|
1542 | + <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span> |
|
1543 | 1543 | </p> |
1544 | 1544 | <div class="form-group row"> |
1545 | 1545 | <div class="col-sm-4"> |
1546 | - <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/> |
|
1546 | + <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/> |
|
1547 | 1547 | </div> |
1548 | 1548 | <div class="col-sm-3"> |
1549 | - <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button> |
|
1549 | + <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button> |
|
1550 | 1550 | </div> |
1551 | 1551 | <div style="clear:both"></div> |
1552 | 1552 | <div class="col-sm-12 wpinv-discount-msg"> |
@@ -1559,10 +1559,10 @@ discard block |
||
1559 | 1559 | <?php |
1560 | 1560 | } |
1561 | 1561 | } |
1562 | -add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 ); |
|
1562 | +add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10); |
|
1563 | 1563 | |
1564 | 1564 | function wpinv_agree_to_terms_js() { |
1565 | - if ( wpinv_get_option( 'show_agree_to_terms', false ) ) { |
|
1565 | + if (wpinv_get_option('show_agree_to_terms', false)) { |
|
1566 | 1566 | ?> |
1567 | 1567 | <script type="text/javascript"> |
1568 | 1568 | jQuery(document).ready(function($){ |
@@ -1577,127 +1577,127 @@ discard block |
||
1577 | 1577 | <?php |
1578 | 1578 | } |
1579 | 1579 | } |
1580 | -add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' ); |
|
1580 | +add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js'); |
|
1581 | 1581 | |
1582 | 1582 | function wpinv_payment_mode_select() { |
1583 | - $gateways = wpinv_get_enabled_payment_gateways( true ); |
|
1584 | - $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways ); |
|
1583 | + $gateways = wpinv_get_enabled_payment_gateways(true); |
|
1584 | + $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways); |
|
1585 | 1585 | $page_URL = wpinv_get_current_page_url(); |
1586 | - $invoice = wpinv_get_invoice( 0, true ); |
|
1586 | + $invoice = wpinv_get_invoice(0, true); |
|
1587 | 1587 | |
1588 | 1588 | do_action('wpinv_payment_mode_top'); |
1589 | 1589 | $invoice_id = (int)$invoice->ID; |
1590 | - $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id ); |
|
1590 | + $chosen_gateway = wpinv_get_chosen_gateway($invoice_id); |
|
1591 | 1591 | ?> |
1592 | - <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( $invoice->is_free() ? 'style="display:none;" data-free="1"' : '' ); ?>> |
|
1593 | - <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?> |
|
1592 | + <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ($invoice->is_free() ? 'style="display:none;" data-free="1"' : ''); ?>> |
|
1593 | + <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?> |
|
1594 | 1594 | <div id="wpinv-payment-mode-wrap" class="panel panel-default"> |
1595 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div> |
|
1595 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div> |
|
1596 | 1596 | <div class="panel-body list-group wpi-payment_methods"> |
1597 | 1597 | <?php |
1598 | - do_action( 'wpinv_payment_mode_before_gateways' ); |
|
1599 | - |
|
1600 | - if ( !empty( $gateways ) ) { |
|
1601 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
1602 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
1603 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
1604 | - $gateway_label = wpinv_get_gateway_checkout_label( $gateway_id ); |
|
1605 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
1598 | + do_action('wpinv_payment_mode_before_gateways'); |
|
1599 | + |
|
1600 | + if (!empty($gateways)) { |
|
1601 | + foreach ($gateways as $gateway_id => $gateway) { |
|
1602 | + $checked = checked($gateway_id, $chosen_gateway, false); |
|
1603 | + $button_label = wpinv_get_gateway_button_label($gateway_id); |
|
1604 | + $gateway_label = wpinv_get_gateway_checkout_label($gateway_id); |
|
1605 | + $description = wpinv_get_gateway_description($gateway_id); |
|
1606 | 1606 | ?> |
1607 | 1607 | <div class="list-group-item"> |
1608 | 1608 | <div class="radio"> |
1609 | - <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway_label ); ?></label> |
|
1609 | + <label><input type="radio" data-button-text="<?php echo esc_attr($button_label); ?>" value="<?php echo esc_attr($gateway_id); ?>" <?php echo $checked; ?> id="wpi_gateway_<?php echo esc_attr($gateway_id); ?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html($gateway_label); ?></label> |
|
1610 | 1610 | </div> |
1611 | - <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert"> |
|
1612 | - <?php if ( !empty( $description ) ) { ?> |
|
1613 | - <div class="wpi-gateway-desc alert alert-info"><?php _e( $description, 'invoicing' ); ?></div> |
|
1611 | + <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert"> |
|
1612 | + <?php if (!empty($description)) { ?> |
|
1613 | + <div class="wpi-gateway-desc alert alert-info"><?php _e($description, 'invoicing'); ?></div> |
|
1614 | 1614 | <?php } ?> |
1615 | - <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?> |
|
1615 | + <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?> |
|
1616 | 1616 | </div> |
1617 | 1617 | </div> |
1618 | 1618 | <?php |
1619 | 1619 | } |
1620 | 1620 | } else { |
1621 | - echo '<div class="alert alert-warning">'. __( 'No payment gateway active', 'invoicing' ) .'</div>'; |
|
1621 | + echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>'; |
|
1622 | 1622 | } |
1623 | 1623 | |
1624 | - do_action( 'wpinv_payment_mode_after_gateways' ); |
|
1624 | + do_action('wpinv_payment_mode_after_gateways'); |
|
1625 | 1625 | ?> |
1626 | 1626 | </div> |
1627 | 1627 | </div> |
1628 | - <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?> |
|
1628 | + <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?> |
|
1629 | 1629 | </div> |
1630 | 1630 | <?php |
1631 | 1631 | do_action('wpinv_payment_mode_bottom'); |
1632 | 1632 | } |
1633 | -add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' ); |
|
1633 | +add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select'); |
|
1634 | 1634 | |
1635 | 1635 | function wpinv_checkout_billing_info() { |
1636 | - if ( wpinv_is_checkout() ) { |
|
1636 | + if (wpinv_is_checkout()) { |
|
1637 | 1637 | $logged_in = is_user_logged_in(); |
1638 | 1638 | $billing_details = wpinv_checkout_billing_details(); |
1639 | - $selected_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1639 | + $selected_country = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country(); |
|
1640 | 1640 | ?> |
1641 | 1641 | <div id="wpinv-fields" class="clearfix"> |
1642 | 1642 | <div id="wpi-billing" class="wpi-billing clearfix panel panel-default"> |
1643 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div> |
|
1643 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div> |
|
1644 | 1644 | <div id="wpinv-fields-box" class="panel-body"> |
1645 | - <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?> |
|
1645 | + <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?> |
|
1646 | 1646 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1647 | - <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><?php if ( wpinv_get_option( 'fname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1647 | + <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><?php if (wpinv_get_option('fname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1648 | 1648 | <?php |
1649 | - echo wpinv_html_text( array( |
|
1649 | + echo wpinv_html_text(array( |
|
1650 | 1650 | 'id' => 'wpinv_first_name', |
1651 | 1651 | 'name' => 'wpinv_first_name', |
1652 | 1652 | 'value' => $billing_details['first_name'], |
1653 | 1653 | 'class' => 'wpi-input form-control', |
1654 | - 'placeholder' => __( 'First name', 'invoicing' ), |
|
1655 | - 'required' => (bool)wpinv_get_option( 'fname_mandatory' ), |
|
1656 | - ) ); |
|
1654 | + 'placeholder' => __('First name', 'invoicing'), |
|
1655 | + 'required' => (bool)wpinv_get_option('fname_mandatory'), |
|
1656 | + )); |
|
1657 | 1657 | ?> |
1658 | 1658 | </p> |
1659 | 1659 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1660 | - <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?><?php if ( wpinv_get_option( 'lname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1660 | + <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?><?php if (wpinv_get_option('lname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1661 | 1661 | <?php |
1662 | - echo wpinv_html_text( array( |
|
1662 | + echo wpinv_html_text(array( |
|
1663 | 1663 | 'id' => 'wpinv_last_name', |
1664 | 1664 | 'name' => 'wpinv_last_name', |
1665 | 1665 | 'value' => $billing_details['last_name'], |
1666 | 1666 | 'class' => 'wpi-input form-control', |
1667 | - 'placeholder' => __( 'Last name', 'invoicing' ), |
|
1668 | - 'required' => (bool)wpinv_get_option( 'lname_mandatory' ), |
|
1669 | - ) ); |
|
1667 | + 'placeholder' => __('Last name', 'invoicing'), |
|
1668 | + 'required' => (bool)wpinv_get_option('lname_mandatory'), |
|
1669 | + )); |
|
1670 | 1670 | ?> |
1671 | 1671 | </p> |
1672 | 1672 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1673 | - <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><?php if ( wpinv_get_option( 'address_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1673 | + <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><?php if (wpinv_get_option('address_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1674 | 1674 | <?php |
1675 | - echo wpinv_html_text( array( |
|
1675 | + echo wpinv_html_text(array( |
|
1676 | 1676 | 'id' => 'wpinv_address', |
1677 | 1677 | 'name' => 'wpinv_address', |
1678 | 1678 | 'value' => $billing_details['address'], |
1679 | 1679 | 'class' => 'wpi-input form-control', |
1680 | - 'placeholder' => __( 'Address', 'invoicing' ), |
|
1681 | - 'required' => (bool)wpinv_get_option( 'address_mandatory' ), |
|
1682 | - ) ); |
|
1680 | + 'placeholder' => __('Address', 'invoicing'), |
|
1681 | + 'required' => (bool)wpinv_get_option('address_mandatory'), |
|
1682 | + )); |
|
1683 | 1683 | ?> |
1684 | 1684 | </p> |
1685 | 1685 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1686 | - <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><?php if ( wpinv_get_option( 'city_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1686 | + <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><?php if (wpinv_get_option('city_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1687 | 1687 | <?php |
1688 | - echo wpinv_html_text( array( |
|
1688 | + echo wpinv_html_text(array( |
|
1689 | 1689 | 'id' => 'wpinv_city', |
1690 | 1690 | 'name' => 'wpinv_city', |
1691 | 1691 | 'value' => $billing_details['city'], |
1692 | 1692 | 'class' => 'wpi-input form-control', |
1693 | - 'placeholder' => __( 'City', 'invoicing' ), |
|
1694 | - 'required' => (bool)wpinv_get_option( 'city_mandatory' ), |
|
1695 | - ) ); |
|
1693 | + 'placeholder' => __('City', 'invoicing'), |
|
1694 | + 'required' => (bool)wpinv_get_option('city_mandatory'), |
|
1695 | + )); |
|
1696 | 1696 | ?> |
1697 | 1697 | </p> |
1698 | 1698 | <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf"> |
1699 | - <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><?php if ( wpinv_get_option( 'country_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1700 | - <?php echo wpinv_html_select( array( |
|
1699 | + <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><?php if (wpinv_get_option('country_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1700 | + <?php echo wpinv_html_select(array( |
|
1701 | 1701 | 'options' => wpinv_get_country_list(), |
1702 | 1702 | 'name' => 'wpinv_country', |
1703 | 1703 | 'id' => 'wpinv_country', |
@@ -1705,16 +1705,16 @@ discard block |
||
1705 | 1705 | 'show_option_all' => false, |
1706 | 1706 | 'show_option_none' => false, |
1707 | 1707 | 'class' => 'wpi-input form-control wpi_select2', |
1708 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
1709 | - 'required' => (bool)wpinv_get_option( 'country_mandatory' ), |
|
1710 | - ) ); ?> |
|
1708 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
1709 | + 'required' => (bool)wpinv_get_option('country_mandatory'), |
|
1710 | + )); ?> |
|
1711 | 1711 | </p> |
1712 | 1712 | <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll"> |
1713 | - <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><?php if ( wpinv_get_option( 'state_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1713 | + <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><?php if (wpinv_get_option('state_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1714 | 1714 | <?php |
1715 | - $states = wpinv_get_country_states( $selected_country ); |
|
1716 | - if( !empty( $states ) ) { |
|
1717 | - echo wpinv_html_select( array( |
|
1715 | + $states = wpinv_get_country_states($selected_country); |
|
1716 | + if (!empty($states)) { |
|
1717 | + echo wpinv_html_select(array( |
|
1718 | 1718 | 'options' => $states, |
1719 | 1719 | 'name' => 'wpinv_state', |
1720 | 1720 | 'id' => 'wpinv_state', |
@@ -1722,61 +1722,61 @@ discard block |
||
1722 | 1722 | 'show_option_all' => false, |
1723 | 1723 | 'show_option_none' => false, |
1724 | 1724 | 'class' => 'wpi-input form-control wpi_select2', |
1725 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
1726 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
1727 | - ) ); |
|
1725 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
1726 | + 'required' => (bool)wpinv_get_option('state_mandatory'), |
|
1727 | + )); |
|
1728 | 1728 | } else { |
1729 | - echo wpinv_html_text( array( |
|
1729 | + echo wpinv_html_text(array( |
|
1730 | 1730 | 'name' => 'wpinv_state', |
1731 | 1731 | 'value' => $billing_details['state'], |
1732 | 1732 | 'id' => 'wpinv_state', |
1733 | 1733 | 'class' => 'wpi-input form-control', |
1734 | - 'placeholder' => __( 'State / Province', 'invoicing' ), |
|
1735 | - 'required' => (bool)wpinv_get_option( 'state_mandatory' ), |
|
1736 | - ) ); |
|
1734 | + 'placeholder' => __('State / Province', 'invoicing'), |
|
1735 | + 'required' => (bool)wpinv_get_option('state_mandatory'), |
|
1736 | + )); |
|
1737 | 1737 | } |
1738 | 1738 | ?> |
1739 | 1739 | </p> |
1740 | 1740 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
1741 | - <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?><?php if ( wpinv_get_option( 'zip_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1741 | + <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?><?php if (wpinv_get_option('zip_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1742 | 1742 | <?php |
1743 | - echo wpinv_html_text( array( |
|
1743 | + echo wpinv_html_text(array( |
|
1744 | 1744 | 'name' => 'wpinv_zip', |
1745 | 1745 | 'value' => $billing_details['zip'], |
1746 | 1746 | 'id' => 'wpinv_zip', |
1747 | 1747 | 'class' => 'wpi-input form-control', |
1748 | - 'placeholder' => __( 'ZIP / Postcode', 'invoicing' ), |
|
1749 | - 'required' => (bool)wpinv_get_option( 'zip_mandatory' ), |
|
1750 | - ) ); |
|
1748 | + 'placeholder' => __('ZIP / Postcode', 'invoicing'), |
|
1749 | + 'required' => (bool)wpinv_get_option('zip_mandatory'), |
|
1750 | + )); |
|
1751 | 1751 | ?> |
1752 | 1752 | </p> |
1753 | 1753 | <p class="wpi-cart-field wpi-col2 wpi-coll"> |
1754 | - <label for="wpinv_phone" class="wpi-label"><?php _e( 'Phone', 'invoicing' );?><?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1754 | + <label for="wpinv_phone" class="wpi-label"><?php _e('Phone', 'invoicing'); ?><?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label> |
|
1755 | 1755 | <?php |
1756 | - echo wpinv_html_text( array( |
|
1756 | + echo wpinv_html_text(array( |
|
1757 | 1757 | 'id' => 'wpinv_phone', |
1758 | 1758 | 'name' => 'wpinv_phone', |
1759 | 1759 | 'value' => $billing_details['phone'], |
1760 | 1760 | 'class' => 'wpi-input form-control', |
1761 | - 'placeholder' => __( 'Phone', 'invoicing' ), |
|
1762 | - 'required' => (bool)wpinv_get_option( 'phone_mandatory' ), |
|
1763 | - ) ); |
|
1761 | + 'placeholder' => __('Phone', 'invoicing'), |
|
1762 | + 'required' => (bool)wpinv_get_option('phone_mandatory'), |
|
1763 | + )); |
|
1764 | 1764 | ?> |
1765 | 1765 | </p> |
1766 | - <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?> |
|
1766 | + <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?> |
|
1767 | 1767 | <div class="clearfix"></div> |
1768 | 1768 | </div> |
1769 | 1769 | </div> |
1770 | - <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?> |
|
1770 | + <?php do_action('wpinv_after_billing_fields', $billing_details); ?> |
|
1771 | 1771 | </div> |
1772 | 1772 | <?php |
1773 | 1773 | } |
1774 | 1774 | } |
1775 | -add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' ); |
|
1775 | +add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info'); |
|
1776 | 1776 | |
1777 | 1777 | function wpinv_checkout_hidden_fields() { |
1778 | 1778 | ?> |
1779 | - <?php if ( is_user_logged_in() ) { ?> |
|
1779 | + <?php if (is_user_logged_in()) { ?> |
|
1780 | 1780 | <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/> |
1781 | 1781 | <?php } ?> |
1782 | 1782 | <input type="hidden" name="wpi_action" value="payment" /> |
@@ -1786,9 +1786,9 @@ discard block |
||
1786 | 1786 | function wpinv_checkout_button_purchase() { |
1787 | 1787 | ob_start(); |
1788 | 1788 | ?> |
1789 | - <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>" name="wpinv_payment" value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>"/> |
|
1789 | + <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>" name="wpinv_payment" value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>"/> |
|
1790 | 1790 | <?php |
1791 | - return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() ); |
|
1791 | + return apply_filters('wpinv_checkout_button_purchase', ob_get_clean()); |
|
1792 | 1792 | } |
1793 | 1793 | |
1794 | 1794 | function wpinv_checkout_total() { |
@@ -1797,116 +1797,116 @@ discard block |
||
1797 | 1797 | <div id="wpinv_checkout_total" class="panel panel-info"> |
1798 | 1798 | <div class="panel-body"> |
1799 | 1799 | <?php |
1800 | - do_action( 'wpinv_purchase_form_before_checkout_total' ); |
|
1800 | + do_action('wpinv_purchase_form_before_checkout_total'); |
|
1801 | 1801 | ?> |
1802 | - <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span> |
|
1802 | + <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span> |
|
1803 | 1803 | <?php |
1804 | - do_action( 'wpinv_purchase_form_after_checkout_total' ); |
|
1804 | + do_action('wpinv_purchase_form_after_checkout_total'); |
|
1805 | 1805 | ?> |
1806 | 1806 | </div> |
1807 | 1807 | </div> |
1808 | 1808 | <?php |
1809 | 1809 | } |
1810 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 ); |
|
1810 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998); |
|
1811 | 1811 | |
1812 | 1812 | function wpinv_checkout_accept_tandc() { |
1813 | - $page = wpinv_get_option( 'tandc_page' ); |
|
1813 | + $page = wpinv_get_option('tandc_page'); |
|
1814 | 1814 | ?> |
1815 | 1815 | <div id="wpinv_checkout_tandc" class="panel panel-success"> |
1816 | 1816 | <div class="panel-body"> |
1817 | 1817 | <?php echo wpinv_get_policy_text(); ?> |
1818 | 1818 | <?php |
1819 | - if(isset($page) && (int)$page > 0 && apply_filters( 'wpinv_checkout_show_terms', true )){ |
|
1820 | - $terms_link = esc_url( get_permalink( $page ) ); |
|
1819 | + if (isset($page) && (int)$page > 0 && apply_filters('wpinv_checkout_show_terms', true)) { |
|
1820 | + $terms_link = esc_url(get_permalink($page)); |
|
1821 | 1821 | ?> |
1822 | 1822 | <label class=""> |
1823 | - <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked( apply_filters( 'wpinv_terms_is_checked_default', isset( $_POST['wpi_terms'] ) ), true ); ?>> <span><?php printf( __( 'I’ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms & conditions</a>', 'invoicing' ), $terms_link ); ?></span> <span class="wpi-required">*</span> |
|
1823 | + <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked(apply_filters('wpinv_terms_is_checked_default', isset($_POST['wpi_terms'])), true); ?>> <span><?php printf(__('I’ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms & conditions</a>', 'invoicing'), $terms_link); ?></span> <span class="wpi-required">*</span> |
|
1824 | 1824 | </label> |
1825 | 1825 | <?php } ?> |
1826 | 1826 | </div> |
1827 | 1827 | </div> |
1828 | 1828 | <?php |
1829 | 1829 | } |
1830 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995 ); |
|
1830 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995); |
|
1831 | 1831 | |
1832 | 1832 | function wpinv_checkout_submit() { |
1833 | 1833 | ?> |
1834 | 1834 | <div id="wpinv_purchase_submit" class="panel panel-success"> |
1835 | 1835 | <div class="panel-body text-center"> |
1836 | 1836 | <?php |
1837 | - do_action( 'wpinv_purchase_form_before_submit' ); |
|
1837 | + do_action('wpinv_purchase_form_before_submit'); |
|
1838 | 1838 | wpinv_checkout_hidden_fields(); |
1839 | 1839 | echo wpinv_checkout_button_purchase(); |
1840 | - do_action( 'wpinv_purchase_form_after_submit' ); |
|
1840 | + do_action('wpinv_purchase_form_after_submit'); |
|
1841 | 1841 | ?> |
1842 | 1842 | </div> |
1843 | 1843 | </div> |
1844 | 1844 | <?php |
1845 | 1845 | } |
1846 | -add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 ); |
|
1846 | +add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999); |
|
1847 | 1847 | |
1848 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
1849 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1848 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
1849 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1850 | 1850 | |
1851 | - if ( empty( $invoice ) ) { |
|
1851 | + if (empty($invoice)) { |
|
1852 | 1852 | return NULL; |
1853 | 1853 | } |
1854 | 1854 | |
1855 | 1855 | $billing_details = $invoice->get_user_info(); |
1856 | 1856 | $address_row = ''; |
1857 | - if ( $address = $billing_details['address'] ) { |
|
1858 | - $address_row .= wpautop( wp_kses_post( $address ) ); |
|
1857 | + if ($address = $billing_details['address']) { |
|
1858 | + $address_row .= wpautop(wp_kses_post($address)); |
|
1859 | 1859 | } |
1860 | 1860 | |
1861 | 1861 | $address_fields = array(); |
1862 | - if ( !empty( $billing_details['city'] ) ) { |
|
1862 | + if (!empty($billing_details['city'])) { |
|
1863 | 1863 | $address_fields[] = $billing_details['city']; |
1864 | 1864 | } |
1865 | 1865 | |
1866 | - $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : ''; |
|
1867 | - if ( !empty( $billing_details['state'] ) ) { |
|
1868 | - $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country ); |
|
1866 | + $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : ''; |
|
1867 | + if (!empty($billing_details['state'])) { |
|
1868 | + $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country); |
|
1869 | 1869 | } |
1870 | 1870 | |
1871 | - if ( !empty( $billing_country ) ) { |
|
1872 | - $address_fields[] = wpinv_country_name( $billing_country ); |
|
1871 | + if (!empty($billing_country)) { |
|
1872 | + $address_fields[] = wpinv_country_name($billing_country); |
|
1873 | 1873 | } |
1874 | 1874 | |
1875 | - if ( !empty( $address_fields ) ) { |
|
1876 | - $address_fields = implode( ", ", $address_fields ); |
|
1875 | + if (!empty($address_fields)) { |
|
1876 | + $address_fields = implode(", ", $address_fields); |
|
1877 | 1877 | |
1878 | - if ( !empty( $billing_details['zip'] ) ) { |
|
1878 | + if (!empty($billing_details['zip'])) { |
|
1879 | 1879 | $address_fields .= ' ' . $billing_details['zip']; |
1880 | 1880 | } |
1881 | 1881 | |
1882 | - $address_row .= wpautop( wp_kses_post( $address_fields ) ); |
|
1882 | + $address_row .= wpautop(wp_kses_post($address_fields)); |
|
1883 | 1883 | } |
1884 | 1884 | ob_start(); |
1885 | 1885 | ?> |
1886 | 1886 | <table class="table table-bordered table-sm wpi-billing-details"> |
1887 | 1887 | <tbody> |
1888 | 1888 | <tr class="wpi-receipt-name"> |
1889 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
1890 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
1889 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
1890 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
1891 | 1891 | </tr> |
1892 | 1892 | <tr class="wpi-receipt-email"> |
1893 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
1894 | - <td><?php echo $billing_details['email'] ;?></td> |
|
1893 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
1894 | + <td><?php echo $billing_details['email']; ?></td> |
|
1895 | 1895 | </tr> |
1896 | - <?php if ( $billing_details['company'] ) { ?> |
|
1896 | + <?php if ($billing_details['company']) { ?> |
|
1897 | 1897 | <tr class="wpi-receipt-company"> |
1898 | - <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th> |
|
1899 | - <td><?php echo esc_html( $billing_details['company'] ) ;?></td> |
|
1898 | + <th class="text-left"><?php _e('Company', 'invoicing'); ?></th> |
|
1899 | + <td><?php echo esc_html($billing_details['company']); ?></td> |
|
1900 | 1900 | </tr> |
1901 | 1901 | <?php } ?> |
1902 | 1902 | <tr class="wpi-receipt-address"> |
1903 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
1904 | - <td><?php echo $address_row ;?></td> |
|
1903 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
1904 | + <td><?php echo $address_row; ?></td> |
|
1905 | 1905 | </tr> |
1906 | - <?php if ( $billing_details['phone'] ) { ?> |
|
1906 | + <?php if ($billing_details['phone']) { ?> |
|
1907 | 1907 | <tr class="wpi-receipt-phone"> |
1908 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
1909 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
1908 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
1909 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
1910 | 1910 | </tr> |
1911 | 1911 | <?php } ?> |
1912 | 1912 | </tbody> |
@@ -1914,74 +1914,74 @@ discard block |
||
1914 | 1914 | <?php |
1915 | 1915 | $output = ob_get_clean(); |
1916 | 1916 | |
1917 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
1917 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
1918 | 1918 | |
1919 | 1919 | echo $output; |
1920 | 1920 | } |
1921 | 1921 | |
1922 | -function wpinv_filter_success_page_content( $content ) { |
|
1923 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1924 | - if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) { |
|
1925 | - $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content ); |
|
1922 | +function wpinv_filter_success_page_content($content) { |
|
1923 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1924 | + if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) { |
|
1925 | + $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content); |
|
1926 | 1926 | } |
1927 | 1927 | } |
1928 | 1928 | |
1929 | 1929 | return $content; |
1930 | 1930 | } |
1931 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1931 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1932 | 1932 | |
1933 | -function wpinv_receipt_actions( $invoice ) { |
|
1934 | - if ( !empty( $invoice ) ) { |
|
1933 | +function wpinv_receipt_actions($invoice) { |
|
1934 | + if (!empty($invoice)) { |
|
1935 | 1935 | $actions = array(); |
1936 | 1936 | |
1937 | - if ( wpinv_user_can_view_invoice( $invoice->ID ) ) { |
|
1938 | - $actions['print'] = array( |
|
1939 | - 'url' => $invoice->get_view_url( true ), |
|
1940 | - 'name' => __( 'Print Invoice', 'invoicing' ), |
|
1937 | + if (wpinv_user_can_view_invoice($invoice->ID)) { |
|
1938 | + $actions['print'] = array( |
|
1939 | + 'url' => $invoice->get_view_url(true), |
|
1940 | + 'name' => __('Print Invoice', 'invoicing'), |
|
1941 | 1941 | 'class' => 'btn-primary', |
1942 | 1942 | ); |
1943 | 1943 | } |
1944 | 1944 | |
1945 | - if ( is_user_logged_in() ) { |
|
1945 | + if (is_user_logged_in()) { |
|
1946 | 1946 | $actions['history'] = array( |
1947 | 1947 | 'url' => wpinv_get_history_page_uri(), |
1948 | - 'name' => __( 'Invoice History', 'invoicing' ), |
|
1948 | + 'name' => __('Invoice History', 'invoicing'), |
|
1949 | 1949 | 'class' => 'btn-warning', |
1950 | 1950 | ); |
1951 | 1951 | } |
1952 | 1952 | |
1953 | - $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice ); |
|
1953 | + $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice); |
|
1954 | 1954 | |
1955 | - if ( !empty( $actions ) ) { |
|
1955 | + if (!empty($actions)) { |
|
1956 | 1956 | ?> |
1957 | 1957 | <div class="wpinv-receipt-actions text-right"> |
1958 | - <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?> |
|
1959 | - <a href="<?php echo esc_url( $action['url'] );?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class( $key );?>" <?php echo ( !empty($action['attrs']) ? $action['attrs'] : '' ) ;?>><?php echo esc_html( $action['name'] );?></a> |
|
1958 | + <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?> |
|
1959 | + <a href="<?php echo esc_url($action['url']); ?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class($key); ?>" <?php echo (!empty($action['attrs']) ? $action['attrs'] : ''); ?>><?php echo esc_html($action['name']); ?></a> |
|
1960 | 1960 | <?php } ?> |
1961 | 1961 | </div> |
1962 | 1962 | <?php |
1963 | 1963 | } |
1964 | 1964 | } |
1965 | 1965 | } |
1966 | -add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 ); |
|
1966 | +add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1); |
|
1967 | 1967 | |
1968 | -function wpinv_invoice_link( $invoice_id ) { |
|
1969 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1968 | +function wpinv_invoice_link($invoice_id) { |
|
1969 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1970 | 1970 | |
1971 | - if ( empty( $invoice ) ) { |
|
1971 | + if (empty($invoice)) { |
|
1972 | 1972 | return NULL; |
1973 | 1973 | } |
1974 | 1974 | |
1975 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1975 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1976 | 1976 | |
1977 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1977 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1978 | 1978 | } |
1979 | 1979 | |
1980 | -function wpinv_invoice_subscription_details( $invoice ) { |
|
1981 | - if ( !empty( $invoice ) && $invoice->is_recurring() && ! wpinv_is_subscription_payment( $invoice ) ) { |
|
1982 | - $subscription = wpinv_get_subscription( $invoice, true ); |
|
1980 | +function wpinv_invoice_subscription_details($invoice) { |
|
1981 | + if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) { |
|
1982 | + $subscription = wpinv_get_subscription($invoice, true); |
|
1983 | 1983 | |
1984 | - if ( empty( $subscription ) ) { |
|
1984 | + if (empty($subscription)) { |
|
1985 | 1985 | return; |
1986 | 1986 | } |
1987 | 1987 | |
@@ -1992,15 +1992,15 @@ discard block |
||
1992 | 1992 | $payments = $subscription->get_child_payments(); |
1993 | 1993 | ?> |
1994 | 1994 | <div class="wpinv-subscriptions-details"> |
1995 | - <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3> |
|
1995 | + <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3> |
|
1996 | 1996 | <table class="table"> |
1997 | 1997 | <thead> |
1998 | 1998 | <tr> |
1999 | - <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th> |
|
2000 | - <th><?php _e( 'Start Date', 'invoicing' ) ;?></th> |
|
2001 | - <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th> |
|
2002 | - <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th> |
|
2003 | - <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th> |
|
1999 | + <th><?php _e('Billing Cycle', 'invoicing'); ?></th> |
|
2000 | + <th><?php _e('Start Date', 'invoicing'); ?></th> |
|
2001 | + <th><?php _e('Expiration Date', 'invoicing'); ?></th> |
|
2002 | + <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th> |
|
2003 | + <th class="text-center"><?php _e('Status', 'invoicing'); ?></th> |
|
2004 | 2004 | </tr> |
2005 | 2005 | </thead> |
2006 | 2006 | <tbody> |
@@ -2014,29 +2014,29 @@ discard block |
||
2014 | 2014 | </tbody> |
2015 | 2015 | </table> |
2016 | 2016 | </div> |
2017 | - <?php if ( !empty( $payments ) ) { ?> |
|
2017 | + <?php if (!empty($payments)) { ?> |
|
2018 | 2018 | <div class="wpinv-renewal-payments"> |
2019 | - <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3> |
|
2019 | + <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3> |
|
2020 | 2020 | <table class="table"> |
2021 | 2021 | <thead> |
2022 | 2022 | <tr> |
2023 | 2023 | <th>#</th> |
2024 | - <th><?php _e( 'Invoice', 'invoicing' ) ;?></th> |
|
2025 | - <th><?php _e( 'Date', 'invoicing' ) ;?></th> |
|
2026 | - <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th> |
|
2024 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
2025 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
2026 | + <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th> |
|
2027 | 2027 | </tr> |
2028 | 2028 | </thead> |
2029 | 2029 | <tbody> |
2030 | 2030 | <?php |
2031 | 2031 | $i = 1; |
2032 | - foreach ( $payments as $payment ) { |
|
2032 | + foreach ($payments as $payment) { |
|
2033 | 2033 | $invoice_id = $payment->ID; |
2034 | 2034 | ?> |
2035 | 2035 | <tr> |
2036 | - <th scope="row"><?php echo $i;?></th> |
|
2037 | - <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td> |
|
2038 | - <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td> |
|
2039 | - <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td> |
|
2036 | + <th scope="row"><?php echo $i; ?></th> |
|
2037 | + <td><?php echo wpinv_invoice_link($invoice_id); ?></td> |
|
2038 | + <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td> |
|
2039 | + <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td> |
|
2040 | 2040 | </tr> |
2041 | 2041 | <?php $i++; } ?> |
2042 | 2042 | </tbody> |
@@ -2047,52 +2047,52 @@ discard block |
||
2047 | 2047 | } |
2048 | 2048 | } |
2049 | 2049 | |
2050 | -function wpinv_cart_total_label( $label, $invoice ) { |
|
2051 | - if ( empty( $invoice ) ) { |
|
2050 | +function wpinv_cart_total_label($label, $invoice) { |
|
2051 | + if (empty($invoice)) { |
|
2052 | 2052 | return $label; |
2053 | 2053 | } |
2054 | 2054 | |
2055 | 2055 | $prefix_label = ''; |
2056 | - if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) { |
|
2057 | - $prefix_label = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice ); |
|
2058 | - } else if ( $invoice->is_renewal() ) { |
|
2059 | - $prefix_label = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> '; |
|
2056 | + if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) { |
|
2057 | + $prefix_label = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice); |
|
2058 | + } else if ($invoice->is_renewal()) { |
|
2059 | + $prefix_label = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> '; |
|
2060 | 2060 | } |
2061 | 2061 | |
2062 | - if ( $prefix_label != '' ) { |
|
2063 | - $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
2062 | + if ($prefix_label != '') { |
|
2063 | + $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label; |
|
2064 | 2064 | } |
2065 | 2065 | |
2066 | 2066 | return $label; |
2067 | 2067 | } |
2068 | -add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2069 | -add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2070 | -add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 ); |
|
2068 | +add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2069 | +add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2070 | +add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2); |
|
2071 | 2071 | |
2072 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 ); |
|
2072 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1); |
|
2073 | 2073 | |
2074 | -function wpinv_invoice_print_description( $invoice ) { |
|
2075 | - if ( empty( $invoice ) ) { |
|
2074 | +function wpinv_invoice_print_description($invoice) { |
|
2075 | + if (empty($invoice)) { |
|
2076 | 2076 | return NULL; |
2077 | 2077 | } |
2078 | - if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) { |
|
2078 | + if ($description = wpinv_get_invoice_description($invoice->ID)) { |
|
2079 | 2079 | ?> |
2080 | 2080 | <div class="row wpinv-lower"> |
2081 | 2081 | <div class="col-sm-12 wpinv-description"> |
2082 | - <?php echo wpautop( $description ); ?> |
|
2082 | + <?php echo wpautop($description); ?> |
|
2083 | 2083 | </div> |
2084 | 2084 | </div> |
2085 | 2085 | <?php |
2086 | 2086 | } |
2087 | 2087 | } |
2088 | -add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 ); |
|
2088 | +add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1); |
|
2089 | 2089 | |
2090 | -function wpinv_invoice_print_payment_info( $invoice ) { |
|
2091 | - if ( empty( $invoice ) ) { |
|
2090 | +function wpinv_invoice_print_payment_info($invoice) { |
|
2091 | + if (empty($invoice)) { |
|
2092 | 2092 | return NULL; |
2093 | 2093 | } |
2094 | 2094 | |
2095 | - if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) { |
|
2095 | + if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) { |
|
2096 | 2096 | ?> |
2097 | 2097 | <div class="row wpinv-payments"> |
2098 | 2098 | <div class="col-sm-12"> |
@@ -2104,43 +2104,43 @@ discard block |
||
2104 | 2104 | } |
2105 | 2105 | // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 ); |
2106 | 2106 | |
2107 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
2108 | - if ( empty( $note ) ) { |
|
2107 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
2108 | + if (empty($note)) { |
|
2109 | 2109 | return NULL; |
2110 | 2110 | } |
2111 | 2111 | |
2112 | - if ( is_int( $note ) ) { |
|
2113 | - $note = get_comment( $note ); |
|
2112 | + if (is_int($note)) { |
|
2113 | + $note = get_comment($note); |
|
2114 | 2114 | } |
2115 | 2115 | |
2116 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
2116 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
2117 | 2117 | return NULL; |
2118 | 2118 | } |
2119 | 2119 | |
2120 | - $note_classes = array( 'note' ); |
|
2121 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
2120 | + $note_classes = array('note'); |
|
2121 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
2122 | 2122 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
2123 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
2124 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
2123 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
2124 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
2125 | 2125 | |
2126 | 2126 | ob_start(); |
2127 | 2127 | ?> |
2128 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>"> |
|
2128 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>"> |
|
2129 | 2129 | <div class="note_content"> |
2130 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
2130 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
2131 | 2131 | </div> |
2132 | 2132 | <p class="meta"> |
2133 | - <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr> |
|
2134 | - <?php if ( $note->comment_author !== 'System' || current_user_can( 'manage_options' ) ) { ?> |
|
2135 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
2133 | + <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr> |
|
2134 | + <?php if ($note->comment_author !== 'System' || current_user_can('manage_options')) { ?> |
|
2135 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
2136 | 2136 | <?php } ?> |
2137 | 2137 | </p> |
2138 | 2138 | </li> |
2139 | 2139 | <?php |
2140 | 2140 | $note_content = ob_get_clean(); |
2141 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
2141 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
2142 | 2142 | |
2143 | - if ( $echo ) { |
|
2143 | + if ($echo) { |
|
2144 | 2144 | echo $note_content; |
2145 | 2145 | } else { |
2146 | 2146 | return $note_content; |
@@ -2150,43 +2150,43 @@ discard block |
||
2150 | 2150 | function wpinv_invalid_invoice_content() { |
2151 | 2151 | global $post; |
2152 | 2152 | |
2153 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
2153 | + $invoice = wpinv_get_invoice($post->ID); |
|
2154 | 2154 | |
2155 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing' ); |
|
2156 | - if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
2157 | - if ( is_user_logged_in() ) { |
|
2158 | - if ( wpinv_require_login_to_checkout() ) { |
|
2159 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
2160 | - $error = __( 'You are not allowed to view this invoice.', 'invoicing' ); |
|
2155 | + $error = __('This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing'); |
|
2156 | + if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) { |
|
2157 | + if (is_user_logged_in()) { |
|
2158 | + if (wpinv_require_login_to_checkout()) { |
|
2159 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
2160 | + $error = __('You are not allowed to view this invoice.', 'invoicing'); |
|
2161 | 2161 | } |
2162 | 2162 | } |
2163 | 2163 | } else { |
2164 | - if ( wpinv_require_login_to_checkout() ) { |
|
2165 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
2166 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
2164 | + if (wpinv_require_login_to_checkout()) { |
|
2165 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
2166 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
2167 | 2167 | } |
2168 | 2168 | } |
2169 | 2169 | } |
2170 | 2170 | } else { |
2171 | - $error = __( 'This invoice is deleted or does not exist.', 'invoicing' ); |
|
2171 | + $error = __('This invoice is deleted or does not exist.', 'invoicing'); |
|
2172 | 2172 | } |
2173 | 2173 | ?> |
2174 | 2174 | <div class="row wpinv-row-invalid"> |
2175 | 2175 | <div class="col-md-6 col-md-offset-3 wpinv-message error"> |
2176 | - <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3> |
|
2176 | + <h3><?php _e('Access Denied', 'invoicing'); ?></h3> |
|
2177 | 2177 | <p class="wpinv-msg-text"><?php echo $error; ?></p> |
2178 | 2178 | </div> |
2179 | 2179 | </div> |
2180 | 2180 | <?php |
2181 | 2181 | } |
2182 | -add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' ); |
|
2182 | +add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content'); |
|
2183 | 2183 | |
2184 | -add_action( 'wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field'); |
|
2185 | -function wpinv_force_company_name_field(){ |
|
2184 | +add_action('wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field'); |
|
2185 | +function wpinv_force_company_name_field() { |
|
2186 | 2186 | $invoice = wpinv_get_invoice_cart(); |
2187 | - $user_id = wpinv_get_user_id( $invoice->ID ); |
|
2188 | - $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true ); |
|
2189 | - if ( 1 == wpinv_get_option( 'force_show_company' ) && !wpinv_use_taxes() ) { |
|
2187 | + $user_id = wpinv_get_user_id($invoice->ID); |
|
2188 | + $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true); |
|
2189 | + if (1 == wpinv_get_option('force_show_company') && !wpinv_use_taxes()) { |
|
2190 | 2190 | ?> |
2191 | 2191 | <p class="wpi-cart-field wpi-col2 wpi-colf"> |
2192 | 2192 | <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label> |
@@ -2211,21 +2211,21 @@ discard block |
||
2211 | 2211 | * @return string |
2212 | 2212 | */ |
2213 | 2213 | function wpinv_get_policy_text() { |
2214 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
2214 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
2215 | 2215 | |
2216 | - $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' )); |
|
2216 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
2217 | 2217 | |
2218 | - if(!$privacy_page_id){ |
|
2219 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
2218 | + if (!$privacy_page_id) { |
|
2219 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
2220 | 2220 | } |
2221 | 2221 | |
2222 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
2222 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
2223 | 2223 | |
2224 | 2224 | $find_replace = array( |
2225 | 2225 | '[wpinv_privacy_policy]' => $privacy_link, |
2226 | 2226 | ); |
2227 | 2227 | |
2228 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
2228 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
2229 | 2229 | |
2230 | 2230 | return wp_kses_post(wpautop($privacy_text)); |
2231 | 2231 | } |
@@ -2234,25 +2234,25 @@ discard block |
||
2234 | 2234 | /** |
2235 | 2235 | * Allows the user to set their own price for an invoice item |
2236 | 2236 | */ |
2237 | -function wpinv_checkout_cart_item_name_your_price( $cart_item, $key ) { |
|
2237 | +function wpinv_checkout_cart_item_name_your_price($cart_item, $key) { |
|
2238 | 2238 | |
2239 | 2239 | //Ensure we have an item id |
2240 | - if(! is_array( $cart_item ) || empty( $cart_item['id'] ) ) { |
|
2240 | + if (!is_array($cart_item) || empty($cart_item['id'])) { |
|
2241 | 2241 | return; |
2242 | 2242 | } |
2243 | 2243 | |
2244 | 2244 | //Fetch the item |
2245 | 2245 | $item_id = $cart_item['id']; |
2246 | - $item = new WPInv_Item( $item_id ); |
|
2246 | + $item = new WPInv_Item($item_id); |
|
2247 | 2247 | |
2248 | - if(! $item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing() ) { |
|
2248 | + if (!$item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing()) { |
|
2249 | 2249 | return; |
2250 | 2250 | } |
2251 | 2251 | |
2252 | 2252 | //Fetch the dynamic pricing "strings" |
2253 | - $suggested_price_text = esc_html( wpinv_get_option( 'suggested_price_text', __( 'Suggested Price:', 'invoicing' ) ) ); |
|
2254 | - $minimum_price_text = esc_html( wpinv_get_option( 'minimum_price_text', __( 'Minimum Price:', 'invoicing' ) ) ); |
|
2255 | - $name_your_price_text = esc_html( wpinv_get_option( 'name_your_price_text', __( 'Name Your Price', 'invoicing' ) ) ); |
|
2253 | + $suggested_price_text = esc_html(wpinv_get_option('suggested_price_text', __('Suggested Price:', 'invoicing'))); |
|
2254 | + $minimum_price_text = esc_html(wpinv_get_option('minimum_price_text', __('Minimum Price:', 'invoicing'))); |
|
2255 | + $name_your_price_text = esc_html(wpinv_get_option('name_your_price_text', __('Name Your Price', 'invoicing'))); |
|
2256 | 2256 | |
2257 | 2257 | //Display a "name_your_price" button |
2258 | 2258 | echo " — <a href='#' class='wpinv-name-your-price-frontend small'>$name_your_price_text</a></div>"; |
@@ -2261,7 +2261,7 @@ discard block |
||
2261 | 2261 | echo '<div class="name-your-price-miniform">'; |
2262 | 2262 | |
2263 | 2263 | //Maybe display the recommended price |
2264 | - if( $item->get_price() > 0 && !empty( $suggested_price_text ) ) { |
|
2264 | + if ($item->get_price() > 0 && !empty($suggested_price_text)) { |
|
2265 | 2265 | $suggested_price = $item->get_the_price(); |
2266 | 2266 | echo "<div>$suggested_price_text — $suggested_price</div>"; |
2267 | 2267 | } |
@@ -2269,30 +2269,30 @@ discard block |
||
2269 | 2269 | //Display the update price form |
2270 | 2270 | $symbol = wpinv_currency_symbol(); |
2271 | 2271 | $position = wpinv_currency_position(); |
2272 | - $minimum = esc_attr( $item->get_minimum_price() ); |
|
2273 | - $price = esc_attr( $cart_item['item_price'] ); |
|
2274 | - $update = esc_attr__( "Update", 'invoicing' ); |
|
2272 | + $minimum = esc_attr($item->get_minimum_price()); |
|
2273 | + $price = esc_attr($cart_item['item_price']); |
|
2274 | + $update = esc_attr__("Update", 'invoicing'); |
|
2275 | 2275 | |
2276 | 2276 | //Ensure it supports dynamic prici |
2277 | - if( $price < $minimum ) { |
|
2277 | + if ($price < $minimum) { |
|
2278 | 2278 | $price = $minimum; |
2279 | 2279 | } |
2280 | 2280 | |
2281 | 2281 | echo '<label>'; |
2282 | 2282 | echo $position != 'right' ? $symbol . ' ' : ''; |
2283 | 2283 | echo "<input type='number' min='$minimum' placeholder='$price' value='$price' class='wpi-field-price' />"; |
2284 | - echo $position == 'right' ? ' ' . $symbol : '' ; |
|
2284 | + echo $position == 'right' ? ' ' . $symbol : ''; |
|
2285 | 2285 | echo "</label>"; |
2286 | 2286 | echo "<input type='hidden' value='$item_id' class='wpi-field-item' />"; |
2287 | 2287 | echo "<a class='btn btn-success wpinv-submit wpinv-update-dynamic-price-frontend'>$update</a>"; |
2288 | 2288 | |
2289 | 2289 | //Maybe display the minimum price |
2290 | - if( $item->get_minimum_price() > 0 && !empty( $minimum_price_text ) ) { |
|
2291 | - $minimum_price = wpinv_price( wpinv_format_amount( $item->get_minimum_price() ) ); |
|
2290 | + if ($item->get_minimum_price() > 0 && !empty($minimum_price_text)) { |
|
2291 | + $minimum_price = wpinv_price(wpinv_format_amount($item->get_minimum_price())); |
|
2292 | 2292 | echo "<div>$minimum_price_text — $minimum_price</div>"; |
2293 | 2293 | } |
2294 | 2294 | |
2295 | 2295 | echo "</div>"; |
2296 | 2296 | |
2297 | 2297 | } |
2298 | -add_action( 'wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2 ); |
|
2299 | 2298 | \ No newline at end of file |
2299 | +add_action('wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2); |
|
2300 | 2300 | \ No newline at end of file |
@@ -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,40 +23,40 @@ discard block |
||
23 | 23 | 'block-keywords'=> "['invoicing','buy', 'buy item']", |
24 | 24 | 'class_name' => __CLASS__, |
25 | 25 | 'base_id' => 'wpinv_buy', |
26 | - 'name' => __('Invoicing > Buy Item Button','invoicing'), |
|
26 | + 'name' => __('Invoicing > Buy Item Button', 'invoicing'), |
|
27 | 27 | 'widget_ops' => array( |
28 | 28 | 'classname' => 'wpinv-buy-item-class', |
29 | - 'description' => esc_html__('Displays buy invoicing item button.','invoicing'), |
|
29 | + 'description' => esc_html__('Displays buy invoicing item button.', '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' => '', |
38 | 38 | 'advanced' => false |
39 | 39 | ), |
40 | 40 | 'buy_items' => array( |
41 | - 'title' => __( 'Items to buy', 'invoicing' ), |
|
42 | - 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2 ', 'invoicing' ), |
|
41 | + 'title' => __('Items to buy', 'invoicing'), |
|
42 | + 'desc' => __('Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2 ', 'invoicing'), |
|
43 | 43 | 'type' => 'text', |
44 | 44 | 'desc_tip' => true, |
45 | 45 | 'default' => '', |
46 | - 'placeholder' => __('Items to buy','invoicing'), |
|
46 | + 'placeholder' => __('Items to buy', 'invoicing'), |
|
47 | 47 | 'advanced' => false |
48 | 48 | ), |
49 | 49 | 'button_label' => array( |
50 | - 'title' => __( 'Button Label', 'invoicing' ), |
|
51 | - 'desc' => __( 'Enter button label. Default "Buy Now".', 'invoicing' ), |
|
50 | + 'title' => __('Button Label', 'invoicing'), |
|
51 | + 'desc' => __('Enter button label. Default "Buy Now".', 'invoicing'), |
|
52 | 52 | 'type' => 'text', |
53 | 53 | 'desc_tip' => true, |
54 | 54 | 'default' => '', |
55 | 55 | 'advanced' => true |
56 | 56 | ), |
57 | 57 | 'post_id' => array( |
58 | - 'title' => __( 'Post ID', 'invoicing' ), |
|
59 | - 'desc' => __( 'Enter related post ID. This is for 3rd party add ons and not mandatory field.', 'invoicing' ), |
|
58 | + 'title' => __('Post ID', 'invoicing'), |
|
59 | + 'desc' => __('Enter related post ID. This is for 3rd party add ons and not mandatory field.', 'invoicing'), |
|
60 | 60 | 'type' => 'number', |
61 | 61 | 'desc_tip' => true, |
62 | 62 | 'default' => '', |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | ); |
68 | 68 | |
69 | 69 | |
70 | - parent::__construct( $options ); |
|
70 | + parent::__construct($options); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -79,24 +79,24 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return string |
81 | 81 | */ |
82 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
82 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
83 | 83 | |
84 | 84 | $defaults = array( |
85 | 85 | 'buy_items' => '', // should be used like: item_id|quantity,item_id|quantity,item_id|quantity |
86 | - 'button_label' => __( 'Buy Now', 'invoicing' ), // the button title |
|
86 | + 'button_label' => __('Buy Now', 'invoicing'), // the button title |
|
87 | 87 | 'post_id' => '', // any related post_id |
88 | 88 | ); |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Parse incoming $args into an array and merge it with $defaults |
92 | 92 | */ |
93 | - $args = wp_parse_args( $args, $defaults ); |
|
93 | + $args = wp_parse_args($args, $defaults); |
|
94 | 94 | |
95 | - $post_id = isset( $args['post_id'] ) ? (int)$args['post_id'] : 0; |
|
95 | + $post_id = isset($args['post_id']) ? (int)$args['post_id'] : 0; |
|
96 | 96 | |
97 | 97 | $html = '<div class="wpi-buy-button-wrapper wpi-g">'; |
98 | 98 | $html .= '<button class="button button-primary wpi-buy-button" type="button" onclick="wpi_buy(this,\'' . $args['buy_items'] . '\',' . $post_id . ');">' . $args['button_label'] . '</button>'; |
99 | - $html .= wp_nonce_field( 'wpinv_buy_items', 'wpinv_buy_nonce', true, false ); |
|
99 | + $html .= wp_nonce_field('wpinv_buy_items', 'wpinv_buy_nonce', true, false); |
|
100 | 100 | $html .= '</div>'; |
101 | 101 | |
102 | 102 | return $html; |
@@ -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(); |
@@ -31,31 +31,31 @@ discard block |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | public function define_constants() { |
34 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
35 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
34 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
35 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | private function actions() { |
39 | 39 | /* Internationalize the text strings used. */ |
40 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
40 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
41 | 41 | |
42 | 42 | /* Perform actions on admin initialization. */ |
43 | - add_action( 'admin_init', array( &$this, 'admin_init') ); |
|
44 | - add_action( 'init', array( &$this, 'init' ), 3 ); |
|
45 | - add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
43 | + add_action('admin_init', array(&$this, 'admin_init')); |
|
44 | + add_action('init', array(&$this, 'init'), 3); |
|
45 | + add_action('init', array(&$this, 'wpinv_actions')); |
|
46 | 46 | |
47 | - if ( class_exists( 'BuddyPress' ) ) { |
|
48 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
47 | + if (class_exists('BuddyPress')) { |
|
48 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
49 | 49 | } |
50 | 50 | |
51 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
52 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
51 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
52 | + add_action('widgets_init', array(&$this, 'register_widgets')); |
|
53 | 53 | |
54 | - if ( is_admin() ) { |
|
55 | - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); |
|
56 | - add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) ); |
|
54 | + if (is_admin()) { |
|
55 | + add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts')); |
|
56 | + add_action('admin_body_class', array(&$this, 'admin_body_class')); |
|
57 | 57 | } else { |
58 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
58 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -65,16 +65,16 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference. |
67 | 67 | */ |
68 | - do_action_ref_array( 'wpinv_actions', array( &$this ) ); |
|
68 | + do_action_ref_array('wpinv_actions', array(&$this)); |
|
69 | 69 | |
70 | - add_action( 'admin_init', array( &$this, 'activation_redirect') ); |
|
70 | + add_action('admin_init', array(&$this, 'activation_redirect')); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | public function plugins_loaded() { |
74 | 74 | /* Internationalize the text strings used. */ |
75 | 75 | $this->load_textdomain(); |
76 | 76 | |
77 | - do_action( 'wpinv_loaded' ); |
|
77 | + do_action('wpinv_loaded'); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -82,222 +82,222 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @since 1.0 |
84 | 84 | */ |
85 | - public function load_textdomain( $locale = NULL ) { |
|
86 | - if ( empty( $locale ) ) { |
|
87 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
85 | + public function load_textdomain($locale = NULL) { |
|
86 | + if (empty($locale)) { |
|
87 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
88 | 88 | } |
89 | 89 | |
90 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
90 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
91 | 91 | |
92 | - unload_textdomain( 'invoicing' ); |
|
93 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
94 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
92 | + unload_textdomain('invoicing'); |
|
93 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
94 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
95 | 95 | |
96 | 96 | /** |
97 | 97 | * Define language constants. |
98 | 98 | */ |
99 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
99 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | public function includes() { |
103 | 103 | global $wpinv_options; |
104 | 104 | |
105 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
105 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
106 | 106 | $wpinv_options = wpinv_get_settings(); |
107 | 107 | |
108 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' ); |
|
109 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
110 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
111 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
112 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
113 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
114 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
115 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' ); |
|
116 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
117 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
118 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
119 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
120 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
121 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); |
|
122 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); |
|
123 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); |
|
124 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); |
|
125 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
126 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
127 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
128 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
129 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
130 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
131 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
132 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
133 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
134 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' ); |
|
135 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
136 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' ); |
|
137 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
138 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
139 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
140 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
141 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
142 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
143 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
144 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
145 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
146 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
147 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
148 | - |
|
149 | - if ( !class_exists( 'WPInv_EUVat' ) ) { |
|
150 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
108 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php'); |
|
109 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
110 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
111 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
112 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
113 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
114 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
115 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php'); |
|
116 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
117 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
118 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
119 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
120 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
121 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php'); |
|
122 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); |
|
123 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); |
|
124 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); |
|
125 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
126 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
127 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
128 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
129 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
130 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
131 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
132 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
133 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
134 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php'); |
|
135 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
136 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php'); |
|
137 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
138 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
139 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
140 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
141 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
142 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
143 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
144 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
145 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
146 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
147 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
148 | + |
|
149 | + if (!class_exists('WPInv_EUVat')) { |
|
150 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
151 | 151 | } |
152 | 152 | |
153 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
154 | - if ( !empty( $gateways ) ) { |
|
155 | - foreach ( $gateways as $gateway ) { |
|
156 | - if ( $gateway == 'manual' ) { |
|
153 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
154 | + if (!empty($gateways)) { |
|
155 | + foreach ($gateways as $gateway) { |
|
156 | + if ($gateway == 'manual') { |
|
157 | 157 | continue; |
158 | 158 | } |
159 | 159 | |
160 | 160 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
161 | 161 | |
162 | - if ( file_exists( $gateway_file ) ) { |
|
163 | - require_once( $gateway_file ); |
|
162 | + if (file_exists($gateway_file)) { |
|
163 | + require_once($gateway_file); |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | } |
167 | - require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
167 | + require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
|
168 | 168 | |
169 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
170 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
171 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
172 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); |
|
169 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
170 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
171 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
172 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); |
|
173 | 173 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
174 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); |
|
175 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); |
|
176 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
177 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); |
|
178 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
179 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
180 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
174 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); |
|
175 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); |
|
176 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
177 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); |
|
178 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
179 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
180 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
181 | 181 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
182 | 182 | // load the user class only on the users.php page |
183 | 183 | global $pagenow; |
184 | - if($pagenow=='users.php'){ |
|
184 | + if ($pagenow == 'users.php') { |
|
185 | 185 | new WPInv_Admin_Users(); |
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
189 | 189 | // include css inliner |
190 | - if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
|
191 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
190 | + if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
191 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
192 | 192 | } |
193 | 193 | |
194 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
194 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | public function init() { |
198 | 198 | } |
199 | 199 | |
200 | 200 | public function admin_init() { |
201 | - add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
201 | + add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | public function activation_redirect() { |
205 | 205 | // Bail if no activation redirect |
206 | - if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
206 | + if (!get_transient('_wpinv_activation_redirect')) { |
|
207 | 207 | return; |
208 | 208 | } |
209 | 209 | |
210 | 210 | // Delete the redirect transient |
211 | - delete_transient( '_wpinv_activation_redirect' ); |
|
211 | + delete_transient('_wpinv_activation_redirect'); |
|
212 | 212 | |
213 | 213 | // Bail if activating from network, or bulk |
214 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
214 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
215 | 215 | return; |
216 | 216 | } |
217 | 217 | |
218 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
218 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
219 | 219 | exit; |
220 | 220 | } |
221 | 221 | |
222 | 222 | public function enqueue_scripts() { |
223 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
223 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
224 | 224 | |
225 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); |
|
226 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
225 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); |
|
226 | + wp_enqueue_style('wpinv_front_style'); |
|
227 | 227 | |
228 | 228 | // Register scripts |
229 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
230 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), WPINV_VERSION ); |
|
229 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
230 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), WPINV_VERSION); |
|
231 | 231 | |
232 | 232 | $localize = array(); |
233 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
234 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
233 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
234 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
235 | 235 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
236 | 236 | $localize['currency_pos'] = wpinv_currency_position(); |
237 | 237 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
238 | 238 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
239 | 239 | $localize['decimals'] = wpinv_decimals(); |
240 | - $localize['txtComplete'] = __( 'Complete', 'invoicing' ); |
|
240 | + $localize['txtComplete'] = __('Complete', 'invoicing'); |
|
241 | 241 | $localize['UseTaxes'] = wpinv_use_taxes(); |
242 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
242 | + $localize['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
243 | 243 | |
244 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
244 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
245 | 245 | |
246 | - wp_enqueue_script( 'jquery-blockui' ); |
|
246 | + wp_enqueue_script('jquery-blockui'); |
|
247 | 247 | $autofill_api = wpinv_get_option('address_autofill_api'); |
248 | 248 | $autofill_active = wpinv_get_option('address_autofill_active'); |
249 | - if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
250 | - if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
251 | - wp_dequeue_script( 'google-maps-api' ); |
|
249 | + if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
|
250 | + if (wp_script_is('google-maps-api', 'enqueued')) { |
|
251 | + wp_dequeue_script('google-maps-api'); |
|
252 | 252 | } |
253 | - wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
254 | - wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
253 | + wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
|
254 | + wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
|
255 | 255 | } |
256 | 256 | |
257 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
258 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
257 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
258 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
259 | 259 | |
260 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
261 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
260 | + wp_enqueue_script('wpinv-front-script'); |
|
261 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | public function admin_enqueue_scripts() { |
265 | 265 | global $post, $pagenow; |
266 | 266 | |
267 | 267 | $post_type = wpinv_admin_post_type(); |
268 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
269 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : ''; |
|
268 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
269 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : ''; |
|
270 | 270 | |
271 | 271 | $jquery_ui_css = false; |
272 | - if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
272 | + if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
273 | 273 | $jquery_ui_css = true; |
274 | - } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) { |
|
274 | + } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') { |
|
275 | 275 | $jquery_ui_css = true; |
276 | 276 | } |
277 | - if ( $jquery_ui_css ) { |
|
278 | - wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
|
279 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
277 | + if ($jquery_ui_css) { |
|
278 | + wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
279 | + wp_enqueue_style('jquery-ui-css'); |
|
280 | 280 | } |
281 | 281 | |
282 | - wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
283 | - wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
282 | + wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
283 | + wp_enqueue_style('wpinv_meta_box_style'); |
|
284 | 284 | |
285 | - wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION ); |
|
286 | - wp_enqueue_style( 'wpinv_admin_style' ); |
|
285 | + wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION); |
|
286 | + wp_enqueue_style('wpinv_admin_style'); |
|
287 | 287 | |
288 | - $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ); |
|
289 | - if ( $page == 'wpinv-subscriptions' ) { |
|
290 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
288 | + $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')); |
|
289 | + if ($page == 'wpinv-subscriptions') { |
|
290 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
291 | 291 | } |
292 | 292 | |
293 | - if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) { |
|
294 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
293 | + if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) { |
|
294 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
295 | 295 | } |
296 | 296 | |
297 | - wp_enqueue_style( 'wp-color-picker' ); |
|
298 | - wp_enqueue_script( 'wp-color-picker' ); |
|
297 | + wp_enqueue_style('wp-color-picker'); |
|
298 | + wp_enqueue_script('wp-color-picker'); |
|
299 | 299 | |
300 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
300 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
301 | 301 | |
302 | 302 | if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
303 | 303 | $autofill_api = wpinv_get_option('address_autofill_api'); |
@@ -308,20 +308,20 @@ discard block |
||
308 | 308 | } |
309 | 309 | } |
310 | 310 | |
311 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
312 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
311 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
312 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
313 | 313 | |
314 | - wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ), WPINV_VERSION ); |
|
315 | - wp_enqueue_script( 'wpinv-admin-script' ); |
|
314 | + wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION); |
|
315 | + wp_enqueue_script('wpinv-admin-script'); |
|
316 | 316 | |
317 | 317 | $localize = array(); |
318 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
319 | - $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
|
320 | - $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
321 | - $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
|
322 | - $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
|
323 | - $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
|
324 | - $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
318 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
319 | + $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
320 | + $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
321 | + $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
322 | + $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
323 | + $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
324 | + $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
|
325 | 325 | $localize['tax'] = wpinv_tax_amount(); |
326 | 326 | $localize['discount'] = wpinv_discount_amount(); |
327 | 327 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
@@ -329,69 +329,69 @@ discard block |
||
329 | 329 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
330 | 330 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
331 | 331 | $localize['decimals'] = wpinv_decimals(); |
332 | - $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
|
333 | - $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
|
334 | - $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
|
335 | - $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
|
336 | - $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
|
337 | - $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
|
338 | - $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
|
339 | - $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' ); |
|
340 | - $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
|
341 | - $localize['emptyInvoice'] = __( 'Add at least one item to save invoice!', 'invoicing' ); |
|
342 | - $localize['errDeleteItem'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
|
343 | - $localize['delete_subscription'] = __( 'Are you sure you want to delete this subscription?', 'invoicing' ); |
|
344 | - $localize['action_edit'] = __( 'Edit', 'invoicing' ); |
|
345 | - $localize['action_cancel'] = __( 'Cancel', 'invoicing' ); |
|
346 | - |
|
347 | - $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
348 | - |
|
349 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
350 | - |
|
351 | - if ( $page == 'wpinv-subscriptions' ) { |
|
352 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
353 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
332 | + $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
333 | + $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
334 | + $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
335 | + $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
336 | + $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
337 | + $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
338 | + $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
339 | + $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'); |
|
340 | + $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
|
341 | + $localize['emptyInvoice'] = __('Add at least one item to save invoice!', 'invoicing'); |
|
342 | + $localize['errDeleteItem'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
|
343 | + $localize['delete_subscription'] = __('Are you sure you want to delete this subscription?', 'invoicing'); |
|
344 | + $localize['action_edit'] = __('Edit', 'invoicing'); |
|
345 | + $localize['action_cancel'] = __('Cancel', 'invoicing'); |
|
346 | + |
|
347 | + $localize = apply_filters('wpinv_admin_js_localize', $localize); |
|
348 | + |
|
349 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
|
350 | + |
|
351 | + if ($page == 'wpinv-subscriptions') { |
|
352 | + wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION); |
|
353 | + wp_enqueue_script('wpinv-sub-admin-script'); |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 | |
357 | - public function admin_body_class( $classes ) { |
|
357 | + public function admin_body_class($classes) { |
|
358 | 358 | global $pagenow, $post, $current_screen; |
359 | 359 | |
360 | - if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
360 | + if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) { |
|
361 | 361 | $classes .= ' wpinv-cpt'; |
362 | 362 | } |
363 | 363 | |
364 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
364 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
365 | 365 | |
366 | - $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false; |
|
367 | - if ( $add_class ) { |
|
368 | - $classes .= ' wpi-' . wpinv_sanitize_key( $page ); |
|
366 | + $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false; |
|
367 | + if ($add_class) { |
|
368 | + $classes .= ' wpi-' . wpinv_sanitize_key($page); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | $settings_class = array(); |
372 | - if ( $page == 'wpinv-settings' ) { |
|
373 | - if ( !empty( $_REQUEST['tab'] ) ) { |
|
374 | - $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
372 | + if ($page == 'wpinv-settings') { |
|
373 | + if (!empty($_REQUEST['tab'])) { |
|
374 | + $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
|
375 | 375 | } |
376 | 376 | |
377 | - if ( !empty( $_REQUEST['section'] ) ) { |
|
378 | - $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
377 | + if (!empty($_REQUEST['section'])) { |
|
378 | + $settings_class[] = sanitize_text_field($_REQUEST['section']); |
|
379 | 379 | } |
380 | 380 | |
381 | - $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
381 | + $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
|
382 | 382 | } |
383 | 383 | |
384 | - if ( !empty( $settings_class ) ) { |
|
385 | - $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
384 | + if (!empty($settings_class)) { |
|
385 | + $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | $post_type = wpinv_admin_post_type(); |
389 | 389 | |
390 | - if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
390 | + if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
|
391 | 391 | return $classes .= ' wpinv'; |
392 | 392 | } |
393 | 393 | |
394 | - if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
394 | + if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
|
395 | 395 | $classes .= ' wpi-editable-n'; |
396 | 396 | } |
397 | 397 | |
@@ -403,21 +403,21 @@ discard block |
||
403 | 403 | } |
404 | 404 | |
405 | 405 | public function wpinv_actions() { |
406 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
407 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
406 | + if (isset($_REQUEST['wpi_action'])) { |
|
407 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | |
411 | - public function pre_get_posts( $wp_query ) { |
|
412 | - 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() ) { |
|
413 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
411 | + public function pre_get_posts($wp_query) { |
|
412 | + 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()) { |
|
413 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | return $wp_query; |
417 | 417 | } |
418 | 418 | |
419 | 419 | public function bp_invoicing_init() { |
420 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
420 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
@@ -425,11 +425,11 @@ discard block |
||
425 | 425 | * |
426 | 426 | */ |
427 | 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" ); |
|
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 | 434 | } |
435 | 435 | } |
436 | 436 | \ No newline at end of file |