@@ -12,49 +12,49 @@ discard block |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Reports { |
14 | 14 | |
15 | - /** |
|
16 | - * Class constructor. |
|
17 | - * |
|
18 | - */ |
|
19 | - public function __construct() { |
|
20 | - add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 ); |
|
21 | - add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) ); |
|
22 | - add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) ); |
|
23 | - add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) ); |
|
24 | - add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) ); |
|
25 | - |
|
26 | - } |
|
27 | - |
|
28 | - /** |
|
29 | - * Registers the reports page. |
|
30 | - * |
|
31 | - */ |
|
32 | - public function register_reports_page() { |
|
33 | - |
|
34 | - add_submenu_page( |
|
15 | + /** |
|
16 | + * Class constructor. |
|
17 | + * |
|
18 | + */ |
|
19 | + public function __construct() { |
|
20 | + add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 ); |
|
21 | + add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) ); |
|
22 | + add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) ); |
|
23 | + add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) ); |
|
24 | + add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) ); |
|
25 | + |
|
26 | + } |
|
27 | + |
|
28 | + /** |
|
29 | + * Registers the reports page. |
|
30 | + * |
|
31 | + */ |
|
32 | + public function register_reports_page() { |
|
33 | + |
|
34 | + add_submenu_page( |
|
35 | 35 | 'wpinv', |
36 | 36 | __( 'Reports', 'invoicing' ), |
37 | 37 | __( 'Reports', 'invoicing' ), |
38 | 38 | wpinv_get_capability(), |
39 | 39 | 'wpinv-reports', |
40 | 40 | array( $this, 'display_reports_page' ) |
41 | - ); |
|
41 | + ); |
|
42 | 42 | |
43 | - } |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Displays the reports page. |
|
47 | - * |
|
48 | - */ |
|
49 | - public function display_reports_page() { |
|
45 | + /** |
|
46 | + * Displays the reports page. |
|
47 | + * |
|
48 | + */ |
|
49 | + public function display_reports_page() { |
|
50 | 50 | |
51 | - // Prepare variables. |
|
52 | - $tabs = $this->get_tabs(); |
|
53 | - $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports'; |
|
54 | - $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports'; |
|
51 | + // Prepare variables. |
|
52 | + $tabs = $this->get_tabs(); |
|
53 | + $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports'; |
|
54 | + $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports'; |
|
55 | 55 | |
56 | - // Display the current tab. |
|
57 | - ?> |
|
56 | + // Display the current tab. |
|
57 | + ?> |
|
58 | 58 | |
59 | 59 | <div class="wrap"> |
60 | 60 | |
@@ -63,19 +63,19 @@ discard block |
||
63 | 63 | <nav class="nav-tab-wrapper"> |
64 | 64 | |
65 | 65 | <?php |
66 | - foreach( $tabs as $key => $label ) { |
|
66 | + foreach( $tabs as $key => $label ) { |
|
67 | 67 | |
68 | - $key = sanitize_text_field( $key ); |
|
69 | - $label = sanitize_text_field( $label ); |
|
70 | - $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab'; |
|
71 | - $url = esc_url( |
|
72 | - add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) ) |
|
73 | - ); |
|
68 | + $key = sanitize_text_field( $key ); |
|
69 | + $label = sanitize_text_field( $label ); |
|
70 | + $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab'; |
|
71 | + $url = esc_url( |
|
72 | + add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) ) |
|
73 | + ); |
|
74 | 74 | |
75 | - echo "\n\t\t\t<a href='$url' class='$class'>$label</a>"; |
|
75 | + echo "\n\t\t\t<a href='$url' class='$class'>$label</a>"; |
|
76 | 76 | |
77 | - } |
|
78 | - ?> |
|
77 | + } |
|
78 | + ?> |
|
79 | 79 | |
80 | 80 | </nav> |
81 | 81 | |
@@ -86,74 +86,74 @@ discard block |
||
86 | 86 | </div> |
87 | 87 | <?php |
88 | 88 | |
89 | - wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array( 'jquery' ), '2.9.4', true ); |
|
90 | - wp_enqueue_style( 'chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4' ); |
|
89 | + wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array( 'jquery' ), '2.9.4', true ); |
|
90 | + wp_enqueue_style( 'chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4' ); |
|
91 | 91 | |
92 | - } |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * Retrieves reports page tabs. |
|
96 | - * |
|
97 | - * @return array |
|
98 | - */ |
|
99 | - public function get_tabs() { |
|
94 | + /** |
|
95 | + * Retrieves reports page tabs. |
|
96 | + * |
|
97 | + * @return array |
|
98 | + */ |
|
99 | + public function get_tabs() { |
|
100 | 100 | |
101 | - $tabs = array( |
|
102 | - 'reports' => __( 'Reports', 'invoicing' ), |
|
103 | - 'export' => __( 'Export', 'invoicing' ), |
|
104 | - ); |
|
101 | + $tabs = array( |
|
102 | + 'reports' => __( 'Reports', 'invoicing' ), |
|
103 | + 'export' => __( 'Export', 'invoicing' ), |
|
104 | + ); |
|
105 | 105 | |
106 | - return apply_filters( 'getpaid_report_tabs', $tabs ); |
|
107 | - } |
|
106 | + return apply_filters( 'getpaid_report_tabs', $tabs ); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Displays the reports tab. |
|
111 | - * |
|
112 | - */ |
|
113 | - public function display_reports_tab() { |
|
109 | + /** |
|
110 | + * Displays the reports tab. |
|
111 | + * |
|
112 | + */ |
|
113 | + public function display_reports_tab() { |
|
114 | 114 | |
115 | - $reports = new GetPaid_Reports_Report(); |
|
116 | - $reports->display(); |
|
115 | + $reports = new GetPaid_Reports_Report(); |
|
116 | + $reports->display(); |
|
117 | 117 | |
118 | - } |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Displays the exports tab. |
|
122 | - * |
|
123 | - */ |
|
124 | - public function display_exports_tab() { |
|
120 | + /** |
|
121 | + * Displays the exports tab. |
|
122 | + * |
|
123 | + */ |
|
124 | + public function display_exports_tab() { |
|
125 | 125 | |
126 | - $exports = new GetPaid_Reports_Export(); |
|
127 | - $exports->display(); |
|
126 | + $exports = new GetPaid_Reports_Export(); |
|
127 | + $exports->display(); |
|
128 | 128 | |
129 | - } |
|
129 | + } |
|
130 | 130 | |
131 | - /** |
|
132 | - * Donwnloads a graph. |
|
133 | - * |
|
134 | - * @param array $args |
|
135 | - */ |
|
136 | - public function download_graph( $args ) { |
|
131 | + /** |
|
132 | + * Donwnloads a graph. |
|
133 | + * |
|
134 | + * @param array $args |
|
135 | + */ |
|
136 | + public function download_graph( $args ) { |
|
137 | 137 | |
138 | - if ( ! empty( $args['graph'] ) ) { |
|
139 | - $downloader = new GetPaid_Graph_Downloader(); |
|
140 | - $downloader->download( $args['graph'] ); |
|
141 | - } |
|
138 | + if ( ! empty( $args['graph'] ) ) { |
|
139 | + $downloader = new GetPaid_Graph_Downloader(); |
|
140 | + $downloader->download( $args['graph'] ); |
|
141 | + } |
|
142 | 142 | |
143 | - } |
|
143 | + } |
|
144 | 144 | |
145 | - /** |
|
146 | - * Exports invoices. |
|
147 | - * |
|
148 | - * @param array $args |
|
149 | - */ |
|
150 | - public function export_invoices( $args ) { |
|
145 | + /** |
|
146 | + * Exports invoices. |
|
147 | + * |
|
148 | + * @param array $args |
|
149 | + */ |
|
150 | + public function export_invoices( $args ) { |
|
151 | 151 | |
152 | - if ( ! empty( $args['post_type'] ) ) { |
|
153 | - $downloader = new GetPaid_Invoice_Exporter(); |
|
154 | - $downloader->export( $args['post_type'], $args ); |
|
155 | - } |
|
152 | + if ( ! empty( $args['post_type'] ) ) { |
|
153 | + $downloader = new GetPaid_Invoice_Exporter(); |
|
154 | + $downloader->export( $args['post_type'], $args ); |
|
155 | + } |
|
156 | 156 | |
157 | - } |
|
157 | + } |
|
158 | 158 | |
159 | 159 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * GetPaid_Reports Class. |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | * |
18 | 18 | */ |
19 | 19 | public function __construct() { |
20 | - add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 ); |
|
21 | - add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) ); |
|
22 | - add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) ); |
|
23 | - add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) ); |
|
24 | - add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) ); |
|
20 | + add_action('admin_menu', array($this, 'register_reports_page'), 20); |
|
21 | + add_action('wpinv_reports_tab_reports', array($this, 'display_reports_tab')); |
|
22 | + add_action('wpinv_reports_tab_export', array($this, 'display_exports_tab')); |
|
23 | + add_action('getpaid_authenticated_admin_action_download_graph', array($this, 'download_graph')); |
|
24 | + add_action('getpaid_authenticated_admin_action_export_invoices', array($this, 'export_invoices')); |
|
25 | 25 | |
26 | 26 | } |
27 | 27 | |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | |
34 | 34 | add_submenu_page( |
35 | 35 | 'wpinv', |
36 | - __( 'Reports', 'invoicing' ), |
|
37 | - __( 'Reports', 'invoicing' ), |
|
36 | + __('Reports', 'invoicing'), |
|
37 | + __('Reports', 'invoicing'), |
|
38 | 38 | wpinv_get_capability(), |
39 | 39 | 'wpinv-reports', |
40 | - array( $this, 'display_reports_page' ) |
|
40 | + array($this, 'display_reports_page') |
|
41 | 41 | ); |
42 | 42 | |
43 | 43 | } |
@@ -50,26 +50,26 @@ discard block |
||
50 | 50 | |
51 | 51 | // Prepare variables. |
52 | 52 | $tabs = $this->get_tabs(); |
53 | - $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports'; |
|
54 | - $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports'; |
|
53 | + $current_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'reports'; |
|
54 | + $current_tab = array_key_exists($current_tab, $tabs) ? $current_tab : 'reports'; |
|
55 | 55 | |
56 | 56 | // Display the current tab. |
57 | 57 | ?> |
58 | 58 | |
59 | 59 | <div class="wrap"> |
60 | 60 | |
61 | - <h1><?php echo sanitize_text_field( $tabs[ $current_tab ] ); ?></h1> |
|
61 | + <h1><?php echo sanitize_text_field($tabs[$current_tab]); ?></h1> |
|
62 | 62 | |
63 | 63 | <nav class="nav-tab-wrapper"> |
64 | 64 | |
65 | 65 | <?php |
66 | - foreach( $tabs as $key => $label ) { |
|
66 | + foreach ($tabs as $key => $label) { |
|
67 | 67 | |
68 | - $key = sanitize_text_field( $key ); |
|
69 | - $label = sanitize_text_field( $label ); |
|
68 | + $key = sanitize_text_field($key); |
|
69 | + $label = sanitize_text_field($label); |
|
70 | 70 | $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab'; |
71 | 71 | $url = esc_url( |
72 | - add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) ) |
|
72 | + add_query_arg('tab', $key, admin_url('admin.php?page=wpinv-reports')) |
|
73 | 73 | ); |
74 | 74 | |
75 | 75 | echo "\n\t\t\t<a href='$url' class='$class'>$label</a>"; |
@@ -79,15 +79,15 @@ discard block |
||
79 | 79 | |
80 | 80 | </nav> |
81 | 81 | |
82 | - <div class="bsui <?php echo esc_attr( $current_tab ); ?>"> |
|
83 | - <?php do_action( "wpinv_reports_tab_{$current_tab}" ); ?> |
|
82 | + <div class="bsui <?php echo esc_attr($current_tab); ?>"> |
|
83 | + <?php do_action("wpinv_reports_tab_{$current_tab}"); ?> |
|
84 | 84 | </div> |
85 | 85 | |
86 | 86 | </div> |
87 | 87 | <?php |
88 | 88 | |
89 | - wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array( 'jquery' ), '2.9.4', true ); |
|
90 | - wp_enqueue_style( 'chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4' ); |
|
89 | + wp_enqueue_script('chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array('jquery'), '2.9.4', true); |
|
90 | + wp_enqueue_style('chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4'); |
|
91 | 91 | |
92 | 92 | } |
93 | 93 | |
@@ -99,11 +99,11 @@ discard block |
||
99 | 99 | public function get_tabs() { |
100 | 100 | |
101 | 101 | $tabs = array( |
102 | - 'reports' => __( 'Reports', 'invoicing' ), |
|
103 | - 'export' => __( 'Export', 'invoicing' ), |
|
102 | + 'reports' => __('Reports', 'invoicing'), |
|
103 | + 'export' => __('Export', 'invoicing'), |
|
104 | 104 | ); |
105 | 105 | |
106 | - return apply_filters( 'getpaid_report_tabs', $tabs ); |
|
106 | + return apply_filters('getpaid_report_tabs', $tabs); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @param array $args |
135 | 135 | */ |
136 | - public function download_graph( $args ) { |
|
136 | + public function download_graph($args) { |
|
137 | 137 | |
138 | - if ( ! empty( $args['graph'] ) ) { |
|
138 | + if (!empty($args['graph'])) { |
|
139 | 139 | $downloader = new GetPaid_Graph_Downloader(); |
140 | - $downloader->download( $args['graph'] ); |
|
140 | + $downloader->download($args['graph']); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | } |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @param array $args |
149 | 149 | */ |
150 | - public function export_invoices( $args ) { |
|
150 | + public function export_invoices($args) { |
|
151 | 151 | |
152 | - if ( ! empty( $args['post_type'] ) ) { |
|
152 | + if (!empty($args['post_type'])) { |
|
153 | 153 | $downloader = new GetPaid_Invoice_Exporter(); |
154 | - $downloader->export( $args['post_type'], $args ); |
|
154 | + $downloader->export($args['post_type'], $args); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | } |
@@ -7,20 +7,20 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$class = empty( $class ) ? 'btn-primary' : sanitize_html_class( $class ); |
|
13 | -$label = empty( $label ) ? esc_attr__( 'Pay %price% »', 'invoicing' ) : esc_attr( $label ); |
|
14 | -$free = empty( $free ) ? esc_attr__( 'Continue »', 'invoicing' ) : esc_attr( $free ); |
|
12 | +$class = empty($class) ? 'btn-primary' : sanitize_html_class($class); |
|
13 | +$label = empty($label) ? esc_attr__('Pay %price% »', 'invoicing') : esc_attr($label); |
|
14 | +$free = empty($free) ? esc_attr__('Continue »', 'invoicing') : esc_attr($free); |
|
15 | 15 | |
16 | -do_action( 'getpaid_before_payment_form_pay_button', $form ); |
|
16 | +do_action('getpaid_before_payment_form_pay_button', $form); |
|
17 | 17 | |
18 | 18 | echo aui()->input( |
19 | 19 | array( |
20 | - 'name' => esc_attr( $id ), |
|
21 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
20 | + 'name' => esc_attr($id), |
|
21 | + 'id' => esc_attr($id) . uniqid('_'), |
|
22 | 22 | 'value' => $label, |
23 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
23 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
24 | 24 | 'type' => 'submit', |
25 | 25 | 'class' => 'getpaid-payment-form-submit btn btn-block submit-button ' . $class, |
26 | 26 | 'extra_attributes' => array( |
@@ -30,4 +30,4 @@ discard block |
||
30 | 30 | ) |
31 | 31 | ); |
32 | 32 | |
33 | -do_action( 'getpaid_after_payment_form_pay_button', $form ); |
|
34 | 33 | \ No newline at end of file |
34 | +do_action('getpaid_after_payment_form_pay_button', $form); |
|
35 | 35 | \ No newline at end of file |
@@ -256,8 +256,9 @@ |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | function wpinv_cart_needs_tax_address_fields() { |
259 | - if( !wpinv_is_cart_taxed() ) |
|
260 | - return false; |
|
259 | + if( !wpinv_is_cart_taxed() ) { |
|
260 | + return false; |
|
261 | + } |
|
261 | 262 | |
262 | 263 | return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' ); |
263 | 264 | } |
@@ -215,16 +215,16 @@ discard block |
||
215 | 215 | function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) { |
216 | 216 | |
217 | 217 | $initial_tax = $tax_amount; |
218 | - $recurring_tax = 0; |
|
218 | + $recurring_tax = 0; |
|
219 | 219 | |
220 | 220 | if ( $item->is_recurring() ) { |
221 | - $recurring_tax = $recurring_tax_amount; |
|
222 | - } |
|
221 | + $recurring_tax = $recurring_tax_amount; |
|
222 | + } |
|
223 | 223 | |
224 | - return array( |
|
225 | - 'name' => sanitize_text_field( $tax_name ), |
|
226 | - 'initial_tax' => $initial_tax, |
|
227 | - 'recurring_tax' => $recurring_tax, |
|
224 | + return array( |
|
225 | + 'name' => sanitize_text_field( $tax_name ), |
|
226 | + 'initial_tax' => $initial_tax, |
|
227 | + 'recurring_tax' => $recurring_tax, |
|
228 | 228 | ); |
229 | 229 | |
230 | 230 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | */ |
329 | 329 | function wpinv_should_validate_vat_number() { |
330 | 330 | $validate = wpinv_get_option( 'validate_vat_number' ); |
331 | - return ! empty( $validate ); |
|
331 | + return ! empty( $validate ); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | function wpinv_sales_tax_for_year( $year = null ) { |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Returns an array of eu states. |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @return array |
13 | 13 | */ |
14 | 14 | function getpaid_get_eu_states() { |
15 | - return wpinv_get_data( 'eu-states' ); |
|
15 | + return wpinv_get_data('eu-states'); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @return bool |
22 | 22 | */ |
23 | -function getpaid_is_eu_state( $country ) { |
|
24 | - return ! empty( $country ) && in_array( strtoupper( $country ), getpaid_get_eu_states() ) ? true : false; |
|
23 | +function getpaid_is_eu_state($country) { |
|
24 | + return !empty($country) && in_array(strtoupper($country), getpaid_get_eu_states()) ? true : false; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @return array |
31 | 31 | */ |
32 | 32 | function getpaid_get_gst_states() { |
33 | - return array( 'AU', 'NZ', 'CA', 'CN' ); |
|
33 | + return array('AU', 'NZ', 'CA', 'CN'); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return bool |
40 | 40 | */ |
41 | -function getpaid_is_gst_country( $country ) { |
|
42 | - return ! empty( $country ) && in_array( strtoupper( $country ), getpaid_get_gst_states() ) ? true : false; |
|
41 | +function getpaid_is_gst_country($country) { |
|
42 | + return !empty($country) && in_array(strtoupper($country), getpaid_get_gst_states()) ? true : false; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | */ |
50 | 50 | function wpinv_use_taxes() { |
51 | 51 | |
52 | - $ret = wpinv_get_option( 'enable_taxes', false ); |
|
53 | - return (bool) apply_filters( 'wpinv_use_taxes', ! empty( $ret ) ); |
|
52 | + $ret = wpinv_get_option('enable_taxes', false); |
|
53 | + return (bool) apply_filters('wpinv_use_taxes', !empty($ret)); |
|
54 | 54 | |
55 | 55 | } |
56 | 56 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param WPInv_Invoice $invoice |
61 | 61 | * @return bool |
62 | 62 | */ |
63 | -function wpinv_is_invoice_taxable( $invoice ) { |
|
63 | +function wpinv_is_invoice_taxable($invoice) { |
|
64 | 64 | return $invoice->is_taxable(); |
65 | 65 | } |
66 | 66 | |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | * @param string $country |
71 | 71 | * @return bool |
72 | 72 | */ |
73 | -function wpinv_is_country_taxable( $country ) { |
|
74 | - $is_eu = getpaid_is_eu_state( $country ); |
|
75 | - $is_exempt = $is_eu && $country == wpinv_is_base_country( $country ) && wpinv_same_country_exempt_vat(); |
|
73 | +function wpinv_is_country_taxable($country) { |
|
74 | + $is_eu = getpaid_is_eu_state($country); |
|
75 | + $is_exempt = $is_eu && $country == wpinv_is_base_country($country) && wpinv_same_country_exempt_vat(); |
|
76 | 76 | |
77 | - return (bool) apply_filters( 'wpinv_is_country_taxable', ! $is_exempt, $country ); |
|
77 | + return (bool) apply_filters('wpinv_is_country_taxable', !$is_exempt, $country); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param WPInv_Item|GetPaid_Form_Item $item |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | -function wpinv_is_item_taxable( $item ) { |
|
87 | +function wpinv_is_item_taxable($item) { |
|
88 | 88 | return '_exempt' != $item->get_vat_rule(); |
89 | 89 | } |
90 | 90 | |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | * @return bool |
95 | 95 | */ |
96 | 96 | function wpinv_use_store_address_as_tax_base() { |
97 | - $use_base = wpinv_get_option( 'tax_base', 'billing' ) == 'base'; |
|
98 | - return (bool) apply_filters( 'wpinv_use_store_address_as_tax_base', $use_base ); |
|
97 | + $use_base = wpinv_get_option('tax_base', 'billing') == 'base'; |
|
98 | + return (bool) apply_filters('wpinv_use_store_address_as_tax_base', $use_base); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @return bool |
105 | 105 | */ |
106 | 106 | function wpinv_prices_include_tax() { |
107 | - $is_inclusive = wpinv_get_option( 'prices_include_tax', 'no' ) == 'yes'; |
|
108 | - return (bool) apply_filters( 'wpinv_prices_include_tax', $is_inclusive ); |
|
107 | + $is_inclusive = wpinv_get_option('prices_include_tax', 'no') == 'yes'; |
|
108 | + return (bool) apply_filters('wpinv_prices_include_tax', $is_inclusive); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * @return bool |
115 | 115 | */ |
116 | 116 | function wpinv_round_tax_per_tax_rate() { |
117 | - $subtotal_rounding = wpinv_get_option( 'tax_subtotal_rounding', 1 ); |
|
118 | - return (bool) apply_filters( 'wpinv_round_tax_per_tax_rate', empty( $subtotal_rounding ) ); |
|
117 | + $subtotal_rounding = wpinv_get_option('tax_subtotal_rounding', 1); |
|
118 | + return (bool) apply_filters('wpinv_round_tax_per_tax_rate', empty($subtotal_rounding)); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | * @return bool |
125 | 125 | */ |
126 | 126 | function wpinv_display_individual_tax_rates() { |
127 | - $individual = wpinv_get_option( 'tax_display_totals', 'single' ) == 'individual'; |
|
128 | - return (bool) apply_filters( 'wpinv_display_individual_tax_rates', $individual ); |
|
127 | + $individual = wpinv_get_option('tax_display_totals', 'single') == 'individual'; |
|
128 | + return (bool) apply_filters('wpinv_display_individual_tax_rates', $individual); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | * @return float |
135 | 135 | */ |
136 | 136 | function wpinv_get_default_tax_rate() { |
137 | - $rate = wpinv_get_option( 'tax_rate', false ); |
|
138 | - return (float) apply_filters( 'wpinv_get_default_tax_rate', floatval( $rate ) ); |
|
137 | + $rate = wpinv_get_option('tax_rate', false); |
|
138 | + return (float) apply_filters('wpinv_get_default_tax_rate', floatval($rate)); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @return bool |
145 | 145 | */ |
146 | 146 | function wpinv_same_country_exempt_vat() { |
147 | - return 'no' == wpinv_get_option( 'vat_same_country_rule' ); |
|
147 | + return 'no' == wpinv_get_option('vat_same_country_rule'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -164,28 +164,28 @@ discard block |
||
164 | 164 | * @param string $state |
165 | 165 | * @return array |
166 | 166 | */ |
167 | -function getpaid_get_item_tax_rates( $item, $country = '', $state = '' ) { |
|
167 | +function getpaid_get_item_tax_rates($item, $country = '', $state = '') { |
|
168 | 168 | |
169 | 169 | // Abort if the item is not taxable. |
170 | - if ( ! wpinv_is_item_taxable( $item ) ) { |
|
170 | + if (!wpinv_is_item_taxable($item)) { |
|
171 | 171 | return array(); |
172 | 172 | } |
173 | 173 | |
174 | 174 | // Maybe use the store address. |
175 | - if ( wpinv_use_store_address_as_tax_base() ) { |
|
175 | + if (wpinv_use_store_address_as_tax_base()) { |
|
176 | 176 | $country = wpinv_get_default_country(); |
177 | 177 | $state = wpinv_get_default_state(); |
178 | 178 | } |
179 | 179 | |
180 | 180 | // Retrieve tax rates. |
181 | - $tax_rates = GetPaid_Tax::get_address_tax_rates( $country, $state ); |
|
181 | + $tax_rates = GetPaid_Tax::get_address_tax_rates($country, $state); |
|
182 | 182 | |
183 | 183 | // Fallback to the default tax rates if non were found. |
184 | - if ( empty( $tax_rates ) ) { |
|
184 | + if (empty($tax_rates)) { |
|
185 | 185 | $tax_rates = GetPaid_Tax::get_default_tax_rates(); |
186 | 186 | } |
187 | 187 | |
188 | - return apply_filters( 'getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state ); |
|
188 | + return apply_filters('getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -195,23 +195,23 @@ discard block |
||
195 | 195 | * @param array $rates |
196 | 196 | * @return array |
197 | 197 | */ |
198 | -function getpaid_filter_item_tax_rates( $item, $rates ) { |
|
198 | +function getpaid_filter_item_tax_rates($item, $rates) { |
|
199 | 199 | |
200 | 200 | $tax_class = $item->get_vat_class(); |
201 | 201 | |
202 | - foreach ( $rates as $i => $rate ) { |
|
202 | + foreach ($rates as $i => $rate) { |
|
203 | 203 | |
204 | - if ( $tax_class == '_reduced' ) { |
|
205 | - $rates[ $i ]['rate'] = empty( $rate['reduced_rate'] ) ? 0 : $rate['reduced_rate']; |
|
204 | + if ($tax_class == '_reduced') { |
|
205 | + $rates[$i]['rate'] = empty($rate['reduced_rate']) ? 0 : $rate['reduced_rate']; |
|
206 | 206 | } |
207 | 207 | |
208 | - if ( $tax_class == '_exempt' ) { |
|
209 | - $rates[ $i ]['rate'] = 0; |
|
208 | + if ($tax_class == '_exempt') { |
|
209 | + $rates[$i]['rate'] = 0; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | } |
213 | 213 | |
214 | - return apply_filters( 'getpaid_filter_item_tax_rates', $rates, $item ); |
|
214 | + return apply_filters('getpaid_filter_item_tax_rates', $rates, $item); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -221,12 +221,12 @@ discard block |
||
221 | 221 | * @param array $rates |
222 | 222 | * @return array |
223 | 223 | */ |
224 | -function getpaid_calculate_item_taxes( $amount, $rates ) { |
|
224 | +function getpaid_calculate_item_taxes($amount, $rates) { |
|
225 | 225 | |
226 | 226 | $is_inclusive = wpinv_prices_include_tax(); |
227 | - $taxes = GetPaid_Tax::calc_tax( $amount, $rates, $is_inclusive ); |
|
227 | + $taxes = GetPaid_Tax::calc_tax($amount, $rates, $is_inclusive); |
|
228 | 228 | |
229 | - return apply_filters( 'getpaid_calculate_taxes', $taxes, $amount, $rates ); |
|
229 | + return apply_filters('getpaid_calculate_taxes', $taxes, $amount, $rates); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -238,17 +238,17 @@ discard block |
||
238 | 238 | * @param float $recurring_tax_amount |
239 | 239 | * @return array |
240 | 240 | */ |
241 | -function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) { |
|
241 | +function getpaid_prepare_item_tax($item, $tax_name, $tax_amount, $recurring_tax_amount) { |
|
242 | 242 | |
243 | - $initial_tax = $tax_amount; |
|
243 | + $initial_tax = $tax_amount; |
|
244 | 244 | $recurring_tax = 0; |
245 | 245 | |
246 | - if ( $item->is_recurring() ) { |
|
246 | + if ($item->is_recurring()) { |
|
247 | 247 | $recurring_tax = $recurring_tax_amount; |
248 | 248 | } |
249 | 249 | |
250 | 250 | return array( |
251 | - 'name' => sanitize_text_field( $tax_name ), |
|
251 | + 'name' => sanitize_text_field($tax_name), |
|
252 | 252 | 'initial_tax' => $initial_tax, |
253 | 253 | 'recurring_tax' => $recurring_tax, |
254 | 254 | ); |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | * @param string $vat_number |
262 | 262 | * @return string |
263 | 263 | */ |
264 | -function wpinv_sanitize_vat_number( $vat_number ) { |
|
265 | - return str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) ); |
|
264 | +function wpinv_sanitize_vat_number($vat_number) { |
|
265 | + return str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number))); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -271,22 +271,22 @@ discard block |
||
271 | 271 | * @param string $vat_number |
272 | 272 | * @return bool |
273 | 273 | */ |
274 | -function wpinv_regex_validate_vat_number( $vat_number ) { |
|
274 | +function wpinv_regex_validate_vat_number($vat_number) { |
|
275 | 275 | |
276 | - $country = substr( $vat_number, 0, 2 ); |
|
277 | - $vatin = substr( $vat_number, 2 ); |
|
278 | - $regexes = wpinv_get_data( 'vat-number-regexes' ); |
|
276 | + $country = substr($vat_number, 0, 2); |
|
277 | + $vatin = substr($vat_number, 2); |
|
278 | + $regexes = wpinv_get_data('vat-number-regexes'); |
|
279 | 279 | |
280 | - if ( isset( $regexes[ $country ] ) ) { |
|
280 | + if (isset($regexes[$country])) { |
|
281 | 281 | |
282 | - $regex = $regexes[ $country ]; |
|
282 | + $regex = $regexes[$country]; |
|
283 | 283 | $regex = '/^(?:' . $regex . ')$/'; |
284 | - return 1 === preg_match( $regex, $vatin ); |
|
284 | + return 1 === preg_match($regex, $vatin); |
|
285 | 285 | |
286 | 286 | } |
287 | 287 | |
288 | 288 | // Not an EU state, use filters to validate the number. |
289 | - return apply_filters( 'wpinv_regex_validate_vat_number', true, $vat_number ); |
|
289 | + return apply_filters('wpinv_regex_validate_vat_number', true, $vat_number); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -295,29 +295,29 @@ discard block |
||
295 | 295 | * @param string $vat_number |
296 | 296 | * @return bool |
297 | 297 | */ |
298 | -function wpinv_vies_validate_vat_number( $vat_number ) { |
|
298 | +function wpinv_vies_validate_vat_number($vat_number) { |
|
299 | 299 | |
300 | - $country = substr( $vat_number, 0, 2 ); |
|
301 | - $vatin = substr( $vat_number, 2 ); |
|
300 | + $country = substr($vat_number, 0, 2); |
|
301 | + $vatin = substr($vat_number, 2); |
|
302 | 302 | |
303 | 303 | $url = add_query_arg( |
304 | 304 | array( |
305 | - 'ms' => urlencode( $country ), |
|
306 | - 'iso' => urlencode( $country ), |
|
307 | - 'vat' => urlencode( $vatin ), |
|
305 | + 'ms' => urlencode($country), |
|
306 | + 'iso' => urlencode($country), |
|
307 | + 'vat' => urlencode($vatin), |
|
308 | 308 | ), |
309 | 309 | 'http://ec.europa.eu/taxation_customs/vies/viesquer.do' |
310 | 310 | ); |
311 | 311 | |
312 | - $response = wp_remote_get( $url ); |
|
313 | - $response = wp_remote_retrieve_body( $response ); |
|
312 | + $response = wp_remote_get($url); |
|
313 | + $response = wp_remote_retrieve_body($response); |
|
314 | 314 | |
315 | 315 | // Fallback gracefully if the VIES website is down. |
316 | - if ( empty( $response ) ) { |
|
316 | + if (empty($response)) { |
|
317 | 317 | return true; |
318 | 318 | } |
319 | 319 | |
320 | - return 1 !== preg_match( '/invalid VAT number/i', $response ); |
|
320 | + return 1 !== preg_match('/invalid VAT number/i', $response); |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -328,23 +328,23 @@ discard block |
||
328 | 328 | * @param string $country |
329 | 329 | * @return bool |
330 | 330 | */ |
331 | -function wpinv_validate_vat_number( $vat_number, $country ) { |
|
331 | +function wpinv_validate_vat_number($vat_number, $country) { |
|
332 | 332 | |
333 | 333 | // Abort if we are not validating this. |
334 | - if ( ! wpinv_should_validate_vat_number() || empty( $vat_number ) ) { |
|
334 | + if (!wpinv_should_validate_vat_number() || empty($vat_number)) { |
|
335 | 335 | return true; |
336 | 336 | } |
337 | 337 | |
338 | 338 | // In case the vat number does not have a country code... |
339 | - $vat_number = wpinv_sanitize_vat_number( $vat_number ); |
|
340 | - $_country = substr( $vat_number, 0, 2 ); |
|
341 | - $_country = $_country == wpinv_country_name( $_country ); |
|
339 | + $vat_number = wpinv_sanitize_vat_number($vat_number); |
|
340 | + $_country = substr($vat_number, 0, 2); |
|
341 | + $_country = $_country == wpinv_country_name($_country); |
|
342 | 342 | |
343 | - if ( $_country ) { |
|
344 | - $vat_number = strtoupper( $country ) . $vat_number; |
|
343 | + if ($_country) { |
|
344 | + $vat_number = strtoupper($country) . $vat_number; |
|
345 | 345 | } |
346 | 346 | |
347 | - return wpinv_regex_validate_vat_number( $vat_number ) && wpinv_vies_validate_vat_number( $vat_number ); |
|
347 | + return wpinv_regex_validate_vat_number($vat_number) && wpinv_vies_validate_vat_number($vat_number); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -353,40 +353,40 @@ discard block |
||
353 | 353 | * @return bool |
354 | 354 | */ |
355 | 355 | function wpinv_should_validate_vat_number() { |
356 | - $validate = wpinv_get_option( 'validate_vat_number' ); |
|
357 | - return ! empty( $validate ); |
|
356 | + $validate = wpinv_get_option('validate_vat_number'); |
|
357 | + return !empty($validate); |
|
358 | 358 | } |
359 | 359 | |
360 | -function wpinv_sales_tax_for_year( $year = null ) { |
|
361 | - return wpinv_price( wpinv_get_sales_tax_for_year( $year ) ); |
|
360 | +function wpinv_sales_tax_for_year($year = null) { |
|
361 | + return wpinv_price(wpinv_get_sales_tax_for_year($year)); |
|
362 | 362 | } |
363 | 363 | |
364 | -function wpinv_get_sales_tax_for_year( $year = null ) { |
|
364 | +function wpinv_get_sales_tax_for_year($year = null) { |
|
365 | 365 | global $wpdb; |
366 | 366 | |
367 | 367 | // Start at zero |
368 | 368 | $tax = 0; |
369 | 369 | |
370 | - if ( ! empty( $year ) ) { |
|
370 | + if (!empty($year)) { |
|
371 | 371 | $args = array( |
372 | 372 | 'post_type' => 'wpi_invoice', |
373 | - 'post_status' => array( 'publish' ), |
|
373 | + 'post_status' => array('publish'), |
|
374 | 374 | 'posts_per_page' => -1, |
375 | 375 | 'year' => $year, |
376 | 376 | 'fields' => 'ids' |
377 | 377 | ); |
378 | 378 | |
379 | - $payments = get_posts( $args ); |
|
380 | - $payment_ids = implode( ',', $payments ); |
|
379 | + $payments = get_posts($args); |
|
380 | + $payment_ids = implode(',', $payments); |
|
381 | 381 | |
382 | - if ( count( $payments ) > 0 ) { |
|
382 | + if (count($payments) > 0) { |
|
383 | 383 | $sql = "SELECT SUM( meta_value ) FROM $wpdb->postmeta WHERE meta_key = '_wpinv_tax' AND post_id IN( $payment_ids )"; |
384 | - $tax = $wpdb->get_var( $sql ); |
|
384 | + $tax = $wpdb->get_var($sql); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | } |
388 | 388 | |
389 | - return apply_filters( 'wpinv_get_sales_tax_for_year', $tax, $year ); |
|
389 | + return apply_filters('wpinv_get_sales_tax_for_year', $tax, $year); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | function wpinv_is_cart_taxed() { |
@@ -395,33 +395,33 @@ discard block |
||
395 | 395 | |
396 | 396 | function wpinv_prices_show_tax_on_checkout() { |
397 | 397 | return false; // TODO |
398 | - $ret = ( wpinv_get_option( 'checkout_include_tax', false ) == 'yes' && wpinv_use_taxes() ); |
|
398 | + $ret = (wpinv_get_option('checkout_include_tax', false) == 'yes' && wpinv_use_taxes()); |
|
399 | 399 | |
400 | - return apply_filters( 'wpinv_taxes_on_prices_on_checkout', $ret ); |
|
400 | + return apply_filters('wpinv_taxes_on_prices_on_checkout', $ret); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | function wpinv_display_tax_rate() { |
404 | - $ret = wpinv_use_taxes() && wpinv_get_option( 'display_tax_rate', false ); |
|
404 | + $ret = wpinv_use_taxes() && wpinv_get_option('display_tax_rate', false); |
|
405 | 405 | |
406 | - return apply_filters( 'wpinv_display_tax_rate', $ret ); |
|
406 | + return apply_filters('wpinv_display_tax_rate', $ret); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | function wpinv_cart_needs_tax_address_fields() { |
410 | - if( !wpinv_is_cart_taxed() ) |
|
410 | + if (!wpinv_is_cart_taxed()) |
|
411 | 411 | return false; |
412 | 412 | |
413 | - return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' ); |
|
413 | + return !did_action('wpinv_after_cc_fields', 'wpinv_default_cc_address_fields'); |
|
414 | 414 | } |
415 | 415 | |
416 | -function wpinv_item_is_tax_exclusive( $item_id = 0 ) { |
|
417 | - $ret = (bool)get_post_meta( $item_id, '_wpinv_tax_exclusive', false ); |
|
418 | - return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id ); |
|
416 | +function wpinv_item_is_tax_exclusive($item_id = 0) { |
|
417 | + $ret = (bool) get_post_meta($item_id, '_wpinv_tax_exclusive', false); |
|
418 | + return apply_filters('wpinv_is_tax_exclusive', $ret, $item_id); |
|
419 | 419 | } |
420 | 420 | |
421 | -function wpinv_currency_decimal_filter( $decimals = 2 ) { |
|
421 | +function wpinv_currency_decimal_filter($decimals = 2) { |
|
422 | 422 | $currency = wpinv_get_currency(); |
423 | 423 | |
424 | - switch ( $currency ) { |
|
424 | + switch ($currency) { |
|
425 | 425 | case 'RIAL' : |
426 | 426 | case 'JPY' : |
427 | 427 | case 'TWD' : |
@@ -430,13 +430,13 @@ discard block |
||
430 | 430 | break; |
431 | 431 | } |
432 | 432 | |
433 | - return apply_filters( 'wpinv_currency_decimal_count', $decimals, $currency ); |
|
433 | + return apply_filters('wpinv_currency_decimal_count', $decimals, $currency); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | function wpinv_tax_amount() { |
437 | 437 | $output = 0.00; |
438 | 438 | |
439 | - return apply_filters( 'wpinv_tax_amount', $output ); |
|
439 | + return apply_filters('wpinv_tax_amount', $output); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | /** |
@@ -444,25 +444,25 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @param string|bool|null $vat_rule |
446 | 446 | */ |
447 | -function getpaid_filter_vat_rule( $vat_rule ) { |
|
447 | +function getpaid_filter_vat_rule($vat_rule) { |
|
448 | 448 | |
449 | - if ( empty( $vat_rule ) ) { |
|
449 | + if (empty($vat_rule)) { |
|
450 | 450 | return 'digital'; |
451 | 451 | } |
452 | 452 | |
453 | 453 | return $vat_rule; |
454 | 454 | } |
455 | -add_filter( 'wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule' ); |
|
455 | +add_filter('wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule'); |
|
456 | 456 | |
457 | 457 | /** |
458 | 458 | * Filters the VAT class to ensure that each item has a VAT class. |
459 | 459 | * |
460 | 460 | * @param string|bool|null $vat_rule |
461 | 461 | */ |
462 | -function getpaid_filter_vat_class( $vat_class ) { |
|
463 | - return empty( $vat_class ) ? '_standard' : $vat_class; |
|
462 | +function getpaid_filter_vat_class($vat_class) { |
|
463 | + return empty($vat_class) ? '_standard' : $vat_class; |
|
464 | 464 | } |
465 | -add_filter( 'wpinv_get_item_vat_class', 'getpaid_filter_vat_class' ); |
|
465 | +add_filter('wpinv_get_item_vat_class', 'getpaid_filter_vat_class'); |
|
466 | 466 | |
467 | 467 | /** |
468 | 468 | * Returns a list of all tax classes. |
@@ -474,9 +474,9 @@ discard block |
||
474 | 474 | return apply_filters( |
475 | 475 | 'getpaid_tax_classes', |
476 | 476 | array( |
477 | - '_standard' => __( 'Standard Tax Rate', 'invoicing' ), |
|
478 | - '_reduced' => __( 'Reduced Tax Rate', 'invoicing' ), |
|
479 | - '_exempt' => __( 'Tax Exempt', 'invoicing' ), |
|
477 | + '_standard' => __('Standard Tax Rate', 'invoicing'), |
|
478 | + '_reduced' => __('Reduced Tax Rate', 'invoicing'), |
|
479 | + '_exempt' => __('Tax Exempt', 'invoicing'), |
|
480 | 480 | ) |
481 | 481 | ); |
482 | 482 | |
@@ -492,8 +492,8 @@ discard block |
||
492 | 492 | return apply_filters( |
493 | 493 | 'getpaid_tax_rules', |
494 | 494 | array( |
495 | - 'physical' => __( 'Physical Item', 'invoicing' ), |
|
496 | - 'digital' => __( 'Digital Item', 'invoicing' ), |
|
495 | + 'physical' => __('Physical Item', 'invoicing'), |
|
496 | + 'digital' => __('Digital Item', 'invoicing'), |
|
497 | 497 | ) |
498 | 498 | ); |
499 | 499 | |
@@ -505,15 +505,15 @@ discard block |
||
505 | 505 | * @param string $tax_class |
506 | 506 | * @return string |
507 | 507 | */ |
508 | -function getpaid_get_tax_class_label( $tax_class ) { |
|
508 | +function getpaid_get_tax_class_label($tax_class) { |
|
509 | 509 | |
510 | 510 | $classes = getpaid_get_tax_classes(); |
511 | 511 | |
512 | - if ( isset( $classes[ $tax_class ] ) ) { |
|
513 | - return sanitize_text_field( $classes[ $tax_class ] ); |
|
512 | + if (isset($classes[$tax_class])) { |
|
513 | + return sanitize_text_field($classes[$tax_class]); |
|
514 | 514 | } |
515 | 515 | |
516 | - return sanitize_text_field( $tax_class ); |
|
516 | + return sanitize_text_field($tax_class); |
|
517 | 517 | |
518 | 518 | } |
519 | 519 | |
@@ -523,14 +523,14 @@ discard block |
||
523 | 523 | * @param string $tax_rule |
524 | 524 | * @return string |
525 | 525 | */ |
526 | -function getpaid_get_tax_rule_label( $tax_rule ) { |
|
526 | +function getpaid_get_tax_rule_label($tax_rule) { |
|
527 | 527 | |
528 | 528 | $rules = getpaid_get_tax_rules(); |
529 | 529 | |
530 | - if ( isset( $rules[ $tax_rule ] ) ) { |
|
531 | - return sanitize_text_field( $rules[ $tax_rule ] ); |
|
530 | + if (isset($rules[$tax_rule])) { |
|
531 | + return sanitize_text_field($rules[$tax_rule]); |
|
532 | 532 | } |
533 | 533 | |
534 | - return sanitize_text_field( $tax_rule ); |
|
534 | + return sanitize_text_field($tax_rule); |
|
535 | 535 | |
536 | 536 | } |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | */ |
98 | 98 | function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
99 | 99 | |
100 | - $invoice_statuses = array( |
|
101 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
100 | + $invoice_statuses = array( |
|
101 | + 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
102 | 102 | 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
103 | 103 | 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
104 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
105 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
106 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
104 | + 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
105 | + 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
106 | + 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
107 | 107 | 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
108 | 108 | 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
109 | 109 | ); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $invoice = $invoice->get_post_type(); |
121 | 121 | } |
122 | 122 | |
123 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
123 | + return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -238,25 +238,25 @@ discard block |
||
238 | 238 | * @return string |
239 | 239 | */ |
240 | 240 | function getpaid_get_price_format() { |
241 | - $currency_pos = wpinv_currency_position(); |
|
242 | - $format = '%1$s%2$s'; |
|
243 | - |
|
244 | - switch ( $currency_pos ) { |
|
245 | - case 'left': |
|
246 | - $format = '%1$s%2$s'; |
|
247 | - break; |
|
248 | - case 'right': |
|
249 | - $format = '%2$s%1$s'; |
|
250 | - break; |
|
251 | - case 'left_space': |
|
252 | - $format = '%1$s %2$s'; |
|
253 | - break; |
|
254 | - case 'right_space': |
|
255 | - $format = '%2$s %1$s'; |
|
256 | - break; |
|
257 | - } |
|
258 | - |
|
259 | - return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
241 | + $currency_pos = wpinv_currency_position(); |
|
242 | + $format = '%1$s%2$s'; |
|
243 | + |
|
244 | + switch ( $currency_pos ) { |
|
245 | + case 'left': |
|
246 | + $format = '%1$s%2$s'; |
|
247 | + break; |
|
248 | + case 'right': |
|
249 | + $format = '%2$s%1$s'; |
|
250 | + break; |
|
251 | + case 'left_space': |
|
252 | + $format = '%1$s %2$s'; |
|
253 | + break; |
|
254 | + case 'right_space': |
|
255 | + $format = '%2$s %1$s'; |
|
256 | + break; |
|
257 | + } |
|
258 | + |
|
259 | + return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -359,13 +359,13 @@ discard block |
||
359 | 359 | * @param mixed $value Value. |
360 | 360 | */ |
361 | 361 | function getpaid_maybe_define_constant( $name, $value ) { |
362 | - if ( ! defined( $name ) ) { |
|
363 | - define( $name, $value ); |
|
364 | - } |
|
362 | + if ( ! defined( $name ) ) { |
|
363 | + define( $name, $value ); |
|
364 | + } |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | function wpinv_get_php_arg_separator_output() { |
368 | - return ini_get( 'arg_separator.output' ); |
|
368 | + return ini_get( 'arg_separator.output' ); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | function wpinv_rgb_from_hex( $color ) { |
@@ -716,11 +716,11 @@ discard block |
||
716 | 716 | $list = array(); |
717 | 717 | } |
718 | 718 | |
719 | - if ( ! is_array( $list ) ) { |
|
720 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
721 | - } |
|
719 | + if ( ! is_array( $list ) ) { |
|
720 | + return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
721 | + } |
|
722 | 722 | |
723 | - return $list; |
|
723 | + return $list; |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | /** |
@@ -740,9 +740,9 @@ discard block |
||
740 | 740 | } |
741 | 741 | |
742 | 742 | $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
743 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
743 | + wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
744 | 744 | |
745 | - return $data; |
|
745 | + return $data; |
|
746 | 746 | } |
747 | 747 | |
748 | 748 | /** |
@@ -771,17 +771,17 @@ discard block |
||
771 | 771 | */ |
772 | 772 | function wpinv_clean( $var ) { |
773 | 773 | |
774 | - if ( is_array( $var ) ) { |
|
775 | - return array_map( 'wpinv_clean', $var ); |
|
774 | + if ( is_array( $var ) ) { |
|
775 | + return array_map( 'wpinv_clean', $var ); |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | if ( is_object( $var ) ) { |
779 | - $object_vars = get_object_vars( $var ); |
|
780 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
781 | - $var->$property_name = wpinv_clean( $property_value ); |
|
779 | + $object_vars = get_object_vars( $var ); |
|
780 | + foreach ( $object_vars as $property_name => $property_value ) { |
|
781 | + $var->$property_name = wpinv_clean( $property_value ); |
|
782 | 782 | } |
783 | 783 | return $var; |
784 | - } |
|
784 | + } |
|
785 | 785 | |
786 | 786 | return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
787 | 787 | } |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | */ |
795 | 795 | function getpaid_convert_price_string_to_options( $str ) { |
796 | 796 | |
797 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
797 | + $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
798 | 798 | $options = array(); |
799 | 799 | |
800 | 800 | foreach ( $raw_options as $option ) { |
@@ -872,7 +872,7 @@ discard block |
||
872 | 872 | * @return string |
873 | 873 | */ |
874 | 874 | function getpaid_date_format() { |
875 | - return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
875 | + return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
876 | 876 | } |
877 | 877 | |
878 | 878 | /** |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | * @return string |
882 | 882 | */ |
883 | 883 | function getpaid_time_format() { |
884 | - return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
884 | + return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | /** |
@@ -894,15 +894,15 @@ discard block |
||
894 | 894 | function getpaid_limit_length( $string, $limit ) { |
895 | 895 | $str_limit = $limit - 3; |
896 | 896 | |
897 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
898 | - if ( mb_strlen( $string ) > $limit ) { |
|
899 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
900 | - } |
|
901 | - } else { |
|
902 | - if ( strlen( $string ) > $limit ) { |
|
903 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
904 | - } |
|
905 | - } |
|
897 | + if ( function_exists( 'mb_strimwidth' ) ) { |
|
898 | + if ( mb_strlen( $string ) > $limit ) { |
|
899 | + $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
900 | + } |
|
901 | + } else { |
|
902 | + if ( strlen( $string ) > $limit ) { |
|
903 | + $string = substr( $string, 0, $str_limit ) . '...'; |
|
904 | + } |
|
905 | + } |
|
906 | 906 | return $string; |
907 | 907 | |
908 | 908 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Are we supporting item quantities? |
@@ -20,35 +20,35 @@ discard block |
||
20 | 20 | */ |
21 | 21 | function wpinv_get_ip() { |
22 | 22 | |
23 | - if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) { |
|
24 | - return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) ); |
|
23 | + if (isset($_SERVER['HTTP_X_REAL_IP'])) { |
|
24 | + return sanitize_text_field(wp_unslash($_SERVER['HTTP_X_REAL_IP'])); |
|
25 | 25 | } |
26 | 26 | |
27 | - if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
27 | + if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
28 | 28 | // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2 |
29 | 29 | // Make sure we always only send through the first IP in the list which should always be the client IP. |
30 | - return (string) rest_is_ip_address( trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) ); |
|
30 | + return (string) rest_is_ip_address(trim(current(preg_split('/,/', sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR'])))))); |
|
31 | 31 | } |
32 | 32 | |
33 | - if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
34 | - return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) ); |
|
33 | + if (isset($_SERVER['HTTP_CLIENT_IP'])) { |
|
34 | + return sanitize_text_field(wp_unslash($_SERVER['HTTP_CLIENT_IP'])); |
|
35 | 35 | } |
36 | 36 | |
37 | - if ( isset( $_SERVER['REMOTE_ADDR'] ) ) { |
|
38 | - return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ); |
|
37 | + if (isset($_SERVER['REMOTE_ADDR'])) { |
|
38 | + return sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | return ''; |
42 | 42 | } |
43 | 43 | |
44 | 44 | function wpinv_get_user_agent() { |
45 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
46 | - $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
|
45 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
46 | + $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); |
|
47 | 47 | } else { |
48 | 48 | $user_agent = ''; |
49 | 49 | } |
50 | 50 | |
51 | - return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
|
51 | + return apply_filters('wpinv_get_user_agent', $user_agent); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -56,21 +56,21 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @param string $amount The amount to sanitize. |
58 | 58 | */ |
59 | -function wpinv_sanitize_amount( $amount ) { |
|
59 | +function wpinv_sanitize_amount($amount) { |
|
60 | 60 | |
61 | 61 | // Abort early to avoid multiplying decimals by 100; |
62 | - if ( '.' !== wpinv_decimal_separator() ) { |
|
63 | - return floatval( $amount ); |
|
62 | + if ('.' !== wpinv_decimal_separator()) { |
|
63 | + return floatval($amount); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | // Format decimals. |
67 | - $amount = str_replace( wpinv_decimal_separator(), '.', $amount ); |
|
67 | + $amount = str_replace(wpinv_decimal_separator(), '.', $amount); |
|
68 | 68 | |
69 | 69 | // Remove thousands. |
70 | - $amount = str_replace( wpinv_thousands_separator(), '', $amount ); |
|
70 | + $amount = str_replace(wpinv_thousands_separator(), '', $amount); |
|
71 | 71 | |
72 | 72 | // Cast the remaining to a float. |
73 | - return (float) preg_replace( '/[^0-9\.\-]/', '', $amount ); |
|
73 | + return (float) preg_replace('/[^0-9\.\-]/', '', $amount); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 | |
@@ -80,19 +80,19 @@ discard block |
||
80 | 80 | * @param float $amount |
81 | 81 | * @param float|string|int|null $decimals |
82 | 82 | */ |
83 | -function wpinv_round_amount( $amount, $decimals = null, $use_sprintf = false ) { |
|
83 | +function wpinv_round_amount($amount, $decimals = null, $use_sprintf = false) { |
|
84 | 84 | |
85 | - if ( $decimals === null ) { |
|
85 | + if ($decimals === null) { |
|
86 | 86 | $decimals = wpinv_decimals(); |
87 | 87 | } |
88 | 88 | |
89 | - if ( $use_sprintf ) { |
|
90 | - $amount = sprintf( "%.{$decimals}f", (float) $amount ); |
|
89 | + if ($use_sprintf) { |
|
90 | + $amount = sprintf("%.{$decimals}f", (float) $amount); |
|
91 | 91 | } else { |
92 | - $amount = round( (float) $amount, absint( $decimals ) ); |
|
92 | + $amount = round((float) $amount, absint($decimals)); |
|
93 | 93 | } |
94 | 94 | |
95 | - return apply_filters( 'wpinv_round_amount', $amount, $decimals ); |
|
95 | + return apply_filters('wpinv_round_amount', $amount, $decimals); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -104,32 +104,32 @@ discard block |
||
104 | 104 | * @param string|WPInv_Invoice $invoice The invoice object|post type|type |
105 | 105 | * @return array |
106 | 106 | */ |
107 | -function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
|
107 | +function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) { |
|
108 | 108 | |
109 | 109 | $invoice_statuses = array( |
110 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
111 | - 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
|
112 | - 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
113 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
114 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
115 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
116 | - 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
117 | - 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
|
110 | + 'wpi-pending' => _x('Pending payment', 'Invoice status', 'invoicing'), |
|
111 | + 'publish' => _x('Paid', 'Invoice status', 'invoicing'), |
|
112 | + 'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'), |
|
113 | + 'wpi-onhold' => _x('On hold', 'Invoice status', 'invoicing'), |
|
114 | + 'wpi-cancelled' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
115 | + 'wpi-refunded' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
116 | + 'wpi-failed' => _x('Failed', 'Invoice status', 'invoicing'), |
|
117 | + 'wpi-renewal' => _x('Renewal Payment', 'Invoice status', 'invoicing'), |
|
118 | 118 | ); |
119 | 119 | |
120 | - if ( $draft ) { |
|
121 | - $invoice_statuses['draft'] = __( 'Draft', 'invoicing' ); |
|
120 | + if ($draft) { |
|
121 | + $invoice_statuses['draft'] = __('Draft', 'invoicing'); |
|
122 | 122 | } |
123 | 123 | |
124 | - if ( $trashed ) { |
|
125 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
124 | + if ($trashed) { |
|
125 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
126 | 126 | } |
127 | 127 | |
128 | - if ( $invoice instanceof WPInv_Invoice ) { |
|
128 | + if ($invoice instanceof WPInv_Invoice) { |
|
129 | 129 | $invoice = $invoice->get_post_type(); |
130 | 130 | } |
131 | 131 | |
132 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
132 | + return apply_filters('wpinv_statuses', $invoice_statuses, $invoice); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | * @param string $status The raw status |
139 | 139 | * @param string|WPInv_Invoice $invoice The invoice object|post type|type |
140 | 140 | */ |
141 | -function wpinv_status_nicename( $status, $invoice = false ) { |
|
142 | - $statuses = wpinv_get_invoice_statuses( true, true, $invoice ); |
|
143 | - $status = isset( $statuses[$status] ) ? $statuses[$status] : $status; |
|
141 | +function wpinv_status_nicename($status, $invoice = false) { |
|
142 | + $statuses = wpinv_get_invoice_statuses(true, true, $invoice); |
|
143 | + $status = isset($statuses[$status]) ? $statuses[$status] : $status; |
|
144 | 144 | |
145 | - return sanitize_text_field( $status ); |
|
145 | + return sanitize_text_field($status); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -150,13 +150,13 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @param string $current |
152 | 152 | */ |
153 | -function wpinv_get_currency( $current = '' ) { |
|
153 | +function wpinv_get_currency($current = '') { |
|
154 | 154 | |
155 | - if ( empty( $current ) ) { |
|
156 | - $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) ); |
|
155 | + if (empty($current)) { |
|
156 | + $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD')); |
|
157 | 157 | } |
158 | 158 | |
159 | - return trim( strtoupper( $current ) ); |
|
159 | + return trim(strtoupper($current)); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -164,25 +164,25 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @param string|null $currency The currency code. Defaults to the default currency. |
166 | 166 | */ |
167 | -function wpinv_currency_symbol( $currency = null ) { |
|
167 | +function wpinv_currency_symbol($currency = null) { |
|
168 | 168 | |
169 | 169 | // Prepare the currency. |
170 | - $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency ); |
|
170 | + $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency); |
|
171 | 171 | |
172 | 172 | // Fetch all symbols. |
173 | 173 | $symbols = wpinv_get_currency_symbols(); |
174 | 174 | |
175 | 175 | // Fetch this currencies symbol. |
176 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency; |
|
176 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
177 | 177 | |
178 | 178 | // Filter the symbol. |
179 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
179 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | function wpinv_currency_position() { |
183 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
183 | + $position = wpinv_get_option('currency_position', 'left'); |
|
184 | 184 | |
185 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
185 | + return apply_filters('wpinv_currency_position', $position); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -190,13 +190,13 @@ discard block |
||
190 | 190 | * |
191 | 191 | * @param $string|null $current |
192 | 192 | */ |
193 | -function wpinv_thousands_separator( $current = null ) { |
|
193 | +function wpinv_thousands_separator($current = null) { |
|
194 | 194 | |
195 | - if ( null == $current ) { |
|
196 | - $current = wpinv_get_option( 'thousands_separator', '.' ); |
|
195 | + if (null == $current) { |
|
196 | + $current = wpinv_get_option('thousands_separator', '.'); |
|
197 | 197 | } |
198 | 198 | |
199 | - return trim( $current ); |
|
199 | + return trim($current); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -204,13 +204,13 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @param $string|null $current |
206 | 206 | */ |
207 | -function wpinv_decimal_separator( $current = null ) { |
|
207 | +function wpinv_decimal_separator($current = null) { |
|
208 | 208 | |
209 | - if ( null == $current ) { |
|
210 | - $current = wpinv_get_option( 'decimal_separator', '.' ); |
|
209 | + if (null == $current) { |
|
210 | + $current = wpinv_get_option('decimal_separator', '.'); |
|
211 | 211 | } |
212 | 212 | |
213 | - return trim( $current ); |
|
213 | + return trim($current); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -218,27 +218,27 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @param $string|null $current |
220 | 220 | */ |
221 | -function wpinv_decimals( $current = null ) { |
|
221 | +function wpinv_decimals($current = null) { |
|
222 | 222 | |
223 | - if ( null == $current ) { |
|
224 | - $current = wpinv_get_option( 'decimals', 2 ); |
|
223 | + if (null == $current) { |
|
224 | + $current = wpinv_get_option('decimals', 2); |
|
225 | 225 | } |
226 | 226 | |
227 | - return absint( $current ); |
|
227 | + return absint($current); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
231 | 231 | * Retrieves a list of all supported currencies. |
232 | 232 | */ |
233 | 233 | function wpinv_get_currencies() { |
234 | - return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) ); |
|
234 | + return apply_filters('wpinv_currencies', wpinv_get_data('currencies')); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
238 | 238 | * Retrieves a list of all currency symbols. |
239 | 239 | */ |
240 | 240 | function wpinv_get_currency_symbols() { |
241 | - return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) ); |
|
241 | + return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols')); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $currency_pos = wpinv_currency_position(); |
251 | 251 | $format = '%1$s%2$s'; |
252 | 252 | |
253 | - switch ( $currency_pos ) { |
|
253 | + switch ($currency_pos) { |
|
254 | 254 | case 'left': |
255 | 255 | $format = '%1$s%2$s'; |
256 | 256 | break; |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | break; |
266 | 266 | } |
267 | 267 | |
268 | - return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
268 | + return apply_filters('getpaid_price_format', $format, $currency_pos); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -275,25 +275,25 @@ discard block |
||
275 | 275 | * @param string $currency Currency. |
276 | 276 | * @return string |
277 | 277 | */ |
278 | -function wpinv_price( $amount = 0, $currency = '' ) { |
|
278 | +function wpinv_price($amount = 0, $currency = '') { |
|
279 | 279 | |
280 | 280 | // Backwards compatibility. |
281 | - $amount = floatval( wpinv_sanitize_amount( $amount ) ); |
|
281 | + $amount = floatval(wpinv_sanitize_amount($amount)); |
|
282 | 282 | |
283 | 283 | // Prepare variables. |
284 | - $currency = wpinv_get_currency( $currency ); |
|
284 | + $currency = wpinv_get_currency($currency); |
|
285 | 285 | $amount = (float) $amount; |
286 | 286 | $unformatted_amount = $amount; |
287 | 287 | $negative = $amount < 0; |
288 | - $amount = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) ); |
|
289 | - $amount = wpinv_format_amount( $amount ); |
|
288 | + $amount = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount)); |
|
289 | + $amount = wpinv_format_amount($amount); |
|
290 | 290 | |
291 | 291 | // Format the amount. |
292 | 292 | $format = getpaid_get_price_format(); |
293 | - $formatted_amount = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount ); |
|
293 | + $formatted_amount = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount); |
|
294 | 294 | |
295 | 295 | // Filter the formatting. |
296 | - return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount ); |
|
296 | + return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -304,33 +304,33 @@ discard block |
||
304 | 304 | * @param bool $calculate Whether or not to apply separators. |
305 | 305 | * @return string |
306 | 306 | */ |
307 | -function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) { |
|
307 | +function wpinv_format_amount($amount, $decimals = null, $calculate = false) { |
|
308 | 308 | $thousands_sep = wpinv_thousands_separator(); |
309 | 309 | $decimal_sep = wpinv_decimal_separator(); |
310 | - $decimals = wpinv_decimals( $decimals ); |
|
310 | + $decimals = wpinv_decimals($decimals); |
|
311 | 311 | |
312 | 312 | // Format decimals. |
313 | - $amount = str_replace( $decimal_sep, '.', $amount ); |
|
313 | + $amount = str_replace($decimal_sep, '.', $amount); |
|
314 | 314 | |
315 | 315 | // Remove thousands. |
316 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
316 | + $amount = str_replace($thousands_sep, '', $amount); |
|
317 | 317 | |
318 | 318 | // Cast the remaining to a float. |
319 | - $amount = floatval( $amount ); |
|
319 | + $amount = floatval($amount); |
|
320 | 320 | |
321 | - if ( $calculate ) { |
|
321 | + if ($calculate) { |
|
322 | 322 | return $amount; |
323 | 323 | } |
324 | 324 | |
325 | 325 | // Fomart the amount. |
326 | - return number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
326 | + return number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
327 | 327 | } |
328 | 328 | |
329 | -function wpinv_sanitize_key( $key ) { |
|
329 | +function wpinv_sanitize_key($key) { |
|
330 | 330 | $raw_key = $key; |
331 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
331 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
332 | 332 | |
333 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
333 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
@@ -338,8 +338,8 @@ discard block |
||
338 | 338 | * |
339 | 339 | * @param $str the file whose extension should be retrieved. |
340 | 340 | */ |
341 | -function wpinv_get_file_extension( $str ) { |
|
342 | - $filetype = wp_check_filetype( $str ); |
|
341 | +function wpinv_get_file_extension($str) { |
|
342 | + $filetype = wp_check_filetype($str); |
|
343 | 343 | return $filetype['ext']; |
344 | 344 | } |
345 | 345 | |
@@ -348,16 +348,16 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @param string $string |
350 | 350 | */ |
351 | -function wpinv_string_is_image_url( $string ) { |
|
352 | - $extension = strtolower( wpinv_get_file_extension( $string ) ); |
|
353 | - return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true ); |
|
351 | +function wpinv_string_is_image_url($string) { |
|
352 | + $extension = strtolower(wpinv_get_file_extension($string)); |
|
353 | + return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
357 | 357 | * Returns the current URL. |
358 | 358 | */ |
359 | 359 | function wpinv_get_current_page_url() { |
360 | - return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
360 | + return (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -367,46 +367,46 @@ discard block |
||
367 | 367 | * @param string $name Constant name. |
368 | 368 | * @param mixed $value Value. |
369 | 369 | */ |
370 | -function getpaid_maybe_define_constant( $name, $value ) { |
|
371 | - if ( ! defined( $name ) ) { |
|
372 | - define( $name, $value ); |
|
370 | +function getpaid_maybe_define_constant($name, $value) { |
|
371 | + if (!defined($name)) { |
|
372 | + define($name, $value); |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
376 | 376 | function wpinv_get_php_arg_separator_output() { |
377 | - return ini_get( 'arg_separator.output' ); |
|
377 | + return ini_get('arg_separator.output'); |
|
378 | 378 | } |
379 | 379 | |
380 | -function wpinv_rgb_from_hex( $color ) { |
|
381 | - $color = str_replace( '#', '', $color ); |
|
380 | +function wpinv_rgb_from_hex($color) { |
|
381 | + $color = str_replace('#', '', $color); |
|
382 | 382 | |
383 | 383 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
384 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
385 | - if ( empty( $color ) ) { |
|
384 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
385 | + if (empty($color)) { |
|
386 | 386 | return NULL; |
387 | 387 | } |
388 | 388 | |
389 | - $color = str_split( $color ); |
|
389 | + $color = str_split($color); |
|
390 | 390 | |
391 | 391 | $rgb = array(); |
392 | - $rgb['R'] = hexdec( $color[0] . $color[1] ); |
|
393 | - $rgb['G'] = hexdec( $color[2] . $color[3] ); |
|
394 | - $rgb['B'] = hexdec( $color[4] . $color[5] ); |
|
392 | + $rgb['R'] = hexdec($color[0] . $color[1]); |
|
393 | + $rgb['G'] = hexdec($color[2] . $color[3]); |
|
394 | + $rgb['B'] = hexdec($color[4] . $color[5]); |
|
395 | 395 | |
396 | 396 | return $rgb; |
397 | 397 | } |
398 | 398 | |
399 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
400 | - $base = wpinv_rgb_from_hex( $color ); |
|
399 | +function wpinv_hex_darker($color, $factor = 30) { |
|
400 | + $base = wpinv_rgb_from_hex($color); |
|
401 | 401 | $color = '#'; |
402 | 402 | |
403 | - foreach ( $base as $k => $v ) { |
|
403 | + foreach ($base as $k => $v) { |
|
404 | 404 | $amount = $v / 100; |
405 | - $amount = round( $amount * $factor ); |
|
405 | + $amount = round($amount * $factor); |
|
406 | 406 | $new_decimal = $v - $amount; |
407 | 407 | |
408 | - $new_hex_component = dechex( $new_decimal ); |
|
409 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
408 | + $new_hex_component = dechex($new_decimal); |
|
409 | + if (strlen($new_hex_component) < 2) { |
|
410 | 410 | $new_hex_component = "0" . $new_hex_component; |
411 | 411 | } |
412 | 412 | $color .= $new_hex_component; |
@@ -415,18 +415,18 @@ discard block |
||
415 | 415 | return $color; |
416 | 416 | } |
417 | 417 | |
418 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
419 | - $base = wpinv_rgb_from_hex( $color ); |
|
418 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
419 | + $base = wpinv_rgb_from_hex($color); |
|
420 | 420 | $color = '#'; |
421 | 421 | |
422 | - foreach ( $base as $k => $v ) { |
|
422 | + foreach ($base as $k => $v) { |
|
423 | 423 | $amount = 255 - $v; |
424 | 424 | $amount = $amount / 100; |
425 | - $amount = round( $amount * $factor ); |
|
425 | + $amount = round($amount * $factor); |
|
426 | 426 | $new_decimal = $v + $amount; |
427 | 427 | |
428 | - $new_hex_component = dechex( $new_decimal ); |
|
429 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
428 | + $new_hex_component = dechex($new_decimal); |
|
429 | + if (strlen($new_hex_component) < 2) { |
|
430 | 430 | $new_hex_component = "0" . $new_hex_component; |
431 | 431 | } |
432 | 432 | $color .= $new_hex_component; |
@@ -435,22 +435,22 @@ discard block |
||
435 | 435 | return $color; |
436 | 436 | } |
437 | 437 | |
438 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
439 | - $hex = str_replace( '#', '', $color ); |
|
438 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
439 | + $hex = str_replace('#', '', $color); |
|
440 | 440 | |
441 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
442 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
443 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
441 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
442 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
443 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
444 | 444 | |
445 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
445 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
446 | 446 | |
447 | 447 | return $brightness > 155 ? $dark : $light; |
448 | 448 | } |
449 | 449 | |
450 | -function wpinv_format_hex( $hex ) { |
|
451 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
450 | +function wpinv_format_hex($hex) { |
|
451 | + $hex = trim(str_replace('#', '', $hex)); |
|
452 | 452 | |
453 | - if ( strlen( $hex ) == 3 ) { |
|
453 | + if (strlen($hex) == 3) { |
|
454 | 454 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
455 | 455 | } |
456 | 456 | |
@@ -470,12 +470,12 @@ discard block |
||
470 | 470 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
471 | 471 | * @return string |
472 | 472 | */ |
473 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
474 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
475 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
473 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
474 | + if (function_exists('mb_strimwidth')) { |
|
475 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
476 | 476 | } |
477 | 477 | |
478 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
478 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | /** |
@@ -487,28 +487,28 @@ discard block |
||
487 | 487 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
488 | 488 | * @return int Returns the number of characters in string. |
489 | 489 | */ |
490 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
491 | - if ( function_exists( 'mb_strlen' ) ) { |
|
492 | - return mb_strlen( $str, $encoding ); |
|
490 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
491 | + if (function_exists('mb_strlen')) { |
|
492 | + return mb_strlen($str, $encoding); |
|
493 | 493 | } |
494 | 494 | |
495 | - return strlen( $str ); |
|
495 | + return strlen($str); |
|
496 | 496 | } |
497 | 497 | |
498 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
499 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
500 | - return mb_strtolower( $str, $encoding ); |
|
498 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
499 | + if (function_exists('mb_strtolower')) { |
|
500 | + return mb_strtolower($str, $encoding); |
|
501 | 501 | } |
502 | 502 | |
503 | - return strtolower( $str ); |
|
503 | + return strtolower($str); |
|
504 | 504 | } |
505 | 505 | |
506 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
507 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
508 | - return mb_strtoupper( $str, $encoding ); |
|
506 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
507 | + if (function_exists('mb_strtoupper')) { |
|
508 | + return mb_strtoupper($str, $encoding); |
|
509 | 509 | } |
510 | 510 | |
511 | - return strtoupper( $str ); |
|
511 | + return strtoupper($str); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | /** |
@@ -522,12 +522,12 @@ discard block |
||
522 | 522 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
523 | 523 | * @return int Returns the position of the first occurrence of search in the string. |
524 | 524 | */ |
525 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
526 | - if ( function_exists( 'mb_strpos' ) ) { |
|
527 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
525 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
526 | + if (function_exists('mb_strpos')) { |
|
527 | + return mb_strpos($str, $find, $offset, $encoding); |
|
528 | 528 | } |
529 | 529 | |
530 | - return strpos( $str, $find, $offset ); |
|
530 | + return strpos($str, $find, $offset); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | /** |
@@ -541,12 +541,12 @@ discard block |
||
541 | 541 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
542 | 542 | * @return int Returns the position of the last occurrence of search. |
543 | 543 | */ |
544 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
545 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
546 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
544 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
545 | + if (function_exists('mb_strrpos')) { |
|
546 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
547 | 547 | } |
548 | 548 | |
549 | - return strrpos( $str, $find, $offset ); |
|
549 | + return strrpos($str, $find, $offset); |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | /** |
@@ -561,16 +561,16 @@ discard block |
||
561 | 561 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
562 | 562 | * @return string |
563 | 563 | */ |
564 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
565 | - if ( function_exists( 'mb_substr' ) ) { |
|
566 | - if ( $length === null ) { |
|
567 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
564 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
565 | + if (function_exists('mb_substr')) { |
|
566 | + if ($length === null) { |
|
567 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
568 | 568 | } else { |
569 | - return mb_substr( $str, $start, $length, $encoding ); |
|
569 | + return mb_substr($str, $start, $length, $encoding); |
|
570 | 570 | } |
571 | 571 | } |
572 | 572 | |
573 | - return substr( $str, $start, $length ); |
|
573 | + return substr($str, $start, $length); |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | /** |
@@ -582,48 +582,48 @@ discard block |
||
582 | 582 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
583 | 583 | * @return string The width of string. |
584 | 584 | */ |
585 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
586 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
587 | - return mb_strwidth( $str, $encoding ); |
|
585 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
586 | + if (function_exists('mb_strwidth')) { |
|
587 | + return mb_strwidth($str, $encoding); |
|
588 | 588 | } |
589 | 589 | |
590 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
590 | + return wpinv_utf8_strlen($str, $encoding); |
|
591 | 591 | } |
592 | 592 | |
593 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
594 | - if ( function_exists( 'mb_strlen' ) ) { |
|
595 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
593 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
594 | + if (function_exists('mb_strlen')) { |
|
595 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
596 | 596 | $str_end = ""; |
597 | 597 | |
598 | - if ( $lower_str_end ) { |
|
599 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
598 | + if ($lower_str_end) { |
|
599 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
600 | 600 | } else { |
601 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
601 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | return $first_letter . $str_end; |
605 | 605 | } |
606 | 606 | |
607 | - return ucfirst( $str ); |
|
607 | + return ucfirst($str); |
|
608 | 608 | } |
609 | 609 | |
610 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
611 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
612 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
610 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
611 | + if (function_exists('mb_convert_case')) { |
|
612 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
613 | 613 | } |
614 | 614 | |
615 | - return ucwords( $str ); |
|
615 | + return ucwords($str); |
|
616 | 616 | } |
617 | 617 | |
618 | -function wpinv_period_in_days( $period, $unit ) { |
|
619 | - $period = absint( $period ); |
|
618 | +function wpinv_period_in_days($period, $unit) { |
|
619 | + $period = absint($period); |
|
620 | 620 | |
621 | - if ( $period > 0 ) { |
|
622 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
621 | + if ($period > 0) { |
|
622 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
623 | 623 | $period = $period * 7; |
624 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
624 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
625 | 625 | $period = $period * 30; |
626 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
626 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
627 | 627 | $period = $period * 365; |
628 | 628 | } |
629 | 629 | } |
@@ -631,14 +631,14 @@ discard block |
||
631 | 631 | return $period; |
632 | 632 | } |
633 | 633 | |
634 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
635 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
636 | - return cal_days_in_month( $calendar, $month, $year ); |
|
634 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
635 | + if (function_exists('cal_days_in_month')) { |
|
636 | + return cal_days_in_month($calendar, $month, $year); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | // Fallback in case the calendar extension is not loaded in PHP |
640 | 640 | // Only supports Gregorian calendar |
641 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
641 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | /** |
@@ -649,12 +649,12 @@ discard block |
||
649 | 649 | * |
650 | 650 | * @return string |
651 | 651 | */ |
652 | -function wpi_help_tip( $tip, $allow_html = false ) { |
|
652 | +function wpi_help_tip($tip, $allow_html = false) { |
|
653 | 653 | |
654 | - if ( $allow_html ) { |
|
655 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
654 | + if ($allow_html) { |
|
655 | + $tip = wpi_sanitize_tooltip($tip); |
|
656 | 656 | } else { |
657 | - $tip = esc_attr( $tip ); |
|
657 | + $tip = esc_attr($tip); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -668,8 +668,8 @@ discard block |
||
668 | 668 | * @param string $var |
669 | 669 | * @return string |
670 | 670 | */ |
671 | -function wpi_sanitize_tooltip( $var ) { |
|
672 | - return wp_kses( html_entity_decode( $var ), array( |
|
671 | +function wpi_sanitize_tooltip($var) { |
|
672 | + return wp_kses(html_entity_decode($var), array( |
|
673 | 673 | 'br' => array(), |
674 | 674 | 'em' => array(), |
675 | 675 | 'strong' => array(), |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | 'li' => array(), |
681 | 681 | 'ol' => array(), |
682 | 682 | 'p' => array(), |
683 | - ) ); |
|
683 | + )); |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | /** |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | */ |
691 | 691 | function wpinv_get_screen_ids() { |
692 | 692 | |
693 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
693 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
694 | 694 | |
695 | 695 | $screen_ids = array( |
696 | 696 | 'toplevel_page_' . $screen_id, |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | 'invoicing_page_wpi-addons', |
709 | 709 | ); |
710 | 710 | |
711 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
711 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | /** |
@@ -719,14 +719,14 @@ discard block |
||
719 | 719 | * @param array|string $list List of values. |
720 | 720 | * @return array Sanitized array of values. |
721 | 721 | */ |
722 | -function wpinv_parse_list( $list ) { |
|
722 | +function wpinv_parse_list($list) { |
|
723 | 723 | |
724 | - if ( empty( $list ) ) { |
|
724 | + if (empty($list)) { |
|
725 | 725 | $list = array(); |
726 | 726 | } |
727 | 727 | |
728 | - if ( ! is_array( $list ) ) { |
|
729 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
728 | + if (!is_array($list)) { |
|
729 | + return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY); |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | return $list; |
@@ -740,16 +740,16 @@ discard block |
||
740 | 740 | * @param string $key Type of data to fetch. |
741 | 741 | * @return mixed Fetched data. |
742 | 742 | */ |
743 | -function wpinv_get_data( $key ) { |
|
743 | +function wpinv_get_data($key) { |
|
744 | 744 | |
745 | 745 | // Try fetching it from the cache. |
746 | - $data = wp_cache_get( "wpinv-data-$key", 'wpinv' ); |
|
747 | - if( $data ) { |
|
746 | + $data = wp_cache_get("wpinv-data-$key", 'wpinv'); |
|
747 | + if ($data) { |
|
748 | 748 | return $data; |
749 | 749 | } |
750 | 750 | |
751 | - $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
|
752 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
751 | + $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php"); |
|
752 | + wp_cache_set("wpinv-data-$key", $data, 'wpinv'); |
|
753 | 753 | |
754 | 754 | return $data; |
755 | 755 | } |
@@ -763,10 +763,10 @@ discard block |
||
763 | 763 | * @param bool $first_empty Whether or not the first item in the list should be empty |
764 | 764 | * @return mixed Fetched data. |
765 | 765 | */ |
766 | -function wpinv_maybe_add_empty_option( $options, $first_empty ) { |
|
766 | +function wpinv_maybe_add_empty_option($options, $first_empty) { |
|
767 | 767 | |
768 | - if ( ! empty( $options ) && $first_empty ) { |
|
769 | - return array_merge( array( '' => '' ), $options ); |
|
768 | + if (!empty($options) && $first_empty) { |
|
769 | + return array_merge(array('' => ''), $options); |
|
770 | 770 | } |
771 | 771 | return $options; |
772 | 772 | |
@@ -778,21 +778,21 @@ discard block |
||
778 | 778 | * @param mixed $var Data to sanitize. |
779 | 779 | * @return string|array |
780 | 780 | */ |
781 | -function wpinv_clean( $var ) { |
|
781 | +function wpinv_clean($var) { |
|
782 | 782 | |
783 | - if ( is_array( $var ) ) { |
|
784 | - return array_map( 'wpinv_clean', $var ); |
|
783 | + if (is_array($var)) { |
|
784 | + return array_map('wpinv_clean', $var); |
|
785 | 785 | } |
786 | 786 | |
787 | - if ( is_object( $var ) ) { |
|
788 | - $object_vars = get_object_vars( $var ); |
|
789 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
790 | - $var->$property_name = wpinv_clean( $property_value ); |
|
787 | + if (is_object($var)) { |
|
788 | + $object_vars = get_object_vars($var); |
|
789 | + foreach ($object_vars as $property_name => $property_value) { |
|
790 | + $var->$property_name = wpinv_clean($property_value); |
|
791 | 791 | } |
792 | 792 | return $var; |
793 | 793 | } |
794 | 794 | |
795 | - return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
|
795 | + return is_string($var) ? sanitize_text_field($var) : $var; |
|
796 | 796 | } |
797 | 797 | |
798 | 798 | /** |
@@ -801,43 +801,43 @@ discard block |
||
801 | 801 | * @param string $str Data to convert. |
802 | 802 | * @return string|array |
803 | 803 | */ |
804 | -function getpaid_convert_price_string_to_options( $str ) { |
|
804 | +function getpaid_convert_price_string_to_options($str) { |
|
805 | 805 | |
806 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
807 | - $options = array(); |
|
806 | + $raw_options = array_map('trim', explode(',', $str)); |
|
807 | + $options = array(); |
|
808 | 808 | |
809 | - foreach ( $raw_options as $option ) { |
|
809 | + foreach ($raw_options as $option) { |
|
810 | 810 | |
811 | - if ( '' == $option ) { |
|
811 | + if ('' == $option) { |
|
812 | 812 | continue; |
813 | 813 | } |
814 | 814 | |
815 | - $option = array_map( 'trim', explode( '|', $option ) ); |
|
815 | + $option = array_map('trim', explode('|', $option)); |
|
816 | 816 | |
817 | 817 | $price = null; |
818 | 818 | $label = null; |
819 | 819 | |
820 | - if ( isset( $option[0] ) && '' != $option[0] ) { |
|
821 | - $label = $option[0]; |
|
820 | + if (isset($option[0]) && '' != $option[0]) { |
|
821 | + $label = $option[0]; |
|
822 | 822 | } |
823 | 823 | |
824 | - if ( isset( $option[1] ) && '' != $option[1] ) { |
|
824 | + if (isset($option[1]) && '' != $option[1]) { |
|
825 | 825 | $price = $option[1]; |
826 | 826 | } |
827 | 827 | |
828 | - if ( ! isset( $price ) ) { |
|
828 | + if (!isset($price)) { |
|
829 | 829 | $price = $label; |
830 | 830 | } |
831 | 831 | |
832 | - if ( ! isset( $price ) || ! is_numeric( $price ) ) { |
|
832 | + if (!isset($price) || !is_numeric($price)) { |
|
833 | 833 | continue; |
834 | 834 | } |
835 | 835 | |
836 | - if ( ! isset( $label ) ) { |
|
836 | + if (!isset($label)) { |
|
837 | 837 | $label = $price; |
838 | 838 | } |
839 | 839 | |
840 | - $options[ $price ] = $label; |
|
840 | + $options[$price] = $label; |
|
841 | 841 | } |
842 | 842 | |
843 | 843 | return $options; |
@@ -846,22 +846,22 @@ discard block |
||
846 | 846 | /** |
847 | 847 | * Returns the help tip. |
848 | 848 | */ |
849 | -function getpaid_get_help_tip( $tip, $additional_classes = '' ) { |
|
850 | - $additional_classes = sanitize_html_class( $additional_classes ); |
|
851 | - $tip = esc_attr__( $tip ); |
|
849 | +function getpaid_get_help_tip($tip, $additional_classes = '') { |
|
850 | + $additional_classes = sanitize_html_class($additional_classes); |
|
851 | + $tip = esc_attr__($tip); |
|
852 | 852 | return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>"; |
853 | 853 | } |
854 | 854 | |
855 | 855 | /** |
856 | 856 | * Formats a date |
857 | 857 | */ |
858 | -function getpaid_format_date( $date ) { |
|
858 | +function getpaid_format_date($date) { |
|
859 | 859 | |
860 | - if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) { |
|
860 | + if (empty($date) || $date == '0000-00-00 00:00:00') { |
|
861 | 861 | return ''; |
862 | 862 | } |
863 | 863 | |
864 | - return date_i18n( getpaid_date_format(), strtotime( $date ) ); |
|
864 | + return date_i18n(getpaid_date_format(), strtotime($date)); |
|
865 | 865 | |
866 | 866 | } |
867 | 867 | |
@@ -870,9 +870,9 @@ discard block |
||
870 | 870 | * |
871 | 871 | * @return string |
872 | 872 | */ |
873 | -function getpaid_format_date_value( $date, $default = "—" ) { |
|
874 | - $date = getpaid_format_date( $date ); |
|
875 | - return empty( $date ) ? $default : $date; |
|
873 | +function getpaid_format_date_value($date, $default = "—") { |
|
874 | + $date = getpaid_format_date($date); |
|
875 | + return empty($date) ? $default : $date; |
|
876 | 876 | } |
877 | 877 | |
878 | 878 | /** |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | * @return string |
882 | 882 | */ |
883 | 883 | function getpaid_date_format() { |
884 | - return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
884 | + return apply_filters('getpaid_date_format', get_option('date_format')); |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | /** |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | * @return string |
891 | 891 | */ |
892 | 892 | function getpaid_time_format() { |
893 | - return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
893 | + return apply_filters('getpaid_time_format', get_option('time_format')); |
|
894 | 894 | } |
895 | 895 | |
896 | 896 | /** |
@@ -900,16 +900,16 @@ discard block |
||
900 | 900 | * @param integer $limit Limit size in characters. |
901 | 901 | * @return string |
902 | 902 | */ |
903 | -function getpaid_limit_length( $string, $limit ) { |
|
903 | +function getpaid_limit_length($string, $limit) { |
|
904 | 904 | $str_limit = $limit - 3; |
905 | 905 | |
906 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
907 | - if ( mb_strlen( $string ) > $limit ) { |
|
908 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
906 | + if (function_exists('mb_strimwidth')) { |
|
907 | + if (mb_strlen($string) > $limit) { |
|
908 | + $string = mb_strimwidth($string, 0, $str_limit) . '...'; |
|
909 | 909 | } |
910 | 910 | } else { |
911 | - if ( strlen( $string ) > $limit ) { |
|
912 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
911 | + if (strlen($string) > $limit) { |
|
912 | + $string = substr($string, 0, $str_limit) . '...'; |
|
913 | 913 | } |
914 | 914 | } |
915 | 915 | return $string; |
@@ -923,7 +923,7 @@ discard block |
||
923 | 923 | * @since 1.0.19 |
924 | 924 | */ |
925 | 925 | function getpaid_api() { |
926 | - return getpaid()->get( 'api' ); |
|
926 | + return getpaid()->get('api'); |
|
927 | 927 | } |
928 | 928 | |
929 | 929 | /** |
@@ -933,7 +933,7 @@ discard block |
||
933 | 933 | * @since 1.0.19 |
934 | 934 | */ |
935 | 935 | function getpaid_post_types() { |
936 | - return getpaid()->get( 'post_types' ); |
|
936 | + return getpaid()->get('post_types'); |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | /** |
@@ -943,7 +943,7 @@ discard block |
||
943 | 943 | * @since 1.0.19 |
944 | 944 | */ |
945 | 945 | function getpaid_session() { |
946 | - return getpaid()->get( 'session' ); |
|
946 | + return getpaid()->get('session'); |
|
947 | 947 | } |
948 | 948 | |
949 | 949 | /** |
@@ -953,7 +953,7 @@ discard block |
||
953 | 953 | * @since 1.0.19 |
954 | 954 | */ |
955 | 955 | function getpaid_notes() { |
956 | - return getpaid()->get( 'notes' ); |
|
956 | + return getpaid()->get('notes'); |
|
957 | 957 | } |
958 | 958 | |
959 | 959 | /** |
@@ -962,7 +962,7 @@ discard block |
||
962 | 962 | * @return GetPaid_Admin |
963 | 963 | */ |
964 | 964 | function getpaid_admin() { |
965 | - return getpaid()->get( 'admin' ); |
|
965 | + return getpaid()->get('admin'); |
|
966 | 966 | } |
967 | 967 | |
968 | 968 | /** |
@@ -972,8 +972,8 @@ discard block |
||
972 | 972 | * @param string $base the base url |
973 | 973 | * @return string |
974 | 974 | */ |
975 | -function getpaid_get_authenticated_action_url( $action, $base = false ) { |
|
976 | - return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
975 | +function getpaid_get_authenticated_action_url($action, $base = false) { |
|
976 | + return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce'); |
|
977 | 977 | } |
978 | 978 | |
979 | 979 | /** |
@@ -981,11 +981,11 @@ discard block |
||
981 | 981 | * |
982 | 982 | * @return string |
983 | 983 | */ |
984 | -function getpaid_get_post_type_label( $post_type, $plural = true ) { |
|
984 | +function getpaid_get_post_type_label($post_type, $plural = true) { |
|
985 | 985 | |
986 | - $post_type = get_post_type_object( $post_type ); |
|
986 | + $post_type = get_post_type_object($post_type); |
|
987 | 987 | |
988 | - if ( ! is_object( $post_type ) ) { |
|
988 | + if (!is_object($post_type)) { |
|
989 | 989 | return null; |
990 | 990 | } |
991 | 991 | |
@@ -998,18 +998,18 @@ discard block |
||
998 | 998 | * |
999 | 999 | * @return mixed|null |
1000 | 1000 | */ |
1001 | -function getpaid_get_array_field( $array, $key, $secondary_key = null ) { |
|
1001 | +function getpaid_get_array_field($array, $key, $secondary_key = null) { |
|
1002 | 1002 | |
1003 | - if ( ! is_array( $array ) ) { |
|
1003 | + if (!is_array($array)) { |
|
1004 | 1004 | return null; |
1005 | 1005 | } |
1006 | 1006 | |
1007 | - if ( ! empty( $secondary_key ) ) { |
|
1008 | - $array = isset( $array[ $secondary_key ] ) ? $array[ $secondary_key ] : array(); |
|
1009 | - return getpaid_get_array_field( $array, $key ); |
|
1007 | + if (!empty($secondary_key)) { |
|
1008 | + $array = isset($array[$secondary_key]) ? $array[$secondary_key] : array(); |
|
1009 | + return getpaid_get_array_field($array, $key); |
|
1010 | 1010 | } |
1011 | 1011 | |
1012 | - return isset( $array[ $key ] ) ? $array[ $key ] : null; |
|
1012 | + return isset($array[$key]) ? $array[$key] : null; |
|
1013 | 1013 | |
1014 | 1014 | } |
1015 | 1015 | |
@@ -1018,12 +1018,12 @@ discard block |
||
1018 | 1018 | * |
1019 | 1019 | * @return array |
1020 | 1020 | */ |
1021 | -function getpaid_array_merge_if_empty( $args, $defaults ) { |
|
1021 | +function getpaid_array_merge_if_empty($args, $defaults) { |
|
1022 | 1022 | |
1023 | - foreach ( $defaults as $key => $value ) { |
|
1023 | + foreach ($defaults as $key => $value) { |
|
1024 | 1024 | |
1025 | - if ( array_key_exists( $key, $args ) && empty( $args[ $key ] ) ) { |
|
1026 | - $args[ $key ] = $value; |
|
1025 | + if (array_key_exists($key, $args) && empty($args[$key])) { |
|
1026 | + $args[$key] = $value; |
|
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | } |
@@ -12,224 +12,224 @@ |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Payment_Form_Submission_Refresh_Prices { |
14 | 14 | |
15 | - /** |
|
16 | - * Contains the response for refreshing prices. |
|
17 | - * @var array |
|
18 | - */ |
|
19 | - public $response = array(); |
|
15 | + /** |
|
16 | + * Contains the response for refreshing prices. |
|
17 | + * @var array |
|
18 | + */ |
|
19 | + public $response = array(); |
|
20 | 20 | |
21 | 21 | /** |
22 | - * Class constructor |
|
23 | - * |
|
24 | - * @param GetPaid_Payment_Form_Submission $submission |
|
25 | - */ |
|
26 | - public function __construct( $submission ) { |
|
27 | - |
|
28 | - $this->response = array( |
|
29 | - 'submission_id' => $submission->id, |
|
22 | + * Class constructor |
|
23 | + * |
|
24 | + * @param GetPaid_Payment_Form_Submission $submission |
|
25 | + */ |
|
26 | + public function __construct( $submission ) { |
|
27 | + |
|
28 | + $this->response = array( |
|
29 | + 'submission_id' => $submission->id, |
|
30 | 30 | 'has_recurring' => $submission->has_recurring, |
31 | 31 | 'is_free' => ! $submission->should_collect_payment_details(), |
32 | - ); |
|
33 | - |
|
34 | - $this->add_totals( $submission ); |
|
35 | - $this->add_texts( $submission ); |
|
36 | - $this->add_items( $submission ); |
|
37 | - $this->add_fees( $submission ); |
|
38 | - $this->add_discounts( $submission ); |
|
39 | - $this->add_taxes( $submission ); |
|
40 | - $this->add_gateways( $submission ); |
|
41 | - |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * Adds totals to a response for submission refresh prices. |
|
46 | - * |
|
47 | - * @param GetPaid_Payment_Form_Submission $submission |
|
48 | - */ |
|
49 | - public function add_totals( $submission ) { |
|
50 | - |
|
51 | - $this->response = array_merge( |
|
52 | - $this->response, |
|
53 | - array( |
|
54 | - |
|
55 | - 'totals' => array( |
|
56 | - 'subtotal' => $submission->format_amount( $submission->get_subtotal() ), |
|
57 | - 'discount' => $submission->format_amount( $submission->get_discount() ), |
|
58 | - 'fees' => $submission->format_amount( $submission->get_fee() ), |
|
59 | - 'tax' => $submission->format_amount( $submission->get_tax() ), |
|
60 | - 'total' => $submission->format_amount( $submission->get_total() ), |
|
61 | - 'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ), |
|
62 | - ), |
|
63 | - |
|
64 | - 'recurring' => array( |
|
65 | - 'subtotal' => $submission->format_amount( $submission->get_recurring_subtotal() ), |
|
66 | - 'discount' => $submission->format_amount( $submission->get_recurring_discount() ), |
|
67 | - 'fees' => $submission->format_amount( $submission->get_recurring_fee() ), |
|
68 | - 'tax' => $submission->format_amount( $submission->get_recurring_tax() ), |
|
69 | - 'total' => $submission->format_amount( $submission->get_recurring_total() ), |
|
70 | - ), |
|
71 | - |
|
72 | - ) |
|
73 | - ); |
|
74 | - |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Adds texts to a response for submission refresh prices. |
|
79 | - * |
|
80 | - * @param GetPaid_Payment_Form_Submission $submission |
|
81 | - */ |
|
82 | - public function add_texts( $submission ) { |
|
83 | - |
|
84 | - $payable = $submission->format_amount( $submission->get_total() ); |
|
85 | - |
|
86 | - if ( $submission->has_recurring != 0 ) { |
|
87 | - |
|
88 | - $recurring = new WPInv_Item( $submission->has_recurring ); |
|
89 | - $period = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' ); |
|
90 | - |
|
91 | - if ( $submission->get_total() == $submission->get_recurring_total() ) { |
|
92 | - $payable = "$payable / $period"; |
|
93 | - } else { |
|
94 | - $payable = sprintf( |
|
95 | - __( '%1$s (renews at %2$s / %3$s)'), |
|
96 | - $submission->format_amount( $submission->get_total() ), |
|
97 | - $submission->format_amount( $submission->get_recurring_total() ), |
|
98 | - $period |
|
99 | - ); |
|
100 | - } |
|
101 | - |
|
102 | - } |
|
103 | - |
|
104 | - $texts = array( |
|
105 | - '.getpaid-checkout-total-payable' => $payable, |
|
106 | - ); |
|
107 | - |
|
108 | - foreach ( $submission->get_items() as $item_id => $item ) { |
|
109 | - $texts[".item-$item_id .getpaid-item-initial-price"] = $submission->format_amount( $item->get_sub_total() ); |
|
110 | - $texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() ); |
|
111 | - } |
|
112 | - |
|
113 | - $this->response = array_merge( $this->response, array( 'texts' => $texts ) ); |
|
114 | - |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * Adds items to a response for submission refresh prices. |
|
119 | - * |
|
120 | - * @param GetPaid_Payment_Form_Submission $submission |
|
121 | - */ |
|
122 | - public function add_items( $submission ) { |
|
123 | - |
|
124 | - // Add items. |
|
125 | - $items = array(); |
|
32 | + ); |
|
33 | + |
|
34 | + $this->add_totals( $submission ); |
|
35 | + $this->add_texts( $submission ); |
|
36 | + $this->add_items( $submission ); |
|
37 | + $this->add_fees( $submission ); |
|
38 | + $this->add_discounts( $submission ); |
|
39 | + $this->add_taxes( $submission ); |
|
40 | + $this->add_gateways( $submission ); |
|
41 | + |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * Adds totals to a response for submission refresh prices. |
|
46 | + * |
|
47 | + * @param GetPaid_Payment_Form_Submission $submission |
|
48 | + */ |
|
49 | + public function add_totals( $submission ) { |
|
50 | + |
|
51 | + $this->response = array_merge( |
|
52 | + $this->response, |
|
53 | + array( |
|
54 | + |
|
55 | + 'totals' => array( |
|
56 | + 'subtotal' => $submission->format_amount( $submission->get_subtotal() ), |
|
57 | + 'discount' => $submission->format_amount( $submission->get_discount() ), |
|
58 | + 'fees' => $submission->format_amount( $submission->get_fee() ), |
|
59 | + 'tax' => $submission->format_amount( $submission->get_tax() ), |
|
60 | + 'total' => $submission->format_amount( $submission->get_total() ), |
|
61 | + 'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ), |
|
62 | + ), |
|
63 | + |
|
64 | + 'recurring' => array( |
|
65 | + 'subtotal' => $submission->format_amount( $submission->get_recurring_subtotal() ), |
|
66 | + 'discount' => $submission->format_amount( $submission->get_recurring_discount() ), |
|
67 | + 'fees' => $submission->format_amount( $submission->get_recurring_fee() ), |
|
68 | + 'tax' => $submission->format_amount( $submission->get_recurring_tax() ), |
|
69 | + 'total' => $submission->format_amount( $submission->get_recurring_total() ), |
|
70 | + ), |
|
71 | + |
|
72 | + ) |
|
73 | + ); |
|
74 | + |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Adds texts to a response for submission refresh prices. |
|
79 | + * |
|
80 | + * @param GetPaid_Payment_Form_Submission $submission |
|
81 | + */ |
|
82 | + public function add_texts( $submission ) { |
|
83 | + |
|
84 | + $payable = $submission->format_amount( $submission->get_total() ); |
|
85 | + |
|
86 | + if ( $submission->has_recurring != 0 ) { |
|
87 | + |
|
88 | + $recurring = new WPInv_Item( $submission->has_recurring ); |
|
89 | + $period = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' ); |
|
90 | + |
|
91 | + if ( $submission->get_total() == $submission->get_recurring_total() ) { |
|
92 | + $payable = "$payable / $period"; |
|
93 | + } else { |
|
94 | + $payable = sprintf( |
|
95 | + __( '%1$s (renews at %2$s / %3$s)'), |
|
96 | + $submission->format_amount( $submission->get_total() ), |
|
97 | + $submission->format_amount( $submission->get_recurring_total() ), |
|
98 | + $period |
|
99 | + ); |
|
100 | + } |
|
101 | + |
|
102 | + } |
|
103 | + |
|
104 | + $texts = array( |
|
105 | + '.getpaid-checkout-total-payable' => $payable, |
|
106 | + ); |
|
126 | 107 | |
127 | 108 | foreach ( $submission->get_items() as $item_id => $item ) { |
128 | - $items["$item_id"] = $submission->format_amount( $item->get_sub_total() ); |
|
129 | - } |
|
109 | + $texts[".item-$item_id .getpaid-item-initial-price"] = $submission->format_amount( $item->get_sub_total() ); |
|
110 | + $texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() ); |
|
111 | + } |
|
130 | 112 | |
131 | - $this->response = array_merge( |
|
132 | - $this->response, |
|
133 | - array( 'items' => $items ) |
|
134 | - ); |
|
113 | + $this->response = array_merge( $this->response, array( 'texts' => $texts ) ); |
|
135 | 114 | |
136 | - } |
|
115 | + } |
|
137 | 116 | |
138 | - /** |
|
139 | - * Adds fees to a response for submission refresh prices. |
|
140 | - * |
|
141 | - * @param GetPaid_Payment_Form_Submission $submission |
|
142 | - */ |
|
143 | - public function add_fees( $submission ) { |
|
117 | + /** |
|
118 | + * Adds items to a response for submission refresh prices. |
|
119 | + * |
|
120 | + * @param GetPaid_Payment_Form_Submission $submission |
|
121 | + */ |
|
122 | + public function add_items( $submission ) { |
|
123 | + |
|
124 | + // Add items. |
|
125 | + $items = array(); |
|
126 | + |
|
127 | + foreach ( $submission->get_items() as $item_id => $item ) { |
|
128 | + $items["$item_id"] = $submission->format_amount( $item->get_sub_total() ); |
|
129 | + } |
|
130 | + |
|
131 | + $this->response = array_merge( |
|
132 | + $this->response, |
|
133 | + array( 'items' => $items ) |
|
134 | + ); |
|
135 | + |
|
136 | + } |
|
144 | 137 | |
145 | - $fees = array(); |
|
138 | + /** |
|
139 | + * Adds fees to a response for submission refresh prices. |
|
140 | + * |
|
141 | + * @param GetPaid_Payment_Form_Submission $submission |
|
142 | + */ |
|
143 | + public function add_fees( $submission ) { |
|
144 | + |
|
145 | + $fees = array(); |
|
146 | 146 | |
147 | 147 | foreach ( $submission->get_fees() as $name => $data ) { |
148 | - $fees[$name] = $submission->format_amount( $data['initial_fee'] ); |
|
149 | - } |
|
148 | + $fees[$name] = $submission->format_amount( $data['initial_fee'] ); |
|
149 | + } |
|
150 | 150 | |
151 | - $this->response = array_merge( |
|
152 | - $this->response, |
|
153 | - array( 'fees' => $fees ) |
|
154 | - ); |
|
151 | + $this->response = array_merge( |
|
152 | + $this->response, |
|
153 | + array( 'fees' => $fees ) |
|
154 | + ); |
|
155 | 155 | |
156 | - } |
|
156 | + } |
|
157 | 157 | |
158 | - /** |
|
159 | - * Adds discounts to a response for submission refresh prices. |
|
160 | - * |
|
161 | - * @param GetPaid_Payment_Form_Submission $submission |
|
162 | - */ |
|
163 | - public function add_discounts( $submission ) { |
|
158 | + /** |
|
159 | + * Adds discounts to a response for submission refresh prices. |
|
160 | + * |
|
161 | + * @param GetPaid_Payment_Form_Submission $submission |
|
162 | + */ |
|
163 | + public function add_discounts( $submission ) { |
|
164 | 164 | |
165 | - $discounts = array(); |
|
165 | + $discounts = array(); |
|
166 | 166 | |
167 | 167 | foreach ( $submission->get_discounts() as $name => $data ) { |
168 | - $discounts[$name] = $submission->format_amount( $data['initial_discount'] ); |
|
169 | - } |
|
168 | + $discounts[$name] = $submission->format_amount( $data['initial_discount'] ); |
|
169 | + } |
|
170 | 170 | |
171 | - $this->response = array_merge( |
|
172 | - $this->response, |
|
173 | - array( 'discounts' => $discounts ) |
|
174 | - ); |
|
171 | + $this->response = array_merge( |
|
172 | + $this->response, |
|
173 | + array( 'discounts' => $discounts ) |
|
174 | + ); |
|
175 | 175 | |
176 | - } |
|
176 | + } |
|
177 | 177 | |
178 | - /** |
|
179 | - * Adds taxes to a response for submission refresh prices. |
|
180 | - * |
|
181 | - * @param GetPaid_Payment_Form_Submission $submission |
|
182 | - */ |
|
183 | - public function add_taxes( $submission ) { |
|
184 | - |
|
185 | - $taxes = array(); |
|
186 | - $markup = ''; |
|
178 | + /** |
|
179 | + * Adds taxes to a response for submission refresh prices. |
|
180 | + * |
|
181 | + * @param GetPaid_Payment_Form_Submission $submission |
|
182 | + */ |
|
183 | + public function add_taxes( $submission ) { |
|
184 | + |
|
185 | + $taxes = array(); |
|
186 | + $markup = ''; |
|
187 | 187 | foreach ( $submission->get_taxes() as $name => $data ) { |
188 | - $name = sanitize_text_field( $name ); |
|
189 | - $amount = $submission->format_amount( $data['initial_tax'] ); |
|
190 | - $taxes[$name] = $amount; |
|
191 | - $markup .= "<small class='form-text'>$name : $amount</small>"; |
|
192 | - } |
|
188 | + $name = sanitize_text_field( $name ); |
|
189 | + $amount = $submission->format_amount( $data['initial_tax'] ); |
|
190 | + $taxes[$name] = $amount; |
|
191 | + $markup .= "<small class='form-text'>$name : $amount</small>"; |
|
192 | + } |
|
193 | 193 | |
194 | - if ( wpinv_display_individual_tax_rates() ) { |
|
195 | - $this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup; |
|
196 | - } |
|
194 | + if ( wpinv_display_individual_tax_rates() ) { |
|
195 | + $this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup; |
|
196 | + } |
|
197 | 197 | |
198 | - $this->response = array_merge( |
|
199 | - $this->response, |
|
200 | - array( 'taxes' => $taxes ) |
|
201 | - ); |
|
198 | + $this->response = array_merge( |
|
199 | + $this->response, |
|
200 | + array( 'taxes' => $taxes ) |
|
201 | + ); |
|
202 | 202 | |
203 | - } |
|
203 | + } |
|
204 | 204 | |
205 | - /** |
|
206 | - * Adds gateways to a response for submission refresh prices. |
|
207 | - * |
|
208 | - * @param GetPaid_Payment_Form_Submission $submission |
|
209 | - */ |
|
210 | - public function add_gateways( $submission ) { |
|
205 | + /** |
|
206 | + * Adds gateways to a response for submission refresh prices. |
|
207 | + * |
|
208 | + * @param GetPaid_Payment_Form_Submission $submission |
|
209 | + */ |
|
210 | + public function add_gateways( $submission ) { |
|
211 | 211 | |
212 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
212 | + $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
213 | 213 | |
214 | - if ( $this->response['has_recurring'] ) { |
|
214 | + if ( $this->response['has_recurring'] ) { |
|
215 | 215 | |
216 | - foreach ( $gateways as $i => $gateway ) { |
|
216 | + foreach ( $gateways as $i => $gateway ) { |
|
217 | 217 | |
218 | - if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
219 | - unset( $gateways[ $i ] ); |
|
220 | - } |
|
218 | + if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
219 | + unset( $gateways[ $i ] ); |
|
220 | + } |
|
221 | 221 | |
222 | - } |
|
222 | + } |
|
223 | 223 | |
224 | - } |
|
224 | + } |
|
225 | 225 | |
226 | 226 | |
227 | - $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission ); |
|
228 | - $this->response = array_merge( |
|
229 | - $this->response, |
|
230 | - array( 'gateways' => $gateways ) |
|
231 | - ); |
|
227 | + $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission ); |
|
228 | + $this->response = array_merge( |
|
229 | + $this->response, |
|
230 | + array( 'gateways' => $gateways ) |
|
231 | + ); |
|
232 | 232 | |
233 | - } |
|
233 | + } |
|
234 | 234 | |
235 | 235 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Payment form submission refresh prices class |
@@ -23,21 +23,21 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param GetPaid_Payment_Form_Submission $submission |
25 | 25 | */ |
26 | - public function __construct( $submission ) { |
|
26 | + public function __construct($submission) { |
|
27 | 27 | |
28 | 28 | $this->response = array( |
29 | 29 | 'submission_id' => $submission->id, |
30 | 30 | 'has_recurring' => $submission->has_recurring, |
31 | - 'is_free' => ! $submission->should_collect_payment_details(), |
|
31 | + 'is_free' => !$submission->should_collect_payment_details(), |
|
32 | 32 | ); |
33 | 33 | |
34 | - $this->add_totals( $submission ); |
|
35 | - $this->add_texts( $submission ); |
|
36 | - $this->add_items( $submission ); |
|
37 | - $this->add_fees( $submission ); |
|
38 | - $this->add_discounts( $submission ); |
|
39 | - $this->add_taxes( $submission ); |
|
40 | - $this->add_gateways( $submission ); |
|
34 | + $this->add_totals($submission); |
|
35 | + $this->add_texts($submission); |
|
36 | + $this->add_items($submission); |
|
37 | + $this->add_fees($submission); |
|
38 | + $this->add_discounts($submission); |
|
39 | + $this->add_taxes($submission); |
|
40 | + $this->add_gateways($submission); |
|
41 | 41 | |
42 | 42 | } |
43 | 43 | |
@@ -46,27 +46,27 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @param GetPaid_Payment_Form_Submission $submission |
48 | 48 | */ |
49 | - public function add_totals( $submission ) { |
|
49 | + public function add_totals($submission) { |
|
50 | 50 | |
51 | 51 | $this->response = array_merge( |
52 | 52 | $this->response, |
53 | 53 | array( |
54 | 54 | |
55 | 55 | 'totals' => array( |
56 | - 'subtotal' => $submission->format_amount( $submission->get_subtotal() ), |
|
57 | - 'discount' => $submission->format_amount( $submission->get_discount() ), |
|
58 | - 'fees' => $submission->format_amount( $submission->get_fee() ), |
|
59 | - 'tax' => $submission->format_amount( $submission->get_tax() ), |
|
60 | - 'total' => $submission->format_amount( $submission->get_total() ), |
|
61 | - 'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ), |
|
56 | + 'subtotal' => $submission->format_amount($submission->get_subtotal()), |
|
57 | + 'discount' => $submission->format_amount($submission->get_discount()), |
|
58 | + 'fees' => $submission->format_amount($submission->get_fee()), |
|
59 | + 'tax' => $submission->format_amount($submission->get_tax()), |
|
60 | + 'total' => $submission->format_amount($submission->get_total()), |
|
61 | + 'raw_total' => html_entity_decode(sanitize_text_field($submission->format_amount($submission->get_total())), ENT_QUOTES), |
|
62 | 62 | ), |
63 | 63 | |
64 | 64 | 'recurring' => array( |
65 | - 'subtotal' => $submission->format_amount( $submission->get_recurring_subtotal() ), |
|
66 | - 'discount' => $submission->format_amount( $submission->get_recurring_discount() ), |
|
67 | - 'fees' => $submission->format_amount( $submission->get_recurring_fee() ), |
|
68 | - 'tax' => $submission->format_amount( $submission->get_recurring_tax() ), |
|
69 | - 'total' => $submission->format_amount( $submission->get_recurring_total() ), |
|
65 | + 'subtotal' => $submission->format_amount($submission->get_recurring_subtotal()), |
|
66 | + 'discount' => $submission->format_amount($submission->get_recurring_discount()), |
|
67 | + 'fees' => $submission->format_amount($submission->get_recurring_fee()), |
|
68 | + 'tax' => $submission->format_amount($submission->get_recurring_tax()), |
|
69 | + 'total' => $submission->format_amount($submission->get_recurring_total()), |
|
70 | 70 | ), |
71 | 71 | |
72 | 72 | ) |
@@ -79,22 +79,22 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @param GetPaid_Payment_Form_Submission $submission |
81 | 81 | */ |
82 | - public function add_texts( $submission ) { |
|
82 | + public function add_texts($submission) { |
|
83 | 83 | |
84 | - $payable = $submission->format_amount( $submission->get_total() ); |
|
84 | + $payable = $submission->format_amount($submission->get_total()); |
|
85 | 85 | |
86 | - if ( $submission->has_recurring != 0 ) { |
|
86 | + if ($submission->has_recurring != 0) { |
|
87 | 87 | |
88 | - $recurring = new WPInv_Item( $submission->has_recurring ); |
|
89 | - $period = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' ); |
|
88 | + $recurring = new WPInv_Item($submission->has_recurring); |
|
89 | + $period = getpaid_get_subscription_period_label($recurring->get_recurring_period(true), $recurring->get_recurring_interval(), ''); |
|
90 | 90 | |
91 | - if ( $submission->get_total() == $submission->get_recurring_total() ) { |
|
91 | + if ($submission->get_total() == $submission->get_recurring_total()) { |
|
92 | 92 | $payable = "$payable / $period"; |
93 | 93 | } else { |
94 | 94 | $payable = sprintf( |
95 | - __( '%1$s (renews at %2$s / %3$s)'), |
|
96 | - $submission->format_amount( $submission->get_total() ), |
|
97 | - $submission->format_amount( $submission->get_recurring_total() ), |
|
95 | + __('%1$s (renews at %2$s / %3$s)'), |
|
96 | + $submission->format_amount($submission->get_total()), |
|
97 | + $submission->format_amount($submission->get_recurring_total()), |
|
98 | 98 | $period |
99 | 99 | ); |
100 | 100 | } |
@@ -105,12 +105,12 @@ discard block |
||
105 | 105 | '.getpaid-checkout-total-payable' => $payable, |
106 | 106 | ); |
107 | 107 | |
108 | - foreach ( $submission->get_items() as $item_id => $item ) { |
|
109 | - $texts[".item-$item_id .getpaid-item-initial-price"] = $submission->format_amount( $item->get_sub_total() ); |
|
110 | - $texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() ); |
|
108 | + foreach ($submission->get_items() as $item_id => $item) { |
|
109 | + $texts[".item-$item_id .getpaid-item-initial-price"] = $submission->format_amount($item->get_sub_total()); |
|
110 | + $texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount($item->get_recurring_sub_total()); |
|
111 | 111 | } |
112 | 112 | |
113 | - $this->response = array_merge( $this->response, array( 'texts' => $texts ) ); |
|
113 | + $this->response = array_merge($this->response, array('texts' => $texts)); |
|
114 | 114 | |
115 | 115 | } |
116 | 116 | |
@@ -119,18 +119,18 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @param GetPaid_Payment_Form_Submission $submission |
121 | 121 | */ |
122 | - public function add_items( $submission ) { |
|
122 | + public function add_items($submission) { |
|
123 | 123 | |
124 | 124 | // Add items. |
125 | 125 | $items = array(); |
126 | 126 | |
127 | - foreach ( $submission->get_items() as $item_id => $item ) { |
|
128 | - $items["$item_id"] = $submission->format_amount( $item->get_sub_total() ); |
|
127 | + foreach ($submission->get_items() as $item_id => $item) { |
|
128 | + $items["$item_id"] = $submission->format_amount($item->get_sub_total()); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | $this->response = array_merge( |
132 | 132 | $this->response, |
133 | - array( 'items' => $items ) |
|
133 | + array('items' => $items) |
|
134 | 134 | ); |
135 | 135 | |
136 | 136 | } |
@@ -140,17 +140,17 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @param GetPaid_Payment_Form_Submission $submission |
142 | 142 | */ |
143 | - public function add_fees( $submission ) { |
|
143 | + public function add_fees($submission) { |
|
144 | 144 | |
145 | 145 | $fees = array(); |
146 | 146 | |
147 | - foreach ( $submission->get_fees() as $name => $data ) { |
|
148 | - $fees[$name] = $submission->format_amount( $data['initial_fee'] ); |
|
147 | + foreach ($submission->get_fees() as $name => $data) { |
|
148 | + $fees[$name] = $submission->format_amount($data['initial_fee']); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | $this->response = array_merge( |
152 | 152 | $this->response, |
153 | - array( 'fees' => $fees ) |
|
153 | + array('fees' => $fees) |
|
154 | 154 | ); |
155 | 155 | |
156 | 156 | } |
@@ -160,17 +160,17 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @param GetPaid_Payment_Form_Submission $submission |
162 | 162 | */ |
163 | - public function add_discounts( $submission ) { |
|
163 | + public function add_discounts($submission) { |
|
164 | 164 | |
165 | 165 | $discounts = array(); |
166 | 166 | |
167 | - foreach ( $submission->get_discounts() as $name => $data ) { |
|
168 | - $discounts[$name] = $submission->format_amount( $data['initial_discount'] ); |
|
167 | + foreach ($submission->get_discounts() as $name => $data) { |
|
168 | + $discounts[$name] = $submission->format_amount($data['initial_discount']); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | $this->response = array_merge( |
172 | 172 | $this->response, |
173 | - array( 'discounts' => $discounts ) |
|
173 | + array('discounts' => $discounts) |
|
174 | 174 | ); |
175 | 175 | |
176 | 176 | } |
@@ -180,24 +180,24 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @param GetPaid_Payment_Form_Submission $submission |
182 | 182 | */ |
183 | - public function add_taxes( $submission ) { |
|
183 | + public function add_taxes($submission) { |
|
184 | 184 | |
185 | 185 | $taxes = array(); |
186 | 186 | $markup = ''; |
187 | - foreach ( $submission->get_taxes() as $name => $data ) { |
|
188 | - $name = sanitize_text_field( $name ); |
|
189 | - $amount = $submission->format_amount( $data['initial_tax'] ); |
|
187 | + foreach ($submission->get_taxes() as $name => $data) { |
|
188 | + $name = sanitize_text_field($name); |
|
189 | + $amount = $submission->format_amount($data['initial_tax']); |
|
190 | 190 | $taxes[$name] = $amount; |
191 | 191 | $markup .= "<small class='form-text'>$name : $amount</small>"; |
192 | 192 | } |
193 | 193 | |
194 | - if ( wpinv_display_individual_tax_rates() ) { |
|
194 | + if (wpinv_display_individual_tax_rates()) { |
|
195 | 195 | $this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup; |
196 | 196 | } |
197 | 197 | |
198 | 198 | $this->response = array_merge( |
199 | 199 | $this->response, |
200 | - array( 'taxes' => $taxes ) |
|
200 | + array('taxes' => $taxes) |
|
201 | 201 | ); |
202 | 202 | |
203 | 203 | } |
@@ -207,16 +207,16 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @param GetPaid_Payment_Form_Submission $submission |
209 | 209 | */ |
210 | - public function add_gateways( $submission ) { |
|
210 | + public function add_gateways($submission) { |
|
211 | 211 | |
212 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
212 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
213 | 213 | |
214 | - if ( $this->response['has_recurring'] ) { |
|
214 | + if ($this->response['has_recurring']) { |
|
215 | 215 | |
216 | - foreach ( $gateways as $i => $gateway ) { |
|
216 | + foreach ($gateways as $i => $gateway) { |
|
217 | 217 | |
218 | - if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
219 | - unset( $gateways[ $i ] ); |
|
218 | + if (!wpinv_gateway_support_subscription($gateway)) { |
|
219 | + unset($gateways[$i]); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | } |
@@ -224,10 +224,10 @@ discard block |
||
224 | 224 | } |
225 | 225 | |
226 | 226 | |
227 | - $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission ); |
|
227 | + $gateways = apply_filters('getpaid_submission_gateways', $gateways, $submission); |
|
228 | 228 | $this->response = array_merge( |
229 | 229 | $this->response, |
230 | - array( 'gateways' => $gateways ) |
|
230 | + array('gateways' => $gateways) |
|
231 | 231 | ); |
232 | 232 | |
233 | 233 | } |
@@ -12,194 +12,194 @@ |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Invoice_Exporter extends GetPaid_Graph_Downloader { |
14 | 14 | |
15 | - /** |
|
16 | - * Retrieves invoices query args. |
|
17 | - * |
|
18 | - * @param string $post_type post type to retrieve. |
|
19 | - * @param array $args Args to search for. |
|
20 | - * @return array |
|
21 | - */ |
|
22 | - public function get_invoice_query_args( $post_type, $args ) { |
|
23 | - |
|
24 | - $query_args = array( |
|
25 | - 'post_type' => $post_type, |
|
26 | - 'post_status' => array_keys( wpinv_get_invoice_statuses( true, false, $post_type ) ), |
|
27 | - 'posts_per_page' => -1, |
|
28 | - 'no_found_rows' => true, |
|
29 | - 'update_post_term_cache' => false, |
|
30 | - 'fields' => 'ids', |
|
31 | - ); |
|
32 | - |
|
33 | - if ( ! empty( $args['status'] ) && in_array( $args['status'], $query_args['post_status'], true ) ) { |
|
34 | - $query_args['post_status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) ); |
|
35 | - } |
|
36 | - |
|
37 | - $date_query = array(); |
|
38 | - if ( ! empty( $args['to_date'] ) ) { |
|
39 | - $date_query['before'] = wpinv_clean( $args['to_date'] ); |
|
40 | - } |
|
41 | - |
|
42 | - if ( ! empty( $args['from_date'] ) ) { |
|
43 | - $date_query['after'] = wpinv_clean( $args['from_date'] ); |
|
44 | - } |
|
45 | - |
|
46 | - if ( ! empty( $date_query ) ) { |
|
47 | - $date_query['inclusive'] = true; |
|
48 | - $query_args['date_query'] = array( $date_query ); |
|
49 | - } |
|
50 | - |
|
51 | - return $query_args; |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Retrieves invoices. |
|
56 | - * |
|
57 | - * @param array $query_args WP_Query args. |
|
58 | - * @return WPInv_Invoice[] |
|
59 | - */ |
|
60 | - public function get_invoices( $query_args ) { |
|
61 | - |
|
62 | - // Get invoices. |
|
63 | - $invoices = new WP_Query( $query_args ); |
|
64 | - |
|
65 | - // Prepare the results. |
|
66 | - return array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
67 | - |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Handles the actual download. |
|
72 | - * |
|
73 | - */ |
|
74 | - public function export( $post_type, $args ) { |
|
75 | - |
|
76 | - $invoices = $this->get_invoices( $this->get_invoice_query_args( $post_type, $args ) ); |
|
77 | - $stream = $this->prepare_output(); |
|
78 | - $headers = $this->get_export_fields( $post_type ); |
|
79 | - $file_type = $this->prepare_file_type( strtolower( getpaid_get_post_type_label( $post_type ) ) ); |
|
80 | - |
|
81 | - if ( 'csv' == $file_type ) { |
|
82 | - $this->download_csv( $invoices, $stream, $headers ); |
|
83 | - } else if( 'xml' == $file_type ) { |
|
84 | - $this->download_xml( $invoices, $stream, $headers ); |
|
85 | - } else { |
|
86 | - $this->download_json( $invoices, $stream, $headers ); |
|
87 | - } |
|
88 | - |
|
89 | - fclose( $stream ); |
|
90 | - exit; |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Prepares a single invoice for download. |
|
95 | - * |
|
96 | - * @param WPInv_Invoice $invoice The invoice to prepare.. |
|
97 | - * @param array $fields The fields to stream. |
|
98 | - * @since 1.0.19 |
|
99 | - * @return array |
|
100 | - */ |
|
101 | - public function prepare_row( $invoice, $fields ) { |
|
102 | - |
|
103 | - $prepared = array(); |
|
104 | - $amount_fields = $this->get_amount_fields( $invoice->get_post_type() ); |
|
105 | - |
|
106 | - foreach ( $fields as $field ) { |
|
107 | - |
|
108 | - $value = ''; |
|
109 | - $method = "get_$field"; |
|
110 | - |
|
111 | - if ( method_exists( $invoice, $method ) ) { |
|
112 | - $value = $invoice->$method(); |
|
113 | - } |
|
114 | - |
|
115 | - if ( in_array( $field, $amount_fields ) ) { |
|
116 | - $value = wpinv_round_amount( wpinv_sanitize_amount( $value ) ); |
|
117 | - } |
|
118 | - |
|
119 | - $prepared[ $field ] = wpinv_clean( $value ); |
|
120 | - |
|
121 | - } |
|
122 | - |
|
123 | - return $prepared; |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Retrieves export fields. |
|
128 | - * |
|
129 | - * @param string $post_type |
|
130 | - * @since 1.0.19 |
|
131 | - * @return array |
|
132 | - */ |
|
133 | - public function get_export_fields( $post_type ) { |
|
134 | - |
|
135 | - $fields = array( |
|
136 | - 'id', |
|
137 | - 'parent_id', |
|
138 | - 'status', |
|
139 | - 'date_created', |
|
140 | - 'date_modified', |
|
141 | - 'date_due', |
|
142 | - 'date_completed', |
|
143 | - 'number', |
|
144 | - 'key', |
|
145 | - 'description', |
|
146 | - 'post_type', |
|
147 | - 'mode', |
|
148 | - 'customer_id', |
|
149 | - 'customer_first_name', |
|
150 | - 'customer_last_name', |
|
151 | - 'customer_phone', |
|
152 | - 'customer_email', |
|
153 | - 'customer_country', |
|
154 | - 'customer_city', |
|
155 | - 'customer_state', |
|
156 | - 'customer_zip', |
|
157 | - 'customer_company', |
|
158 | - 'customer_vat_number', |
|
159 | - 'customer_address', |
|
160 | - 'subtotal', |
|
161 | - 'total_discount', |
|
162 | - 'total_tax', |
|
163 | - 'total_fees', |
|
164 | - 'fees', |
|
165 | - 'discounts', |
|
166 | - 'taxes', |
|
167 | - 'cart_details', |
|
168 | - 'item_ids', |
|
169 | - 'payment_form', |
|
170 | - 'discount_code', |
|
171 | - 'gateway', |
|
172 | - 'transaction_id', |
|
173 | - 'currency', |
|
174 | - 'disable_taxes', |
|
175 | - 'subscription_id', |
|
176 | - 'remote_subscription_id', |
|
177 | - 'is_viewed', |
|
178 | - 'email_cc', |
|
179 | - 'template', |
|
180 | - 'created_via' |
|
181 | - ); |
|
182 | - |
|
183 | - return apply_filters( 'getpaid_invoice_exporter_get_fields', $fields, $post_type ); |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * Retrieves amount fields. |
|
188 | - * |
|
189 | - * @param string $post_type |
|
190 | - * @since 1.0.19 |
|
191 | - * @return array |
|
192 | - */ |
|
193 | - public function get_amount_fields( $post_type ) { |
|
194 | - |
|
195 | - $fields = array( |
|
196 | - 'subtotal', |
|
197 | - 'total_discount', |
|
198 | - 'total_tax', |
|
199 | - 'total_fees' |
|
200 | - ); |
|
201 | - |
|
202 | - return apply_filters( 'getpaid_invoice_exporter_get_amount_fields', $fields, $post_type ); |
|
203 | - } |
|
15 | + /** |
|
16 | + * Retrieves invoices query args. |
|
17 | + * |
|
18 | + * @param string $post_type post type to retrieve. |
|
19 | + * @param array $args Args to search for. |
|
20 | + * @return array |
|
21 | + */ |
|
22 | + public function get_invoice_query_args( $post_type, $args ) { |
|
23 | + |
|
24 | + $query_args = array( |
|
25 | + 'post_type' => $post_type, |
|
26 | + 'post_status' => array_keys( wpinv_get_invoice_statuses( true, false, $post_type ) ), |
|
27 | + 'posts_per_page' => -1, |
|
28 | + 'no_found_rows' => true, |
|
29 | + 'update_post_term_cache' => false, |
|
30 | + 'fields' => 'ids', |
|
31 | + ); |
|
32 | + |
|
33 | + if ( ! empty( $args['status'] ) && in_array( $args['status'], $query_args['post_status'], true ) ) { |
|
34 | + $query_args['post_status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) ); |
|
35 | + } |
|
36 | + |
|
37 | + $date_query = array(); |
|
38 | + if ( ! empty( $args['to_date'] ) ) { |
|
39 | + $date_query['before'] = wpinv_clean( $args['to_date'] ); |
|
40 | + } |
|
41 | + |
|
42 | + if ( ! empty( $args['from_date'] ) ) { |
|
43 | + $date_query['after'] = wpinv_clean( $args['from_date'] ); |
|
44 | + } |
|
45 | + |
|
46 | + if ( ! empty( $date_query ) ) { |
|
47 | + $date_query['inclusive'] = true; |
|
48 | + $query_args['date_query'] = array( $date_query ); |
|
49 | + } |
|
50 | + |
|
51 | + return $query_args; |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Retrieves invoices. |
|
56 | + * |
|
57 | + * @param array $query_args WP_Query args. |
|
58 | + * @return WPInv_Invoice[] |
|
59 | + */ |
|
60 | + public function get_invoices( $query_args ) { |
|
61 | + |
|
62 | + // Get invoices. |
|
63 | + $invoices = new WP_Query( $query_args ); |
|
64 | + |
|
65 | + // Prepare the results. |
|
66 | + return array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
67 | + |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Handles the actual download. |
|
72 | + * |
|
73 | + */ |
|
74 | + public function export( $post_type, $args ) { |
|
75 | + |
|
76 | + $invoices = $this->get_invoices( $this->get_invoice_query_args( $post_type, $args ) ); |
|
77 | + $stream = $this->prepare_output(); |
|
78 | + $headers = $this->get_export_fields( $post_type ); |
|
79 | + $file_type = $this->prepare_file_type( strtolower( getpaid_get_post_type_label( $post_type ) ) ); |
|
80 | + |
|
81 | + if ( 'csv' == $file_type ) { |
|
82 | + $this->download_csv( $invoices, $stream, $headers ); |
|
83 | + } else if( 'xml' == $file_type ) { |
|
84 | + $this->download_xml( $invoices, $stream, $headers ); |
|
85 | + } else { |
|
86 | + $this->download_json( $invoices, $stream, $headers ); |
|
87 | + } |
|
88 | + |
|
89 | + fclose( $stream ); |
|
90 | + exit; |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * Prepares a single invoice for download. |
|
95 | + * |
|
96 | + * @param WPInv_Invoice $invoice The invoice to prepare.. |
|
97 | + * @param array $fields The fields to stream. |
|
98 | + * @since 1.0.19 |
|
99 | + * @return array |
|
100 | + */ |
|
101 | + public function prepare_row( $invoice, $fields ) { |
|
102 | + |
|
103 | + $prepared = array(); |
|
104 | + $amount_fields = $this->get_amount_fields( $invoice->get_post_type() ); |
|
105 | + |
|
106 | + foreach ( $fields as $field ) { |
|
107 | + |
|
108 | + $value = ''; |
|
109 | + $method = "get_$field"; |
|
110 | + |
|
111 | + if ( method_exists( $invoice, $method ) ) { |
|
112 | + $value = $invoice->$method(); |
|
113 | + } |
|
114 | + |
|
115 | + if ( in_array( $field, $amount_fields ) ) { |
|
116 | + $value = wpinv_round_amount( wpinv_sanitize_amount( $value ) ); |
|
117 | + } |
|
118 | + |
|
119 | + $prepared[ $field ] = wpinv_clean( $value ); |
|
120 | + |
|
121 | + } |
|
122 | + |
|
123 | + return $prepared; |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * Retrieves export fields. |
|
128 | + * |
|
129 | + * @param string $post_type |
|
130 | + * @since 1.0.19 |
|
131 | + * @return array |
|
132 | + */ |
|
133 | + public function get_export_fields( $post_type ) { |
|
134 | + |
|
135 | + $fields = array( |
|
136 | + 'id', |
|
137 | + 'parent_id', |
|
138 | + 'status', |
|
139 | + 'date_created', |
|
140 | + 'date_modified', |
|
141 | + 'date_due', |
|
142 | + 'date_completed', |
|
143 | + 'number', |
|
144 | + 'key', |
|
145 | + 'description', |
|
146 | + 'post_type', |
|
147 | + 'mode', |
|
148 | + 'customer_id', |
|
149 | + 'customer_first_name', |
|
150 | + 'customer_last_name', |
|
151 | + 'customer_phone', |
|
152 | + 'customer_email', |
|
153 | + 'customer_country', |
|
154 | + 'customer_city', |
|
155 | + 'customer_state', |
|
156 | + 'customer_zip', |
|
157 | + 'customer_company', |
|
158 | + 'customer_vat_number', |
|
159 | + 'customer_address', |
|
160 | + 'subtotal', |
|
161 | + 'total_discount', |
|
162 | + 'total_tax', |
|
163 | + 'total_fees', |
|
164 | + 'fees', |
|
165 | + 'discounts', |
|
166 | + 'taxes', |
|
167 | + 'cart_details', |
|
168 | + 'item_ids', |
|
169 | + 'payment_form', |
|
170 | + 'discount_code', |
|
171 | + 'gateway', |
|
172 | + 'transaction_id', |
|
173 | + 'currency', |
|
174 | + 'disable_taxes', |
|
175 | + 'subscription_id', |
|
176 | + 'remote_subscription_id', |
|
177 | + 'is_viewed', |
|
178 | + 'email_cc', |
|
179 | + 'template', |
|
180 | + 'created_via' |
|
181 | + ); |
|
182 | + |
|
183 | + return apply_filters( 'getpaid_invoice_exporter_get_fields', $fields, $post_type ); |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * Retrieves amount fields. |
|
188 | + * |
|
189 | + * @param string $post_type |
|
190 | + * @since 1.0.19 |
|
191 | + * @return array |
|
192 | + */ |
|
193 | + public function get_amount_fields( $post_type ) { |
|
194 | + |
|
195 | + $fields = array( |
|
196 | + 'subtotal', |
|
197 | + 'total_discount', |
|
198 | + 'total_tax', |
|
199 | + 'total_fees' |
|
200 | + ); |
|
201 | + |
|
202 | + return apply_filters( 'getpaid_invoice_exporter_get_amount_fields', $fields, $post_type ); |
|
203 | + } |
|
204 | 204 | |
205 | 205 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * GetPaid_Invoice_Exporter Class. |
@@ -19,33 +19,33 @@ discard block |
||
19 | 19 | * @param array $args Args to search for. |
20 | 20 | * @return array |
21 | 21 | */ |
22 | - public function get_invoice_query_args( $post_type, $args ) { |
|
22 | + public function get_invoice_query_args($post_type, $args) { |
|
23 | 23 | |
24 | 24 | $query_args = array( |
25 | 25 | 'post_type' => $post_type, |
26 | - 'post_status' => array_keys( wpinv_get_invoice_statuses( true, false, $post_type ) ), |
|
26 | + 'post_status' => array_keys(wpinv_get_invoice_statuses(true, false, $post_type)), |
|
27 | 27 | 'posts_per_page' => -1, |
28 | 28 | 'no_found_rows' => true, |
29 | 29 | 'update_post_term_cache' => false, |
30 | 30 | 'fields' => 'ids', |
31 | 31 | ); |
32 | 32 | |
33 | - if ( ! empty( $args['status'] ) && in_array( $args['status'], $query_args['post_status'], true ) ) { |
|
34 | - $query_args['post_status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) ); |
|
33 | + if (!empty($args['status']) && in_array($args['status'], $query_args['post_status'], true)) { |
|
34 | + $query_args['post_status'] = wpinv_clean(wpinv_parse_list($args['status'])); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | $date_query = array(); |
38 | - if ( ! empty( $args['to_date'] ) ) { |
|
39 | - $date_query['before'] = wpinv_clean( $args['to_date'] ); |
|
38 | + if (!empty($args['to_date'])) { |
|
39 | + $date_query['before'] = wpinv_clean($args['to_date']); |
|
40 | 40 | } |
41 | 41 | |
42 | - if ( ! empty( $args['from_date'] ) ) { |
|
43 | - $date_query['after'] = wpinv_clean( $args['from_date'] ); |
|
42 | + if (!empty($args['from_date'])) { |
|
43 | + $date_query['after'] = wpinv_clean($args['from_date']); |
|
44 | 44 | } |
45 | 45 | |
46 | - if ( ! empty( $date_query ) ) { |
|
46 | + if (!empty($date_query)) { |
|
47 | 47 | $date_query['inclusive'] = true; |
48 | - $query_args['date_query'] = array( $date_query ); |
|
48 | + $query_args['date_query'] = array($date_query); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | return $query_args; |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | * @param array $query_args WP_Query args. |
58 | 58 | * @return WPInv_Invoice[] |
59 | 59 | */ |
60 | - public function get_invoices( $query_args ) { |
|
60 | + public function get_invoices($query_args) { |
|
61 | 61 | |
62 | 62 | // Get invoices. |
63 | - $invoices = new WP_Query( $query_args ); |
|
63 | + $invoices = new WP_Query($query_args); |
|
64 | 64 | |
65 | 65 | // Prepare the results. |
66 | - return array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
66 | + return array_map('wpinv_get_invoice', $invoices->posts); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | |
@@ -71,22 +71,22 @@ discard block |
||
71 | 71 | * Handles the actual download. |
72 | 72 | * |
73 | 73 | */ |
74 | - public function export( $post_type, $args ) { |
|
74 | + public function export($post_type, $args) { |
|
75 | 75 | |
76 | - $invoices = $this->get_invoices( $this->get_invoice_query_args( $post_type, $args ) ); |
|
76 | + $invoices = $this->get_invoices($this->get_invoice_query_args($post_type, $args)); |
|
77 | 77 | $stream = $this->prepare_output(); |
78 | - $headers = $this->get_export_fields( $post_type ); |
|
79 | - $file_type = $this->prepare_file_type( strtolower( getpaid_get_post_type_label( $post_type ) ) ); |
|
78 | + $headers = $this->get_export_fields($post_type); |
|
79 | + $file_type = $this->prepare_file_type(strtolower(getpaid_get_post_type_label($post_type))); |
|
80 | 80 | |
81 | - if ( 'csv' == $file_type ) { |
|
82 | - $this->download_csv( $invoices, $stream, $headers ); |
|
83 | - } else if( 'xml' == $file_type ) { |
|
84 | - $this->download_xml( $invoices, $stream, $headers ); |
|
81 | + if ('csv' == $file_type) { |
|
82 | + $this->download_csv($invoices, $stream, $headers); |
|
83 | + } else if ('xml' == $file_type) { |
|
84 | + $this->download_xml($invoices, $stream, $headers); |
|
85 | 85 | } else { |
86 | - $this->download_json( $invoices, $stream, $headers ); |
|
86 | + $this->download_json($invoices, $stream, $headers); |
|
87 | 87 | } |
88 | 88 | |
89 | - fclose( $stream ); |
|
89 | + fclose($stream); |
|
90 | 90 | exit; |
91 | 91 | } |
92 | 92 | |
@@ -98,25 +98,25 @@ discard block |
||
98 | 98 | * @since 1.0.19 |
99 | 99 | * @return array |
100 | 100 | */ |
101 | - public function prepare_row( $invoice, $fields ) { |
|
101 | + public function prepare_row($invoice, $fields) { |
|
102 | 102 | |
103 | 103 | $prepared = array(); |
104 | - $amount_fields = $this->get_amount_fields( $invoice->get_post_type() ); |
|
104 | + $amount_fields = $this->get_amount_fields($invoice->get_post_type()); |
|
105 | 105 | |
106 | - foreach ( $fields as $field ) { |
|
106 | + foreach ($fields as $field) { |
|
107 | 107 | |
108 | 108 | $value = ''; |
109 | 109 | $method = "get_$field"; |
110 | 110 | |
111 | - if ( method_exists( $invoice, $method ) ) { |
|
112 | - $value = $invoice->$method(); |
|
111 | + if (method_exists($invoice, $method)) { |
|
112 | + $value = $invoice->$method(); |
|
113 | 113 | } |
114 | 114 | |
115 | - if ( in_array( $field, $amount_fields ) ) { |
|
116 | - $value = wpinv_round_amount( wpinv_sanitize_amount( $value ) ); |
|
115 | + if (in_array($field, $amount_fields)) { |
|
116 | + $value = wpinv_round_amount(wpinv_sanitize_amount($value)); |
|
117 | 117 | } |
118 | 118 | |
119 | - $prepared[ $field ] = wpinv_clean( $value ); |
|
119 | + $prepared[$field] = wpinv_clean($value); |
|
120 | 120 | |
121 | 121 | } |
122 | 122 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @since 1.0.19 |
131 | 131 | * @return array |
132 | 132 | */ |
133 | - public function get_export_fields( $post_type ) { |
|
133 | + public function get_export_fields($post_type) { |
|
134 | 134 | |
135 | 135 | $fields = array( |
136 | 136 | 'id', |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | 'created_via' |
181 | 181 | ); |
182 | 182 | |
183 | - return apply_filters( 'getpaid_invoice_exporter_get_fields', $fields, $post_type ); |
|
183 | + return apply_filters('getpaid_invoice_exporter_get_fields', $fields, $post_type); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @since 1.0.19 |
191 | 191 | * @return array |
192 | 192 | */ |
193 | - public function get_amount_fields( $post_type ) { |
|
193 | + public function get_amount_fields($post_type) { |
|
194 | 194 | |
195 | 195 | $fields = array( |
196 | 196 | 'subtotal', |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | 'total_fees' |
200 | 200 | ); |
201 | 201 | |
202 | - return apply_filters( 'getpaid_invoice_exporter_get_amount_fields', $fields, $post_type ); |
|
202 | + return apply_filters('getpaid_invoice_exporter_get_amount_fields', $fields, $post_type); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | $tax_rates = GetPaid_Tax::get_all_tax_rates(); |
10 | 10 | $dummy_rate = array( |
@@ -13,12 +13,12 @@ discard block |
||
13 | 13 | 'global' => true, |
14 | 14 | 'rate' => wpinv_get_default_tax_rate(), |
15 | 15 | 'reduced_rate' => 5, |
16 | - 'name' => __( 'VAT', 'invoicing' ), |
|
16 | + 'name' => __('VAT', 'invoicing'), |
|
17 | 17 | ); |
18 | 18 | |
19 | 19 | $reset_url = esc_url( |
20 | 20 | wp_nonce_url( |
21 | - add_query_arg( 'getpaid-admin-action', 'reset_tax_rates' ), |
|
21 | + add_query_arg('getpaid-admin-action', 'reset_tax_rates'), |
|
22 | 22 | 'getpaid-nonce', |
23 | 23 | 'getpaid-nonce' |
24 | 24 | ) |
@@ -27,34 +27,34 @@ discard block |
||
27 | 27 | ?> |
28 | 28 | <div class="table-responsive"> |
29 | 29 | <table id="wpinv_tax_rates" class="widefat fixed table"> |
30 | - <caption><?php echo esc_html_e( 'Enter tax rates for specific regions.', 'invoicing' ); ?></caption> |
|
30 | + <caption><?php echo esc_html_e('Enter tax rates for specific regions.', 'invoicing'); ?></caption> |
|
31 | 31 | |
32 | 32 | <thead> |
33 | 33 | <tr class="table-light"> |
34 | 34 | |
35 | 35 | <th scope="col" class="border-bottom border-top"> |
36 | - <?php _e( 'Country', 'invoicing' ); ?> |
|
37 | - <?php echo getpaid_get_help_tip( __( 'Optionally limit this tax rate to a specific country.', 'invoicing' ), 'position-static' ); ?> |
|
36 | + <?php _e('Country', 'invoicing'); ?> |
|
37 | + <?php echo getpaid_get_help_tip(__('Optionally limit this tax rate to a specific country.', 'invoicing'), 'position-static'); ?> |
|
38 | 38 | </th> |
39 | 39 | |
40 | 40 | <th scope="col" class="border-bottom border-top"> |
41 | - <?php _e( 'State', 'invoicing' ); ?> |
|
42 | - <?php echo getpaid_get_help_tip( __( 'Separate state codes using a comma or leave blank to apply country wide.', 'invoicing' ), 'position-static' ); ?> |
|
41 | + <?php _e('State', 'invoicing'); ?> |
|
42 | + <?php echo getpaid_get_help_tip(__('Separate state codes using a comma or leave blank to apply country wide.', 'invoicing'), 'position-static'); ?> |
|
43 | 43 | </th> |
44 | 44 | |
45 | 45 | <th scope="col" class="border-bottom border-top"> |
46 | - <?php _e( 'Standard Rate %', 'invoicing' ); ?> |
|
47 | - <?php echo getpaid_get_help_tip( __( 'The tax rate (percentage) to charge on items that use the "Standard rate" tax class.', 'invoicing' ), 'position-static' ); ?> |
|
46 | + <?php _e('Standard Rate %', 'invoicing'); ?> |
|
47 | + <?php echo getpaid_get_help_tip(__('The tax rate (percentage) to charge on items that use the "Standard rate" tax class.', 'invoicing'), 'position-static'); ?> |
|
48 | 48 | </th> |
49 | 49 | |
50 | 50 | <th scope="col" class="border-bottom border-top"> |
51 | - <?php _e( 'Reduced Rate %', 'invoicing' ); ?> |
|
52 | - <?php echo getpaid_get_help_tip( __( 'The tax rate (percentage) to charge on items that use the "Reduced rate" tax class.', 'invoicing' ), 'position-static' ); ?> |
|
51 | + <?php _e('Reduced Rate %', 'invoicing'); ?> |
|
52 | + <?php echo getpaid_get_help_tip(__('The tax rate (percentage) to charge on items that use the "Reduced rate" tax class.', 'invoicing'), 'position-static'); ?> |
|
53 | 53 | </th> |
54 | 54 | |
55 | 55 | <th scope="col" class="border-bottom border-top"> |
56 | - <?php _e( 'Tax Name', 'invoicing' ); ?> |
|
57 | - <?php echo getpaid_get_help_tip( __( 'The name of this tax, e.g VAT.', 'invoicing' ), 'position-static' ); ?> |
|
56 | + <?php _e('Tax Name', 'invoicing'); ?> |
|
57 | + <?php echo getpaid_get_help_tip(__('The name of this tax, e.g VAT.', 'invoicing'), 'position-static'); ?> |
|
58 | 58 | </th> |
59 | 59 | |
60 | 60 | <th scope="col" class="border-bottom border-top" style="width:32px"> </th> |
@@ -63,19 +63,19 @@ discard block |
||
63 | 63 | </thead> |
64 | 64 | |
65 | 65 | <tbody> |
66 | - <?php array_walk( $tax_rates, 'wpinv_tax_rate_callback' ); ?> |
|
66 | + <?php array_walk($tax_rates, 'wpinv_tax_rate_callback'); ?> |
|
67 | 67 | </tbody> |
68 | 68 | |
69 | 69 | <tfoot> |
70 | 70 | <tr class="table-light"> |
71 | 71 | <td colspan="6" class="border-top"> |
72 | 72 | |
73 | - <button type="button" class="button button-secondary wpinv_add_tax_rate" aria-label="<?php esc_attr_e( 'Add Tax Rate', 'invoicing' ); ?>"> |
|
74 | - <span><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span> |
|
73 | + <button type="button" class="button button-secondary wpinv_add_tax_rate" aria-label="<?php esc_attr_e('Add Tax Rate', 'invoicing'); ?>"> |
|
74 | + <span><?php _e('Add Tax Rate', 'invoicing'); ?></span> |
|
75 | 75 | </button> |
76 | 76 | |
77 | - <a href="<?php echo $reset_url; ?>" class="button button-secondary wpinv_reset_tax_rates" aria-label="<?php esc_attr_e( 'Reset Tax Rates', 'invoicing' ); ?>"> |
|
78 | - <span><?php _e( 'Reset Tax Rates', 'invoicing' ); ?></span> |
|
77 | + <a href="<?php echo $reset_url; ?>" class="button button-secondary wpinv_reset_tax_rates" aria-label="<?php esc_attr_e('Reset Tax Rates', 'invoicing'); ?>"> |
|
78 | + <span><?php _e('Reset Tax Rates', 'invoicing'); ?></span> |
|
79 | 79 | </a> |
80 | 80 | </td> |
81 | 81 | </tr> |
@@ -84,6 +84,6 @@ discard block |
||
84 | 84 | </div> |
85 | 85 | |
86 | 86 | <script type="text/html" id="tmpl-wpinv-tax-rate-row"> |
87 | - <?php echo wpinv_tax_rate_callback( $dummy_rate, 0, false ); ?> |
|
87 | + <?php echo wpinv_tax_rate_callback($dummy_rate, 0, false); ?> |
|
88 | 88 | </script> |
89 | 89 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @var array $tax_rate |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | ?> |
12 | 12 | |
@@ -18,54 +18,54 @@ discard block |
||
18 | 18 | $country = aui()->select( |
19 | 19 | array( |
20 | 20 | 'options' => array_merge( |
21 | - array( '' => __( 'All Countries', 'invoicing' ) ), |
|
21 | + array('' => __('All Countries', 'invoicing')), |
|
22 | 22 | wpinv_get_country_list() |
23 | 23 | ), |
24 | 24 | 'name' => "tax_rates[$key][country]", |
25 | - 'id' => uniqid( 'tax_rate_country' ), |
|
26 | - 'value' => sanitize_text_field( $tax_rate['country'] ), |
|
27 | - 'label' => __( 'Country', 'invoicing' ), |
|
25 | + 'id' => uniqid('tax_rate_country'), |
|
26 | + 'value' => sanitize_text_field($tax_rate['country']), |
|
27 | + 'label' => __('Country', 'invoicing'), |
|
28 | 28 | 'class' => 'wpinv_country', |
29 | 29 | 'no_wrap' => true, |
30 | 30 | ) |
31 | 31 | ); |
32 | 32 | |
33 | - echo str_replace( 'custom-select', '', $country ); |
|
33 | + echo str_replace('custom-select', '', $country); |
|
34 | 34 | ?> |
35 | 35 | </td> |
36 | 36 | |
37 | 37 | <td class="wpinv_tax_state"> |
38 | 38 | |
39 | 39 | <label class="w-100"> |
40 | - <span class="screen-reader-text"><?php _e( 'States', 'invoicing' ); ?></span> |
|
41 | - <input type="text" placeholder="<?php esc_attr_e( 'Apply to whole country', 'invoicing' ); ?>" name="tax_rates[<?php echo $key ?>][state]" value="<?php echo empty( $tax_rate['global'] ) ? sanitize_text_field( $tax_rate['state'] ) : ''; ?>"/> |
|
40 | + <span class="screen-reader-text"><?php _e('States', 'invoicing'); ?></span> |
|
41 | + <input type="text" placeholder="<?php esc_attr_e('Apply to whole country', 'invoicing'); ?>" name="tax_rates[<?php echo $key ?>][state]" value="<?php echo empty($tax_rate['global']) ? sanitize_text_field($tax_rate['state']) : ''; ?>"/> |
|
42 | 42 | </label> |
43 | 43 | |
44 | 44 | </td> |
45 | 45 | |
46 | 46 | <td class="wpinv_standard_rate"> |
47 | 47 | <label class="w-100"> |
48 | - <span class="screen-reader-text"><?php _e( 'Standard Rate', 'invoicing' ); ?></span> |
|
49 | - <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo $key ?>][rate]" value="<?php echo wpinv_sanitize_amount( $tax_rate['rate'] ); ?>"/> |
|
48 | + <span class="screen-reader-text"><?php _e('Standard Rate', 'invoicing'); ?></span> |
|
49 | + <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo $key ?>][rate]" value="<?php echo wpinv_sanitize_amount($tax_rate['rate']); ?>"/> |
|
50 | 50 | </label> |
51 | 51 | </td> |
52 | 52 | |
53 | 53 | <td class="wpinv_reduced_rate"> |
54 | 54 | <label class="w-100"> |
55 | - <span class="screen-reader-text"><?php _e( 'Reduced Rate', 'invoicing' ); ?></span> |
|
56 | - <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo $key ?>][reduced_rate]" value="<?php echo wpinv_sanitize_amount( $tax_rate['reduced_rate'] ); ?>"/> |
|
55 | + <span class="screen-reader-text"><?php _e('Reduced Rate', 'invoicing'); ?></span> |
|
56 | + <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo $key ?>][reduced_rate]" value="<?php echo wpinv_sanitize_amount($tax_rate['reduced_rate']); ?>"/> |
|
57 | 57 | </label> |
58 | 58 | </td> |
59 | 59 | |
60 | 60 | <td class="wpinv_tax_name"> |
61 | 61 | <label class="w-100"> |
62 | - <span class="screen-reader-text"><?php _e( 'Tax Name', 'invoicing' ); ?></span> |
|
63 | - <input type="text" name="tax_rates[<?php echo $key ?>][name]" value="<?php echo sanitize_text_field( $tax_rate['name'] ); ?>"/> |
|
62 | + <span class="screen-reader-text"><?php _e('Tax Name', 'invoicing'); ?></span> |
|
63 | + <input type="text" name="tax_rates[<?php echo $key ?>][name]" value="<?php echo sanitize_text_field($tax_rate['name']); ?>"/> |
|
64 | 64 | </label> |
65 | 65 | </td> |
66 | 66 | |
67 | 67 | <td class="wpinv_tax_remove"> |
68 | - <button type="button" class="close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>" title="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>"> |
|
68 | + <button type="button" class="close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e('Delete', 'invoicing'); ?>" title="<?php esc_attr_e('Delete', 'invoicing'); ?>"> |
|
69 | 69 | <span aria-hidden="true">×</span> |
70 | 70 | </button> |
71 | 71 | </td> |
@@ -611,10 +611,11 @@ |
||
611 | 611 | foreach ( $args['options'] as $key => $option ) : |
612 | 612 | $sanitize_key = wpinv_sanitize_key( $key ); |
613 | 613 | |
614 | - if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
|
615 | - $enabled = '1'; |
|
616 | - else |
|
617 | - $enabled = null; |
|
614 | + if ( isset( $wpinv_options['gateways'][ $key ] ) ) { |
|
615 | + $enabled = '1'; |
|
616 | + } else { |
|
617 | + $enabled = null; |
|
618 | + } |
|
618 | 619 | |
619 | 620 | echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
620 | 621 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
@@ -196,11 +196,11 @@ discard block |
||
196 | 196 | $cb = "wpinv_{$option['type']}_callback"; |
197 | 197 | $section = "wpinv_settings_{$tab}_$section"; |
198 | 198 | |
199 | - if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) { |
|
200 | - $tip = wpinv_clean( $option['desc'] ); |
|
201 | - $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
|
202 | - unset( $option['desc'] ); |
|
203 | - } |
|
199 | + if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) { |
|
200 | + $tip = wpinv_clean( $option['desc'] ); |
|
201 | + $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
|
202 | + unset( $option['desc'] ); |
|
203 | + } |
|
204 | 204 | |
205 | 205 | // Loop through all tabs. |
206 | 206 | add_settings_field( |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
228 | 228 | 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
229 | 229 | 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
230 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
231 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
230 | + 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
231 | + 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
232 | 232 | 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
233 | 233 | 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
234 | 234 | ) |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @return array |
243 | 243 | */ |
244 | 244 | function wpinv_get_registered_settings() { |
245 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
245 | + return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | } |
290 | 290 | |
291 | 291 | // General filter |
292 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
292 | + $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
293 | 293 | |
294 | - // Key specific filter. |
|
295 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
294 | + // Key specific filter. |
|
295 | + $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | // Loop through the whitelist and unset any that are empty for the tab being saved |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | |
349 | 349 | foreach ( $new_rates as $rate ) { |
350 | 350 | |
351 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
352 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
353 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
354 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
355 | - $rate['global'] = empty( $rate['state'] ); |
|
356 | - $tax_rates[] = $rate; |
|
351 | + $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
352 | + $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
353 | + $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
354 | + $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
355 | + $rate['global'] = empty( $rate['state'] ); |
|
356 | + $tax_rates[] = $rate; |
|
357 | 357 | |
358 | - } |
|
358 | + } |
|
359 | 359 | |
360 | 360 | update_option( 'wpinv_tax_rates', $tax_rates ); |
361 | 361 | |
@@ -373,11 +373,11 @@ discard block |
||
373 | 373 | $tabs['general'] = __( 'General', 'invoicing' ); |
374 | 374 | $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
375 | 375 | $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
376 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
376 | + $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
377 | 377 | |
378 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
379 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
380 | - } |
|
378 | + if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
379 | + $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
380 | + } |
|
381 | 381 | |
382 | 382 | $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
383 | 383 | $tabs['misc'] = __( 'Misc', 'invoicing' ); |
@@ -417,14 +417,14 @@ discard block |
||
417 | 417 | ) ), |
418 | 418 | 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
419 | 419 | 'main' => __( 'Tax Settings', 'invoicing' ), |
420 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
421 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
420 | + 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
421 | + 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
422 | 422 | ) ), |
423 | 423 | 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
424 | 424 | 'main' => __( 'Email Settings', 'invoicing' ), |
425 | - ) ), |
|
425 | + ) ), |
|
426 | 426 | |
427 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
427 | + 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
428 | 428 | |
429 | 429 | 'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array( |
430 | 430 | 'main' => __( 'Privacy policy', 'invoicing' ), |
@@ -444,51 +444,51 @@ discard block |
||
444 | 444 | } |
445 | 445 | |
446 | 446 | function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
447 | - $pages_options = array(); |
|
447 | + $pages_options = array(); |
|
448 | 448 | |
449 | - if( $default_label !== NULL && $default_label !== false ) { |
|
450 | - $pages_options = array( '' => $default_label ); // Blank option |
|
451 | - } |
|
449 | + if( $default_label !== NULL && $default_label !== false ) { |
|
450 | + $pages_options = array( '' => $default_label ); // Blank option |
|
451 | + } |
|
452 | 452 | |
453 | - $pages = get_pages(); |
|
454 | - if ( $pages ) { |
|
455 | - foreach ( $pages as $page ) { |
|
456 | - $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
453 | + $pages = get_pages(); |
|
454 | + if ( $pages ) { |
|
455 | + foreach ( $pages as $page ) { |
|
456 | + $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
457 | 457 | $pages_options[ $page->ID ] = $title; |
458 | - } |
|
459 | - } |
|
458 | + } |
|
459 | + } |
|
460 | 460 | |
461 | - return $pages_options; |
|
461 | + return $pages_options; |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | function wpinv_header_callback( $args ) { |
465 | - if ( !empty( $args['desc'] ) ) { |
|
465 | + if ( !empty( $args['desc'] ) ) { |
|
466 | 466 | echo $args['desc']; |
467 | 467 | } |
468 | 468 | } |
469 | 469 | |
470 | 470 | function wpinv_hidden_callback( $args ) { |
471 | - global $wpinv_options; |
|
472 | - |
|
473 | - if ( isset( $args['set_value'] ) ) { |
|
474 | - $value = $args['set_value']; |
|
475 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
476 | - $value = $wpinv_options[ $args['id'] ]; |
|
477 | - } else { |
|
478 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
479 | - } |
|
480 | - |
|
481 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
482 | - $args['readonly'] = true; |
|
483 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
484 | - $name = ''; |
|
485 | - } else { |
|
486 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
487 | - } |
|
488 | - |
|
489 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
471 | + global $wpinv_options; |
|
472 | + |
|
473 | + if ( isset( $args['set_value'] ) ) { |
|
474 | + $value = $args['set_value']; |
|
475 | + } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
476 | + $value = $wpinv_options[ $args['id'] ]; |
|
477 | + } else { |
|
478 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
479 | + } |
|
480 | + |
|
481 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
482 | + $args['readonly'] = true; |
|
483 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
484 | + $name = ''; |
|
485 | + } else { |
|
486 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
487 | + } |
|
488 | + |
|
489 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
490 | 490 | |
491 | - echo $html; |
|
491 | + echo $html; |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | /** |
@@ -496,12 +496,12 @@ discard block |
||
496 | 496 | */ |
497 | 497 | function wpinv_checkbox_callback( $args ) { |
498 | 498 | |
499 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
500 | - $std = wpinv_get_option( $args['id'], $std ); |
|
501 | - $id = esc_attr( $args['id'] ); |
|
499 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
500 | + $std = wpinv_get_option( $args['id'], $std ); |
|
501 | + $id = esc_attr( $args['id'] ); |
|
502 | 502 | |
503 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
504 | - ?> |
|
503 | + getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
504 | + ?> |
|
505 | 505 | <fieldset> |
506 | 506 | <label> |
507 | 507 | <input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
@@ -513,77 +513,77 @@ discard block |
||
513 | 513 | |
514 | 514 | function wpinv_multicheck_callback( $args ) { |
515 | 515 | |
516 | - global $wpinv_options; |
|
516 | + global $wpinv_options; |
|
517 | 517 | |
518 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
519 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
518 | + $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
519 | + $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
520 | 520 | |
521 | - if ( ! empty( $args['options'] ) ) { |
|
521 | + if ( ! empty( $args['options'] ) ) { |
|
522 | 522 | |
523 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
524 | - $value = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std; |
|
523 | + $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
524 | + $value = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std; |
|
525 | 525 | |
526 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
526 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
527 | 527 | foreach( $args['options'] as $key => $option ): |
528 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
529 | - if ( in_array( $sanitize_key, $value ) ) { |
|
530 | - $enabled = $sanitize_key; |
|
531 | - } else { |
|
532 | - $enabled = NULL; |
|
533 | - } |
|
534 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
535 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
536 | - endforeach; |
|
537 | - echo '</div>'; |
|
538 | - echo '<p class="description">' . $args['desc'] . '</p>'; |
|
539 | - } |
|
528 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
529 | + if ( in_array( $sanitize_key, $value ) ) { |
|
530 | + $enabled = $sanitize_key; |
|
531 | + } else { |
|
532 | + $enabled = NULL; |
|
533 | + } |
|
534 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
535 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
536 | + endforeach; |
|
537 | + echo '</div>'; |
|
538 | + echo '<p class="description">' . $args['desc'] . '</p>'; |
|
539 | + } |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | function wpinv_payment_icons_callback( $args ) { |
543 | - global $wpinv_options; |
|
543 | + global $wpinv_options; |
|
544 | 544 | |
545 | 545 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
546 | 546 | |
547 | - if ( ! empty( $args['options'] ) ) { |
|
548 | - foreach( $args['options'] as $key => $option ) { |
|
547 | + if ( ! empty( $args['options'] ) ) { |
|
548 | + foreach( $args['options'] as $key => $option ) { |
|
549 | 549 | $sanitize_key = wpinv_sanitize_key( $key ); |
550 | 550 | |
551 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
552 | - $enabled = $option; |
|
553 | - } else { |
|
554 | - $enabled = NULL; |
|
555 | - } |
|
556 | - |
|
557 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
558 | - |
|
559 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
560 | - |
|
561 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
562 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
563 | - } else { |
|
564 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
565 | - |
|
566 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
567 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
568 | - } else { |
|
569 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
570 | - $content_dir = WP_CONTENT_DIR; |
|
571 | - |
|
572 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
573 | - // Replaces backslashes with forward slashes for Windows systems |
|
574 | - $image = wp_normalize_path( $image ); |
|
575 | - $content_dir = wp_normalize_path( $content_dir ); |
|
576 | - } |
|
577 | - |
|
578 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
579 | - } |
|
580 | - |
|
581 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
582 | - } |
|
583 | - echo $option . '</label>'; |
|
584 | - } |
|
585 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
586 | - } |
|
551 | + if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
552 | + $enabled = $option; |
|
553 | + } else { |
|
554 | + $enabled = NULL; |
|
555 | + } |
|
556 | + |
|
557 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
558 | + |
|
559 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
560 | + |
|
561 | + if ( wpinv_string_is_image_url( $key ) ) { |
|
562 | + echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
563 | + } else { |
|
564 | + $card = strtolower( str_replace( ' ', '', $option ) ); |
|
565 | + |
|
566 | + if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
567 | + $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
568 | + } else { |
|
569 | + $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
570 | + $content_dir = WP_CONTENT_DIR; |
|
571 | + |
|
572 | + if ( function_exists( 'wp_normalize_path' ) ) { |
|
573 | + // Replaces backslashes with forward slashes for Windows systems |
|
574 | + $image = wp_normalize_path( $image ); |
|
575 | + $content_dir = wp_normalize_path( $content_dir ); |
|
576 | + } |
|
577 | + |
|
578 | + $image = str_replace( $content_dir, content_url(), $image ); |
|
579 | + } |
|
580 | + |
|
581 | + echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
582 | + } |
|
583 | + echo $option . '</label>'; |
|
584 | + } |
|
585 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
586 | + } |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | /** |
@@ -591,9 +591,9 @@ discard block |
||
591 | 591 | */ |
592 | 592 | function wpinv_radio_callback( $args ) { |
593 | 593 | |
594 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
595 | - $std = wpinv_get_option( $args['id'], $std ); |
|
596 | - ?> |
|
594 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
595 | + $std = wpinv_get_option( $args['id'], $std ); |
|
596 | + ?> |
|
597 | 597 | <fieldset> |
598 | 598 | <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
599 | 599 | <?php foreach( $args['options'] as $key => $option ) : ?> |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | </ul> |
608 | 608 | </fieldset> |
609 | 609 | <?php |
610 | - getpaid_settings_description_callback( $args ); |
|
610 | + getpaid_settings_description_callback( $args ); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
@@ -615,50 +615,50 @@ discard block |
||
615 | 615 | */ |
616 | 616 | function getpaid_settings_description_callback( $args ) { |
617 | 617 | |
618 | - if ( ! empty( $args['desc'] ) ) { |
|
619 | - $description = wp_kses_post( $args['desc'] ); |
|
620 | - echo "<p class='description'>$description</p>"; |
|
621 | - } |
|
618 | + if ( ! empty( $args['desc'] ) ) { |
|
619 | + $description = wp_kses_post( $args['desc'] ); |
|
620 | + echo "<p class='description'>$description</p>"; |
|
621 | + } |
|
622 | 622 | |
623 | 623 | } |
624 | 624 | |
625 | 625 | function wpinv_gateways_callback( $args ) { |
626 | - global $wpinv_options; |
|
626 | + global $wpinv_options; |
|
627 | 627 | |
628 | 628 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
629 | 629 | |
630 | - foreach ( $args['options'] as $key => $option ) : |
|
631 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
630 | + foreach ( $args['options'] as $key => $option ) : |
|
631 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
632 | 632 | |
633 | 633 | if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
634 | - $enabled = '1'; |
|
635 | - else |
|
636 | - $enabled = null; |
|
634 | + $enabled = '1'; |
|
635 | + else |
|
636 | + $enabled = null; |
|
637 | 637 | |
638 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
639 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
640 | - endforeach; |
|
638 | + echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
639 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
640 | + endforeach; |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | function wpinv_gateway_select_callback($args) { |
644 | - global $wpinv_options; |
|
644 | + global $wpinv_options; |
|
645 | 645 | |
646 | 646 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
647 | 647 | $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
648 | 648 | |
649 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
649 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
650 | 650 | |
651 | - foreach ( $args['options'] as $key => $option ) : |
|
652 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
651 | + foreach ( $args['options'] as $key => $option ) : |
|
652 | + if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
653 | 653 | $selected = selected( $key, $args['selected'], false ); |
654 | 654 | } else { |
655 | 655 | $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
656 | 656 | } |
657 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
658 | - endforeach; |
|
657 | + echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
658 | + endforeach; |
|
659 | 659 | |
660 | - echo '</select>'; |
|
661 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
660 | + echo '</select>'; |
|
661 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | /** |
@@ -669,29 +669,29 @@ discard block |
||
669 | 669 | */ |
670 | 670 | function wpinv_settings_attrs_helper( $args ) { |
671 | 671 | |
672 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
673 | - $id = esc_attr( $args['id'] ); |
|
674 | - $placeholder = esc_attr( $args['placeholder'] ); |
|
672 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
673 | + $id = esc_attr( $args['id'] ); |
|
674 | + $placeholder = esc_attr( $args['placeholder'] ); |
|
675 | 675 | |
676 | - if ( ! empty( $args['faux'] ) ) { |
|
677 | - $args['readonly'] = true; |
|
678 | - $name = ''; |
|
679 | - } else { |
|
680 | - $value = wpinv_get_option( $args['id'], $value ); |
|
681 | - $name = "wpinv_settings[$id]"; |
|
682 | - } |
|
676 | + if ( ! empty( $args['faux'] ) ) { |
|
677 | + $args['readonly'] = true; |
|
678 | + $name = ''; |
|
679 | + } else { |
|
680 | + $value = wpinv_get_option( $args['id'], $value ); |
|
681 | + $name = "wpinv_settings[$id]"; |
|
682 | + } |
|
683 | 683 | |
684 | - $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
685 | - $class = esc_attr( $args['class'] ); |
|
686 | - $style = esc_attr( $args['style'] ); |
|
687 | - $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
684 | + $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
685 | + $class = esc_attr( $args['class'] ); |
|
686 | + $style = esc_attr( $args['style'] ); |
|
687 | + $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
688 | 688 | |
689 | - $onchange = ''; |
|
689 | + $onchange = ''; |
|
690 | 690 | if ( ! empty( $args['onchange'] ) ) { |
691 | 691 | $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
692 | - } |
|
692 | + } |
|
693 | 693 | |
694 | - return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
|
694 | + return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | /** |
@@ -699,11 +699,11 @@ discard block |
||
699 | 699 | */ |
700 | 700 | function wpinv_text_callback( $args ) { |
701 | 701 | |
702 | - $desc = wp_kses_post( $args['desc'] ); |
|
703 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
704 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
702 | + $desc = wp_kses_post( $args['desc'] ); |
|
703 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
704 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
705 | 705 | |
706 | - ?> |
|
706 | + ?> |
|
707 | 707 | <label style="width: 100%;"> |
708 | 708 | <input type="text" <?php echo $attr; ?>> |
709 | 709 | <?php echo $desc; ?> |
@@ -717,14 +717,14 @@ discard block |
||
717 | 717 | */ |
718 | 718 | function wpinv_number_callback( $args ) { |
719 | 719 | |
720 | - $desc = wp_kses_post( $args['desc'] ); |
|
721 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
722 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
723 | - $max = intval( $args['max'] ); |
|
724 | - $min = intval( $args['min'] ); |
|
725 | - $step = floatval( $args['step'] ); |
|
720 | + $desc = wp_kses_post( $args['desc'] ); |
|
721 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
722 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
723 | + $max = intval( $args['max'] ); |
|
724 | + $min = intval( $args['min'] ); |
|
725 | + $step = floatval( $args['step'] ); |
|
726 | 726 | |
727 | - ?> |
|
727 | + ?> |
|
728 | 728 | <label style="width: 100%;"> |
729 | 729 | <input type="number" step="<?php echo $step; ?>" max="<?php echo $max; ?>" min="<?php echo $min; ?>" <?php echo $attr; ?>> |
730 | 730 | <?php echo $desc; ?> |
@@ -734,48 +734,48 @@ discard block |
||
734 | 734 | } |
735 | 735 | |
736 | 736 | function wpinv_textarea_callback( $args ) { |
737 | - global $wpinv_options; |
|
737 | + global $wpinv_options; |
|
738 | 738 | |
739 | 739 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
740 | 740 | |
741 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
742 | - $value = $wpinv_options[ $args['id'] ]; |
|
743 | - } else { |
|
744 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
745 | - } |
|
741 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
742 | + $value = $wpinv_options[ $args['id'] ]; |
|
743 | + } else { |
|
744 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
745 | + } |
|
746 | 746 | |
747 | 747 | $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
748 | 748 | $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
749 | 749 | |
750 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
751 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
750 | + $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
751 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
752 | 752 | |
753 | - echo $html; |
|
753 | + echo $html; |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | function wpinv_password_callback( $args ) { |
757 | - global $wpinv_options; |
|
757 | + global $wpinv_options; |
|
758 | 758 | |
759 | 759 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
760 | 760 | |
761 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
762 | - $value = $wpinv_options[ $args['id'] ]; |
|
763 | - } else { |
|
764 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
765 | - } |
|
761 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
762 | + $value = $wpinv_options[ $args['id'] ]; |
|
763 | + } else { |
|
764 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
765 | + } |
|
766 | 766 | |
767 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
768 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
769 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
767 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
768 | + $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
769 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
770 | 770 | |
771 | - echo $html; |
|
771 | + echo $html; |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | function wpinv_missing_callback($args) { |
775 | - printf( |
|
776 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
777 | - '<strong>' . $args['id'] . '</strong>' |
|
778 | - ); |
|
775 | + printf( |
|
776 | + __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
777 | + '<strong>' . $args['id'] . '</strong>' |
|
778 | + ); |
|
779 | 779 | } |
780 | 780 | |
781 | 781 | /** |
@@ -783,13 +783,13 @@ discard block |
||
783 | 783 | */ |
784 | 784 | function wpinv_select_callback( $args ) { |
785 | 785 | |
786 | - $desc = wp_kses_post( $args['desc'] ); |
|
787 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
788 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
789 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
790 | - $value = wpinv_get_option( $args['id'], $value ); |
|
786 | + $desc = wp_kses_post( $args['desc'] ); |
|
787 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
788 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
789 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
790 | + $value = wpinv_get_option( $args['id'], $value ); |
|
791 | 791 | |
792 | - ?> |
|
792 | + ?> |
|
793 | 793 | <label style="width: 100%;"> |
794 | 794 | <select <?php echo $attr; ?>> |
795 | 795 | <?php foreach ( $args['options'] as $option => $name ) : ?> |
@@ -803,123 +803,123 @@ discard block |
||
803 | 803 | } |
804 | 804 | |
805 | 805 | function wpinv_color_select_callback( $args ) { |
806 | - global $wpinv_options; |
|
806 | + global $wpinv_options; |
|
807 | 807 | |
808 | 808 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
809 | 809 | |
810 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
811 | - $value = $wpinv_options[ $args['id'] ]; |
|
812 | - } else { |
|
813 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
814 | - } |
|
810 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
811 | + $value = $wpinv_options[ $args['id'] ]; |
|
812 | + } else { |
|
813 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
814 | + } |
|
815 | 815 | |
816 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
816 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
817 | 817 | |
818 | - foreach ( $args['options'] as $option => $color ) { |
|
819 | - $selected = selected( $option, $value, false ); |
|
820 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
821 | - } |
|
818 | + foreach ( $args['options'] as $option => $color ) { |
|
819 | + $selected = selected( $option, $value, false ); |
|
820 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
821 | + } |
|
822 | 822 | |
823 | - $html .= '</select>'; |
|
824 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
823 | + $html .= '</select>'; |
|
824 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
825 | 825 | |
826 | - echo $html; |
|
826 | + echo $html; |
|
827 | 827 | } |
828 | 828 | |
829 | 829 | function wpinv_rich_editor_callback( $args ) { |
830 | - global $wpinv_options, $wp_version; |
|
830 | + global $wpinv_options, $wp_version; |
|
831 | 831 | |
832 | 832 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
833 | 833 | |
834 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
835 | - $value = $wpinv_options[ $args['id'] ]; |
|
834 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
835 | + $value = $wpinv_options[ $args['id'] ]; |
|
836 | 836 | |
837 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
838 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
839 | - } |
|
840 | - } else { |
|
841 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
842 | - } |
|
837 | + if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
838 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
839 | + } |
|
840 | + } else { |
|
841 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
842 | + } |
|
843 | 843 | |
844 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
844 | + $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
845 | 845 | |
846 | - $html = '<div class="getpaid-settings-editor-input">'; |
|
847 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
848 | - ob_start(); |
|
849 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
850 | - $html .= ob_get_clean(); |
|
851 | - } else { |
|
852 | - $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
853 | - } |
|
846 | + $html = '<div class="getpaid-settings-editor-input">'; |
|
847 | + if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
848 | + ob_start(); |
|
849 | + wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
850 | + $html .= ob_get_clean(); |
|
851 | + } else { |
|
852 | + $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
853 | + } |
|
854 | 854 | |
855 | - $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
855 | + $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
856 | 856 | |
857 | - echo $html; |
|
857 | + echo $html; |
|
858 | 858 | } |
859 | 859 | |
860 | 860 | function wpinv_upload_callback( $args ) { |
861 | - global $wpinv_options; |
|
861 | + global $wpinv_options; |
|
862 | 862 | |
863 | 863 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
864 | 864 | |
865 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
866 | - $value = $wpinv_options[$args['id']]; |
|
867 | - } else { |
|
868 | - $value = isset($args['std']) ? $args['std'] : ''; |
|
869 | - } |
|
865 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
866 | + $value = $wpinv_options[$args['id']]; |
|
867 | + } else { |
|
868 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
869 | + } |
|
870 | 870 | |
871 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
872 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
873 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
874 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
871 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
872 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
873 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
874 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
875 | 875 | |
876 | - echo $html; |
|
876 | + echo $html; |
|
877 | 877 | } |
878 | 878 | |
879 | 879 | function wpinv_color_callback( $args ) { |
880 | - global $wpinv_options; |
|
880 | + global $wpinv_options; |
|
881 | 881 | |
882 | 882 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
883 | 883 | |
884 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
885 | - $value = $wpinv_options[ $args['id'] ]; |
|
886 | - } else { |
|
887 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
888 | - } |
|
884 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
885 | + $value = $wpinv_options[ $args['id'] ]; |
|
886 | + } else { |
|
887 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
888 | + } |
|
889 | 889 | |
890 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
890 | + $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
891 | 891 | |
892 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
893 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
892 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
893 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
894 | 894 | |
895 | - echo $html; |
|
895 | + echo $html; |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | function wpinv_country_states_callback($args) { |
899 | - global $wpinv_options; |
|
899 | + global $wpinv_options; |
|
900 | 900 | |
901 | 901 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
902 | 902 | |
903 | - if ( isset( $args['placeholder'] ) ) { |
|
904 | - $placeholder = $args['placeholder']; |
|
905 | - } else { |
|
906 | - $placeholder = ''; |
|
907 | - } |
|
903 | + if ( isset( $args['placeholder'] ) ) { |
|
904 | + $placeholder = $args['placeholder']; |
|
905 | + } else { |
|
906 | + $placeholder = ''; |
|
907 | + } |
|
908 | 908 | |
909 | - $states = wpinv_get_country_states(); |
|
909 | + $states = wpinv_get_country_states(); |
|
910 | 910 | |
911 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
912 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
911 | + $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
912 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
913 | 913 | |
914 | - foreach ( $states as $option => $name ) { |
|
915 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
916 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
917 | - } |
|
914 | + foreach ( $states as $option => $name ) { |
|
915 | + $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
916 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
917 | + } |
|
918 | 918 | |
919 | - $html .= '</select>'; |
|
920 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
919 | + $html .= '</select>'; |
|
920 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
921 | 921 | |
922 | - echo $html; |
|
922 | + echo $html; |
|
923 | 923 | } |
924 | 924 | |
925 | 925 | /** |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | */ |
928 | 928 | function wpinv_tax_rates_callback() { |
929 | 929 | |
930 | - ?> |
|
930 | + ?> |
|
931 | 931 | </td> |
932 | 932 | </tr> |
933 | 933 | <tr class="bsui"> |
@@ -942,17 +942,17 @@ discard block |
||
942 | 942 | * Displays a tax rate' edit row. |
943 | 943 | */ |
944 | 944 | function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
945 | - ob_start(); |
|
945 | + ob_start(); |
|
946 | 946 | |
947 | - $key = sanitize_key( $key ); |
|
948 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
949 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
947 | + $key = sanitize_key( $key ); |
|
948 | + $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
949 | + include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
950 | 950 | |
951 | - if ( $echo ) { |
|
952 | - echo ob_get_clean(); |
|
953 | - } else { |
|
954 | - return ob_get_clean(); |
|
955 | - } |
|
951 | + if ( $echo ) { |
|
952 | + echo ob_get_clean(); |
|
953 | + } else { |
|
954 | + return ob_get_clean(); |
|
955 | + } |
|
956 | 956 | |
957 | 957 | } |
958 | 958 | |
@@ -980,19 +980,19 @@ discard block |
||
980 | 980 | } |
981 | 981 | |
982 | 982 | function wpinv_descriptive_text_callback( $args ) { |
983 | - echo wp_kses_post( $args['desc'] ); |
|
983 | + echo wp_kses_post( $args['desc'] ); |
|
984 | 984 | } |
985 | 985 | |
986 | 986 | function wpinv_raw_html_callback( $args ) { |
987 | - echo $args['desc']; |
|
987 | + echo $args['desc']; |
|
988 | 988 | } |
989 | 989 | |
990 | 990 | function wpinv_hook_callback( $args ) { |
991 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
991 | + do_action( 'wpinv_' . $args['id'], $args ); |
|
992 | 992 | } |
993 | 993 | |
994 | 994 | function wpinv_set_settings_cap() { |
995 | - return wpinv_get_capability(); |
|
995 | + return wpinv_get_capability(); |
|
996 | 996 | } |
997 | 997 | add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
998 | 998 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves all default settings. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | function wpinv_get_settings() { |
17 | 17 | $defaults = array(); |
18 | 18 | |
19 | - foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) { |
|
19 | + foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) { |
|
20 | 20 | |
21 | - foreach ( array_values( $tab_settings ) as $section_settings ) { |
|
21 | + foreach (array_values($tab_settings) as $section_settings) { |
|
22 | 22 | |
23 | - foreach ( $section_settings as $key => $setting ) { |
|
24 | - if ( isset( $setting['std'] ) ) { |
|
25 | - $defaults[ $key ] = $setting['std']; |
|
23 | + foreach ($section_settings as $key => $setting) { |
|
24 | + if (isset($setting['std'])) { |
|
25 | + $defaults[$key] = $setting['std']; |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | global $wpinv_options; |
44 | 44 | |
45 | 45 | // Try fetching the saved options. |
46 | - if ( ! is_array( $wpinv_options ) ) { |
|
47 | - $wpinv_options = get_option( 'wpinv_settings' ); |
|
46 | + if (!is_array($wpinv_options)) { |
|
47 | + $wpinv_options = get_option('wpinv_settings'); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | // If that fails, don't fetch the default settings to prevent a loop. |
51 | - if ( ! is_array( $wpinv_options ) ) { |
|
51 | + if (!is_array($wpinv_options)) { |
|
52 | 52 | $wpinv_options = array(); |
53 | 53 | } |
54 | 54 | |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | * @param mixed $default The default value to use if the setting has not been set. |
63 | 63 | * @return mixed |
64 | 64 | */ |
65 | -function wpinv_get_option( $key = '', $default = false ) { |
|
65 | +function wpinv_get_option($key = '', $default = false) { |
|
66 | 66 | |
67 | 67 | $options = wpinv_get_options(); |
68 | - $value = isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
69 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
68 | + $value = isset($options[$key]) ? $options[$key] : $default; |
|
69 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
70 | 70 | |
71 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
71 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | * @param array $options the new options. |
78 | 78 | * @return bool |
79 | 79 | */ |
80 | -function wpinv_update_options( $options ) { |
|
80 | +function wpinv_update_options($options) { |
|
81 | 81 | global $wpinv_options; |
82 | 82 | |
83 | 83 | // update the option. |
84 | - if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) { |
|
84 | + if (is_array($options) && update_option('wpinv_settings', $options)) { |
|
85 | 85 | $wpinv_options = $options; |
86 | 86 | return true; |
87 | 87 | } |
@@ -96,24 +96,24 @@ discard block |
||
96 | 96 | * @param mixed $value The setting value. |
97 | 97 | * @return bool |
98 | 98 | */ |
99 | -function wpinv_update_option( $key = '', $value = false ) { |
|
99 | +function wpinv_update_option($key = '', $value = false) { |
|
100 | 100 | |
101 | 101 | // If no key, exit. |
102 | - if ( empty( $key ) ) { |
|
102 | + if (empty($key)) { |
|
103 | 103 | return false; |
104 | 104 | } |
105 | 105 | |
106 | 106 | // Maybe delete the option instead. |
107 | - if ( is_null( $value ) ) { |
|
108 | - return wpinv_delete_option( $key ); |
|
107 | + if (is_null($value)) { |
|
108 | + return wpinv_delete_option($key); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | // Prepare the new options. |
112 | 112 | $options = wpinv_get_options(); |
113 | - $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key ); |
|
113 | + $options[$key] = apply_filters('wpinv_update_option', $value, $key); |
|
114 | 114 | |
115 | 115 | // Save the new options. |
116 | - return wpinv_update_options( $options ); |
|
116 | + return wpinv_update_options($options); |
|
117 | 117 | |
118 | 118 | } |
119 | 119 | |
@@ -123,18 +123,18 @@ discard block |
||
123 | 123 | * @param string $key the setting key. |
124 | 124 | * @return bool |
125 | 125 | */ |
126 | -function wpinv_delete_option( $key = '' ) { |
|
126 | +function wpinv_delete_option($key = '') { |
|
127 | 127 | |
128 | 128 | // If no key, exit |
129 | - if ( empty( $key ) ) { |
|
129 | + if (empty($key)) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | 133 | $options = wpinv_get_options(); |
134 | 134 | |
135 | - if ( isset( $options[ $key ] ) ) { |
|
136 | - unset( $options[ $key ] ); |
|
137 | - return wpinv_update_options( $options ); |
|
135 | + if (isset($options[$key])) { |
|
136 | + unset($options[$key]); |
|
137 | + return wpinv_update_options($options); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | return true; |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | function wpinv_register_settings() { |
149 | 149 | |
150 | 150 | // Loop through all tabs. |
151 | - foreach ( wpinv_get_registered_settings() as $tab => $sections ) { |
|
151 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
152 | 152 | |
153 | 153 | // In each tab, loop through sections. |
154 | - foreach ( $sections as $section => $settings ) { |
|
154 | + foreach ($sections as $section => $settings) { |
|
155 | 155 | |
156 | 156 | // Check for backwards compatibility |
157 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
158 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
157 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
158 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
159 | 159 | $section = 'main'; |
160 | 160 | $settings = $sections; |
161 | 161 | } |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | 'wpinv_settings_' . $tab . '_' . $section |
169 | 169 | ); |
170 | 170 | |
171 | - foreach ( $settings as $option ) { |
|
172 | - if ( ! empty( $option['id'] ) ) { |
|
173 | - wpinv_register_settings_option( $tab, $section, $option ); |
|
171 | + foreach ($settings as $option) { |
|
172 | + if (!empty($option['id'])) { |
|
173 | + wpinv_register_settings_option($tab, $section, $option); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | } |
179 | 179 | |
180 | 180 | // Creates our settings in the options table. |
181 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
181 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
182 | 182 | } |
183 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
183 | +add_action('admin_init', 'wpinv_register_settings'); |
|
184 | 184 | |
185 | 185 | /** |
186 | 186 | * Register a single settings option. |
@@ -190,47 +190,47 @@ discard block |
||
190 | 190 | * @param string $option |
191 | 191 | * |
192 | 192 | */ |
193 | -function wpinv_register_settings_option( $tab, $section, $option ) { |
|
193 | +function wpinv_register_settings_option($tab, $section, $option) { |
|
194 | 194 | |
195 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
195 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
196 | 196 | $cb = "wpinv_{$option['type']}_callback"; |
197 | 197 | $section = "wpinv_settings_{$tab}_$section"; |
198 | 198 | |
199 | - if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) { |
|
200 | - $tip = wpinv_clean( $option['desc'] ); |
|
199 | + if (isset($option['desc']) && !empty($option['help-tip'])) { |
|
200 | + $tip = wpinv_clean($option['desc']); |
|
201 | 201 | $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
202 | - unset( $option['desc'] ); |
|
202 | + unset($option['desc']); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | // Loop through all tabs. |
206 | 206 | add_settings_field( |
207 | 207 | 'wpinv_settings[' . $option['id'] . ']', |
208 | 208 | $name, |
209 | - function_exists( $cb ) ? $cb : 'wpinv_missing_callback', |
|
209 | + function_exists($cb) ? $cb : 'wpinv_missing_callback', |
|
210 | 210 | $section, |
211 | 211 | $section, |
212 | 212 | array( |
213 | 213 | 'section' => $section, |
214 | - 'id' => isset( $option['id'] ) ? $option['id'] : uniqid( 'wpinv-' ), |
|
215 | - 'desc' => isset( $option['desc'] ) ? $option['desc'] : '', |
|
214 | + 'id' => isset($option['id']) ? $option['id'] : uniqid('wpinv-'), |
|
215 | + 'desc' => isset($option['desc']) ? $option['desc'] : '', |
|
216 | 216 | 'name' => $name, |
217 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
218 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
219 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
220 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
221 | - 'min' => isset( $option['min'] ) ? $option['min'] : 0, |
|
222 | - 'max' => isset( $option['max'] ) ? $option['max'] : 999999, |
|
223 | - 'step' => isset( $option['step'] ) ? $option['step'] : 1, |
|
224 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
225 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
226 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
227 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
228 | - 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
|
229 | - 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
|
230 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
231 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
232 | - 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
233 | - 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
217 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
218 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
219 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
220 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
221 | + 'min' => isset($option['min']) ? $option['min'] : 0, |
|
222 | + 'max' => isset($option['max']) ? $option['max'] : 999999, |
|
223 | + 'step' => isset($option['step']) ? $option['step'] : 1, |
|
224 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
225 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
226 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
227 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
228 | + 'onchange' => isset($option['onchange']) ? $option['onchange'] : '', |
|
229 | + 'custom' => isset($option['custom']) ? $option['custom'] : '', |
|
230 | + 'class' => isset($option['class']) ? $option['class'] : '', |
|
231 | + 'style' => isset($option['style']) ? $option['style'] : '', |
|
232 | + 'cols' => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
233 | + 'rows' => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
234 | 234 | ) |
235 | 235 | ); |
236 | 236 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @return array |
243 | 243 | */ |
244 | 244 | function wpinv_get_registered_settings() { |
245 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
245 | + return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings'))); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @return array |
252 | 252 | */ |
253 | 253 | function getpaid_get_integration_settings() { |
254 | - return apply_filters( 'getpaid_integration_settings', array() ); |
|
254 | + return apply_filters('getpaid_integration_settings', array()); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -259,139 +259,139 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @return array |
261 | 261 | */ |
262 | -function wpinv_settings_sanitize( $input = array() ) { |
|
262 | +function wpinv_settings_sanitize($input = array()) { |
|
263 | 263 | |
264 | 264 | $wpinv_options = wpinv_get_options(); |
265 | 265 | |
266 | - if ( empty( wp_get_raw_referer() ) ) { |
|
266 | + if (empty(wp_get_raw_referer())) { |
|
267 | 267 | return $input; |
268 | 268 | } |
269 | 269 | |
270 | - wp_parse_str( wp_get_raw_referer(), $referrer ); |
|
270 | + wp_parse_str(wp_get_raw_referer(), $referrer); |
|
271 | 271 | |
272 | 272 | $settings = wpinv_get_registered_settings(); |
273 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
274 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
273 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
274 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
275 | 275 | |
276 | 276 | $input = $input ? $input : array(); |
277 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
278 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
277 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
278 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
279 | 279 | |
280 | 280 | // Loop through each setting being saved and pass it through a sanitization filter |
281 | - foreach ( $input as $key => $value ) { |
|
281 | + foreach ($input as $key => $value) { |
|
282 | 282 | |
283 | 283 | // Get the setting type (checkbox, select, etc) |
284 | - $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false; |
|
284 | + $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false; |
|
285 | 285 | |
286 | - if ( $type ) { |
|
286 | + if ($type) { |
|
287 | 287 | // Field type specific filter |
288 | - $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key ); |
|
288 | + $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | // General filter |
292 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
292 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
293 | 293 | |
294 | 294 | // Key specific filter. |
295 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
295 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | // Loop through the whitelist and unset any that are empty for the tab being saved |
299 | - $main_settings = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
300 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
299 | + $main_settings = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
300 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
301 | 301 | |
302 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
302 | + $found_settings = array_merge($main_settings, $section_settings); |
|
303 | 303 | |
304 | - if ( ! empty( $found_settings ) ) { |
|
305 | - foreach ( $found_settings as $key => $value ) { |
|
304 | + if (!empty($found_settings)) { |
|
305 | + foreach ($found_settings as $key => $value) { |
|
306 | 306 | |
307 | 307 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
308 | - if ( is_numeric( $key ) ) { |
|
308 | + if (is_numeric($key)) { |
|
309 | 309 | $key = $value['id']; |
310 | 310 | } |
311 | 311 | |
312 | - if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) { |
|
313 | - unset( $wpinv_options[ $key ] ); |
|
312 | + if (!isset($input[$key]) && isset($wpinv_options[$key])) { |
|
313 | + unset($wpinv_options[$key]); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | } |
317 | 317 | |
318 | 318 | // Merge our new settings with the existing |
319 | - $output = array_merge( $wpinv_options, $input ); |
|
319 | + $output = array_merge($wpinv_options, $input); |
|
320 | 320 | |
321 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
321 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
322 | 322 | |
323 | 323 | return $output; |
324 | 324 | } |
325 | 325 | |
326 | -function wpinv_settings_sanitize_misc_accounting( $input ) { |
|
326 | +function wpinv_settings_sanitize_misc_accounting($input) { |
|
327 | 327 | |
328 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
328 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
329 | 329 | return $input; |
330 | 330 | } |
331 | 331 | |
332 | - if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) { |
|
332 | + if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) { |
|
333 | 333 | // Shows an admin notice about upgrading previous order numbers |
334 | - getpaid_session()->set( 'upgrade_sequential', '1' ); |
|
334 | + getpaid_session()->set('upgrade_sequential', '1'); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | return $input; |
338 | 338 | } |
339 | -add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' ); |
|
339 | +add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting'); |
|
340 | 340 | |
341 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
342 | - if( ! wpinv_current_user_can_manage_invoicing() ) { |
|
341 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
342 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
343 | 343 | return $input; |
344 | 344 | } |
345 | 345 | |
346 | - $new_rates = ! empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array(); |
|
346 | + $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array(); |
|
347 | 347 | $tax_rates = array(); |
348 | 348 | |
349 | - foreach ( $new_rates as $rate ) { |
|
349 | + foreach ($new_rates as $rate) { |
|
350 | 350 | |
351 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
352 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
353 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
354 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
355 | - $rate['global'] = empty( $rate['state'] ); |
|
351 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate']); |
|
352 | + $rate['name'] = sanitize_text_field($rate['name']); |
|
353 | + $rate['state'] = sanitize_text_field($rate['state']); |
|
354 | + $rate['country'] = sanitize_text_field($rate['country']); |
|
355 | + $rate['global'] = empty($rate['state']); |
|
356 | 356 | $tax_rates[] = $rate; |
357 | 357 | |
358 | 358 | } |
359 | 359 | |
360 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
360 | + update_option('wpinv_tax_rates', $tax_rates); |
|
361 | 361 | |
362 | 362 | return $input; |
363 | 363 | } |
364 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
364 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
365 | 365 | |
366 | -function wpinv_sanitize_text_field( $input ) { |
|
367 | - return trim( $input ); |
|
366 | +function wpinv_sanitize_text_field($input) { |
|
367 | + return trim($input); |
|
368 | 368 | } |
369 | -add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' ); |
|
369 | +add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field'); |
|
370 | 370 | |
371 | 371 | function wpinv_get_settings_tabs() { |
372 | 372 | $tabs = array(); |
373 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
374 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
375 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
376 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
373 | + $tabs['general'] = __('General', 'invoicing'); |
|
374 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
375 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
376 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
377 | 377 | |
378 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
379 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
378 | + if (count(getpaid_get_integration_settings()) > 0) { |
|
379 | + $tabs['integrations'] = __('Integrations', 'invoicing'); |
|
380 | 380 | } |
381 | 381 | |
382 | - $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
|
383 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
384 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
382 | + $tabs['privacy'] = __('Privacy', 'invoicing'); |
|
383 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
384 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
385 | 385 | |
386 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
386 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
387 | 387 | } |
388 | 388 | |
389 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
389 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
390 | 390 | $tabs = false; |
391 | 391 | $sections = wpinv_get_registered_settings_sections(); |
392 | 392 | |
393 | - if( $tab && ! empty( $sections[ $tab ] ) ) { |
|
394 | - $tabs = $sections[ $tab ]; |
|
393 | + if ($tab && !empty($sections[$tab])) { |
|
394 | + $tabs = $sections[$tab]; |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | return $tabs; |
@@ -400,91 +400,91 @@ discard block |
||
400 | 400 | function wpinv_get_registered_settings_sections() { |
401 | 401 | static $sections = false; |
402 | 402 | |
403 | - if ( false !== $sections ) { |
|
403 | + if (false !== $sections) { |
|
404 | 404 | return $sections; |
405 | 405 | } |
406 | 406 | |
407 | 407 | $sections = array( |
408 | - 'general' => apply_filters( 'wpinv_settings_sections_general', array( |
|
409 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
410 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
411 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
412 | - ) ), |
|
413 | - 'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array( |
|
414 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
415 | - ) ), |
|
416 | - 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
|
417 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
418 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
419 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
420 | - ) ), |
|
421 | - 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
|
422 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
423 | - ) ), |
|
424 | - |
|
425 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
426 | - |
|
427 | - 'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array( |
|
428 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
429 | - ) ), |
|
430 | - 'misc' => apply_filters( 'wpinv_settings_sections_misc', array( |
|
431 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
432 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
433 | - ) ), |
|
434 | - 'tools' => apply_filters( 'wpinv_settings_sections_tools', array( |
|
435 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
436 | - ) ), |
|
408 | + 'general' => apply_filters('wpinv_settings_sections_general', array( |
|
409 | + 'main' => __('General Settings', 'invoicing'), |
|
410 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
411 | + 'labels' => __('Label Texts', 'invoicing'), |
|
412 | + )), |
|
413 | + 'gateways' => apply_filters('wpinv_settings_sections_gateways', array( |
|
414 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
415 | + )), |
|
416 | + 'taxes' => apply_filters('wpinv_settings_sections_taxes', array( |
|
417 | + 'main' => __('Tax Settings', 'invoicing'), |
|
418 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
419 | + 'vat' => __('EU VAT Settings', 'invoicing') |
|
420 | + )), |
|
421 | + 'emails' => apply_filters('wpinv_settings_sections_emails', array( |
|
422 | + 'main' => __('Email Settings', 'invoicing'), |
|
423 | + )), |
|
424 | + |
|
425 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'), |
|
426 | + |
|
427 | + 'privacy' => apply_filters('wpinv_settings_sections_privacy', array( |
|
428 | + 'main' => __('Privacy policy', 'invoicing'), |
|
429 | + )), |
|
430 | + 'misc' => apply_filters('wpinv_settings_sections_misc', array( |
|
431 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
432 | + 'custom-css' => __('Custom CSS', 'invoicing'), |
|
433 | + )), |
|
434 | + 'tools' => apply_filters('wpinv_settings_sections_tools', array( |
|
435 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
436 | + )), |
|
437 | 437 | ); |
438 | 438 | |
439 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
439 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
440 | 440 | |
441 | 441 | return $sections; |
442 | 442 | } |
443 | 443 | |
444 | -function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
|
444 | +function wpinv_get_pages($with_slug = false, $default_label = NULL) { |
|
445 | 445 | $pages_options = array(); |
446 | 446 | |
447 | - if( $default_label !== NULL && $default_label !== false ) { |
|
448 | - $pages_options = array( '' => $default_label ); // Blank option |
|
447 | + if ($default_label !== NULL && $default_label !== false) { |
|
448 | + $pages_options = array('' => $default_label); // Blank option |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | $pages = get_pages(); |
452 | - if ( $pages ) { |
|
453 | - foreach ( $pages as $page ) { |
|
452 | + if ($pages) { |
|
453 | + foreach ($pages as $page) { |
|
454 | 454 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
455 | - $pages_options[ $page->ID ] = $title; |
|
455 | + $pages_options[$page->ID] = $title; |
|
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
459 | 459 | return $pages_options; |
460 | 460 | } |
461 | 461 | |
462 | -function wpinv_header_callback( $args ) { |
|
463 | - if ( !empty( $args['desc'] ) ) { |
|
462 | +function wpinv_header_callback($args) { |
|
463 | + if (!empty($args['desc'])) { |
|
464 | 464 | echo $args['desc']; |
465 | 465 | } |
466 | 466 | } |
467 | 467 | |
468 | -function wpinv_hidden_callback( $args ) { |
|
468 | +function wpinv_hidden_callback($args) { |
|
469 | 469 | global $wpinv_options; |
470 | 470 | |
471 | - if ( isset( $args['set_value'] ) ) { |
|
471 | + if (isset($args['set_value'])) { |
|
472 | 472 | $value = $args['set_value']; |
473 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
474 | - $value = $wpinv_options[ $args['id'] ]; |
|
473 | + } elseif (isset($wpinv_options[$args['id']])) { |
|
474 | + $value = $wpinv_options[$args['id']]; |
|
475 | 475 | } else { |
476 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
476 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
477 | 477 | } |
478 | 478 | |
479 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
479 | + if (isset($args['faux']) && true === $args['faux']) { |
|
480 | 480 | $args['readonly'] = true; |
481 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
481 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
482 | 482 | $name = ''; |
483 | 483 | } else { |
484 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
484 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
485 | 485 | } |
486 | 486 | |
487 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
487 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
488 | 488 | |
489 | 489 | echo $html; |
490 | 490 | } |
@@ -492,61 +492,61 @@ discard block |
||
492 | 492 | /** |
493 | 493 | * Displays a checkbox settings callback. |
494 | 494 | */ |
495 | -function wpinv_checkbox_callback( $args ) { |
|
495 | +function wpinv_checkbox_callback($args) { |
|
496 | 496 | |
497 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
498 | - $std = wpinv_get_option( $args['id'], $std ); |
|
499 | - $id = esc_attr( $args['id'] ); |
|
497 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
498 | + $std = wpinv_get_option($args['id'], $std); |
|
499 | + $id = esc_attr($args['id']); |
|
500 | 500 | |
501 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
501 | + getpaid_hidden_field("wpinv_settings[$id]", '0'); |
|
502 | 502 | ?> |
503 | 503 | <fieldset> |
504 | 504 | <label> |
505 | - <input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
|
506 | - <?php echo wp_kses_post( $args['desc'] ); ?> |
|
505 | + <input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox"> |
|
506 | + <?php echo wp_kses_post($args['desc']); ?> |
|
507 | 507 | </label> |
508 | 508 | </fieldset> |
509 | 509 | <?php |
510 | 510 | } |
511 | 511 | |
512 | -function wpinv_multicheck_callback( $args ) { |
|
512 | +function wpinv_multicheck_callback($args) { |
|
513 | 513 | |
514 | 514 | global $wpinv_options; |
515 | 515 | |
516 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
517 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
516 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
517 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
518 | 518 | |
519 | - if ( ! empty( $args['options'] ) ) { |
|
519 | + if (!empty($args['options'])) { |
|
520 | 520 | |
521 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
522 | - $value = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std; |
|
521 | + $std = isset($args['std']) ? $args['std'] : array(); |
|
522 | + $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : $std; |
|
523 | 523 | |
524 | 524 | echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
525 | - foreach( $args['options'] as $key => $option ): |
|
526 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
527 | - if ( in_array( $sanitize_key, $value ) ) { |
|
525 | + foreach ($args['options'] as $key => $option): |
|
526 | + $sanitize_key = wpinv_sanitize_key($key); |
|
527 | + if (in_array($sanitize_key, $value)) { |
|
528 | 528 | $enabled = $sanitize_key; |
529 | 529 | } else { |
530 | 530 | $enabled = NULL; |
531 | 531 | } |
532 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
533 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
532 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
533 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>'; |
|
534 | 534 | endforeach; |
535 | 535 | echo '</div>'; |
536 | 536 | echo '<p class="description">' . $args['desc'] . '</p>'; |
537 | 537 | } |
538 | 538 | } |
539 | 539 | |
540 | -function wpinv_payment_icons_callback( $args ) { |
|
540 | +function wpinv_payment_icons_callback($args) { |
|
541 | 541 | global $wpinv_options; |
542 | 542 | |
543 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
543 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
544 | 544 | |
545 | - if ( ! empty( $args['options'] ) ) { |
|
546 | - foreach( $args['options'] as $key => $option ) { |
|
547 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
545 | + if (!empty($args['options'])) { |
|
546 | + foreach ($args['options'] as $key => $option) { |
|
547 | + $sanitize_key = wpinv_sanitize_key($key); |
|
548 | 548 | |
549 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
549 | + if (isset($wpinv_options[$args['id']][$key])) { |
|
550 | 550 | $enabled = $option; |
551 | 551 | } else { |
552 | 552 | $enabled = NULL; |
@@ -554,109 +554,109 @@ discard block |
||
554 | 554 | |
555 | 555 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
556 | 556 | |
557 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
557 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
558 | 558 | |
559 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
560 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
559 | + if (wpinv_string_is_image_url($key)) { |
|
560 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
561 | 561 | } else { |
562 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
562 | + $card = strtolower(str_replace(' ', '', $option)); |
|
563 | 563 | |
564 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
565 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
564 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
565 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
566 | 566 | } else { |
567 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
567 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
568 | 568 | $content_dir = WP_CONTENT_DIR; |
569 | 569 | |
570 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
570 | + if (function_exists('wp_normalize_path')) { |
|
571 | 571 | // Replaces backslashes with forward slashes for Windows systems |
572 | - $image = wp_normalize_path( $image ); |
|
573 | - $content_dir = wp_normalize_path( $content_dir ); |
|
572 | + $image = wp_normalize_path($image); |
|
573 | + $content_dir = wp_normalize_path($content_dir); |
|
574 | 574 | } |
575 | 575 | |
576 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
576 | + $image = str_replace($content_dir, content_url(), $image); |
|
577 | 577 | } |
578 | 578 | |
579 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
579 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
580 | 580 | } |
581 | 581 | echo $option . '</label>'; |
582 | 582 | } |
583 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
583 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
584 | 584 | } |
585 | 585 | } |
586 | 586 | |
587 | 587 | /** |
588 | 588 | * Displays a radio settings field. |
589 | 589 | */ |
590 | -function wpinv_radio_callback( $args ) { |
|
590 | +function wpinv_radio_callback($args) { |
|
591 | 591 | |
592 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
593 | - $std = wpinv_get_option( $args['id'], $std ); |
|
592 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
593 | + $std = wpinv_get_option($args['id'], $std); |
|
594 | 594 | ?> |
595 | 595 | <fieldset> |
596 | - <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
|
597 | - <?php foreach( $args['options'] as $key => $option ) : ?> |
|
596 | + <ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;"> |
|
597 | + <?php foreach ($args['options'] as $key => $option) : ?> |
|
598 | 598 | <li> |
599 | 599 | <label> |
600 | - <input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio"> |
|
601 | - <?php echo wp_kses_post( $option ); ?> |
|
600 | + <input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio"> |
|
601 | + <?php echo wp_kses_post($option); ?> |
|
602 | 602 | </label> |
603 | 603 | </li> |
604 | 604 | <?php endforeach; ?> |
605 | 605 | </ul> |
606 | 606 | </fieldset> |
607 | 607 | <?php |
608 | - getpaid_settings_description_callback( $args ); |
|
608 | + getpaid_settings_description_callback($args); |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | /** |
612 | 612 | * Displays a description if available. |
613 | 613 | */ |
614 | -function getpaid_settings_description_callback( $args ) { |
|
614 | +function getpaid_settings_description_callback($args) { |
|
615 | 615 | |
616 | - if ( ! empty( $args['desc'] ) ) { |
|
617 | - $description = wp_kses_post( $args['desc'] ); |
|
616 | + if (!empty($args['desc'])) { |
|
617 | + $description = wp_kses_post($args['desc']); |
|
618 | 618 | echo "<p class='description'>$description</p>"; |
619 | 619 | } |
620 | 620 | |
621 | 621 | } |
622 | 622 | |
623 | -function wpinv_gateways_callback( $args ) { |
|
623 | +function wpinv_gateways_callback($args) { |
|
624 | 624 | global $wpinv_options; |
625 | 625 | |
626 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
626 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
627 | 627 | |
628 | - foreach ( $args['options'] as $key => $option ) : |
|
629 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
628 | + foreach ($args['options'] as $key => $option) : |
|
629 | + $sanitize_key = wpinv_sanitize_key($key); |
|
630 | 630 | |
631 | - if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
|
631 | + if (isset($wpinv_options['gateways'][$key])) |
|
632 | 632 | $enabled = '1'; |
633 | 633 | else |
634 | 634 | $enabled = null; |
635 | 635 | |
636 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
637 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
636 | + echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
637 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>'; |
|
638 | 638 | endforeach; |
639 | 639 | } |
640 | 640 | |
641 | 641 | function wpinv_gateway_select_callback($args) { |
642 | 642 | global $wpinv_options; |
643 | 643 | |
644 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
645 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
644 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
645 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
646 | 646 | |
647 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
647 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >'; |
|
648 | 648 | |
649 | - foreach ( $args['options'] as $key => $option ) : |
|
650 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
651 | - $selected = selected( $key, $args['selected'], false ); |
|
649 | + foreach ($args['options'] as $key => $option) : |
|
650 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
651 | + $selected = selected($key, $args['selected'], false); |
|
652 | 652 | } else { |
653 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
|
653 | + $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : ''; |
|
654 | 654 | } |
655 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
655 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
656 | 656 | endforeach; |
657 | 657 | |
658 | 658 | echo '</select>'; |
659 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
659 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
660 | 660 | } |
661 | 661 | |
662 | 662 | /** |
@@ -665,28 +665,28 @@ discard block |
||
665 | 665 | * @param array $args |
666 | 666 | * @return string |
667 | 667 | */ |
668 | -function wpinv_settings_attrs_helper( $args ) { |
|
668 | +function wpinv_settings_attrs_helper($args) { |
|
669 | 669 | |
670 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
671 | - $id = esc_attr( $args['id'] ); |
|
672 | - $placeholder = esc_attr( $args['placeholder'] ); |
|
670 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
671 | + $id = esc_attr($args['id']); |
|
672 | + $placeholder = esc_attr($args['placeholder']); |
|
673 | 673 | |
674 | - if ( ! empty( $args['faux'] ) ) { |
|
674 | + if (!empty($args['faux'])) { |
|
675 | 675 | $args['readonly'] = true; |
676 | 676 | $name = ''; |
677 | 677 | } else { |
678 | - $value = wpinv_get_option( $args['id'], $value ); |
|
678 | + $value = wpinv_get_option($args['id'], $value); |
|
679 | 679 | $name = "wpinv_settings[$id]"; |
680 | 680 | } |
681 | 681 | |
682 | - $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
683 | - $class = esc_attr( $args['class'] ); |
|
684 | - $style = esc_attr( $args['style'] ); |
|
685 | - $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
682 | + $value = is_scalar($value) ? esc_attr($value) : ''; |
|
683 | + $class = esc_attr($args['class']); |
|
684 | + $style = esc_attr($args['style']); |
|
685 | + $readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"'; |
|
686 | 686 | |
687 | 687 | $onchange = ''; |
688 | - if ( ! empty( $args['onchange'] ) ) { |
|
689 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
688 | + if (!empty($args['onchange'])) { |
|
689 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
@@ -695,11 +695,11 @@ discard block |
||
695 | 695 | /** |
696 | 696 | * Displays a text input settings callback. |
697 | 697 | */ |
698 | -function wpinv_text_callback( $args ) { |
|
698 | +function wpinv_text_callback($args) { |
|
699 | 699 | |
700 | - $desc = wp_kses_post( $args['desc'] ); |
|
701 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
702 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
700 | + $desc = wp_kses_post($args['desc']); |
|
701 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
702 | + $attr = wpinv_settings_attrs_helper($args); |
|
703 | 703 | |
704 | 704 | ?> |
705 | 705 | <label style="width: 100%;"> |
@@ -713,14 +713,14 @@ discard block |
||
713 | 713 | /** |
714 | 714 | * Displays a number input settings callback. |
715 | 715 | */ |
716 | -function wpinv_number_callback( $args ) { |
|
716 | +function wpinv_number_callback($args) { |
|
717 | 717 | |
718 | - $desc = wp_kses_post( $args['desc'] ); |
|
719 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
720 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
721 | - $max = intval( $args['max'] ); |
|
722 | - $min = intval( $args['min'] ); |
|
723 | - $step = floatval( $args['step'] ); |
|
718 | + $desc = wp_kses_post($args['desc']); |
|
719 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
720 | + $attr = wpinv_settings_attrs_helper($args); |
|
721 | + $max = intval($args['max']); |
|
722 | + $min = intval($args['min']); |
|
723 | + $step = floatval($args['step']); |
|
724 | 724 | |
725 | 725 | ?> |
726 | 726 | <label style="width: 100%;"> |
@@ -731,47 +731,47 @@ discard block |
||
731 | 731 | |
732 | 732 | } |
733 | 733 | |
734 | -function wpinv_textarea_callback( $args ) { |
|
734 | +function wpinv_textarea_callback($args) { |
|
735 | 735 | global $wpinv_options; |
736 | 736 | |
737 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
737 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
738 | 738 | |
739 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
740 | - $value = $wpinv_options[ $args['id'] ]; |
|
739 | + if (isset($wpinv_options[$args['id']])) { |
|
740 | + $value = $wpinv_options[$args['id']]; |
|
741 | 741 | } else { |
742 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
742 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
743 | 743 | } |
744 | 744 | |
745 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
746 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
745 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
746 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
747 | 747 | |
748 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
749 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
748 | + $html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
749 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
750 | 750 | |
751 | 751 | echo $html; |
752 | 752 | } |
753 | 753 | |
754 | -function wpinv_password_callback( $args ) { |
|
754 | +function wpinv_password_callback($args) { |
|
755 | 755 | global $wpinv_options; |
756 | 756 | |
757 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
757 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
758 | 758 | |
759 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
760 | - $value = $wpinv_options[ $args['id'] ]; |
|
759 | + if (isset($wpinv_options[$args['id']])) { |
|
760 | + $value = $wpinv_options[$args['id']]; |
|
761 | 761 | } else { |
762 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
762 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
763 | 763 | } |
764 | 764 | |
765 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
766 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
767 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
765 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
766 | + $html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
767 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
768 | 768 | |
769 | 769 | echo $html; |
770 | 770 | } |
771 | 771 | |
772 | 772 | function wpinv_missing_callback($args) { |
773 | 773 | printf( |
774 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
774 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
775 | 775 | '<strong>' . $args['id'] . '</strong>' |
776 | 776 | ); |
777 | 777 | } |
@@ -779,20 +779,20 @@ discard block |
||
779 | 779 | /** |
780 | 780 | * Displays a number input settings callback. |
781 | 781 | */ |
782 | -function wpinv_select_callback( $args ) { |
|
782 | +function wpinv_select_callback($args) { |
|
783 | 783 | |
784 | - $desc = wp_kses_post( $args['desc'] ); |
|
785 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
786 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
787 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
788 | - $value = wpinv_get_option( $args['id'], $value ); |
|
784 | + $desc = wp_kses_post($args['desc']); |
|
785 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
786 | + $attr = wpinv_settings_attrs_helper($args); |
|
787 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
788 | + $value = wpinv_get_option($args['id'], $value); |
|
789 | 789 | |
790 | 790 | ?> |
791 | 791 | <label style="width: 100%;"> |
792 | 792 | <select <?php echo $attr; ?>> |
793 | - <?php foreach ( $args['options'] as $option => $name ) : ?> |
|
794 | - <option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( is_array( $value ) ? in_array( "$option", $value, true ) : "$option" === $value ); ?>><?php echo wpinv_clean( $name ); ?></option> |
|
795 | - <?php endforeach;?> |
|
793 | + <?php foreach ($args['options'] as $option => $name) : ?> |
|
794 | + <option value="<?php echo esc_attr($option); ?>" <?php echo selected(is_array($value) ? in_array("$option", $value, true) : "$option" === $value); ?>><?php echo wpinv_clean($name); ?></option> |
|
795 | + <?php endforeach; ?> |
|
796 | 796 | </select> |
797 | 797 | <?php echo $desc; ?> |
798 | 798 | </label> |
@@ -800,95 +800,95 @@ discard block |
||
800 | 800 | |
801 | 801 | } |
802 | 802 | |
803 | -function wpinv_color_select_callback( $args ) { |
|
803 | +function wpinv_color_select_callback($args) { |
|
804 | 804 | global $wpinv_options; |
805 | 805 | |
806 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
806 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
807 | 807 | |
808 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
809 | - $value = $wpinv_options[ $args['id'] ]; |
|
808 | + if (isset($wpinv_options[$args['id']])) { |
|
809 | + $value = $wpinv_options[$args['id']]; |
|
810 | 810 | } else { |
811 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
811 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
812 | 812 | } |
813 | 813 | |
814 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
814 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
815 | 815 | |
816 | - foreach ( $args['options'] as $option => $color ) { |
|
817 | - $selected = selected( $option, $value, false ); |
|
818 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
816 | + foreach ($args['options'] as $option => $color) { |
|
817 | + $selected = selected($option, $value, false); |
|
818 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>'; |
|
819 | 819 | } |
820 | 820 | |
821 | 821 | $html .= '</select>'; |
822 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
822 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
823 | 823 | |
824 | 824 | echo $html; |
825 | 825 | } |
826 | 826 | |
827 | -function wpinv_rich_editor_callback( $args ) { |
|
827 | +function wpinv_rich_editor_callback($args) { |
|
828 | 828 | global $wpinv_options, $wp_version; |
829 | 829 | |
830 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
830 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
831 | 831 | |
832 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
833 | - $value = $wpinv_options[ $args['id'] ]; |
|
832 | + if (isset($wpinv_options[$args['id']])) { |
|
833 | + $value = $wpinv_options[$args['id']]; |
|
834 | 834 | |
835 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
836 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
835 | + if (empty($args['allow_blank']) && empty($value)) { |
|
836 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
837 | 837 | } |
838 | 838 | } else { |
839 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
839 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
840 | 840 | } |
841 | 841 | |
842 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
842 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
843 | 843 | |
844 | 844 | $html = '<div class="getpaid-settings-editor-input">'; |
845 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
845 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
846 | 846 | ob_start(); |
847 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
847 | + wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false)); |
|
848 | 848 | $html .= ob_get_clean(); |
849 | 849 | } else { |
850 | - $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
850 | + $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
851 | 851 | } |
852 | 852 | |
853 | - $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
853 | + $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
854 | 854 | |
855 | 855 | echo $html; |
856 | 856 | } |
857 | 857 | |
858 | -function wpinv_upload_callback( $args ) { |
|
858 | +function wpinv_upload_callback($args) { |
|
859 | 859 | global $wpinv_options; |
860 | 860 | |
861 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
861 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
862 | 862 | |
863 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
863 | + if (isset($wpinv_options[$args['id']])) { |
|
864 | 864 | $value = $wpinv_options[$args['id']]; |
865 | 865 | } else { |
866 | 866 | $value = isset($args['std']) ? $args['std'] : ''; |
867 | 867 | } |
868 | 868 | |
869 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
870 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
871 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
872 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
869 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
870 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
871 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
872 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
873 | 873 | |
874 | 874 | echo $html; |
875 | 875 | } |
876 | 876 | |
877 | -function wpinv_color_callback( $args ) { |
|
877 | +function wpinv_color_callback($args) { |
|
878 | 878 | global $wpinv_options; |
879 | 879 | |
880 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
880 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
881 | 881 | |
882 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
883 | - $value = $wpinv_options[ $args['id'] ]; |
|
882 | + if (isset($wpinv_options[$args['id']])) { |
|
883 | + $value = $wpinv_options[$args['id']]; |
|
884 | 884 | } else { |
885 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
885 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
886 | 886 | } |
887 | 887 | |
888 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
888 | + $default = isset($args['std']) ? $args['std'] : ''; |
|
889 | 889 | |
890 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
891 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
890 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />'; |
|
891 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
892 | 892 | |
893 | 893 | echo $html; |
894 | 894 | } |
@@ -896,9 +896,9 @@ discard block |
||
896 | 896 | function wpinv_country_states_callback($args) { |
897 | 897 | global $wpinv_options; |
898 | 898 | |
899 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
899 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
900 | 900 | |
901 | - if ( isset( $args['placeholder'] ) ) { |
|
901 | + if (isset($args['placeholder'])) { |
|
902 | 902 | $placeholder = $args['placeholder']; |
903 | 903 | } else { |
904 | 904 | $placeholder = ''; |
@@ -906,16 +906,16 @@ discard block |
||
906 | 906 | |
907 | 907 | $states = wpinv_get_country_states(); |
908 | 908 | |
909 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
910 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
909 | + $class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
910 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
911 | 911 | |
912 | - foreach ( $states as $option => $name ) { |
|
913 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
914 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
912 | + foreach ($states as $option => $name) { |
|
913 | + $selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : ''; |
|
914 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
915 | 915 | } |
916 | 916 | |
917 | 917 | $html .= '</select>'; |
918 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
918 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
919 | 919 | |
920 | 920 | echo $html; |
921 | 921 | } |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | </tr> |
931 | 931 | <tr class="bsui"> |
932 | 932 | <td colspan="2" class="p-0"> |
933 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?> |
|
933 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?> |
|
934 | 934 | |
935 | 935 | <?php |
936 | 936 | |
@@ -939,14 +939,14 @@ discard block |
||
939 | 939 | /** |
940 | 940 | * Displays a tax rate' edit row. |
941 | 941 | */ |
942 | -function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
|
942 | +function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) { |
|
943 | 943 | ob_start(); |
944 | 944 | |
945 | - $key = sanitize_key( $key ); |
|
946 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
947 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
945 | + $key = sanitize_key($key); |
|
946 | + $tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate']; |
|
947 | + include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php'; |
|
948 | 948 | |
949 | - if ( $echo ) { |
|
949 | + if ($echo) { |
|
950 | 950 | echo ob_get_clean(); |
951 | 951 | } else { |
952 | 952 | return ob_get_clean(); |
@@ -958,81 +958,81 @@ discard block |
||
958 | 958 | ob_start(); ?> |
959 | 959 | </td><tr> |
960 | 960 | <td colspan="2" class="wpinv_tools_tdbox"> |
961 | - <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
962 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
961 | + <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
962 | + <?php do_action('wpinv_tools_before'); ?> |
|
963 | 963 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
964 | 964 | <thead> |
965 | 965 | <tr> |
966 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
967 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
968 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
966 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
967 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
968 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
969 | 969 | </tr> |
970 | 970 | </thead> |
971 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
971 | + <?php do_action('wpinv_tools_row'); ?> |
|
972 | 972 | <tbody> |
973 | 973 | </tbody> |
974 | 974 | </table> |
975 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
975 | + <?php do_action('wpinv_tools_after'); ?> |
|
976 | 976 | <?php |
977 | 977 | echo ob_get_clean(); |
978 | 978 | } |
979 | 979 | |
980 | -function wpinv_descriptive_text_callback( $args ) { |
|
981 | - echo wp_kses_post( $args['desc'] ); |
|
980 | +function wpinv_descriptive_text_callback($args) { |
|
981 | + echo wp_kses_post($args['desc']); |
|
982 | 982 | } |
983 | 983 | |
984 | -function wpinv_raw_html_callback( $args ) { |
|
984 | +function wpinv_raw_html_callback($args) { |
|
985 | 985 | echo $args['desc']; |
986 | 986 | } |
987 | 987 | |
988 | -function wpinv_hook_callback( $args ) { |
|
989 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
988 | +function wpinv_hook_callback($args) { |
|
989 | + do_action('wpinv_' . $args['id'], $args); |
|
990 | 990 | } |
991 | 991 | |
992 | 992 | function wpinv_set_settings_cap() { |
993 | 993 | return wpinv_get_capability(); |
994 | 994 | } |
995 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
995 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
996 | 996 | |
997 | -function wpinv_settings_sanitize_input( $value, $key ) { |
|
997 | +function wpinv_settings_sanitize_input($value, $key) { |
|
998 | 998 | |
999 | - if ( $key == 'tax_rate' ) { |
|
1000 | - $value = wpinv_sanitize_amount( $value ); |
|
999 | + if ($key == 'tax_rate') { |
|
1000 | + $value = wpinv_sanitize_amount($value); |
|
1001 | 1001 | $value = $value >= 100 ? 99 : $value; |
1002 | 1002 | } |
1003 | 1003 | |
1004 | 1004 | return $value; |
1005 | 1005 | } |
1006 | -add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 ); |
|
1006 | +add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2); |
|
1007 | 1007 | |
1008 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
1009 | - $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1010 | - $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1008 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
1009 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
1010 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
1011 | 1011 | |
1012 | - if ( $old != $new ) { |
|
1013 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
1012 | + if ($old != $new) { |
|
1013 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
1014 | 1014 | } |
1015 | 1015 | } |
1016 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
1017 | -add_action( 'wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1018 | -add_action( 'wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1019 | -add_action( 'wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1020 | -add_action( 'wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1021 | -add_action( 'wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1022 | -add_action( 'wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1023 | -add_action( 'wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1024 | -add_action( 'wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1025 | -add_action( 'wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1026 | -add_action( 'wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1027 | - |
|
1028 | -function wpinv_settings_tab_bottom_emails( $active_tab, $section ) { |
|
1016 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
1017 | +add_action('wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1018 | +add_action('wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1019 | +add_action('wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1020 | +add_action('wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1021 | +add_action('wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1022 | +add_action('wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1023 | +add_action('wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1024 | +add_action('wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1025 | +add_action('wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1026 | +add_action('wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1027 | + |
|
1028 | +function wpinv_settings_tab_bottom_emails($active_tab, $section) { |
|
1029 | 1029 | ?> |
1030 | 1030 | <div class="wpinv-email-wc-row "> |
1031 | 1031 | <div class="wpinv-email-wc-td"> |
1032 | - <h3 class="wpinv-email-wc-title"><?php echo apply_filters( 'wpinv_settings_email_wildcards_title', __( 'Wildcards For Emails', 'invoicing' ) ); ?></h3> |
|
1032 | + <h3 class="wpinv-email-wc-title"><?php echo apply_filters('wpinv_settings_email_wildcards_title', __('Wildcards For Emails', 'invoicing')); ?></h3> |
|
1033 | 1033 | <p class="wpinv-email-wc-description"> |
1034 | 1034 | <?php |
1035 | - $description = __( 'The following wildcards can be used in email subjects, heading and content:<br> |
|
1035 | + $description = __('The following wildcards can be used in email subjects, heading and content:<br> |
|
1036 | 1036 | <strong>{site_title} :</strong> Site Title<br> |
1037 | 1037 | <strong>{name} :</strong> Customer\'s full name<br> |
1038 | 1038 | <strong>{first_name} :</strong> Customer\'s first name<br> |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | <strong>{invoice_due_date} :</strong> The date the invoice is due<br> |
1047 | 1047 | <strong>{date} :</strong> Today\'s date.<br> |
1048 | 1048 | <strong>{is_was} :</strong> If due date of invoice is past, displays "was" otherwise displays "is"<br> |
1049 | - <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing' ); |
|
1049 | + <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing'); |
|
1050 | 1050 | echo apply_filters('wpinv_settings_email_wildcards_description', $description, $active_tab, $section); |
1051 | 1051 | ?> |
1052 | 1052 | </p> |