@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | // Exit if accessed directly. |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Main GetPaid Class. |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @type array $meta_tables Optional. An array of metadata table names. |
56 | 56 | * } |
57 | 57 | */ |
58 | - public function setup_globals( $args = array() ) { |
|
58 | + public function setup_globals($args = array()) { |
|
59 | 59 | parent::setup_globals( |
60 | 60 | array( |
61 | 61 | 'id' => 'getpaid', |
@@ -76,30 +76,30 @@ discard block |
||
76 | 76 | * @param array $main_nav Optional. See BP_Component::setup_nav() for description. |
77 | 77 | * @param array $sub_nav Optional. See BP_Component::setup_nav() for description. |
78 | 78 | */ |
79 | - public function setup_nav( $main_nav = array(), $sub_nav = array() ) { |
|
79 | + public function setup_nav($main_nav = array(), $sub_nav = array()) { |
|
80 | 80 | |
81 | 81 | // Abort if the integration is inactive. |
82 | - if ( ! getpaid_is_buddypress_integration_active() || ! is_user_logged_in() ) { |
|
82 | + if (!getpaid_is_buddypress_integration_active() || !is_user_logged_in()) { |
|
83 | 83 | return; |
84 | 84 | } |
85 | 85 | |
86 | 86 | // Or a user is not viewing their profile. |
87 | - if ( bp_displayed_user_id() !== bp_loggedin_user_id() ) { |
|
87 | + if (bp_displayed_user_id() !== bp_loggedin_user_id()) { |
|
88 | 88 | return; |
89 | 89 | } |
90 | 90 | |
91 | 91 | // Determine user to use. |
92 | 92 | $user_domain = bp_loggedin_user_domain(); |
93 | 93 | $slug = 'getpaid'; |
94 | - $payments_link = trailingslashit( $user_domain . $slug ); |
|
94 | + $payments_link = trailingslashit($user_domain . $slug); |
|
95 | 95 | |
96 | 96 | // Add 'Payments' to the main navigation. |
97 | 97 | $main_nav = array( |
98 | - 'name' => _x( 'Billing', 'BuddyPress profile payments screen nav', 'invoicing' ), |
|
98 | + 'name' => _x('Billing', 'BuddyPress profile payments screen nav', 'invoicing'), |
|
99 | 99 | 'slug' => $slug, |
100 | - 'position' => apply_filters( 'wpinv_bp_nav_position', wpinv_get_option( 'wpinv_menu_position', 91 ), $slug ), |
|
101 | - 'screen_function' => array( $this, 'display_current_tab' ), |
|
102 | - 'default_subnav_slug' => apply_filters( 'getpaid_default_tab', 'gp-edit-address' ), |
|
100 | + 'position' => apply_filters('wpinv_bp_nav_position', wpinv_get_option('wpinv_menu_position', 91), $slug), |
|
101 | + 'screen_function' => array($this, 'display_current_tab'), |
|
102 | + 'default_subnav_slug' => apply_filters('getpaid_default_tab', 'gp-edit-address'), |
|
103 | 103 | 'show_for_displayed_user' => false, |
104 | 104 | 'item_css_id' => $this->id, |
105 | 105 | 'parent_url' => $user_domain, |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | ); |
108 | 108 | |
109 | 109 | // Add the subnav items to the payments nav item if we are using a theme that supports this. |
110 | - foreach ( getpaid_get_user_content_tabs() as $_slug => $tab ) { |
|
110 | + foreach (getpaid_get_user_content_tabs() as $_slug => $tab) { |
|
111 | 111 | |
112 | 112 | $sub_nav[] = array( |
113 | 113 | 'name' => $tab['label'], |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | 'parent_url' => $payments_link, |
116 | 116 | 'parent_slug' => $slug, |
117 | 117 | 'position' => 10, |
118 | - 'screen_function' => function() use ( $tab ) { |
|
118 | + 'screen_function' => function() use ($tab) { |
|
119 | 119 | $GLOBALS['getpaid_bp_current_tab'] = $tab; |
120 | 120 | $this->display_current_tab(); |
121 | 121 | }, |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | } |
127 | 127 | |
128 | - parent::setup_nav( $main_nav, $sub_nav ); |
|
128 | + parent::setup_nav($main_nav, $sub_nav); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -139,36 +139,36 @@ discard block |
||
139 | 139 | * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a |
140 | 140 | * description. |
141 | 141 | */ |
142 | - public function setup_admin_bar( $wp_admin_nav = array() ) { |
|
142 | + public function setup_admin_bar($wp_admin_nav = array()) { |
|
143 | 143 | |
144 | 144 | // Menus for logged in user. |
145 | - if ( is_user_logged_in() ) { |
|
145 | + if (is_user_logged_in()) { |
|
146 | 146 | |
147 | 147 | // Setup the logged in user variables. |
148 | - $payments_link = trailingslashit( bp_loggedin_user_domain() . 'getpaid/' ); |
|
148 | + $payments_link = trailingslashit(bp_loggedin_user_domain() . 'getpaid/'); |
|
149 | 149 | |
150 | 150 | // Add the "Payments" sub menu. |
151 | 151 | $wp_admin_nav[] = array( |
152 | 152 | 'parent' => buddypress()->my_account_menu_id, |
153 | 153 | 'id' => 'my-account-getpaid', |
154 | - 'title' => _x( 'Billing', 'BuddyPress my account payments sub nav', 'invoicing' ), |
|
155 | - 'href' => $payments_link . apply_filters( 'getpaid_default_tab', 'gp-edit-address' ), |
|
154 | + 'title' => _x('Billing', 'BuddyPress my account payments sub nav', 'invoicing'), |
|
155 | + 'href' => $payments_link . apply_filters('getpaid_default_tab', 'gp-edit-address'), |
|
156 | 156 | ); |
157 | 157 | |
158 | - foreach ( getpaid_get_user_content_tabs() as $slug => $tab ) { |
|
158 | + foreach (getpaid_get_user_content_tabs() as $slug => $tab) { |
|
159 | 159 | |
160 | 160 | $wp_admin_nav[] = array( |
161 | 161 | 'parent' => 'my-account-getpaid', |
162 | 162 | 'id' => 'my-account-getpaid' . $slug, |
163 | 163 | 'title' => $tab['label'], |
164 | - 'href' => trailingslashit( $payments_link . $slug ), |
|
164 | + 'href' => trailingslashit($payments_link . $slug), |
|
165 | 165 | 'position' => 20, |
166 | 166 | ); |
167 | 167 | |
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
171 | - parent::setup_admin_bar( $wp_admin_nav ); |
|
171 | + parent::setup_admin_bar($wp_admin_nav); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -179,9 +179,9 @@ discard block |
||
179 | 179 | public function get_current_tab() { |
180 | 180 | global $getpaid_bp_current_tab; |
181 | 181 | |
182 | - if ( empty( $getpaid_bp_current_tab ) ) { |
|
182 | + if (empty($getpaid_bp_current_tab)) { |
|
183 | 183 | return array( |
184 | - 'label' => __( 'Invoices', 'invoicing' ), |
|
184 | + 'label' => __('Invoices', 'invoicing'), |
|
185 | 185 | 'content' => '[wpinv_history]', |
186 | 186 | 'icon' => 'fas fa-file-invoice', |
187 | 187 | ); |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | */ |
198 | 198 | public function display_current_tab() { |
199 | 199 | |
200 | - add_action( 'bp_template_content', array( $this, 'handle_display_current_tab' ) ); |
|
201 | - $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ); |
|
200 | + add_action('bp_template_content', array($this, 'handle_display_current_tab')); |
|
201 | + $template = apply_filters('bp_core_template_plugin', 'members/single/plugins'); |
|
202 | 202 | |
203 | - bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) ); |
|
203 | + bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template)); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @since 2.1.5 |
210 | 210 | */ |
211 | 211 | public function handle_display_current_tab() { |
212 | - echo getpaid_prepare_user_content_tab( $this->get_current_tab() ); |
|
212 | + echo getpaid_prepare_user_content_tab($this->get_current_tab()); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | } |
@@ -13,18 +13,18 @@ discard block |
||
13 | 13 | * @return WPInv_Subscription[]|WPInv_Subscription|false |
14 | 14 | * @since 2.3.0 |
15 | 15 | */ |
16 | -function getpaid_get_invoice_subscriptions( $invoice ) { |
|
16 | +function getpaid_get_invoice_subscriptions($invoice) { |
|
17 | 17 | |
18 | 18 | // Retrieve subscription groups. |
19 | - $subscription_ids = wp_list_pluck( getpaid_get_invoice_subscription_groups( $invoice->get_id() ), 'subscription_id' ); |
|
19 | + $subscription_ids = wp_list_pluck(getpaid_get_invoice_subscription_groups($invoice->get_id()), 'subscription_id'); |
|
20 | 20 | |
21 | 21 | // No subscription groups, normal subscription. |
22 | - if ( empty( $subscription_ids ) ) { |
|
23 | - return getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
22 | + if (empty($subscription_ids)) { |
|
23 | + return getpaid_subscriptions()->get_invoice_subscription($invoice); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | // Subscription groups. |
27 | - return array_filter( array_map( 'getpaid_get_subscription', $subscription_ids ) ); |
|
27 | + return array_filter(array_map('getpaid_get_subscription', $subscription_ids)); |
|
28 | 28 | |
29 | 29 | } |
30 | 30 | |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * @return array |
36 | 36 | * @since 2.3.0 |
37 | 37 | */ |
38 | -function getpaid_get_invoice_subscription_groups( $invoice_id ) { |
|
39 | - $subscription_groups = get_post_meta( $invoice_id, 'getpaid_subscription_groups', true ); |
|
40 | - return empty( $subscription_groups ) ? array() : $subscription_groups; |
|
38 | +function getpaid_get_invoice_subscription_groups($invoice_id) { |
|
39 | + $subscription_groups = get_post_meta($invoice_id, 'getpaid_subscription_groups', true); |
|
40 | + return empty($subscription_groups) ? array() : $subscription_groups; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * @return array|false |
49 | 49 | * @since 2.3.0 |
50 | 50 | */ |
51 | -function getpaid_get_invoice_subscription_group( $invoice_id, $subscription_id ) { |
|
52 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $invoice_id ); |
|
53 | - $matching_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
54 | - return reset( $matching_group ); |
|
51 | +function getpaid_get_invoice_subscription_group($invoice_id, $subscription_id) { |
|
52 | + $subscription_groups = getpaid_get_invoice_subscription_groups($invoice_id); |
|
53 | + $matching_group = wp_list_filter($subscription_groups, compact('subscription_id')); |
|
54 | + return reset($matching_group); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | * @since 2.3.0 |
62 | 62 | * @return WPInv_Subscription|false |
63 | 63 | */ |
64 | -function getpaid_get_subscription( $subscription ) { |
|
64 | +function getpaid_get_subscription($subscription) { |
|
65 | 65 | |
66 | - if ( ! is_a( $subscription, 'WPInv_Subscription' ) ) { |
|
67 | - $subscription = new WPInv_Subscription( $subscription ); |
|
66 | + if (!is_a($subscription, 'WPInv_Subscription')) { |
|
67 | + $subscription = new WPInv_Subscription($subscription); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | return $subscription->exists() ? $subscription : false; |
@@ -79,26 +79,26 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return int|array|WPInv_Subscription[]|GetPaid_Subscriptions_Query |
81 | 81 | */ |
82 | -function getpaid_get_subscriptions( $args = array(), $return = 'results' ) { |
|
82 | +function getpaid_get_subscriptions($args = array(), $return = 'results') { |
|
83 | 83 | |
84 | 84 | // Do not retrieve all fields if we just want the count. |
85 | - if ( 'count' == $return ) { |
|
85 | + if ('count' == $return) { |
|
86 | 86 | $args['fields'] = 'id'; |
87 | 87 | $args['number'] = 1; |
88 | 88 | } |
89 | 89 | |
90 | 90 | // Do not count all matches if we just want the results. |
91 | - if ( 'results' == $return ) { |
|
91 | + if ('results' == $return) { |
|
92 | 92 | $args['count_total'] = false; |
93 | 93 | } |
94 | 94 | |
95 | - $query = new GetPaid_Subscriptions_Query( $args ); |
|
95 | + $query = new GetPaid_Subscriptions_Query($args); |
|
96 | 96 | |
97 | - if ( 'results' == $return ) { |
|
97 | + if ('results' == $return) { |
|
98 | 98 | return $query->get_results(); |
99 | 99 | } |
100 | 100 | |
101 | - if ( 'count' == $return ) { |
|
101 | + if ('count' == $return) { |
|
102 | 102 | return $query->get_total(); |
103 | 103 | } |
104 | 104 | |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | return apply_filters( |
116 | 116 | 'getpaid_get_subscription_statuses', |
117 | 117 | array( |
118 | - 'pending' => __( 'Pending', 'invoicing' ), |
|
119 | - 'trialling' => __( 'Trialing', 'invoicing' ), |
|
120 | - 'active' => __( 'Active', 'invoicing' ), |
|
121 | - 'failing' => __( 'Failing', 'invoicing' ), |
|
122 | - 'expired' => __( 'Expired', 'invoicing' ), |
|
123 | - 'completed' => __( 'Complete', 'invoicing' ), |
|
124 | - 'cancelled' => __( 'Cancelled', 'invoicing' ), |
|
118 | + 'pending' => __('Pending', 'invoicing'), |
|
119 | + 'trialling' => __('Trialing', 'invoicing'), |
|
120 | + 'active' => __('Active', 'invoicing'), |
|
121 | + 'failing' => __('Failing', 'invoicing'), |
|
122 | + 'expired' => __('Expired', 'invoicing'), |
|
123 | + 'completed' => __('Complete', 'invoicing'), |
|
124 | + 'cancelled' => __('Cancelled', 'invoicing'), |
|
125 | 125 | ) |
126 | 126 | ); |
127 | 127 | |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return string |
134 | 134 | */ |
135 | -function getpaid_get_subscription_status_label( $status ) { |
|
135 | +function getpaid_get_subscription_status_label($status) { |
|
136 | 136 | $statuses = getpaid_get_subscription_statuses(); |
137 | - return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) ); |
|
137 | + return isset($statuses[$status]) ? $statuses[$status] : ucfirst(sanitize_text_field($status)); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -164,14 +164,14 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @return array |
166 | 166 | */ |
167 | -function getpaid_get_subscription_status_counts( $args = array() ) { |
|
167 | +function getpaid_get_subscription_status_counts($args = array()) { |
|
168 | 168 | |
169 | - $statuses = array_keys( getpaid_get_subscription_statuses() ); |
|
169 | + $statuses = array_keys(getpaid_get_subscription_statuses()); |
|
170 | 170 | $counts = array(); |
171 | 171 | |
172 | - foreach ( $statuses as $status ) { |
|
173 | - $_args = wp_parse_args( "status=$status", $args ); |
|
174 | - $counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' ); |
|
172 | + foreach ($statuses as $status) { |
|
173 | + $_args = wp_parse_args("status=$status", $args); |
|
174 | + $counts[$status] = getpaid_get_subscriptions($_args, 'count'); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | return $counts; |
@@ -190,23 +190,23 @@ discard block |
||
190 | 190 | array( |
191 | 191 | |
192 | 192 | 'day' => array( |
193 | - 'singular' => __( '%s day', 'invoicing' ), |
|
194 | - 'plural' => __( '%d days', 'invoicing' ), |
|
193 | + 'singular' => __('%s day', 'invoicing'), |
|
194 | + 'plural' => __('%d days', 'invoicing'), |
|
195 | 195 | ), |
196 | 196 | |
197 | 197 | 'week' => array( |
198 | - 'singular' => __( '%s week', 'invoicing' ), |
|
199 | - 'plural' => __( '%d weeks', 'invoicing' ), |
|
198 | + 'singular' => __('%s week', 'invoicing'), |
|
199 | + 'plural' => __('%d weeks', 'invoicing'), |
|
200 | 200 | ), |
201 | 201 | |
202 | 202 | 'month' => array( |
203 | - 'singular' => __( '%s month', 'invoicing' ), |
|
204 | - 'plural' => __( '%d months', 'invoicing' ), |
|
203 | + 'singular' => __('%s month', 'invoicing'), |
|
204 | + 'plural' => __('%d months', 'invoicing'), |
|
205 | 205 | ), |
206 | 206 | |
207 | 207 | 'year' => array( |
208 | - 'singular' => __( '%s year', 'invoicing' ), |
|
209 | - 'plural' => __( '%d years', 'invoicing' ), |
|
208 | + 'singular' => __('%s year', 'invoicing'), |
|
209 | + 'plural' => __('%d years', 'invoicing'), |
|
210 | 210 | ), |
211 | 211 | |
212 | 212 | ) |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | * @param string $trial_period |
221 | 221 | * @return int |
222 | 222 | */ |
223 | -function getpaid_get_subscription_trial_period_interval( $trial_period ) { |
|
224 | - return (int) preg_replace( '/[^0-9]/', '', $trial_period ); |
|
223 | +function getpaid_get_subscription_trial_period_interval($trial_period) { |
|
224 | + return (int) preg_replace('/[^0-9]/', '', $trial_period); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | * @param string $trial_period |
231 | 231 | * @return string |
232 | 232 | */ |
233 | -function getpaid_get_subscription_trial_period_period( $trial_period ) { |
|
234 | - return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) ); |
|
233 | +function getpaid_get_subscription_trial_period_period($trial_period) { |
|
234 | + return preg_replace('/[^a-z]/', '', strtolower($trial_period)); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | * @param int $interval |
242 | 242 | * @return string |
243 | 243 | */ |
244 | -function getpaid_get_subscription_period_label( $period, $interval = 1, $singular_prefix = '1' ) { |
|
245 | - $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix ); |
|
246 | - return strtolower( sanitize_text_field( $label ) ); |
|
244 | +function getpaid_get_subscription_period_label($period, $interval = 1, $singular_prefix = '1') { |
|
245 | + $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label($period, $interval) : getpaid_get_singular_subscription_period_label($period, $singular_prefix); |
|
246 | + return strtolower(sanitize_text_field($label)); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -252,19 +252,19 @@ discard block |
||
252 | 252 | * @param string $period |
253 | 253 | * @return string |
254 | 254 | */ |
255 | -function getpaid_get_singular_subscription_period_label( $period, $singular_prefix = '1' ) { |
|
255 | +function getpaid_get_singular_subscription_period_label($period, $singular_prefix = '1') { |
|
256 | 256 | |
257 | 257 | $periods = getpaid_get_subscription_periods(); |
258 | - $period = strtolower( $period ); |
|
258 | + $period = strtolower($period); |
|
259 | 259 | |
260 | - if ( isset( $periods[ $period ] ) ) { |
|
261 | - return sprintf( $periods[ $period ]['singular'], $singular_prefix ); |
|
260 | + if (isset($periods[$period])) { |
|
261 | + return sprintf($periods[$period]['singular'], $singular_prefix); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | // Backwards compatibility. |
265 | - foreach ( $periods as $key => $data ) { |
|
266 | - if ( strpos( $key, $period ) === 0 ) { |
|
267 | - return sprintf( $data['singular'], $singular_prefix ); |
|
265 | + foreach ($periods as $key => $data) { |
|
266 | + if (strpos($key, $period) === 0) { |
|
267 | + return sprintf($data['singular'], $singular_prefix); |
|
268 | 268 | } |
269 | 269 | } |
270 | 270 | |
@@ -279,19 +279,19 @@ discard block |
||
279 | 279 | * @param int $interval |
280 | 280 | * @return string |
281 | 281 | */ |
282 | -function getpaid_get_plural_subscription_period_label( $period, $interval ) { |
|
282 | +function getpaid_get_plural_subscription_period_label($period, $interval) { |
|
283 | 283 | |
284 | 284 | $periods = getpaid_get_subscription_periods(); |
285 | - $period = strtolower( $period ); |
|
285 | + $period = strtolower($period); |
|
286 | 286 | |
287 | - if ( isset( $periods[ $period ] ) ) { |
|
288 | - return sprintf( $periods[ $period ]['plural'], $interval ); |
|
287 | + if (isset($periods[$period])) { |
|
288 | + return sprintf($periods[$period]['plural'], $interval); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | // Backwards compatibility. |
292 | - foreach ( $periods as $key => $data ) { |
|
293 | - if ( strpos( $key, $period ) === 0 ) { |
|
294 | - return sprintf( $data['plural'], $interval ); |
|
292 | + foreach ($periods as $key => $data) { |
|
293 | + if (strpos($key, $period) === 0) { |
|
294 | + return sprintf($data['plural'], $interval); |
|
295 | 295 | } |
296 | 296 | } |
297 | 297 | |
@@ -305,33 +305,33 @@ discard block |
||
305 | 305 | * @param WPInv_Subscription $subscription |
306 | 306 | * @return string |
307 | 307 | */ |
308 | -function getpaid_get_formatted_subscription_amount( $subscription ) { |
|
308 | +function getpaid_get_formatted_subscription_amount($subscription) { |
|
309 | 309 | |
310 | - $initial = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
311 | - $recurring = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
312 | - $period = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
310 | + $initial = wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency()); |
|
311 | + $recurring = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency()); |
|
312 | + $period = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''); |
|
313 | 313 | $bill_times = $subscription->get_bill_times(); |
314 | 314 | $bill_times_less = $bill_times - 1; |
315 | 315 | |
316 | - if ( ! empty( $bill_times ) ) { |
|
316 | + if (!empty($bill_times)) { |
|
317 | 317 | $bill_times = $subscription->get_frequency() * $bill_times; |
318 | - $bill_times_less = getpaid_get_subscription_period_label( $subscription->get_frequency(), $bill_times - $subscription->get_frequency() ); |
|
319 | - $bill_times = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times ); |
|
318 | + $bill_times_less = getpaid_get_subscription_period_label($subscription->get_frequency(), $bill_times - $subscription->get_frequency()); |
|
319 | + $bill_times = getpaid_get_subscription_period_label($subscription->get_period(), $bill_times); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | // Trial periods. |
323 | - if ( $subscription->has_trial_period() ) { |
|
323 | + if ($subscription->has_trial_period()) { |
|
324 | 324 | |
325 | - $trial_period = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() ); |
|
326 | - $trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() ); |
|
325 | + $trial_period = getpaid_get_subscription_trial_period_period($subscription->get_trial_period()); |
|
326 | + $trial_interval = getpaid_get_subscription_trial_period_interval($subscription->get_trial_period()); |
|
327 | 327 | |
328 | - if ( empty( $bill_times ) ) { |
|
328 | + if (empty($bill_times)) { |
|
329 | 329 | |
330 | 330 | return sprintf( |
331 | 331 | // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period |
332 | - _x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ), |
|
332 | + _x('%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing'), |
|
333 | 333 | $initial, |
334 | - getpaid_get_subscription_period_label( $trial_period, $trial_interval ), |
|
334 | + getpaid_get_subscription_period_label($trial_period, $trial_interval), |
|
335 | 335 | $recurring, |
336 | 336 | $period |
337 | 337 | ); |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | |
341 | 341 | return sprintf( |
342 | 342 | // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period, $5: is the bill times |
343 | - _x( '%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing' ), |
|
343 | + _x('%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing'), |
|
344 | 344 | $initial, |
345 | - getpaid_get_subscription_period_label( $trial_period, $trial_interval ), |
|
345 | + getpaid_get_subscription_period_label($trial_period, $trial_interval), |
|
346 | 346 | $recurring, |
347 | 347 | $period, |
348 | 348 | $bill_times |
@@ -350,13 +350,13 @@ discard block |
||
350 | 350 | |
351 | 351 | } |
352 | 352 | |
353 | - if ( $initial != $recurring ) { |
|
353 | + if ($initial != $recurring) { |
|
354 | 354 | |
355 | - if ( empty( $bill_times ) ) { |
|
355 | + if (empty($bill_times)) { |
|
356 | 356 | |
357 | 357 | return sprintf( |
358 | 358 | // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period |
359 | - _x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ), |
|
359 | + _x('Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing'), |
|
360 | 360 | $initial, |
361 | 361 | $recurring, |
362 | 362 | $period |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | |
367 | 367 | return sprintf( |
368 | 368 | // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period, $4: is the bill times |
369 | - _x( 'Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing' ), |
|
369 | + _x('Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing'), |
|
370 | 370 | $initial, |
371 | 371 | $recurring, |
372 | 372 | $period, |
@@ -375,11 +375,11 @@ discard block |
||
375 | 375 | |
376 | 376 | } |
377 | 377 | |
378 | - if ( empty( $bill_times ) ) { |
|
378 | + if (empty($bill_times)) { |
|
379 | 379 | |
380 | 380 | return sprintf( |
381 | 381 | // translators: $1: is the recurring amount, $2: is the recurring period |
382 | - _x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
382 | + _x('%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing'), |
|
383 | 383 | $initial, |
384 | 384 | $period |
385 | 385 | ); |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | |
389 | 389 | return sprintf( |
390 | 390 | // translators: $1: is the bill times, $2: is the recurring amount, $3: is the recurring period |
391 | - _x( '%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ), |
|
391 | + _x('%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing'), |
|
392 | 392 | $bill_times, |
393 | 393 | $initial, |
394 | 394 | $period |
@@ -402,8 +402,8 @@ discard block |
||
402 | 402 | * @param WPInv_Invoice $invoice |
403 | 403 | * @return WPInv_Subscription|false |
404 | 404 | */ |
405 | -function getpaid_get_invoice_subscription( $invoice ) { |
|
406 | - return getpaid_subscriptions()->get_invoice_subscription( $invoice ); |
|
405 | +function getpaid_get_invoice_subscription($invoice) { |
|
406 | + return getpaid_subscriptions()->get_invoice_subscription($invoice); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -411,9 +411,9 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @param WPInv_Invoice $invoice |
413 | 413 | */ |
414 | -function getpaid_activate_invoice_subscription( $invoice ) { |
|
415 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
416 | - if ( is_a( $subscription, 'WPInv_Subscription' ) ) { |
|
414 | +function getpaid_activate_invoice_subscription($invoice) { |
|
415 | + $subscription = getpaid_get_invoice_subscription($invoice); |
|
416 | + if (is_a($subscription, 'WPInv_Subscription')) { |
|
417 | 417 | $subscription->activate(); |
418 | 418 | } |
419 | 419 | } |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @return WPInv_Subscriptions |
425 | 425 | */ |
426 | 426 | function getpaid_subscriptions() { |
427 | - return getpaid()->get( 'subscriptions' ); |
|
427 | + return getpaid()->get('subscriptions'); |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | /** |
@@ -433,13 +433,13 @@ discard block |
||
433 | 433 | * @since 2.3.0 |
434 | 434 | * @return WPInv_Subscription|bool |
435 | 435 | */ |
436 | -function wpinv_get_invoice_subscription( $invoice ) { |
|
436 | +function wpinv_get_invoice_subscription($invoice) { |
|
437 | 437 | |
438 | 438 | // Retrieve the invoice. |
439 | - $invoice = new WPInv_Invoice( $invoice ); |
|
439 | + $invoice = new WPInv_Invoice($invoice); |
|
440 | 440 | |
441 | 441 | // Ensure it is a recurring invoice. |
442 | - if ( ! $invoice->is_recurring() ) { |
|
442 | + if (!$invoice->is_recurring()) { |
|
443 | 443 | return false; |
444 | 444 | } |
445 | 445 | |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | ) |
452 | 452 | ); |
453 | 453 | |
454 | - return empty( $subscription ) ? false : $subscription[0]; |
|
454 | + return empty($subscription) ? false : $subscription[0]; |
|
455 | 455 | |
456 | 456 | } |
457 | 457 | |
@@ -466,50 +466,50 @@ discard block |
||
466 | 466 | * @param GetPaid_Form_Item|WPInv_Item $cart_item |
467 | 467 | * @return string |
468 | 468 | */ |
469 | -function getpaid_get_recurring_item_key( $cart_item ) { |
|
469 | +function getpaid_get_recurring_item_key($cart_item) { |
|
470 | 470 | |
471 | 471 | $cart_key = 'renews_'; |
472 | 472 | $interval = $cart_item->get_recurring_interval(); |
473 | - $period = $cart_item->get_recurring_period( true ); |
|
473 | + $period = $cart_item->get_recurring_period(true); |
|
474 | 474 | $length = $cart_item->get_recurring_limit() * $interval; |
475 | - $trial_period = $cart_item->get_trial_period( true ); |
|
475 | + $trial_period = $cart_item->get_trial_period(true); |
|
476 | 476 | $trial_length = $cart_item->get_trial_interval(); |
477 | 477 | |
478 | 478 | // First start with the billing interval and period |
479 | - switch ( $interval ) { |
|
479 | + switch ($interval) { |
|
480 | 480 | case 1: |
481 | - if ( 'day' == $period ) { |
|
481 | + if ('day' == $period) { |
|
482 | 482 | $cart_key .= 'daily'; |
483 | 483 | } else { |
484 | - $cart_key .= sprintf( '%sly', $period ); |
|
484 | + $cart_key .= sprintf('%sly', $period); |
|
485 | 485 | } |
486 | 486 | break; |
487 | 487 | case 2: |
488 | - $cart_key .= sprintf( 'every_2nd_%s', $period ); |
|
488 | + $cart_key .= sprintf('every_2nd_%s', $period); |
|
489 | 489 | break; |
490 | 490 | case 3: |
491 | - $cart_key .= sprintf( 'every_3rd_%s', $period ); |
|
491 | + $cart_key .= sprintf('every_3rd_%s', $period); |
|
492 | 492 | break; |
493 | 493 | default: |
494 | - $cart_key .= sprintf( 'every_%dth_%s', $interval, $period ); |
|
494 | + $cart_key .= sprintf('every_%dth_%s', $interval, $period); |
|
495 | 495 | break; |
496 | 496 | } |
497 | 497 | |
498 | 498 | // Maybe add the optional maximum billing periods... |
499 | - if ( $length > 0 ) { |
|
499 | + if ($length > 0) { |
|
500 | 500 | $cart_key .= '_for_'; |
501 | - $cart_key .= sprintf( '%d_%s', $length, $period ); |
|
502 | - if ( $length > 1 ) { |
|
501 | + $cart_key .= sprintf('%d_%s', $length, $period); |
|
502 | + if ($length > 1) { |
|
503 | 503 | $cart_key .= 's'; |
504 | 504 | } |
505 | 505 | } |
506 | 506 | |
507 | 507 | // And an optional free trial. |
508 | - if ( $cart_item->has_free_trial() ) { |
|
509 | - $cart_key .= sprintf( '_after_a_%d_%s_trial', $trial_length, $trial_period ); |
|
508 | + if ($cart_item->has_free_trial()) { |
|
509 | + $cart_key .= sprintf('_after_a_%d_%s_trial', $trial_length, $trial_period); |
|
510 | 510 | } |
511 | 511 | |
512 | - return apply_filters( 'getpaid_get_recurring_item_key', $cart_key, $cart_item ); |
|
512 | + return apply_filters('getpaid_get_recurring_item_key', $cart_key, $cart_item); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | /** |
@@ -518,14 +518,14 @@ discard block |
||
518 | 518 | * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice |
519 | 519 | * @return array |
520 | 520 | */ |
521 | -function getpaid_get_subscription_groups( $invoice ) { |
|
521 | +function getpaid_get_subscription_groups($invoice) { |
|
522 | 522 | |
523 | 523 | // Generate subscription groups. |
524 | 524 | $subscription_groups = array(); |
525 | - foreach ( $invoice->get_items() as $item ) { |
|
525 | + foreach ($invoice->get_items() as $item) { |
|
526 | 526 | |
527 | - if ( $item->is_recurring() ) { |
|
528 | - $subscription_groups[ getpaid_get_recurring_item_key( $item ) ][] = $item; |
|
527 | + if ($item->is_recurring()) { |
|
528 | + $subscription_groups[getpaid_get_recurring_item_key($item)][] = $item; |
|
529 | 529 | } |
530 | 530 | } |
531 | 531 | |
@@ -541,19 +541,19 @@ discard block |
||
541 | 541 | * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice |
542 | 542 | * @return array |
543 | 543 | */ |
544 | -function getpaid_calculate_subscription_totals( $invoice ) { |
|
544 | +function getpaid_calculate_subscription_totals($invoice) { |
|
545 | 545 | |
546 | 546 | // Generate subscription groups. |
547 | - $subscription_groups = getpaid_get_subscription_groups( $invoice ); |
|
547 | + $subscription_groups = getpaid_get_subscription_groups($invoice); |
|
548 | 548 | |
549 | 549 | // Now let's calculate the totals for each group of subscriptions |
550 | 550 | $subscription_totals = array(); |
551 | 551 | |
552 | - foreach ( $subscription_groups as $subscription_key => $items ) { |
|
552 | + foreach ($subscription_groups as $subscription_key => $items) { |
|
553 | 553 | |
554 | - if ( empty( $subscription_totals[ $subscription_key ] ) ) { |
|
554 | + if (empty($subscription_totals[$subscription_key])) { |
|
555 | 555 | |
556 | - $subscription_totals[ $subscription_key ] = array( |
|
556 | + $subscription_totals[$subscription_key] = array( |
|
557 | 557 | 'initial_total' => 0, |
558 | 558 | 'recurring_total' => 0, |
559 | 559 | 'items' => array(), |
@@ -566,33 +566,33 @@ discard block |
||
566 | 566 | * Get the totals of the group. |
567 | 567 | * @var GetPaid_Form_Item $item |
568 | 568 | */ |
569 | - foreach ( $items as $item ) { |
|
569 | + foreach ($items as $item) { |
|
570 | 570 | |
571 | - $subscription_totals[ $subscription_key ]['items'][ $item->get_id() ] = $item->prepare_data_for_saving(); |
|
572 | - $subscription_totals[ $subscription_key ]['item_id'] = $item->get_id(); |
|
573 | - $subscription_totals[ $subscription_key ]['period'] = $item->get_recurring_period( true ); |
|
574 | - $subscription_totals[ $subscription_key ]['interval'] = $item->get_recurring_interval(); |
|
575 | - $subscription_totals[ $subscription_key ]['initial_total'] += $item->get_sub_total() + $item->item_tax - $item->item_discount; |
|
576 | - $subscription_totals[ $subscription_key ]['recurring_total'] += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount; |
|
577 | - $subscription_totals[ $subscription_key ]['recurring_limit'] = $item->get_recurring_limit(); |
|
571 | + $subscription_totals[$subscription_key]['items'][$item->get_id()] = $item->prepare_data_for_saving(); |
|
572 | + $subscription_totals[$subscription_key]['item_id'] = $item->get_id(); |
|
573 | + $subscription_totals[$subscription_key]['period'] = $item->get_recurring_period(true); |
|
574 | + $subscription_totals[$subscription_key]['interval'] = $item->get_recurring_interval(); |
|
575 | + $subscription_totals[$subscription_key]['initial_total'] += $item->get_sub_total() + $item->item_tax - $item->item_discount; |
|
576 | + $subscription_totals[$subscription_key]['recurring_total'] += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount; |
|
577 | + $subscription_totals[$subscription_key]['recurring_limit'] = $item->get_recurring_limit(); |
|
578 | 578 | |
579 | 579 | // Calculate the next renewal date. |
580 | - $period = $item->get_recurring_period( true ); |
|
580 | + $period = $item->get_recurring_period(true); |
|
581 | 581 | $interval = $item->get_recurring_interval(); |
582 | 582 | |
583 | 583 | // If the subscription item has a trial period... |
584 | - if ( $item->has_free_trial() ) { |
|
585 | - $period = $item->get_trial_period( true ); |
|
584 | + if ($item->has_free_trial()) { |
|
585 | + $period = $item->get_trial_period(true); |
|
586 | 586 | $interval = $item->get_trial_interval(); |
587 | - $subscription_totals[ $subscription_key ]['trialling'] = $interval . ' ' . $period; |
|
587 | + $subscription_totals[$subscription_key]['trialling'] = $interval . ' ' . $period; |
|
588 | 588 | } |
589 | 589 | |
590 | - $subscription_totals[ $subscription_key ]['renews_on'] = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", current_time( 'timestamp' ) ) ); |
|
590 | + $subscription_totals[$subscription_key]['renews_on'] = date('Y-m-d H:i:s', strtotime("+$interval $period", current_time('timestamp'))); |
|
591 | 591 | |
592 | 592 | } |
593 | 593 | } |
594 | 594 | |
595 | - return apply_filters( 'getpaid_calculate_subscription_totals', $subscription_totals, $invoice ); |
|
595 | + return apply_filters('getpaid_calculate_subscription_totals', $subscription_totals, $invoice); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | /** |
@@ -601,18 +601,18 @@ discard block |
||
601 | 601 | * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice |
602 | 602 | * @return array |
603 | 603 | */ |
604 | -function getpaid_should_group_subscriptions( $invoice ) { |
|
604 | +function getpaid_should_group_subscriptions($invoice) { |
|
605 | 605 | |
606 | 606 | $recurring_items = 0; |
607 | 607 | |
608 | - foreach ( $invoice->get_items() as $item ) { |
|
608 | + foreach ($invoice->get_items() as $item) { |
|
609 | 609 | |
610 | - if ( $item->is_recurring() ) { |
|
611 | - $recurring_items ++; |
|
610 | + if ($item->is_recurring()) { |
|
611 | + $recurring_items++; |
|
612 | 612 | } |
613 | 613 | } |
614 | 614 | |
615 | - return apply_filters( 'getpaid_should_group_subscriptions', $recurring_items > 1, $invoice ); |
|
615 | + return apply_filters('getpaid_should_group_subscriptions', $recurring_items > 1, $invoice); |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | /** |
@@ -622,12 +622,12 @@ discard block |
||
622 | 622 | * @param int|false $subscription_id |
623 | 623 | * @return int |
624 | 624 | */ |
625 | -function getpaid_count_subscription_invoices( $parent_invoice_id, $subscription_id = false ) { |
|
625 | +function getpaid_count_subscription_invoices($parent_invoice_id, $subscription_id = false) { |
|
626 | 626 | global $wpdb; |
627 | 627 | |
628 | 628 | $parent_invoice_id = (int) $parent_invoice_id; |
629 | 629 | |
630 | - if ( false === $subscription_id || ! (bool) get_post_meta( $parent_invoice_id, '_wpinv_subscription_id', true ) ) { |
|
630 | + if (false === $subscription_id || !(bool) get_post_meta($parent_invoice_id, '_wpinv_subscription_id', true)) { |
|
631 | 631 | |
632 | 632 | return (int) $wpdb->get_var( |
633 | 633 | $wpdb->prepare( |
@@ -649,10 +649,10 @@ discard block |
||
649 | 649 | |
650 | 650 | $count = 0; |
651 | 651 | |
652 | - foreach ( wp_parse_id_list( $invoice_ids ) as $invoice_id ) { |
|
652 | + foreach (wp_parse_id_list($invoice_ids) as $invoice_id) { |
|
653 | 653 | |
654 | - if ( $invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta( $invoice_id, '_wpinv_subscription_id', true ) ) { |
|
655 | - $count ++; |
|
654 | + if ($invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta($invoice_id, '_wpinv_subscription_id', true)) { |
|
655 | + $count++; |
|
656 | 656 | continue; |
657 | 657 | } |
658 | 658 | } |
@@ -7,63 +7,63 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
13 | -$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) ); |
|
14 | -if ( ! empty( $required ) ) { |
|
12 | +$label = empty($label) ? '' : wp_kses_post($label); |
|
13 | +$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label)); |
|
14 | +if (!empty($required)) { |
|
15 | 15 | $label .= "<span class='text-danger'> *</span>"; |
16 | 16 | } |
17 | 17 | |
18 | 18 | $disable_dates = array(); |
19 | 19 | |
20 | -if ( ! empty( $disabled_dates ) ) { |
|
21 | - $disabled_dates = preg_replace( '/\s+/', '', $disabled_dates ); |
|
22 | - $disabled_dates = str_ireplace( 'today', current_time( 'Y-m-d' ), $disabled_dates ); |
|
23 | - $disabled_dates = array_filter( explode( ',', $disabled_dates ) ); |
|
20 | +if (!empty($disabled_dates)) { |
|
21 | + $disabled_dates = preg_replace('/\s+/', '', $disabled_dates); |
|
22 | + $disabled_dates = str_ireplace('today', current_time('Y-m-d'), $disabled_dates); |
|
23 | + $disabled_dates = array_filter(explode(',', $disabled_dates)); |
|
24 | 24 | |
25 | - foreach ( $disabled_dates as $disabled_date ) { |
|
25 | + foreach ($disabled_dates as $disabled_date) { |
|
26 | 26 | |
27 | - $disabled_date = trim( $disabled_date ); |
|
27 | + $disabled_date = trim($disabled_date); |
|
28 | 28 | |
29 | - if ( false === strpos( $disabled_date, '|' ) ) { |
|
29 | + if (false === strpos($disabled_date, '|')) { |
|
30 | 30 | $disable_dates[] = $disabled_date; |
31 | 31 | continue; |
32 | 32 | } |
33 | 33 | |
34 | - $disabled_date = explode( '|', $disabled_date ); |
|
34 | + $disabled_date = explode('|', $disabled_date); |
|
35 | 35 | $disable_dates[] = array( |
36 | - 'from' => trim( $disabled_date[0] ), |
|
37 | - 'to' => trim( $disabled_date[1] ), |
|
36 | + 'from' => trim($disabled_date[0]), |
|
37 | + 'to' => trim($disabled_date[1]), |
|
38 | 38 | ); |
39 | 39 | |
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | 43 | $options = array( |
44 | - 'data-default-date' => empty( $default_date ) ? false : $default_date, |
|
45 | - 'data-min-date' => empty( $min_date ) ? false : $min_date, |
|
46 | - 'data-max-date' => empty( $max_date ) ? false : $max_date, |
|
47 | - 'data-mode' => empty( $mode ) ? 'single' : $mode, |
|
48 | - 'data-alt-format' => get_option( 'date_format', 'F j, Y' ), |
|
44 | + 'data-default-date' => empty($default_date) ? false : $default_date, |
|
45 | + 'data-min-date' => empty($min_date) ? false : $min_date, |
|
46 | + 'data-max-date' => empty($max_date) ? false : $max_date, |
|
47 | + 'data-mode' => empty($mode) ? 'single' : $mode, |
|
48 | + 'data-alt-format' => get_option('date_format', 'F j, Y'), |
|
49 | 49 | 'data-date-format' => 'Y-m-d', |
50 | 50 | 'data-alt-input' => 'true', |
51 | - 'data-disable_alt' => empty( $disabled_dates ) ? false : wp_json_encode( $disable_dates ), |
|
52 | - 'data-disable_days_alt' => empty( $disable_days ) ? false : wp_json_encode( wp_parse_id_list( $disable_days ) ), |
|
51 | + 'data-disable_alt' => empty($disabled_dates) ? false : wp_json_encode($disable_dates), |
|
52 | + 'data-disable_days_alt' => empty($disable_days) ? false : wp_json_encode(wp_parse_id_list($disable_days)), |
|
53 | 53 | ); |
54 | 54 | |
55 | 55 | aui()->input( |
56 | 56 | array( |
57 | - 'name' => esc_attr( $id ), |
|
58 | - 'id' => esc_attr( $element_id ), |
|
59 | - 'placeholder' => empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
60 | - 'required' => ! empty( $required ), |
|
57 | + 'name' => esc_attr($id), |
|
58 | + 'id' => esc_attr($element_id), |
|
59 | + 'placeholder' => empty($placeholder) ? '' : esc_attr($placeholder), |
|
60 | + 'required' => !empty($required), |
|
61 | 61 | 'label' => $label, |
62 | 62 | 'label_type' => 'vertical', |
63 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
63 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
64 | 64 | 'type' => 'datepicker', |
65 | 65 | 'class' => $label_class . ' getpaid-init-flatpickr flatpickr-input', |
66 | - 'extra_attributes' => array_filter( apply_filters( 'getpaid_date_field_attributes', $options ) ), |
|
66 | + 'extra_attributes' => array_filter(apply_filters('getpaid_date_field_attributes', $options)), |
|
67 | 67 | 'value' => $query_value, |
68 | 68 | ), |
69 | 69 | true |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 2.0.2 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * The main installer/updater class. |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @param string $upgrade_from The current invoicing version. |
27 | 27 | */ |
28 | - public function upgrade_db( $upgrade_from ) { |
|
28 | + public function upgrade_db($upgrade_from) { |
|
29 | 29 | |
30 | 30 | // Save the current invoicing version. |
31 | - update_option( 'wpinv_version', WPINV_VERSION ); |
|
31 | + update_option('wpinv_version', WPINV_VERSION); |
|
32 | 32 | |
33 | 33 | // Setup the invoice Custom Post Type. |
34 | 34 | GetPaid_Post_Types::register_post_types(); |
@@ -48,13 +48,13 @@ discard block |
||
48 | 48 | // Create any missing database tables. |
49 | 49 | $method = "upgrade_from_$upgrade_from"; |
50 | 50 | |
51 | - $installed = get_option( 'gepaid_installed_on' ); |
|
51 | + $installed = get_option('gepaid_installed_on'); |
|
52 | 52 | |
53 | - if ( empty( $installed ) ) { |
|
54 | - update_option( 'gepaid_installed_on', time() ); |
|
53 | + if (empty($installed)) { |
|
54 | + update_option('gepaid_installed_on', time()); |
|
55 | 55 | } |
56 | 56 | |
57 | - if ( method_exists( $this, $method ) ) { |
|
57 | + if (method_exists($this, $method)) { |
|
58 | 58 | $this->$method(); |
59 | 59 | } |
60 | 60 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $this->create_invoice_items_table(); |
71 | 71 | |
72 | 72 | // Save default tax rates. |
73 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
73 | + update_option('wpinv_tax_rates', wpinv_get_data('tax-rates')); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -81,27 +81,27 @@ discard block |
||
81 | 81 | global $wpdb; |
82 | 82 | |
83 | 83 | // Invoices. |
84 | - $results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
85 | - if ( ! empty( $results ) ) { |
|
86 | - $wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" ); |
|
84 | + $results = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )"); |
|
85 | + if (!empty($results)) { |
|
86 | + $wpdb->query("UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )"); |
|
87 | 87 | |
88 | 88 | // Clean post cache |
89 | - foreach ( $results as $row ) { |
|
90 | - clean_post_cache( $row->ID ); |
|
89 | + foreach ($results as $row) { |
|
90 | + clean_post_cache($row->ID); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | 94 | // Item meta key changes |
95 | 95 | $query = 'SELECT DISTINCT post_id FROM ' . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )"; |
96 | - $results = $wpdb->get_results( $query ); |
|
96 | + $results = $wpdb->get_results($query); |
|
97 | 97 | |
98 | - if ( ! empty( $results ) ) { |
|
99 | - $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" ); |
|
100 | - $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" ); |
|
101 | - $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" ); |
|
98 | + if (!empty($results)) { |
|
99 | + $wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )"); |
|
100 | + $wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'"); |
|
101 | + $wpdb->query('UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'"); |
|
102 | 102 | |
103 | - foreach ( $results as $row ) { |
|
104 | - clean_post_cache( $row->post_id ); |
|
103 | + foreach ($results as $row) { |
|
104 | + clean_post_cache($row->post_id); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function upgrade_from_207() { |
135 | 135 | global $wpdb; |
136 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);" ); |
|
136 | + $wpdb->query("ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);"); |
|
137 | 137 | $this->upgrade_from_2615(); |
138 | 138 | } |
139 | 139 | |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function upgrade_from_2615() { |
145 | 145 | global $wpdb; |
146 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN item_price DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY custom_price DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY discount DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY subtotal DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY price DECIMAL(16,4) NOT NULL DEFAULT '0';" ); |
|
147 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoices MODIFY COLUMN subtotal DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY tax DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY fees_total DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY total DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY discount DECIMAL(16,4) NOT NULL DEFAULT '0';" ); |
|
146 | + $wpdb->query("ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN item_price DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY custom_price DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY discount DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY subtotal DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY price DECIMAL(16,4) NOT NULL DEFAULT '0';"); |
|
147 | + $wpdb->query("ALTER TABLE {$wpdb->prefix}getpaid_invoices MODIFY COLUMN subtotal DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY tax DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY fees_total DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY total DECIMAL(16,4) NOT NULL DEFAULT '0', MODIFY discount DECIMAL(16,4) NOT NULL DEFAULT '0';"); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * |
153 | 153 | */ |
154 | 154 | public function add_capabilities() { |
155 | - $GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' ); |
|
155 | + $GLOBALS['wp_roles']->add_cap('administrator', 'manage_invoicing'); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | |
168 | 168 | // Checkout page. |
169 | 169 | 'checkout_page' => array( |
170 | - 'name' => _x( 'gp-checkout', 'Page slug', 'invoicing' ), |
|
171 | - 'title' => _x( 'Checkout', 'Page title', 'invoicing' ), |
|
170 | + 'name' => _x('gp-checkout', 'Page slug', 'invoicing'), |
|
171 | + 'title' => _x('Checkout', 'Page title', 'invoicing'), |
|
172 | 172 | 'content' => ' |
173 | 173 | <!-- wp:shortcode --> |
174 | 174 | [wpinv_checkout] |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | |
180 | 180 | // Invoice history page. |
181 | 181 | 'invoice_history_page' => array( |
182 | - 'name' => _x( 'gp-invoices', 'Page slug', 'invoicing' ), |
|
183 | - 'title' => _x( 'My Invoices', 'Page title', 'invoicing' ), |
|
182 | + 'name' => _x('gp-invoices', 'Page slug', 'invoicing'), |
|
183 | + 'title' => _x('My Invoices', 'Page title', 'invoicing'), |
|
184 | 184 | 'content' => ' |
185 | 185 | <!-- wp:shortcode --> |
186 | 186 | [wpinv_history] |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | |
192 | 192 | // Success page content. |
193 | 193 | 'success_page' => array( |
194 | - 'name' => _x( 'gp-receipt', 'Page slug', 'invoicing' ), |
|
195 | - 'title' => _x( 'Payment Confirmation', 'Page title', 'invoicing' ), |
|
194 | + 'name' => _x('gp-receipt', 'Page slug', 'invoicing'), |
|
195 | + 'title' => _x('Payment Confirmation', 'Page title', 'invoicing'), |
|
196 | 196 | 'content' => ' |
197 | 197 | <!-- wp:shortcode --> |
198 | 198 | [wpinv_receipt] |
@@ -203,16 +203,16 @@ discard block |
||
203 | 203 | |
204 | 204 | // Failure page content. |
205 | 205 | 'failure_page' => array( |
206 | - 'name' => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ), |
|
207 | - 'title' => _x( 'Transaction Failed', 'Page title', 'invoicing' ), |
|
208 | - 'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ), |
|
206 | + 'name' => _x('gp-transaction-failed', 'Page slug', 'invoicing'), |
|
207 | + 'title' => _x('Transaction Failed', 'Page title', 'invoicing'), |
|
208 | + 'content' => __('Your transaction failed, please try again or contact site support.', 'invoicing'), |
|
209 | 209 | 'parent' => 'gp-checkout', |
210 | 210 | ), |
211 | 211 | |
212 | 212 | // Subscriptions history page. |
213 | 213 | 'invoice_subscription_page' => array( |
214 | - 'name' => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ), |
|
215 | - 'title' => _x( 'My Subscriptions', 'Page title', 'invoicing' ), |
|
214 | + 'name' => _x('gp-subscriptions', 'Page slug', 'invoicing'), |
|
215 | + 'title' => _x('My Subscriptions', 'Page title', 'invoicing'), |
|
216 | 216 | 'content' => ' |
217 | 217 | <!-- wp:shortcode --> |
218 | 218 | [wpinv_subscriptions] |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function create_pages() { |
234 | 234 | |
235 | - foreach ( self::get_pages() as $key => $page ) { |
|
236 | - wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] ); |
|
235 | + foreach (self::get_pages() as $key => $page) { |
|
236 | + wpinv_create_page(esc_sql($page['name']), $key, $page['title'], $page['content'], $page['parent']); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | KEY customer_and_status (customer_id, status) |
274 | 274 | ) $charset_collate;"; |
275 | 275 | |
276 | - dbDelta( $sql ); |
|
276 | + dbDelta($sql); |
|
277 | 277 | |
278 | 278 | } |
279 | 279 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | KEY `key` (`key`) |
325 | 325 | ) $charset_collate;"; |
326 | 326 | |
327 | - dbDelta( $sql ); |
|
327 | + dbDelta($sql); |
|
328 | 328 | |
329 | 329 | } |
330 | 330 | |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | KEY post_id (post_id) |
362 | 362 | ) $charset_collate;"; |
363 | 363 | |
364 | - dbDelta( $sql ); |
|
364 | + dbDelta($sql); |
|
365 | 365 | |
366 | 366 | } |
367 | 367 | |
@@ -374,32 +374,32 @@ discard block |
||
374 | 374 | |
375 | 375 | $invoices_table = $wpdb->prefix . 'getpaid_invoices'; |
376 | 376 | $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items'; |
377 | - $migrated = $wpdb->get_col( "SELECT post_id FROM $invoices_table" ); |
|
377 | + $migrated = $wpdb->get_col("SELECT post_id FROM $invoices_table"); |
|
378 | 378 | $invoices = array_unique( |
379 | 379 | get_posts( |
380 | 380 | array( |
381 | - 'post_type' => array( 'wpi_invoice', 'wpi_quote' ), |
|
381 | + 'post_type' => array('wpi_invoice', 'wpi_quote'), |
|
382 | 382 | 'posts_per_page' => -1, |
383 | 383 | 'fields' => 'ids', |
384 | - 'post_status' => array_keys( get_post_stati() ), |
|
384 | + 'post_status' => array_keys(get_post_stati()), |
|
385 | 385 | 'exclude' => (array) $migrated, |
386 | 386 | ) |
387 | 387 | ) |
388 | 388 | ); |
389 | 389 | |
390 | 390 | // Abort if we do not have any invoices. |
391 | - if ( empty( $invoices ) ) { |
|
391 | + if (empty($invoices)) { |
|
392 | 392 | return; |
393 | 393 | } |
394 | 394 | |
395 | 395 | require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php'; |
396 | 396 | |
397 | 397 | $invoice_rows = array(); |
398 | - foreach ( $invoices as $invoice ) { |
|
398 | + foreach ($invoices as $invoice) { |
|
399 | 399 | |
400 | - $invoice = new WPInv_Legacy_Invoice( $invoice ); |
|
400 | + $invoice = new WPInv_Legacy_Invoice($invoice); |
|
401 | 401 | |
402 | - if ( empty( $invoice->ID ) ) { |
|
402 | + if (empty($invoice->ID)) { |
|
403 | 403 | return; |
404 | 404 | } |
405 | 405 | |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | 'post_id' => $invoice->ID, |
408 | 408 | 'number' => $invoice->get_number(), |
409 | 409 | 'key' => $invoice->get_key(), |
410 | - 'type' => str_replace( 'wpi_', '', $invoice->post_type ), |
|
410 | + 'type' => str_replace('wpi_', '', $invoice->post_type), |
|
411 | 411 | 'mode' => $invoice->mode, |
412 | 412 | 'user_ip' => $invoice->get_ip(), |
413 | 413 | 'first_name' => $invoice->get_first_name(), |
@@ -436,27 +436,27 @@ discard block |
||
436 | 436 | 'custom_meta' => $invoice->payment_meta, |
437 | 437 | ); |
438 | 438 | |
439 | - foreach ( $fields as $key => $val ) { |
|
440 | - if ( is_null( $val ) ) { |
|
439 | + foreach ($fields as $key => $val) { |
|
440 | + if (is_null($val)) { |
|
441 | 441 | $val = ''; |
442 | 442 | } |
443 | - $val = maybe_serialize( $val ); |
|
444 | - $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
443 | + $val = maybe_serialize($val); |
|
444 | + $fields[$key] = $wpdb->prepare('%s', $val); |
|
445 | 445 | } |
446 | 446 | |
447 | - $fields = implode( ', ', $fields ); |
|
447 | + $fields = implode(', ', $fields); |
|
448 | 448 | $invoice_rows[] = "($fields)"; |
449 | 449 | |
450 | 450 | $item_rows = array(); |
451 | 451 | $item_columns = array(); |
452 | - foreach ( $invoice->get_cart_details() as $details ) { |
|
452 | + foreach ($invoice->get_cart_details() as $details) { |
|
453 | 453 | $fields = array( |
454 | 454 | 'post_id' => $invoice->ID, |
455 | 455 | 'item_id' => $details['id'], |
456 | 456 | 'item_name' => $details['name'], |
457 | - 'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'], |
|
457 | + 'item_description' => empty($details['meta']['description']) ? '' : $details['meta']['description'], |
|
458 | 458 | 'vat_rate' => $details['vat_rate'], |
459 | - 'vat_class' => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'], |
|
459 | + 'vat_class' => empty($details['vat_class']) ? '_standard' : $details['vat_class'], |
|
460 | 460 | 'tax' => $details['tax'], |
461 | 461 | 'item_price' => $details['item_price'], |
462 | 462 | 'custom_price' => $details['custom_price'], |
@@ -468,31 +468,31 @@ discard block |
||
468 | 468 | 'fees' => $details['fees'], |
469 | 469 | ); |
470 | 470 | |
471 | - $item_columns = array_keys( $fields ); |
|
471 | + $item_columns = array_keys($fields); |
|
472 | 472 | |
473 | - foreach ( $fields as $key => $val ) { |
|
474 | - if ( is_null( $val ) ) { |
|
473 | + foreach ($fields as $key => $val) { |
|
474 | + if (is_null($val)) { |
|
475 | 475 | $val = ''; |
476 | 476 | } |
477 | - $val = maybe_serialize( $val ); |
|
478 | - $fields[ $key ] = $wpdb->prepare( '%s', $val ); |
|
477 | + $val = maybe_serialize($val); |
|
478 | + $fields[$key] = $wpdb->prepare('%s', $val); |
|
479 | 479 | } |
480 | 480 | |
481 | - $fields = implode( ', ', $fields ); |
|
481 | + $fields = implode(', ', $fields); |
|
482 | 482 | $item_rows[] = "($fields)"; |
483 | 483 | } |
484 | 484 | |
485 | - $item_rows = implode( ', ', $item_rows ); |
|
486 | - $item_columns = implode( ', ', $item_columns ); |
|
487 | - $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" ); |
|
485 | + $item_rows = implode(', ', $item_rows); |
|
486 | + $item_columns = implode(', ', $item_columns); |
|
487 | + $wpdb->query("INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows"); |
|
488 | 488 | } |
489 | 489 | |
490 | - if ( empty( $invoice_rows ) ) { |
|
490 | + if (empty($invoice_rows)) { |
|
491 | 491 | return; |
492 | 492 | } |
493 | 493 | |
494 | - $invoice_rows = implode( ', ', $invoice_rows ); |
|
495 | - $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" ); |
|
494 | + $invoice_rows = implode(', ', $invoice_rows); |
|
495 | + $wpdb->query("INSERT INTO $invoices_table VALUES $invoice_rows"); |
|
496 | 496 | |
497 | 497 | } |
498 | 498 | |
@@ -503,12 +503,12 @@ discard block |
||
503 | 503 | public static function rename_gateways_label() { |
504 | 504 | global $wpdb; |
505 | 505 | |
506 | - foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) { |
|
506 | + foreach (array_keys(wpinv_get_payment_gateways()) as $gateway) { |
|
507 | 507 | |
508 | 508 | $wpdb->update( |
509 | 509 | $wpdb->prefix . 'getpaid_invoices', |
510 | - array( 'gateway' => $gateway ), |
|
511 | - array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ), |
|
510 | + array('gateway' => $gateway), |
|
511 | + array('gateway' => wpinv_get_gateway_admin_label($gateway)), |
|
512 | 512 | '%s', |
513 | 513 | '%s' |
514 | 514 | ); |
@@ -4,99 +4,99 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Displays an invoice. |
11 | 11 | * |
12 | 12 | * @param WPInv_Invoice $invoice. |
13 | 13 | */ |
14 | -function getpaid_invoice( $invoice ) { |
|
15 | - if ( ! empty( $invoice ) ) { |
|
16 | - wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) ); |
|
14 | +function getpaid_invoice($invoice) { |
|
15 | + if (!empty($invoice)) { |
|
16 | + wpinv_get_template('invoice/invoice.php', compact('invoice')); |
|
17 | 17 | } |
18 | 18 | } |
19 | -add_action( 'getpaid_invoice', 'getpaid_invoice', 10 ); |
|
19 | +add_action('getpaid_invoice', 'getpaid_invoice', 10); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Displays the invoice footer. |
23 | 23 | */ |
24 | -function getpaid_invoice_footer( $invoice ) { |
|
25 | - if ( ! empty( $invoice ) ) { |
|
26 | - wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) ); |
|
24 | +function getpaid_invoice_footer($invoice) { |
|
25 | + if (!empty($invoice)) { |
|
26 | + wpinv_get_template('invoice/footer.php', compact('invoice')); |
|
27 | 27 | } |
28 | 28 | } |
29 | -add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 ); |
|
29 | +add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Displays the invoice top bar. |
33 | 33 | */ |
34 | -function getpaid_invoice_header( $invoice ) { |
|
35 | - if ( ! empty( $invoice ) ) { |
|
36 | - wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) ); |
|
34 | +function getpaid_invoice_header($invoice) { |
|
35 | + if (!empty($invoice)) { |
|
36 | + wpinv_get_template('invoice/header.php', compact('invoice')); |
|
37 | 37 | } |
38 | 38 | } |
39 | -add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 ); |
|
39 | +add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Displays actions on the left side of the header. |
43 | 43 | */ |
44 | -function getpaid_invoice_header_left_actions( $invoice ) { |
|
45 | - if ( ! empty( $invoice ) ) { |
|
46 | - wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) ); |
|
44 | +function getpaid_invoice_header_left_actions($invoice) { |
|
45 | + if (!empty($invoice)) { |
|
46 | + wpinv_get_template('invoice/header-left-actions.php', compact('invoice')); |
|
47 | 47 | } |
48 | 48 | } |
49 | -add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 ); |
|
49 | +add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Displays actions on the right side of the invoice top bar. |
53 | 53 | */ |
54 | -function getpaid_invoice_header_right_actions( $invoice ) { |
|
55 | - if ( ! empty( $invoice ) ) { |
|
56 | - wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) ); |
|
54 | +function getpaid_invoice_header_right_actions($invoice) { |
|
55 | + if (!empty($invoice)) { |
|
56 | + wpinv_get_template('invoice/header-right-actions.php', compact('invoice')); |
|
57 | 57 | } |
58 | 58 | } |
59 | -add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 ); |
|
59 | +add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Displays the invoice title, logo etc. |
63 | 63 | */ |
64 | -function getpaid_invoice_details_top( $invoice ) { |
|
65 | - if ( ! empty( $invoice ) ) { |
|
66 | - wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) ); |
|
64 | +function getpaid_invoice_details_top($invoice) { |
|
65 | + if (!empty($invoice)) { |
|
66 | + wpinv_get_template('invoice/details-top.php', compact('invoice')); |
|
67 | 67 | } |
68 | 68 | } |
69 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 ); |
|
69 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Displays the company logo. |
73 | 73 | */ |
74 | -function getpaid_invoice_logo( $invoice ) { |
|
75 | - if ( ! empty( $invoice ) ) { |
|
76 | - wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) ); |
|
74 | +function getpaid_invoice_logo($invoice) { |
|
75 | + if (!empty($invoice)) { |
|
76 | + wpinv_get_template('invoice/invoice-logo.php', compact('invoice')); |
|
77 | 77 | } |
78 | 78 | } |
79 | -add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' ); |
|
79 | +add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo'); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Displays the type of invoice. |
83 | 83 | */ |
84 | -function getpaid_invoice_type( $invoice ) { |
|
85 | - if ( ! empty( $invoice ) ) { |
|
86 | - wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) ); |
|
84 | +function getpaid_invoice_type($invoice) { |
|
85 | + if (!empty($invoice)) { |
|
86 | + wpinv_get_template('invoice/invoice-type.php', compact('invoice')); |
|
87 | 87 | } |
88 | 88 | } |
89 | -add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' ); |
|
89 | +add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type'); |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * Displays the invoice details. |
93 | 93 | */ |
94 | -function getpaid_invoice_details_main( $invoice ) { |
|
95 | - if ( ! empty( $invoice ) ) { |
|
96 | - wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) ); |
|
94 | +function getpaid_invoice_details_main($invoice) { |
|
95 | + if (!empty($invoice)) { |
|
96 | + wpinv_get_template('invoice/details.php', compact('invoice')); |
|
97 | 97 | } |
98 | 98 | } |
99 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 ); |
|
99 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50); |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Returns a path to the templates directory. |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
126 | 126 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
127 | 127 | */ |
128 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
129 | - getpaid_template()->display_template( $template_name, $args, $template_path, $default_path ); |
|
128 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
129 | + getpaid_template()->display_template($template_name, $args, $template_path, $default_path); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
141 | 141 | */ |
142 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
142 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
143 | + return getpaid_template()->get_template($template_name, $args, $template_path, $default_path); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @return string |
150 | 150 | */ |
151 | 151 | function wpinv_template_path() { |
152 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
152 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | */ |
160 | 160 | function wpinv_get_theme_template_dir_name() { |
161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
161 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -170,58 +170,58 @@ discard block |
||
170 | 170 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
171 | 171 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
172 | 172 | */ |
173 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
174 | - return getpaid_template()->locate_template( $template_name, $template_path, $default_path ); |
|
173 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
174 | + return getpaid_template()->locate_template($template_name, $template_path, $default_path); |
|
175 | 175 | } |
176 | 176 | |
177 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
177 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
178 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
179 | 179 | |
180 | 180 | // Setup possible parts |
181 | 181 | $templates = array(); |
182 | - if ( isset( $name ) ) { |
|
182 | + if (isset($name)) { |
|
183 | 183 | $templates[] = $slug . '-' . $name . '.php'; |
184 | 184 | } |
185 | 185 | $templates[] = $slug . '.php'; |
186 | 186 | |
187 | 187 | // Allow template parts to be filtered |
188 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
188 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
189 | 189 | |
190 | 190 | // Return the part that is found |
191 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
191 | + return wpinv_locate_tmpl($templates, $load, false); |
|
192 | 192 | } |
193 | 193 | |
194 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
194 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
195 | 195 | // No file found yet |
196 | 196 | $located = false; |
197 | 197 | |
198 | 198 | // Try to find a template file |
199 | - foreach ( (array)$template_names as $template_name ) { |
|
199 | + foreach ((array) $template_names as $template_name) { |
|
200 | 200 | |
201 | 201 | // Continue if template is empty |
202 | - if ( empty( $template_name ) ) { |
|
202 | + if (empty($template_name)) { |
|
203 | 203 | continue; |
204 | 204 | } |
205 | 205 | |
206 | 206 | // Trim off any slashes from the template name |
207 | - $template_name = ltrim( $template_name, '/' ); |
|
207 | + $template_name = ltrim($template_name, '/'); |
|
208 | 208 | |
209 | 209 | // try locating this template file by looping through the template paths |
210 | - foreach ( wpinv_get_theme_template_paths() as $template_path ) { |
|
210 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
211 | 211 | |
212 | - if ( file_exists( $template_path . $template_name ) ) { |
|
212 | + if (file_exists($template_path . $template_name)) { |
|
213 | 213 | $located = $template_path . $template_name; |
214 | 214 | break; |
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
218 | - if ( ! empty( $located ) ) { |
|
218 | + if (!empty($located)) { |
|
219 | 219 | break; |
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
224 | - load_template( $located, $require_once ); |
|
223 | + if ((true == $load) && !empty($located)) { |
|
224 | + load_template($located, $require_once); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | return $located; |
@@ -231,73 +231,73 @@ discard block |
||
231 | 231 | $template_dir = wpinv_get_theme_template_dir_name(); |
232 | 232 | |
233 | 233 | $file_paths = array( |
234 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
235 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
234 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
235 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
236 | 236 | 100 => wpinv_get_templates_dir(), |
237 | 237 | ); |
238 | 238 | |
239 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
239 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
240 | 240 | |
241 | 241 | // sort the file paths based on priority |
242 | - ksort( $file_paths, SORT_NUMERIC ); |
|
242 | + ksort($file_paths, SORT_NUMERIC); |
|
243 | 243 | |
244 | - return array_map( 'trailingslashit', $file_paths ); |
|
244 | + return array_map('trailingslashit', $file_paths); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | function wpinv_checkout_meta_tags() { |
248 | 248 | |
249 | 249 | $pages = array(); |
250 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
251 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
252 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
253 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
250 | + $pages[] = wpinv_get_option('success_page'); |
|
251 | + $pages[] = wpinv_get_option('failure_page'); |
|
252 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
253 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
254 | 254 | |
255 | - if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) { |
|
255 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
256 | 256 | return; |
257 | 257 | } |
258 | 258 | |
259 | 259 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
260 | 260 | } |
261 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
261 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
262 | 262 | |
263 | -function wpinv_add_body_classes( $class ) { |
|
264 | - $classes = (array)$class; |
|
263 | +function wpinv_add_body_classes($class) { |
|
264 | + $classes = (array) $class; |
|
265 | 265 | |
266 | - if ( wpinv_is_checkout() ) { |
|
266 | + if (wpinv_is_checkout()) { |
|
267 | 267 | $classes[] = 'wpinv-checkout'; |
268 | 268 | $classes[] = 'wpinv-page'; |
269 | 269 | } |
270 | 270 | |
271 | - if ( wpinv_is_success_page() ) { |
|
271 | + if (wpinv_is_success_page()) { |
|
272 | 272 | $classes[] = 'wpinv-success'; |
273 | 273 | $classes[] = 'wpinv-page'; |
274 | 274 | } |
275 | 275 | |
276 | - if ( wpinv_is_failed_transaction_page() ) { |
|
276 | + if (wpinv_is_failed_transaction_page()) { |
|
277 | 277 | $classes[] = 'wpinv-failed-transaction'; |
278 | 278 | $classes[] = 'wpinv-page'; |
279 | 279 | } |
280 | 280 | |
281 | - if ( wpinv_is_invoice_history_page() ) { |
|
281 | + if (wpinv_is_invoice_history_page()) { |
|
282 | 282 | $classes[] = 'wpinv-history'; |
283 | 283 | $classes[] = 'wpinv-page'; |
284 | 284 | } |
285 | 285 | |
286 | - if ( wpinv_is_subscriptions_history_page() ) { |
|
286 | + if (wpinv_is_subscriptions_history_page()) { |
|
287 | 287 | $classes[] = 'wpinv-subscription'; |
288 | 288 | $classes[] = 'wpinv-page'; |
289 | 289 | } |
290 | 290 | |
291 | - if ( wpinv_is_test_mode() ) { |
|
291 | + if (wpinv_is_test_mode()) { |
|
292 | 292 | $classes[] = 'wpinv-test-mode'; |
293 | 293 | $classes[] = 'wpinv-page'; |
294 | 294 | } |
295 | 295 | |
296 | - return array_unique( $classes ); |
|
296 | + return array_unique($classes); |
|
297 | 297 | } |
298 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
298 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
299 | 299 | |
300 | -function wpinv_html_select( $args = array() ) { |
|
300 | +function wpinv_html_select($args = array()) { |
|
301 | 301 | $defaults = array( |
302 | 302 | 'options' => array(), |
303 | 303 | 'name' => null, |
@@ -306,8 +306,8 @@ discard block |
||
306 | 306 | 'selected' => 0, |
307 | 307 | 'placeholder' => null, |
308 | 308 | 'multiple' => false, |
309 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
310 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
309 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
310 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
311 | 311 | 'data' => array(), |
312 | 312 | 'onchange' => null, |
313 | 313 | 'required' => false, |
@@ -315,79 +315,79 @@ discard block |
||
315 | 315 | 'readonly' => false, |
316 | 316 | ); |
317 | 317 | |
318 | - $args = wp_parse_args( $args, $defaults ); |
|
318 | + $args = wp_parse_args($args, $defaults); |
|
319 | 319 | |
320 | 320 | $attrs = array( |
321 | 321 | 'name' => $args['name'], |
322 | 322 | 'id' => $args['id'], |
323 | - 'class' => 'wpinv-select ' . implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ), |
|
324 | - 'multiple' => ! empty( $args['multiple'] ), |
|
325 | - 'readonly' => ! empty( $args['readonly'] ), |
|
326 | - 'disabled' => ! empty( $args['disabled'] ), |
|
327 | - 'required' => ! empty( $args['required'] ), |
|
328 | - 'onchange' => ! empty( $args['onchange'] ), |
|
323 | + 'class' => 'wpinv-select ' . implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))), |
|
324 | + 'multiple' => !empty($args['multiple']), |
|
325 | + 'readonly' => !empty($args['readonly']), |
|
326 | + 'disabled' => !empty($args['disabled']), |
|
327 | + 'required' => !empty($args['required']), |
|
328 | + 'onchange' => !empty($args['onchange']), |
|
329 | 329 | ); |
330 | 330 | |
331 | - if ( $args['placeholder'] ) { |
|
331 | + if ($args['placeholder']) { |
|
332 | 332 | $attrs['data-placeholder'] = $args['placeholder']; |
333 | 333 | } |
334 | 334 | |
335 | - if ( $args['onchange'] ) { |
|
335 | + if ($args['onchange']) { |
|
336 | 336 | $attrs['onchange'] = $args['onchange']; |
337 | 337 | } |
338 | 338 | |
339 | - foreach ( $args['data'] as $key => $value ) { |
|
339 | + foreach ($args['data'] as $key => $value) { |
|
340 | 340 | $attrs["data-$key"] = $value; |
341 | 341 | } |
342 | 342 | |
343 | 343 | echo '<select '; |
344 | 344 | |
345 | - foreach ( $attrs as $attr => $value ) { |
|
345 | + foreach ($attrs as $attr => $value) { |
|
346 | 346 | |
347 | - if ( false === $value ) { |
|
347 | + if (false === $value) { |
|
348 | 348 | continue; |
349 | 349 | } |
350 | 350 | |
351 | - if ( true === $value ) { |
|
352 | - echo ' ' . esc_attr( $attr ); |
|
351 | + if (true === $value) { |
|
352 | + echo ' ' . esc_attr($attr); |
|
353 | 353 | } else { |
354 | - echo ' ' . esc_attr( $attr ) . '="' . esc_attr( $value ) . '"'; |
|
354 | + echo ' ' . esc_attr($attr) . '="' . esc_attr($value) . '"'; |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | } |
358 | 358 | |
359 | 359 | echo '>'; |
360 | 360 | |
361 | - if ( $args['show_option_all'] ) { |
|
362 | - if ( $args['multiple'] ) { |
|
363 | - $selected = in_array( 0, $args['selected'] ); |
|
361 | + if ($args['show_option_all']) { |
|
362 | + if ($args['multiple']) { |
|
363 | + $selected = in_array(0, $args['selected']); |
|
364 | 364 | } else { |
365 | - $selected = empty( $args['selected'] ); |
|
365 | + $selected = empty($args['selected']); |
|
366 | 366 | } |
367 | - echo '<option value="all"' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
367 | + echo '<option value="all"' . selected($selected, true, false) . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
368 | 368 | } |
369 | 369 | |
370 | - if ( ! empty( $args['options'] ) ) { |
|
370 | + if (!empty($args['options'])) { |
|
371 | 371 | |
372 | - if ( $args['show_option_none'] ) { |
|
373 | - if ( $args['multiple'] ) { |
|
374 | - $selected = in_array( '', $args['selected'], true ); |
|
372 | + if ($args['show_option_none']) { |
|
373 | + if ($args['multiple']) { |
|
374 | + $selected = in_array('', $args['selected'], true); |
|
375 | 375 | } else { |
376 | 376 | $selected = $args['selected'] === ''; |
377 | 377 | } |
378 | 378 | |
379 | - echo '<option value=""' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
379 | + echo '<option value=""' . selected($selected, true, false) . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
380 | 380 | } |
381 | 381 | |
382 | - foreach ( $args['options'] as $key => $option ) { |
|
382 | + foreach ($args['options'] as $key => $option) { |
|
383 | 383 | |
384 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
385 | - $selected = in_array( $key, $args['selected'], true ); |
|
384 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
385 | + $selected = in_array($key, $args['selected'], true); |
|
386 | 386 | } else { |
387 | 387 | $selected = $args['selected'] === $key; |
388 | 388 | } |
389 | 389 | |
390 | - echo '<option value="' . esc_attr( $key ) . '"' . selected( $selected, true, false ) . '>' . esc_html( $option ) . '</option>'; |
|
390 | + echo '<option value="' . esc_attr($key) . '"' . selected($selected, true, false) . '>' . esc_html($option) . '</option>'; |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | |
396 | 396 | } |
397 | 397 | |
398 | -function wpinv_item_dropdown( $args = array() ) { |
|
398 | +function wpinv_item_dropdown($args = array()) { |
|
399 | 399 | $defaults = array( |
400 | 400 | 'name' => 'wpi_item', |
401 | 401 | 'id' => 'wpi_item', |
@@ -403,14 +403,14 @@ discard block |
||
403 | 403 | 'multiple' => false, |
404 | 404 | 'selected' => 0, |
405 | 405 | 'number' => -1, |
406 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
407 | - 'data' => array( 'search-type' => 'item' ), |
|
406 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
407 | + 'data' => array('search-type' => 'item'), |
|
408 | 408 | 'show_option_all' => false, |
409 | 409 | 'show_option_none' => false, |
410 | 410 | 'show_recurring' => false, |
411 | 411 | ); |
412 | 412 | |
413 | - $args = wp_parse_args( $args, $defaults ); |
|
413 | + $args = wp_parse_args($args, $defaults); |
|
414 | 414 | |
415 | 415 | $item_args = array( |
416 | 416 | 'post_type' => 'wpi_item', |
@@ -419,40 +419,40 @@ discard block |
||
419 | 419 | 'posts_per_page' => $args['number'], |
420 | 420 | ); |
421 | 421 | |
422 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
422 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
423 | 423 | |
424 | - $items = get_posts( $item_args ); |
|
424 | + $items = get_posts($item_args); |
|
425 | 425 | $options = array(); |
426 | - if ( $items ) { |
|
427 | - foreach ( $items as $item ) { |
|
428 | - $title = esc_html( $item->post_title ); |
|
426 | + if ($items) { |
|
427 | + foreach ($items as $item) { |
|
428 | + $title = esc_html($item->post_title); |
|
429 | 429 | |
430 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
431 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
430 | + if (!empty($args['show_recurring'])) { |
|
431 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
432 | 432 | } |
433 | 433 | |
434 | - $options[ absint( $item->ID ) ] = $title; |
|
434 | + $options[absint($item->ID)] = $title; |
|
435 | 435 | } |
436 | 436 | } |
437 | 437 | |
438 | 438 | // This ensures that any selected items are included in the drop down |
439 | - if ( is_array( $args['selected'] ) ) { |
|
440 | - foreach ( $args['selected'] as $item ) { |
|
441 | - if ( ! in_array( $item, $options ) ) { |
|
442 | - $title = get_the_title( $item ); |
|
443 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
444 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
439 | + if (is_array($args['selected'])) { |
|
440 | + foreach ($args['selected'] as $item) { |
|
441 | + if (!in_array($item, $options)) { |
|
442 | + $title = get_the_title($item); |
|
443 | + if (!empty($args['show_recurring'])) { |
|
444 | + $title .= wpinv_get_item_suffix($item, false); |
|
445 | 445 | } |
446 | - $options[ $item ] = $title; |
|
446 | + $options[$item] = $title; |
|
447 | 447 | } |
448 | 448 | } |
449 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
450 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
451 | - $title = get_the_title( $args['selected'] ); |
|
452 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
453 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
449 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
450 | + if (!in_array($args['selected'], $options)) { |
|
451 | + $title = get_the_title($args['selected']); |
|
452 | + if (!empty($args['show_recurring'])) { |
|
453 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
454 | 454 | } |
455 | - $options[ $args['selected'] ] = get_the_title( $args['selected'] ); |
|
455 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
@@ -488,16 +488,16 @@ discard block |
||
488 | 488 | ); |
489 | 489 | |
490 | 490 | $options = array(); |
491 | - if ( $items ) { |
|
492 | - foreach ( $items as $item ) { |
|
493 | - $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false ); |
|
491 | + if ($items) { |
|
492 | + foreach ($items as $item) { |
|
493 | + $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false); |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
497 | 497 | return $options; |
498 | 498 | } |
499 | 499 | |
500 | -function wpinv_html_checkbox( $args = array() ) { |
|
500 | +function wpinv_html_checkbox($args = array()) { |
|
501 | 501 | $defaults = array( |
502 | 502 | 'name' => null, |
503 | 503 | 'current' => null, |
@@ -508,17 +508,17 @@ discard block |
||
508 | 508 | ), |
509 | 509 | ); |
510 | 510 | |
511 | - $args = wp_parse_args( $args, $defaults ); |
|
511 | + $args = wp_parse_args($args, $defaults); |
|
512 | 512 | |
513 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
513 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
514 | 514 | $attr = ''; |
515 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
515 | + if (!empty($args['options']['disabled'])) { |
|
516 | 516 | $attr .= ' disabled="disabled"'; |
517 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
517 | + } elseif (!empty($args['options']['readonly'])) { |
|
518 | 518 | $attr .= ' readonly'; |
519 | 519 | } |
520 | 520 | |
521 | - $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . esc_attr( $class ) . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
521 | + $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . esc_attr($class) . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
522 | 522 | |
523 | 523 | return $output; |
524 | 524 | } |
@@ -526,34 +526,34 @@ discard block |
||
526 | 526 | /** |
527 | 527 | * Displays a hidden field. |
528 | 528 | */ |
529 | -function getpaid_hidden_field( $name, $value ) { |
|
530 | - echo "<input type='hidden' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' />"; |
|
529 | +function getpaid_hidden_field($name, $value) { |
|
530 | + echo "<input type='hidden' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' />"; |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | /** |
534 | 534 | * Displays a submit field. |
535 | 535 | */ |
536 | -function getpaid_submit_field( $value, $name = 'submit', $class = 'btn-primary' ) { |
|
537 | - echo "<input type='submit' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' class='btn " . esc_attr( $class ) . "' />"; |
|
536 | +function getpaid_submit_field($value, $name = 'submit', $class = 'btn-primary') { |
|
537 | + echo "<input type='submit' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' class='btn " . esc_attr($class) . "' />"; |
|
538 | 538 | } |
539 | 539 | |
540 | -function wpinv_html_text( $args = array() ) { |
|
540 | +function wpinv_html_text($args = array()) { |
|
541 | 541 | // Backwards compatibility |
542 | - if ( func_num_args() > 1 ) { |
|
542 | + if (func_num_args() > 1) { |
|
543 | 543 | $args = func_get_args(); |
544 | 544 | |
545 | 545 | $name = $args[0]; |
546 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
547 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
548 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
546 | + $value = isset($args[1]) ? $args[1] : ''; |
|
547 | + $label = isset($args[2]) ? $args[2] : ''; |
|
548 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | $defaults = array( |
552 | 552 | 'id' => '', |
553 | - 'name' => isset( $name ) ? $name : 'text', |
|
554 | - 'value' => isset( $value ) ? $value : null, |
|
555 | - 'label' => isset( $label ) ? $label : null, |
|
556 | - 'desc' => isset( $desc ) ? $desc : null, |
|
553 | + 'name' => isset($name) ? $name : 'text', |
|
554 | + 'value' => isset($value) ? $value : null, |
|
555 | + 'label' => isset($label) ? $label : null, |
|
556 | + 'desc' => isset($desc) ? $desc : null, |
|
557 | 557 | 'placeholder' => '', |
558 | 558 | 'class' => 'regular-text', |
559 | 559 | 'disabled' => false, |
@@ -563,41 +563,41 @@ discard block |
||
563 | 563 | 'data' => false, |
564 | 564 | ); |
565 | 565 | |
566 | - $args = wp_parse_args( $args, $defaults ); |
|
566 | + $args = wp_parse_args($args, $defaults); |
|
567 | 567 | |
568 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
568 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
569 | 569 | $options = ''; |
570 | - if ( $args['required'] ) { |
|
570 | + if ($args['required']) { |
|
571 | 571 | $options .= ' required="required"'; |
572 | 572 | } |
573 | - if ( $args['readonly'] ) { |
|
573 | + if ($args['readonly']) { |
|
574 | 574 | $options .= ' readonly'; |
575 | 575 | } |
576 | - if ( $args['readonly'] ) { |
|
576 | + if ($args['readonly']) { |
|
577 | 577 | $options .= ' readonly'; |
578 | 578 | } |
579 | 579 | |
580 | 580 | $data = ''; |
581 | - if ( ! empty( $args['data'] ) ) { |
|
582 | - foreach ( $args['data'] as $key => $value ) { |
|
583 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
581 | + if (!empty($args['data'])) { |
|
582 | + foreach ($args['data'] as $key => $value) { |
|
583 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
584 | 584 | } |
585 | 585 | } |
586 | 586 | |
587 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
588 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
589 | - if ( ! empty( $args['desc'] ) ) { |
|
590 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
587 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
588 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
589 | + if (!empty($args['desc'])) { |
|
590 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
591 | 591 | } |
592 | 592 | |
593 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
593 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
594 | 594 | |
595 | 595 | $output .= '</span>'; |
596 | 596 | |
597 | 597 | return $output; |
598 | 598 | } |
599 | 599 | |
600 | -function wpinv_html_textarea( $args = array() ) { |
|
600 | +function wpinv_html_textarea($args = array()) { |
|
601 | 601 | $defaults = array( |
602 | 602 | 'name' => 'textarea', |
603 | 603 | 'value' => null, |
@@ -608,31 +608,31 @@ discard block |
||
608 | 608 | 'placeholder' => '', |
609 | 609 | ); |
610 | 610 | |
611 | - $args = wp_parse_args( $args, $defaults ); |
|
611 | + $args = wp_parse_args($args, $defaults); |
|
612 | 612 | |
613 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
613 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
614 | 614 | $disabled = ''; |
615 | - if ( $args['disabled'] ) { |
|
615 | + if ($args['disabled']) { |
|
616 | 616 | $disabled = ' disabled="disabled"'; |
617 | 617 | } |
618 | 618 | |
619 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
620 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
621 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
619 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
620 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
621 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
622 | 622 | |
623 | - if ( ! empty( $args['desc'] ) ) { |
|
624 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
623 | + if (!empty($args['desc'])) { |
|
624 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
625 | 625 | } |
626 | 626 | $output .= '</span>'; |
627 | 627 | |
628 | 628 | return $output; |
629 | 629 | } |
630 | 630 | |
631 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
631 | +function wpinv_html_ajax_user_search($args = array()) { |
|
632 | 632 | $defaults = array( |
633 | 633 | 'name' => 'user_id', |
634 | 634 | 'value' => null, |
635 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
635 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
636 | 636 | 'label' => null, |
637 | 637 | 'desc' => null, |
638 | 638 | 'class' => '', |
@@ -641,13 +641,13 @@ discard block |
||
641 | 641 | 'data' => false, |
642 | 642 | ); |
643 | 643 | |
644 | - $args = wp_parse_args( $args, $defaults ); |
|
644 | + $args = wp_parse_args($args, $defaults); |
|
645 | 645 | |
646 | 646 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
647 | 647 | |
648 | 648 | $output = '<span class="wpinv_user_search_wrap">'; |
649 | - $output .= wpinv_html_text( $args ); |
|
650 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
649 | + $output .= wpinv_html_text($args); |
|
650 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
651 | 651 | $output .= '</span>'; |
652 | 652 | |
653 | 653 | return $output; |
@@ -658,44 +658,44 @@ discard block |
||
658 | 658 | * |
659 | 659 | * @param string $template the template that is currently being used. |
660 | 660 | */ |
661 | -function wpinv_template( $template ) { |
|
661 | +function wpinv_template($template) { |
|
662 | 662 | global $post; |
663 | 663 | |
664 | - if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) { |
|
664 | + if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) { |
|
665 | 665 | |
666 | 666 | // If the user can view this invoice, display it. |
667 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
667 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
668 | 668 | |
669 | - return wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
669 | + return wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
670 | 670 | |
671 | 671 | // Else display an error message. |
672 | 672 | } else { |
673 | 673 | |
674 | - return wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
674 | + return wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
675 | 675 | |
676 | 676 | } |
677 | 677 | } |
678 | 678 | |
679 | 679 | return $template; |
680 | 680 | } |
681 | -add_filter( 'template_include', 'wpinv_template', 1000, 1 ); |
|
681 | +add_filter('template_include', 'wpinv_template', 1000, 1); |
|
682 | 682 | |
683 | 683 | function wpinv_get_business_address() { |
684 | 684 | $business_address = wpinv_store_address(); |
685 | - $business_address = ! empty( $business_address ) ? wp_kses_post( wpautop( $business_address ) ) : ''; |
|
685 | + $business_address = !empty($business_address) ? wp_kses_post(wpautop($business_address)) : ''; |
|
686 | 686 | |
687 | 687 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
688 | 688 | |
689 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
689 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | /** |
693 | 693 | * Displays the company address. |
694 | 694 | */ |
695 | 695 | function wpinv_display_from_address() { |
696 | - wpinv_get_template( 'invoice/company-address.php' ); |
|
696 | + wpinv_get_template('invoice/company-address.php'); |
|
697 | 697 | } |
698 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 ); |
|
698 | +add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10); |
|
699 | 699 | |
700 | 700 | /** |
701 | 701 | * Generates a watermark text for an invoice. |
@@ -703,9 +703,9 @@ discard block |
||
703 | 703 | * @param WPInv_Invoice $invoice |
704 | 704 | * @return string |
705 | 705 | */ |
706 | -function wpinv_watermark( $invoice ) { |
|
707 | - $watermark = wpinv_get_watermark( $invoice ); |
|
708 | - return apply_filters( 'wpinv_get_watermark', $watermark, $invoice ); |
|
706 | +function wpinv_watermark($invoice) { |
|
707 | + $watermark = wpinv_get_watermark($invoice); |
|
708 | + return apply_filters('wpinv_get_watermark', $watermark, $invoice); |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | /** |
@@ -714,37 +714,37 @@ discard block |
||
714 | 714 | * @param WPInv_Invoice $invoice |
715 | 715 | * @return string |
716 | 716 | */ |
717 | -function wpinv_get_watermark( $invoice ) { |
|
717 | +function wpinv_get_watermark($invoice) { |
|
718 | 718 | return $invoice->get_status_nicename(); |
719 | 719 | } |
720 | 720 | |
721 | 721 | /** |
722 | 722 | * @deprecated |
723 | 723 | */ |
724 | -function wpinv_display_invoice_details( $invoice ) { |
|
725 | - return getpaid_invoice_meta( $invoice ); |
|
724 | +function wpinv_display_invoice_details($invoice) { |
|
725 | + return getpaid_invoice_meta($invoice); |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | /** |
729 | 729 | * Displays invoice meta. |
730 | 730 | */ |
731 | -function getpaid_invoice_meta( $invoice ) { |
|
731 | +function getpaid_invoice_meta($invoice) { |
|
732 | 732 | |
733 | - $invoice = new WPInv_Invoice( $invoice ); |
|
733 | + $invoice = new WPInv_Invoice($invoice); |
|
734 | 734 | |
735 | 735 | // Ensure that we have an invoice. |
736 | - if ( 0 == $invoice->get_id() ) { |
|
736 | + if (0 == $invoice->get_id()) { |
|
737 | 737 | return; |
738 | 738 | } |
739 | 739 | |
740 | 740 | // Get the invoice meta. |
741 | - $meta = getpaid_get_invoice_meta( $invoice ); |
|
741 | + $meta = getpaid_get_invoice_meta($invoice); |
|
742 | 742 | |
743 | 743 | // Display the meta. |
744 | - wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) ); |
|
744 | + wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta')); |
|
745 | 745 | |
746 | 746 | } |
747 | -add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 ); |
|
747 | +add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10); |
|
748 | 748 | |
749 | 749 | /** |
750 | 750 | * Retrieves the address markup to use on Invoices. |
@@ -756,29 +756,29 @@ discard block |
||
756 | 756 | * @param string $separator How to separate address lines. |
757 | 757 | * @return string |
758 | 758 | */ |
759 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
759 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
760 | 760 | |
761 | 761 | // Retrieve the address markup... |
762 | - $country = empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
763 | - $format = wpinv_get_full_address_format( $country ); |
|
762 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
763 | + $format = wpinv_get_full_address_format($country); |
|
764 | 764 | |
765 | 765 | // ... and the replacements. |
766 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
766 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
767 | 767 | |
768 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
768 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
769 | 769 | |
770 | 770 | // Remove unavailable tags. |
771 | - $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address ); |
|
771 | + $formatted_address = preg_replace('/\{\{\w+\}\}/', '', $formatted_address); |
|
772 | 772 | |
773 | 773 | // Clean up white space. |
774 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
775 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
774 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
775 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
776 | 776 | |
777 | 777 | // Break newlines apart and remove empty lines/trim commas and white space. |
778 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
778 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
779 | 779 | |
780 | 780 | // Add html breaks. |
781 | - $formatted_address = implode( $separator, $formatted_address ); |
|
781 | + $formatted_address = implode($separator, $formatted_address); |
|
782 | 782 | |
783 | 783 | // We're done! |
784 | 784 | return $formatted_address; |
@@ -790,118 +790,118 @@ discard block |
||
790 | 790 | * |
791 | 791 | * @param WPInv_Invoice $invoice |
792 | 792 | */ |
793 | -function wpinv_display_to_address( $invoice = 0 ) { |
|
794 | - if ( ! empty( $invoice ) ) { |
|
795 | - wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) ); |
|
793 | +function wpinv_display_to_address($invoice = 0) { |
|
794 | + if (!empty($invoice)) { |
|
795 | + wpinv_get_template('invoice/billing-address.php', compact('invoice')); |
|
796 | 796 | } |
797 | 797 | } |
798 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 ); |
|
798 | +add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40); |
|
799 | 799 | |
800 | 800 | |
801 | 801 | /** |
802 | 802 | * Displays invoice line items. |
803 | 803 | */ |
804 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
804 | +function wpinv_display_line_items($invoice_id = 0) { |
|
805 | 805 | |
806 | 806 | // Prepare the invoice. |
807 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
807 | + $invoice = new WPInv_Invoice($invoice_id); |
|
808 | 808 | |
809 | 809 | // Abort if there is no invoice. |
810 | - if ( 0 == $invoice->get_id() ) { |
|
810 | + if (0 == $invoice->get_id()) { |
|
811 | 811 | return; |
812 | 812 | } |
813 | 813 | |
814 | 814 | // Line item columns. |
815 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
816 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
815 | + $columns = getpaid_invoice_item_columns($invoice); |
|
816 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
817 | 817 | |
818 | - wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) ); |
|
818 | + wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns')); |
|
819 | 819 | } |
820 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 ); |
|
820 | +add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10); |
|
821 | 821 | |
822 | 822 | /** |
823 | 823 | * Displays invoice subscriptions. |
824 | 824 | * |
825 | 825 | * @param WPInv_Invoice $invoice |
826 | 826 | */ |
827 | -function getpaid_display_invoice_subscriptions( $invoice ) { |
|
827 | +function getpaid_display_invoice_subscriptions($invoice) { |
|
828 | 828 | |
829 | 829 | // Subscriptions. |
830 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
830 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
831 | 831 | |
832 | - if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) { |
|
832 | + if (empty($subscriptions) || !$invoice->is_recurring()) { |
|
833 | 833 | return; |
834 | 834 | } |
835 | 835 | |
836 | - $main_subscription = getpaid_get_invoice_subscription( $invoice ); |
|
836 | + $main_subscription = getpaid_get_invoice_subscription($invoice); |
|
837 | 837 | |
838 | 838 | // Display related subscriptions. |
839 | - if ( is_array( $subscriptions ) ) { |
|
840 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Subscriptions', 'invoicing' ) ); |
|
841 | - getpaid_admin_subscription_related_subscriptions_metabox( $main_subscription, false ); |
|
839 | + if (is_array($subscriptions)) { |
|
840 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Subscriptions', 'invoicing')); |
|
841 | + getpaid_admin_subscription_related_subscriptions_metabox($main_subscription, false); |
|
842 | 842 | } |
843 | 843 | |
844 | - if ( $main_subscription->get_total_payments() > 1 ) { |
|
845 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Invoices', 'invoicing' ) ); |
|
846 | - getpaid_admin_subscription_invoice_details_metabox( $main_subscription, false ); |
|
844 | + if ($main_subscription->get_total_payments() > 1) { |
|
845 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Invoices', 'invoicing')); |
|
846 | + getpaid_admin_subscription_invoice_details_metabox($main_subscription, false); |
|
847 | 847 | } |
848 | 848 | |
849 | 849 | } |
850 | -add_action( 'getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55 ); |
|
851 | -add_action( 'wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11 ); |
|
850 | +add_action('getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55); |
|
851 | +add_action('wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11); |
|
852 | 852 | |
853 | 853 | /** |
854 | 854 | * Displays invoice notices on invoices. |
855 | 855 | */ |
856 | 856 | function wpinv_display_invoice_notice() { |
857 | 857 | |
858 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
859 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
858 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
859 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
860 | 860 | |
861 | - if ( empty( $label ) && empty( $notice ) ) { |
|
861 | + if (empty($label) && empty($notice)) { |
|
862 | 862 | return; |
863 | 863 | } |
864 | 864 | |
865 | 865 | echo '<div class="mt-4 mb-4 wpinv-vat-notice">'; |
866 | 866 | |
867 | - if ( ! empty( $label ) ) { |
|
868 | - echo "<h5>" . esc_html( $label ) . "</h5>"; |
|
867 | + if (!empty($label)) { |
|
868 | + echo "<h5>" . esc_html($label) . "</h5>"; |
|
869 | 869 | } |
870 | 870 | |
871 | - if ( ! empty( $notice ) ) { |
|
872 | - echo '<small class="form-text text-muted">' . wp_kses_post( wpautop( wptexturize( $notice ) ) ) . '</small>'; |
|
871 | + if (!empty($notice)) { |
|
872 | + echo '<small class="form-text text-muted">' . wp_kses_post(wpautop(wptexturize($notice))) . '</small>'; |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | echo '</div>'; |
876 | 876 | } |
877 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 ); |
|
877 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100); |
|
878 | 878 | |
879 | 879 | /** |
880 | 880 | * @param WPInv_Invoice $invoice |
881 | 881 | */ |
882 | -function wpinv_display_invoice_notes( $invoice ) { |
|
882 | +function wpinv_display_invoice_notes($invoice) { |
|
883 | 883 | |
884 | 884 | // Retrieve the notes. |
885 | - $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' ); |
|
885 | + $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer'); |
|
886 | 886 | |
887 | 887 | // Abort if we have non. |
888 | - if ( empty( $notes ) ) { |
|
888 | + if (empty($notes)) { |
|
889 | 889 | return; |
890 | 890 | } |
891 | 891 | |
892 | 892 | // Echo the note. |
893 | 893 | echo '<div class="getpaid-invoice-notes-wrapper position-relative my-4">'; |
894 | - echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . esc_html__( 'Notes', 'invoicing' ) . '</h2>'; |
|
894 | + echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . esc_html__('Notes', 'invoicing') . '</h2>'; |
|
895 | 895 | echo '<ul class="getpaid-invoice-notes text-break overflow-auto list-unstyled p-0 m-0">'; |
896 | 896 | |
897 | - foreach ( $notes as $note ) { |
|
898 | - wpinv_get_invoice_note_line_item( $note ); |
|
897 | + foreach ($notes as $note) { |
|
898 | + wpinv_get_invoice_note_line_item($note); |
|
899 | 899 | } |
900 | 900 | |
901 | 901 | echo '</ul>'; |
902 | 902 | echo '</div>'; |
903 | 903 | } |
904 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 ); |
|
904 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60); |
|
905 | 905 | |
906 | 906 | /** |
907 | 907 | * Loads scripts on our invoice templates. |
@@ -909,32 +909,32 @@ discard block |
||
909 | 909 | function wpinv_display_style() { |
910 | 910 | |
911 | 911 | // Make sure that all scripts have been loaded. |
912 | - if ( ! did_action( 'wp_enqueue_scripts' ) ) { |
|
913 | - do_action( 'wp_enqueue_scripts' ); |
|
912 | + if (!did_action('wp_enqueue_scripts')) { |
|
913 | + do_action('wp_enqueue_scripts'); |
|
914 | 914 | } |
915 | 915 | |
916 | 916 | // Register the invoices style. |
917 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) ); |
|
917 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css')); |
|
918 | 918 | |
919 | 919 | // Load required styles |
920 | - wp_print_styles( 'wpinv-single-style' ); |
|
921 | - wp_print_styles( 'ayecode-ui' ); |
|
920 | + wp_print_styles('wpinv-single-style'); |
|
921 | + wp_print_styles('ayecode-ui'); |
|
922 | 922 | |
923 | 923 | // Maybe load custom css. |
924 | - $custom_css = wpinv_get_option( 'template_custom_css' ); |
|
924 | + $custom_css = wpinv_get_option('template_custom_css'); |
|
925 | 925 | |
926 | - if ( isset( $custom_css ) && ! empty( $custom_css ) ) { |
|
927 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
928 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
926 | + if (isset($custom_css) && !empty($custom_css)) { |
|
927 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
928 | + $custom_css = str_replace('>', '>', $custom_css); |
|
929 | 929 | echo '<style type="text/css">'; |
930 | - echo wp_kses_post( $custom_css ); |
|
930 | + echo wp_kses_post($custom_css); |
|
931 | 931 | echo '</style>'; |
932 | 932 | } |
933 | 933 | |
934 | 934 | wp_site_icon(); |
935 | 935 | } |
936 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
937 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
936 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
937 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
938 | 938 | |
939 | 939 | |
940 | 940 | /** |
@@ -946,41 +946,41 @@ discard block |
||
946 | 946 | // Retrieve the current invoice. |
947 | 947 | $invoice_id = getpaid_get_current_invoice_id(); |
948 | 948 | |
949 | - if ( empty( $invoice_id ) ) { |
|
949 | + if (empty($invoice_id)) { |
|
950 | 950 | |
951 | 951 | return aui()->alert( |
952 | 952 | array( |
953 | 953 | 'type' => 'warning', |
954 | - 'content' => __( 'Invalid invoice', 'invoicing' ), |
|
954 | + 'content' => __('Invalid invoice', 'invoicing'), |
|
955 | 955 | ) |
956 | 956 | ); |
957 | 957 | |
958 | 958 | } |
959 | 959 | |
960 | 960 | // Can the user view this invoice? |
961 | - if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) { |
|
961 | + if (!wpinv_user_can_view_invoice($invoice_id)) { |
|
962 | 962 | |
963 | 963 | return aui()->alert( |
964 | 964 | array( |
965 | 965 | 'type' => 'warning', |
966 | - 'content' => __( 'You are not allowed to view this invoice', 'invoicing' ), |
|
966 | + 'content' => __('You are not allowed to view this invoice', 'invoicing'), |
|
967 | 967 | ) |
968 | 968 | ); |
969 | 969 | |
970 | 970 | } |
971 | 971 | |
972 | 972 | // Ensure that it is not yet paid for. |
973 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
973 | + $invoice = new WPInv_Invoice($invoice_id); |
|
974 | 974 | |
975 | 975 | // Maybe mark it as viewed. |
976 | - getpaid_maybe_mark_invoice_as_viewed( $invoice ); |
|
976 | + getpaid_maybe_mark_invoice_as_viewed($invoice); |
|
977 | 977 | |
978 | - if ( $invoice->is_paid() ) { |
|
978 | + if ($invoice->is_paid()) { |
|
979 | 979 | |
980 | 980 | return aui()->alert( |
981 | 981 | array( |
982 | 982 | 'type' => 'success', |
983 | - 'content' => __( 'This invoice has already been paid.', 'invoicing' ), |
|
983 | + 'content' => __('This invoice has already been paid.', 'invoicing'), |
|
984 | 984 | ) |
985 | 985 | ); |
986 | 986 | |
@@ -990,15 +990,15 @@ discard block |
||
990 | 990 | $wpi_checkout_id = $invoice_id; |
991 | 991 | |
992 | 992 | // Retrieve appropriate payment form. |
993 | - $payment_form = new GetPaid_Payment_Form( $invoice->get_meta( 'force_payment_form' ) ); |
|
994 | - $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
993 | + $payment_form = new GetPaid_Payment_Form($invoice->get_meta('force_payment_form')); |
|
994 | + $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
995 | 995 | |
996 | - if ( ! $payment_form->exists() ) { |
|
996 | + if (!$payment_form->exists()) { |
|
997 | 997 | |
998 | 998 | return aui()->alert( |
999 | 999 | array( |
1000 | 1000 | 'type' => 'warning', |
1001 | - 'content' => __( 'Error loading the payment form', 'invoicing' ), |
|
1001 | + 'content' => __('Error loading the payment form', 'invoicing'), |
|
1002 | 1002 | ) |
1003 | 1003 | ); |
1004 | 1004 | |
@@ -1007,29 +1007,29 @@ discard block |
||
1007 | 1007 | // Set the invoice. |
1008 | 1008 | $payment_form->invoice = $invoice; |
1009 | 1009 | |
1010 | - if ( ! $payment_form->is_default() ) { |
|
1010 | + if (!$payment_form->is_default()) { |
|
1011 | 1011 | |
1012 | 1012 | $items = array(); |
1013 | 1013 | $item_ids = array(); |
1014 | 1014 | |
1015 | - foreach ( $invoice->get_items() as $item ) { |
|
1016 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
1015 | + foreach ($invoice->get_items() as $item) { |
|
1016 | + if (!in_array($item->get_id(), $item_ids)) { |
|
1017 | 1017 | $item_ids[] = $item->get_id(); |
1018 | 1018 | $items[] = $item; |
1019 | 1019 | } |
1020 | 1020 | } |
1021 | 1021 | |
1022 | - foreach ( $payment_form->get_items() as $item ) { |
|
1023 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
1022 | + foreach ($payment_form->get_items() as $item) { |
|
1023 | + if (!in_array($item->get_id(), $item_ids)) { |
|
1024 | 1024 | $item_ids[] = $item->get_id(); |
1025 | 1025 | $items[] = $item; |
1026 | 1026 | } |
1027 | 1027 | } |
1028 | 1028 | |
1029 | - $payment_form->set_items( $items ); |
|
1029 | + $payment_form->set_items($items); |
|
1030 | 1030 | |
1031 | 1031 | } else { |
1032 | - $payment_form->set_items( $invoice->get_items() ); |
|
1032 | + $payment_form->set_items($invoice->get_items()); |
|
1033 | 1033 | } |
1034 | 1034 | |
1035 | 1035 | // Generate the html. |
@@ -1038,7 +1038,7 @@ discard block |
||
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | function wpinv_empty_cart_message() { |
1041 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1041 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1042 | 1042 | } |
1043 | 1043 | |
1044 | 1044 | /** |
@@ -1056,76 +1056,76 @@ discard block |
||
1056 | 1056 | true |
1057 | 1057 | ); |
1058 | 1058 | } |
1059 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1059 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1060 | 1060 | |
1061 | 1061 | /** |
1062 | 1062 | * Filters the receipt page. |
1063 | 1063 | */ |
1064 | -function wpinv_filter_success_page_content( $content ) { |
|
1064 | +function wpinv_filter_success_page_content($content) { |
|
1065 | 1065 | |
1066 | 1066 | // Maybe abort early. |
1067 | - if ( is_admin() || ! is_singular() || ! in_the_loop() || ! is_main_query() || is_preview() ) { |
|
1067 | + if (is_admin() || !is_singular() || !in_the_loop() || !is_main_query() || is_preview()) { |
|
1068 | 1068 | return $content; |
1069 | 1069 | } |
1070 | 1070 | |
1071 | 1071 | // Ensure this is our page. |
1072 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1072 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1073 | 1073 | |
1074 | - $gateway = sanitize_text_field( $_GET['payment-confirm'] ); |
|
1075 | - return apply_filters( "wpinv_payment_confirm_$gateway", $content ); |
|
1074 | + $gateway = sanitize_text_field($_GET['payment-confirm']); |
|
1075 | + return apply_filters("wpinv_payment_confirm_$gateway", $content); |
|
1076 | 1076 | |
1077 | 1077 | } |
1078 | 1078 | |
1079 | 1079 | return $content; |
1080 | 1080 | } |
1081 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1081 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1082 | 1082 | |
1083 | -function wpinv_invoice_link( $invoice_id ) { |
|
1084 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1083 | +function wpinv_invoice_link($invoice_id) { |
|
1084 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1085 | 1085 | |
1086 | - if ( empty( $invoice ) ) { |
|
1086 | + if (empty($invoice)) { |
|
1087 | 1087 | return null; |
1088 | 1088 | } |
1089 | 1089 | |
1090 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1090 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1091 | 1091 | |
1092 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1092 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1093 | 1093 | } |
1094 | 1094 | |
1095 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
1096 | - if ( empty( $note ) ) { |
|
1095 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
1096 | + if (empty($note)) { |
|
1097 | 1097 | return null; |
1098 | 1098 | } |
1099 | 1099 | |
1100 | - if ( is_int( $note ) ) { |
|
1101 | - $note = get_comment( $note ); |
|
1100 | + if (is_int($note)) { |
|
1101 | + $note = get_comment($note); |
|
1102 | 1102 | } |
1103 | 1103 | |
1104 | - if ( ! ( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
1104 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
1105 | 1105 | return null; |
1106 | 1106 | } |
1107 | 1107 | |
1108 | - $note_classes = array( 'note' ); |
|
1109 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
1108 | + $note_classes = array('note'); |
|
1109 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
1110 | 1110 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
1111 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
1112 | - $note_classes = ! empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
1111 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
1112 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
1113 | 1113 | |
1114 | 1114 | ob_start(); |
1115 | 1115 | ?> |
1116 | - <li rel="<?php echo absint( $note->comment_ID ); ?>" class="<?php echo esc_attr( $note_classes ); ?> mb-2"> |
|
1116 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mb-2"> |
|
1117 | 1117 | <div class="note_content"> |
1118 | 1118 | |
1119 | - <?php echo wp_kses_post( wptexturize( $note->comment_content ) ); ?> |
|
1119 | + <?php echo wp_kses_post(wptexturize($note->comment_content)); ?> |
|
1120 | 1120 | |
1121 | - <?php if ( ! is_admin() ) : ?> |
|
1121 | + <?php if (!is_admin()) : ?> |
|
1122 | 1122 | <em class="small form-text text-muted mt-0"> |
1123 | 1123 | <?php |
1124 | 1124 | printf( |
1125 | - esc_html__( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1126 | - esc_html( $note->comment_author ), |
|
1127 | - esc_html( getpaid_format_date_value( $note->comment_date ) ), |
|
1128 | - esc_html( date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ) |
|
1125 | + esc_html__('%1$s - %2$s at %3$s', 'invoicing'), |
|
1126 | + esc_html($note->comment_author), |
|
1127 | + esc_html(getpaid_format_date_value($note->comment_date)), |
|
1128 | + esc_html(date_i18n(get_option('time_format'), strtotime($note->comment_date))) |
|
1129 | 1129 | ); |
1130 | 1130 | ?> |
1131 | 1131 | </em> |
@@ -1133,21 +1133,21 @@ discard block |
||
1133 | 1133 | |
1134 | 1134 | </div> |
1135 | 1135 | |
1136 | - <?php if ( is_admin() ) : ?> |
|
1136 | + <?php if (is_admin()) : ?> |
|
1137 | 1137 | |
1138 | 1138 | <p class="meta px-4 py-2"> |
1139 | - <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"> |
|
1139 | + <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"> |
|
1140 | 1140 | <?php |
1141 | 1141 | printf( |
1142 | - esc_html__( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1143 | - esc_html( $note->comment_author ), |
|
1144 | - esc_html( getpaid_format_date_value( $note->comment_date ) ), |
|
1145 | - esc_html( date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ) |
|
1142 | + esc_html__('%1$s - %2$s at %3$s', 'invoicing'), |
|
1143 | + esc_html($note->comment_author), |
|
1144 | + esc_html(getpaid_format_date_value($note->comment_date)), |
|
1145 | + esc_html(date_i18n(get_option('time_format'), strtotime($note->comment_date))) |
|
1146 | 1146 | ); |
1147 | 1147 | ?> |
1148 | 1148 | </abbr> |
1149 | - <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?> |
|
1150 | - <a href="#" class="delete_note" data-id="<?php echo esc_attr( $note->comment_ID ); ?>"><?php esc_html_e( 'Delete note', 'invoicing' ); ?></a> |
|
1149 | + <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?> |
|
1150 | + <a href="#" class="delete_note" data-id="<?php echo esc_attr($note->comment_ID); ?>"><?php esc_html_e('Delete note', 'invoicing'); ?></a> |
|
1151 | 1151 | <?php } ?> |
1152 | 1152 | </p> |
1153 | 1153 | |
@@ -1156,10 +1156,10 @@ discard block |
||
1156 | 1156 | </li> |
1157 | 1157 | <?php |
1158 | 1158 | $note_content = ob_get_clean(); |
1159 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
1159 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
1160 | 1160 | |
1161 | - if ( $echo ) { |
|
1162 | - echo wp_kses_post( $note_content ); |
|
1161 | + if ($echo) { |
|
1162 | + echo wp_kses_post($note_content); |
|
1163 | 1163 | } else { |
1164 | 1164 | return $note_content; |
1165 | 1165 | } |
@@ -1172,43 +1172,43 @@ discard block |
||
1172 | 1172 | * @return string |
1173 | 1173 | */ |
1174 | 1174 | function wpinv_get_policy_text() { |
1175 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
1175 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
1176 | 1176 | |
1177 | - $text = wpinv_get_option( 'invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ) ); |
|
1177 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
1178 | 1178 | |
1179 | - if ( ! $privacy_page_id ) { |
|
1180 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
1179 | + if (!$privacy_page_id) { |
|
1180 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
1181 | 1181 | } |
1182 | 1182 | |
1183 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
1183 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
1184 | 1184 | |
1185 | 1185 | $find_replace = array( |
1186 | 1186 | '[wpinv_privacy_policy]' => $privacy_link, |
1187 | 1187 | ); |
1188 | 1188 | |
1189 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
1189 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
1190 | 1190 | |
1191 | - return wp_kses_post( wpautop( $privacy_text ) ); |
|
1191 | + return wp_kses_post(wpautop($privacy_text)); |
|
1192 | 1192 | } |
1193 | 1193 | |
1194 | 1194 | function wpinv_oxygen_fix_conflict() { |
1195 | 1195 | global $ct_ignore_post_types; |
1196 | 1196 | |
1197 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
1197 | + if (!is_array($ct_ignore_post_types)) { |
|
1198 | 1198 | $ct_ignore_post_types = array(); |
1199 | 1199 | } |
1200 | 1200 | |
1201 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form' ); |
|
1201 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form'); |
|
1202 | 1202 | |
1203 | - foreach ( $post_types as $post_type ) { |
|
1203 | + foreach ($post_types as $post_type) { |
|
1204 | 1204 | $ct_ignore_post_types[] = $post_type; |
1205 | 1205 | |
1206 | 1206 | // Ignore post type |
1207 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
1207 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
1208 | 1208 | } |
1209 | 1209 | |
1210 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
1211 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
1210 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
1211 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | /** |
@@ -1216,10 +1216,10 @@ discard block |
||
1216 | 1216 | * |
1217 | 1217 | * @param GetPaid_Payment_Form $form |
1218 | 1218 | */ |
1219 | -function getpaid_display_payment_form( $form ) { |
|
1219 | +function getpaid_display_payment_form($form) { |
|
1220 | 1220 | |
1221 | - if ( is_numeric( $form ) ) { |
|
1222 | - $form = new GetPaid_Payment_Form( $form ); |
|
1221 | + if (is_numeric($form)) { |
|
1222 | + $form = new GetPaid_Payment_Form($form); |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | $form->display(); |
@@ -1229,61 +1229,61 @@ discard block |
||
1229 | 1229 | /** |
1230 | 1230 | * Helper function to display a item payment form on the frontend. |
1231 | 1231 | */ |
1232 | -function getpaid_display_item_payment_form( $items ) { |
|
1232 | +function getpaid_display_item_payment_form($items) { |
|
1233 | 1233 | |
1234 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1235 | - $form->set_items( $items ); |
|
1234 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1235 | + $form->set_items($items); |
|
1236 | 1236 | |
1237 | - if ( 0 == count( $form->get_items() ) ) { |
|
1237 | + if (0 == count($form->get_items())) { |
|
1238 | 1238 | aui()->alert( |
1239 | 1239 | array( |
1240 | 1240 | 'type' => 'warning', |
1241 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
1241 | + 'content' => __('No published items found', 'invoicing'), |
|
1242 | 1242 | ), |
1243 | 1243 | true |
1244 | 1244 | ); |
1245 | 1245 | return; |
1246 | 1246 | } |
1247 | 1247 | |
1248 | - $extra_items = esc_attr( getpaid_convert_items_to_string( $items ) ); |
|
1249 | - $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items ); |
|
1248 | + $extra_items = esc_attr(getpaid_convert_items_to_string($items)); |
|
1249 | + $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items); |
|
1250 | 1250 | $extra_items = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />"; |
1251 | 1251 | $extra_items .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />"; |
1252 | 1252 | |
1253 | - $form->display( $extra_items ); |
|
1253 | + $form->display($extra_items); |
|
1254 | 1254 | } |
1255 | 1255 | |
1256 | 1256 | /** |
1257 | 1257 | * Helper function to display an invoice payment form on the frontend. |
1258 | 1258 | */ |
1259 | -function getpaid_display_invoice_payment_form( $invoice_id ) { |
|
1259 | +function getpaid_display_invoice_payment_form($invoice_id) { |
|
1260 | 1260 | |
1261 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1261 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1262 | 1262 | |
1263 | - if ( empty( $invoice ) ) { |
|
1263 | + if (empty($invoice)) { |
|
1264 | 1264 | aui()->alert( |
1265 | 1265 | array( |
1266 | 1266 | 'type' => 'warning', |
1267 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1267 | + 'content' => __('Invoice not found', 'invoicing'), |
|
1268 | 1268 | ), |
1269 | 1269 | true |
1270 | 1270 | ); |
1271 | 1271 | return; |
1272 | 1272 | } |
1273 | 1273 | |
1274 | - if ( $invoice->is_paid() ) { |
|
1274 | + if ($invoice->is_paid()) { |
|
1275 | 1275 | aui()->alert( |
1276 | 1276 | array( |
1277 | 1277 | 'type' => 'warning', |
1278 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1278 | + 'content' => __('Invoice has already been paid', 'invoicing'), |
|
1279 | 1279 | ), |
1280 | 1280 | true |
1281 | 1281 | ); |
1282 | 1282 | return; |
1283 | 1283 | } |
1284 | 1284 | |
1285 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1286 | - $form->set_items( $invoice->get_items() ); |
|
1285 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1286 | + $form->set_items($invoice->get_items()); |
|
1287 | 1287 | |
1288 | 1288 | $form->display(); |
1289 | 1289 | } |
@@ -1291,25 +1291,25 @@ discard block |
||
1291 | 1291 | /** |
1292 | 1292 | * Helper function to convert item string to array. |
1293 | 1293 | */ |
1294 | -function getpaid_convert_items_to_array( $items ) { |
|
1295 | - $items = array_filter( array_map( 'trim', explode( ',', $items ) ) ); |
|
1294 | +function getpaid_convert_items_to_array($items) { |
|
1295 | + $items = array_filter(array_map('trim', explode(',', $items))); |
|
1296 | 1296 | $prepared = array(); |
1297 | 1297 | |
1298 | - foreach ( $items as $item ) { |
|
1299 | - $data = array_map( 'trim', explode( '|', $item ) ); |
|
1298 | + foreach ($items as $item) { |
|
1299 | + $data = array_map('trim', explode('|', $item)); |
|
1300 | 1300 | |
1301 | - if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) { |
|
1301 | + if (empty($data[0]) || !is_numeric($data[0])) { |
|
1302 | 1302 | continue; |
1303 | 1303 | } |
1304 | 1304 | |
1305 | 1305 | $quantity = 1; |
1306 | - if ( isset( $data[1] ) && is_numeric( $data[1] ) ) { |
|
1306 | + if (isset($data[1]) && is_numeric($data[1])) { |
|
1307 | 1307 | $quantity = (float) $data[1]; |
1308 | 1308 | } |
1309 | 1309 | |
1310 | 1310 | // WPML support. |
1311 | - $item_id = apply_filters( 'wpml_object_id', $data[0], 'wpi_item', true ); |
|
1312 | - $prepared[ $item_id ] = $quantity; |
|
1311 | + $item_id = apply_filters('wpml_object_id', $data[0], 'wpi_item', true); |
|
1312 | + $prepared[$item_id] = $quantity; |
|
1313 | 1313 | |
1314 | 1314 | } |
1315 | 1315 | |
@@ -1319,13 +1319,13 @@ discard block |
||
1319 | 1319 | /** |
1320 | 1320 | * Helper function to convert item array to string. |
1321 | 1321 | */ |
1322 | -function getpaid_convert_items_to_string( $items ) { |
|
1322 | +function getpaid_convert_items_to_string($items) { |
|
1323 | 1323 | $prepared = array(); |
1324 | 1324 | |
1325 | - foreach ( $items as $item => $quantity ) { |
|
1325 | + foreach ($items as $item => $quantity) { |
|
1326 | 1326 | $prepared[] = "$item|$quantity"; |
1327 | 1327 | } |
1328 | - return implode( ',', $prepared ); |
|
1328 | + return implode(',', $prepared); |
|
1329 | 1329 | } |
1330 | 1330 | |
1331 | 1331 | /** |
@@ -1333,21 +1333,21 @@ discard block |
||
1333 | 1333 | * |
1334 | 1334 | * Provide a label and one of $form, $items or $invoice. |
1335 | 1335 | */ |
1336 | -function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) { |
|
1337 | - $label = sanitize_text_field( $label ); |
|
1336 | +function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) { |
|
1337 | + $label = sanitize_text_field($label); |
|
1338 | 1338 | |
1339 | - if ( ! empty( $form ) ) { |
|
1340 | - $form = esc_attr( $form ); |
|
1339 | + if (!empty($form)) { |
|
1340 | + $form = esc_attr($form); |
|
1341 | 1341 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
1342 | 1342 | } |
1343 | 1343 | |
1344 | - if ( ! empty( $items ) ) { |
|
1345 | - $items = esc_attr( $items ); |
|
1344 | + if (!empty($items)) { |
|
1345 | + $items = esc_attr($items); |
|
1346 | 1346 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
1347 | 1347 | } |
1348 | 1348 | |
1349 | - if ( ! empty( $invoice ) ) { |
|
1350 | - $invoice = esc_attr( $invoice ); |
|
1349 | + if (!empty($invoice)) { |
|
1350 | + $invoice = esc_attr($invoice); |
|
1351 | 1351 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>"; |
1352 | 1352 | } |
1353 | 1353 | |
@@ -1358,17 +1358,17 @@ discard block |
||
1358 | 1358 | * |
1359 | 1359 | * @param WPInv_Invoice $invoice |
1360 | 1360 | */ |
1361 | -function getpaid_the_invoice_description( $invoice ) { |
|
1361 | +function getpaid_the_invoice_description($invoice) { |
|
1362 | 1362 | $description = $invoice->get_description(); |
1363 | 1363 | |
1364 | - if ( empty( $description ) ) { |
|
1364 | + if (empty($description)) { |
|
1365 | 1365 | return; |
1366 | 1366 | } |
1367 | 1367 | |
1368 | - echo "<small class='getpaid-invoice-description text-dark p-2 form-text' style='margin-bottom: 20px; border-left: 2px solid #2196F3;'><em>" . wp_kses_post( wpautop( $description ) ) . "</em></small>"; |
|
1368 | + echo "<small class='getpaid-invoice-description text-dark p-2 form-text' style='margin-bottom: 20px; border-left: 2px solid #2196F3;'><em>" . wp_kses_post(wpautop($description)) . "</em></small>"; |
|
1369 | 1369 | } |
1370 | -add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 ); |
|
1371 | -add_action( 'wpinv_email_billing_details', 'getpaid_the_invoice_description', 100 ); |
|
1370 | +add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100); |
|
1371 | +add_action('wpinv_email_billing_details', 'getpaid_the_invoice_description', 100); |
|
1372 | 1372 | |
1373 | 1373 | /** |
1374 | 1374 | * Render element on a form. |
@@ -1376,79 +1376,79 @@ discard block |
||
1376 | 1376 | * @param array $element |
1377 | 1377 | * @param GetPaid_Payment_Form $form |
1378 | 1378 | */ |
1379 | -function getpaid_payment_form_element( $element, $form ) { |
|
1379 | +function getpaid_payment_form_element($element, $form) { |
|
1380 | 1380 | |
1381 | 1381 | // Set up the args. |
1382 | - $element_type = trim( $element['type'] ); |
|
1382 | + $element_type = trim($element['type']); |
|
1383 | 1383 | $element['form'] = $form; |
1384 | - extract( $element ); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract |
|
1384 | + extract($element); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract |
|
1385 | 1385 | |
1386 | 1386 | // Try to locate the appropriate template. |
1387 | - $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" ); |
|
1387 | + $located = wpinv_locate_template("payment-forms/elements/$element_type.php"); |
|
1388 | 1388 | |
1389 | 1389 | // Abort if this is not our element. |
1390 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1390 | + if (empty($located) || !file_exists($located)) { |
|
1391 | 1391 | return; |
1392 | 1392 | } |
1393 | 1393 | |
1394 | 1394 | // Generate the class and id of the element. |
1395 | - $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) ); |
|
1396 | - $id = isset( $id ) ? $id : uniqid( 'gp' ); |
|
1395 | + $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type)); |
|
1396 | + $id = isset($id) ? $id : uniqid('gp'); |
|
1397 | 1397 | |
1398 | - $element_id = ! empty( $element['label'] ) ? sanitize_title( $element['label'] ) : $id; |
|
1399 | - $query_value = isset( $_GET[ $element_id ] ) ? wpinv_clean( urldecode_deep( $_GET[ $element_id ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
1398 | + $element_id = !empty($element['label']) ? sanitize_title($element['label']) : $id; |
|
1399 | + $query_value = isset($_GET[$element_id]) ? wpinv_clean(urldecode_deep($_GET[$element_id])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
1400 | 1400 | |
1401 | 1401 | $element_id = 'getpaid-' . $element_id; |
1402 | - if ( ! empty( $GLOBALS['rendered_getpaid_forms'][ $form->get_id() ] ) ) { |
|
1403 | - $element_id = $element_id . '-' . $GLOBALS['rendered_getpaid_forms'][ $form->get_id() ]; |
|
1402 | + if (!empty($GLOBALS['rendered_getpaid_forms'][$form->get_id()])) { |
|
1403 | + $element_id = $element_id . '-' . $GLOBALS['rendered_getpaid_forms'][$form->get_id()]; |
|
1404 | 1404 | } |
1405 | 1405 | |
1406 | 1406 | // Echo the opening wrapper. |
1407 | - echo "<div class='getpaid-payment-form-element " . esc_attr( $wrapper_class ) . "'>"; |
|
1407 | + echo "<div class='getpaid-payment-form-element " . esc_attr($wrapper_class) . "'>"; |
|
1408 | 1408 | |
1409 | 1409 | // Fires before displaying a given element type's content. |
1410 | - do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form ); |
|
1410 | + do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form); |
|
1411 | 1411 | |
1412 | 1412 | // Include the template for the element. |
1413 | 1413 | include $located; |
1414 | 1414 | |
1415 | 1415 | // Fires after displaying a given element type's content. |
1416 | - do_action( "getpaid_payment_form_{$element_type}_element", $element, $form ); |
|
1416 | + do_action("getpaid_payment_form_{$element_type}_element", $element, $form); |
|
1417 | 1417 | |
1418 | 1418 | // Echo the closing wrapper. |
1419 | 1419 | echo '</div>'; |
1420 | 1420 | } |
1421 | -add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 ); |
|
1421 | +add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2); |
|
1422 | 1422 | |
1423 | 1423 | /** |
1424 | 1424 | * Render an element's edit page. |
1425 | 1425 | * |
1426 | 1426 | * @param WP_Post $post |
1427 | 1427 | */ |
1428 | -function getpaid_payment_form_edit_element_template( $post ) { |
|
1428 | +function getpaid_payment_form_edit_element_template($post) { |
|
1429 | 1429 | |
1430 | 1430 | // Retrieve all elements. |
1431 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1431 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1432 | 1432 | |
1433 | - foreach ( $all_elements as $element ) { |
|
1433 | + foreach ($all_elements as $element) { |
|
1434 | 1434 | |
1435 | 1435 | // Try to locate the appropriate template. |
1436 | - $element = esc_attr( sanitize_key( $element ) ); |
|
1437 | - $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" ); |
|
1436 | + $element = esc_attr(sanitize_key($element)); |
|
1437 | + $located = wpinv_locate_template("payment-forms-admin/edit/$element.php"); |
|
1438 | 1438 | |
1439 | 1439 | // Continue if this is not our element. |
1440 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1440 | + if (empty($located) || !file_exists($located)) { |
|
1441 | 1441 | continue; |
1442 | 1442 | } |
1443 | 1443 | |
1444 | 1444 | // Include the template for the element. |
1445 | - echo "<div v-if=\"active_form_element.type=='" . esc_attr( $element ) . "'\">"; |
|
1445 | + echo "<div v-if=\"active_form_element.type=='" . esc_attr($element) . "'\">"; |
|
1446 | 1446 | include $located; |
1447 | 1447 | echo '</div>'; |
1448 | 1448 | } |
1449 | 1449 | |
1450 | 1450 | } |
1451 | -add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' ); |
|
1451 | +add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template'); |
|
1452 | 1452 | |
1453 | 1453 | /** |
1454 | 1454 | * Render an element's preview. |
@@ -1457,27 +1457,27 @@ discard block |
||
1457 | 1457 | function getpaid_payment_form_render_element_preview_template() { |
1458 | 1458 | |
1459 | 1459 | // Retrieve all elements. |
1460 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1460 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1461 | 1461 | |
1462 | - foreach ( $all_elements as $element ) { |
|
1462 | + foreach ($all_elements as $element) { |
|
1463 | 1463 | |
1464 | 1464 | // Try to locate the appropriate template. |
1465 | - $element = sanitize_key( $element ); |
|
1466 | - $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" ); |
|
1465 | + $element = sanitize_key($element); |
|
1466 | + $located = wpinv_locate_template("payment-forms-admin/previews/$element.php"); |
|
1467 | 1467 | |
1468 | 1468 | // Continue if this is not our element. |
1469 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1469 | + if (empty($located) || !file_exists($located)) { |
|
1470 | 1470 | continue; |
1471 | 1471 | } |
1472 | 1472 | |
1473 | 1473 | // Include the template for the element. |
1474 | - echo "<div v-if=\"form_element.type=='" . esc_html( $element ) . "'\">"; |
|
1474 | + echo "<div v-if=\"form_element.type=='" . esc_html($element) . "'\">"; |
|
1475 | 1475 | include $located; |
1476 | 1476 | echo '</div>'; |
1477 | 1477 | } |
1478 | 1478 | |
1479 | 1479 | } |
1480 | -add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' ); |
|
1480 | +add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template'); |
|
1481 | 1481 | |
1482 | 1482 | /** |
1483 | 1483 | * Shows a list of gateways that support recurring payments. |
@@ -1485,17 +1485,17 @@ discard block |
||
1485 | 1485 | function wpinv_get_recurring_gateways_text() { |
1486 | 1486 | $gateways = array(); |
1487 | 1487 | |
1488 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
1489 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
1490 | - $gateways[] = sanitize_text_field( $gateway['admin_label'] ); |
|
1488 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
1489 | + if (wpinv_gateway_support_subscription($key)) { |
|
1490 | + $gateways[] = sanitize_text_field($gateway['admin_label']); |
|
1491 | 1491 | } |
1492 | 1492 | } |
1493 | 1493 | |
1494 | - if ( empty( $gateways ) ) { |
|
1495 | - return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) . '</span>'; |
|
1494 | + if (empty($gateways)) { |
|
1495 | + return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . '</span>'; |
|
1496 | 1496 | } |
1497 | 1497 | |
1498 | - return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) . '</span>'; |
|
1498 | + return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . '</span>'; |
|
1499 | 1499 | |
1500 | 1500 | } |
1501 | 1501 | |
@@ -1505,7 +1505,7 @@ discard block |
||
1505 | 1505 | * @return GetPaid_Template |
1506 | 1506 | */ |
1507 | 1507 | function getpaid_template() { |
1508 | - return getpaid()->get( 'template' ); |
|
1508 | + return getpaid()->get('template'); |
|
1509 | 1509 | } |
1510 | 1510 | |
1511 | 1511 | /** |
@@ -1514,8 +1514,8 @@ discard block |
||
1514 | 1514 | * @param array args |
1515 | 1515 | * @return string |
1516 | 1516 | */ |
1517 | -function getpaid_paginate_links( $args ) { |
|
1518 | - return str_replace( 'page-link dots', 'page-link text-dark', aui()->pagination( $args ) ); |
|
1517 | +function getpaid_paginate_links($args) { |
|
1518 | + return str_replace('page-link dots', 'page-link text-dark', aui()->pagination($args)); |
|
1519 | 1519 | } |
1520 | 1520 | |
1521 | 1521 | /** |
@@ -1525,22 +1525,22 @@ discard block |
||
1525 | 1525 | * @param string state |
1526 | 1526 | * @return string |
1527 | 1527 | */ |
1528 | -function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false ) { |
|
1528 | +function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false) { |
|
1529 | 1529 | |
1530 | - $states = wpinv_get_country_states( $country ); |
|
1531 | - $uniqid = uniqid( '_' ); |
|
1530 | + $states = wpinv_get_country_states($country); |
|
1531 | + $uniqid = uniqid('_'); |
|
1532 | 1532 | |
1533 | - if ( ! empty( $states ) ) { |
|
1533 | + if (!empty($states)) { |
|
1534 | 1534 | |
1535 | 1535 | return aui()->select( |
1536 | 1536 | array( |
1537 | 1537 | 'options' => $states, |
1538 | - 'name' => esc_attr( $field_name ), |
|
1539 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1540 | - 'value' => sanitize_text_field( $state ), |
|
1538 | + 'name' => esc_attr($field_name), |
|
1539 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
1540 | + 'value' => sanitize_text_field($state), |
|
1541 | 1541 | 'placeholder' => $placeholder, |
1542 | 1542 | 'required' => $required, |
1543 | - 'label' => wp_kses_post( $label ), |
|
1543 | + 'label' => wp_kses_post($label), |
|
1544 | 1544 | 'label_type' => 'vertical', |
1545 | 1545 | 'help_text' => $help_text, |
1546 | 1546 | 'class' => 'getpaid-address-field wpinv_state', |
@@ -1557,14 +1557,14 @@ discard block |
||
1557 | 1557 | |
1558 | 1558 | return aui()->input( |
1559 | 1559 | array( |
1560 | - 'name' => esc_attr( $field_name ), |
|
1561 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1560 | + 'name' => esc_attr($field_name), |
|
1561 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
1562 | 1562 | 'placeholder' => $placeholder, |
1563 | 1563 | 'required' => $required, |
1564 | - 'label' => wp_kses_post( $label ), |
|
1564 | + 'label' => wp_kses_post($label), |
|
1565 | 1565 | 'label_type' => 'vertical', |
1566 | 1566 | 'help_text' => $help_text, |
1567 | - 'value' => sanitize_text_field( $state ), |
|
1567 | + 'value' => sanitize_text_field($state), |
|
1568 | 1568 | 'class' => 'getpaid-address-field wpinv_state', |
1569 | 1569 | 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
1570 | 1570 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
@@ -1583,16 +1583,16 @@ discard block |
||
1583 | 1583 | * @param array $element |
1584 | 1584 | * @return string |
1585 | 1585 | */ |
1586 | -function getpaid_get_form_element_grid_class( $element ) { |
|
1586 | +function getpaid_get_form_element_grid_class($element) { |
|
1587 | 1587 | |
1588 | 1588 | $class = 'col-12'; |
1589 | - $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width']; |
|
1589 | + $width = empty($element['grid_width']) ? 'full' : $element['grid_width']; |
|
1590 | 1590 | |
1591 | - if ( $width == 'half' ) { |
|
1591 | + if ($width == 'half') { |
|
1592 | 1592 | $class .= ' col-md-6'; |
1593 | 1593 | } |
1594 | 1594 | |
1595 | - if ( $width == 'third' ) { |
|
1595 | + if ($width == 'third') { |
|
1596 | 1596 | $class .= ' col-md-4'; |
1597 | 1597 | } |
1598 | 1598 | |
@@ -1607,15 +1607,15 @@ discard block |
||
1607 | 1607 | * |
1608 | 1608 | * @return string |
1609 | 1609 | */ |
1610 | -function getpaid_embed_url( $payment_form = false, $items = false ) { |
|
1610 | +function getpaid_embed_url($payment_form = false, $items = false) { |
|
1611 | 1611 | |
1612 | 1612 | return add_query_arg( |
1613 | 1613 | array( |
1614 | 1614 | 'getpaid_embed' => 1, |
1615 | - 'form' => $payment_form ? absint( $payment_form ) : false, |
|
1616 | - 'item' => $items ? urlencode( $items ) : false, |
|
1615 | + 'form' => $payment_form ? absint($payment_form) : false, |
|
1616 | + 'item' => $items ? urlencode($items) : false, |
|
1617 | 1617 | ), |
1618 | - home_url( 'index.php' ) |
|
1618 | + home_url('index.php') |
|
1619 | 1619 | ); |
1620 | 1620 | |
1621 | 1621 | } |
@@ -1625,13 +1625,13 @@ discard block |
||
1625 | 1625 | * |
1626 | 1626 | * @return string |
1627 | 1627 | */ |
1628 | -function getpaid_filter_embed_template( $template ) { |
|
1628 | +function getpaid_filter_embed_template($template) { |
|
1629 | 1629 | |
1630 | - if ( isset( $_GET['getpaid_embed'] ) ) { |
|
1631 | - wpinv_get_template( 'payment-forms/embed.php' ); |
|
1630 | + if (isset($_GET['getpaid_embed'])) { |
|
1631 | + wpinv_get_template('payment-forms/embed.php'); |
|
1632 | 1632 | exit; |
1633 | 1633 | } |
1634 | 1634 | |
1635 | 1635 | return $template; |
1636 | 1636 | } |
1637 | -add_filter( 'template_include', 'getpaid_filter_embed_template' ); |
|
1637 | +add_filter('template_include', 'getpaid_filter_embed_template'); |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * GetPaid_Reports_Export Class. |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | public function display() { |
20 | 20 | |
21 | 21 | echo "<div class='row mt-4' style='max-width: 920px;' >"; |
22 | - foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { |
|
23 | - $this->display_post_type_export( $post_type ); |
|
22 | + foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) { |
|
23 | + $this->display_post_type_export($post_type); |
|
24 | 24 | } |
25 | 25 | $this->display_subscription_export(); |
26 | 26 | echo '</div>'; |
@@ -31,13 +31,13 @@ discard block |
||
31 | 31 | * Retrieves the download url. |
32 | 32 | * |
33 | 33 | */ |
34 | - public function get_download_url( $post_type ) { |
|
34 | + public function get_download_url($post_type) { |
|
35 | 35 | |
36 | 36 | return wp_nonce_url( |
37 | 37 | add_query_arg( |
38 | 38 | array( |
39 | 39 | 'getpaid-admin-action' => 'export_invoices', |
40 | - 'post_type' => urlencode( $post_type ), |
|
40 | + 'post_type' => urlencode($post_type), |
|
41 | 41 | ) |
42 | 42 | ), |
43 | 43 | 'getpaid-nonce', |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * Displays a single post type export card. |
51 | 51 | * |
52 | 52 | */ |
53 | - public function display_post_type_export( $post_type ) { |
|
53 | + public function display_post_type_export($post_type) { |
|
54 | 54 | |
55 | 55 | ?> |
56 | 56 | |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | <strong> |
62 | 62 | <?php |
63 | 63 | printf( |
64 | - esc_html__( 'Export %s', 'invoicing' ), |
|
65 | - esc_html( getpaid_get_post_type_label( $post_type ) ) |
|
64 | + esc_html__('Export %s', 'invoicing'), |
|
65 | + esc_html(getpaid_get_post_type_label($post_type)) |
|
66 | 66 | ); |
67 | 67 | ?> |
68 | 68 | </strong> |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | |
71 | 71 | <div class="card-body"> |
72 | 72 | |
73 | - <form method="post" action="<?php echo esc_url( $this->get_download_url( $post_type ) ); ?>"> |
|
73 | + <form method="post" action="<?php echo esc_url($this->get_download_url($post_type)); ?>"> |
|
74 | 74 | |
75 | 75 | <?php |
76 | - $this->generate_from_date( $post_type ); |
|
77 | - $this->generate_to_date( $post_type ); |
|
78 | - $this->generate_post_status_select( $post_type ); |
|
79 | - $this->generate_file_type_select( $post_type ); |
|
80 | - submit_button( __( 'Download', 'invoicing' ) ); |
|
76 | + $this->generate_from_date($post_type); |
|
77 | + $this->generate_to_date($post_type); |
|
78 | + $this->generate_post_status_select($post_type); |
|
79 | + $this->generate_file_type_select($post_type); |
|
80 | + submit_button(__('Download', 'invoicing')); |
|
81 | 81 | ?> |
82 | 82 | |
83 | 83 | </form> |
@@ -95,14 +95,14 @@ discard block |
||
95 | 95 | * Generates the from date input field. |
96 | 96 | * |
97 | 97 | */ |
98 | - public function generate_from_date( $post_type ) { |
|
98 | + public function generate_from_date($post_type) { |
|
99 | 99 | |
100 | 100 | aui()->input( |
101 | 101 | array( |
102 | 102 | 'type' => 'datepicker', |
103 | - 'id' => esc_attr( "$post_type-from_date" ), |
|
103 | + 'id' => esc_attr("$post_type-from_date"), |
|
104 | 104 | 'name' => 'from_date', |
105 | - 'label' => __( 'From Date', 'invoicing' ), |
|
105 | + 'label' => __('From Date', 'invoicing'), |
|
106 | 106 | 'label_type' => 'vertical', |
107 | 107 | 'placeholder' => 'YYYY-MM-DD', |
108 | 108 | 'extra_attributes' => array( |
@@ -119,14 +119,14 @@ discard block |
||
119 | 119 | * Generates the to date input field. |
120 | 120 | * |
121 | 121 | */ |
122 | - public function generate_to_date( $post_type ) { |
|
122 | + public function generate_to_date($post_type) { |
|
123 | 123 | |
124 | 124 | aui()->input( |
125 | 125 | array( |
126 | 126 | 'type' => 'datepicker', |
127 | - 'id' => esc_attr( "$post_type-to_date" ), |
|
127 | + 'id' => esc_attr("$post_type-to_date"), |
|
128 | 128 | 'name' => 'to_date', |
129 | - 'label' => __( 'To Date', 'invoicing' ), |
|
129 | + 'label' => __('To Date', 'invoicing'), |
|
130 | 130 | 'label_type' => 'vertical', |
131 | 131 | 'placeholder' => 'YYYY-MM-DD', |
132 | 132 | 'extra_attributes' => array( |
@@ -142,20 +142,20 @@ discard block |
||
142 | 142 | * Generates the to post status select field. |
143 | 143 | * |
144 | 144 | */ |
145 | - public function generate_post_status_select( $post_type ) { |
|
145 | + public function generate_post_status_select($post_type) { |
|
146 | 146 | |
147 | - if ( 'subscriptions' === $post_type ) { |
|
147 | + if ('subscriptions' === $post_type) { |
|
148 | 148 | $options = getpaid_get_subscription_statuses(); |
149 | 149 | } else { |
150 | - $options = wpinv_get_invoice_statuses( true, false, $post_type ); |
|
150 | + $options = wpinv_get_invoice_statuses(true, false, $post_type); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | aui()->select( |
154 | 154 | array( |
155 | 155 | 'name' => 'status', |
156 | - 'id' => esc_attr( "$post_type-status" ), |
|
157 | - 'placeholder' => __( 'All Statuses', 'invoicing' ), |
|
158 | - 'label' => __( 'Status', 'invoicing' ), |
|
156 | + 'id' => esc_attr("$post_type-status"), |
|
157 | + 'placeholder' => __('All Statuses', 'invoicing'), |
|
158 | + 'label' => __('Status', 'invoicing'), |
|
159 | 159 | 'label_type' => 'vertical', |
160 | 160 | 'label_class' => 'd-block', |
161 | 161 | 'options' => $options, |
@@ -169,21 +169,21 @@ discard block |
||
169 | 169 | * Generates the to file type select field. |
170 | 170 | * |
171 | 171 | */ |
172 | - public function generate_file_type_select( $post_type ) { |
|
172 | + public function generate_file_type_select($post_type) { |
|
173 | 173 | |
174 | 174 | aui()->select( |
175 | 175 | array( |
176 | 176 | 'name' => 'file_type', |
177 | - 'id' => esc_attr( "$post_type-file_type" ), |
|
178 | - 'placeholder' => __( 'Select File Type', 'invoicing' ), |
|
179 | - 'label' => __( 'Export File', 'invoicing' ), |
|
177 | + 'id' => esc_attr("$post_type-file_type"), |
|
178 | + 'placeholder' => __('Select File Type', 'invoicing'), |
|
179 | + 'label' => __('Export File', 'invoicing'), |
|
180 | 180 | 'label_type' => 'vertical', |
181 | 181 | 'label_class' => 'd-block', |
182 | 182 | 'value' => 'csv', |
183 | 183 | 'options' => array( |
184 | - 'csv' => __( 'CSV', 'invoicing' ), |
|
185 | - 'xml' => __( 'XML', 'invoicing' ), |
|
186 | - 'json' => __( 'JSON', 'invoicing' ), |
|
184 | + 'csv' => __('CSV', 'invoicing'), |
|
185 | + 'xml' => __('XML', 'invoicing'), |
|
186 | + 'json' => __('JSON', 'invoicing'), |
|
187 | 187 | ), |
188 | 188 | ), |
189 | 189 | true |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * Displays a field's markup. |
196 | 196 | * |
197 | 197 | */ |
198 | - public function display_markup( $markup ) { |
|
198 | + public function display_markup($markup) { |
|
199 | 199 | |
200 | 200 | echo wp_kses( |
201 | 201 | str_replace( |
@@ -224,20 +224,20 @@ discard block |
||
224 | 224 | |
225 | 225 | <div class="card-header"> |
226 | 226 | <strong> |
227 | - <?php esc_html_e( 'Export Subscriptions', 'invoicing' ); ?> |
|
227 | + <?php esc_html_e('Export Subscriptions', 'invoicing'); ?> |
|
228 | 228 | </strong> |
229 | 229 | </div> |
230 | 230 | |
231 | 231 | <div class="card-body"> |
232 | 232 | |
233 | - <form method="post" action="<?php echo esc_url( $this->get_download_url( 'subscriptions' ) ); ?>"> |
|
233 | + <form method="post" action="<?php echo esc_url($this->get_download_url('subscriptions')); ?>"> |
|
234 | 234 | |
235 | 235 | <?php |
236 | - $this->generate_from_date( 'subscriptions' ); |
|
237 | - $this->generate_to_date( 'subscriptions' ); |
|
238 | - $this->generate_post_status_select( 'subscriptions' ); |
|
239 | - $this->generate_file_type_select( 'subscriptions' ); |
|
240 | - submit_button( __( 'Download', 'invoicing' ) ); |
|
236 | + $this->generate_from_date('subscriptions'); |
|
237 | + $this->generate_to_date('subscriptions'); |
|
238 | + $this->generate_post_status_select('subscriptions'); |
|
239 | + $this->generate_file_type_select('subscriptions'); |
|
240 | + submit_button(__('Download', 'invoicing')); |
|
241 | 241 | ?> |
242 | 242 | |
243 | 243 | </form> |
@@ -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( 'WP_Font_Awesome_Settings' ) ) { |
|
22 | +if (!class_exists('WP_Font_Awesome_Settings')) { |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * A Class to be able to change settings for Font Awesome. |
@@ -92,18 +92,18 @@ discard block |
||
92 | 92 | * @return WP_Font_Awesome_Settings - Main instance. |
93 | 93 | */ |
94 | 94 | public static function instance() { |
95 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) { |
|
95 | + if (!isset(self::$instance) && !(self::$instance instanceof WP_Font_Awesome_Settings)) { |
|
96 | 96 | self::$instance = new WP_Font_Awesome_Settings; |
97 | 97 | |
98 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
98 | + add_action('init', array(self::$instance, 'init')); // set settings |
|
99 | 99 | |
100 | - if ( is_admin() ) { |
|
101 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
102 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
103 | - add_action( 'admin_notices', array( self::$instance, 'admin_notices' ) ); |
|
100 | + if (is_admin()) { |
|
101 | + add_action('admin_menu', array(self::$instance, 'menu_item')); |
|
102 | + add_action('admin_init', array(self::$instance, 'register_settings')); |
|
103 | + add_action('admin_notices', array(self::$instance, 'admin_notices')); |
|
104 | 104 | } |
105 | 105 | |
106 | - do_action( 'wp_font_awesome_settings_loaded' ); |
|
106 | + do_action('wp_font_awesome_settings_loaded'); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | return self::$instance; |
@@ -116,40 +116,40 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function init() { |
118 | 118 | // Download fontawesome locally. |
119 | - add_action( 'add_option_wp-font-awesome-settings', array( $this, 'add_option_wp_font_awesome_settings' ), 10, 2 ); |
|
120 | - add_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 ); |
|
119 | + add_action('add_option_wp-font-awesome-settings', array($this, 'add_option_wp_font_awesome_settings'), 10, 2); |
|
120 | + add_action('update_option_wp-font-awesome-settings', array($this, 'update_option_wp_font_awesome_settings'), 10, 2); |
|
121 | 121 | |
122 | 122 | $this->settings = $this->get_settings(); |
123 | 123 | |
124 | 124 | // check if the official plugin is active and use that instead if so. |
125 | - if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) { |
|
125 | + if (!defined('FONTAWESOME_PLUGIN_FILE')) { |
|
126 | 126 | |
127 | - if ( $this->settings['type'] == 'CSS' ) { |
|
127 | + if ($this->settings['type'] == 'CSS') { |
|
128 | 128 | |
129 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
130 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
129 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') { |
|
130 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 5000); |
|
131 | 131 | } |
132 | 132 | |
133 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
134 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
135 | - add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_styles' ), 10, 2 ); |
|
133 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') { |
|
134 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 5000); |
|
135 | + add_filter('block_editor_settings_all', array($this, 'enqueue_editor_styles'), 10, 2); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | } else { |
139 | 139 | |
140 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
141 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
140 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') { |
|
141 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5000); |
|
142 | 142 | } |
143 | 143 | |
144 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
145 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
146 | - add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_scripts' ), 10, 2 ); |
|
144 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') { |
|
145 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 5000); |
|
146 | + add_filter('block_editor_settings_all', array($this, 'enqueue_editor_scripts'), 10, 2); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | 150 | // remove font awesome if set to do so |
151 | - if ( $this->settings['dequeue'] == '1' ) { |
|
152 | - add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 ); |
|
151 | + if ($this->settings['dequeue'] == '1') { |
|
152 | + add_action('clean_url', array($this, 'remove_font_awesome'), 5000, 3); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return array |
165 | 165 | */ |
166 | - public function enqueue_editor_styles( $editor_settings, $block_editor_context ){ |
|
166 | + public function enqueue_editor_styles($editor_settings, $block_editor_context) { |
|
167 | 167 | |
168 | - if ( ! empty( $editor_settings['__unstableResolvedAssets']['styles'] ) ) { |
|
168 | + if (!empty($editor_settings['__unstableResolvedAssets']['styles'])) { |
|
169 | 169 | $url = $this->get_url(); |
170 | 170 | $editor_settings['__unstableResolvedAssets']['styles'] .= "<link rel='stylesheet' id='font-awesome-css' href='$url' media='all' />"; |
171 | 171 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @return array |
183 | 183 | */ |
184 | - public function enqueue_editor_scripts( $editor_settings, $block_editor_context ){ |
|
184 | + public function enqueue_editor_scripts($editor_settings, $block_editor_context) { |
|
185 | 185 | |
186 | 186 | $url = $this->get_url(); |
187 | 187 | $editor_settings['__unstableResolvedAssets']['scripts'] .= "<script src='$url' id='font-awesome-js'></script>"; |
@@ -195,22 +195,22 @@ discard block |
||
195 | 195 | public function enqueue_style() { |
196 | 196 | // build url |
197 | 197 | $url = $this->get_url(); |
198 | - $version = ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ? strip_tags( $this->settings['local_version'] ) : null; |
|
198 | + $version = !empty($this->settings['local']) && empty($this->settings['pro']) ? strip_tags($this->settings['local_version']) : null; |
|
199 | 199 | |
200 | - wp_deregister_style( 'font-awesome' ); // deregister in case its already there |
|
201 | - wp_register_style( 'font-awesome', $url, array(), $version ); |
|
202 | - wp_enqueue_style( 'font-awesome' ); |
|
200 | + wp_deregister_style('font-awesome'); // deregister in case its already there |
|
201 | + wp_register_style('font-awesome', $url, array(), $version); |
|
202 | + wp_enqueue_style('font-awesome'); |
|
203 | 203 | |
204 | 204 | // RTL language support CSS. |
205 | - if ( is_rtl() ) { |
|
206 | - wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() ); |
|
205 | + if (is_rtl()) { |
|
206 | + wp_add_inline_style('font-awesome', $this->rtl_inline_css()); |
|
207 | 207 | } |
208 | 208 | |
209 | - if ( $this->settings['shims'] ) { |
|
210 | - $url = $this->get_url( true ); |
|
211 | - wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there |
|
212 | - wp_register_style( 'font-awesome-shims', $url, array(), $version ); |
|
213 | - wp_enqueue_style( 'font-awesome-shims' ); |
|
209 | + if ($this->settings['shims']) { |
|
210 | + $url = $this->get_url(true); |
|
211 | + wp_deregister_style('font-awesome-shims'); // deregister in case its already there |
|
212 | + wp_register_style('font-awesome-shims', $url, array(), $version); |
|
213 | + wp_enqueue_style('font-awesome-shims'); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
@@ -222,15 +222,15 @@ discard block |
||
222 | 222 | $url = $this->get_url(); |
223 | 223 | |
224 | 224 | $deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script'; |
225 | - call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there |
|
226 | - wp_register_script( 'font-awesome', $url, array(), null ); |
|
227 | - wp_enqueue_script( 'font-awesome' ); |
|
225 | + call_user_func($deregister_function, 'font-awesome'); // deregister in case its already there |
|
226 | + wp_register_script('font-awesome', $url, array(), null); |
|
227 | + wp_enqueue_script('font-awesome'); |
|
228 | 228 | |
229 | - if ( $this->settings['shims'] ) { |
|
230 | - $url = $this->get_url( true ); |
|
231 | - call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there |
|
232 | - wp_register_script( 'font-awesome-shims', $url, array(), null ); |
|
233 | - wp_enqueue_script( 'font-awesome-shims' ); |
|
229 | + if ($this->settings['shims']) { |
|
230 | + $url = $this->get_url(true); |
|
231 | + call_user_func($deregister_function, 'font-awesome-shims'); // deregister in case its already there |
|
232 | + wp_register_script('font-awesome-shims', $url, array(), null); |
|
233 | + wp_enqueue_script('font-awesome-shims'); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
@@ -242,16 +242,16 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return string The url to the file. |
244 | 244 | */ |
245 | - public function get_url( $shims = false, $local = true ) { |
|
245 | + public function get_url($shims = false, $local = true) { |
|
246 | 246 | $script = $shims ? 'v4-shims' : 'all'; |
247 | 247 | $sub = $this->settings['pro'] ? 'pro' : 'use'; |
248 | 248 | $type = $this->settings['type']; |
249 | 249 | $version = $this->settings['version']; |
250 | - $kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : ''; |
|
250 | + $kit_url = $this->settings['kit-url'] ? esc_url($this->settings['kit-url']) : ''; |
|
251 | 251 | $url = ''; |
252 | 252 | |
253 | - if ( $type == 'KIT' && $kit_url ) { |
|
254 | - if ( $shims ) { |
|
253 | + if ($type == 'KIT' && $kit_url) { |
|
254 | + if ($shims) { |
|
255 | 255 | // if its a kit then we don't add shims here |
256 | 256 | return ''; |
257 | 257 | } |
@@ -260,13 +260,13 @@ discard block |
||
260 | 260 | } else { |
261 | 261 | $v = ''; |
262 | 262 | // Check and load locally. |
263 | - if ( $local && $this->has_local() ) { |
|
263 | + if ($local && $this->has_local()) { |
|
264 | 264 | $script .= ".min"; |
265 | - $v .= '&ver=' . strip_tags( $this->settings['local_version'] ); |
|
265 | + $v .= '&ver=' . strip_tags($this->settings['local_version']); |
|
266 | 266 | $url .= $this->get_fonts_url(); // Local fonts url. |
267 | 267 | } else { |
268 | 268 | $url .= "https://$sub.fontawesome.com/releases/"; // CDN |
269 | - $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version |
|
269 | + $url .= !empty($version) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version |
|
270 | 270 | } |
271 | 271 | $url .= $type == 'CSS' ? 'css/' : 'js/'; // type |
272 | 272 | $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type |
@@ -287,16 +287,16 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @return string The filtered url. |
289 | 289 | */ |
290 | - public function remove_font_awesome( $url, $original_url, $_context ) { |
|
290 | + public function remove_font_awesome($url, $original_url, $_context) { |
|
291 | 291 | |
292 | - if ( $_context == 'display' |
|
293 | - && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false ) |
|
294 | - && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false ) |
|
292 | + if ($_context == 'display' |
|
293 | + && (strstr($url, "fontawesome") !== false || strstr($url, "font-awesome") !== false) |
|
294 | + && (strstr($url, ".js") !== false || strstr($url, ".css") !== false) |
|
295 | 295 | ) {// it's a font-awesome-url (probably) |
296 | 296 | |
297 | - if ( strstr( $url, "wpfas=true" ) !== false ) { |
|
298 | - if ( $this->settings['type'] == 'JS' ) { |
|
299 | - if ( $this->settings['js-pseudo'] ) { |
|
297 | + if (strstr($url, "wpfas=true") !== false) { |
|
298 | + if ($this->settings['type'] == 'JS') { |
|
299 | + if ($this->settings['js-pseudo']) { |
|
300 | 300 | $url .= "' data-search-pseudo-elements defer='defer"; |
301 | 301 | } else { |
302 | 302 | $url .= "' defer='defer"; |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * Register the database settings with WordPress. |
316 | 316 | */ |
317 | 317 | public function register_settings() { |
318 | - register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' ); |
|
318 | + register_setting('wp-font-awesome-settings', 'wp-font-awesome-settings'); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -324,10 +324,10 @@ discard block |
||
324 | 324 | */ |
325 | 325 | public function menu_item() { |
326 | 326 | $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
327 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array( |
|
327 | + call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array( |
|
328 | 328 | $this, |
329 | 329 | 'settings_page' |
330 | - ) ); |
|
330 | + )); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | * @return array The array of settings. |
337 | 337 | */ |
338 | 338 | public function get_settings() { |
339 | - $db_settings = get_option( 'wp-font-awesome-settings' ); |
|
339 | + $db_settings = get_option('wp-font-awesome-settings'); |
|
340 | 340 | |
341 | 341 | $defaults = array( |
342 | 342 | 'type' => 'CSS', // type to use, CSS or JS or KIT |
@@ -351,30 +351,30 @@ discard block |
||
351 | 351 | 'kit-url' => '', // the kit url |
352 | 352 | ); |
353 | 353 | |
354 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
354 | + $settings = wp_parse_args($db_settings, $defaults); |
|
355 | 355 | |
356 | 356 | /** |
357 | 357 | * Filter the Font Awesome settings. |
358 | 358 | * |
359 | 359 | * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
360 | 360 | */ |
361 | - return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults ); |
|
361 | + return $this->settings = apply_filters('wp-font-awesome-settings', $settings, $db_settings, $defaults); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
365 | 365 | * The settings page html output. |
366 | 366 | */ |
367 | 367 | public function settings_page() { |
368 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
369 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) ); |
|
368 | + if (!current_user_can('manage_options')) { |
|
369 | + wp_die(__('You do not have sufficient permissions to access this page.', 'font-awesome-settings')); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | // a hidden way to force the update of the version number via api instead of waiting the 48 hours |
373 | - if ( isset( $_REQUEST['force-version-check'] ) ) { |
|
374 | - $this->get_latest_version( $force_api = true ); |
|
373 | + if (isset($_REQUEST['force-version-check'])) { |
|
374 | + $this->get_latest_version($force_api = true); |
|
375 | 375 | } |
376 | 376 | |
377 | - if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) { |
|
377 | + if (!defined('FONTAWESOME_PLUGIN_FILE')) { |
|
378 | 378 | ?> |
379 | 379 | <style> |
380 | 380 | .wpfas-kit-show { |
@@ -401,42 +401,42 @@ discard block |
||
401 | 401 | <h1><?php echo $this->name; ?></h1> |
402 | 402 | <form method="post" action="options.php" class="fas-settings-form"> |
403 | 403 | <?php |
404 | - settings_fields( 'wp-font-awesome-settings' ); |
|
405 | - do_settings_sections( 'wp-font-awesome-settings' ); |
|
404 | + settings_fields('wp-font-awesome-settings'); |
|
405 | + do_settings_sections('wp-font-awesome-settings'); |
|
406 | 406 | $table_class = ''; |
407 | - if ( $this->settings['type'] ) { |
|
408 | - $table_class .= 'wpfas-' . sanitize_html_class( strtolower( $this->settings['type'] ) ) . '-set'; |
|
407 | + if ($this->settings['type']) { |
|
408 | + $table_class .= 'wpfas-' . sanitize_html_class(strtolower($this->settings['type'])) . '-set'; |
|
409 | 409 | } |
410 | - if ( ! empty( $this->settings['pro'] ) ) { |
|
410 | + if (!empty($this->settings['pro'])) { |
|
411 | 411 | $table_class .= ' wpfas-has-pro'; |
412 | 412 | } |
413 | 413 | ?> |
414 | - <?php if ( $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ) { ?> |
|
415 | - <?php if ( $this->has_local() ) { ?> |
|
416 | - <div class="notice notice-info"><p><strong><?php _e( 'Font Awesome fonts are loading locally.', 'font-awesome-settings' ); ?></strong></p></div> |
|
414 | + <?php if ($this->settings['type'] != 'KIT' && !empty($this->settings['local']) && empty($this->settings['pro'])) { ?> |
|
415 | + <?php if ($this->has_local()) { ?> |
|
416 | + <div class="notice notice-info"><p><strong><?php _e('Font Awesome fonts are loading locally.', 'font-awesome-settings'); ?></strong></p></div> |
|
417 | 417 | <?php } else { ?> |
418 | - <div class="notice notice-error"><p><strong><?php _e( 'Font Awesome fonts are not loading locally!', 'font-awesome-settings' ); ?></strong></p></div> |
|
418 | + <div class="notice notice-error"><p><strong><?php _e('Font Awesome fonts are not loading locally!', 'font-awesome-settings'); ?></strong></p></div> |
|
419 | 419 | <?php } ?> |
420 | 420 | <?php } ?> |
421 | - <table class="form-table wpfas-table-settings <?php echo esc_attr( $table_class ); ?>"> |
|
421 | + <table class="form-table wpfas-table-settings <?php echo esc_attr($table_class); ?>"> |
|
422 | 422 | <tr valign="top"> |
423 | - <th scope="row"><label for="wpfas-type"><?php _e( 'Type', 'font-awesome-settings' ); ?></label></th> |
|
423 | + <th scope="row"><label for="wpfas-type"><?php _e('Type', 'font-awesome-settings'); ?></label></th> |
|
424 | 424 | <td> |
425 | 425 | <select name="wp-font-awesome-settings[type]" id="wpfas-type" onchange="if(this.value=='KIT'){jQuery('.wpfas-table-settings').addClass('wpfas-kit-set');}else{jQuery('.wpfas-table-settings').removeClass('wpfas-kit-set');}"> |
426 | - <option value="CSS" <?php selected( $this->settings['type'], 'CSS' ); ?>><?php _e( 'CSS (default)', 'font-awesome-settings' ); ?></option> |
|
427 | - <option value="JS" <?php selected( $this->settings['type'], 'JS' ); ?>>JS</option> |
|
428 | - <option value="KIT" <?php selected( $this->settings['type'], 'KIT' ); ?>><?php _e( 'Kits (settings managed on fontawesome.com)', 'font-awesome-settings' ); ?></option> |
|
426 | + <option value="CSS" <?php selected($this->settings['type'], 'CSS'); ?>><?php _e('CSS (default)', 'font-awesome-settings'); ?></option> |
|
427 | + <option value="JS" <?php selected($this->settings['type'], 'JS'); ?>>JS</option> |
|
428 | + <option value="KIT" <?php selected($this->settings['type'], 'KIT'); ?>><?php _e('Kits (settings managed on fontawesome.com)', 'font-awesome-settings'); ?></option> |
|
429 | 429 | </select> |
430 | 430 | </td> |
431 | 431 | </tr> |
432 | 432 | |
433 | 433 | <tr valign="top" class="wpfas-kit-show"> |
434 | - <th scope="row"><label for="wpfas-kit-url"><?php _e( 'Kit URL', 'font-awesome-settings' ); ?></label></th> |
|
434 | + <th scope="row"><label for="wpfas-kit-url"><?php _e('Kit URL', 'font-awesome-settings'); ?></label></th> |
|
435 | 435 | <td> |
436 | - <input class="regular-text" id="wpfas-kit-url" type="url" name="wp-font-awesome-settings[kit-url]" value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>" placeholder="<?php echo 'https://kit.font';echo 'awesome.com/123abc.js'; // this won't pass theme check :(?>"/> |
|
436 | + <input class="regular-text" id="wpfas-kit-url" type="url" name="wp-font-awesome-settings[kit-url]" value="<?php echo esc_attr($this->settings['kit-url']); ?>" placeholder="<?php echo 'https://kit.font'; echo 'awesome.com/123abc.js'; // this won't pass theme check :(?>"/> |
|
437 | 437 | <span><?php |
438 | 438 | echo sprintf( |
439 | - __( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ), |
|
439 | + __('Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings'), |
|
440 | 440 | '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>', |
441 | 441 | '</a>' |
442 | 442 | ); |
@@ -445,44 +445,44 @@ discard block |
||
445 | 445 | </tr> |
446 | 446 | |
447 | 447 | <tr valign="top" class="wpfas-kit-hide"> |
448 | - <th scope="row"><label for="wpfas-version"><?php _e( 'Version', 'font-awesome-settings' ); ?></label></th> |
|
448 | + <th scope="row"><label for="wpfas-version"><?php _e('Version', 'font-awesome-settings'); ?></label></th> |
|
449 | 449 | <td> |
450 | 450 | <select name="wp-font-awesome-settings[version]" id="wpfas-version"> |
451 | - <option value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo sprintf( __( 'Latest - %s (default)', 'font-awesome-settings' ), $this->get_latest_version() ); ?></option> |
|
452 | - <option value="6.1.0" <?php selected( $this->settings['version'], '6.1.0' ); ?>>6.1.0</option> |
|
453 | - <option value="6.0.0" <?php selected( $this->settings['version'], '6.0.0' ); ?>>6.0.0</option> |
|
454 | - <option value="5.15.4" <?php selected( $this->settings['version'], '5.15.4' ); ?>>5.15.4</option> |
|
455 | - <option value="5.6.0" <?php selected( $this->settings['version'], '5.6.0' ); ?>>5.6.0</option> |
|
456 | - <option value="5.5.0" <?php selected( $this->settings['version'], '5.5.0' ); ?>>5.5.0</option> |
|
457 | - <option value="5.4.0" <?php selected( $this->settings['version'], '5.4.0' ); ?>>5.4.0</option> |
|
458 | - <option value="5.3.0" <?php selected( $this->settings['version'], '5.3.0' ); ?>>5.3.0</option> |
|
459 | - <option value="5.2.0" <?php selected( $this->settings['version'], '5.2.0' ); ?>>5.2.0</option> |
|
460 | - <option value="5.1.0" <?php selected( $this->settings['version'], '5.1.0' ); ?>>5.1.0</option> |
|
461 | - <option value="4.7.0" <?php selected( $this->settings['version'], '4.7.0' ); ?>>4.7.1 (CSS only)</option> |
|
451 | + <option value="" <?php selected($this->settings['version'], ''); ?>><?php echo sprintf(__('Latest - %s (default)', 'font-awesome-settings'), $this->get_latest_version()); ?></option> |
|
452 | + <option value="6.1.0" <?php selected($this->settings['version'], '6.1.0'); ?>>6.1.0</option> |
|
453 | + <option value="6.0.0" <?php selected($this->settings['version'], '6.0.0'); ?>>6.0.0</option> |
|
454 | + <option value="5.15.4" <?php selected($this->settings['version'], '5.15.4'); ?>>5.15.4</option> |
|
455 | + <option value="5.6.0" <?php selected($this->settings['version'], '5.6.0'); ?>>5.6.0</option> |
|
456 | + <option value="5.5.0" <?php selected($this->settings['version'], '5.5.0'); ?>>5.5.0</option> |
|
457 | + <option value="5.4.0" <?php selected($this->settings['version'], '5.4.0'); ?>>5.4.0</option> |
|
458 | + <option value="5.3.0" <?php selected($this->settings['version'], '5.3.0'); ?>>5.3.0</option> |
|
459 | + <option value="5.2.0" <?php selected($this->settings['version'], '5.2.0'); ?>>5.2.0</option> |
|
460 | + <option value="5.1.0" <?php selected($this->settings['version'], '5.1.0'); ?>>5.1.0</option> |
|
461 | + <option value="4.7.0" <?php selected($this->settings['version'], '4.7.0'); ?>>4.7.1 (CSS only)</option> |
|
462 | 462 | </select> |
463 | 463 | </td> |
464 | 464 | </tr> |
465 | 465 | |
466 | 466 | <tr valign="top"> |
467 | - <th scope="row"><label for="wpfas-enqueue"><?php _e( 'Enqueue', 'font-awesome-settings' ); ?></label></th> |
|
467 | + <th scope="row"><label for="wpfas-enqueue"><?php _e('Enqueue', 'font-awesome-settings'); ?></label></th> |
|
468 | 468 | <td> |
469 | 469 | <select name="wp-font-awesome-settings[enqueue]" id="wpfas-enqueue"> |
470 | - <option value="" <?php selected( $this->settings['enqueue'], '' ); ?>><?php _e( 'Frontend + Backend (default)', 'font-awesome-settings' ); ?></option> |
|
471 | - <option value="frontend" <?php selected( $this->settings['enqueue'], 'frontend' ); ?>><?php _e( 'Frontend', 'font-awesome-settings' ); ?></option> |
|
472 | - <option value="backend" <?php selected( $this->settings['enqueue'], 'backend' ); ?>><?php _e( 'Backend', 'font-awesome-settings' ); ?></option> |
|
470 | + <option value="" <?php selected($this->settings['enqueue'], ''); ?>><?php _e('Frontend + Backend (default)', 'font-awesome-settings'); ?></option> |
|
471 | + <option value="frontend" <?php selected($this->settings['enqueue'], 'frontend'); ?>><?php _e('Frontend', 'font-awesome-settings'); ?></option> |
|
472 | + <option value="backend" <?php selected($this->settings['enqueue'], 'backend'); ?>><?php _e('Backend', 'font-awesome-settings'); ?></option> |
|
473 | 473 | </select> |
474 | 474 | </td> |
475 | 475 | </tr> |
476 | 476 | |
477 | 477 | <tr valign="top" class="wpfas-kit-hide"> |
478 | 478 | <th scope="row"><label |
479 | - for="wpfas-pro"><?php _e( 'Enable pro', 'font-awesome-settings' ); ?></label></th> |
|
479 | + for="wpfas-pro"><?php _e('Enable pro', 'font-awesome-settings'); ?></label></th> |
|
480 | 480 | <td> |
481 | 481 | <input type="hidden" name="wp-font-awesome-settings[pro]" value="0"/> |
482 | - <input type="checkbox" name="wp-font-awesome-settings[pro]" value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro" onchange="if(jQuery(this).is(':checked')){jQuery('.wpfas-table-settings').addClass('wpfas-has-pro')}else{jQuery('.wpfas-table-settings').removeClass('wpfas-has-pro')}"/> |
|
482 | + <input type="checkbox" name="wp-font-awesome-settings[pro]" value="1" <?php checked($this->settings['pro'], '1'); ?> id="wpfas-pro" onchange="if(jQuery(this).is(':checked')){jQuery('.wpfas-table-settings').addClass('wpfas-has-pro')}else{jQuery('.wpfas-table-settings').removeClass('wpfas-has-pro')}"/> |
|
483 | 483 | <span><?php |
484 | 484 | echo wp_sprintf( |
485 | - __( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ), |
|
485 | + __('Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings'), |
|
486 | 486 | '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/referral?a=c9b89e1418">', |
487 | 487 | ' <i class="fas fa-external-link-alt"></i></a>', |
488 | 488 | '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn">', |
@@ -493,49 +493,49 @@ discard block |
||
493 | 493 | </tr> |
494 | 494 | |
495 | 495 | <tr valign="top" class="wpfas-kit-hide wpfas-hide-pro"> |
496 | - <th scope="row"><label for="wpfas-local"><?php _e( 'Load Fonts Locally', 'font-awesome-settings' ); ?></label></th> |
|
496 | + <th scope="row"><label for="wpfas-local"><?php _e('Load Fonts Locally', 'font-awesome-settings'); ?></label></th> |
|
497 | 497 | <td> |
498 | 498 | <input type="hidden" name="wp-font-awesome-settings[local]" value="0"/> |
499 | - <input type="hidden" name="wp-font-awesome-settings[local_version]" value="<?php echo esc_attr( $this->settings['local_version'] ); ?>"/> |
|
500 | - <input type="checkbox" name="wp-font-awesome-settings[local]" value="1" <?php checked( $this->settings['local'], '1' ); ?> id="wpfas-local"/> |
|
501 | - <span><?php _e( '(For free version only) Load FontAwesome fonts from locally. This downloads FontAwesome fonts from fontawesome.com & stores at the local site.', 'font-awesome-settings' ); ?></span> |
|
499 | + <input type="hidden" name="wp-font-awesome-settings[local_version]" value="<?php echo esc_attr($this->settings['local_version']); ?>"/> |
|
500 | + <input type="checkbox" name="wp-font-awesome-settings[local]" value="1" <?php checked($this->settings['local'], '1'); ?> id="wpfas-local"/> |
|
501 | + <span><?php _e('(For free version only) Load FontAwesome fonts from locally. This downloads FontAwesome fonts from fontawesome.com & stores at the local site.', 'font-awesome-settings'); ?></span> |
|
502 | 502 | </td> |
503 | 503 | </tr> |
504 | 504 | |
505 | 505 | <tr valign="top" class="wpfas-kit-hide"> |
506 | 506 | <th scope="row"><label |
507 | - for="wpfas-shims"><?php _e( 'Enable v4 shims compatibility', 'font-awesome-settings' ); ?></label> |
|
507 | + for="wpfas-shims"><?php _e('Enable v4 shims compatibility', 'font-awesome-settings'); ?></label> |
|
508 | 508 | </th> |
509 | 509 | <td> |
510 | 510 | <input type="hidden" name="wp-font-awesome-settings[shims]" value="0"/> |
511 | 511 | <input type="checkbox" name="wp-font-awesome-settings[shims]" |
512 | - value="1" <?php checked( $this->settings['shims'], '1' ); ?> id="wpfas-shims"/> |
|
513 | - <span><?php _e( 'This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings' ); ?></span> |
|
512 | + value="1" <?php checked($this->settings['shims'], '1'); ?> id="wpfas-shims"/> |
|
513 | + <span><?php _e('This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings'); ?></span> |
|
514 | 514 | </td> |
515 | 515 | </tr> |
516 | 516 | |
517 | 517 | <tr valign="top" class="wpfas-kit-hide"> |
518 | 518 | <th scope="row"><label |
519 | - for="wpfas-js-pseudo"><?php _e( 'Enable JS pseudo elements (not recommended)', 'font-awesome-settings' ); ?></label> |
|
519 | + for="wpfas-js-pseudo"><?php _e('Enable JS pseudo elements (not recommended)', 'font-awesome-settings'); ?></label> |
|
520 | 520 | </th> |
521 | 521 | <td> |
522 | 522 | <input type="hidden" name="wp-font-awesome-settings[js-pseudo]" value="0"/> |
523 | 523 | <input type="checkbox" name="wp-font-awesome-settings[js-pseudo]" |
524 | - value="1" <?php checked( $this->settings['js-pseudo'], '1' ); ?> |
|
524 | + value="1" <?php checked($this->settings['js-pseudo'], '1'); ?> |
|
525 | 525 | id="wpfas-js-pseudo"/> |
526 | - <span><?php _e( 'Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings' ); ?></span> |
|
526 | + <span><?php _e('Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings'); ?></span> |
|
527 | 527 | </td> |
528 | 528 | </tr> |
529 | 529 | |
530 | 530 | <tr valign="top"> |
531 | 531 | <th scope="row"><label |
532 | - for="wpfas-dequeue"><?php _e( 'Dequeue', 'font-awesome-settings' ); ?></label></th> |
|
532 | + for="wpfas-dequeue"><?php _e('Dequeue', 'font-awesome-settings'); ?></label></th> |
|
533 | 533 | <td> |
534 | 534 | <input type="hidden" name="wp-font-awesome-settings[dequeue]" value="0"/> |
535 | 535 | <input type="checkbox" name="wp-font-awesome-settings[dequeue]" |
536 | - value="1" <?php checked( $this->settings['dequeue'], '1' ); ?> |
|
536 | + value="1" <?php checked($this->settings['dequeue'], '1'); ?> |
|
537 | 537 | id="wpfas-dequeue"/> |
538 | - <span><?php _e( 'This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings' ); ?></span> |
|
538 | + <span><?php _e('This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings'); ?></span> |
|
539 | 539 | </td> |
540 | 540 | </tr> |
541 | 541 | |
@@ -544,12 +544,12 @@ discard block |
||
544 | 544 | <?php |
545 | 545 | submit_button(); |
546 | 546 | ?> |
547 | - <p class="submit"><a href="https://fontawesome.com/referral?a=c9b89e1418" class="button button-secondary"><?php _e('Get 14,000+ more icons with Font Awesome Pro','font-awesome-settings'); ?> <i class="fas fa-external-link-alt"></i></a></p> |
|
547 | + <p class="submit"><a href="https://fontawesome.com/referral?a=c9b89e1418" class="button button-secondary"><?php _e('Get 14,000+ more icons with Font Awesome Pro', 'font-awesome-settings'); ?> <i class="fas fa-external-link-alt"></i></a></p> |
|
548 | 548 | |
549 | 549 | </div> |
550 | 550 | </form> |
551 | 551 | |
552 | - <div id="wpfas-version"><?php echo sprintf(__( 'Version: %s (affiliate links provided)', 'font-awesome-settings' ), $this->version ); ?></div> |
|
552 | + <div id="wpfas-version"><?php echo sprintf(__('Version: %s (affiliate links provided)', 'font-awesome-settings'), $this->version); ?></div> |
|
553 | 553 | </div> |
554 | 554 | <?php |
555 | 555 | } |
@@ -564,12 +564,12 @@ discard block |
||
564 | 564 | * |
565 | 565 | * @return string Either a valid version number or an empty string. |
566 | 566 | */ |
567 | - public function validate_version_number( $version ) { |
|
567 | + public function validate_version_number($version) { |
|
568 | 568 | |
569 | - if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) { |
|
569 | + if (version_compare($version, '0.0.1', '>=') >= 0) { |
|
570 | 570 | // valid |
571 | 571 | } else { |
572 | - $version = '';// not validated |
|
572 | + $version = ''; // not validated |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | return $version; |
@@ -584,27 +584,27 @@ discard block |
||
584 | 584 | * @since 1.0.7 |
585 | 585 | * @return mixed|string The latest version number found. |
586 | 586 | */ |
587 | - public function get_latest_version( $force_api = false ) { |
|
587 | + public function get_latest_version($force_api = false) { |
|
588 | 588 | $latest_version = $this->latest; |
589 | 589 | |
590 | - $cache = get_transient( 'wp-font-awesome-settings-version' ); |
|
590 | + $cache = get_transient('wp-font-awesome-settings-version'); |
|
591 | 591 | |
592 | - if ( $cache === false || $force_api ) { // its not set |
|
592 | + if ($cache === false || $force_api) { // its not set |
|
593 | 593 | $api_ver = $this->get_latest_version_from_api(); |
594 | - if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) { |
|
594 | + if (version_compare($api_ver, $this->latest, '>=') >= 0) { |
|
595 | 595 | $latest_version = $api_ver; |
596 | - set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS ); |
|
596 | + set_transient('wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS); |
|
597 | 597 | } |
598 | - } elseif ( $this->validate_version_number( $cache ) ) { |
|
599 | - if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) { |
|
598 | + } elseif ($this->validate_version_number($cache)) { |
|
599 | + if (version_compare($cache, $this->latest, '>=') >= 0) { |
|
600 | 600 | $latest_version = $cache; |
601 | 601 | } |
602 | 602 | } |
603 | 603 | |
604 | 604 | // Check and auto download fonts locally. |
605 | - if ( empty( $this->settings['pro'] ) && empty( $this->settings['version'] ) && $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && ! empty( $this->settings['local_version'] ) && ! empty( $latest_version ) ) { |
|
606 | - if ( version_compare( $latest_version, $this->settings['local_version'], '>' ) && is_admin() && ! wp_doing_ajax() ) { |
|
607 | - $this->download_package( $latest_version ); |
|
605 | + if (empty($this->settings['pro']) && empty($this->settings['version']) && $this->settings['type'] != 'KIT' && !empty($this->settings['local']) && !empty($this->settings['local_version']) && !empty($latest_version)) { |
|
606 | + if (version_compare($latest_version, $this->settings['local_version'], '>') && is_admin() && !wp_doing_ajax()) { |
|
607 | + $this->download_package($latest_version); |
|
608 | 608 | } |
609 | 609 | } |
610 | 610 | |
@@ -619,10 +619,10 @@ discard block |
||
619 | 619 | */ |
620 | 620 | public function get_latest_version_from_api() { |
621 | 621 | $version = "0"; |
622 | - $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" ); |
|
623 | - if ( ! is_wp_error( $response ) && is_array( $response ) ) { |
|
624 | - $api_response = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
625 | - if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) { |
|
622 | + $response = wp_remote_get("https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest"); |
|
623 | + if (!is_wp_error($response) && is_array($response)) { |
|
624 | + $api_response = json_decode(wp_remote_retrieve_body($response), true); |
|
625 | + if (isset($api_response['tag_name']) && version_compare($api_response['tag_name'], $this->latest, '>=') >= 0 && empty($api_response['prerelease'])) { |
|
626 | 626 | $version = $api_response['tag_name']; |
627 | 627 | } |
628 | 628 | } |
@@ -650,21 +650,21 @@ discard block |
||
650 | 650 | public function admin_notices() { |
651 | 651 | $settings = $this->settings; |
652 | 652 | |
653 | - if ( defined( 'FONTAWESOME_PLUGIN_FILE' ) ) { |
|
654 | - if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wp-font-awesome-settings' ) { |
|
653 | + if (defined('FONTAWESOME_PLUGIN_FILE')) { |
|
654 | + if (!empty($_REQUEST['page']) && $_REQUEST['page'] == 'wp-font-awesome-settings') { |
|
655 | 655 | ?> |
656 | 656 | <div class="notice notice-error is-dismissible"> |
657 | - <p><?php _e( 'The Official Font Awesome Plugin is active, please adjust your settings there.', 'font-awesome-settings' ); ?></p> |
|
657 | + <p><?php _e('The Official Font Awesome Plugin is active, please adjust your settings there.', 'font-awesome-settings'); ?></p> |
|
658 | 658 | </div> |
659 | 659 | <?php |
660 | 660 | } |
661 | 661 | } else { |
662 | - if ( ! empty( $settings ) ) { |
|
663 | - if ( $settings['type'] != 'KIT' && $settings['pro'] && ( $settings['version'] == '' || version_compare( $settings['version'], '6', '>=' ) ) ) { |
|
662 | + if (!empty($settings)) { |
|
663 | + if ($settings['type'] != 'KIT' && $settings['pro'] && ($settings['version'] == '' || version_compare($settings['version'], '6', '>='))) { |
|
664 | 664 | $link = admin_url('options-general.php?page=wp-font-awesome-settings'); |
665 | 665 | ?> |
666 | 666 | <div class="notice notice-error is-dismissible"> |
667 | - <p><?php echo sprintf( __( 'Font Awesome Pro v6 requires the use of a kit, please setup your kit in %ssettings.%s', 'font-awesome-settings' ),"<a href='". esc_url_raw( $link )."'>","</a>" ); ?></p> |
|
667 | + <p><?php echo sprintf(__('Font Awesome Pro v6 requires the use of a kit, please setup your kit in %ssettings.%s', 'font-awesome-settings'), "<a href='" . esc_url_raw($link) . "'>", "</a>"); ?></p> |
|
668 | 668 | </div> |
669 | 669 | <?php |
670 | 670 | } |
@@ -680,20 +680,20 @@ discard block |
||
680 | 680 | * @param string $option The option name. |
681 | 681 | * @param mixed $value The option value. |
682 | 682 | */ |
683 | - public function add_option_wp_font_awesome_settings( $option, $value ) { |
|
683 | + public function add_option_wp_font_awesome_settings($option, $value) { |
|
684 | 684 | // Do nothing if WordPress is being installed. |
685 | - if ( wp_installing() ) { |
|
685 | + if (wp_installing()) { |
|
686 | 686 | return; |
687 | 687 | } |
688 | 688 | |
689 | - if ( ! empty( $value['local'] ) && empty( $value['pro'] ) && ! ( ! empty( $value['type'] ) && $value['type'] == 'KIT' ) ) { |
|
690 | - $version = isset( $value['version'] ) && $value['version'] ? $value['version'] : $this->get_latest_version(); |
|
689 | + if (!empty($value['local']) && empty($value['pro']) && !(!empty($value['type']) && $value['type'] == 'KIT')) { |
|
690 | + $version = isset($value['version']) && $value['version'] ? $value['version'] : $this->get_latest_version(); |
|
691 | 691 | |
692 | - if ( ! empty( $version ) ) { |
|
693 | - $response = $this->download_package( $version, $value ); |
|
692 | + if (!empty($version)) { |
|
693 | + $response = $this->download_package($version, $value); |
|
694 | 694 | |
695 | - if ( is_wp_error( $response ) ) { |
|
696 | - add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'font-awesome-settings' ) . ' ' . $response->get_error_message(), 'error' ); |
|
695 | + if (is_wp_error($response)) { |
|
696 | + add_settings_error('general', 'fontawesome_download', __('ERROR:', 'font-awesome-settings') . ' ' . $response->get_error_message(), 'error'); |
|
697 | 697 | } |
698 | 698 | } |
699 | 699 | } |
@@ -707,25 +707,25 @@ discard block |
||
707 | 707 | * @param mixed $old_value The old option value. |
708 | 708 | * @param mixed $value The new option value. |
709 | 709 | */ |
710 | - public function update_option_wp_font_awesome_settings( $old_value, $new_value ) { |
|
710 | + public function update_option_wp_font_awesome_settings($old_value, $new_value) { |
|
711 | 711 | // Do nothing if WordPress is being installed. |
712 | - if ( wp_installing() ) { |
|
712 | + if (wp_installing()) { |
|
713 | 713 | return; |
714 | 714 | } |
715 | 715 | |
716 | - if ( ! empty( $new_value['local'] ) && empty( $new_value['pro'] ) && ! ( ! empty( $new_value['type'] ) && $new_value['type'] == 'KIT' ) ) { |
|
716 | + if (!empty($new_value['local']) && empty($new_value['pro']) && !(!empty($new_value['type']) && $new_value['type'] == 'KIT')) { |
|
717 | 717 | // Old values |
718 | - $old_version = isset( $old_value['version'] ) && $old_value['version'] ? $old_value['version'] : ( isset( $old_value['local_version'] ) ? $old_value['local_version'] : '' ); |
|
719 | - $old_local = isset( $old_value['local'] ) ? (int) $old_value['local'] : 0; |
|
718 | + $old_version = isset($old_value['version']) && $old_value['version'] ? $old_value['version'] : (isset($old_value['local_version']) ? $old_value['local_version'] : ''); |
|
719 | + $old_local = isset($old_value['local']) ? (int) $old_value['local'] : 0; |
|
720 | 720 | |
721 | 721 | // New values |
722 | - $new_version = isset( $new_value['version'] ) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version(); |
|
722 | + $new_version = isset($new_value['version']) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version(); |
|
723 | 723 | |
724 | - if ( empty( $old_local ) || $old_version !== $new_version || ! file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) { |
|
725 | - $response = $this->download_package( $new_version, $new_value ); |
|
724 | + if (empty($old_local) || $old_version !== $new_version || !file_exists($this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css')) { |
|
725 | + $response = $this->download_package($new_version, $new_value); |
|
726 | 726 | |
727 | - if ( is_wp_error( $response ) ) { |
|
728 | - add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'font-awesome-settings' ) . ' ' . $response->get_error_message(), 'error' ); |
|
727 | + if (is_wp_error($response)) { |
|
728 | + add_settings_error('general', 'fontawesome_download', __('ERROR:', 'font-awesome-settings') . ' ' . $response->get_error_message(), 'error'); |
|
729 | 729 | } |
730 | 730 | } |
731 | 731 | } |
@@ -739,9 +739,9 @@ discard block |
||
739 | 739 | * @param string Fonts directory local path. |
740 | 740 | */ |
741 | 741 | public function get_fonts_dir() { |
742 | - $upload_dir = wp_upload_dir( null, false ); |
|
742 | + $upload_dir = wp_upload_dir(null, false); |
|
743 | 743 | |
744 | - return $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR; |
|
744 | + return $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR; |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | /** |
@@ -752,9 +752,9 @@ discard block |
||
752 | 752 | * @param string Fonts directory local url. |
753 | 753 | */ |
754 | 754 | public function get_fonts_url() { |
755 | - $upload_dir = wp_upload_dir( null, false ); |
|
755 | + $upload_dir = wp_upload_dir(null, false); |
|
756 | 756 | |
757 | - return $upload_dir['baseurl'] . '/ayefonts/fa/'; |
|
757 | + return $upload_dir['baseurl'] . '/ayefonts/fa/'; |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | /** |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | * @return bool True if active else false. |
766 | 766 | */ |
767 | 767 | public function has_local() { |
768 | - if ( ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) && file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) { |
|
768 | + if (!empty($this->settings['local']) && empty($this->settings['pro']) && file_exists($this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css')) { |
|
769 | 769 | return true; |
770 | 770 | } |
771 | 771 | |
@@ -780,18 +780,18 @@ discard block |
||
780 | 780 | * @return object The WP Filesystem. |
781 | 781 | */ |
782 | 782 | public function get_wp_filesystem() { |
783 | - if ( ! function_exists( 'get_filesystem_method' ) ) { |
|
784 | - require_once( ABSPATH . "/wp-admin/includes/file.php" ); |
|
783 | + if (!function_exists('get_filesystem_method')) { |
|
784 | + require_once(ABSPATH . "/wp-admin/includes/file.php"); |
|
785 | 785 | } |
786 | 786 | |
787 | 787 | $access_type = get_filesystem_method(); |
788 | 788 | |
789 | - if ( $access_type === 'direct' ) { |
|
789 | + if ($access_type === 'direct') { |
|
790 | 790 | /* You can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
791 | - $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() ); |
|
791 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
792 | 792 | |
793 | 793 | /* Initialize the API */ |
794 | - if ( ! WP_Filesystem( $creds ) ) { |
|
794 | + if (!WP_Filesystem($creds)) { |
|
795 | 795 | /* Any problems and we exit */ |
796 | 796 | return false; |
797 | 797 | } |
@@ -800,11 +800,11 @@ discard block |
||
800 | 800 | |
801 | 801 | return $wp_filesystem; |
802 | 802 | /* Do our file manipulations below */ |
803 | - } else if ( defined( 'FTP_USER' ) ) { |
|
804 | - $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() ); |
|
803 | + } else if (defined('FTP_USER')) { |
|
804 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
805 | 805 | |
806 | 806 | /* Initialize the API */ |
807 | - if ( ! WP_Filesystem( $creds ) ) { |
|
807 | + if (!WP_Filesystem($creds)) { |
|
808 | 808 | /* Any problems and we exit */ |
809 | 809 | return false; |
810 | 810 | } |
@@ -827,38 +827,38 @@ discard block |
||
827 | 827 | * @param array $option Fontawesome settings. |
828 | 828 | * @return WP_ERROR|bool Error on fail and true on success. |
829 | 829 | */ |
830 | - public function download_package( $version, $option = array() ) { |
|
830 | + public function download_package($version, $option = array()) { |
|
831 | 831 | $filename = 'fontawesome-free-' . $version . '-web'; |
832 | 832 | $url = 'https://use.fontawesome.com/releases/v' . $version . '/' . $filename . '.zip'; |
833 | 833 | |
834 | - if ( ! function_exists( 'wp_handle_upload' ) ) { |
|
834 | + if (!function_exists('wp_handle_upload')) { |
|
835 | 835 | require_once ABSPATH . 'wp-admin/includes/file.php'; |
836 | 836 | } |
837 | 837 | |
838 | - $download_file = download_url( esc_url_raw( $url ) ); |
|
838 | + $download_file = download_url(esc_url_raw($url)); |
|
839 | 839 | |
840 | - if ( is_wp_error( $download_file ) ) { |
|
841 | - return new WP_Error( 'fontawesome_download_failed', __( $download_file->get_error_message(), 'font-awesome-settings' ) ); |
|
842 | - } else if ( empty( $download_file ) ) { |
|
843 | - return new WP_Error( 'fontawesome_download_failed', __( 'Something went wrong in downloading the font awesome to store locally.', 'font-awesome-settings' ) ); |
|
840 | + if (is_wp_error($download_file)) { |
|
841 | + return new WP_Error('fontawesome_download_failed', __($download_file->get_error_message(), 'font-awesome-settings')); |
|
842 | + } else if (empty($download_file)) { |
|
843 | + return new WP_Error('fontawesome_download_failed', __('Something went wrong in downloading the font awesome to store locally.', 'font-awesome-settings')); |
|
844 | 844 | } |
845 | 845 | |
846 | - $response = $this->extract_package( $download_file, $filename, true ); |
|
846 | + $response = $this->extract_package($download_file, $filename, true); |
|
847 | 847 | |
848 | 848 | // Update local version. |
849 | - if ( is_wp_error( $response ) ) { |
|
849 | + if (is_wp_error($response)) { |
|
850 | 850 | return $response; |
851 | - } else if ( $response ) { |
|
852 | - if ( empty( $option ) ) { |
|
853 | - $option = get_option( 'wp-font-awesome-settings' ); |
|
851 | + } else if ($response) { |
|
852 | + if (empty($option)) { |
|
853 | + $option = get_option('wp-font-awesome-settings'); |
|
854 | 854 | } |
855 | 855 | |
856 | 856 | $option['local_version'] = $version; |
857 | 857 | |
858 | 858 | // Remove action to prevent looping. |
859 | - remove_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 ); |
|
859 | + remove_action('update_option_wp-font-awesome-settings', array($this, 'update_option_wp_font_awesome_settings'), 10, 2); |
|
860 | 860 | |
861 | - update_option( 'wp-font-awesome-settings', $option ); |
|
861 | + update_option('wp-font-awesome-settings', $option); |
|
862 | 862 | |
863 | 863 | return true; |
864 | 864 | } |
@@ -876,60 +876,60 @@ discard block |
||
876 | 876 | * @param bool $delete_package Delete temp file or not. |
877 | 877 | * @return WP_Error|bool True on success WP_Error on fail. |
878 | 878 | */ |
879 | - public function extract_package( $package, $dirname = '', $delete_package = false ) { |
|
879 | + public function extract_package($package, $dirname = '', $delete_package = false) { |
|
880 | 880 | global $wp_filesystem; |
881 | 881 | |
882 | 882 | $wp_filesystem = $this->get_wp_filesystem(); |
883 | 883 | |
884 | - if ( empty( $wp_filesystem ) && isset( $wp_filesystem->errors ) && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) { |
|
885 | - return new WP_Error( 'fontawesome_filesystem_error', __( $wp_filesystem->errors->get_error_message(), 'font-awesome-settings' ) ); |
|
886 | - } else if ( empty( $wp_filesystem ) ) { |
|
887 | - return new WP_Error( 'fontawesome_filesystem_error', __( 'Failed to initialise WP_Filesystem while trying to download the Font Awesome package.', 'font-awesome-settings' ) ); |
|
884 | + if (empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) { |
|
885 | + return new WP_Error('fontawesome_filesystem_error', __($wp_filesystem->errors->get_error_message(), 'font-awesome-settings')); |
|
886 | + } else if (empty($wp_filesystem)) { |
|
887 | + return new WP_Error('fontawesome_filesystem_error', __('Failed to initialise WP_Filesystem while trying to download the Font Awesome package.', 'font-awesome-settings')); |
|
888 | 888 | } |
889 | 889 | |
890 | 890 | $fonts_dir = $this->get_fonts_dir(); |
891 | - $fonts_tmp_dir = dirname( $fonts_dir ) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR; |
|
891 | + $fonts_tmp_dir = dirname($fonts_dir) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR; |
|
892 | 892 | |
893 | - if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) { |
|
894 | - $wp_filesystem->delete( $fonts_tmp_dir, true ); |
|
893 | + if ($wp_filesystem->is_dir($fonts_tmp_dir)) { |
|
894 | + $wp_filesystem->delete($fonts_tmp_dir, true); |
|
895 | 895 | } |
896 | 896 | |
897 | 897 | // Unzip package to working directory. |
898 | - $result = unzip_file( $package, $fonts_tmp_dir ); |
|
898 | + $result = unzip_file($package, $fonts_tmp_dir); |
|
899 | 899 | |
900 | - if ( is_wp_error( $result ) ) { |
|
901 | - $wp_filesystem->delete( $fonts_tmp_dir, true ); |
|
900 | + if (is_wp_error($result)) { |
|
901 | + $wp_filesystem->delete($fonts_tmp_dir, true); |
|
902 | 902 | |
903 | - if ( 'incompatible_archive' === $result->get_error_code() ) { |
|
904 | - return new WP_Error( 'fontawesome_incompatible_archive', __( $result->get_error_message(), 'font-awesome-settings' ) ); |
|
903 | + if ('incompatible_archive' === $result->get_error_code()) { |
|
904 | + return new WP_Error('fontawesome_incompatible_archive', __($result->get_error_message(), 'font-awesome-settings')); |
|
905 | 905 | } |
906 | 906 | |
907 | 907 | return $result; |
908 | 908 | } |
909 | 909 | |
910 | - if ( $wp_filesystem->is_dir( $fonts_dir ) ) { |
|
911 | - $wp_filesystem->delete( $fonts_dir, true ); |
|
910 | + if ($wp_filesystem->is_dir($fonts_dir)) { |
|
911 | + $wp_filesystem->delete($fonts_dir, true); |
|
912 | 912 | } |
913 | 913 | |
914 | 914 | $extract_dir = $fonts_tmp_dir; |
915 | 915 | |
916 | - if ( $dirname && $wp_filesystem->is_dir( $extract_dir . $dirname . DIRECTORY_SEPARATOR ) ) { |
|
916 | + if ($dirname && $wp_filesystem->is_dir($extract_dir . $dirname . DIRECTORY_SEPARATOR)) { |
|
917 | 917 | $extract_dir .= $dirname . DIRECTORY_SEPARATOR; |
918 | 918 | } |
919 | 919 | |
920 | 920 | try { |
921 | - $return = $wp_filesystem->move( $extract_dir, $fonts_dir, true ); |
|
922 | - } catch ( Exception $e ) { |
|
923 | - $return = new WP_Error( 'fontawesome_move_package', __( 'Fail to move font awesome package!', 'font-awesome-settings' ) ); |
|
921 | + $return = $wp_filesystem->move($extract_dir, $fonts_dir, true); |
|
922 | + } catch (Exception $e) { |
|
923 | + $return = new WP_Error('fontawesome_move_package', __('Fail to move font awesome package!', 'font-awesome-settings')); |
|
924 | 924 | } |
925 | 925 | |
926 | - if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) { |
|
927 | - $wp_filesystem->delete( $fonts_tmp_dir, true ); |
|
926 | + if ($wp_filesystem->is_dir($fonts_tmp_dir)) { |
|
927 | + $wp_filesystem->delete($fonts_tmp_dir, true); |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | // Once extracted, delete the package if required. |
931 | - if ( $delete_package ) { |
|
932 | - unlink( $package ); |
|
931 | + if ($delete_package) { |
|
932 | + unlink($package); |
|
933 | 933 | } |
934 | 934 | |
935 | 935 | return $return; |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @param null|string|array $query Optional. The query variables. |
99 | 99 | */ |
100 | - public function __construct( $query = null ) { |
|
101 | - if ( ! is_null( $query ) ) { |
|
102 | - $this->prepare_query( $query ); |
|
100 | + public function __construct($query = null) { |
|
101 | + if (!is_null($query)) { |
|
102 | + $this->prepare_query($query); |
|
103 | 103 | $this->query(); |
104 | 104 | } |
105 | 105 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @param string|array $args Query vars, as passed to `GetPaid_Subscriptions_Query`. |
113 | 113 | * @return array Complete query variables with undefined ones filled in with defaults. |
114 | 114 | */ |
115 | - public static function fill_query_vars( $args ) { |
|
115 | + public static function fill_query_vars($args) { |
|
116 | 116 | $defaults = array( |
117 | 117 | 'status' => 'all', |
118 | 118 | 'customer_in' => array(), |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | 'fields' => 'all', |
131 | 131 | ); |
132 | 132 | |
133 | - return wp_parse_args( $args, $defaults ); |
|
133 | + return wp_parse_args($args, $defaults); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -182,45 +182,45 @@ discard block |
||
182 | 182 | * Use 'all' for all fields. Default 'all'. |
183 | 183 | * } |
184 | 184 | */ |
185 | - public function prepare_query( $query = array() ) { |
|
185 | + public function prepare_query($query = array()) { |
|
186 | 186 | global $wpdb; |
187 | 187 | |
188 | - if ( empty( $this->query_vars ) || ! empty( $query ) ) { |
|
188 | + if (empty($this->query_vars) || !empty($query)) { |
|
189 | 189 | $this->query_limit = null; |
190 | - $this->query_vars = $this->fill_query_vars( $query ); |
|
190 | + $this->query_vars = $this->fill_query_vars($query); |
|
191 | 191 | } |
192 | 192 | |
193 | - if ( ! empty( $this->query_vars['fields'] ) && 'all' !== $this->query_vars['fields'] ) { |
|
194 | - $this->query_vars['fields'] = wpinv_parse_list( $this->query_vars['fields'] ); |
|
193 | + if (!empty($this->query_vars['fields']) && 'all' !== $this->query_vars['fields']) { |
|
194 | + $this->query_vars['fields'] = wpinv_parse_list($this->query_vars['fields']); |
|
195 | 195 | } |
196 | 196 | |
197 | - do_action( 'getpaid_pre_get_subscriptions', array( &$this ) ); |
|
197 | + do_action('getpaid_pre_get_subscriptions', array(&$this)); |
|
198 | 198 | |
199 | 199 | // Ensure that query vars are filled after 'getpaid_pre_get_subscriptions'. |
200 | - $qv =& $this->query_vars; |
|
201 | - $qv = $this->fill_query_vars( $qv ); |
|
200 | + $qv = & $this->query_vars; |
|
201 | + $qv = $this->fill_query_vars($qv); |
|
202 | 202 | $table = $wpdb->prefix . 'wpinv_subscriptions'; |
203 | 203 | $this->query_from = "FROM $table"; |
204 | 204 | |
205 | 205 | // Prepare query fields. |
206 | - $this->prepare_query_fields( $qv, $table ); |
|
206 | + $this->prepare_query_fields($qv, $table); |
|
207 | 207 | |
208 | 208 | // Prepare query where. |
209 | - $this->prepare_query_where( $qv, $table ); |
|
209 | + $this->prepare_query_where($qv, $table); |
|
210 | 210 | |
211 | 211 | // Prepare query order. |
212 | - $this->prepare_query_order( $qv, $table ); |
|
212 | + $this->prepare_query_order($qv, $table); |
|
213 | 213 | |
214 | 214 | // limit |
215 | - if ( isset( $qv['number'] ) && $qv['number'] > 0 ) { |
|
216 | - if ( $qv['offset'] ) { |
|
217 | - $this->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['offset'], $qv['number'] ); |
|
215 | + if (isset($qv['number']) && $qv['number'] > 0) { |
|
216 | + if ($qv['offset']) { |
|
217 | + $this->query_limit = $wpdb->prepare('LIMIT %d, %d', $qv['offset'], $qv['number']); |
|
218 | 218 | } else { |
219 | - $this->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['number'] * ( $qv['paged'] - 1 ), $qv['number'] ); |
|
219 | + $this->query_limit = $wpdb->prepare('LIMIT %d, %d', $qv['number'] * ($qv['paged'] - 1), $qv['number']); |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | - do_action_ref_array( 'getpaid_after_subscriptions_query', array( &$this ) ); |
|
223 | + do_action_ref_array('getpaid_after_subscriptions_query', array(&$this)); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -231,22 +231,22 @@ discard block |
||
231 | 231 | * @param array $qv Query vars. |
232 | 232 | * @param string $table Table name. |
233 | 233 | */ |
234 | - protected function prepare_query_fields( &$qv, $table ) { |
|
234 | + protected function prepare_query_fields(&$qv, $table) { |
|
235 | 235 | |
236 | - if ( is_array( $qv['fields'] ) ) { |
|
237 | - $qv['fields'] = array_unique( $qv['fields'] ); |
|
236 | + if (is_array($qv['fields'])) { |
|
237 | + $qv['fields'] = array_unique($qv['fields']); |
|
238 | 238 | |
239 | 239 | $query_fields = array(); |
240 | - foreach ( $qv['fields'] as $field ) { |
|
241 | - $field = sanitize_key( $field ); |
|
240 | + foreach ($qv['fields'] as $field) { |
|
241 | + $field = sanitize_key($field); |
|
242 | 242 | $query_fields[] = "$table.`$field`"; |
243 | 243 | } |
244 | - $this->query_fields = implode( ',', $query_fields ); |
|
244 | + $this->query_fields = implode(',', $query_fields); |
|
245 | 245 | } else { |
246 | 246 | $this->query_fields = "$table.*"; |
247 | 247 | } |
248 | 248 | |
249 | - if ( isset( $qv['count_total'] ) && $qv['count_total'] ) { |
|
249 | + if (isset($qv['count_total']) && $qv['count_total']) { |
|
250 | 250 | $this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields; |
251 | 251 | } |
252 | 252 | |
@@ -260,58 +260,58 @@ discard block |
||
260 | 260 | * @param array $qv Query vars. |
261 | 261 | * @param string $table Table name. |
262 | 262 | */ |
263 | - protected function prepare_query_where( &$qv, $table ) { |
|
263 | + protected function prepare_query_where(&$qv, $table) { |
|
264 | 264 | global $wpdb; |
265 | 265 | $this->query_where = 'WHERE 1=1'; |
266 | 266 | |
267 | 267 | // Status. |
268 | - if ( 'all' !== $qv['status'] ) { |
|
269 | - $statuses = wpinv_clean( wpinv_parse_list( $qv['status'] ) ); |
|
270 | - $prepared_statuses = join( ',', array_fill( 0, count( $statuses ), '%s' ) ); |
|
271 | - $this->query_where .= $wpdb->prepare( " AND $table.`status` IN ( $prepared_statuses )", $statuses ); |
|
268 | + if ('all' !== $qv['status']) { |
|
269 | + $statuses = wpinv_clean(wpinv_parse_list($qv['status'])); |
|
270 | + $prepared_statuses = join(',', array_fill(0, count($statuses), '%s')); |
|
271 | + $this->query_where .= $wpdb->prepare(" AND $table.`status` IN ( $prepared_statuses )", $statuses); |
|
272 | 272 | } |
273 | 273 | |
274 | - if ( ! empty( $qv['customer_in'] ) ) { |
|
275 | - $customer_in = implode( ',', wp_parse_id_list( $qv['customer_in'] ) ); |
|
274 | + if (!empty($qv['customer_in'])) { |
|
275 | + $customer_in = implode(',', wp_parse_id_list($qv['customer_in'])); |
|
276 | 276 | $this->query_where .= " AND $table.`customer_id` IN ($customer_in)"; |
277 | - } elseif ( ! empty( $qv['customer_not_in'] ) ) { |
|
278 | - $customer_not_in = implode( ',', wp_parse_id_list( $qv['customer_not_in'] ) ); |
|
277 | + } elseif (!empty($qv['customer_not_in'])) { |
|
278 | + $customer_not_in = implode(',', wp_parse_id_list($qv['customer_not_in'])); |
|
279 | 279 | $this->query_where .= " AND $table.`customer_id` NOT IN ($customer_not_in)"; |
280 | 280 | } |
281 | 281 | |
282 | - if ( ! empty( $qv['product_in'] ) ) { |
|
283 | - $product_in = implode( ',', wp_parse_id_list( $qv['product_in'] ) ); |
|
282 | + if (!empty($qv['product_in'])) { |
|
283 | + $product_in = implode(',', wp_parse_id_list($qv['product_in'])); |
|
284 | 284 | $this->query_where .= " AND $table.`product_id` IN ($product_in)"; |
285 | - } elseif ( ! empty( $qv['product_not_in'] ) ) { |
|
286 | - $product_not_in = implode( ',', wp_parse_id_list( $qv['product_not_in'] ) ); |
|
285 | + } elseif (!empty($qv['product_not_in'])) { |
|
286 | + $product_not_in = implode(',', wp_parse_id_list($qv['product_not_in'])); |
|
287 | 287 | $this->query_where .= " AND $table.`product_id` NOT IN ($product_not_in)"; |
288 | 288 | } |
289 | 289 | |
290 | - if ( ! empty( $qv['invoice_in'] ) ) { |
|
291 | - $invoice_in = implode( ',', wp_parse_id_list( $qv['invoice_in'] ) ); |
|
290 | + if (!empty($qv['invoice_in'])) { |
|
291 | + $invoice_in = implode(',', wp_parse_id_list($qv['invoice_in'])); |
|
292 | 292 | $this->query_where .= " AND $table.`parent_payment_id` IN ($invoice_in)"; |
293 | - } elseif ( ! empty( $qv['invoice_not_in'] ) ) { |
|
294 | - $invoice_not_in = implode( ',', wp_parse_id_list( $qv['invoice_not_in'] ) ); |
|
293 | + } elseif (!empty($qv['invoice_not_in'])) { |
|
294 | + $invoice_not_in = implode(',', wp_parse_id_list($qv['invoice_not_in'])); |
|
295 | 295 | $this->query_where .= " AND $table.`parent_payment_id` NOT IN ($invoice_not_in)"; |
296 | 296 | } |
297 | 297 | |
298 | - if ( ! empty( $qv['include'] ) ) { |
|
299 | - $include = implode( ',', wp_parse_id_list( $qv['include'] ) ); |
|
298 | + if (!empty($qv['include'])) { |
|
299 | + $include = implode(',', wp_parse_id_list($qv['include'])); |
|
300 | 300 | $this->query_where .= " AND $table.`id` IN ($include)"; |
301 | - } elseif ( ! empty( $qv['exclude'] ) ) { |
|
302 | - $exclude = implode( ',', wp_parse_id_list( $qv['exclude'] ) ); |
|
301 | + } elseif (!empty($qv['exclude'])) { |
|
302 | + $exclude = implode(',', wp_parse_id_list($qv['exclude'])); |
|
303 | 303 | $this->query_where .= " AND $table.`id` NOT IN ($exclude)"; |
304 | 304 | } |
305 | 305 | |
306 | 306 | // Date queries are allowed for the subscription creation date. |
307 | - if ( ! empty( $qv['date_created_query'] ) && is_array( $qv['date_created_query'] ) ) { |
|
308 | - $date_created_query = new WP_Date_Query( $qv['date_created_query'], "$table.created" ); |
|
307 | + if (!empty($qv['date_created_query']) && is_array($qv['date_created_query'])) { |
|
308 | + $date_created_query = new WP_Date_Query($qv['date_created_query'], "$table.created"); |
|
309 | 309 | $this->query_where .= $date_created_query->get_sql(); |
310 | 310 | } |
311 | 311 | |
312 | 312 | // Date queries are also allowed for the subscription expiration date. |
313 | - if ( ! empty( $qv['date_expires_query'] ) && is_array( $qv['date_expires_query'] ) ) { |
|
314 | - $date_expires_query = new WP_Date_Query( $qv['date_expires_query'], "$table.expiration" ); |
|
313 | + if (!empty($qv['date_expires_query']) && is_array($qv['date_expires_query'])) { |
|
314 | + $date_expires_query = new WP_Date_Query($qv['date_expires_query'], "$table.expiration"); |
|
315 | 315 | $this->query_where .= $date_expires_query->get_sql(); |
316 | 316 | } |
317 | 317 | |
@@ -325,24 +325,24 @@ discard block |
||
325 | 325 | * @param array $qv Query vars. |
326 | 326 | * @param string $table Table name. |
327 | 327 | */ |
328 | - protected function prepare_query_order( &$qv, $table ) { |
|
328 | + protected function prepare_query_order(&$qv, $table) { |
|
329 | 329 | |
330 | 330 | // sorting. |
331 | - $qv['order'] = isset( $qv['order'] ) ? strtoupper( $qv['order'] ) : ''; |
|
332 | - $order = $this->parse_order( $qv['order'] ); |
|
331 | + $qv['order'] = isset($qv['order']) ? strtoupper($qv['order']) : ''; |
|
332 | + $order = $this->parse_order($qv['order']); |
|
333 | 333 | |
334 | 334 | // Default order is by 'id' (latest subscriptions). |
335 | - if ( empty( $qv['orderby'] ) ) { |
|
336 | - $qv['orderby'] = array( 'id' ); |
|
335 | + if (empty($qv['orderby'])) { |
|
336 | + $qv['orderby'] = array('id'); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | // 'orderby' values may be an array, comma- or space-separated list. |
340 | - $ordersby = array_filter( wpinv_parse_list( $qv['orderby'] ) ); |
|
340 | + $ordersby = array_filter(wpinv_parse_list($qv['orderby'])); |
|
341 | 341 | |
342 | 342 | $orderby_array = array(); |
343 | - foreach ( $ordersby as $_key => $_value ) { |
|
343 | + foreach ($ordersby as $_key => $_value) { |
|
344 | 344 | |
345 | - if ( is_int( $_key ) ) { |
|
345 | + if (is_int($_key)) { |
|
346 | 346 | // Integer key means this is a flat array of 'orderby' fields. |
347 | 347 | $_orderby = $_value; |
348 | 348 | $_order = $order; |
@@ -352,19 +352,19 @@ discard block |
||
352 | 352 | $_order = $_value; |
353 | 353 | } |
354 | 354 | |
355 | - $parsed = $this->parse_orderby( $_orderby, $table ); |
|
355 | + $parsed = $this->parse_orderby($_orderby, $table); |
|
356 | 356 | |
357 | - if ( $parsed ) { |
|
358 | - $orderby_array[] = $parsed . ' ' . $this->parse_order( $_order ); |
|
357 | + if ($parsed) { |
|
358 | + $orderby_array[] = $parsed . ' ' . $this->parse_order($_order); |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
362 | 362 | // If no valid clauses were found, order by id. |
363 | - if ( empty( $orderby_array ) ) { |
|
363 | + if (empty($orderby_array)) { |
|
364 | 364 | $orderby_array[] = "id $order"; |
365 | 365 | } |
366 | 366 | |
367 | - $this->query_orderby = 'ORDER BY ' . implode( ', ', $orderby_array ); |
|
367 | + $this->query_orderby = 'ORDER BY ' . implode(', ', $orderby_array); |
|
368 | 368 | |
369 | 369 | } |
370 | 370 | |
@@ -378,34 +378,34 @@ discard block |
||
378 | 378 | public function query() { |
379 | 379 | global $wpdb; |
380 | 380 | |
381 | - $qv =& $this->query_vars; |
|
381 | + $qv = & $this->query_vars; |
|
382 | 382 | |
383 | 383 | // Return a non-null value to bypass the default GetPaid subscriptions query and remember to set the |
384 | 384 | // total_subscriptions property. |
385 | - $this->results = apply_filters_ref_array( 'getpaid_subscriptions_pre_query', array( null, &$this ) ); |
|
385 | + $this->results = apply_filters_ref_array('getpaid_subscriptions_pre_query', array(null, &$this)); |
|
386 | 386 | |
387 | - if ( null === $this->results ) { |
|
387 | + if (null === $this->results) { |
|
388 | 388 | $this->request = "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"; |
389 | 389 | |
390 | - if ( ( is_array( $qv['fields'] ) && 1 != count( $qv['fields'] ) ) || 'all' == $qv['fields'] ) { |
|
391 | - $this->results = $wpdb->get_results( $this->request ); |
|
390 | + if ((is_array($qv['fields']) && 1 != count($qv['fields'])) || 'all' == $qv['fields']) { |
|
391 | + $this->results = $wpdb->get_results($this->request); |
|
392 | 392 | } else { |
393 | - $this->results = $wpdb->get_col( $this->request ); |
|
393 | + $this->results = $wpdb->get_col($this->request); |
|
394 | 394 | } |
395 | 395 | |
396 | - if ( isset( $qv['count_total'] ) && $qv['count_total'] ) { |
|
397 | - $found_subscriptions_query = apply_filters( 'getpaid_found_subscriptions_query', 'SELECT FOUND_ROWS()', $this ); |
|
398 | - $this->total_subscriptions = (int) $wpdb->get_var( $found_subscriptions_query ); |
|
396 | + if (isset($qv['count_total']) && $qv['count_total']) { |
|
397 | + $found_subscriptions_query = apply_filters('getpaid_found_subscriptions_query', 'SELECT FOUND_ROWS()', $this); |
|
398 | + $this->total_subscriptions = (int) $wpdb->get_var($found_subscriptions_query); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
402 | - if ( 'all' == $qv['fields'] ) { |
|
403 | - foreach ( $this->results as $key => $subscription ) { |
|
404 | - $this->set_cache( $subscription->id, $subscription, 'getpaid_subscriptions' ); |
|
405 | - $this->set_cache( $subscription->profile_id, $subscription->id, 'getpaid_subscription_profile_ids_to_subscription_ids' ); |
|
406 | - $this->set_cache( $subscription->transaction_id, $subscription->id, 'getpaid_subscription_transaction_ids_to_subscription_ids' ); |
|
407 | - $this->set_cache( $subscription->transaction_id, $subscription->id, 'getpaid_subscription_transaction_ids_to_subscription_ids' ); |
|
408 | - $this->results[ $key ] = new WPInv_Subscription( $subscription ); |
|
402 | + if ('all' == $qv['fields']) { |
|
403 | + foreach ($this->results as $key => $subscription) { |
|
404 | + $this->set_cache($subscription->id, $subscription, 'getpaid_subscriptions'); |
|
405 | + $this->set_cache($subscription->profile_id, $subscription->id, 'getpaid_subscription_profile_ids_to_subscription_ids'); |
|
406 | + $this->set_cache($subscription->transaction_id, $subscription->id, 'getpaid_subscription_transaction_ids_to_subscription_ids'); |
|
407 | + $this->set_cache($subscription->transaction_id, $subscription->id, 'getpaid_subscription_transaction_ids_to_subscription_ids'); |
|
408 | + $this->results[$key] = new WPInv_Subscription($subscription); |
|
409 | 409 | } |
410 | 410 | } |
411 | 411 | |
@@ -420,13 +420,13 @@ discard block |
||
420 | 420 | * @param integer $expire |
421 | 421 | * @return boolean |
422 | 422 | */ |
423 | - public function set_cache( $key, $data, $group = '', $expire = 0 ) { |
|
423 | + public function set_cache($key, $data, $group = '', $expire = 0) { |
|
424 | 424 | |
425 | - if ( empty( $key ) ) { |
|
425 | + if (empty($key)) { |
|
426 | 426 | return false; |
427 | 427 | } |
428 | 428 | |
429 | - wp_cache_set( $key, $data, $group, $expire ); |
|
429 | + wp_cache_set($key, $data, $group, $expire); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | /** |
@@ -437,9 +437,9 @@ discard block |
||
437 | 437 | * @param string $query_var Query variable key. |
438 | 438 | * @return mixed |
439 | 439 | */ |
440 | - public function get( $query_var ) { |
|
441 | - if ( isset( $this->query_vars[ $query_var ] ) ) { |
|
442 | - return $this->query_vars[ $query_var ]; |
|
440 | + public function get($query_var) { |
|
441 | + if (isset($this->query_vars[$query_var])) { |
|
442 | + return $this->query_vars[$query_var]; |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | return null; |
@@ -453,8 +453,8 @@ discard block |
||
453 | 453 | * @param string $query_var Query variable key. |
454 | 454 | * @param mixed $value Query variable value. |
455 | 455 | */ |
456 | - public function set( $query_var, $value ) { |
|
457 | - $this->query_vars[ $query_var ] = $value; |
|
456 | + public function set($query_var, $value) { |
|
457 | + $this->query_vars[$query_var] = $value; |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | /** |
@@ -488,16 +488,16 @@ discard block |
||
488 | 488 | * @param string $table The current table. |
489 | 489 | * @return string Value to use in the ORDER clause, if `$orderby` is valid. |
490 | 490 | */ |
491 | - protected function parse_orderby( $orderby, $table ) { |
|
491 | + protected function parse_orderby($orderby, $table) { |
|
492 | 492 | |
493 | 493 | $_orderby = ''; |
494 | - if ( in_array( $orderby, array( 'customer_id', 'frequency', 'period', 'initial_amount', 'recurring_amount', 'bill_times', 'transaction_id', 'parent_payment_id', 'product_id', 'created', 'expiration', 'trial_period', 'status', 'profile_id' ) ) ) { |
|
494 | + if (in_array($orderby, array('customer_id', 'frequency', 'period', 'initial_amount', 'recurring_amount', 'bill_times', 'transaction_id', 'parent_payment_id', 'product_id', 'created', 'expiration', 'trial_period', 'status', 'profile_id'))) { |
|
495 | 495 | $_orderby = "$table.`$orderby`"; |
496 | - } elseif ( 'id' === strtolower( $orderby ) ) { |
|
496 | + } elseif ('id' === strtolower($orderby)) { |
|
497 | 497 | $_orderby = "$table.id"; |
498 | - } elseif ( 'include' === $orderby && ! empty( $this->query_vars['include'] ) ) { |
|
499 | - $include = wp_parse_id_list( $this->query_vars['include'] ); |
|
500 | - $include_sql = implode( ',', $include ); |
|
498 | + } elseif ('include' === $orderby && !empty($this->query_vars['include'])) { |
|
499 | + $include = wp_parse_id_list($this->query_vars['include']); |
|
500 | + $include_sql = implode(',', $include); |
|
501 | 501 | $_orderby = "FIELD( $table.id, $include_sql )"; |
502 | 502 | } |
503 | 503 | |
@@ -512,12 +512,12 @@ discard block |
||
512 | 512 | * @param string $order The 'order' query variable. |
513 | 513 | * @return string The sanitized 'order' query variable. |
514 | 514 | */ |
515 | - protected function parse_order( $order ) { |
|
516 | - if ( ! is_string( $order ) || empty( $order ) ) { |
|
515 | + protected function parse_order($order) { |
|
516 | + if (!is_string($order) || empty($order)) { |
|
517 | 517 | return 'DESC'; |
518 | 518 | } |
519 | 519 | |
520 | - if ( 'ASC' === strtoupper( $order ) ) { |
|
520 | + if ('ASC' === strtoupper($order)) { |
|
521 | 521 | return 'ASC'; |
522 | 522 | } else { |
523 | 523 | return 'DESC'; |
@@ -9,9 +9,9 @@ discard block |
||
9 | 9 | * @var array $fee |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) || exit; |
|
12 | +defined('ABSPATH') || exit; |
|
13 | 13 | |
14 | -do_action( 'getpaid_before_invoice_fee_item', $invoice, $fee ); |
|
14 | +do_action('getpaid_before_invoice_fee_item', $invoice, $fee); |
|
15 | 15 | |
16 | 16 | ?> |
17 | 17 | |
@@ -19,64 +19,64 @@ discard block |
||
19 | 19 | |
20 | 20 | <div class="form-row row"> |
21 | 21 | |
22 | - <?php foreach ( array_keys( $columns ) as $column ) : ?> |
|
22 | + <?php foreach (array_keys($columns) as $column) : ?> |
|
23 | 23 | |
24 | - <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm'; ?> getpaid-invoice-item-<?php echo esc_attr( $column ); ?>"> |
|
24 | + <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm'; ?> getpaid-invoice-item-<?php echo esc_attr($column); ?>"> |
|
25 | 25 | |
26 | 26 | <?php |
27 | 27 | |
28 | 28 | // Fires before printing a fee item column. |
29 | - do_action( "getpaid_invoice_fee_item_before_$column", $fee, $invoice ); |
|
29 | + do_action("getpaid_invoice_fee_item_before_$column", $fee, $invoice); |
|
30 | 30 | |
31 | 31 | // Item name. |
32 | - if ( 'name' == $column ) { |
|
32 | + if ('name' == $column) { |
|
33 | 33 | |
34 | 34 | // Display the name. |
35 | - echo '<div class="mb-1">' . esc_html( $fee['name'] ) . '</div>'; |
|
35 | + echo '<div class="mb-1">' . esc_html($fee['name']) . '</div>'; |
|
36 | 36 | |
37 | 37 | // And an optional description. |
38 | - $description = empty( $fee['description'] ) ? esc_html__( 'Fee', 'invoicing' ) : esc_html( $fee['description'] ); |
|
39 | - echo wp_kses_post( "<small class='form-text text-muted pr-2 m-0'>$description</small>" ); |
|
38 | + $description = empty($fee['description']) ? esc_html__('Fee', 'invoicing') : esc_html($fee['description']); |
|
39 | + echo wp_kses_post("<small class='form-text text-muted pr-2 m-0'>$description</small>"); |
|
40 | 40 | |
41 | 41 | } |
42 | 42 | |
43 | 43 | // Item price. |
44 | - if ( 'price' == $column ) { |
|
44 | + if ('price' == $column) { |
|
45 | 45 | |
46 | 46 | // Display the item price (or recurring price if this is a renewal invoice) |
47 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
48 | - wpinv_the_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
47 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
48 | + wpinv_the_price($fee['recurring_fee'], $invoice->get_currency()); |
|
49 | 49 | } else { |
50 | - wpinv_the_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
50 | + wpinv_the_price($fee['initial_fee'], $invoice->get_currency()); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | 54 | // Item quantity. |
55 | - if ( 'quantity' == $column ) { |
|
55 | + if ('quantity' == $column) { |
|
56 | 56 | echo '—'; |
57 | 57 | } |
58 | 58 | |
59 | 59 | // Item tax. |
60 | - if ( 'tax_rate' == $column ) { |
|
60 | + if ('tax_rate' == $column) { |
|
61 | 61 | echo '—'; |
62 | 62 | } |
63 | 63 | |
64 | 64 | // Item sub total. |
65 | - if ( 'subtotal' == $column ) { |
|
65 | + if ('subtotal' == $column) { |
|
66 | 66 | |
67 | 67 | // Display the item price (or recurring price if this is a renewal invoice) |
68 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
69 | - wpinv_the_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
68 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
69 | + wpinv_the_price($fee['recurring_fee'], $invoice->get_currency()); |
|
70 | 70 | } else { |
71 | - wpinv_the_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
71 | + wpinv_the_price($fee['initial_fee'], $invoice->get_currency()); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | 75 | // Fires when printing a fee item column. |
76 | - do_action( "getpaid_invoice_fee_item_$column", $fee, $invoice ); |
|
76 | + do_action("getpaid_invoice_fee_item_$column", $fee, $invoice); |
|
77 | 77 | |
78 | 78 | // Fires after printing a fee item column. |
79 | - do_action( "getpaid_invoice_fee_item_after_$column", $fee, $invoice ); |
|
79 | + do_action("getpaid_invoice_fee_item_after_$column", $fee, $invoice); |
|
80 | 80 | |
81 | 81 | ?> |
82 | 82 |