@@ -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 taxes class |
@@ -29,22 +29,22 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @param GetPaid_Payment_Form_Submission $submission |
31 | 31 | */ |
32 | - public function __construct( $submission ) { |
|
32 | + public function __construct($submission) { |
|
33 | 33 | |
34 | 34 | // Validate VAT number. |
35 | - $this->validate_vat( $submission ); |
|
35 | + $this->validate_vat($submission); |
|
36 | 36 | |
37 | - if ( $this->skip_taxes ) { |
|
37 | + if ($this->skip_taxes) { |
|
38 | 38 | return; |
39 | 39 | } |
40 | 40 | |
41 | - foreach ( $submission->get_items() as $item ) { |
|
42 | - $this->process_item_tax( $item, $submission ); |
|
41 | + foreach ($submission->get_items() as $item) { |
|
42 | + $this->process_item_tax($item, $submission); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | // Process any existing invoice taxes. |
46 | - if ( $submission->has_invoice() ) { |
|
47 | - $this->taxes = array_replace( $submission->get_invoice()->get_taxes(), $this->taxes ); |
|
46 | + if ($submission->has_invoice()) { |
|
47 | + $this->taxes = array_replace($submission->get_invoice()->get_taxes(), $this->taxes); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | } |
@@ -56,24 +56,24 @@ discard block |
||
56 | 56 | * @param GetPaid_Form_Item $item |
57 | 57 | * @param GetPaid_Payment_Form_Submission $submission |
58 | 58 | */ |
59 | - public function process_item_tax( $item, $submission ) { |
|
59 | + public function process_item_tax($item, $submission) { |
|
60 | 60 | |
61 | - $rates = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state ); |
|
62 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
63 | - $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item->get_id(), $item->get_sub_total(), $submission->get_discount_code(), false ), $rates ); |
|
64 | - $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item->get_id(), $item->get_recurring_sub_total(), $submission->get_discount_code(), true ), $rates ); |
|
61 | + $rates = getpaid_get_item_tax_rates($item, $submission->country, $submission->state); |
|
62 | + $rates = getpaid_filter_item_tax_rates($item, $rates); |
|
63 | + $taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item->get_id(), $item->get_sub_total(), $submission->get_discount_code(), false), $rates); |
|
64 | + $r_taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item->get_id(), $item->get_recurring_sub_total(), $submission->get_discount_code(), true), $rates); |
|
65 | 65 | |
66 | - foreach ( $taxes as $name => $amount ) { |
|
67 | - $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
68 | - $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
66 | + foreach ($taxes as $name => $amount) { |
|
67 | + $recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0; |
|
68 | + $tax = getpaid_prepare_item_tax($item, $name, $amount, $recurring); |
|
69 | 69 | |
70 | - if ( ! isset( $this->taxes[ $name ] ) ) { |
|
71 | - $this->taxes[ $name ] = $tax; |
|
70 | + if (!isset($this->taxes[$name])) { |
|
71 | + $this->taxes[$name] = $tax; |
|
72 | 72 | continue; |
73 | 73 | } |
74 | 74 | |
75 | - $this->taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
76 | - $this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
75 | + $this->taxes[$name]['initial_tax'] += $tax['initial_tax']; |
|
76 | + $this->taxes[$name]['recurring_tax'] += $tax['recurring_tax']; |
|
77 | 77 | |
78 | 78 | } |
79 | 79 | |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | * @since 1.0.19 |
87 | 87 | * @return bool |
88 | 88 | */ |
89 | - public function has_digital_item( $submission ) { |
|
89 | + public function has_digital_item($submission) { |
|
90 | 90 | |
91 | - foreach ( $submission->get_items() as $item ) { |
|
91 | + foreach ($submission->get_items() as $item) { |
|
92 | 92 | |
93 | - if ( 'digital' == $item->get_vat_rule() ) { |
|
93 | + if ('digital' == $item->get_vat_rule()) { |
|
94 | 94 | return true; |
95 | 95 | } |
96 | 96 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @return bool |
107 | 107 | */ |
108 | 108 | public static function is_eu_store() { |
109 | - return self::is_eu_country( wpinv_get_default_country() ); |
|
109 | + return self::is_eu_country(wpinv_get_default_country()); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | * @since 1.0.19 |
117 | 117 | * @return bool |
118 | 118 | */ |
119 | - public static function is_eu_country( $country ) { |
|
120 | - return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country ); |
|
119 | + public static function is_eu_country($country) { |
|
120 | + return getpaid_is_eu_state($country) || getpaid_is_gst_country($country); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | * @since 1.0.19 |
128 | 128 | * @return bool |
129 | 129 | */ |
130 | - public static function is_eu_transaction( $customer_country ) { |
|
131 | - return self::is_eu_country( $customer_country ) && self::is_eu_store(); |
|
130 | + public static function is_eu_transaction($customer_country) { |
|
131 | + return self::is_eu_country($customer_country) && self::is_eu_store(); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | * @since 1.0.19 |
139 | 139 | * @return string |
140 | 140 | */ |
141 | - public function get_vat_number( $submission ) { |
|
141 | + public function get_vat_number($submission) { |
|
142 | 142 | |
143 | 143 | // Retrieve from the posted number. |
144 | - $vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' ); |
|
145 | - if ( ! empty( $vat_number ) ) { |
|
146 | - return wpinv_clean( $vat_number ); |
|
144 | + $vat_number = $submission->get_field('wpinv_vat_number', 'billing'); |
|
145 | + if (!empty($vat_number)) { |
|
146 | + return wpinv_clean($vat_number); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | // Retrieve from the invoice. |
@@ -157,12 +157,12 @@ discard block |
||
157 | 157 | * @since 1.0.19 |
158 | 158 | * @return string |
159 | 159 | */ |
160 | - public function get_company( $submission ) { |
|
160 | + public function get_company($submission) { |
|
161 | 161 | |
162 | 162 | // Retrieve from the posted data. |
163 | - $company = $submission->get_field( 'wpinv_company', 'billing' ); |
|
164 | - if ( ! empty( $company ) ) { |
|
165 | - return wpinv_clean( $company ); |
|
163 | + $company = $submission->get_field('wpinv_company', 'billing'); |
|
164 | + if (!empty($company)) { |
|
165 | + return wpinv_clean($company); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | // Retrieve from the invoice. |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | * @since 1.0.19 |
178 | 178 | * @return string |
179 | 179 | */ |
180 | - public function requires_vat( $ip_in_eu, $country_in_eu ) { |
|
180 | + public function requires_vat($ip_in_eu, $country_in_eu) { |
|
181 | 181 | |
182 | - $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
183 | - $prevent_b2c = ! empty( $prevent_b2c ); |
|
182 | + $prevent_b2c = wpinv_get_option('vat_prevent_b2c_purchase'); |
|
183 | + $prevent_b2c = !empty($prevent_b2c); |
|
184 | 184 | $is_eu = $ip_in_eu || $country_in_eu; |
185 | 185 | |
186 | 186 | return $prevent_b2c && $is_eu; |
@@ -192,45 +192,45 @@ discard block |
||
192 | 192 | * @param GetPaid_Payment_Form_Submission $submission |
193 | 193 | * @since 1.0.19 |
194 | 194 | */ |
195 | - public function validate_vat( $submission ) { |
|
195 | + public function validate_vat($submission) { |
|
196 | 196 | |
197 | - $in_eu = $this->is_eu_transaction( $submission->country ); |
|
197 | + $in_eu = $this->is_eu_transaction($submission->country); |
|
198 | 198 | |
199 | 199 | // Abort if we are not validating vat numbers. |
200 | - if ( ! $in_eu ) { |
|
200 | + if (!$in_eu) { |
|
201 | 201 | return; |
202 | 202 | } |
203 | 203 | |
204 | 204 | // Prepare variables. |
205 | - $vat_number = $this->get_vat_number( $submission ); |
|
205 | + $vat_number = $this->get_vat_number($submission); |
|
206 | 206 | $ip_country = getpaid_get_ip_country(); |
207 | - $is_eu = $this->is_eu_country( $submission->country ); |
|
208 | - $is_ip_eu = $this->is_eu_country( $ip_country ); |
|
207 | + $is_eu = $this->is_eu_country($submission->country); |
|
208 | + $is_ip_eu = $this->is_eu_country($ip_country); |
|
209 | 209 | |
210 | 210 | // Maybe abort early for initial fetches. |
211 | - if ( $submission->is_initial_fetch() && empty( $vat_number ) ) { |
|
211 | + if ($submission->is_initial_fetch() && empty($vat_number)) { |
|
212 | 212 | return; |
213 | 213 | } |
214 | 214 | |
215 | 215 | // If we're preventing business to consumer purchases, |
216 | - if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) { |
|
216 | + if ($this->requires_vat($is_ip_eu, $is_eu) && empty($vat_number)) { |
|
217 | 217 | |
218 | 218 | // Ensure that a vat number has been specified. |
219 | 219 | throw new Exception( |
220 | - __( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' ) |
|
220 | + __('Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing') |
|
221 | 221 | ); |
222 | 222 | |
223 | 223 | } |
224 | 224 | |
225 | - if ( empty( $vat_number ) ) { |
|
225 | + if (empty($vat_number)) { |
|
226 | 226 | return; |
227 | 227 | } |
228 | 228 | |
229 | - if ( wpinv_should_validate_vat_number() && ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) { |
|
230 | - throw new Exception( __( 'Your VAT number is invalid', 'invoicing' ) ); |
|
229 | + if (wpinv_should_validate_vat_number() && !wpinv_validate_vat_number($vat_number, $submission->country)) { |
|
230 | + throw new Exception(__('Your VAT number is invalid', 'invoicing')); |
|
231 | 231 | } |
232 | 232 | |
233 | - if ( wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
233 | + if (wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option('vat_same_country_rule', 'vat_too')) { |
|
234 | 234 | return; |
235 | 235 | } |
236 | 236 |
@@ -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 | * WPInv_Ajax class. |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | * Hook in ajax handlers. |
18 | 18 | */ |
19 | 19 | public static function init() { |
20 | - add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 ); |
|
21 | - add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 ); |
|
20 | + add_action('init', array(__CLASS__, 'define_ajax'), 0); |
|
21 | + add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0); |
|
22 | 22 | self::add_ajax_events(); |
23 | 23 | } |
24 | 24 | |
@@ -27,11 +27,11 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function define_ajax() { |
29 | 29 | |
30 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
31 | - getpaid_maybe_define_constant( 'DOING_AJAX', true ); |
|
32 | - getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true ); |
|
33 | - if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) { |
|
34 | - /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 ); |
|
30 | + if (!empty($_GET['wpinv-ajax'])) { |
|
31 | + getpaid_maybe_define_constant('DOING_AJAX', true); |
|
32 | + getpaid_maybe_define_constant('WPInv_DOING_AJAX', true); |
|
33 | + if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) { |
|
34 | + /** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0); |
|
35 | 35 | } |
36 | 36 | $GLOBALS['wpdb']->hide_errors(); |
37 | 37 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * @since 1.0.18 |
45 | 45 | */ |
46 | 46 | private static function wpinv_ajax_headers() { |
47 | - if ( ! headers_sent() ) { |
|
47 | + if (!headers_sent()) { |
|
48 | 48 | send_origin_headers(); |
49 | 49 | send_nosniff_header(); |
50 | 50 | nocache_headers(); |
51 | - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); |
|
52 | - header( 'X-Robots-Tag: noindex' ); |
|
53 | - status_header( 200 ); |
|
51 | + header('Content-Type: text/html; charset=' . get_option('blog_charset')); |
|
52 | + header('X-Robots-Tag: noindex'); |
|
53 | + status_header(200); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | public static function do_wpinv_ajax() { |
61 | 61 | global $wp_query; |
62 | 62 | |
63 | - if ( ! empty( $_GET['wpinv-ajax'] ) ) { |
|
64 | - $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) ); |
|
63 | + if (!empty($_GET['wpinv-ajax'])) { |
|
64 | + $wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax']))); |
|
65 | 65 | } |
66 | 66 | |
67 | - $action = $wp_query->get( 'wpinv-ajax' ); |
|
67 | + $action = $wp_query->get('wpinv-ajax'); |
|
68 | 68 | |
69 | - if ( $action ) { |
|
69 | + if ($action) { |
|
70 | 70 | self::wpinv_ajax_headers(); |
71 | - $action = sanitize_text_field( $action ); |
|
72 | - do_action( 'wpinv_ajax_' . $action ); |
|
71 | + $action = sanitize_text_field($action); |
|
72 | + do_action('wpinv_ajax_' . $action); |
|
73 | 73 | wp_die(); |
74 | 74 | } |
75 | 75 | |
@@ -101,36 +101,36 @@ discard block |
||
101 | 101 | 'payment_form_refresh_prices' => true, |
102 | 102 | ); |
103 | 103 | |
104 | - foreach ( $ajax_events as $ajax_event => $nopriv ) { |
|
105 | - add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
106 | - add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
104 | + foreach ($ajax_events as $ajax_event => $nopriv) { |
|
105 | + add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
106 | + add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
107 | 107 | |
108 | - if ( $nopriv ) { |
|
109 | - add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
110 | - add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
111 | - add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) ); |
|
108 | + if ($nopriv) { |
|
109 | + add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
110 | + add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
111 | + add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event)); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | 116 | public static function add_note() { |
117 | - check_ajax_referer( 'add-invoice-note', '_nonce' ); |
|
117 | + check_ajax_referer('add-invoice-note', '_nonce'); |
|
118 | 118 | |
119 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
119 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
120 | 120 | die(-1); |
121 | 121 | } |
122 | 122 | |
123 | - $post_id = absint( $_POST['post_id'] ); |
|
124 | - $note = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) ); |
|
125 | - $note_type = sanitize_text_field( $_POST['note_type'] ); |
|
123 | + $post_id = absint($_POST['post_id']); |
|
124 | + $note = wp_kses_post(trim(stripslashes($_POST['note']))); |
|
125 | + $note_type = sanitize_text_field($_POST['note_type']); |
|
126 | 126 | |
127 | 127 | $is_customer_note = $note_type == 'customer' ? 1 : 0; |
128 | 128 | |
129 | - if ( $post_id > 0 ) { |
|
130 | - $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note ); |
|
129 | + if ($post_id > 0) { |
|
130 | + $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note); |
|
131 | 131 | |
132 | - if ( $note_id > 0 && !is_wp_error( $note_id ) ) { |
|
133 | - wpinv_get_invoice_note_line_item( $note_id ); |
|
132 | + if ($note_id > 0 && !is_wp_error($note_id)) { |
|
133 | + wpinv_get_invoice_note_line_item($note_id); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
@@ -138,16 +138,16 @@ discard block |
||
138 | 138 | } |
139 | 139 | |
140 | 140 | public static function delete_note() { |
141 | - check_ajax_referer( 'delete-invoice-note', '_nonce' ); |
|
141 | + check_ajax_referer('delete-invoice-note', '_nonce'); |
|
142 | 142 | |
143 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
143 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
144 | 144 | die(-1); |
145 | 145 | } |
146 | 146 | |
147 | - $note_id = (int)$_POST['note_id']; |
|
147 | + $note_id = (int) $_POST['note_id']; |
|
148 | 148 | |
149 | - if ( $note_id > 0 ) { |
|
150 | - wp_delete_comment( $note_id, true ); |
|
149 | + if ($note_id > 0) { |
|
150 | + wp_delete_comment($note_id, true); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | die(); |
@@ -165,34 +165,34 @@ discard block |
||
165 | 165 | public static function get_billing_details() { |
166 | 166 | |
167 | 167 | // Verify nonce. |
168 | - check_ajax_referer( 'wpinv-nonce' ); |
|
168 | + check_ajax_referer('wpinv-nonce'); |
|
169 | 169 | |
170 | 170 | // Can the user manage the plugin? |
171 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
171 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
172 | 172 | die(-1); |
173 | 173 | } |
174 | 174 | |
175 | 175 | // Do we have a user id? |
176 | 176 | $user_id = $_GET['user_id']; |
177 | 177 | |
178 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
178 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
179 | 179 | die(-1); |
180 | 180 | } |
181 | 181 | |
182 | 182 | // Fetch the billing details. |
183 | - $billing_details = wpinv_get_user_address( $user_id ); |
|
184 | - $billing_details = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id ); |
|
183 | + $billing_details = wpinv_get_user_address($user_id); |
|
184 | + $billing_details = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id); |
|
185 | 185 | |
186 | 186 | // unset the user id and email. |
187 | - $to_ignore = array( 'user_id', 'email' ); |
|
187 | + $to_ignore = array('user_id', 'email'); |
|
188 | 188 | |
189 | - foreach ( $to_ignore as $key ) { |
|
190 | - if ( isset( $billing_details[ $key ] ) ) { |
|
191 | - unset( $billing_details[ $key ] ); |
|
189 | + foreach ($to_ignore as $key) { |
|
190 | + if (isset($billing_details[$key])) { |
|
191 | + unset($billing_details[$key]); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | - wp_send_json_success( $billing_details ); |
|
195 | + wp_send_json_success($billing_details); |
|
196 | 196 | |
197 | 197 | } |
198 | 198 | |
@@ -202,47 +202,47 @@ discard block |
||
202 | 202 | public static function check_new_user_email() { |
203 | 203 | |
204 | 204 | // Verify nonce. |
205 | - check_ajax_referer( 'wpinv-nonce' ); |
|
205 | + check_ajax_referer('wpinv-nonce'); |
|
206 | 206 | |
207 | 207 | // Can the user manage the plugin? |
208 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
208 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
209 | 209 | die(-1); |
210 | 210 | } |
211 | 211 | |
212 | 212 | // We need an email address. |
213 | - if ( empty( $_GET['email'] ) ) { |
|
214 | - _e( "Provide the new user's email address", 'invoicing' ); |
|
213 | + if (empty($_GET['email'])) { |
|
214 | + _e("Provide the new user's email address", 'invoicing'); |
|
215 | 215 | exit; |
216 | 216 | } |
217 | 217 | |
218 | 218 | // Ensure the email is valid. |
219 | - $email = sanitize_text_field( $_GET['email'] ); |
|
220 | - if ( ! is_email( $email ) ) { |
|
221 | - _e( 'Invalid email address', 'invoicing' ); |
|
219 | + $email = sanitize_text_field($_GET['email']); |
|
220 | + if (!is_email($email)) { |
|
221 | + _e('Invalid email address', 'invoicing'); |
|
222 | 222 | exit; |
223 | 223 | } |
224 | 224 | |
225 | 225 | // And it does not exist. |
226 | - if ( email_exists( $email ) ) { |
|
227 | - _e( 'A user with this email address already exists', 'invoicing' ); |
|
226 | + if (email_exists($email)) { |
|
227 | + _e('A user with this email address already exists', 'invoicing'); |
|
228 | 228 | exit; |
229 | 229 | } |
230 | 230 | |
231 | - wp_send_json_success( true ); |
|
231 | + wp_send_json_success(true); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | public static function run_tool() { |
235 | - check_ajax_referer( 'wpinv-nonce', '_nonce' ); |
|
236 | - if ( !wpinv_current_user_can_manage_invoicing() ) { |
|
235 | + check_ajax_referer('wpinv-nonce', '_nonce'); |
|
236 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
237 | 237 | die(-1); |
238 | 238 | } |
239 | 239 | |
240 | - $tool = sanitize_text_field( $_POST['tool'] ); |
|
240 | + $tool = sanitize_text_field($_POST['tool']); |
|
241 | 241 | |
242 | - do_action( 'wpinv_run_tool' ); |
|
242 | + do_action('wpinv_run_tool'); |
|
243 | 243 | |
244 | - if ( !empty( $tool ) ) { |
|
245 | - do_action( 'wpinv_tool_' . $tool ); |
|
244 | + if (!empty($tool)) { |
|
245 | + do_action('wpinv_tool_' . $tool); |
|
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
@@ -252,27 +252,27 @@ discard block |
||
252 | 252 | public static function get_payment_form() { |
253 | 253 | |
254 | 254 | // Check nonce. |
255 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
255 | + check_ajax_referer('getpaid_form_nonce'); |
|
256 | 256 | |
257 | 257 | // Is the request set up correctly? |
258 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
258 | + if (empty($_GET['form']) && empty($_GET['item'])) { |
|
259 | 259 | echo aui()->alert( |
260 | 260 | array( |
261 | 261 | 'type' => 'warning', |
262 | - 'content' => __( 'No payment form or item provided', 'invoicing' ), |
|
262 | + 'content' => __('No payment form or item provided', 'invoicing'), |
|
263 | 263 | ) |
264 | 264 | ); |
265 | 265 | exit; |
266 | 266 | } |
267 | 267 | |
268 | 268 | // Payment form or button? |
269 | - if ( ! empty( $_GET['form'] ) ) { |
|
270 | - getpaid_display_payment_form( urldecode( $_GET['form'] ) ); |
|
271 | - } else if( ! empty( $_GET['invoice'] ) ) { |
|
272 | - getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) ); |
|
269 | + if (!empty($_GET['form'])) { |
|
270 | + getpaid_display_payment_form(urldecode($_GET['form'])); |
|
271 | + } else if (!empty($_GET['invoice'])) { |
|
272 | + getpaid_display_invoice_payment_form(urldecode($_GET['invoice'])); |
|
273 | 273 | } else { |
274 | - $items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) ); |
|
275 | - getpaid_display_item_payment_form( $items ); |
|
274 | + $items = getpaid_convert_items_to_array(urldecode($_GET['item'])); |
|
275 | + getpaid_display_item_payment_form($items); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | exit; |
@@ -287,17 +287,17 @@ discard block |
||
287 | 287 | public static function payment_form() { |
288 | 288 | |
289 | 289 | // Check nonce. |
290 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
290 | + check_ajax_referer('getpaid_form_nonce'); |
|
291 | 291 | |
292 | 292 | // ... form fields... |
293 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
294 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
293 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
294 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
295 | 295 | exit; |
296 | 296 | } |
297 | 297 | |
298 | 298 | // Process the payment form. |
299 | - $checkout_class = apply_filters( 'getpaid_checkout_class', 'GetPaid_Checkout' ); |
|
300 | - $checkout = new $checkout_class( new GetPaid_Payment_Form_Submission() ); |
|
299 | + $checkout_class = apply_filters('getpaid_checkout_class', 'GetPaid_Checkout'); |
|
300 | + $checkout = new $checkout_class(new GetPaid_Payment_Form_Submission()); |
|
301 | 301 | $checkout->process_checkout(); |
302 | 302 | |
303 | 303 | exit; |
@@ -310,55 +310,55 @@ discard block |
||
310 | 310 | */ |
311 | 311 | public static function get_payment_form_states_field() { |
312 | 312 | |
313 | - if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) { |
|
313 | + if (empty($_GET['country']) || empty($_GET['form'])) { |
|
314 | 314 | exit; |
315 | 315 | } |
316 | 316 | |
317 | - $elements = getpaid_get_payment_form_elements( $_GET['form'] ); |
|
317 | + $elements = getpaid_get_payment_form_elements($_GET['form']); |
|
318 | 318 | |
319 | - if ( empty( $elements ) ) { |
|
319 | + if (empty($elements)) { |
|
320 | 320 | exit; |
321 | 321 | } |
322 | 322 | |
323 | 323 | $address_fields = array(); |
324 | - foreach ( $elements as $element ) { |
|
325 | - if ( 'address' === $element['type'] ) { |
|
324 | + foreach ($elements as $element) { |
|
325 | + if ('address' === $element['type']) { |
|
326 | 326 | $address_fields = $element; |
327 | 327 | break; |
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
331 | - if ( empty( $address_fields ) ) { |
|
331 | + if (empty($address_fields)) { |
|
332 | 332 | exit; |
333 | 333 | } |
334 | 334 | |
335 | - foreach ( $address_fields['fields'] as $address_field ) { |
|
335 | + foreach ($address_fields['fields'] as $address_field) { |
|
336 | 336 | |
337 | - if ( 'wpinv_state' == $address_field['name'] ) { |
|
337 | + if ('wpinv_state' == $address_field['name']) { |
|
338 | 338 | |
339 | - $wrap_class = getpaid_get_form_element_grid_class( $address_field ); |
|
340 | - $wrap_class = esc_attr( "$wrap_class getpaid-address-field-wrapper" ); |
|
341 | - $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] ); |
|
342 | - $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] ); |
|
343 | - $value = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_state', true ) : ''; |
|
344 | - $label = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] ); |
|
339 | + $wrap_class = getpaid_get_form_element_grid_class($address_field); |
|
340 | + $wrap_class = esc_attr("$wrap_class getpaid-address-field-wrapper"); |
|
341 | + $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']); |
|
342 | + $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']); |
|
343 | + $value = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_state', true) : ''; |
|
344 | + $label = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']); |
|
345 | 345 | |
346 | - if ( ! empty( $address_field['required'] ) ) { |
|
346 | + if (!empty($address_field['required'])) { |
|
347 | 347 | $label .= "<span class='text-danger'> *</span>"; |
348 | 348 | } |
349 | 349 | |
350 | - $html = getpaid_get_states_select_markup ( |
|
351 | - sanitize_text_field( $_GET['country'] ), |
|
350 | + $html = getpaid_get_states_select_markup( |
|
351 | + sanitize_text_field($_GET['country']), |
|
352 | 352 | $value, |
353 | 353 | $placeholder, |
354 | 354 | $label, |
355 | 355 | $description, |
356 | - ! empty( $address_field['required'] ), |
|
356 | + !empty($address_field['required']), |
|
357 | 357 | $wrap_class, |
358 | - wpinv_clean( $_GET['name'] ) |
|
358 | + wpinv_clean($_GET['name']) |
|
359 | 359 | ); |
360 | 360 | |
361 | - wp_send_json_success( $html ); |
|
361 | + wp_send_json_success($html); |
|
362 | 362 | exit; |
363 | 363 | |
364 | 364 | } |
@@ -374,56 +374,56 @@ discard block |
||
374 | 374 | public static function recalculate_invoice_totals() { |
375 | 375 | |
376 | 376 | // Verify nonce. |
377 | - check_ajax_referer( 'wpinv-nonce' ); |
|
377 | + check_ajax_referer('wpinv-nonce'); |
|
378 | 378 | |
379 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
379 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
380 | 380 | exit; |
381 | 381 | } |
382 | 382 | |
383 | 383 | // We need an invoice. |
384 | - if ( empty( $_POST['post_id'] ) ) { |
|
384 | + if (empty($_POST['post_id'])) { |
|
385 | 385 | exit; |
386 | 386 | } |
387 | 387 | |
388 | 388 | // Fetch the invoice. |
389 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
389 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
390 | 390 | |
391 | 391 | // Ensure it exists. |
392 | - if ( ! $invoice->get_id() ) { |
|
392 | + if (!$invoice->get_id()) { |
|
393 | 393 | exit; |
394 | 394 | } |
395 | 395 | |
396 | 396 | // Maybe set the country, state, currency. |
397 | - foreach ( array( 'country', 'state', 'currency', 'vat_number' ) as $key ) { |
|
398 | - if ( isset( $_POST[ $key ] ) ) { |
|
397 | + foreach (array('country', 'state', 'currency', 'vat_number') as $key) { |
|
398 | + if (isset($_POST[$key])) { |
|
399 | 399 | $method = "set_$key"; |
400 | - $invoice->$method( sanitize_text_field( $_POST[ $key ] ) ); |
|
400 | + $invoice->$method(sanitize_text_field($_POST[$key])); |
|
401 | 401 | } |
402 | 402 | } |
403 | 403 | |
404 | 404 | // Maybe disable taxes. |
405 | - $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) ); |
|
405 | + $invoice->set_disable_taxes(!empty($_POST['taxes'])); |
|
406 | 406 | |
407 | 407 | // Recalculate totals. |
408 | 408 | $invoice->recalculate_total(); |
409 | 409 | |
410 | - $total = wpinv_price( $invoice->get_total(), $invoice->get_currency() ); |
|
410 | + $total = wpinv_price($invoice->get_total(), $invoice->get_currency()); |
|
411 | 411 | |
412 | - if ( $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) { |
|
413 | - $recurring_total = wpinv_price( $invoice->get_recurring_total(), $invoice->get_currency() ); |
|
414 | - $total .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>'; |
|
412 | + if ($invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) { |
|
413 | + $recurring_total = wpinv_price($invoice->get_recurring_total(), $invoice->get_currency()); |
|
414 | + $total .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>'; |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | $totals = array( |
418 | - 'subtotal' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ), |
|
419 | - 'discount' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ), |
|
420 | - 'tax' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ), |
|
418 | + 'subtotal' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()), |
|
419 | + 'discount' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()), |
|
420 | + 'tax' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()), |
|
421 | 421 | 'total' => $total, |
422 | 422 | ); |
423 | 423 | |
424 | - $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice ); |
|
424 | + $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice); |
|
425 | 425 | |
426 | - wp_send_json_success( compact( 'totals' ) ); |
|
426 | + wp_send_json_success(compact('totals')); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | /** |
@@ -432,33 +432,33 @@ discard block |
||
432 | 432 | public static function get_invoice_items() { |
433 | 433 | |
434 | 434 | // Verify nonce. |
435 | - check_ajax_referer( 'wpinv-nonce' ); |
|
435 | + check_ajax_referer('wpinv-nonce'); |
|
436 | 436 | |
437 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
437 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
438 | 438 | exit; |
439 | 439 | } |
440 | 440 | |
441 | 441 | // We need an invoice and items. |
442 | - if ( empty( $_POST['post_id'] ) ) { |
|
442 | + if (empty($_POST['post_id'])) { |
|
443 | 443 | exit; |
444 | 444 | } |
445 | 445 | |
446 | 446 | // Fetch the invoice. |
447 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
447 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
448 | 448 | |
449 | 449 | // Ensure it exists. |
450 | - if ( ! $invoice->get_id() ) { |
|
450 | + if (!$invoice->get_id()) { |
|
451 | 451 | exit; |
452 | 452 | } |
453 | 453 | |
454 | 454 | // Return an array of invoice items. |
455 | 455 | $items = array(); |
456 | 456 | |
457 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
458 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency(), $invoice->is_renewal() ); |
|
457 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
458 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency(), $invoice->is_renewal()); |
|
459 | 459 | } |
460 | 460 | |
461 | - wp_send_json_success( compact( 'items' ) ); |
|
461 | + wp_send_json_success(compact('items')); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
@@ -467,50 +467,50 @@ discard block |
||
467 | 467 | public static function edit_invoice_item() { |
468 | 468 | |
469 | 469 | // Verify nonce. |
470 | - check_ajax_referer( 'wpinv-nonce' ); |
|
470 | + check_ajax_referer('wpinv-nonce'); |
|
471 | 471 | |
472 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
472 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
473 | 473 | exit; |
474 | 474 | } |
475 | 475 | |
476 | 476 | // We need an invoice and item details. |
477 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) { |
|
477 | + if (empty($_POST['post_id']) || empty($_POST['data'])) { |
|
478 | 478 | exit; |
479 | 479 | } |
480 | 480 | |
481 | 481 | // Fetch the invoice. |
482 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
482 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
483 | 483 | |
484 | 484 | // Ensure it exists and its not been paid for. |
485 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
485 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
486 | 486 | exit; |
487 | 487 | } |
488 | 488 | |
489 | 489 | // Format the data. |
490 | - $data = wp_list_pluck( $_POST['data'], 'value', 'field' ); |
|
490 | + $data = wp_list_pluck($_POST['data'], 'value', 'field'); |
|
491 | 491 | |
492 | 492 | // Ensure that we have an item id. |
493 | - if ( empty( $data['id'] ) ) { |
|
493 | + if (empty($data['id'])) { |
|
494 | 494 | exit; |
495 | 495 | } |
496 | 496 | |
497 | 497 | // Abort if the invoice does not have the specified item. |
498 | - $item = $invoice->get_item( (int) $data['id'] ); |
|
498 | + $item = $invoice->get_item((int) $data['id']); |
|
499 | 499 | |
500 | - if ( empty( $item ) ) { |
|
500 | + if (empty($item)) { |
|
501 | 501 | exit; |
502 | 502 | } |
503 | 503 | |
504 | 504 | // Update the item. |
505 | - $item->set_price( $data['price'] ); |
|
506 | - $item->set_name( $data['name'] ); |
|
507 | - $item->set_description( $data['description'] ); |
|
508 | - $item->set_quantity( $data['quantity'] ); |
|
505 | + $item->set_price($data['price']); |
|
506 | + $item->set_name($data['name']); |
|
507 | + $item->set_description($data['description']); |
|
508 | + $item->set_quantity($data['quantity']); |
|
509 | 509 | |
510 | 510 | // Add it to the invoice. |
511 | - $error = $invoice->add_item( $item ); |
|
511 | + $error = $invoice->add_item($item); |
|
512 | 512 | $alert = false; |
513 | - if ( is_wp_error( $error ) ) { |
|
513 | + if (is_wp_error($error)) { |
|
514 | 514 | $alert = $error->get_error_message(); |
515 | 515 | } |
516 | 516 | |
@@ -523,11 +523,11 @@ discard block |
||
523 | 523 | // Return an array of invoice items. |
524 | 524 | $items = array(); |
525 | 525 | |
526 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
527 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
526 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
527 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
528 | 528 | } |
529 | 529 | |
530 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
530 | + wp_send_json_success(compact('items', 'alert')); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | /** |
@@ -536,33 +536,33 @@ discard block |
||
536 | 536 | public static function remove_invoice_item() { |
537 | 537 | |
538 | 538 | // Verify nonce. |
539 | - check_ajax_referer( 'wpinv-nonce' ); |
|
539 | + check_ajax_referer('wpinv-nonce'); |
|
540 | 540 | |
541 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
541 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
542 | 542 | exit; |
543 | 543 | } |
544 | 544 | |
545 | 545 | // We need an invoice and an item. |
546 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) { |
|
546 | + if (empty($_POST['post_id']) || empty($_POST['item_id'])) { |
|
547 | 547 | exit; |
548 | 548 | } |
549 | 549 | |
550 | 550 | // Fetch the invoice. |
551 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
551 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
552 | 552 | |
553 | 553 | // Ensure it exists and its not been paid for. |
554 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
554 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
555 | 555 | exit; |
556 | 556 | } |
557 | 557 | |
558 | 558 | // Abort if the invoice does not have the specified item. |
559 | - $item = $invoice->get_item( (int) $_POST['item_id'] ); |
|
559 | + $item = $invoice->get_item((int) $_POST['item_id']); |
|
560 | 560 | |
561 | - if ( empty( $item ) ) { |
|
561 | + if (empty($item)) { |
|
562 | 562 | exit; |
563 | 563 | } |
564 | 564 | |
565 | - $invoice->remove_item( (int) $_POST['item_id'] ); |
|
565 | + $invoice->remove_item((int) $_POST['item_id']); |
|
566 | 566 | |
567 | 567 | // Update totals. |
568 | 568 | $invoice->recalculate_total(); |
@@ -573,11 +573,11 @@ discard block |
||
573 | 573 | // Return an array of invoice items. |
574 | 574 | $items = array(); |
575 | 575 | |
576 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
577 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
576 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
577 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
578 | 578 | } |
579 | 579 | |
580 | - wp_send_json_success( compact( 'items' ) ); |
|
580 | + wp_send_json_success(compact('items')); |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | /** |
@@ -586,39 +586,39 @@ discard block |
||
586 | 586 | public static function add_invoice_items() { |
587 | 587 | |
588 | 588 | // Verify nonce. |
589 | - check_ajax_referer( 'wpinv-nonce' ); |
|
589 | + check_ajax_referer('wpinv-nonce'); |
|
590 | 590 | |
591 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
591 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
592 | 592 | exit; |
593 | 593 | } |
594 | 594 | |
595 | 595 | // We need an invoice and items. |
596 | - if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) { |
|
596 | + if (empty($_POST['post_id']) || empty($_POST['items'])) { |
|
597 | 597 | exit; |
598 | 598 | } |
599 | 599 | |
600 | 600 | // Fetch the invoice. |
601 | - $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) ); |
|
601 | + $invoice = new WPInv_Invoice(trim($_POST['post_id'])); |
|
602 | 602 | $alert = false; |
603 | 603 | |
604 | 604 | // Ensure it exists and its not been paid for. |
605 | - if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) { |
|
605 | + if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) { |
|
606 | 606 | exit; |
607 | 607 | } |
608 | 608 | |
609 | 609 | // Add the items. |
610 | - foreach ( $_POST['items'] as $data ) { |
|
610 | + foreach ($_POST['items'] as $data) { |
|
611 | 611 | |
612 | - $item = new GetPaid_Form_Item( $data[ 'id' ] ); |
|
612 | + $item = new GetPaid_Form_Item($data['id']); |
|
613 | 613 | |
614 | - if ( is_numeric( $data[ 'qty' ] ) && (float) $data[ 'qty' ] > 0 ) { |
|
615 | - $item->set_quantity( $data[ 'qty' ] ); |
|
614 | + if (is_numeric($data['qty']) && (float) $data['qty'] > 0) { |
|
615 | + $item->set_quantity($data['qty']); |
|
616 | 616 | } |
617 | 617 | |
618 | - if ( $item->get_id() > 0 ) { |
|
619 | - $error = $invoice->add_item( $item ); |
|
618 | + if ($item->get_id() > 0) { |
|
619 | + $error = $invoice->add_item($item); |
|
620 | 620 | |
621 | - if ( is_wp_error( $error ) ) { |
|
621 | + if (is_wp_error($error)) { |
|
622 | 622 | $alert = $error->get_error_message(); |
623 | 623 | } |
624 | 624 | |
@@ -633,11 +633,11 @@ discard block |
||
633 | 633 | // Return an array of invoice items. |
634 | 634 | $items = array(); |
635 | 635 | |
636 | - foreach ( $invoice->get_items() as $item_id => $item ) { |
|
637 | - $items[ $item_id ] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() ); |
|
636 | + foreach ($invoice->get_items() as $item_id => $item) { |
|
637 | + $items[$item_id] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency()); |
|
638 | 638 | } |
639 | 639 | |
640 | - wp_send_json_success( compact( 'items', 'alert' ) ); |
|
640 | + wp_send_json_success(compact('items', 'alert')); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | /** |
@@ -646,15 +646,15 @@ discard block |
||
646 | 646 | public static function get_invoicing_items() { |
647 | 647 | |
648 | 648 | // Verify nonce. |
649 | - check_ajax_referer( 'wpinv-nonce' ); |
|
649 | + check_ajax_referer('wpinv-nonce'); |
|
650 | 650 | |
651 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
651 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
652 | 652 | exit; |
653 | 653 | } |
654 | 654 | |
655 | 655 | // We need a search term. |
656 | - if ( empty( $_GET['search'] ) ) { |
|
657 | - wp_send_json_success( array() ); |
|
656 | + if (empty($_GET['search'])) { |
|
657 | + wp_send_json_success(array()); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | // Retrieve items. |
@@ -663,8 +663,8 @@ discard block |
||
663 | 663 | 'orderby' => 'title', |
664 | 664 | 'order' => 'ASC', |
665 | 665 | 'posts_per_page' => -1, |
666 | - 'post_status' => array( 'publish' ), |
|
667 | - 's' => trim( $_GET['search'] ), |
|
666 | + 'post_status' => array('publish'), |
|
667 | + 's' => trim($_GET['search']), |
|
668 | 668 | 'meta_query' => array( |
669 | 669 | array( |
670 | 670 | 'key' => '_wpinv_type', |
@@ -674,22 +674,22 @@ discard block |
||
674 | 674 | ) |
675 | 675 | ); |
676 | 676 | |
677 | - $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) ); |
|
677 | + $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args)); |
|
678 | 678 | $data = array(); |
679 | 679 | |
680 | 680 | |
681 | - $is_payment_form = ( ! empty( $_GET['post_id'] ) && 'wpi_payment_form' == get_post_type( $_GET['post_id'] ) ); |
|
681 | + $is_payment_form = (!empty($_GET['post_id']) && 'wpi_payment_form' == get_post_type($_GET['post_id'])); |
|
682 | 682 | |
683 | - foreach ( $items as $item ) { |
|
684 | - $item = new GetPaid_Form_Item( $item ); |
|
683 | + foreach ($items as $item) { |
|
684 | + $item = new GetPaid_Form_Item($item); |
|
685 | 685 | $data[] = array( |
686 | 686 | 'id' => (int) $item->get_id(), |
687 | - 'text' => strip_tags( $item->get_name() ), |
|
688 | - 'form_data' => $is_payment_form ? $item->prepare_data_for_use( false ) : '', |
|
687 | + 'text' => strip_tags($item->get_name()), |
|
688 | + 'form_data' => $is_payment_form ? $item->prepare_data_for_use(false) : '', |
|
689 | 689 | ); |
690 | 690 | } |
691 | 691 | |
692 | - wp_send_json_success( $data ); |
|
692 | + wp_send_json_success($data); |
|
693 | 693 | |
694 | 694 | } |
695 | 695 | |
@@ -699,28 +699,28 @@ discard block |
||
699 | 699 | public static function get_aui_states_field() { |
700 | 700 | |
701 | 701 | // Verify nonce. |
702 | - check_ajax_referer( 'wpinv-nonce' ); |
|
702 | + check_ajax_referer('wpinv-nonce'); |
|
703 | 703 | |
704 | 704 | // We need a country. |
705 | - if ( empty( $_GET['country'] ) ) { |
|
705 | + if (empty($_GET['country'])) { |
|
706 | 706 | exit; |
707 | 707 | } |
708 | 708 | |
709 | - $states = wpinv_get_country_states( sanitize_text_field( $_GET['country'] ) ); |
|
710 | - $state = isset( $_GET['state'] ) ? sanitize_text_field( $_GET['state'] ) : wpinv_get_default_state(); |
|
711 | - $name = isset( $_GET['name'] ) ? sanitize_text_field( $_GET['name'] ) : 'wpinv_state'; |
|
712 | - $class = isset( $_GET['class'] ) ? sanitize_text_field( $_GET['class'] ) : 'form-control-sm'; |
|
709 | + $states = wpinv_get_country_states(sanitize_text_field($_GET['country'])); |
|
710 | + $state = isset($_GET['state']) ? sanitize_text_field($_GET['state']) : wpinv_get_default_state(); |
|
711 | + $name = isset($_GET['name']) ? sanitize_text_field($_GET['name']) : 'wpinv_state'; |
|
712 | + $class = isset($_GET['class']) ? sanitize_text_field($_GET['class']) : 'form-control-sm'; |
|
713 | 713 | |
714 | - if ( empty( $states ) ) { |
|
714 | + if (empty($states)) { |
|
715 | 715 | |
716 | 716 | $html = aui()->input( |
717 | 717 | array( |
718 | 718 | 'type' => 'text', |
719 | 719 | 'id' => 'wpinv_state', |
720 | 720 | 'name' => $name, |
721 | - 'label' => __( 'State', 'invoicing' ), |
|
721 | + 'label' => __('State', 'invoicing'), |
|
722 | 722 | 'label_type' => 'vertical', |
723 | - 'placeholder' => __( 'State', 'invoicing' ), |
|
723 | + 'placeholder' => __('State', 'invoicing'), |
|
724 | 724 | 'class' => $class, |
725 | 725 | 'value' => $state, |
726 | 726 | ) |
@@ -732,9 +732,9 @@ discard block |
||
732 | 732 | array( |
733 | 733 | 'id' => 'wpinv_state', |
734 | 734 | 'name' => $name, |
735 | - 'label' => __( 'State', 'invoicing' ), |
|
735 | + 'label' => __('State', 'invoicing'), |
|
736 | 736 | 'label_type' => 'vertical', |
737 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
737 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
738 | 738 | 'class' => $class, |
739 | 739 | 'value' => $state, |
740 | 740 | 'options' => $states, |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | wp_send_json_success( |
749 | 749 | array( |
750 | 750 | 'html' => $html, |
751 | - 'select' => ! empty ( $states ) |
|
751 | + 'select' => !empty ($states) |
|
752 | 752 | ) |
753 | 753 | ); |
754 | 754 | |
@@ -762,11 +762,11 @@ discard block |
||
762 | 762 | public static function payment_form_refresh_prices() { |
763 | 763 | |
764 | 764 | // Check nonce. |
765 | - check_ajax_referer( 'getpaid_form_nonce' ); |
|
765 | + check_ajax_referer('getpaid_form_nonce'); |
|
766 | 766 | |
767 | 767 | // ... form fields... |
768 | - if ( empty( $_POST['getpaid_payment_form_submission'] ) ) { |
|
769 | - _e( 'Error: Reload the page and try again.', 'invoicing' ); |
|
768 | + if (empty($_POST['getpaid_payment_form_submission'])) { |
|
769 | + _e('Error: Reload the page and try again.', 'invoicing'); |
|
770 | 770 | exit; |
771 | 771 | } |
772 | 772 | |
@@ -774,18 +774,18 @@ discard block |
||
774 | 774 | $submission = new GetPaid_Payment_Form_Submission(); |
775 | 775 | |
776 | 776 | // Do we have an error? |
777 | - if ( ! empty( $submission->last_error ) ) { |
|
777 | + if (!empty($submission->last_error)) { |
|
778 | 778 | echo $submission->last_error; |
779 | 779 | exit; |
780 | 780 | } |
781 | 781 | |
782 | 782 | // Prepare the response. |
783 | - $response = new GetPaid_Payment_Form_Submission_Refresh_Prices( $submission ); |
|
783 | + $response = new GetPaid_Payment_Form_Submission_Refresh_Prices($submission); |
|
784 | 784 | |
785 | 785 | // Filter the response. |
786 | - $response = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $response->response, $submission ); |
|
786 | + $response = apply_filters('getpaid_payment_form_ajax_refresh_prices', $response->response, $submission); |
|
787 | 787 | |
788 | - wp_send_json_success( $response ); |
|
788 | + wp_send_json_success($response); |
|
789 | 789 | } |
790 | 790 | |
791 | 791 | } |
@@ -7,116 +7,116 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -do_action( 'getpaid_before_payment_form_cart_item', $form, $item ); |
|
12 | +do_action('getpaid_before_payment_form_cart_item', $form, $item); |
|
13 | 13 | |
14 | 14 | $currency = $form->get_currency(); |
15 | 15 | |
16 | 16 | ?> |
17 | -<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo $item->get_id(); ?> border-bottom py-2 px-3'> |
|
17 | +<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo $item->get_id(); ?> border-bottom py-2 px-3'> |
|
18 | 18 | |
19 | 19 | <div class="form-row needs-validation"> |
20 | 20 | |
21 | - <?php foreach ( array_keys( $columns ) as $key ) : ?> |
|
21 | + <?php foreach (array_keys($columns) as $key) : ?> |
|
22 | 22 | |
23 | - <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> position-relative getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?> getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?>-<?php echo $item->get_id(); ?>"> |
|
23 | + <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> position-relative getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?> getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?>-<?php echo $item->get_id(); ?>"> |
|
24 | 24 | |
25 | 25 | <?php |
26 | 26 | |
27 | 27 | // Fires before printing a line item column. |
28 | - do_action( "getpaid_form_cart_item_before_$key", $item, $form ); |
|
28 | + do_action("getpaid_form_cart_item_before_$key", $item, $form); |
|
29 | 29 | |
30 | 30 | // Item name. |
31 | - if ( 'name' == $key ) { |
|
31 | + if ('name' == $key) { |
|
32 | 32 | |
33 | 33 | // Display the name. |
34 | - echo '<div class="mb-1">' . sanitize_text_field( $item->get_name() ) . '</div>'; |
|
34 | + echo '<div class="mb-1">' . sanitize_text_field($item->get_name()) . '</div>'; |
|
35 | 35 | |
36 | 36 | // And an optional description. |
37 | 37 | $description = $item->get_description(); |
38 | 38 | |
39 | - if ( ! empty( $description ) ) { |
|
40 | - $description = wp_kses_post( $description ); |
|
39 | + if (!empty($description)) { |
|
40 | + $description = wp_kses_post($description); |
|
41 | 41 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
42 | 42 | } |
43 | 43 | |
44 | 44 | // Price help text. |
45 | - $description = getpaid_item_recurring_price_help_text( $item, $currency ); |
|
46 | - if ( $description ) { |
|
45 | + $description = getpaid_item_recurring_price_help_text($item, $currency); |
|
46 | + if ($description) { |
|
47 | 47 | echo "<small class='getpaid-form-item-price-desc form-text text-muted pr-2 m-0'>$description</small>"; |
48 | 48 | } |
49 | 49 | |
50 | 50 | } |
51 | 51 | |
52 | 52 | // Item price. |
53 | - if ( 'price' == $key ) { |
|
53 | + if ('price' == $key) { |
|
54 | 54 | |
55 | 55 | // Set the currency position. |
56 | 56 | $position = wpinv_currency_position(); |
57 | 57 | |
58 | - if ( $position == 'left_space' ) { |
|
58 | + if ($position == 'left_space') { |
|
59 | 59 | $position = 'left'; |
60 | 60 | } |
61 | 61 | |
62 | - if ( $position == 'right_space' ) { |
|
62 | + if ($position == 'right_space') { |
|
63 | 63 | $position = 'right'; |
64 | 64 | } |
65 | 65 | |
66 | - if ( $item->user_can_set_their_price() ) { |
|
67 | - $price = max( (float) $item->get_price(), (float) $item->get_minimum_price() ); |
|
66 | + if ($item->user_can_set_their_price()) { |
|
67 | + $price = max((float) $item->get_price(), (float) $item->get_minimum_price()); |
|
68 | 68 | $minimum = (float) $item->get_minimum_price(); |
69 | 69 | $validate_minimum = ''; |
70 | 70 | $class = ''; |
71 | 71 | $data_minimum = ''; |
72 | 72 | |
73 | - if ( $minimum > 0 ) { |
|
73 | + if ($minimum > 0) { |
|
74 | 74 | $validate_minimum = sprintf( |
75 | - esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ), |
|
76 | - sanitize_text_field( wpinv_price( $minimum, $currency ) ) |
|
75 | + esc_attr__('The minimum allowed amount is %s', 'invoicing'), |
|
76 | + sanitize_text_field(wpinv_price($minimum, $currency)) |
|
77 | 77 | ); |
78 | 78 | |
79 | 79 | $class = 'getpaid-validate-minimum-amount'; |
80 | 80 | |
81 | - $data_minimum = "data-minimum-amount='$minimum'"; |
|
81 | + $data_minimum = "data-minimum-amount='$minimum'"; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | ?> |
85 | 85 | <div class="input-group input-group-sm"> |
86 | - <?php if( 'left' == $position ) : ?> |
|
86 | + <?php if ('left' == $position) : ?> |
|
87 | 87 | <div class="input-group-prepend"> |
88 | - <span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span> |
|
88 | + <span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span> |
|
89 | 89 | </div> |
90 | 90 | <?php endif; ?> |
91 | 91 | |
92 | - <input type="text" <?php echo $data_minimum; ?> name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo $price; ?>" placeholder="<?php echo esc_attr( $item->get_minimum_price() ); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border <?php echo $class; ?>" style="width: 64px; line-height: 1; min-height: 35px;"> |
|
92 | + <input type="text" <?php echo $data_minimum; ?> name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo $price; ?>" placeholder="<?php echo esc_attr($item->get_minimum_price()); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border <?php echo $class; ?>" style="width: 64px; line-height: 1; min-height: 35px;"> |
|
93 | 93 | |
94 | - <?php if ( ! empty( $validate_minimum ) ) : ?> |
|
94 | + <?php if (!empty($validate_minimum)) : ?> |
|
95 | 95 | <div class="invalid-tooltip"> |
96 | 96 | <?php echo $validate_minimum; ?> |
97 | 97 | </div> |
98 | 98 | <?php endif; ?> |
99 | 99 | |
100 | - <?php if( 'left' != $position ) : ?> |
|
100 | + <?php if ('left' != $position) : ?> |
|
101 | 101 | <div class="input-group-append"> |
102 | - <span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span> |
|
102 | + <span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span> |
|
103 | 103 | </div> |
104 | 104 | <?php endif; ?> |
105 | 105 | </div> |
106 | 106 | |
107 | 107 | <?php |
108 | 108 | } else { |
109 | - echo wpinv_price( $item->get_price(), $currency ); |
|
109 | + echo wpinv_price($item->get_price(), $currency); |
|
110 | 110 | ?> |
111 | - <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'> |
|
111 | + <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr($item->get_price()); ?>'> |
|
112 | 112 | <?php |
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | 116 | // Item quantity. |
117 | - if ( 'quantity' == $key ) { |
|
117 | + if ('quantity' == $key) { |
|
118 | 118 | |
119 | - if ( $item->allows_quantities() ) { |
|
119 | + if ($item->allows_quantities()) { |
|
120 | 120 | ?> |
121 | 121 | <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type='text' style='width: 64px; line-height: 1; min-height: 35px;' class='getpaid-item-quantity-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border' value='<?php echo (float) $item->get_quantity(); ?>' min='1' required> |
122 | 122 | <?php |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | // Item sub total. |
133 | - if ( 'subtotal' == $key ) { |
|
134 | - echo wpinv_price( $item->get_sub_total(), $currency ); |
|
133 | + if ('subtotal' == $key) { |
|
134 | + echo wpinv_price($item->get_sub_total(), $currency); |
|
135 | 135 | } |
136 | 136 | |
137 | - do_action( "getpaid_payment_form_cart_item_$key", $item, $form ); |
|
137 | + do_action("getpaid_payment_form_cart_item_$key", $item, $form); |
|
138 | 138 | ?> |
139 | 139 | |
140 | 140 | </div> |
@@ -145,4 +145,4 @@ discard block |
||
145 | 145 | |
146 | 146 | </div> |
147 | 147 | <?php |
148 | -do_action( 'getpaid_payment_form_cart_item', $form, $item ); |
|
148 | +do_action('getpaid_payment_form_cart_item', $form, $item); |
@@ -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,30 +46,30 @@ 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 | - 'initial_amt' => wpinv_round_amount( $submission->get_total(), null, true ), |
|
72 | + 'initial_amt' => wpinv_round_amount($submission->get_total(), null, true), |
|
73 | 73 | 'currency' => $submission->get_currency(), |
74 | 74 | |
75 | 75 | ) |
@@ -82,22 +82,22 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @param GetPaid_Payment_Form_Submission $submission |
84 | 84 | */ |
85 | - public function add_texts( $submission ) { |
|
85 | + public function add_texts($submission) { |
|
86 | 86 | |
87 | - $payable = $submission->format_amount( $submission->get_total() ); |
|
87 | + $payable = $submission->format_amount($submission->get_total()); |
|
88 | 88 | |
89 | - if ( $submission->has_recurring != 0 ) { |
|
89 | + if ($submission->has_recurring != 0) { |
|
90 | 90 | |
91 | - $recurring = new WPInv_Item( $submission->has_recurring ); |
|
92 | - $period = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' ); |
|
91 | + $recurring = new WPInv_Item($submission->has_recurring); |
|
92 | + $period = getpaid_get_subscription_period_label($recurring->get_recurring_period(true), $recurring->get_recurring_interval(), ''); |
|
93 | 93 | |
94 | - if ( $submission->get_total() == $submission->get_recurring_total() ) { |
|
94 | + if ($submission->get_total() == $submission->get_recurring_total()) { |
|
95 | 95 | $payable = "$payable / $period"; |
96 | 96 | } else { |
97 | 97 | $payable = sprintf( |
98 | - __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ), |
|
99 | - $submission->format_amount( $submission->get_total() ), |
|
100 | - $submission->format_amount( $submission->get_recurring_total() ), |
|
98 | + __('%1$s (renews at %2$s / %3$s)', 'invoicing'), |
|
99 | + $submission->format_amount($submission->get_total()), |
|
100 | + $submission->format_amount($submission->get_recurring_total()), |
|
101 | 101 | $period |
102 | 102 | ); |
103 | 103 | } |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | '.getpaid-checkout-total-payable' => $payable, |
109 | 109 | ); |
110 | 110 | |
111 | - foreach ( $submission->get_items() as $item_id => $item ) { |
|
112 | - $initial_price = $submission->format_amount( $this->standardize_price( $item->get_id(), $item->get_sub_total(), $submission->get_discount_code(), false ) ); |
|
113 | - $recurring_price = $submission->format_amount( $this->standardize_price( $item->get_id(), $item->get_recurring_sub_total(), $submission->get_discount_code(), true ) ); |
|
114 | - $texts[".item-$item_id .getpaid-form-item-price-desc"] = getpaid_item_recurring_price_help_text( $item, $submission->get_currency(), $initial_price, $recurring_price ); |
|
111 | + foreach ($submission->get_items() as $item_id => $item) { |
|
112 | + $initial_price = $submission->format_amount($this->standardize_price($item->get_id(), $item->get_sub_total(), $submission->get_discount_code(), false)); |
|
113 | + $recurring_price = $submission->format_amount($this->standardize_price($item->get_id(), $item->get_recurring_sub_total(), $submission->get_discount_code(), true)); |
|
114 | + $texts[".item-$item_id .getpaid-form-item-price-desc"] = getpaid_item_recurring_price_help_text($item, $submission->get_currency(), $initial_price, $recurring_price); |
|
115 | 115 | } |
116 | 116 | |
117 | - $this->response = array_merge( $this->response, array( 'texts' => $texts ) ); |
|
117 | + $this->response = array_merge($this->response, array('texts' => $texts)); |
|
118 | 118 | |
119 | 119 | } |
120 | 120 | |
@@ -123,18 +123,18 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @param GetPaid_Payment_Form_Submission $submission |
125 | 125 | */ |
126 | - public function add_items( $submission ) { |
|
126 | + public function add_items($submission) { |
|
127 | 127 | |
128 | 128 | // Add items. |
129 | 129 | $items = array(); |
130 | 130 | |
131 | - foreach ( $submission->get_items() as $item_id => $item ) { |
|
132 | - $items["$item_id"] = $submission->format_amount( $item->get_sub_total() ); |
|
131 | + foreach ($submission->get_items() as $item_id => $item) { |
|
132 | + $items["$item_id"] = $submission->format_amount($item->get_sub_total()); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | $this->response = array_merge( |
136 | 136 | $this->response, |
137 | - array( 'items' => $items ) |
|
137 | + array('items' => $items) |
|
138 | 138 | ); |
139 | 139 | |
140 | 140 | } |
@@ -144,17 +144,17 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @param GetPaid_Payment_Form_Submission $submission |
146 | 146 | */ |
147 | - public function add_fees( $submission ) { |
|
147 | + public function add_fees($submission) { |
|
148 | 148 | |
149 | 149 | $fees = array(); |
150 | 150 | |
151 | - foreach ( $submission->get_fees() as $name => $data ) { |
|
152 | - $fees[$name] = $submission->format_amount( $data['initial_fee'] ); |
|
151 | + foreach ($submission->get_fees() as $name => $data) { |
|
152 | + $fees[$name] = $submission->format_amount($data['initial_fee']); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | $this->response = array_merge( |
156 | 156 | $this->response, |
157 | - array( 'fees' => $fees ) |
|
157 | + array('fees' => $fees) |
|
158 | 158 | ); |
159 | 159 | |
160 | 160 | } |
@@ -164,17 +164,17 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @param GetPaid_Payment_Form_Submission $submission |
166 | 166 | */ |
167 | - public function add_discounts( $submission ) { |
|
167 | + public function add_discounts($submission) { |
|
168 | 168 | |
169 | 169 | $discounts = array(); |
170 | 170 | |
171 | - foreach ( $submission->get_discounts() as $name => $data ) { |
|
172 | - $discounts[$name] = $submission->format_amount( $data['initial_discount'] ); |
|
171 | + foreach ($submission->get_discounts() as $name => $data) { |
|
172 | + $discounts[$name] = $submission->format_amount($data['initial_discount']); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | $this->response = array_merge( |
176 | 176 | $this->response, |
177 | - array( 'discounts' => $discounts ) |
|
177 | + array('discounts' => $discounts) |
|
178 | 178 | ); |
179 | 179 | |
180 | 180 | } |
@@ -184,24 +184,24 @@ discard block |
||
184 | 184 | * |
185 | 185 | * @param GetPaid_Payment_Form_Submission $submission |
186 | 186 | */ |
187 | - public function add_taxes( $submission ) { |
|
187 | + public function add_taxes($submission) { |
|
188 | 188 | |
189 | 189 | $taxes = array(); |
190 | 190 | $markup = ''; |
191 | - foreach ( $submission->get_taxes() as $name => $data ) { |
|
192 | - $name = sanitize_text_field( $name ); |
|
193 | - $amount = $submission->format_amount( $data['initial_tax'] ); |
|
191 | + foreach ($submission->get_taxes() as $name => $data) { |
|
192 | + $name = sanitize_text_field($name); |
|
193 | + $amount = $submission->format_amount($data['initial_tax']); |
|
194 | 194 | $taxes[$name] = $amount; |
195 | 195 | $markup .= "<small class='form-text'>$name : $amount</small>"; |
196 | 196 | } |
197 | 197 | |
198 | - if ( wpinv_display_individual_tax_rates() ) { |
|
198 | + if (wpinv_display_individual_tax_rates()) { |
|
199 | 199 | $this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup; |
200 | 200 | } |
201 | 201 | |
202 | 202 | $this->response = array_merge( |
203 | 203 | $this->response, |
204 | - array( 'taxes' => $taxes ) |
|
204 | + array('taxes' => $taxes) |
|
205 | 205 | ); |
206 | 206 | |
207 | 207 | } |
@@ -211,16 +211,16 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @param GetPaid_Payment_Form_Submission $submission |
213 | 213 | */ |
214 | - public function add_gateways( $submission ) { |
|
214 | + public function add_gateways($submission) { |
|
215 | 215 | |
216 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
216 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
217 | 217 | |
218 | - if ( $this->response['has_recurring'] ) { |
|
218 | + if ($this->response['has_recurring']) { |
|
219 | 219 | |
220 | - foreach ( $gateways as $i => $gateway ) { |
|
220 | + foreach ($gateways as $i => $gateway) { |
|
221 | 221 | |
222 | - if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
223 | - unset( $gateways[ $i ] ); |
|
222 | + if (!wpinv_gateway_support_subscription($gateway)) { |
|
223 | + unset($gateways[$i]); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | } |
@@ -228,10 +228,10 @@ discard block |
||
228 | 228 | } |
229 | 229 | |
230 | 230 | |
231 | - $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission ); |
|
231 | + $gateways = apply_filters('getpaid_submission_gateways', $gateways, $submission); |
|
232 | 232 | $this->response = array_merge( |
233 | 233 | $this->response, |
234 | - array( 'gateways' => $gateways ) |
|
234 | + array('gateways' => $gateways) |
|
235 | 235 | ); |
236 | 236 | |
237 | 237 | } |
@@ -244,22 +244,22 @@ discard block |
||
244 | 244 | * @param string $discount_code |
245 | 245 | * @param bool $recurring |
246 | 246 | */ |
247 | - public function standardize_price( $item_id, $item_total, $discount_code, $recurring = false ) { |
|
247 | + public function standardize_price($item_id, $item_total, $discount_code, $recurring = false) { |
|
248 | 248 | |
249 | 249 | $standardadized_price = $item_total; |
250 | 250 | |
251 | 251 | // Do we have a $discount_code? |
252 | - if ( ! empty( $discount_code ) ) { |
|
252 | + if (!empty($discount_code)) { |
|
253 | 253 | |
254 | - $discount = new WPInv_Discount( $discount_code ); |
|
254 | + $discount = new WPInv_Discount($discount_code); |
|
255 | 255 | |
256 | - if ( $discount->exists() && $discount->is_valid_for_items( $item_id ) && ( ! $recurring || $discount->is_recurring() ) ) { |
|
257 | - $standardadized_price = $item_total - $discount->get_discounted_amount( $item_total ); |
|
256 | + if ($discount->exists() && $discount->is_valid_for_items($item_id) && (!$recurring || $discount->is_recurring())) { |
|
257 | + $standardadized_price = $item_total - $discount->get_discounted_amount($item_total); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | } |
261 | 261 | |
262 | - return max( 0, $standardadized_price ); |
|
262 | + return max(0, $standardadized_price); |
|
263 | 263 | |
264 | 264 | } |
265 | 265 |
@@ -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 | * Retrieves an item by it's ID. |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | * @param int the item ID to retrieve. |
15 | 15 | * @return WPInv_Item|false |
16 | 16 | */ |
17 | -function wpinv_get_item_by_id( $id ) { |
|
18 | - $item = wpinv_get_item( $id ); |
|
19 | - return empty( $item ) || $id != $item->get_id() ? false : $item; |
|
17 | +function wpinv_get_item_by_id($id) { |
|
18 | + $item = wpinv_get_item($id); |
|
19 | + return empty($item) || $id != $item->get_id() ? false : $item; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return WPInv_Item|false |
26 | 26 | */ |
27 | -function wpinv_get_item_by( $field = '', $value = '', $type = '' ) { |
|
27 | +function wpinv_get_item_by($field = '', $value = '', $type = '') { |
|
28 | 28 | |
29 | - if ( 'id' == strtolower( $field ) ) { |
|
30 | - return wpinv_get_item_by_id( $field ); |
|
29 | + if ('id' == strtolower($field)) { |
|
30 | + return wpinv_get_item_by_id($field); |
|
31 | 31 | } |
32 | 32 | |
33 | - $id = WPInv_Item::get_item_id_by_field( $value, strtolower( $field ), $type ); |
|
34 | - return empty( $id ) ? false : wpinv_get_item( $id ); |
|
33 | + $id = WPInv_Item::get_item_id_by_field($value, strtolower($field), $type); |
|
34 | + return empty($id) ? false : wpinv_get_item($id); |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | |
@@ -41,22 +41,22 @@ discard block |
||
41 | 41 | * @param int|WPInv_Item the item to retrieve. |
42 | 42 | * @return WPInv_Item|false |
43 | 43 | */ |
44 | -function wpinv_get_item( $item = 0 ) { |
|
44 | +function wpinv_get_item($item = 0) { |
|
45 | 45 | |
46 | - if ( empty( $item ) ) { |
|
46 | + if (empty($item)) { |
|
47 | 47 | return false; |
48 | 48 | } |
49 | 49 | |
50 | - $item = new WPInv_Item( $item ); |
|
50 | + $item = new WPInv_Item($item); |
|
51 | 51 | return $item->exists() ? $item : false; |
52 | 52 | |
53 | 53 | } |
54 | 54 | |
55 | -function wpinv_get_all_items( $args = array() ) { |
|
55 | +function wpinv_get_all_items($args = array()) { |
|
56 | 56 | |
57 | - $args = wp_parse_args( $args, array( |
|
58 | - 'status' => array( 'publish' ), |
|
59 | - 'limit' => get_option( 'posts_per_page' ), |
|
57 | + $args = wp_parse_args($args, array( |
|
58 | + 'status' => array('publish'), |
|
59 | + 'limit' => get_option('posts_per_page'), |
|
60 | 60 | 'page' => 1, |
61 | 61 | 'exclude' => array(), |
62 | 62 | 'orderby' => 'date', |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | 'meta_query' => array(), |
66 | 66 | 'return' => 'objects', |
67 | 67 | 'paginate' => false, |
68 | - ) ); |
|
68 | + )); |
|
69 | 69 | |
70 | 70 | $wp_query_args = array( |
71 | 71 | 'post_type' => 'wpi_item', |
@@ -75,26 +75,26 @@ discard block |
||
75 | 75 | 'fields' => 'ids', |
76 | 76 | 'orderby' => $args['orderby'], |
77 | 77 | 'order' => $args['order'], |
78 | - 'paged' => absint( $args['page'] ), |
|
78 | + 'paged' => absint($args['page']), |
|
79 | 79 | ); |
80 | 80 | |
81 | - if ( ! empty( $args['exclude'] ) ) { |
|
82 | - $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] ); |
|
81 | + if (!empty($args['exclude'])) { |
|
82 | + $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']); |
|
83 | 83 | } |
84 | 84 | |
85 | - if ( ! $args['paginate' ] ) { |
|
85 | + if (!$args['paginate']) { |
|
86 | 86 | $wp_query_args['no_found_rows'] = true; |
87 | 87 | } |
88 | 88 | |
89 | - if ( ! empty( $args['search'] ) ) { |
|
89 | + if (!empty($args['search'])) { |
|
90 | 90 | $wp_query_args['s'] = $args['search']; |
91 | 91 | } |
92 | 92 | |
93 | - if ( ! empty( $args['type'] ) && $args['type'] !== wpinv_item_types() ) { |
|
94 | - $types = wpinv_parse_list( $args['type'] ); |
|
93 | + if (!empty($args['type']) && $args['type'] !== wpinv_item_types()) { |
|
94 | + $types = wpinv_parse_list($args['type']); |
|
95 | 95 | $wp_query_args['meta_query'][] = array( |
96 | 96 | 'key' => '_wpinv_type', |
97 | - 'value' => implode( ',', $types ), |
|
97 | + 'value' => implode(',', $types), |
|
98 | 98 | 'compare' => 'IN', |
99 | 99 | ); |
100 | 100 | } |
@@ -102,17 +102,17 @@ discard block |
||
102 | 102 | $wp_query_args = apply_filters('wpinv_get_items_args', $wp_query_args, $args); |
103 | 103 | |
104 | 104 | // Get results. |
105 | - $items = new WP_Query( $wp_query_args ); |
|
105 | + $items = new WP_Query($wp_query_args); |
|
106 | 106 | |
107 | - if ( 'objects' === $args['return'] ) { |
|
108 | - $return = array_map( 'wpinv_get_item_by_id', $items->posts ); |
|
109 | - } elseif ( 'self' === $args['return'] ) { |
|
107 | + if ('objects' === $args['return']) { |
|
108 | + $return = array_map('wpinv_get_item_by_id', $items->posts); |
|
109 | + } elseif ('self' === $args['return']) { |
|
110 | 110 | return $items; |
111 | 111 | } else { |
112 | 112 | $return = $items->posts; |
113 | 113 | } |
114 | 114 | |
115 | - if ( $args['paginate' ] ) { |
|
115 | + if ($args['paginate']) { |
|
116 | 116 | return (object) array( |
117 | 117 | 'items' => $return, |
118 | 118 | 'total' => $items->found_posts, |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | |
125 | 125 | } |
126 | 126 | |
127 | -function wpinv_is_free_item( $item_id = 0 ) { |
|
128 | - if( empty( $item_id ) ) { |
|
127 | +function wpinv_is_free_item($item_id = 0) { |
|
128 | + if (empty($item_id)) { |
|
129 | 129 | return false; |
130 | 130 | } |
131 | 131 | |
132 | - $item = new WPInv_Item( $item_id ); |
|
132 | + $item = new WPInv_Item($item_id); |
|
133 | 133 | |
134 | 134 | return $item->is_free(); |
135 | 135 | } |
@@ -139,21 +139,21 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @param WP_Post|WPInv_Item|Int $item The item to check for. |
141 | 141 | */ |
142 | -function wpinv_item_is_editable( $item = 0 ) { |
|
142 | +function wpinv_item_is_editable($item = 0) { |
|
143 | 143 | |
144 | 144 | // Fetch the item. |
145 | - $item = new WPInv_Item( $item ); |
|
145 | + $item = new WPInv_Item($item); |
|
146 | 146 | |
147 | 147 | // Check if it is editable. |
148 | 148 | return $item->is_editable(); |
149 | 149 | } |
150 | 150 | |
151 | -function wpinv_get_item_price( $item_id = 0 ) { |
|
152 | - if( empty( $item_id ) ) { |
|
151 | +function wpinv_get_item_price($item_id = 0) { |
|
152 | + if (empty($item_id)) { |
|
153 | 153 | return false; |
154 | 154 | } |
155 | 155 | |
156 | - $item = new WPInv_Item( $item_id ); |
|
156 | + $item = new WPInv_Item($item_id); |
|
157 | 157 | |
158 | 158 | return $item->get_price(); |
159 | 159 | } |
@@ -163,96 +163,96 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @param WPInv_Item|int $item |
165 | 165 | */ |
166 | -function wpinv_is_recurring_item( $item = 0 ) { |
|
167 | - $item = new WPInv_Item( $item ); |
|
166 | +function wpinv_is_recurring_item($item = 0) { |
|
167 | + $item = new WPInv_Item($item); |
|
168 | 168 | return $item->is_recurring(); |
169 | 169 | } |
170 | 170 | |
171 | -function wpinv_item_price( $item_id = 0 ) { |
|
172 | - if( empty( $item_id ) ) { |
|
171 | +function wpinv_item_price($item_id = 0) { |
|
172 | + if (empty($item_id)) { |
|
173 | 173 | return false; |
174 | 174 | } |
175 | 175 | |
176 | - $price = wpinv_get_item_price( $item_id ); |
|
177 | - $price = wpinv_price( $price ); |
|
176 | + $price = wpinv_get_item_price($item_id); |
|
177 | + $price = wpinv_price($price); |
|
178 | 178 | |
179 | - return apply_filters( 'wpinv_item_price', $price, $item_id ); |
|
179 | + return apply_filters('wpinv_item_price', $price, $item_id); |
|
180 | 180 | } |
181 | 181 | |
182 | -function wpinv_get_item_final_price( $item_id = 0, $amount_override = null ) { |
|
183 | - if ( is_null( $amount_override ) ) { |
|
184 | - $original_price = get_post_meta( $item_id, '_wpinv_price', true ); |
|
182 | +function wpinv_get_item_final_price($item_id = 0, $amount_override = null) { |
|
183 | + if (is_null($amount_override)) { |
|
184 | + $original_price = get_post_meta($item_id, '_wpinv_price', true); |
|
185 | 185 | } else { |
186 | 186 | $original_price = $amount_override; |
187 | 187 | } |
188 | 188 | |
189 | 189 | $price = $original_price; |
190 | 190 | |
191 | - return apply_filters( 'wpinv_get_item_final_price', $price, $item_id ); |
|
191 | + return apply_filters('wpinv_get_item_final_price', $price, $item_id); |
|
192 | 192 | } |
193 | 193 | |
194 | -function wpinv_item_custom_singular_name( $item_id ) { |
|
195 | - if( empty( $item_id ) ) { |
|
194 | +function wpinv_item_custom_singular_name($item_id) { |
|
195 | + if (empty($item_id)) { |
|
196 | 196 | return false; |
197 | 197 | } |
198 | 198 | |
199 | - $item = new WPInv_Item( $item_id ); |
|
199 | + $item = new WPInv_Item($item_id); |
|
200 | 200 | |
201 | 201 | return $item->get_custom_singular_name(); |
202 | 202 | } |
203 | 203 | |
204 | 204 | function wpinv_get_item_types() { |
205 | 205 | $item_types = array( |
206 | - 'custom' => __( 'Standard', 'invoicing' ), |
|
207 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
206 | + 'custom' => __('Standard', 'invoicing'), |
|
207 | + 'fee' => __('Fee', 'invoicing'), |
|
208 | 208 | ); |
209 | - return apply_filters( 'wpinv_get_item_types', $item_types ); |
|
209 | + return apply_filters('wpinv_get_item_types', $item_types); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | function wpinv_item_types() { |
213 | 213 | $item_types = wpinv_get_item_types(); |
214 | 214 | |
215 | - return ( !empty( $item_types ) ? array_keys( $item_types ) : array() ); |
|
215 | + return (!empty($item_types) ? array_keys($item_types) : array()); |
|
216 | 216 | } |
217 | 217 | |
218 | -function wpinv_get_item_type( $item_id ) { |
|
219 | - if( empty( $item_id ) ) { |
|
218 | +function wpinv_get_item_type($item_id) { |
|
219 | + if (empty($item_id)) { |
|
220 | 220 | return false; |
221 | 221 | } |
222 | 222 | |
223 | - $item = new WPInv_Item( $item_id ); |
|
223 | + $item = new WPInv_Item($item_id); |
|
224 | 224 | |
225 | 225 | return $item->get_type(); |
226 | 226 | } |
227 | 227 | |
228 | -function wpinv_item_type( $item_id ) { |
|
228 | +function wpinv_item_type($item_id) { |
|
229 | 229 | $item_types = wpinv_get_item_types(); |
230 | 230 | |
231 | - $item_type = wpinv_get_item_type( $item_id ); |
|
231 | + $item_type = wpinv_get_item_type($item_id); |
|
232 | 232 | |
233 | - if ( empty( $item_type ) ) { |
|
233 | + if (empty($item_type)) { |
|
234 | 234 | $item_type = '-'; |
235 | 235 | } |
236 | 236 | |
237 | - $item_type = isset( $item_types[$item_type] ) ? $item_types[$item_type] : __( $item_type, 'invoicing' ); |
|
237 | + $item_type = isset($item_types[$item_type]) ? $item_types[$item_type] : __($item_type, 'invoicing'); |
|
238 | 238 | |
239 | - return apply_filters( 'wpinv_item_type', $item_type, $item_id ); |
|
239 | + return apply_filters('wpinv_item_type', $item_type, $item_id); |
|
240 | 240 | } |
241 | 241 | |
242 | -function wpinv_get_random_item( $post_ids = true ) { |
|
243 | - wpinv_get_random_items( 1, $post_ids ); |
|
242 | +function wpinv_get_random_item($post_ids = true) { |
|
243 | + wpinv_get_random_items(1, $post_ids); |
|
244 | 244 | } |
245 | 245 | |
246 | -function wpinv_get_random_items( $num = 3, $post_ids = true ) { |
|
247 | - if ( $post_ids ) { |
|
248 | - $args = array( 'post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num, 'fields' => 'ids' ); |
|
246 | +function wpinv_get_random_items($num = 3, $post_ids = true) { |
|
247 | + if ($post_ids) { |
|
248 | + $args = array('post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num, 'fields' => 'ids'); |
|
249 | 249 | } else { |
250 | - $args = array( 'post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num ); |
|
250 | + $args = array('post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num); |
|
251 | 251 | } |
252 | 252 | |
253 | - $args = apply_filters( 'wpinv_get_random_items', $args ); |
|
253 | + $args = apply_filters('wpinv_get_random_items', $args); |
|
254 | 254 | |
255 | - return get_posts( $args ); |
|
255 | + return get_posts($args); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -261,13 +261,13 @@ discard block |
||
261 | 261 | * @param WPInv_Item|int $item |
262 | 262 | * @param bool $html |
263 | 263 | */ |
264 | -function wpinv_get_item_suffix( $item, $html = true ) { |
|
264 | +function wpinv_get_item_suffix($item, $html = true) { |
|
265 | 265 | |
266 | - $item = new WPInv_Item( $item ); |
|
267 | - $suffix = $item->is_recurring() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : ''; |
|
268 | - $suffix = $html ? $suffix : strip_tags( $suffix ); |
|
266 | + $item = new WPInv_Item($item); |
|
267 | + $suffix = $item->is_recurring() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : ''; |
|
268 | + $suffix = $html ? $suffix : strip_tags($suffix); |
|
269 | 269 | |
270 | - return apply_filters( 'wpinv_get_item_suffix', $suffix, $item, $html ); |
|
270 | + return apply_filters('wpinv_get_item_suffix', $suffix, $item, $html); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | * @param WPInv_Item|int $item |
277 | 277 | * @param bool $force_delete |
278 | 278 | */ |
279 | -function wpinv_remove_item( $item = 0, $force_delete = false ) { |
|
280 | - $item = new WPInv_Item( $item ); |
|
281 | - $item->delete( $force_delete ); |
|
279 | +function wpinv_remove_item($item = 0, $force_delete = false) { |
|
280 | + $item = new WPInv_Item($item); |
|
281 | + $item->delete($force_delete); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -317,45 +317,45 @@ discard block |
||
317 | 317 | * @param bool $wp_error whether or not to return a WP_Error on failure. |
318 | 318 | * @return bool|WP_Error|WPInv_Item |
319 | 319 | */ |
320 | -function wpinv_create_item( $args = array(), $wp_error = false ) { |
|
320 | +function wpinv_create_item($args = array(), $wp_error = false) { |
|
321 | 321 | |
322 | 322 | // Prepare the item. |
323 | - if ( ! empty( $args['custom_id'] ) && empty( $args['ID'] ) ) { |
|
324 | - $type = empty( $args['type'] ) ? 'custom' : $args['type']; |
|
325 | - $item = wpinv_get_item_by( 'custom_id', $args['custom_id'], $type ); |
|
323 | + if (!empty($args['custom_id']) && empty($args['ID'])) { |
|
324 | + $type = empty($args['type']) ? 'custom' : $args['type']; |
|
325 | + $item = wpinv_get_item_by('custom_id', $args['custom_id'], $type); |
|
326 | 326 | |
327 | - if ( ! empty( $item ) ) { |
|
327 | + if (!empty($item)) { |
|
328 | 328 | $args['ID'] = $item->get_id(); |
329 | 329 | } |
330 | 330 | |
331 | 331 | } |
332 | 332 | |
333 | 333 | // Do we have an item? |
334 | - if ( ! empty( $args['ID'] ) ) { |
|
335 | - $item = new WPInv_Item( $args['ID'] ); |
|
334 | + if (!empty($args['ID'])) { |
|
335 | + $item = new WPInv_Item($args['ID']); |
|
336 | 336 | } else { |
337 | 337 | $item = new WPInv_Item(); |
338 | 338 | } |
339 | 339 | |
340 | 340 | // Do we have an error? |
341 | - if ( ! empty( $item->last_error ) ) { |
|
342 | - return $wp_error ? new WP_Error( 'invalid_item', $item->last_error ) : false; |
|
341 | + if (!empty($item->last_error)) { |
|
342 | + return $wp_error ? new WP_Error('invalid_item', $item->last_error) : false; |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | // Update item props. |
346 | - $item->set_props( $args ); |
|
346 | + $item->set_props($args); |
|
347 | 347 | |
348 | 348 | // Save the item. |
349 | 349 | $item->save(); |
350 | 350 | |
351 | 351 | // Do we have an error? |
352 | - if ( ! empty( $item->last_error ) ) { |
|
353 | - return $wp_error ? new WP_Error( 'not_saved', $item->last_error ) : false; |
|
352 | + if (!empty($item->last_error)) { |
|
353 | + return $wp_error ? new WP_Error('not_saved', $item->last_error) : false; |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | // Was the item saved? |
357 | - if ( ! $item->get_id() ) { |
|
358 | - return $wp_error ? new WP_Error( 'not_saved', __( 'An error occured while saving the item', 'invoicing' ) ) : false; |
|
357 | + if (!$item->get_id()) { |
|
358 | + return $wp_error ? new WP_Error('not_saved', __('An error occured while saving the item', 'invoicing')) : false; |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | return $item; |
@@ -367,14 +367,14 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @see wpinv_create_item() |
369 | 369 | */ |
370 | -function wpinv_update_item( $args = array(), $wp_error = false ) { |
|
371 | - return wpinv_create_item( $args, $wp_error ); |
|
370 | +function wpinv_update_item($args = array(), $wp_error = false) { |
|
371 | + return wpinv_create_item($args, $wp_error); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
375 | 375 | * Sanitizes a recurring period |
376 | 376 | */ |
377 | -function getpaid_sanitize_recurring_period( $period, $full = false ) { |
|
377 | +function getpaid_sanitize_recurring_period($period, $full = false) { |
|
378 | 378 | |
379 | 379 | $periods = array( |
380 | 380 | 'D' => 'day', |
@@ -383,11 +383,11 @@ discard block |
||
383 | 383 | 'Y' => 'year', |
384 | 384 | ); |
385 | 385 | |
386 | - if ( ! isset( $periods[ $period ] ) ) { |
|
386 | + if (!isset($periods[$period])) { |
|
387 | 387 | $period = 'D'; |
388 | 388 | } |
389 | 389 | |
390 | - return $full ? $periods[ $period ] : $period; |
|
390 | + return $full ? $periods[$period] : $period; |
|
391 | 391 | |
392 | 392 | } |
393 | 393 | |
@@ -396,38 +396,38 @@ discard block |
||
396 | 396 | * |
397 | 397 | * @param WPInv_Item|GetPaid_Form_Item $item |
398 | 398 | */ |
399 | -function getpaid_item_recurring_price_help_text( $item, $currency = '', $_initial_price = false, $_recurring_price = false ) { |
|
399 | +function getpaid_item_recurring_price_help_text($item, $currency = '', $_initial_price = false, $_recurring_price = false) { |
|
400 | 400 | |
401 | 401 | // Abort if it is not recurring. |
402 | - if ( ! $item->is_recurring() ) { |
|
402 | + if (!$item->is_recurring()) { |
|
403 | 403 | return ''; |
404 | 404 | } |
405 | 405 | |
406 | - $initial_price = false === $_initial_price ? wpinv_price( $item->get_initial_price(), $currency ) : $_initial_price; |
|
407 | - $recurring_price = false === $_recurring_price ? wpinv_price( $item->get_recurring_price(), $currency ) : $_recurring_price; |
|
408 | - $period = getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ); |
|
406 | + $initial_price = false === $_initial_price ? wpinv_price($item->get_initial_price(), $currency) : $_initial_price; |
|
407 | + $recurring_price = false === $_recurring_price ? wpinv_price($item->get_recurring_price(), $currency) : $_recurring_price; |
|
408 | + $period = getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), ''); |
|
409 | 409 | $initial_class = 'getpaid-item-initial-price'; |
410 | 410 | $recurring_class = 'getpaid-item-recurring-price'; |
411 | 411 | |
412 | - if ( $item instanceof GetPaid_Form_Item && false === $_initial_price ) { |
|
413 | - $initial_price = wpinv_price( $item->get_sub_total(), $currency ); |
|
414 | - $recurring_price = wpinv_price( $item->get_recurring_sub_total(), $currency ); |
|
412 | + if ($item instanceof GetPaid_Form_Item && false === $_initial_price) { |
|
413 | + $initial_price = wpinv_price($item->get_sub_total(), $currency); |
|
414 | + $recurring_price = wpinv_price($item->get_recurring_sub_total(), $currency); |
|
415 | 415 | } |
416 | 416 | |
417 | - if ( wpinv_price( 0, $currency ) == $initial_price && wpinv_price( 0, $currency ) == $recurring_price ) { |
|
418 | - return __( 'Free forever', 'invoicing' ); |
|
417 | + if (wpinv_price(0, $currency) == $initial_price && wpinv_price(0, $currency) == $recurring_price) { |
|
418 | + return __('Free forever', 'invoicing'); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | // For free trial items. |
422 | - if ( $item->has_free_trial() ) { |
|
423 | - $trial_period = getpaid_get_subscription_period_label( $item->get_trial_period(), $item->get_trial_interval() ); |
|
422 | + if ($item->has_free_trial()) { |
|
423 | + $trial_period = getpaid_get_subscription_period_label($item->get_trial_period(), $item->get_trial_interval()); |
|
424 | 424 | |
425 | - if ( wpinv_price( 0, $currency ) == $initial_price ) { |
|
425 | + if (wpinv_price(0, $currency) == $initial_price) { |
|
426 | 426 | |
427 | 427 | return sprintf( |
428 | 428 | |
429 | 429 | // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period |
430 | - _x( 'Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing' ), |
|
430 | + _x('Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing'), |
|
431 | 431 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
432 | 432 | "<span class='$recurring_class'>$recurring_price</span>", |
433 | 433 | "<span class='getpaid-item-recurring-period'>$period</span>" |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | return sprintf( |
440 | 440 | |
441 | 441 | // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period |
442 | - _x( '%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing' ), |
|
442 | + _x('%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing'), |
|
443 | 443 | "<span class='$initial_class'>$initial_price</span>", |
444 | 444 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
445 | 445 | "<span class='$recurring_class'>$recurring_price</span>", |
@@ -449,12 +449,12 @@ discard block |
||
449 | 449 | |
450 | 450 | } |
451 | 451 | |
452 | - if ( $initial_price == $recurring_price ) { |
|
452 | + if ($initial_price == $recurring_price) { |
|
453 | 453 | |
454 | 454 | return sprintf( |
455 | 455 | |
456 | 456 | // translators: $1: is the recurring price, $2: is the susbcription period |
457 | - _x( '%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
457 | + _x('%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing'), |
|
458 | 458 | "<span class='$recurring_class'>$recurring_price</span>", |
459 | 459 | "<span class='getpaid-item-recurring-period'>$period</span>" |
460 | 460 | |
@@ -462,12 +462,12 @@ discard block |
||
462 | 462 | |
463 | 463 | } |
464 | 464 | |
465 | - if ( $initial_price == wpinv_price( 0, $currency ) ) { |
|
465 | + if ($initial_price == wpinv_price(0, $currency)) { |
|
466 | 466 | |
467 | 467 | return sprintf( |
468 | 468 | |
469 | 469 | // translators: $1: is the recurring period, $2: is the recurring price |
470 | - _x( 'Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing' ), |
|
470 | + _x('Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing'), |
|
471 | 471 | "<span class='getpaid-item-recurring-period'>$period</span>", |
472 | 472 | "<span class='$recurring_class'>$recurring_price</span>" |
473 | 473 | |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | return sprintf( |
479 | 479 | |
480 | 480 | // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period |
481 | - _x( 'Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing' ), |
|
481 | + _x('Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing'), |
|
482 | 482 | "<span class='$initial_class'>$initial_price</span>", |
483 | 483 | "<span class='$recurring_class'>$recurring_price</span>", |
484 | 484 | "<span class='getpaid-item-recurring-period'>$period</span>" |
@@ -6,39 +6,39 @@ |
||
6 | 6 | /** |
7 | 7 | * Bail if we are not in WP. |
8 | 8 | */ |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if (!defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Set the version only if its the current newest while loading. |
15 | 15 | */ |
16 | -add_action('after_setup_theme', function () { |
|
17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
16 | +add_action('after_setup_theme', function() { |
|
17 | + global $ayecode_ui_version, $ayecode_ui_file_key; |
|
18 | 18 | $this_version = "0.1.43"; |
19 | - if(version_compare($this_version , $ayecode_ui_version, '>')){ |
|
20 | - $ayecode_ui_version = $this_version ; |
|
21 | - $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
19 | + if (version_compare($this_version, $ayecode_ui_version, '>')) { |
|
20 | + $ayecode_ui_version = $this_version; |
|
21 | + $ayecode_ui_file_key = wp_hash(__FILE__); |
|
22 | 22 | } |
23 | 23 | },0); |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Load this version of WP Bootstrap Settings only if the file hash is the current one. |
27 | 27 | */ |
28 | -add_action('after_setup_theme', function () { |
|
28 | +add_action('after_setup_theme', function() { |
|
29 | 29 | global $ayecode_ui_file_key; |
30 | - if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
31 | - include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
32 | - include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
30 | + if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) { |
|
31 | + include_once(dirname(__FILE__) . '/includes/class-aui.php'); |
|
32 | + include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php'); |
|
33 | 33 | } |
34 | 34 | },1); |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Add the function that calls the class. |
38 | 38 | */ |
39 | -if(!function_exists('aui')){ |
|
40 | - function aui(){ |
|
41 | - if(!class_exists("AUI",false)){ |
|
39 | +if (!function_exists('aui')) { |
|
40 | + function aui() { |
|
41 | + if (!class_exists("AUI", false)) { |
|
42 | 42 | return false; |
43 | 43 | } |
44 | 44 | return AUI::instance(); |
@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | /** |
13 | 13 | * Bail if we are not in WP. |
14 | 14 | */ |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if (!defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Only add if the class does not already exist. |
21 | 21 | */ |
22 | -if ( ! class_exists( 'AyeCode_UI_Settings' ) ) { |
|
22 | +if (!class_exists('AyeCode_UI_Settings')) { |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * A Class to be able to change settings for Font Awesome. |
@@ -98,23 +98,23 @@ discard block |
||
98 | 98 | * @return AyeCode_UI_Settings - Main instance. |
99 | 99 | */ |
100 | 100 | public static function instance() { |
101 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
101 | + if (!isset(self::$instance) && !(self::$instance instanceof AyeCode_UI_Settings)) { |
|
102 | 102 | |
103 | 103 | self::$instance = new AyeCode_UI_Settings; |
104 | 104 | |
105 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
105 | + add_action('init', array(self::$instance, 'init')); // set settings |
|
106 | 106 | |
107 | - if ( is_admin() ) { |
|
108 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
109 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
107 | + if (is_admin()) { |
|
108 | + add_action('admin_menu', array(self::$instance, 'menu_item')); |
|
109 | + add_action('admin_init', array(self::$instance, 'register_settings')); |
|
110 | 110 | |
111 | 111 | // Maybe show example page |
112 | - add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
112 | + add_action('template_redirect', array(self::$instance, 'maybe_show_examples')); |
|
113 | 113 | } |
114 | 114 | |
115 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
115 | + add_action('customize_register', array(self::$instance, 'customizer_settings')); |
|
116 | 116 | |
117 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
117 | + do_action('ayecode_ui_settings_loaded'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | return self::$instance; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | /** |
124 | 124 | * Setup some constants. |
125 | 125 | */ |
126 | - public function constants(){ |
|
126 | + public function constants() { |
|
127 | 127 | define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
128 | 128 | define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
129 | 129 | if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
@@ -143,25 +143,25 @@ discard block |
||
143 | 143 | * |
144 | 144 | * We load super early in case there is a theme version that might change the colors |
145 | 145 | */ |
146 | - if ( $this->settings['css'] ) { |
|
147 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
146 | + if ($this->settings['css']) { |
|
147 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 1); |
|
148 | 148 | } |
149 | - if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
150 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
149 | + if ($this->settings['css_backend'] && $this->load_admin_scripts()) { |
|
150 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 1); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // maybe load JS |
154 | - if ( $this->settings['js'] ) { |
|
154 | + if ($this->settings['js']) { |
|
155 | 155 | $priority = $this->is_bs3_compat() ? 100 : 1; |
156 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
156 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), $priority); |
|
157 | 157 | } |
158 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
159 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
158 | + if ($this->settings['js_backend'] && $this->load_admin_scripts()) { |
|
159 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 1); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | // Maybe set the HTML font size |
163 | - if ( $this->settings['html_font_size'] ) { |
|
164 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
163 | + if ($this->settings['html_font_size']) { |
|
164 | + add_action('wp_footer', array($this, 'html_font_size'), 10); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return bool |
174 | 174 | */ |
175 | - public function load_admin_scripts(){ |
|
175 | + public function load_admin_scripts() { |
|
176 | 176 | $result = true; |
177 | 177 | |
178 | 178 | // check if specifically disabled |
179 | - if(!empty($this->settings['disable_admin'])){ |
|
180 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
181 | - foreach($url_parts as $part){ |
|
182 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
179 | + if (!empty($this->settings['disable_admin'])) { |
|
180 | + $url_parts = explode("\n", $this->settings['disable_admin']); |
|
181 | + foreach ($url_parts as $part) { |
|
182 | + if (strpos($_SERVER['REQUEST_URI'], trim($part)) !== false) { |
|
183 | 183 | return false; // return early, no point checking further |
184 | 184 | } |
185 | 185 | } |
@@ -191,9 +191,9 @@ discard block |
||
191 | 191 | /** |
192 | 192 | * Add a html font size to the footer. |
193 | 193 | */ |
194 | - public function html_font_size(){ |
|
194 | + public function html_font_size() { |
|
195 | 195 | $this->settings = $this->get_settings(); |
196 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
196 | + echo "<style>html{font-size:" . absint($this->settings['html_font_size']) . "px;}</style>"; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -201,23 +201,23 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return bool |
203 | 203 | */ |
204 | - public function is_aui_screen(){ |
|
204 | + public function is_aui_screen() { |
|
205 | 205 | $load = false; |
206 | 206 | // check if we should load or not |
207 | - if ( is_admin() ) { |
|
207 | + if (is_admin()) { |
|
208 | 208 | // Only enable on set pages |
209 | 209 | $aui_screens = array( |
210 | 210 | 'page', |
211 | 211 | 'post', |
212 | 212 | 'settings_page_ayecode-ui-settings' |
213 | 213 | ); |
214 | - $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
214 | + $screen_ids = apply_filters('aui_screen_ids', $aui_screens); |
|
215 | 215 | |
216 | 216 | $screen = get_current_screen(); |
217 | 217 | |
218 | 218 | // echo '###'.$screen->id; |
219 | 219 | |
220 | - if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
220 | + if ($screen && in_array($screen->id, $screen_ids)) { |
|
221 | 221 | $load = true; |
222 | 222 | } |
223 | 223 | } |
@@ -230,25 +230,25 @@ discard block |
||
230 | 230 | */ |
231 | 231 | public function enqueue_style() { |
232 | 232 | |
233 | - if( is_admin() && !$this->is_aui_screen()){ |
|
233 | + if (is_admin() && !$this->is_aui_screen()) { |
|
234 | 234 | // don't add wp-admin scripts if not requested to |
235 | - }else{ |
|
235 | + } else { |
|
236 | 236 | $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
237 | 237 | |
238 | 238 | $rtl = is_rtl() ? '-rtl' : ''; |
239 | 239 | |
240 | - if($this->settings[$css_setting]){ |
|
241 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
242 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
243 | - wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
244 | - wp_enqueue_style( 'ayecode-ui' ); |
|
240 | + if ($this->settings[$css_setting]) { |
|
241 | + $compatibility = $this->settings[$css_setting] == 'core' ? false : true; |
|
242 | + $url = $this->settings[$css_setting] == 'core' ? $this->url . 'assets/css/ayecode-ui' . $rtl . '.css' : $this->url . 'assets/css/ayecode-ui-compatibility' . $rtl . '.css'; |
|
243 | + wp_register_style('ayecode-ui', $url, array(), $this->latest); |
|
244 | + wp_enqueue_style('ayecode-ui'); |
|
245 | 245 | |
246 | 246 | // flatpickr |
247 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
247 | + wp_register_style('flatpickr', $this->url . 'assets/css/flatpickr.min.css', array(), $this->latest); |
|
248 | 248 | |
249 | 249 | |
250 | 250 | // fix some wp-admin issues |
251 | - if(is_admin()){ |
|
251 | + if (is_admin()) { |
|
252 | 252 | $custom_css = " |
253 | 253 | body{ |
254 | 254 | background-color: #f1f1f1; |
@@ -291,11 +291,11 @@ discard block |
||
291 | 291 | padding: 0; |
292 | 292 | } |
293 | 293 | "; |
294 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
294 | + wp_add_inline_style('ayecode-ui', $custom_css); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | // custom changes |
298 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
298 | + wp_add_inline_style('ayecode-ui', self::custom_css($compatibility)); |
|
299 | 299 | |
300 | 300 | } |
301 | 301 | } |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * |
309 | 309 | * If this remains small then its best to use this than to add another JS file. |
310 | 310 | */ |
311 | - public function inline_script(){ |
|
311 | + public function inline_script() { |
|
312 | 312 | ob_start(); |
313 | 313 | ?> |
314 | 314 | <script> |
@@ -807,10 +807,10 @@ discard block |
||
807 | 807 | /* |
808 | 808 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
809 | 809 | */ |
810 | - return str_replace( array( |
|
810 | + return str_replace(array( |
|
811 | 811 | '<script>', |
812 | 812 | '</script>' |
813 | - ), '', $output ); |
|
813 | + ), '', $output); |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | |
@@ -824,13 +824,13 @@ discard block |
||
824 | 824 | ob_start(); |
825 | 825 | ?> |
826 | 826 | <script> |
827 | - <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
|
827 | + <?php if (defined('FUSION_BUILDER_VERSION')) { ?> |
|
828 | 828 | /* With Avada builder */ |
829 | 829 | |
830 | 830 | <?php } ?> |
831 | 831 | </script> |
832 | 832 | <?php |
833 | - return str_replace( array( |
|
833 | + return str_replace(array( |
|
834 | 834 | '<script>', |
835 | 835 | '</script>' |
836 | 836 | ), '', ob_get_clean()); |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | * |
842 | 842 | * If this remains small then its best to use this than to add another JS file. |
843 | 843 | */ |
844 | - public function inline_script_file_browser(){ |
|
844 | + public function inline_script_file_browser() { |
|
845 | 845 | ob_start(); |
846 | 846 | ?> |
847 | 847 | <script> |
@@ -856,10 +856,10 @@ discard block |
||
856 | 856 | /* |
857 | 857 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
858 | 858 | */ |
859 | - return str_replace( array( |
|
859 | + return str_replace(array( |
|
860 | 860 | '<script>', |
861 | 861 | '</script>' |
862 | - ), '', $output ); |
|
862 | + ), '', $output); |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | /** |
@@ -867,50 +867,50 @@ discard block |
||
867 | 867 | */ |
868 | 868 | public function enqueue_scripts() { |
869 | 869 | |
870 | - if( is_admin() && !$this->is_aui_screen()){ |
|
870 | + if (is_admin() && !$this->is_aui_screen()) { |
|
871 | 871 | // don't add wp-admin scripts if not requested to |
872 | - }else { |
|
872 | + } else { |
|
873 | 873 | |
874 | 874 | $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
875 | 875 | |
876 | 876 | // select2 |
877 | - wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
877 | + wp_register_script('select2', $this->url . 'assets/js/select2.min.js', array('jquery'), $this->select2_version); |
|
878 | 878 | |
879 | 879 | // flatpickr |
880 | - wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
880 | + wp_register_script('flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest); |
|
881 | 881 | |
882 | 882 | // Bootstrap file browser |
883 | - wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
884 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
883 | + wp_register_script('aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version); |
|
884 | + wp_add_inline_script('aui-custom-file-input', $this->inline_script_file_browser()); |
|
885 | 885 | |
886 | 886 | $load_inline = false; |
887 | 887 | |
888 | - if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
888 | + if ($this->settings[$js_setting] == 'core-popper') { |
|
889 | 889 | // Bootstrap bundle |
890 | 890 | $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
891 | - wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
891 | + wp_register_script('bootstrap-js-bundle', $url, array( |
|
892 | 892 | 'select2', |
893 | 893 | 'jquery' |
894 | - ), $this->latest, $this->is_bs3_compat() ); |
|
894 | + ), $this->latest, $this->is_bs3_compat()); |
|
895 | 895 | // if in admin then add to footer for compatibility. |
896 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
896 | + is_admin() ? wp_enqueue_script('bootstrap-js-bundle', '', null, null, true) : wp_enqueue_script('bootstrap-js-bundle'); |
|
897 | 897 | $script = $this->inline_script(); |
898 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
899 | - } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
898 | + wp_add_inline_script('bootstrap-js-bundle', $script); |
|
899 | + } elseif ($this->settings[$js_setting] == 'popper') { |
|
900 | 900 | $url = $this->url . 'assets/js/popper.min.js'; |
901 | - wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->latest ); |
|
902 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
901 | + wp_register_script('bootstrap-js-popper', $url, array('select2', 'jquery'), $this->latest); |
|
902 | + wp_enqueue_script('bootstrap-js-popper'); |
|
903 | 903 | $load_inline = true; |
904 | 904 | } else { |
905 | 905 | $load_inline = true; |
906 | 906 | } |
907 | 907 | |
908 | 908 | // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
909 | - if ( $load_inline ) { |
|
910 | - wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
911 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
909 | + if ($load_inline) { |
|
910 | + wp_register_script('bootstrap-dummy', '', array('select2', 'jquery')); |
|
911 | + wp_enqueue_script('bootstrap-dummy'); |
|
912 | 912 | $script = $this->inline_script(); |
913 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
913 | + wp_add_inline_script('bootstrap-dummy', $script); |
|
914 | 914 | } |
915 | 915 | } |
916 | 916 | |
@@ -919,9 +919,9 @@ discard block |
||
919 | 919 | /** |
920 | 920 | * Enqueue flatpickr if called. |
921 | 921 | */ |
922 | - public function enqueue_flatpickr(){ |
|
923 | - wp_enqueue_style( 'flatpickr' ); |
|
924 | - wp_enqueue_script( 'flatpickr' ); |
|
922 | + public function enqueue_flatpickr() { |
|
923 | + wp_enqueue_style('flatpickr'); |
|
924 | + wp_enqueue_script('flatpickr'); |
|
925 | 925 | } |
926 | 926 | |
927 | 927 | /** |
@@ -933,15 +933,15 @@ discard block |
||
933 | 933 | |
934 | 934 | $url = ''; |
935 | 935 | // check if we are inside a plugin |
936 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
936 | + $file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__))); |
|
937 | 937 | |
938 | 938 | // add check in-case user has changed wp-content dir name. |
939 | 939 | $wp_content_folder_name = basename(WP_CONTENT_DIR); |
940 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
941 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
940 | + $dir_parts = explode("/$wp_content_folder_name/", $file_dir); |
|
941 | + $url_parts = explode("/$wp_content_folder_name/", plugins_url()); |
|
942 | 942 | |
943 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
944 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
943 | + if (!empty($url_parts[0]) && !empty($dir_parts[1])) { |
|
944 | + $url = trailingslashit($url_parts[0] . "/$wp_content_folder_name/" . $dir_parts[1]); |
|
945 | 945 | } |
946 | 946 | |
947 | 947 | return $url; |
@@ -951,7 +951,7 @@ discard block |
||
951 | 951 | * Register the database settings with WordPress. |
952 | 952 | */ |
953 | 953 | public function register_settings() { |
954 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
954 | + register_setting('ayecode-ui-settings', 'ayecode-ui-settings'); |
|
955 | 955 | } |
956 | 956 | |
957 | 957 | /** |
@@ -960,10 +960,10 @@ discard block |
||
960 | 960 | */ |
961 | 961 | public function menu_item() { |
962 | 962 | $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
963 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
963 | + call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
964 | 964 | $this, |
965 | 965 | 'settings_page' |
966 | - ) ); |
|
966 | + )); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | /** |
@@ -971,7 +971,7 @@ discard block |
||
971 | 971 | * |
972 | 972 | * @return array |
973 | 973 | */ |
974 | - public function theme_js_settings(){ |
|
974 | + public function theme_js_settings() { |
|
975 | 975 | return array( |
976 | 976 | 'ayetheme' => 'popper', |
977 | 977 | 'listimia' => 'required', |
@@ -987,17 +987,17 @@ discard block |
||
987 | 987 | */ |
988 | 988 | public function get_settings() { |
989 | 989 | |
990 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
990 | + $db_settings = get_option('ayecode-ui-settings'); |
|
991 | 991 | $js_default = 'core-popper'; |
992 | 992 | $js_default_backend = $js_default; |
993 | 993 | |
994 | 994 | // maybe set defaults (if no settings set) |
995 | - if(empty($db_settings)){ |
|
996 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
995 | + if (empty($db_settings)) { |
|
996 | + $active_theme = strtolower(get_template()); // active parent theme. |
|
997 | 997 | $theme_js_settings = self::theme_js_settings(); |
998 | - if(isset($theme_js_settings[$active_theme])){ |
|
998 | + if (isset($theme_js_settings[$active_theme])) { |
|
999 | 999 | $js_default = $theme_js_settings[$active_theme]; |
1000 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
1000 | + $js_default_backend = isset($theme_js_settings[$active_theme . "_backend"]) ? $theme_js_settings[$active_theme . "_backend"] : $js_default; |
|
1001 | 1001 | } |
1002 | 1002 | } |
1003 | 1003 | |
@@ -1010,14 +1010,14 @@ discard block |
||
1010 | 1010 | 'disable_admin' => '', // URL snippets to disable loading on admin |
1011 | 1011 | ); |
1012 | 1012 | |
1013 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
1013 | + $settings = wp_parse_args($db_settings, $defaults); |
|
1014 | 1014 | |
1015 | 1015 | /** |
1016 | 1016 | * Filter the Bootstrap settings. |
1017 | 1017 | * |
1018 | 1018 | * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
1019 | 1019 | */ |
1020 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
1020 | + return $this->settings = apply_filters('ayecode-ui-settings', $settings, $db_settings, $defaults); |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | |
@@ -1025,90 +1025,90 @@ discard block |
||
1025 | 1025 | * The settings page html output. |
1026 | 1026 | */ |
1027 | 1027 | public function settings_page() { |
1028 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
1029 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
1028 | + if (!current_user_can('manage_options')) { |
|
1029 | + wp_die(__('You do not have sufficient permissions to access this page.', 'aui')); |
|
1030 | 1030 | } |
1031 | 1031 | ?> |
1032 | 1032 | <div class="wrap"> |
1033 | 1033 | <h1><?php echo $this->name; ?></h1> |
1034 | - <p><?php _e("Here you can adjust settings if you are having compatibility issues.","aui");?></p> |
|
1034 | + <p><?php _e("Here you can adjust settings if you are having compatibility issues.", "aui"); ?></p> |
|
1035 | 1035 | <form method="post" action="options.php"> |
1036 | 1036 | <?php |
1037 | - settings_fields( 'ayecode-ui-settings' ); |
|
1038 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
1037 | + settings_fields('ayecode-ui-settings'); |
|
1038 | + do_settings_sections('ayecode-ui-settings'); |
|
1039 | 1039 | ?> |
1040 | 1040 | |
1041 | - <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
|
1041 | + <h2><?php _e('Frontend', 'aui'); ?></h2> |
|
1042 | 1042 | <table class="form-table wpbs-table-settings"> |
1043 | 1043 | <tr valign="top"> |
1044 | 1044 | <th scope="row"><label |
1045 | - for="wpbs-css"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
1045 | + for="wpbs-css"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
1046 | 1046 | <td> |
1047 | 1047 | <select name="ayecode-ui-settings[css]" id="wpbs-css"> |
1048 | - <option value="compatibility" <?php selected( $this->settings['css'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option> |
|
1049 | - <option value="core" <?php selected( $this->settings['css'], 'core' ); ?>><?php _e( 'Full Mode', 'aui' ); ?></option> |
|
1050 | - <option value="" <?php selected( $this->settings['css'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
1048 | + <option value="compatibility" <?php selected($this->settings['css'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option> |
|
1049 | + <option value="core" <?php selected($this->settings['css'], 'core'); ?>><?php _e('Full Mode', 'aui'); ?></option> |
|
1050 | + <option value="" <?php selected($this->settings['css'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
1051 | 1051 | </select> |
1052 | 1052 | </td> |
1053 | 1053 | </tr> |
1054 | 1054 | |
1055 | 1055 | <tr valign="top"> |
1056 | 1056 | <th scope="row"><label |
1057 | - for="wpbs-js"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
1057 | + for="wpbs-js"><?php _e('Load JS', 'aui'); ?></label></th> |
|
1058 | 1058 | <td> |
1059 | 1059 | <select name="ayecode-ui-settings[js]" id="wpbs-js"> |
1060 | - <option value="core-popper" <?php selected( $this->settings['js'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
1061 | - <option value="popper" <?php selected( $this->settings['js'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
1062 | - <option value="required" <?php selected( $this->settings['js'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
1063 | - <option value="" <?php selected( $this->settings['js'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
1060 | + <option value="core-popper" <?php selected($this->settings['js'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
1061 | + <option value="popper" <?php selected($this->settings['js'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
1062 | + <option value="required" <?php selected($this->settings['js'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
1063 | + <option value="" <?php selected($this->settings['js'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
1064 | 1064 | </select> |
1065 | 1065 | </td> |
1066 | 1066 | </tr> |
1067 | 1067 | |
1068 | 1068 | <tr valign="top"> |
1069 | 1069 | <th scope="row"><label |
1070 | - for="wpbs-font_size"><?php _e( 'HTML Font Size (px)', 'aui' ); ?></label></th> |
|
1070 | + for="wpbs-font_size"><?php _e('HTML Font Size (px)', 'aui'); ?></label></th> |
|
1071 | 1071 | <td> |
1072 | - <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint( $this->settings['html_font_size']); ?>" placeholder="16" /> |
|
1073 | - <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.","aui");?></p> |
|
1072 | + <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint($this->settings['html_font_size']); ?>" placeholder="16" /> |
|
1073 | + <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.", "aui"); ?></p> |
|
1074 | 1074 | </td> |
1075 | 1075 | </tr> |
1076 | 1076 | |
1077 | 1077 | </table> |
1078 | 1078 | |
1079 | - <h2><?php _e( 'Backend', 'aui' ); ?> (wp-admin)</h2> |
|
1079 | + <h2><?php _e('Backend', 'aui'); ?> (wp-admin)</h2> |
|
1080 | 1080 | <table class="form-table wpbs-table-settings"> |
1081 | 1081 | <tr valign="top"> |
1082 | 1082 | <th scope="row"><label |
1083 | - for="wpbs-css-admin"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
1083 | + for="wpbs-css-admin"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
1084 | 1084 | <td> |
1085 | 1085 | <select name="ayecode-ui-settings[css_backend]" id="wpbs-css-admin"> |
1086 | - <option value="compatibility" <?php selected( $this->settings['css_backend'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option> |
|
1087 | - <option value="core" <?php selected( $this->settings['css_backend'], 'core' ); ?>><?php _e( 'Full Mode (will cause style issues)', 'aui' ); ?></option> |
|
1088 | - <option value="" <?php selected( $this->settings['css_backend'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
1086 | + <option value="compatibility" <?php selected($this->settings['css_backend'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option> |
|
1087 | + <option value="core" <?php selected($this->settings['css_backend'], 'core'); ?>><?php _e('Full Mode (will cause style issues)', 'aui'); ?></option> |
|
1088 | + <option value="" <?php selected($this->settings['css_backend'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
1089 | 1089 | </select> |
1090 | 1090 | </td> |
1091 | 1091 | </tr> |
1092 | 1092 | |
1093 | 1093 | <tr valign="top"> |
1094 | 1094 | <th scope="row"><label |
1095 | - for="wpbs-js-admin"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
1095 | + for="wpbs-js-admin"><?php _e('Load JS', 'aui'); ?></label></th> |
|
1096 | 1096 | <td> |
1097 | 1097 | <select name="ayecode-ui-settings[js_backend]" id="wpbs-js-admin"> |
1098 | - <option value="core-popper" <?php selected( $this->settings['js_backend'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
1099 | - <option value="popper" <?php selected( $this->settings['js_backend'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
1100 | - <option value="required" <?php selected( $this->settings['js_backend'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
1101 | - <option value="" <?php selected( $this->settings['js_backend'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
1098 | + <option value="core-popper" <?php selected($this->settings['js_backend'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
1099 | + <option value="popper" <?php selected($this->settings['js_backend'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
1100 | + <option value="required" <?php selected($this->settings['js_backend'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
1101 | + <option value="" <?php selected($this->settings['js_backend'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
1102 | 1102 | </select> |
1103 | 1103 | </td> |
1104 | 1104 | </tr> |
1105 | 1105 | |
1106 | 1106 | <tr valign="top"> |
1107 | 1107 | <th scope="row"><label |
1108 | - for="wpbs-disable-admin"><?php _e( 'Disable load on URL', 'aui' ); ?></label></th> |
|
1108 | + for="wpbs-disable-admin"><?php _e('Disable load on URL', 'aui'); ?></label></th> |
|
1109 | 1109 | <td> |
1110 | - <p><?php _e( 'If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui' ); ?></p> |
|
1111 | - <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin'];?></textarea> |
|
1110 | + <p><?php _e('If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui'); ?></p> |
|
1111 | + <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin']; ?></textarea> |
|
1112 | 1112 | |
1113 | 1113 | </td> |
1114 | 1114 | </tr> |
@@ -1126,9 +1126,9 @@ discard block |
||
1126 | 1126 | <?php |
1127 | 1127 | } |
1128 | 1128 | |
1129 | - public function customizer_settings($wp_customize){ |
|
1129 | + public function customizer_settings($wp_customize) { |
|
1130 | 1130 | $wp_customize->add_section('aui_settings', array( |
1131 | - 'title' => __('AyeCode UI','aui'), |
|
1131 | + 'title' => __('AyeCode UI', 'aui'), |
|
1132 | 1132 | 'priority' => 120, |
1133 | 1133 | )); |
1134 | 1134 | |
@@ -1142,8 +1142,8 @@ discard block |
||
1142 | 1142 | 'type' => 'option', |
1143 | 1143 | 'transport' => 'refresh', |
1144 | 1144 | )); |
1145 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1146 | - 'label' => __('Primary Color','aui'), |
|
1145 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1146 | + 'label' => __('Primary Color', 'aui'), |
|
1147 | 1147 | 'section' => 'aui_settings', |
1148 | 1148 | 'settings' => 'aui_options[color_primary]', |
1149 | 1149 | ))); |
@@ -1155,8 +1155,8 @@ discard block |
||
1155 | 1155 | 'type' => 'option', |
1156 | 1156 | 'transport' => 'refresh', |
1157 | 1157 | )); |
1158 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1159 | - 'label' => __('Secondary Color','aui'), |
|
1158 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1159 | + 'label' => __('Secondary Color', 'aui'), |
|
1160 | 1160 | 'section' => 'aui_settings', |
1161 | 1161 | 'settings' => 'aui_options[color_secondary]', |
1162 | 1162 | ))); |
@@ -1182,12 +1182,12 @@ discard block |
||
1182 | 1182 | .collapse.show:not(.in){display: inherit;} |
1183 | 1183 | .fade.show{opacity: 1;} |
1184 | 1184 | |
1185 | - <?php if( defined( 'SVQ_THEME_VERSION' ) ){ ?> |
|
1185 | + <?php if (defined('SVQ_THEME_VERSION')) { ?> |
|
1186 | 1186 | /* KLEO theme specific */ |
1187 | 1187 | .kleo-main-header .navbar-collapse.collapse.show:not(.in){display: inherit !important;} |
1188 | 1188 | <?php } ?> |
1189 | 1189 | |
1190 | - <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
|
1190 | + <?php if (defined('FUSION_BUILDER_VERSION')) { ?> |
|
1191 | 1191 | /* With Avada builder */ |
1192 | 1192 | body.modal-open .modal.in {opacity:1;z-index: 99999} |
1193 | 1193 | body.modal-open .modal.bsui.in .modal-content {box-shadow: none;} |
@@ -1195,7 +1195,7 @@ discard block |
||
1195 | 1195 | <?php } ?> |
1196 | 1196 | </style> |
1197 | 1197 | <?php |
1198 | - return str_replace( array( |
|
1198 | + return str_replace(array( |
|
1199 | 1199 | '<style>', |
1200 | 1200 | '</style>' |
1201 | 1201 | ), '', ob_get_clean()); |
@@ -1215,16 +1215,16 @@ discard block |
||
1215 | 1215 | <?php |
1216 | 1216 | |
1217 | 1217 | // BS v3 compat |
1218 | - if( self::is_bs3_compat() ){ |
|
1218 | + if (self::is_bs3_compat()) { |
|
1219 | 1219 | echo self::bs3_compat_css(); |
1220 | 1220 | } |
1221 | 1221 | |
1222 | - if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
1223 | - echo self::css_primary($primary_color,$compatibility); |
|
1222 | + if (!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL) { |
|
1223 | + echo self::css_primary($primary_color, $compatibility); |
|
1224 | 1224 | } |
1225 | 1225 | |
1226 | - if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
1227 | - echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
1226 | + if (!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL) { |
|
1227 | + echo self::css_secondary($settings['color_secondary'], $compatibility); |
|
1228 | 1228 | } |
1229 | 1229 | |
1230 | 1230 | // Set admin bar z-index lower when modal is open. |
@@ -1237,7 +1237,7 @@ discard block |
||
1237 | 1237 | /* |
1238 | 1238 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1239 | 1239 | */ |
1240 | - return str_replace( array( |
|
1240 | + return str_replace(array( |
|
1241 | 1241 | '<style>', |
1242 | 1242 | '</style>' |
1243 | 1243 | ), '', ob_get_clean()); |
@@ -1248,48 +1248,48 @@ discard block |
||
1248 | 1248 | * |
1249 | 1249 | * @return bool |
1250 | 1250 | */ |
1251 | - public static function is_bs3_compat(){ |
|
1251 | + public static function is_bs3_compat() { |
|
1252 | 1252 | return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
1253 | 1253 | } |
1254 | 1254 | |
1255 | - public static function css_primary($color_code,$compatibility){; |
|
1255 | + public static function css_primary($color_code, $compatibility) {; |
|
1256 | 1256 | $color_code = sanitize_hex_color($color_code); |
1257 | - if(!$color_code){return '';} |
|
1257 | + if (!$color_code) {return ''; } |
|
1258 | 1258 | /** |
1259 | 1259 | * c = color, b = background color, o = border-color, f = fill |
1260 | 1260 | */ |
1261 | 1261 | $selectors = array( |
1262 | 1262 | 'a' => array('c'), |
1263 | - '.btn-primary' => array('b','o'), |
|
1264 | - '.btn-primary.disabled' => array('b','o'), |
|
1265 | - '.btn-primary:disabled' => array('b','o'), |
|
1266 | - '.btn-outline-primary' => array('c','o'), |
|
1267 | - '.btn-outline-primary:hover' => array('b','o'), |
|
1268 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1269 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1270 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
1263 | + '.btn-primary' => array('b', 'o'), |
|
1264 | + '.btn-primary.disabled' => array('b', 'o'), |
|
1265 | + '.btn-primary:disabled' => array('b', 'o'), |
|
1266 | + '.btn-outline-primary' => array('c', 'o'), |
|
1267 | + '.btn-outline-primary:hover' => array('b', 'o'), |
|
1268 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
1269 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
1270 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b', 'o'), |
|
1271 | 1271 | '.btn-link' => array('c'), |
1272 | 1272 | '.dropdown-item.active' => array('b'), |
1273 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
1274 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
1273 | + '.custom-control-input:checked~.custom-control-label::before' => array('b', 'o'), |
|
1274 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b', 'o'), |
|
1275 | 1275 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
1276 | 1276 | // '.custom-range::-moz-range-thumb' => array('b'), |
1277 | 1277 | // '.custom-range::-ms-thumb' => array('b'), |
1278 | 1278 | '.nav-pills .nav-link.active' => array('b'), |
1279 | 1279 | '.nav-pills .show>.nav-link' => array('b'), |
1280 | 1280 | '.page-link' => array('c'), |
1281 | - '.page-item.active .page-link' => array('b','o'), |
|
1281 | + '.page-item.active .page-link' => array('b', 'o'), |
|
1282 | 1282 | '.badge-primary' => array('b'), |
1283 | - '.alert-primary' => array('b','o'), |
|
1283 | + '.alert-primary' => array('b', 'o'), |
|
1284 | 1284 | '.progress-bar' => array('b'), |
1285 | - '.list-group-item.active' => array('b','o'), |
|
1286 | - '.bg-primary' => array('b','f'), |
|
1285 | + '.list-group-item.active' => array('b', 'o'), |
|
1286 | + '.bg-primary' => array('b', 'f'), |
|
1287 | 1287 | '.btn-link.btn-primary' => array('c'), |
1288 | 1288 | '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
1289 | 1289 | ); |
1290 | 1290 | |
1291 | 1291 | $important_selectors = array( |
1292 | - '.bg-primary' => array('b','f'), |
|
1292 | + '.bg-primary' => array('b', 'f'), |
|
1293 | 1293 | '.border-primary' => array('o'), |
1294 | 1294 | '.text-primary' => array('c'), |
1295 | 1295 | ); |
@@ -1306,116 +1306,116 @@ discard block |
||
1306 | 1306 | $output = ''; |
1307 | 1307 | |
1308 | 1308 | // build rules into each type |
1309 | - foreach($selectors as $selector => $types){ |
|
1310 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1311 | - $types = array_combine($types,$types); |
|
1312 | - if(isset($types['c'])){$color[] = $selector;} |
|
1313 | - if(isset($types['b'])){$background[] = $selector;} |
|
1314 | - if(isset($types['o'])){$border[] = $selector;} |
|
1315 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1309 | + foreach ($selectors as $selector => $types) { |
|
1310 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1311 | + $types = array_combine($types, $types); |
|
1312 | + if (isset($types['c'])) {$color[] = $selector; } |
|
1313 | + if (isset($types['b'])) {$background[] = $selector; } |
|
1314 | + if (isset($types['o'])) {$border[] = $selector; } |
|
1315 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
1316 | 1316 | } |
1317 | 1317 | |
1318 | 1318 | // build rules into each type |
1319 | - foreach($important_selectors as $selector => $types){ |
|
1320 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1321 | - $types = array_combine($types,$types); |
|
1322 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1323 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1324 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1325 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1319 | + foreach ($important_selectors as $selector => $types) { |
|
1320 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1321 | + $types = array_combine($types, $types); |
|
1322 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
1323 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
1324 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
1325 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
1326 | 1326 | } |
1327 | 1327 | |
1328 | 1328 | // add any color rules |
1329 | - if(!empty($color)){ |
|
1330 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1329 | + if (!empty($color)) { |
|
1330 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
1331 | 1331 | } |
1332 | - if(!empty($color_i)){ |
|
1333 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1332 | + if (!empty($color_i)) { |
|
1333 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
1334 | 1334 | } |
1335 | 1335 | |
1336 | 1336 | // add any background color rules |
1337 | - if(!empty($background)){ |
|
1338 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1337 | + if (!empty($background)) { |
|
1338 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
1339 | 1339 | } |
1340 | - if(!empty($background_i)){ |
|
1341 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1340 | + if (!empty($background_i)) { |
|
1341 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
1342 | 1342 | } |
1343 | 1343 | |
1344 | 1344 | // add any border color rules |
1345 | - if(!empty($border)){ |
|
1346 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1345 | + if (!empty($border)) { |
|
1346 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
1347 | 1347 | } |
1348 | - if(!empty($border_i)){ |
|
1349 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1348 | + if (!empty($border_i)) { |
|
1349 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
1350 | 1350 | } |
1351 | 1351 | |
1352 | 1352 | // add any fill color rules |
1353 | - if(!empty($fill)){ |
|
1354 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1353 | + if (!empty($fill)) { |
|
1354 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
1355 | 1355 | } |
1356 | - if(!empty($fill_i)){ |
|
1357 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1356 | + if (!empty($fill_i)) { |
|
1357 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
1358 | 1358 | } |
1359 | 1359 | |
1360 | 1360 | |
1361 | 1361 | $prefix = $compatibility ? ".bsui " : ""; |
1362 | 1362 | |
1363 | 1363 | // darken |
1364 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1365 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1366 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1364 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
1365 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
1366 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
1367 | 1367 | |
1368 | 1368 | // lighten |
1369 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1369 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
1370 | 1370 | |
1371 | 1371 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
1372 | - $op_25 = $color_code."40"; // 25% opacity |
|
1372 | + $op_25 = $color_code . "40"; // 25% opacity |
|
1373 | 1373 | |
1374 | 1374 | |
1375 | 1375 | // button states |
1376 | - $output .= $prefix ." .btn-primary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1377 | - $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1378 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
1379 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1376 | + $output .= $prefix . " .btn-primary:hover{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
1377 | + $output .= $prefix . " .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1378 | + $output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: " . $darker_10 . "; border-color: " . $darker_125 . ";} "; |
|
1379 | + $output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1380 | 1380 | |
1381 | 1381 | |
1382 | 1382 | // dropdown's |
1383 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1383 | + $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1384 | 1384 | |
1385 | 1385 | |
1386 | 1386 | // input states |
1387 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1387 | + $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1388 | 1388 | |
1389 | 1389 | // page link |
1390 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1390 | + $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1391 | 1391 | |
1392 | 1392 | return $output; |
1393 | 1393 | } |
1394 | 1394 | |
1395 | - public static function css_secondary($color_code,$compatibility){; |
|
1395 | + public static function css_secondary($color_code, $compatibility) {; |
|
1396 | 1396 | $color_code = sanitize_hex_color($color_code); |
1397 | - if(!$color_code){return '';} |
|
1397 | + if (!$color_code) {return ''; } |
|
1398 | 1398 | /** |
1399 | 1399 | * c = color, b = background color, o = border-color, f = fill |
1400 | 1400 | */ |
1401 | 1401 | $selectors = array( |
1402 | - '.btn-secondary' => array('b','o'), |
|
1403 | - '.btn-secondary.disabled' => array('b','o'), |
|
1404 | - '.btn-secondary:disabled' => array('b','o'), |
|
1405 | - '.btn-outline-secondary' => array('c','o'), |
|
1406 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
1402 | + '.btn-secondary' => array('b', 'o'), |
|
1403 | + '.btn-secondary.disabled' => array('b', 'o'), |
|
1404 | + '.btn-secondary:disabled' => array('b', 'o'), |
|
1405 | + '.btn-outline-secondary' => array('c', 'o'), |
|
1406 | + '.btn-outline-secondary:hover' => array('b', 'o'), |
|
1407 | 1407 | '.btn-outline-secondary.disabled' => array('c'), |
1408 | 1408 | '.btn-outline-secondary:disabled' => array('c'), |
1409 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1410 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1411 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
1409 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
1410 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
1411 | + '.btn-outline-secondary.dropdown-toggle' => array('b', 'o'), |
|
1412 | 1412 | '.badge-secondary' => array('b'), |
1413 | - '.alert-secondary' => array('b','o'), |
|
1413 | + '.alert-secondary' => array('b', 'o'), |
|
1414 | 1414 | '.btn-link.btn-secondary' => array('c'), |
1415 | 1415 | ); |
1416 | 1416 | |
1417 | 1417 | $important_selectors = array( |
1418 | - '.bg-secondary' => array('b','f'), |
|
1418 | + '.bg-secondary' => array('b', 'f'), |
|
1419 | 1419 | '.border-secondary' => array('o'), |
1420 | 1420 | '.text-secondary' => array('c'), |
1421 | 1421 | ); |
@@ -1432,77 +1432,77 @@ discard block |
||
1432 | 1432 | $output = ''; |
1433 | 1433 | |
1434 | 1434 | // build rules into each type |
1435 | - foreach($selectors as $selector => $types){ |
|
1436 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1437 | - $types = array_combine($types,$types); |
|
1438 | - if(isset($types['c'])){$color[] = $selector;} |
|
1439 | - if(isset($types['b'])){$background[] = $selector;} |
|
1440 | - if(isset($types['o'])){$border[] = $selector;} |
|
1441 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1435 | + foreach ($selectors as $selector => $types) { |
|
1436 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1437 | + $types = array_combine($types, $types); |
|
1438 | + if (isset($types['c'])) {$color[] = $selector; } |
|
1439 | + if (isset($types['b'])) {$background[] = $selector; } |
|
1440 | + if (isset($types['o'])) {$border[] = $selector; } |
|
1441 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
1442 | 1442 | } |
1443 | 1443 | |
1444 | 1444 | // build rules into each type |
1445 | - foreach($important_selectors as $selector => $types){ |
|
1446 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1447 | - $types = array_combine($types,$types); |
|
1448 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1449 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1450 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1451 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1445 | + foreach ($important_selectors as $selector => $types) { |
|
1446 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1447 | + $types = array_combine($types, $types); |
|
1448 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
1449 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
1450 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
1451 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
1452 | 1452 | } |
1453 | 1453 | |
1454 | 1454 | // add any color rules |
1455 | - if(!empty($color)){ |
|
1456 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1455 | + if (!empty($color)) { |
|
1456 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
1457 | 1457 | } |
1458 | - if(!empty($color_i)){ |
|
1459 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1458 | + if (!empty($color_i)) { |
|
1459 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
1460 | 1460 | } |
1461 | 1461 | |
1462 | 1462 | // add any background color rules |
1463 | - if(!empty($background)){ |
|
1464 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1463 | + if (!empty($background)) { |
|
1464 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
1465 | 1465 | } |
1466 | - if(!empty($background_i)){ |
|
1467 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1466 | + if (!empty($background_i)) { |
|
1467 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
1468 | 1468 | } |
1469 | 1469 | |
1470 | 1470 | // add any border color rules |
1471 | - if(!empty($border)){ |
|
1472 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1471 | + if (!empty($border)) { |
|
1472 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
1473 | 1473 | } |
1474 | - if(!empty($border_i)){ |
|
1475 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1474 | + if (!empty($border_i)) { |
|
1475 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
1476 | 1476 | } |
1477 | 1477 | |
1478 | 1478 | // add any fill color rules |
1479 | - if(!empty($fill)){ |
|
1480 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1479 | + if (!empty($fill)) { |
|
1480 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
1481 | 1481 | } |
1482 | - if(!empty($fill_i)){ |
|
1483 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1482 | + if (!empty($fill_i)) { |
|
1483 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
1484 | 1484 | } |
1485 | 1485 | |
1486 | 1486 | |
1487 | 1487 | $prefix = $compatibility ? ".bsui " : ""; |
1488 | 1488 | |
1489 | 1489 | // darken |
1490 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1491 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1492 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1490 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
1491 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
1492 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
1493 | 1493 | |
1494 | 1494 | // lighten |
1495 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1495 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
1496 | 1496 | |
1497 | 1497 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
1498 | - $op_25 = $color_code."40"; // 25% opacity |
|
1498 | + $op_25 = $color_code . "40"; // 25% opacity |
|
1499 | 1499 | |
1500 | 1500 | |
1501 | 1501 | // button states |
1502 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1503 | - $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1504 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
1505 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1502 | + $output .= $prefix . " .btn-secondary:hover{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
1503 | + $output .= $prefix . " .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1504 | + $output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: " . $darker_10 . "; border-color: " . $darker_125 . ";} "; |
|
1505 | + $output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1506 | 1506 | |
1507 | 1507 | |
1508 | 1508 | return $output; |
@@ -1538,8 +1538,8 @@ discard block |
||
1538 | 1538 | /** |
1539 | 1539 | * Check if we should display examples. |
1540 | 1540 | */ |
1541 | - public function maybe_show_examples(){ |
|
1542 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
1541 | + public function maybe_show_examples() { |
|
1542 | + if (current_user_can('manage_options') && isset($_REQUEST['preview-aui'])) { |
|
1543 | 1543 | echo "<head>"; |
1544 | 1544 | wp_head(); |
1545 | 1545 | echo "</head>"; |
@@ -1555,7 +1555,7 @@ discard block |
||
1555 | 1555 | * |
1556 | 1556 | * @return string |
1557 | 1557 | */ |
1558 | - public function get_examples(){ |
|
1558 | + public function get_examples() { |
|
1559 | 1559 | $output = ''; |
1560 | 1560 | |
1561 | 1561 |
@@ -11,93 +11,93 @@ |
||
11 | 11 | |
12 | 12 | class InstalledVersions |
13 | 13 | { |
14 | -private static $installed = array ( |
|
14 | +private static $installed = array( |
|
15 | 15 | 'root' => |
16 | - array ( |
|
16 | + array( |
|
17 | 17 | 'pretty_version' => 'dev-master', |
18 | 18 | 'version' => 'dev-master', |
19 | 19 | 'aliases' => |
20 | - array ( |
|
20 | + array( |
|
21 | 21 | ), |
22 | 22 | 'reference' => '78277f1999221a9d2aa36ed867119bc4dd9b9ba5', |
23 | 23 | 'name' => 'ayecode/invoicing', |
24 | 24 | ), |
25 | 25 | 'versions' => |
26 | - array ( |
|
26 | + array( |
|
27 | 27 | 'ayecode/ayecode-connect-helper' => |
28 | - array ( |
|
28 | + array( |
|
29 | 29 | 'pretty_version' => '1.0.3', |
30 | 30 | 'version' => '1.0.3.0', |
31 | 31 | 'aliases' => |
32 | - array ( |
|
32 | + array( |
|
33 | 33 | ), |
34 | 34 | 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
35 | 35 | ), |
36 | 36 | 'ayecode/invoicing' => |
37 | - array ( |
|
37 | + array( |
|
38 | 38 | 'pretty_version' => 'dev-master', |
39 | 39 | 'version' => 'dev-master', |
40 | 40 | 'aliases' => |
41 | - array ( |
|
41 | + array( |
|
42 | 42 | ), |
43 | 43 | 'reference' => '78277f1999221a9d2aa36ed867119bc4dd9b9ba5', |
44 | 44 | ), |
45 | 45 | 'ayecode/wp-ayecode-ui' => |
46 | - array ( |
|
46 | + array( |
|
47 | 47 | 'pretty_version' => '0.1.43', |
48 | 48 | 'version' => '0.1.43.0', |
49 | 49 | 'aliases' => |
50 | - array ( |
|
50 | + array( |
|
51 | 51 | ), |
52 | 52 | 'reference' => '3606edd468c8a502df34237d0ac9e3470f2ad08d', |
53 | 53 | ), |
54 | 54 | 'ayecode/wp-font-awesome-settings' => |
55 | - array ( |
|
55 | + array( |
|
56 | 56 | 'pretty_version' => '1.0.12', |
57 | 57 | 'version' => '1.0.12.0', |
58 | 58 | 'aliases' => |
59 | - array ( |
|
59 | + array( |
|
60 | 60 | ), |
61 | 61 | 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
62 | 62 | ), |
63 | 63 | 'ayecode/wp-super-duper' => |
64 | - array ( |
|
64 | + array( |
|
65 | 65 | 'pretty_version' => '1.0.24', |
66 | 66 | 'version' => '1.0.24.0', |
67 | 67 | 'aliases' => |
68 | - array ( |
|
68 | + array( |
|
69 | 69 | ), |
70 | 70 | 'reference' => '4eaa2f6f6e1a29ff71f7fdbd694892d7479ef754', |
71 | 71 | ), |
72 | 72 | 'composer/installers' => |
73 | - array ( |
|
73 | + array( |
|
74 | 74 | 'pretty_version' => 'v1.10.0', |
75 | 75 | 'version' => '1.10.0.0', |
76 | 76 | 'aliases' => |
77 | - array ( |
|
77 | + array( |
|
78 | 78 | ), |
79 | 79 | 'reference' => '1a0357fccad9d1cc1ea0c9a05b8847fbccccb78d', |
80 | 80 | ), |
81 | 81 | 'maxmind-db/reader' => |
82 | - array ( |
|
82 | + array( |
|
83 | 83 | 'pretty_version' => 'v1.6.0', |
84 | 84 | 'version' => '1.6.0.0', |
85 | 85 | 'aliases' => |
86 | - array ( |
|
86 | + array( |
|
87 | 87 | ), |
88 | 88 | 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
89 | 89 | ), |
90 | 90 | 'roundcube/plugin-installer' => |
91 | - array ( |
|
91 | + array( |
|
92 | 92 | 'replaced' => |
93 | - array ( |
|
93 | + array( |
|
94 | 94 | 0 => '*', |
95 | 95 | ), |
96 | 96 | ), |
97 | 97 | 'shama/baton' => |
98 | - array ( |
|
98 | + array( |
|
99 | 99 | 'replaced' => |
100 | - array ( |
|
100 | + array( |
|
101 | 101 | 0 => '*', |
102 | 102 | ), |
103 | 103 | ), |
@@ -1,90 +1,90 @@ |
||
1 | -<?php return array ( |
|
1 | +<?php return array( |
|
2 | 2 | 'root' => |
3 | - array ( |
|
3 | + array( |
|
4 | 4 | 'pretty_version' => 'dev-master', |
5 | 5 | 'version' => 'dev-master', |
6 | 6 | 'aliases' => |
7 | - array ( |
|
7 | + array( |
|
8 | 8 | ), |
9 | 9 | 'reference' => '78277f1999221a9d2aa36ed867119bc4dd9b9ba5', |
10 | 10 | 'name' => 'ayecode/invoicing', |
11 | 11 | ), |
12 | 12 | 'versions' => |
13 | - array ( |
|
13 | + array( |
|
14 | 14 | 'ayecode/ayecode-connect-helper' => |
15 | - array ( |
|
15 | + array( |
|
16 | 16 | 'pretty_version' => '1.0.3', |
17 | 17 | 'version' => '1.0.3.0', |
18 | 18 | 'aliases' => |
19 | - array ( |
|
19 | + array( |
|
20 | 20 | ), |
21 | 21 | 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
22 | 22 | ), |
23 | 23 | 'ayecode/invoicing' => |
24 | - array ( |
|
24 | + array( |
|
25 | 25 | 'pretty_version' => 'dev-master', |
26 | 26 | 'version' => 'dev-master', |
27 | 27 | 'aliases' => |
28 | - array ( |
|
28 | + array( |
|
29 | 29 | ), |
30 | 30 | 'reference' => '78277f1999221a9d2aa36ed867119bc4dd9b9ba5', |
31 | 31 | ), |
32 | 32 | 'ayecode/wp-ayecode-ui' => |
33 | - array ( |
|
33 | + array( |
|
34 | 34 | 'pretty_version' => '0.1.43', |
35 | 35 | 'version' => '0.1.43.0', |
36 | 36 | 'aliases' => |
37 | - array ( |
|
37 | + array( |
|
38 | 38 | ), |
39 | 39 | 'reference' => '3606edd468c8a502df34237d0ac9e3470f2ad08d', |
40 | 40 | ), |
41 | 41 | 'ayecode/wp-font-awesome-settings' => |
42 | - array ( |
|
42 | + array( |
|
43 | 43 | 'pretty_version' => '1.0.12', |
44 | 44 | 'version' => '1.0.12.0', |
45 | 45 | 'aliases' => |
46 | - array ( |
|
46 | + array( |
|
47 | 47 | ), |
48 | 48 | 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
49 | 49 | ), |
50 | 50 | 'ayecode/wp-super-duper' => |
51 | - array ( |
|
51 | + array( |
|
52 | 52 | 'pretty_version' => '1.0.24', |
53 | 53 | 'version' => '1.0.24.0', |
54 | 54 | 'aliases' => |
55 | - array ( |
|
55 | + array( |
|
56 | 56 | ), |
57 | 57 | 'reference' => '4eaa2f6f6e1a29ff71f7fdbd694892d7479ef754', |
58 | 58 | ), |
59 | 59 | 'composer/installers' => |
60 | - array ( |
|
60 | + array( |
|
61 | 61 | 'pretty_version' => 'v1.10.0', |
62 | 62 | 'version' => '1.10.0.0', |
63 | 63 | 'aliases' => |
64 | - array ( |
|
64 | + array( |
|
65 | 65 | ), |
66 | 66 | 'reference' => '1a0357fccad9d1cc1ea0c9a05b8847fbccccb78d', |
67 | 67 | ), |
68 | 68 | 'maxmind-db/reader' => |
69 | - array ( |
|
69 | + array( |
|
70 | 70 | 'pretty_version' => 'v1.6.0', |
71 | 71 | 'version' => '1.6.0.0', |
72 | 72 | 'aliases' => |
73 | - array ( |
|
73 | + array( |
|
74 | 74 | ), |
75 | 75 | 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
76 | 76 | ), |
77 | 77 | 'roundcube/plugin-installer' => |
78 | - array ( |
|
78 | + array( |
|
79 | 79 | 'replaced' => |
80 | - array ( |
|
80 | + array( |
|
81 | 81 | 0 => '*', |
82 | 82 | ), |
83 | 83 | ), |
84 | 84 | 'shama/baton' => |
85 | - array ( |
|
85 | + array( |
|
86 | 86 | 'replaced' => |
87 | - array ( |
|
87 | + array( |
|
88 | 88 | 0 => '*', |
89 | 89 | ), |
90 | 90 | ), |