@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -57,32 +57,32 @@ discard block |
||
57 | 57 | |
58 | 58 | $args = array( |
59 | 59 | 'number' => $this->per_step, |
60 | - 'offset' => $this->per_step * ( $this->step - 1 ), |
|
60 | + 'offset' => $this->per_step * ($this->step - 1), |
|
61 | 61 | 'orderby' => 'id', |
62 | 62 | 'order' => 'DESC', |
63 | 63 | ); |
64 | 64 | |
65 | - $donors = Give()->donors->get_donors( $args ); |
|
65 | + $donors = Give()->donors->get_donors($args); |
|
66 | 66 | |
67 | - if ( $donors ) { |
|
67 | + if ($donors) { |
|
68 | 68 | |
69 | - $allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() ); |
|
69 | + $allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys()); |
|
70 | 70 | |
71 | - foreach ( $donors as $donor ) { |
|
71 | + foreach ($donors as $donor) { |
|
72 | 72 | |
73 | - $attached_payment_ids = explode( ',', $donor->payment_ids ); |
|
73 | + $attached_payment_ids = explode(',', $donor->payment_ids); |
|
74 | 74 | |
75 | 75 | $attached_args = array( |
76 | 76 | 'post__in' => $attached_payment_ids, |
77 | - 'number' => - 1, |
|
77 | + 'number' => -1, |
|
78 | 78 | 'status' => $allowed_payment_status, |
79 | 79 | ); |
80 | 80 | |
81 | - $attached_payments = (array) give_get_payments( $attached_args ); |
|
81 | + $attached_payments = (array) give_get_payments($attached_args); |
|
82 | 82 | |
83 | 83 | $unattached_args = array( |
84 | 84 | 'post__not_in' => $attached_payment_ids, |
85 | - 'number' => - 1, |
|
85 | + 'number' => -1, |
|
86 | 86 | 'status' => $allowed_payment_status, |
87 | 87 | 'meta_query' => array( |
88 | 88 | array( |
@@ -93,29 +93,29 @@ discard block |
||
93 | 93 | ), |
94 | 94 | ); |
95 | 95 | |
96 | - $unattached_payments = give_get_payments( $unattached_args ); |
|
96 | + $unattached_payments = give_get_payments($unattached_args); |
|
97 | 97 | |
98 | - $payments = array_merge( $attached_payments, $unattached_payments ); |
|
98 | + $payments = array_merge($attached_payments, $unattached_payments); |
|
99 | 99 | |
100 | 100 | $purchase_value = 0.00; |
101 | 101 | $purchase_count = 0; |
102 | 102 | $payment_ids = array(); |
103 | 103 | |
104 | - if ( $payments ) { |
|
104 | + if ($payments) { |
|
105 | 105 | |
106 | - foreach ( $payments as $payment ) { |
|
106 | + foreach ($payments as $payment) { |
|
107 | 107 | |
108 | 108 | $should_process_payment = 'publish' == $payment->post_status ? true : false; |
109 | - $should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment ); |
|
109 | + $should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment); |
|
110 | 110 | |
111 | - if ( true === $should_process_payment ) { |
|
111 | + if (true === $should_process_payment) { |
|
112 | 112 | |
113 | - if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) { |
|
114 | - $purchase_value += give_donation_amount( $payment->ID ); |
|
113 | + if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) { |
|
114 | + $purchase_value += give_donation_amount($payment->ID); |
|
115 | 115 | } |
116 | 116 | |
117 | - if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) { |
|
118 | - $purchase_count ++; |
|
117 | + if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) { |
|
118 | + $purchase_count++; |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - $payment_ids = implode( ',', $payment_ids ); |
|
126 | + $payment_ids = implode(',', $payment_ids); |
|
127 | 127 | |
128 | 128 | $donor_update_data = array( |
129 | 129 | 'purchase_count' => $purchase_count, |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | 'payment_ids' => $payment_ids, |
132 | 132 | ); |
133 | 133 | |
134 | - $donor_instance = new Give_Donor( $donor->id ); |
|
135 | - $donor_instance->update( $donor_update_data ); |
|
134 | + $donor_instance = new Give_Donor($donor->id); |
|
135 | + $donor_instance->update($donor_update_data); |
|
136 | 136 | |
137 | 137 | }// End foreach(). |
138 | 138 | |
@@ -152,21 +152,21 @@ discard block |
||
152 | 152 | public function get_percentage_complete() { |
153 | 153 | |
154 | 154 | $args = array( |
155 | - 'number' => - 1, |
|
155 | + 'number' => -1, |
|
156 | 156 | 'orderby' => 'id', |
157 | 157 | 'order' => 'DESC', |
158 | 158 | ); |
159 | 159 | |
160 | - $donors = Give()->donors->get_donors( $args ); |
|
161 | - $total = count( $donors ); |
|
160 | + $donors = Give()->donors->get_donors($args); |
|
161 | + $total = count($donors); |
|
162 | 162 | |
163 | 163 | $percentage = 100; |
164 | 164 | |
165 | - if ( $total > 0 ) { |
|
166 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
165 | + if ($total > 0) { |
|
166 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
167 | 167 | } |
168 | 168 | |
169 | - if ( $percentage > 100 ) { |
|
169 | + if ($percentage > 100) { |
|
170 | 170 | $percentage = 100; |
171 | 171 | } |
172 | 172 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @param array $request The Form Data passed into the batch processing |
182 | 182 | */ |
183 | - public function set_properties( $request ) { |
|
183 | + public function set_properties($request) { |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -191,21 +191,21 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function process_step() { |
193 | 193 | |
194 | - if ( ! $this->can_export() ) { |
|
195 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
194 | + if ( ! $this->can_export()) { |
|
195 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array( |
|
196 | 196 | 'response' => 403, |
197 | - ) ); |
|
197 | + )); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | $had_data = $this->get_data(); |
201 | 201 | |
202 | - if ( $had_data ) { |
|
202 | + if ($had_data) { |
|
203 | 203 | $this->done = false; |
204 | 204 | |
205 | 205 | return true; |
206 | 206 | } else { |
207 | 207 | $this->done = true; |
208 | - $this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' ); |
|
208 | + $this->message = esc_html__('Donor stats have been successfully recounted.', 'give'); |
|
209 | 209 | |
210 | 210 | return false; |
211 | 211 | } |
@@ -215,10 +215,10 @@ discard block |
||
215 | 215 | * Headers |
216 | 216 | */ |
217 | 217 | public function headers() { |
218 | - ignore_user_abort( true ); |
|
218 | + ignore_user_abort(true); |
|
219 | 219 | |
220 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
221 | - set_time_limit( 0 ); |
|
220 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
221 | + set_time_limit(0); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -109,32 +109,32 @@ discard block |
||
109 | 109 | $donor_ids = array(); |
110 | 110 | |
111 | 111 | // Check if the ajax request if running for the first time. |
112 | - if ( 1 === (int) $this->step ) { |
|
112 | + if (1 === (int) $this->step) { |
|
113 | 113 | // Delete all the donation ids. |
114 | - $this->delete_option( $this->donation_key ); |
|
114 | + $this->delete_option($this->donation_key); |
|
115 | 115 | // Delete all the donor ids. |
116 | - $this->delete_option( $this->donor_key ); |
|
116 | + $this->delete_option($this->donor_key); |
|
117 | 117 | |
118 | 118 | // Delete all the step and set to 'count' which if the first step in the process of deleting the donors. |
119 | - $this->update_option( $this->step_key, 'count' ); |
|
119 | + $this->update_option($this->step_key, 'count'); |
|
120 | 120 | |
121 | 121 | // Delete tha page count of the step. |
122 | - $this->update_option( $this->step_on_key, '0' ); |
|
122 | + $this->update_option($this->step_on_key, '0'); |
|
123 | 123 | } else { |
124 | 124 | // Get the old donors list. |
125 | - $donor_ids = $this->get_option( $this->donor_key ); |
|
125 | + $donor_ids = $this->get_option($this->donor_key); |
|
126 | 126 | |
127 | 127 | // Get the old donation list. |
128 | - $donation_ids = $this->get_option( $this->donation_key ); |
|
128 | + $donation_ids = $this->get_option($this->donation_key); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | // Get the step and check for it if it's on the first step( 'count' ) or not. |
132 | 132 | $step = (int) $this->get_step(); |
133 | - if ( 1 === $step ) { |
|
133 | + if (1 === $step) { |
|
134 | 134 | /** |
135 | 135 | * Will add or update the donation and donor data by running wp query. |
136 | 136 | */ |
137 | - $this->count( $step, $donation_ids, $donor_ids ); |
|
137 | + $this->count($step, $donation_ids, $donor_ids); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
@@ -145,17 +145,17 @@ discard block |
||
145 | 145 | * @param array $donation_ids Contain the list of all the donation id's that has being add before this |
146 | 146 | * @param array $donor_ids Contain the list of all the donors id's that has being add before this |
147 | 147 | */ |
148 | - private function count( $step, $donation_ids = array(), $donor_ids = array() ) { |
|
148 | + private function count($step, $donation_ids = array(), $donor_ids = array()) { |
|
149 | 149 | |
150 | 150 | // Get the Page count by default it's zero. |
151 | 151 | $paged = (int) $this->get_step_page(); |
152 | 152 | // Incresed the page count by one. |
153 | - ++ $paged; |
|
153 | + ++$paged; |
|
154 | 154 | |
155 | 155 | /** |
156 | 156 | * Filter add to alter the argument before the wp quest run |
157 | 157 | */ |
158 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
158 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
159 | 159 | 'post_type' => 'give_payment', |
160 | 160 | 'post_status' => 'any', |
161 | 161 | 'posts_per_page' => $this->per_step, |
@@ -163,16 +163,16 @@ discard block |
||
163 | 163 | // ONLY TEST MODE TRANSACTIONS!!! |
164 | 164 | 'meta_key' => '_give_payment_mode', |
165 | 165 | 'meta_value' => 'test', |
166 | - ) ); |
|
166 | + )); |
|
167 | 167 | |
168 | 168 | // Reset the post data. |
169 | 169 | wp_reset_postdata(); |
170 | 170 | // Getting the new donation. |
171 | - $donation_posts = new WP_Query( $args ); |
|
171 | + $donation_posts = new WP_Query($args); |
|
172 | 172 | |
173 | 173 | // The Loop. |
174 | - if ( $donation_posts->have_posts() ) { |
|
175 | - while ( $donation_posts->have_posts() ) { |
|
174 | + if ($donation_posts->have_posts()) { |
|
175 | + while ($donation_posts->have_posts()) { |
|
176 | 176 | $donation_posts->the_post(); |
177 | 177 | global $post; |
178 | 178 | // Add the donation id in side the array. |
@@ -191,23 +191,23 @@ discard block |
||
191 | 191 | $max_num_pages = (int) $donation_posts->max_num_pages; |
192 | 192 | |
193 | 193 | // Check current page is less then max number of page or not |
194 | - if ( $paged < $max_num_pages ) { |
|
194 | + if ($paged < $max_num_pages) { |
|
195 | 195 | // Update the curretn page virable for the next step |
196 | - $this->update_option( $this->step_on_key, $paged ); |
|
196 | + $this->update_option($this->step_on_key, $paged); |
|
197 | 197 | |
198 | 198 | // Calculating percentage. |
199 | 199 | $page_remain = $max_num_pages - $paged; |
200 | - $this->total_step = (int) $max_num_pages + ( $total_donation / $this->per_step ) + ( ( $page_remain * 2 ) * count( $donor_ids ) ); |
|
200 | + $this->total_step = (int) $max_num_pages + ($total_donation / $this->per_step) + (($page_remain * 2) * count($donor_ids)); |
|
201 | 201 | $this->step_completed = $paged; |
202 | 202 | } else { |
203 | - $donation_ids_count = count( $donor_ids ); |
|
204 | - $this->update_option( $this->step_key, 'donation' ); |
|
205 | - $this->update_option( $this->step_on_key, '0' ); |
|
203 | + $donation_ids_count = count($donor_ids); |
|
204 | + $this->update_option($this->step_key, 'donation'); |
|
205 | + $this->update_option($this->step_on_key, '0'); |
|
206 | 206 | } |
207 | 207 | |
208 | - $donor_ids = array_unique( $donor_ids ); |
|
209 | - $this->update_option( $this->donor_key, $donor_ids ); |
|
210 | - $this->update_option( $this->donation_key, $donation_ids ); |
|
208 | + $donor_ids = array_unique($donor_ids); |
|
209 | + $this->update_option($this->donor_key, $donor_ids); |
|
210 | + $this->update_option($this->donation_key, $donation_ids); |
|
211 | 211 | |
212 | 212 | wp_reset_postdata(); |
213 | 213 | } |
@@ -219,34 +219,34 @@ discard block |
||
219 | 219 | * @return int |
220 | 220 | */ |
221 | 221 | public function get_percentage_complete() { |
222 | - return ceil( ( 100 * $this->step_completed ) / $this->total_step ); |
|
222 | + return ceil((100 * $this->step_completed) / $this->total_step); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | public function process_step() { |
226 | 226 | |
227 | - if ( ! $this->can_export() ) { |
|
228 | - wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
227 | + if ( ! $this->can_export()) { |
|
228 | + wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | $had_data = $this->get_data(); |
232 | 232 | |
233 | - if ( $had_data ) { |
|
233 | + if ($had_data) { |
|
234 | 234 | $this->done = false; |
235 | 235 | |
236 | 236 | return true; |
237 | 237 | } else { |
238 | - update_option( 'give_earnings_total', give_get_total_earnings( true ) ); |
|
239 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
238 | + update_option('give_earnings_total', give_get_total_earnings(true)); |
|
239 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
240 | 240 | |
241 | - $this->delete_option( $this->donation_key ); |
|
241 | + $this->delete_option($this->donation_key); |
|
242 | 242 | |
243 | 243 | // Reset the sequential order numbers |
244 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
245 | - delete_option( 'give_last_payment_number' ); |
|
244 | + if (give_get_option('enable_sequential')) { |
|
245 | + delete_option('give_last_payment_number'); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | $this->done = true; |
249 | - $this->message = __( 'Test donor and transactions successfully deleted.', 'give' ); |
|
249 | + $this->message = __('Test donor and transactions successfully deleted.', 'give'); |
|
250 | 250 | |
251 | 251 | return false; |
252 | 252 | } |
@@ -264,12 +264,12 @@ discard block |
||
264 | 264 | public function get_data() { |
265 | 265 | |
266 | 266 | // Get the donation id's. |
267 | - $donation_ids = $this->get_option( $this->donation_key ); |
|
267 | + $donation_ids = $this->get_option($this->donation_key); |
|
268 | 268 | |
269 | 269 | /** |
270 | 270 | * Return false id not test donation is found. |
271 | 271 | */ |
272 | - if ( empty( $donation_ids ) ) { |
|
272 | + if (empty($donation_ids)) { |
|
273 | 273 | $this->is_empty = true; |
274 | 274 | $this->total_step = 1; |
275 | 275 | |
@@ -280,70 +280,70 @@ discard block |
||
280 | 280 | $step = (int) $this->get_step(); |
281 | 281 | |
282 | 282 | // get teh donor ids. |
283 | - $donor_ids = $this->get_option( $this->donor_key ); |
|
283 | + $donor_ids = $this->get_option($this->donor_key); |
|
284 | 284 | |
285 | 285 | // In step to we delete all the donation in loop. |
286 | - if ( 2 === $step ) { |
|
286 | + if (2 === $step) { |
|
287 | 287 | $pass_to_donor = false; |
288 | 288 | $page = (int) $this->get_step_page(); |
289 | - $page ++; |
|
290 | - $count = count( $donation_ids ); |
|
289 | + $page++; |
|
290 | + $count = count($donation_ids); |
|
291 | 291 | |
292 | - $this->total_step = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids ); |
|
292 | + $this->total_step = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids); |
|
293 | 293 | $this->step_completed = $page; |
294 | 294 | |
295 | 295 | |
296 | - if ( $count > $this->per_step ) { |
|
296 | + if ($count > $this->per_step) { |
|
297 | 297 | |
298 | - $this->update_option( $this->step_on_key, $page ); |
|
299 | - $donation_ids = $this->get_delete_ids( $donation_ids, $page ); |
|
300 | - $current_page = (int) ceil( $count / $this->per_step ); |
|
298 | + $this->update_option($this->step_on_key, $page); |
|
299 | + $donation_ids = $this->get_delete_ids($donation_ids, $page); |
|
300 | + $current_page = (int) ceil($count / $this->per_step); |
|
301 | 301 | |
302 | - if ( $page === $current_page ) { |
|
302 | + if ($page === $current_page) { |
|
303 | 303 | $pass_to_donor = true; |
304 | 304 | } |
305 | 305 | } else { |
306 | 306 | $pass_to_donor = true; |
307 | 307 | } |
308 | 308 | |
309 | - if ( true === $pass_to_donor ) { |
|
310 | - $this->update_option( $this->step_key, 'donor' ); |
|
311 | - $this->update_option( $this->step_on_key, '0' ); |
|
309 | + if (true === $pass_to_donor) { |
|
310 | + $this->update_option($this->step_key, 'donor'); |
|
311 | + $this->update_option($this->step_on_key, '0'); |
|
312 | 312 | } |
313 | 313 | |
314 | - foreach ( $donation_ids as $item ) { |
|
314 | + foreach ($donation_ids as $item) { |
|
315 | 315 | // Delete the main payment. |
316 | - give_delete_donation( absint( $item ) ); |
|
316 | + give_delete_donation(absint($item)); |
|
317 | 317 | } |
318 | - do_action( 'give_delete_log_cache' ); |
|
318 | + do_action('give_delete_log_cache'); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | |
322 | 322 | // Here we delete all the donor |
323 | - if ( 3 === $step ) { |
|
323 | + if (3 === $step) { |
|
324 | 324 | $page = (int) $this->get_step_page(); |
325 | - $count = count( $donor_ids ); |
|
325 | + $count = count($donor_ids); |
|
326 | 326 | |
327 | - $this->total_step = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids ); |
|
328 | - $this->step_completed = $page + ( count( $donation_ids ) / $this->per_step ); |
|
327 | + $this->total_step = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids); |
|
328 | + $this->step_completed = $page + (count($donation_ids) / $this->per_step); |
|
329 | 329 | |
330 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
330 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
331 | 331 | 'post_type' => 'give_payment', |
332 | 332 | 'post_status' => 'any', |
333 | 333 | 'posts_per_page' => 1, |
334 | 334 | 'meta_key' => '_give_payment_mode', |
335 | 335 | 'meta_value' => 'live', |
336 | - 'author' => $donor_ids[ $page ], |
|
337 | - ) ); |
|
336 | + 'author' => $donor_ids[$page], |
|
337 | + )); |
|
338 | 338 | |
339 | - $donation_posts = get_posts( $args ); |
|
340 | - if ( empty( $donation_posts ) ) { |
|
341 | - Give()->donors->delete_by_user_id( $donor_ids[ $page ] ); |
|
339 | + $donation_posts = get_posts($args); |
|
340 | + if (empty($donation_posts)) { |
|
341 | + Give()->donors->delete_by_user_id($donor_ids[$page]); |
|
342 | 342 | } |
343 | 343 | |
344 | - $page ++; |
|
345 | - $this->update_option( $this->step_on_key, $page ); |
|
346 | - if ( $count === $page ) { |
|
344 | + $page++; |
|
345 | + $this->update_option($this->step_on_key, $page); |
|
346 | + if ($count === $page) { |
|
347 | 347 | $this->is_empty = false; |
348 | 348 | |
349 | 349 | return false; |
@@ -355,24 +355,24 @@ discard block |
||
355 | 355 | return true; |
356 | 356 | } |
357 | 357 | |
358 | - public function get_delete_ids( $donation_ids, $page ) { |
|
359 | - $index = $page --; |
|
360 | - $count = count( $donation_ids ); |
|
358 | + public function get_delete_ids($donation_ids, $page) { |
|
359 | + $index = $page--; |
|
360 | + $count = count($donation_ids); |
|
361 | 361 | $temp = 0; |
362 | 362 | $current_page = 0; |
363 | 363 | $post_delete = $this->per_step; |
364 | 364 | $page_donation_id = array(); |
365 | 365 | |
366 | - foreach ( $donation_ids as $item ) { |
|
367 | - $temp ++; |
|
368 | - $page_donation_id[ $current_page ][] = $item; |
|
369 | - if ( $temp === $post_delete ) { |
|
370 | - $current_page ++; |
|
366 | + foreach ($donation_ids as $item) { |
|
367 | + $temp++; |
|
368 | + $page_donation_id[$current_page][] = $item; |
|
369 | + if ($temp === $post_delete) { |
|
370 | + $current_page++; |
|
371 | 371 | $temp = 0; |
372 | 372 | } |
373 | 373 | } |
374 | 374 | |
375 | - return $page_donation_id[ $page ]; |
|
375 | + return $page_donation_id[$page]; |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
@@ -384,8 +384,8 @@ discard block |
||
384 | 384 | * |
385 | 385 | * @return mixed Returns the data from the database |
386 | 386 | */ |
387 | - public function get_option( $key, $defalut_value = false ) { |
|
388 | - return get_option( $key, $defalut_value ); |
|
387 | + public function get_option($key, $defalut_value = false) { |
|
388 | + return get_option($key, $defalut_value); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
@@ -398,8 +398,8 @@ discard block |
||
398 | 398 | * |
399 | 399 | * @return void |
400 | 400 | */ |
401 | - public function update_option( $key, $value ) { |
|
402 | - update_option( $key, $value, false ); |
|
401 | + public function update_option($key, $value) { |
|
402 | + update_option($key, $value, false); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -411,8 +411,8 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @return void |
413 | 413 | */ |
414 | - public function delete_option( $key ) { |
|
415 | - delete_option( $key ); |
|
414 | + public function delete_option($key) { |
|
415 | + delete_option($key); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
@@ -423,12 +423,12 @@ discard block |
||
423 | 423 | * @return int|string |
424 | 424 | */ |
425 | 425 | private function get_step() { |
426 | - $step_key = (string) $this->get_option( $this->step_key, false ); |
|
427 | - if ( 'count' === $step_key ) { |
|
426 | + $step_key = (string) $this->get_option($this->step_key, false); |
|
427 | + if ('count' === $step_key) { |
|
428 | 428 | return 1; |
429 | - } elseif ( 'donation' === $step_key ) { |
|
429 | + } elseif ('donation' === $step_key) { |
|
430 | 430 | return 2; |
431 | - } elseif ( 'donor' === $step_key ) { |
|
431 | + } elseif ('donor' === $step_key) { |
|
432 | 432 | return 3; |
433 | 433 | } else { |
434 | 434 | return $step_key; |
@@ -439,6 +439,6 @@ discard block |
||
439 | 439 | * Get the current $page value in the ajax. |
440 | 440 | */ |
441 | 441 | private function get_step_page() { |
442 | - return $this->get_option( $this->step_on_key, false ); |
|
442 | + return $this->get_option($this->step_on_key, false); |
|
443 | 443 | } |
444 | 444 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -53,49 +53,49 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function get_data() { |
55 | 55 | |
56 | - if ( $this->step == 1 ) { |
|
57 | - $this->delete_data( 'give_temp_recount_earnings' ); |
|
56 | + if ($this->step == 1) { |
|
57 | + $this->delete_data('give_temp_recount_earnings'); |
|
58 | 58 | } |
59 | 59 | |
60 | - $total = get_option( 'give_temp_recount_earnings', false ); |
|
60 | + $total = get_option('give_temp_recount_earnings', false); |
|
61 | 61 | |
62 | - if ( false === $total ) { |
|
62 | + if (false === $total) { |
|
63 | 63 | $total = (float) 0; |
64 | - $this->store_data( 'give_temp_recount_earnings', $total ); |
|
64 | + $this->store_data('give_temp_recount_earnings', $total); |
|
65 | 65 | } |
66 | 66 | |
67 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
67 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
68 | 68 | |
69 | - $args = apply_filters( 'give_recount_earnings_args', array( |
|
69 | + $args = apply_filters('give_recount_earnings_args', array( |
|
70 | 70 | 'number' => $this->per_step, |
71 | 71 | 'page' => $this->step, |
72 | 72 | 'status' => $accepted_statuses, |
73 | 73 | 'fields' => 'ids' |
74 | - ) ); |
|
74 | + )); |
|
75 | 75 | |
76 | - $payments = give_get_payments( $args ); |
|
76 | + $payments = give_get_payments($args); |
|
77 | 77 | |
78 | - if ( ! empty( $payments ) ) { |
|
78 | + if ( ! empty($payments)) { |
|
79 | 79 | |
80 | - foreach ( $payments as $payment ) { |
|
80 | + foreach ($payments as $payment) { |
|
81 | 81 | |
82 | - $total += give_donation_amount( $payment ); |
|
82 | + $total += give_donation_amount($payment); |
|
83 | 83 | |
84 | 84 | } |
85 | 85 | |
86 | - if ( $total < 0 ) { |
|
86 | + if ($total < 0) { |
|
87 | 87 | $totals = 0; |
88 | 88 | } |
89 | 89 | |
90 | - $total = round( $total, give_get_price_decimals() ); |
|
90 | + $total = round($total, give_get_price_decimals()); |
|
91 | 91 | |
92 | - $this->store_data( 'give_temp_recount_earnings', $total ); |
|
92 | + $this->store_data('give_temp_recount_earnings', $total); |
|
93 | 93 | |
94 | 94 | return true; |
95 | 95 | |
96 | 96 | } |
97 | 97 | |
98 | - update_option( 'give_earnings_total', $total ); |
|
98 | + update_option('give_earnings_total', $total); |
|
99 | 99 | |
100 | 100 | return false; |
101 | 101 | |
@@ -109,25 +109,25 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function get_percentage_complete() { |
111 | 111 | |
112 | - $total = $this->get_stored_data( 'give_recount_earnings_total' ); |
|
112 | + $total = $this->get_stored_data('give_recount_earnings_total'); |
|
113 | 113 | |
114 | - if ( false === $total ) { |
|
115 | - $args = apply_filters( 'give_recount_earnings_total_args', array() ); |
|
114 | + if (false === $total) { |
|
115 | + $args = apply_filters('give_recount_earnings_total_args', array()); |
|
116 | 116 | |
117 | - $counts = give_count_payments( $args ); |
|
118 | - $total = absint( $counts->publish ); |
|
119 | - $total = apply_filters( 'give_recount_store_earnings_total', $total ); |
|
117 | + $counts = give_count_payments($args); |
|
118 | + $total = absint($counts->publish); |
|
119 | + $total = apply_filters('give_recount_store_earnings_total', $total); |
|
120 | 120 | |
121 | - $this->store_data( 'give_recount_earnings_total', $total ); |
|
121 | + $this->store_data('give_recount_earnings_total', $total); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | $percentage = 100; |
125 | 125 | |
126 | - if ( $total > 0 ) { |
|
127 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
126 | + if ($total > 0) { |
|
127 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
128 | 128 | } |
129 | 129 | |
130 | - if ( $percentage > 100 ) { |
|
130 | + if ($percentage > 100) { |
|
131 | 131 | $percentage = 100; |
132 | 132 | } |
133 | 133 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @param array $request The Form Data passed into the batch processing |
143 | 143 | */ |
144 | - public function set_properties( $request ) { |
|
144 | + public function set_properties($request) { |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -152,21 +152,21 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function process_step() { |
154 | 154 | |
155 | - if ( ! $this->can_export() ) { |
|
156 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
155 | + if ( ! $this->can_export()) { |
|
156 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | $had_data = $this->get_data(); |
160 | 160 | |
161 | - if ( $had_data ) { |
|
161 | + if ($had_data) { |
|
162 | 162 | $this->done = false; |
163 | 163 | |
164 | 164 | return true; |
165 | 165 | } else { |
166 | - $this->delete_data( 'give_recount_earnings_total' ); |
|
167 | - $this->delete_data( 'give_temp_recount_earnings' ); |
|
166 | + $this->delete_data('give_recount_earnings_total'); |
|
167 | + $this->delete_data('give_temp_recount_earnings'); |
|
168 | 168 | $this->done = true; |
169 | - $this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' ); |
|
169 | + $this->message = esc_html__('Income stats have been successfully recounted.', 'give'); |
|
170 | 170 | |
171 | 171 | return false; |
172 | 172 | } |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | * Headers. |
177 | 177 | */ |
178 | 178 | public function headers() { |
179 | - ignore_user_abort( true ); |
|
179 | + ignore_user_abort(true); |
|
180 | 180 | |
181 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
182 | - set_time_limit( 0 ); |
|
181 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
182 | + set_time_limit(0); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
@@ -207,17 +207,17 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return mixed Returns the data from the database |
209 | 209 | */ |
210 | - private function get_stored_data( $key ) { |
|
210 | + private function get_stored_data($key) { |
|
211 | 211 | global $wpdb; |
212 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
212 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
213 | 213 | |
214 | - if ( empty( $value ) ) { |
|
214 | + if (empty($value)) { |
|
215 | 215 | return false; |
216 | 216 | } |
217 | 217 | |
218 | - $maybe_json = json_decode( $value ); |
|
219 | - if ( ! is_null( $maybe_json ) ) { |
|
220 | - $value = json_decode( $value, true ); |
|
218 | + $maybe_json = json_decode($value); |
|
219 | + if ( ! is_null($maybe_json)) { |
|
220 | + $value = json_decode($value, true); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | return $value; |
@@ -233,10 +233,10 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @return void |
235 | 235 | */ |
236 | - private function store_data( $key, $value ) { |
|
236 | + private function store_data($key, $value) { |
|
237 | 237 | global $wpdb; |
238 | 238 | |
239 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
239 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
240 | 240 | |
241 | 241 | $data = array( |
242 | 242 | 'option_name' => $key, |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | '%s', |
251 | 251 | ); |
252 | 252 | |
253 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
253 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -262,9 +262,9 @@ discard block |
||
262 | 262 | * |
263 | 263 | * @return void |
264 | 264 | */ |
265 | - private function delete_data( $key ) { |
|
265 | + private function delete_data($key) { |
|
266 | 266 | global $wpdb; |
267 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
267 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -25,59 +25,59 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_do_automatic_upgrades() { |
27 | 27 | $did_upgrade = false; |
28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
29 | 29 | |
30 | - if ( ! $give_version ) { |
|
30 | + if ( ! $give_version) { |
|
31 | 31 | // 1.0 is the first version to use this option so we must add it. |
32 | 32 | $give_version = '1.0'; |
33 | 33 | } |
34 | 34 | |
35 | - switch ( true ) { |
|
35 | + switch (true) { |
|
36 | 36 | |
37 | - case version_compare( $give_version, '1.6', '<' ) : |
|
37 | + case version_compare($give_version, '1.6', '<') : |
|
38 | 38 | give_v16_upgrades(); |
39 | 39 | $did_upgrade = true; |
40 | 40 | |
41 | - case version_compare( $give_version, '1.7', '<' ) : |
|
41 | + case version_compare($give_version, '1.7', '<') : |
|
42 | 42 | give_v17_upgrades(); |
43 | 43 | $did_upgrade = true; |
44 | 44 | |
45 | - case version_compare( $give_version, '1.8', '<' ) : |
|
45 | + case version_compare($give_version, '1.8', '<') : |
|
46 | 46 | give_v18_upgrades(); |
47 | 47 | $did_upgrade = true; |
48 | 48 | |
49 | - case version_compare( $give_version, '1.8.7', '<' ) : |
|
49 | + case version_compare($give_version, '1.8.7', '<') : |
|
50 | 50 | give_v187_upgrades(); |
51 | 51 | $did_upgrade = true; |
52 | 52 | |
53 | - case version_compare( $give_version, '1.8.8', '<' ) : |
|
53 | + case version_compare($give_version, '1.8.8', '<') : |
|
54 | 54 | give_v188_upgrades(); |
55 | 55 | $did_upgrade = true; |
56 | 56 | |
57 | - case version_compare( $give_version, '1.8.9', '<' ) : |
|
57 | + case version_compare($give_version, '1.8.9', '<') : |
|
58 | 58 | give_v189_upgrades(); |
59 | 59 | $did_upgrade = true; |
60 | 60 | |
61 | - case version_compare( $give_version, '1.8.12', '<' ) : |
|
61 | + case version_compare($give_version, '1.8.12', '<') : |
|
62 | 62 | give_v1812_upgrades(); |
63 | 63 | $did_upgrade = true; |
64 | 64 | |
65 | - case version_compare( $give_version, '1.8.13', '<' ) : |
|
65 | + case version_compare($give_version, '1.8.13', '<') : |
|
66 | 66 | give_v1813_upgrades(); |
67 | 67 | $did_upgrade = true; |
68 | 68 | |
69 | - case version_compare( $give_version, '1.8.17', '<' ) : |
|
69 | + case version_compare($give_version, '1.8.17', '<') : |
|
70 | 70 | give_v1817_upgrades(); |
71 | 71 | $did_upgrade = true; |
72 | 72 | } |
73 | 73 | |
74 | - if ( $did_upgrade ) { |
|
75 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
74 | + if ($did_upgrade) { |
|
75 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
80 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
79 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
80 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Display Upgrade Notices |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return void |
91 | 91 | */ |
92 | -function give_show_upgrade_notices( $give_updates ) { |
|
92 | +function give_show_upgrade_notices($give_updates) { |
|
93 | 93 | // v1.3.2 Upgrades |
94 | 94 | $give_updates->register( |
95 | 95 | array( |
@@ -155,21 +155,21 @@ discard block |
||
155 | 155 | ); |
156 | 156 | |
157 | 157 | // v1.8.17 Upgrades for donations. |
158 | - $give_updates->register( array( |
|
158 | + $give_updates->register(array( |
|
159 | 159 | 'id' => 'v1817_update_donation_iranian_currency_code', |
160 | 160 | 'version' => '1.8.17', |
161 | 161 | 'callback' => 'give_v1817_update_donation_iranian_currency_code', |
162 | - ) ); |
|
162 | + )); |
|
163 | 163 | |
164 | 164 | // v1.8.17 Upgrades for cleanup of user roles. |
165 | - $give_updates->register( array( |
|
165 | + $give_updates->register(array( |
|
166 | 166 | 'id' => 'v1817_cleanup_user_roles', |
167 | 167 | 'version' => '1.8.17', |
168 | 168 | 'callback' => 'give_v1817_cleanup_user_roles', |
169 | - ) ); |
|
169 | + )); |
|
170 | 170 | } |
171 | 171 | |
172 | -add_action( 'give_register_updates', 'give_show_upgrade_notices' ); |
|
172 | +add_action('give_register_updates', 'give_show_upgrade_notices'); |
|
173 | 173 | |
174 | 174 | /** |
175 | 175 | * Triggers all upgrade functions |
@@ -181,29 +181,29 @@ discard block |
||
181 | 181 | */ |
182 | 182 | function give_trigger_upgrades() { |
183 | 183 | |
184 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
185 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
184 | + if ( ! current_user_can('manage_give_settings')) { |
|
185 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
186 | 186 | 'response' => 403, |
187 | - ) ); |
|
187 | + )); |
|
188 | 188 | } |
189 | 189 | |
190 | - $give_version = get_option( 'give_version' ); |
|
190 | + $give_version = get_option('give_version'); |
|
191 | 191 | |
192 | - if ( ! $give_version ) { |
|
192 | + if ( ! $give_version) { |
|
193 | 193 | // 1.0 is the first version to use this option so we must add it. |
194 | 194 | $give_version = '1.0'; |
195 | - add_option( 'give_version', $give_version ); |
|
195 | + add_option('give_version', $give_version); |
|
196 | 196 | } |
197 | 197 | |
198 | - update_option( 'give_version', GIVE_VERSION ); |
|
199 | - delete_option( 'give_doing_upgrade' ); |
|
198 | + update_option('give_version', GIVE_VERSION); |
|
199 | + delete_option('give_doing_upgrade'); |
|
200 | 200 | |
201 | - if ( DOING_AJAX ) { |
|
202 | - die( 'complete' ); |
|
201 | + if (DOING_AJAX) { |
|
202 | + die('complete'); |
|
203 | 203 | } // End if(). |
204 | 204 | } |
205 | 205 | |
206 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
206 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
207 | 207 | |
208 | 208 | |
209 | 209 | /** |
@@ -219,24 +219,24 @@ discard block |
||
219 | 219 | /* @var Give_Updates $give_updates */ |
220 | 220 | $give_updates = Give_Updates::get_instance(); |
221 | 221 | |
222 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
223 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
222 | + if ( ! current_user_can('manage_give_settings')) { |
|
223 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
224 | 224 | 'response' => 403, |
225 | - ) ); |
|
225 | + )); |
|
226 | 226 | } |
227 | 227 | |
228 | - ignore_user_abort( true ); |
|
228 | + ignore_user_abort(true); |
|
229 | 229 | |
230 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
231 | - @set_time_limit( 0 ); |
|
230 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
231 | + @set_time_limit(0); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | // UPDATE DB METAKEYS. |
235 | 235 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
236 | - $query = $wpdb->query( $sql ); |
|
236 | + $query = $wpdb->query($sql); |
|
237 | 237 | |
238 | 238 | $give_updates->percentage = 100; |
239 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
239 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | |
@@ -260,24 +260,24 @@ discard block |
||
260 | 260 | $where .= "AND ( p.post_status = 'abandoned' )"; |
261 | 261 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
262 | 262 | |
263 | - $sql = $select . $join . $where; |
|
264 | - $found_payments = $wpdb->get_col( $sql ); |
|
263 | + $sql = $select.$join.$where; |
|
264 | + $found_payments = $wpdb->get_col($sql); |
|
265 | 265 | |
266 | - foreach ( $found_payments as $payment ) { |
|
266 | + foreach ($found_payments as $payment) { |
|
267 | 267 | |
268 | 268 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
269 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
269 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
270 | 270 | |
271 | 271 | // 1450124863 = 12/10/2015 20:42:25. |
272 | - if ( $modified_time >= 1450124863 ) { |
|
272 | + if ($modified_time >= 1450124863) { |
|
273 | 273 | |
274 | - give_update_payment_status( $payment, 'pending' ); |
|
274 | + give_update_payment_status($payment, 'pending'); |
|
275 | 275 | |
276 | 276 | } |
277 | 277 | } |
278 | 278 | |
279 | 279 | $give_updates->percentage = 100; |
280 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
280 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
@@ -290,17 +290,17 @@ discard block |
||
290 | 290 | */ |
291 | 291 | function give_v152_cleanup_users() { |
292 | 292 | |
293 | - $give_version = get_option( 'give_version' ); |
|
293 | + $give_version = get_option('give_version'); |
|
294 | 294 | |
295 | - if ( ! $give_version ) { |
|
295 | + if ( ! $give_version) { |
|
296 | 296 | // 1.0 is the first version to use this option so we must add it. |
297 | 297 | $give_version = '1.0'; |
298 | 298 | } |
299 | 299 | |
300 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
300 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
301 | 301 | |
302 | 302 | // v1.5.2 Upgrades |
303 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
303 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
304 | 304 | |
305 | 305 | // Delete all caps with "ss". |
306 | 306 | // Also delete all unused "campaign" roles. |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | ); |
348 | 348 | |
349 | 349 | global $wp_roles; |
350 | - foreach ( $delete_caps as $cap ) { |
|
351 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
352 | - $wp_roles->remove_cap( $role, $cap ); |
|
350 | + foreach ($delete_caps as $cap) { |
|
351 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
352 | + $wp_roles->remove_cap($role, $cap); |
|
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
@@ -359,15 +359,15 @@ discard block |
||
359 | 359 | $roles->add_caps(); |
360 | 360 | |
361 | 361 | // The Update Ran. |
362 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
363 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
364 | - delete_option( 'give_doing_upgrade' ); |
|
362 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
363 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
364 | + delete_option('give_doing_upgrade'); |
|
365 | 365 | |
366 | 366 | }// End if(). |
367 | 367 | |
368 | 368 | } |
369 | 369 | |
370 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
370 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
371 | 371 | |
372 | 372 | /** |
373 | 373 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -410,53 +410,53 @@ discard block |
||
410 | 410 | |
411 | 411 | // Get addons license key. |
412 | 412 | $addons = array(); |
413 | - foreach ( $give_options as $key => $value ) { |
|
414 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
415 | - $addons[ $key ] = $value; |
|
413 | + foreach ($give_options as $key => $value) { |
|
414 | + if (false !== strpos($key, '_license_key')) { |
|
415 | + $addons[$key] = $value; |
|
416 | 416 | } |
417 | 417 | } |
418 | 418 | |
419 | 419 | // Bailout: We do not have any addon license data to upgrade. |
420 | - if ( empty( $addons ) ) { |
|
420 | + if (empty($addons)) { |
|
421 | 421 | return false; |
422 | 422 | } |
423 | 423 | |
424 | - foreach ( $addons as $key => $addon_license ) { |
|
424 | + foreach ($addons as $key => $addon_license) { |
|
425 | 425 | |
426 | 426 | // Get addon shortname. |
427 | - $shortname = str_replace( '_license_key', '', $key ); |
|
427 | + $shortname = str_replace('_license_key', '', $key); |
|
428 | 428 | |
429 | 429 | // Addon license option name. |
430 | - $addon_license_option_name = $shortname . '_license_active'; |
|
430 | + $addon_license_option_name = $shortname.'_license_active'; |
|
431 | 431 | |
432 | 432 | // bailout if license is empty. |
433 | - if ( empty( $addon_license ) ) { |
|
434 | - delete_option( $addon_license_option_name ); |
|
433 | + if (empty($addon_license)) { |
|
434 | + delete_option($addon_license_option_name); |
|
435 | 435 | continue; |
436 | 436 | } |
437 | 437 | |
438 | 438 | // Get addon name. |
439 | 439 | $addon_name = array(); |
440 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
441 | - foreach ( $addon_name_parts as $name_part ) { |
|
440 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
441 | + foreach ($addon_name_parts as $name_part) { |
|
442 | 442 | |
443 | 443 | // Fix addon name |
444 | - switch ( $name_part ) { |
|
444 | + switch ($name_part) { |
|
445 | 445 | case 'authorizenet' : |
446 | 446 | $name_part = 'authorize.net'; |
447 | 447 | break; |
448 | 448 | } |
449 | 449 | |
450 | - $addon_name[] = ucfirst( $name_part ); |
|
450 | + $addon_name[] = ucfirst($name_part); |
|
451 | 451 | } |
452 | 452 | |
453 | - $addon_name = implode( ' ', $addon_name ); |
|
453 | + $addon_name = implode(' ', $addon_name); |
|
454 | 454 | |
455 | 455 | // Data to send to the API. |
456 | 456 | $api_params = array( |
457 | 457 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
458 | 458 | 'license' => $addon_license, |
459 | - 'item_name' => urlencode( $addon_name ), |
|
459 | + 'item_name' => urlencode($addon_name), |
|
460 | 460 | 'url' => home_url(), |
461 | 461 | ); |
462 | 462 | |
@@ -471,17 +471,17 @@ discard block |
||
471 | 471 | ); |
472 | 472 | |
473 | 473 | // Make sure there are no errors. |
474 | - if ( is_wp_error( $response ) ) { |
|
475 | - delete_option( $addon_license_option_name ); |
|
474 | + if (is_wp_error($response)) { |
|
475 | + delete_option($addon_license_option_name); |
|
476 | 476 | continue; |
477 | 477 | } |
478 | 478 | |
479 | 479 | // Tell WordPress to look for updates. |
480 | - set_site_transient( 'update_plugins', null ); |
|
480 | + set_site_transient('update_plugins', null); |
|
481 | 481 | |
482 | 482 | // Decode license data. |
483 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
484 | - update_option( $addon_license_option_name, $license_data ); |
|
483 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
484 | + update_option($addon_license_option_name, $license_data); |
|
485 | 485 | }// End foreach(). |
486 | 486 | } |
487 | 487 | |
@@ -511,9 +511,9 @@ discard block |
||
511 | 511 | ); |
512 | 512 | |
513 | 513 | global $wp_roles; |
514 | - foreach ( $delete_caps as $cap ) { |
|
515 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
516 | - $wp_roles->remove_cap( $role, $cap ); |
|
514 | + foreach ($delete_caps as $cap) { |
|
515 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
516 | + $wp_roles->remove_cap($role, $cap); |
|
517 | 517 | } |
518 | 518 | } |
519 | 519 | |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | function give_v18_upgrades_core_setting() { |
548 | 548 | // Core settings which changes from checkbox to radio. |
549 | 549 | $core_setting_names = array_merge( |
550 | - array_keys( give_v18_renamed_core_settings() ), |
|
550 | + array_keys(give_v18_renamed_core_settings()), |
|
551 | 551 | array( |
552 | 552 | 'uninstall_on_delete', |
553 | 553 | 'scripts_footer', |
@@ -559,48 +559,48 @@ discard block |
||
559 | 559 | ); |
560 | 560 | |
561 | 561 | // Bailout: If not any setting define. |
562 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
562 | + if ($give_settings = get_option('give_settings')) { |
|
563 | 563 | |
564 | 564 | $setting_changed = false; |
565 | 565 | |
566 | 566 | // Loop: check each setting field. |
567 | - foreach ( $core_setting_names as $setting_name ) { |
|
567 | + foreach ($core_setting_names as $setting_name) { |
|
568 | 568 | // New setting name. |
569 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
569 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
570 | 570 | |
571 | 571 | // Continue: If setting already set. |
572 | 572 | if ( |
573 | - array_key_exists( $new_setting_name, $give_settings ) |
|
574 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
573 | + array_key_exists($new_setting_name, $give_settings) |
|
574 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
575 | 575 | ) { |
576 | 576 | continue; |
577 | 577 | } |
578 | 578 | |
579 | 579 | // Set checkbox value to radio value. |
580 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
580 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
581 | 581 | |
582 | 582 | // @see https://github.com/WordImpress/Give/issues/1063. |
583 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
583 | + if (false !== strpos($setting_name, 'disable_')) { |
|
584 | 584 | |
585 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
586 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
585 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
586 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
587 | 587 | |
588 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
588 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | // Tell bot to update core setting to db. |
592 | - if ( ! $setting_changed ) { |
|
592 | + if ( ! $setting_changed) { |
|
593 | 593 | $setting_changed = true; |
594 | 594 | } |
595 | 595 | } |
596 | 596 | |
597 | 597 | // Update setting only if they changed. |
598 | - if ( $setting_changed ) { |
|
599 | - update_option( 'give_settings', $give_settings ); |
|
598 | + if ($setting_changed) { |
|
599 | + update_option('give_settings', $give_settings); |
|
600 | 600 | } |
601 | 601 | }// End if(). |
602 | 602 | |
603 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
603 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
604 | 604 | } |
605 | 605 | |
606 | 606 | /** |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | $give_updates = Give_Updates::get_instance(); |
615 | 615 | |
616 | 616 | // form query |
617 | - $forms = new WP_Query( array( |
|
617 | + $forms = new WP_Query(array( |
|
618 | 618 | 'paged' => $give_updates->step, |
619 | 619 | 'status' => 'any', |
620 | 620 | 'order' => 'ASC', |
@@ -623,41 +623,41 @@ discard block |
||
623 | 623 | ) |
624 | 624 | ); |
625 | 625 | |
626 | - if ( $forms->have_posts() ) { |
|
627 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 20 ) ); |
|
626 | + if ($forms->have_posts()) { |
|
627 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 20)); |
|
628 | 628 | |
629 | - while ( $forms->have_posts() ) { |
|
629 | + while ($forms->have_posts()) { |
|
630 | 630 | $forms->the_post(); |
631 | 631 | |
632 | 632 | // Form content. |
633 | 633 | // Note in version 1.8 display content setting split into display content and content placement setting. |
634 | 634 | // You can delete _give_content_option in future. |
635 | - $show_content = give_get_meta( get_the_ID(), '_give_content_option', true ); |
|
636 | - if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
637 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
638 | - give_update_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
635 | + $show_content = give_get_meta(get_the_ID(), '_give_content_option', true); |
|
636 | + if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) { |
|
637 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
638 | + give_update_meta(get_the_ID(), '_give_display_content', $field_value); |
|
639 | 639 | |
640 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
641 | - give_update_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
640 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
641 | + give_update_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | // "Disable" Guest Donation. Checkbox. |
645 | 645 | // See: https://github.com/WordImpress/Give/issues/1470. |
646 | - $guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
647 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
648 | - give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
646 | + $guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true); |
|
647 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
648 | + give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
649 | 649 | |
650 | 650 | // Offline Donations. |
651 | 651 | // See: https://github.com/WordImpress/Give/issues/1579. |
652 | - $offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
653 | - if ( 'no' === $offline_donation ) { |
|
652 | + $offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
653 | + if ('no' === $offline_donation) { |
|
654 | 654 | $offline_donation_newval = 'global'; |
655 | - } elseif ( 'yes' === $offline_donation ) { |
|
655 | + } elseif ('yes' === $offline_donation) { |
|
656 | 656 | $offline_donation_newval = 'enabled'; |
657 | 657 | } else { |
658 | 658 | $offline_donation_newval = 'disabled'; |
659 | 659 | } |
660 | - give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
660 | + give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
661 | 661 | |
662 | 662 | // Convert yes/no setting field to enabled/disabled. |
663 | 663 | $form_radio_settings = array( |
@@ -677,15 +677,15 @@ discard block |
||
677 | 677 | '_give_offline_donation_enable_billing_fields_single', |
678 | 678 | ); |
679 | 679 | |
680 | - foreach ( $form_radio_settings as $meta_key ) { |
|
680 | + foreach ($form_radio_settings as $meta_key) { |
|
681 | 681 | // Get value. |
682 | - $field_value = give_get_meta( get_the_ID(), $meta_key, true ); |
|
682 | + $field_value = give_get_meta(get_the_ID(), $meta_key, true); |
|
683 | 683 | |
684 | 684 | // Convert meta value only if it is in yes/no/none. |
685 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
685 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
686 | 686 | |
687 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
688 | - give_update_meta( get_the_ID(), $meta_key, $field_value ); |
|
687 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
688 | + give_update_meta(get_the_ID(), $meta_key, $field_value); |
|
689 | 689 | } |
690 | 690 | } |
691 | 691 | }// End while(). |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | |
695 | 695 | } else { |
696 | 696 | // No more forms found, finish up. |
697 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
697 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
698 | 698 | } |
699 | 699 | } |
700 | 700 | |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | '%_transient_give_stats_%', |
762 | 762 | 'give_cache%', |
763 | 763 | '%_transient_give_add_ons_feed%', |
764 | - '%_transient__give_ajax_works' . |
|
764 | + '%_transient__give_ajax_works'. |
|
765 | 765 | '%_transient_give_total_api_keys%', |
766 | 766 | '%_transient_give_i18n_give_promo_hide%', |
767 | 767 | '%_transient_give_contributors%', |
@@ -788,24 +788,24 @@ discard block |
||
788 | 788 | ARRAY_A |
789 | 789 | ); |
790 | 790 | |
791 | - if ( ! empty( $user_apikey_options ) ) { |
|
792 | - foreach ( $user_apikey_options as $user ) { |
|
793 | - $cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] ); |
|
794 | - $cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] ); |
|
795 | - $cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] ); |
|
791 | + if ( ! empty($user_apikey_options)) { |
|
792 | + foreach ($user_apikey_options as $user) { |
|
793 | + $cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']); |
|
794 | + $cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']); |
|
795 | + $cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']); |
|
796 | 796 | } |
797 | 797 | } |
798 | 798 | |
799 | - if ( ! empty( $cached_options ) ) { |
|
800 | - foreach ( $cached_options as $option ) { |
|
801 | - switch ( true ) { |
|
802 | - case ( false !== strpos( $option, 'transient' ) ): |
|
803 | - $option = str_replace( '_transient_', '', $option ); |
|
804 | - delete_transient( $option ); |
|
799 | + if ( ! empty($cached_options)) { |
|
800 | + foreach ($cached_options as $option) { |
|
801 | + switch (true) { |
|
802 | + case (false !== strpos($option, 'transient')): |
|
803 | + $option = str_replace('_transient_', '', $option); |
|
804 | + delete_transient($option); |
|
805 | 805 | break; |
806 | 806 | |
807 | 807 | default: |
808 | - delete_option( $option ); |
|
808 | + delete_option($option); |
|
809 | 809 | } |
810 | 810 | } |
811 | 811 | } |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | global $wp_roles; |
824 | 824 | |
825 | 825 | // Get the role object. |
826 | - $give_worker = get_role( 'give_worker' ); |
|
826 | + $give_worker = get_role('give_worker'); |
|
827 | 827 | |
828 | 828 | // A list of capabilities to add for give workers. |
829 | 829 | $caps_to_add = array( |
@@ -831,9 +831,9 @@ discard block |
||
831 | 831 | 'edit_pages', |
832 | 832 | ); |
833 | 833 | |
834 | - foreach ( $caps_to_add as $cap ) { |
|
834 | + foreach ($caps_to_add as $cap) { |
|
835 | 835 | // Add the capability. |
836 | - $give_worker->add_cap( $cap ); |
|
836 | + $give_worker->add_cap($cap); |
|
837 | 837 | } |
838 | 838 | |
839 | 839 | } |
@@ -850,7 +850,7 @@ discard block |
||
850 | 850 | $give_updates = Give_Updates::get_instance(); |
851 | 851 | |
852 | 852 | // form query. |
853 | - $donation_forms = new WP_Query( array( |
|
853 | + $donation_forms = new WP_Query(array( |
|
854 | 854 | 'paged' => $give_updates->step, |
855 | 855 | 'status' => 'any', |
856 | 856 | 'order' => 'ASC', |
@@ -859,10 +859,10 @@ discard block |
||
859 | 859 | ) |
860 | 860 | ); |
861 | 861 | |
862 | - if ( $donation_forms->have_posts() ) { |
|
863 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
862 | + if ($donation_forms->have_posts()) { |
|
863 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
864 | 864 | |
865 | - while ( $donation_forms->have_posts() ) { |
|
865 | + while ($donation_forms->have_posts()) { |
|
866 | 866 | $donation_forms->the_post(); |
867 | 867 | $form_id = get_the_ID(); |
868 | 868 | |
@@ -870,41 +870,41 @@ discard block |
||
870 | 870 | update_post_meta( |
871 | 871 | $form_id, |
872 | 872 | '_give_set_price', |
873 | - give_sanitize_amount( get_post_meta( $form_id, '_give_set_price', true ) ) |
|
873 | + give_sanitize_amount(get_post_meta($form_id, '_give_set_price', true)) |
|
874 | 874 | ); |
875 | 875 | |
876 | 876 | // Remove formatting from _give_custom_amount_minimum. |
877 | 877 | update_post_meta( |
878 | 878 | $form_id, |
879 | 879 | '_give_custom_amount_minimum', |
880 | - give_sanitize_amount( get_post_meta( $form_id, '_give_custom_amount_minimum', true ) ) |
|
880 | + give_sanitize_amount(get_post_meta($form_id, '_give_custom_amount_minimum', true)) |
|
881 | 881 | ); |
882 | 882 | |
883 | 883 | // Bailout. |
884 | - if ( 'set' === get_post_meta( $form_id, '_give_price_option', true ) ) { |
|
884 | + if ('set' === get_post_meta($form_id, '_give_price_option', true)) { |
|
885 | 885 | continue; |
886 | 886 | } |
887 | 887 | |
888 | - $donation_levels = get_post_meta( $form_id, '_give_donation_levels', true ); |
|
888 | + $donation_levels = get_post_meta($form_id, '_give_donation_levels', true); |
|
889 | 889 | |
890 | - if ( ! empty( $donation_levels ) ) { |
|
890 | + if ( ! empty($donation_levels)) { |
|
891 | 891 | |
892 | - foreach ( $donation_levels as $index => $donation_level ) { |
|
893 | - if ( isset( $donation_level['_give_amount'] ) ) { |
|
894 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount( $donation_level['_give_amount'] ); |
|
892 | + foreach ($donation_levels as $index => $donation_level) { |
|
893 | + if (isset($donation_level['_give_amount'])) { |
|
894 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount($donation_level['_give_amount']); |
|
895 | 895 | } |
896 | 896 | } |
897 | 897 | |
898 | - update_post_meta( $form_id, '_give_donation_levels', $donation_levels ); |
|
898 | + update_post_meta($form_id, '_give_donation_levels', $donation_levels); |
|
899 | 899 | |
900 | - $donation_levels_amounts = wp_list_pluck( $donation_levels, '_give_amount' ); |
|
900 | + $donation_levels_amounts = wp_list_pluck($donation_levels, '_give_amount'); |
|
901 | 901 | |
902 | - $min_amount = min( $donation_levels_amounts ); |
|
903 | - $max_amount = max( $donation_levels_amounts ); |
|
902 | + $min_amount = min($donation_levels_amounts); |
|
903 | + $max_amount = max($donation_levels_amounts); |
|
904 | 904 | |
905 | 905 | // Set Minimum and Maximum amount for Multi Level Donation Forms |
906 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 ); |
|
907 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount( $max_amount ) : 0 ); |
|
906 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0); |
|
907 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0); |
|
908 | 908 | } |
909 | 909 | |
910 | 910 | } |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | wp_reset_postdata(); |
914 | 914 | } else { |
915 | 915 | // The Update Ran. |
916 | - give_set_upgrade_complete( 'v189_upgrades_levels_post_meta' ); |
|
916 | + give_set_upgrade_complete('v189_upgrades_levels_post_meta'); |
|
917 | 917 | } |
918 | 918 | |
919 | 919 | } |
@@ -969,22 +969,22 @@ discard block |
||
969 | 969 | $give_settings = give_get_settings(); |
970 | 970 | $give_setting_updated = false; |
971 | 971 | |
972 | - if ( $give_settings['thousands_separator'] === $give_settings['decimal_separator'] ) { |
|
972 | + if ($give_settings['thousands_separator'] === $give_settings['decimal_separator']) { |
|
973 | 973 | $give_settings['number_decimals'] = 0; |
974 | 974 | $give_settings['decimal_separator'] = ''; |
975 | 975 | $give_setting_updated = true; |
976 | 976 | |
977 | - } elseif ( empty( $give_settings['decimal_separator'] ) ) { |
|
977 | + } elseif (empty($give_settings['decimal_separator'])) { |
|
978 | 978 | $give_settings['number_decimals'] = 0; |
979 | 979 | $give_setting_updated = true; |
980 | 980 | |
981 | - } elseif ( 6 < absint( $give_settings['number_decimals'] ) ) { |
|
981 | + } elseif (6 < absint($give_settings['number_decimals'])) { |
|
982 | 982 | $give_settings['number_decimals'] = 5; |
983 | 983 | $give_setting_updated = true; |
984 | 984 | } |
985 | 985 | |
986 | - if ( $give_setting_updated ) { |
|
987 | - update_option( 'give_settings', $give_settings ); |
|
986 | + if ($give_setting_updated) { |
|
987 | + update_option('give_settings', $give_settings); |
|
988 | 988 | } |
989 | 989 | } |
990 | 990 | |
@@ -1003,70 +1003,70 @@ discard block |
||
1003 | 1003 | $give_updates = Give_Updates::get_instance(); |
1004 | 1004 | |
1005 | 1005 | // form query. |
1006 | - $donation_forms = new WP_Query( array( |
|
1006 | + $donation_forms = new WP_Query(array( |
|
1007 | 1007 | 'paged' => $give_updates->step, |
1008 | 1008 | 'status' => 'any', |
1009 | 1009 | 'order' => 'ASC', |
1010 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
1010 | + 'post_type' => array('give_forms', 'give_payment'), |
|
1011 | 1011 | 'posts_per_page' => 20, |
1012 | 1012 | ) |
1013 | 1013 | ); |
1014 | 1014 | |
1015 | - if ( $donation_forms->have_posts() ) { |
|
1016 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
1015 | + if ($donation_forms->have_posts()) { |
|
1016 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
1017 | 1017 | |
1018 | - while ( $donation_forms->have_posts() ) { |
|
1018 | + while ($donation_forms->have_posts()) { |
|
1019 | 1019 | $donation_forms->the_post(); |
1020 | 1020 | global $post; |
1021 | 1021 | |
1022 | - $meta = get_post_meta( $post->ID ); |
|
1022 | + $meta = get_post_meta($post->ID); |
|
1023 | 1023 | |
1024 | - switch ( $post->post_type ) { |
|
1024 | + switch ($post->post_type) { |
|
1025 | 1025 | case 'give_forms': |
1026 | 1026 | // _give_set_price. |
1027 | - if ( ! empty( $meta['_give_set_price'][0] ) ) { |
|
1028 | - update_post_meta( $post->ID, '_give_set_price', give_sanitize_amount_for_db( $meta['_give_set_price'][0] ) ); |
|
1027 | + if ( ! empty($meta['_give_set_price'][0])) { |
|
1028 | + update_post_meta($post->ID, '_give_set_price', give_sanitize_amount_for_db($meta['_give_set_price'][0])); |
|
1029 | 1029 | } |
1030 | 1030 | |
1031 | 1031 | // _give_custom_amount_minimum. |
1032 | - if ( ! empty( $meta['_give_custom_amount_minimum'][0] ) ) { |
|
1033 | - update_post_meta( $post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db( $meta['_give_custom_amount_minimum'][0] ) ); |
|
1032 | + if ( ! empty($meta['_give_custom_amount_minimum'][0])) { |
|
1033 | + update_post_meta($post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db($meta['_give_custom_amount_minimum'][0])); |
|
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | // _give_levels_minimum_amount. |
1037 | - if ( ! empty( $meta['_give_levels_minimum_amount'][0] ) ) { |
|
1038 | - update_post_meta( $post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db( $meta['_give_levels_minimum_amount'][0] ) ); |
|
1037 | + if ( ! empty($meta['_give_levels_minimum_amount'][0])) { |
|
1038 | + update_post_meta($post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db($meta['_give_levels_minimum_amount'][0])); |
|
1039 | 1039 | } |
1040 | 1040 | |
1041 | 1041 | // _give_levels_maximum_amount. |
1042 | - if ( ! empty( $meta['_give_levels_maximum_amount'][0] ) ) { |
|
1043 | - update_post_meta( $post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db( $meta['_give_levels_maximum_amount'][0] ) ); |
|
1042 | + if ( ! empty($meta['_give_levels_maximum_amount'][0])) { |
|
1043 | + update_post_meta($post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db($meta['_give_levels_maximum_amount'][0])); |
|
1044 | 1044 | } |
1045 | 1045 | |
1046 | 1046 | // _give_set_goal. |
1047 | - if ( ! empty( $meta['_give_set_goal'][0] ) ) { |
|
1048 | - update_post_meta( $post->ID, '_give_set_goal', give_sanitize_amount_for_db( $meta['_give_set_goal'][0] ) ); |
|
1047 | + if ( ! empty($meta['_give_set_goal'][0])) { |
|
1048 | + update_post_meta($post->ID, '_give_set_goal', give_sanitize_amount_for_db($meta['_give_set_goal'][0])); |
|
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | // _give_form_earnings. |
1052 | - if ( ! empty( $meta['_give_form_earnings'][0] ) ) { |
|
1053 | - update_post_meta( $post->ID, '_give_form_earnings', give_sanitize_amount_for_db( $meta['_give_form_earnings'][0] ) ); |
|
1052 | + if ( ! empty($meta['_give_form_earnings'][0])) { |
|
1053 | + update_post_meta($post->ID, '_give_form_earnings', give_sanitize_amount_for_db($meta['_give_form_earnings'][0])); |
|
1054 | 1054 | } |
1055 | 1055 | |
1056 | 1056 | // _give_custom_amount_minimum. |
1057 | - if ( ! empty( $meta['_give_donation_levels'][0] ) ) { |
|
1058 | - $donation_levels = unserialize( $meta['_give_donation_levels'][0] ); |
|
1057 | + if ( ! empty($meta['_give_donation_levels'][0])) { |
|
1058 | + $donation_levels = unserialize($meta['_give_donation_levels'][0]); |
|
1059 | 1059 | |
1060 | - foreach ( $donation_levels as $index => $level ) { |
|
1061 | - if ( empty( $level['_give_amount'] ) ) { |
|
1060 | + foreach ($donation_levels as $index => $level) { |
|
1061 | + if (empty($level['_give_amount'])) { |
|
1062 | 1062 | continue; |
1063 | 1063 | } |
1064 | 1064 | |
1065 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount_for_db( $level['_give_amount'] ); |
|
1065 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount_for_db($level['_give_amount']); |
|
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | $meta['_give_donation_levels'] = $donation_levels; |
1069 | - update_post_meta( $post->ID, '_give_donation_levels', $meta['_give_donation_levels'] ); |
|
1069 | + update_post_meta($post->ID, '_give_donation_levels', $meta['_give_donation_levels']); |
|
1070 | 1070 | } |
1071 | 1071 | |
1072 | 1072 | |
@@ -1074,8 +1074,8 @@ discard block |
||
1074 | 1074 | |
1075 | 1075 | case 'give_payment': |
1076 | 1076 | // _give_payment_total. |
1077 | - if ( ! empty( $meta['_give_payment_total'][0] ) ) { |
|
1078 | - update_post_meta( $post->ID, '_give_payment_total', give_sanitize_amount_for_db( $meta['_give_payment_total'][0] ) ); |
|
1077 | + if ( ! empty($meta['_give_payment_total'][0])) { |
|
1078 | + update_post_meta($post->ID, '_give_payment_total', give_sanitize_amount_for_db($meta['_give_payment_total'][0])); |
|
1079 | 1079 | } |
1080 | 1080 | |
1081 | 1081 | break; |
@@ -1086,7 +1086,7 @@ discard block |
||
1086 | 1086 | wp_reset_postdata(); |
1087 | 1087 | } else { |
1088 | 1088 | // The Update Ran. |
1089 | - give_set_upgrade_complete( 'v1812_update_amount_values' ); |
|
1089 | + give_set_upgrade_complete('v1812_update_amount_values'); |
|
1090 | 1090 | } |
1091 | 1091 | } |
1092 | 1092 | |
@@ -1106,22 +1106,22 @@ discard block |
||
1106 | 1106 | $offset = 1 === $give_updates->step ? 0 : $give_updates->step * 20; |
1107 | 1107 | |
1108 | 1108 | // form query. |
1109 | - $donors = Give()->donors->get_donors( array( |
|
1109 | + $donors = Give()->donors->get_donors(array( |
|
1110 | 1110 | 'number' => 20, |
1111 | 1111 | 'offset' => $offset, |
1112 | 1112 | ) |
1113 | 1113 | ); |
1114 | 1114 | |
1115 | - if ( ! empty( $donors ) ) { |
|
1116 | - $give_updates->set_percentage( Give()->donors->count(), ( $give_updates->step * 20 ) ); |
|
1115 | + if ( ! empty($donors)) { |
|
1116 | + $give_updates->set_percentage(Give()->donors->count(), ($give_updates->step * 20)); |
|
1117 | 1117 | |
1118 | 1118 | /* @var Object $donor */ |
1119 | - foreach ( $donors as $donor ) { |
|
1120 | - Give()->donors->update( $donor->id, array( 'purchase_value' => give_sanitize_amount_for_db( $donor->purchase_value ) ) ); |
|
1119 | + foreach ($donors as $donor) { |
|
1120 | + Give()->donors->update($donor->id, array('purchase_value' => give_sanitize_amount_for_db($donor->purchase_value))); |
|
1121 | 1121 | } |
1122 | 1122 | } else { |
1123 | 1123 | // The Update Ran. |
1124 | - give_set_upgrade_complete( 'v1812_update_donor_purchase_values' ); |
|
1124 | + give_set_upgrade_complete('v1812_update_donor_purchase_values'); |
|
1125 | 1125 | } |
1126 | 1126 | } |
1127 | 1127 | |
@@ -1136,25 +1136,25 @@ discard block |
||
1136 | 1136 | $offset = 1 === $give_updates->step ? 0 : $give_updates->step * 20; |
1137 | 1137 | |
1138 | 1138 | // Fetch all the existing donors. |
1139 | - $donors = Give()->donors->get_donors( array( |
|
1139 | + $donors = Give()->donors->get_donors(array( |
|
1140 | 1140 | 'number' => 20, |
1141 | 1141 | 'offset' => $offset, |
1142 | 1142 | ) |
1143 | 1143 | ); |
1144 | 1144 | |
1145 | - if ( ! empty( $donors ) ) { |
|
1146 | - $give_updates->set_percentage( Give()->donors->count(), ( $give_updates->step * 20 ) ); |
|
1145 | + if ( ! empty($donors)) { |
|
1146 | + $give_updates->set_percentage(Give()->donors->count(), ($give_updates->step * 20)); |
|
1147 | 1147 | |
1148 | 1148 | /* @var Object $donor */ |
1149 | - foreach ( $donors as $donor ) { |
|
1149 | + foreach ($donors as $donor) { |
|
1150 | 1150 | $user_id = $donor->user_id; |
1151 | 1151 | |
1152 | 1152 | // Proceed, if donor is attached with user. |
1153 | - if ( $user_id ) { |
|
1154 | - $user = get_userdata( $user_id ); |
|
1153 | + if ($user_id) { |
|
1154 | + $user = get_userdata($user_id); |
|
1155 | 1155 | |
1156 | 1156 | // Update user role, if user has subscriber role. |
1157 | - if ( is_array( $user->roles ) && in_array( 'subscriber', $user->roles ) ) { |
|
1157 | + if (is_array($user->roles) && in_array('subscriber', $user->roles)) { |
|
1158 | 1158 | wp_update_user( |
1159 | 1159 | array( |
1160 | 1160 | 'ID' => $user_id, |
@@ -1166,7 +1166,7 @@ discard block |
||
1166 | 1166 | } |
1167 | 1167 | } else { |
1168 | 1168 | // The Update Ran. |
1169 | - give_set_upgrade_complete( 'v1813_update_donor_user_roles' ); |
|
1169 | + give_set_upgrade_complete('v1813_update_donor_user_roles'); |
|
1170 | 1170 | } |
1171 | 1171 | } |
1172 | 1172 | |
@@ -1180,33 +1180,33 @@ discard block |
||
1180 | 1180 | $give_updates = Give_Updates::get_instance(); |
1181 | 1181 | |
1182 | 1182 | // form query. |
1183 | - $payments = new WP_Query( array( |
|
1183 | + $payments = new WP_Query(array( |
|
1184 | 1184 | 'paged' => $give_updates->step, |
1185 | 1185 | 'status' => 'any', |
1186 | 1186 | 'order' => 'ASC', |
1187 | - 'post_type' => array( 'give_payment' ), |
|
1187 | + 'post_type' => array('give_payment'), |
|
1188 | 1188 | 'posts_per_page' => 20, |
1189 | 1189 | ) |
1190 | 1190 | ); |
1191 | 1191 | |
1192 | - if ( $payments->have_posts() ) { |
|
1193 | - $give_updates->set_percentage( $payments->found_posts, ( $give_updates->step * 20 ) ); |
|
1192 | + if ($payments->have_posts()) { |
|
1193 | + $give_updates->set_percentage($payments->found_posts, ($give_updates->step * 20)); |
|
1194 | 1194 | |
1195 | - while( $payments->have_posts() ) { |
|
1195 | + while ($payments->have_posts()) { |
|
1196 | 1196 | $payments->the_post(); |
1197 | 1197 | |
1198 | - $payment_meta = give_get_payment_meta( get_the_ID() ); |
|
1198 | + $payment_meta = give_get_payment_meta(get_the_ID()); |
|
1199 | 1199 | |
1200 | - if ( 'RIAL' === $payment_meta['currency'] ) { |
|
1200 | + if ('RIAL' === $payment_meta['currency']) { |
|
1201 | 1201 | $payment_meta['currency'] = 'IRR'; |
1202 | - give_update_meta( get_the_ID(), '_give_payment_meta', $payment_meta ); |
|
1202 | + give_update_meta(get_the_ID(), '_give_payment_meta', $payment_meta); |
|
1203 | 1203 | } |
1204 | 1204 | |
1205 | 1205 | } |
1206 | 1206 | |
1207 | - }else{ |
|
1207 | + } else { |
|
1208 | 1208 | // The Update Ran. |
1209 | - give_set_upgrade_complete( 'v1817_update_donation_iranian_currency_code' ); |
|
1209 | + give_set_upgrade_complete('v1817_update_donation_iranian_currency_code'); |
|
1210 | 1210 | } |
1211 | 1211 | } |
1212 | 1212 | |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | */ |
1218 | 1218 | function give_v1813_upgrades() { |
1219 | 1219 | // Update admin setting. |
1220 | - give_update_option( 'donor_default_user_role', 'give_donor' ); |
|
1220 | + give_update_option('donor_default_user_role', 'give_donor'); |
|
1221 | 1221 | |
1222 | 1222 | // Update Give roles. |
1223 | 1223 | $roles = new Give_Roles(); |
@@ -1234,9 +1234,9 @@ discard block |
||
1234 | 1234 | function give_v1817_upgrades() { |
1235 | 1235 | $give_settings = give_get_settings(); |
1236 | 1236 | |
1237 | - if ( 'RIAL' === $give_settings['currency'] ) { |
|
1237 | + if ('RIAL' === $give_settings['currency']) { |
|
1238 | 1238 | $give_settings['currency'] = 'IRR'; |
1239 | - update_option( 'give_settings', $give_settings ); |
|
1239 | + update_option('give_settings', $give_settings); |
|
1240 | 1240 | } |
1241 | 1241 | } |
1242 | 1242 | |
@@ -1249,7 +1249,7 @@ discard block |
||
1249 | 1249 | |
1250 | 1250 | global $wp_roles; |
1251 | 1251 | |
1252 | - if( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
1252 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
1253 | 1253 | return; |
1254 | 1254 | } |
1255 | 1255 | |
@@ -1273,15 +1273,15 @@ discard block |
||
1273 | 1273 | ), |
1274 | 1274 | ); |
1275 | 1275 | |
1276 | - foreach ( $add_caps as $role => $caps ) { |
|
1277 | - foreach( $caps as $cap ) { |
|
1278 | - $wp_roles->add_cap( $role, $cap ); |
|
1276 | + foreach ($add_caps as $role => $caps) { |
|
1277 | + foreach ($caps as $cap) { |
|
1278 | + $wp_roles->add_cap($role, $cap); |
|
1279 | 1279 | } |
1280 | 1280 | } |
1281 | 1281 | |
1282 | - foreach ( $remove_caps as $role => $caps ) { |
|
1283 | - foreach( $caps as $cap ) { |
|
1284 | - $wp_roles->remove_cap( $role, $cap ); |
|
1282 | + foreach ($remove_caps as $role => $caps) { |
|
1283 | + foreach ($caps as $cap) { |
|
1284 | + $wp_roles->remove_cap($role, $cap); |
|
1285 | 1285 | } |
1286 | 1286 | } |
1287 | 1287 | |
@@ -1306,6 +1306,6 @@ discard block |
||
1306 | 1306 | $roles->add_roles(); |
1307 | 1307 | $roles->add_caps(); |
1308 | 1308 | |
1309 | - give_set_upgrade_complete( 'v1817_cleanup_user_roles' ); |
|
1309 | + give_set_upgrade_complete('v1817_cleanup_user_roles'); |
|
1310 | 1310 | |
1311 | 1311 | } |
1312 | 1312 | \ No newline at end of file |
@@ -1204,7 +1204,7 @@ |
||
1204 | 1204 | |
1205 | 1205 | } |
1206 | 1206 | |
1207 | - }else{ |
|
1207 | + } else{ |
|
1208 | 1208 | // The Update Ran. |
1209 | 1209 | give_set_upgrade_complete( 'v1817_update_donation_iranian_currency_code' ); |
1210 | 1210 | } |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | |
110 | 110 | // Show error message if Akismet not configured and Admin try to save 'enabled' option. |
111 | 111 | if ( isset( $_POST['akismet_spam_protection'] ) |
112 | - && give_is_setting_enabled( $_POST['akismet_spam_protection'] ) |
|
113 | - && ! give_check_akismet_key() |
|
112 | + && give_is_setting_enabled( $_POST['akismet_spam_protection'] ) |
|
113 | + && ! give_check_akismet_key() |
|
114 | 114 | ) { |
115 | 115 | self::add_error( 'give-akismet-protection', __( 'Please properly configure Akismet to enable SPAM protection.', 'give' ) ); |
116 | 116 | |
@@ -792,9 +792,9 @@ discard block |
||
792 | 792 | <td class="give-docs-link" colspan="2"> |
793 | 793 | <?php |
794 | 794 | echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] ) |
795 | - . '" target="_blank">' |
|
796 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
797 | - . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
|
795 | + . '" target="_blank">' |
|
796 | + . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
797 | + . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
|
798 | 798 | ?> |
799 | 799 | </td> |
800 | 800 | </tr><?php |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Admin_Settings' ) ) : |
|
16 | +if ( ! class_exists('Give_Admin_Settings')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Admin_Settings Class. |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param array $settings Array of settings class object. |
74 | 74 | */ |
75 | - self::$settings = apply_filters( self::$setting_filter_prefix . '_get_settings_pages', array() ); |
|
75 | + self::$settings = apply_filters(self::$setting_filter_prefix.'_get_settings_pages', array()); |
|
76 | 76 | |
77 | 77 | return self::$settings; |
78 | 78 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @return bool |
87 | 87 | */ |
88 | 88 | public static function verify_nonce() { |
89 | - if ( empty( $_REQUEST['_give-save-settings'] ) || ! wp_verify_nonce( $_REQUEST['_give-save-settings'], 'give-save-settings' ) ) { |
|
89 | + if (empty($_REQUEST['_give-save-settings']) || ! wp_verify_nonce($_REQUEST['_give-save-settings'], 'give-save-settings')) { |
|
90 | 90 | return false; |
91 | 91 | } |
92 | 92 | |
@@ -102,17 +102,17 @@ discard block |
||
102 | 102 | public static function save() { |
103 | 103 | $current_tab = give_get_current_setting_tab(); |
104 | 104 | |
105 | - if ( ! self::verify_nonce() ) { |
|
106 | - echo '<div class="notice error"><p>' . __( 'Action failed. Please refresh the page and retry.', 'give' ) . '</p></div>'; |
|
105 | + if ( ! self::verify_nonce()) { |
|
106 | + echo '<div class="notice error"><p>'.__('Action failed. Please refresh the page and retry.', 'give').'</p></div>'; |
|
107 | 107 | die(); |
108 | 108 | } |
109 | 109 | |
110 | 110 | // Show error message if Akismet not configured and Admin try to save 'enabled' option. |
111 | - if ( isset( $_POST['akismet_spam_protection'] ) |
|
112 | - && give_is_setting_enabled( $_POST['akismet_spam_protection'] ) |
|
111 | + if (isset($_POST['akismet_spam_protection']) |
|
112 | + && give_is_setting_enabled($_POST['akismet_spam_protection']) |
|
113 | 113 | && ! give_check_akismet_key() |
114 | 114 | ) { |
115 | - self::add_error( 'give-akismet-protection', __( 'Please properly configure Akismet to enable SPAM protection.', 'give' ) ); |
|
115 | + self::add_error('give-akismet-protection', __('Please properly configure Akismet to enable SPAM protection.', 'give')); |
|
116 | 116 | |
117 | 117 | return; |
118 | 118 | } |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @since 1.8 |
128 | 128 | */ |
129 | - do_action( self::$setting_filter_prefix . '_save_' . $current_tab ); |
|
129 | + do_action(self::$setting_filter_prefix.'_save_'.$current_tab); |
|
130 | 130 | |
131 | - self::add_message( 'give-setting-updated', __( 'Your settings have been saved.', 'give' ) ); |
|
131 | + self::add_message('give-setting-updated', __('Your settings have been saved.', 'give')); |
|
132 | 132 | |
133 | 133 | /** |
134 | 134 | * Trigger Action. |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @since 1.8 |
141 | 141 | */ |
142 | - do_action( self::$setting_filter_prefix . '_saved' ); |
|
142 | + do_action(self::$setting_filter_prefix.'_saved'); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return void |
154 | 154 | */ |
155 | - public static function add_message( $code, $message ) { |
|
156 | - self::$messages[ $code ] = $message; |
|
155 | + public static function add_message($code, $message) { |
|
156 | + self::$messages[$code] = $message; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return void |
168 | 168 | */ |
169 | - public static function add_error( $code, $message ) { |
|
170 | - self::$errors[ $code ] = $message; |
|
169 | + public static function add_error($code, $message) { |
|
170 | + self::$errors[$code] = $message; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -180,18 +180,18 @@ discard block |
||
180 | 180 | $notice_html = ''; |
181 | 181 | $classes = 'give-notice settings-error notice is-dismissible'; |
182 | 182 | |
183 | - self::$errors = apply_filters( self::$setting_filter_prefix . '_error_notices', self::$errors ); |
|
184 | - self::$messages = apply_filters( self::$setting_filter_prefix . '_update_notices', self::$messages ); |
|
183 | + self::$errors = apply_filters(self::$setting_filter_prefix.'_error_notices', self::$errors); |
|
184 | + self::$messages = apply_filters(self::$setting_filter_prefix.'_update_notices', self::$messages); |
|
185 | 185 | |
186 | - if ( 0 < count( self::$errors ) ) { |
|
187 | - foreach ( self::$errors as $code => $message ) { |
|
188 | - $notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' error"><p><strong>' . $message . '</strong></p></div>'; |
|
186 | + if (0 < count(self::$errors)) { |
|
187 | + foreach (self::$errors as $code => $message) { |
|
188 | + $notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' error"><p><strong>'.$message.'</strong></p></div>'; |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | |
192 | - if ( 0 < count( self::$messages ) ) { |
|
193 | - foreach ( self::$messages as $code => $message ) { |
|
194 | - $notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' updated"><p><strong>' . $message . '</strong></p></div>'; |
|
192 | + if (0 < count(self::$messages)) { |
|
193 | + foreach (self::$messages as $code => $message) { |
|
194 | + $notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' updated"><p><strong>'.$message.'</strong></p></div>'; |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | self::$setting_filter_prefix = give_get_current_setting_page(); |
212 | 212 | |
213 | 213 | // Bailout: Exit if setting page is not defined. |
214 | - if ( empty( self::$setting_filter_prefix ) ) { |
|
214 | + if (empty(self::$setting_filter_prefix)) { |
|
215 | 215 | return false; |
216 | 216 | } |
217 | 217 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @since 1.8 |
226 | 226 | */ |
227 | - do_action( self::$setting_filter_prefix . '_start' ); |
|
227 | + do_action(self::$setting_filter_prefix.'_start'); |
|
228 | 228 | |
229 | 229 | $current_tab = give_get_current_setting_tab(); |
230 | 230 | |
@@ -234,9 +234,9 @@ discard block |
||
234 | 234 | /* @var object $current_setting_obj */ |
235 | 235 | $current_setting_obj = new StdClass; |
236 | 236 | |
237 | - foreach ( $all_setting as $setting ) { |
|
237 | + foreach ($all_setting as $setting) { |
|
238 | 238 | if ( |
239 | - method_exists( $setting, 'get_id' ) && |
|
239 | + method_exists($setting, 'get_id') && |
|
240 | 240 | $current_tab === $setting->get_id() |
241 | 241 | ) { |
242 | 242 | $current_setting_obj = $setting; |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | } |
246 | 246 | |
247 | 247 | // Save settings if data has been posted. |
248 | - if ( ! empty( $_POST ) ) { |
|
248 | + if ( ! empty($_POST)) { |
|
249 | 249 | self::save(); |
250 | 250 | } |
251 | 251 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @since 1.8 |
260 | 260 | */ |
261 | - $tabs = apply_filters( self::$setting_filter_prefix . '_tabs_array', array() ); |
|
261 | + $tabs = apply_filters(self::$setting_filter_prefix.'_tabs_array', array()); |
|
262 | 262 | |
263 | 263 | include 'views/html-admin-settings.php'; |
264 | 264 | |
@@ -276,25 +276,25 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return string|bool |
278 | 278 | */ |
279 | - public static function get_option( $option_name = '', $field_id = '', $default = false ) { |
|
279 | + public static function get_option($option_name = '', $field_id = '', $default = false) { |
|
280 | 280 | // Bailout. |
281 | - if ( empty( $option_name ) && empty( $field_id ) ) { |
|
281 | + if (empty($option_name) && empty($field_id)) { |
|
282 | 282 | return false; |
283 | 283 | } |
284 | 284 | |
285 | - if ( ! empty( $field_id ) && ! empty( $option_name ) ) { |
|
285 | + if ( ! empty($field_id) && ! empty($option_name)) { |
|
286 | 286 | // Get field value if any. |
287 | - $option_value = get_option( $option_name ); |
|
287 | + $option_value = get_option($option_name); |
|
288 | 288 | |
289 | - $option_value = ( is_array( $option_value ) && array_key_exists( $field_id, $option_value ) ) |
|
290 | - ? $option_value[ $field_id ] |
|
289 | + $option_value = (is_array($option_value) && array_key_exists($field_id, $option_value)) |
|
290 | + ? $option_value[$field_id] |
|
291 | 291 | : $default; |
292 | 292 | } else { |
293 | 293 | // If option name is empty but not field name then this means, setting is direct store to option table under there field name. |
294 | 294 | $option_name = ! $option_name ? $field_id : $option_name; |
295 | 295 | |
296 | 296 | // Get option value if any. |
297 | - $option_value = get_option( $option_name, $default ); |
|
297 | + $option_value = get_option($option_name, $default); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | return $option_value; |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @return void |
314 | 314 | */ |
315 | - public static function output_fields( $options, $option_name = '' ) { |
|
315 | + public static function output_fields($options, $option_name = '') { |
|
316 | 316 | $current_tab = give_get_current_setting_tab(); |
317 | 317 | |
318 | 318 | // Field Default values. |
@@ -325,52 +325,52 @@ discard block |
||
325 | 325 | 'table_html' => true, |
326 | 326 | ); |
327 | 327 | |
328 | - foreach ( $options as $value ) { |
|
329 | - if ( ! isset( $value['type'] ) ) { |
|
328 | + foreach ($options as $value) { |
|
329 | + if ( ! isset($value['type'])) { |
|
330 | 330 | continue; |
331 | 331 | } |
332 | 332 | |
333 | 333 | // Set title. |
334 | - $defaults['title'] = isset( $value['name'] ) ? $value['name'] : ''; |
|
334 | + $defaults['title'] = isset($value['name']) ? $value['name'] : ''; |
|
335 | 335 | |
336 | 336 | // Set default setting. |
337 | - $value = wp_parse_args( $value, $defaults ); |
|
337 | + $value = wp_parse_args($value, $defaults); |
|
338 | 338 | |
339 | 339 | // Colorpicker field. |
340 | - $value['class'] = ( 'colorpicker' === $value['type'] ? trim( $value['class'] ) . ' give-colorpicker' : $value['class'] ); |
|
341 | - $value['type'] = ( 'colorpicker' === $value['type'] ? 'text' : $value['type'] ); |
|
340 | + $value['class'] = ('colorpicker' === $value['type'] ? trim($value['class']).' give-colorpicker' : $value['class']); |
|
341 | + $value['type'] = ('colorpicker' === $value['type'] ? 'text' : $value['type']); |
|
342 | 342 | |
343 | 343 | |
344 | 344 | // Custom attribute handling. |
345 | 345 | $custom_attributes = array(); |
346 | 346 | |
347 | - if ( ! empty( $value['attributes'] ) && is_array( $value['attributes'] ) ) { |
|
348 | - foreach ( $value['attributes'] as $attribute => $attribute_value ) { |
|
349 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; |
|
347 | + if ( ! empty($value['attributes']) && is_array($value['attributes'])) { |
|
348 | + foreach ($value['attributes'] as $attribute => $attribute_value) { |
|
349 | + $custom_attributes[] = esc_attr($attribute).'="'.esc_attr($attribute_value).'"'; |
|
350 | 350 | } |
351 | 351 | } |
352 | 352 | |
353 | 353 | // Description handling. |
354 | - $description = self::get_field_description( $value ); |
|
354 | + $description = self::get_field_description($value); |
|
355 | 355 | |
356 | 356 | // Switch based on type. |
357 | - switch ( $value['type'] ) { |
|
357 | + switch ($value['type']) { |
|
358 | 358 | |
359 | 359 | // Section Titles |
360 | 360 | case 'title': |
361 | - if ( ! empty( $value['title'] ) ) { |
|
362 | - echo '<div class="give-setting-tab-header give-setting-tab-header-' . $current_tab . '"><h2>' . self::get_field_title( $value ) . '</h2><hr></div>'; |
|
361 | + if ( ! empty($value['title'])) { |
|
362 | + echo '<div class="give-setting-tab-header give-setting-tab-header-'.$current_tab.'"><h2>'.self::get_field_title($value).'</h2><hr></div>'; |
|
363 | 363 | } |
364 | 364 | |
365 | - if ( ! empty( $value['desc'] ) ) { |
|
366 | - echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) ); |
|
365 | + if ( ! empty($value['desc'])) { |
|
366 | + echo wpautop(wptexturize(wp_kses_post($value['desc']))); |
|
367 | 367 | } |
368 | 368 | |
369 | - if ( $value['table_html'] ) { |
|
370 | - echo '<table class="form-table give-setting-tab-body give-setting-tab-body-' . $current_tab . '">' . "\n\n"; |
|
369 | + if ($value['table_html']) { |
|
370 | + echo '<table class="form-table give-setting-tab-body give-setting-tab-body-'.$current_tab.'">'."\n\n"; |
|
371 | 371 | } |
372 | 372 | |
373 | - if ( ! empty( $value['id'] ) ) { |
|
373 | + if ( ! empty($value['id'])) { |
|
374 | 374 | |
375 | 375 | /** |
376 | 376 | * Trigger Action. |
@@ -379,14 +379,14 @@ discard block |
||
379 | 379 | * |
380 | 380 | * @since 1.8 |
381 | 381 | */ |
382 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) ); |
|
382 | + do_action('give_settings_'.sanitize_title($value['id'])); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | break; |
386 | 386 | |
387 | 387 | // Section Ends. |
388 | 388 | case 'sectionend': |
389 | - if ( ! empty( $value['id'] ) ) { |
|
389 | + if ( ! empty($value['id'])) { |
|
390 | 390 | |
391 | 391 | /** |
392 | 392 | * Trigger Action. |
@@ -395,14 +395,14 @@ discard block |
||
395 | 395 | * |
396 | 396 | * @since 1.8 |
397 | 397 | */ |
398 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_end' ); |
|
398 | + do_action('give_settings_'.sanitize_title($value['id']).'_end'); |
|
399 | 399 | } |
400 | 400 | |
401 | - if ( $value['table_html'] ) { |
|
401 | + if ($value['table_html']) { |
|
402 | 402 | echo '</table>'; |
403 | 403 | } |
404 | 404 | |
405 | - if ( ! empty( $value['id'] ) ) { |
|
405 | + if ( ! empty($value['id'])) { |
|
406 | 406 | |
407 | 407 | /** |
408 | 408 | * Trigger Action. |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @since 1.8 |
413 | 413 | */ |
414 | - do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_after' ); |
|
414 | + do_action('give_settings_'.sanitize_title($value['id']).'_after'); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | break; |
@@ -419,27 +419,27 @@ discard block |
||
419 | 419 | // Standard text inputs and subtypes like 'number'. |
420 | 420 | case 'colorpicker': |
421 | 421 | case 'hidden' : |
422 | - $value['wrapper_class'] = empty( $value['wrapper_class'] ) ? 'give-hidden' : trim( $value['wrapper_class'] ) . ' give-hidden'; |
|
422 | + $value['wrapper_class'] = empty($value['wrapper_class']) ? 'give-hidden' : trim($value['wrapper_class']).' give-hidden'; |
|
423 | 423 | case 'text': |
424 | 424 | case 'email': |
425 | 425 | case 'number': |
426 | 426 | case 'password' : |
427 | 427 | $type = $value['type']; |
428 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
428 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
429 | 429 | ?> |
430 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
430 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
431 | 431 | <th scope="row" class="titledesc"> |
432 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
432 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
433 | 433 | </th> |
434 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
434 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
435 | 435 | <input |
436 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
437 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
438 | - type="<?php echo esc_attr( $type ); ?>" |
|
439 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
440 | - value="<?php echo esc_attr( $option_value ); ?>" |
|
441 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
442 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
436 | + name="<?php echo esc_attr($value['id']); ?>" |
|
437 | + id="<?php echo esc_attr($value['id']); ?>" |
|
438 | + type="<?php echo esc_attr($type); ?>" |
|
439 | + style="<?php echo esc_attr($value['css']); ?>" |
|
440 | + value="<?php echo esc_attr($option_value); ?>" |
|
441 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
442 | + <?php echo implode(' ', $custom_attributes); ?> |
|
443 | 443 | /> <?php echo $description; ?> |
444 | 444 | </td> |
445 | 445 | </tr> |
@@ -449,23 +449,23 @@ discard block |
||
449 | 449 | // Textarea. |
450 | 450 | case 'textarea': |
451 | 451 | |
452 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
452 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
453 | 453 | |
454 | 454 | ?> |
455 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
455 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
456 | 456 | <th scope="row" class="titledesc"> |
457 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
457 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
458 | 458 | </th> |
459 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
459 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
460 | 460 | <textarea |
461 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
462 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
463 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
464 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
461 | + name="<?php echo esc_attr($value['id']); ?>" |
|
462 | + id="<?php echo esc_attr($value['id']); ?>" |
|
463 | + style="<?php echo esc_attr($value['css']); ?>" |
|
464 | + class="<?php echo esc_attr($value['class']); ?>" |
|
465 | 465 | rows="10" |
466 | 466 | cols="60" |
467 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
468 | - ><?php echo esc_textarea( $option_value ); ?></textarea> |
|
467 | + <?php echo implode(' ', $custom_attributes); ?> |
|
468 | + ><?php echo esc_textarea($option_value); ?></textarea> |
|
469 | 469 | <?php echo $description; ?> |
470 | 470 | </td> |
471 | 471 | </tr><?php |
@@ -475,35 +475,35 @@ discard block |
||
475 | 475 | case 'select' : |
476 | 476 | case 'multiselect' : |
477 | 477 | |
478 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
478 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
479 | 479 | |
480 | 480 | ?> |
481 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
481 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
482 | 482 | <th scope="row" class="titledesc"> |
483 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
483 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
484 | 484 | </th> |
485 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
485 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
486 | 486 | <select |
487 | - name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) { |
|
487 | + name="<?php echo esc_attr($value['id']); ?><?php if ($value['type'] == 'multiselect') { |
|
488 | 488 | echo '[]'; |
489 | 489 | } ?>" |
490 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
491 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
492 | - class="<?php echo esc_attr( $value['class'] ); ?>" |
|
493 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
494 | - <?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?> |
|
490 | + id="<?php echo esc_attr($value['id']); ?>" |
|
491 | + style="<?php echo esc_attr($value['css']); ?>" |
|
492 | + class="<?php echo esc_attr($value['class']); ?>" |
|
493 | + <?php echo implode(' ', $custom_attributes); ?> |
|
494 | + <?php echo ('multiselect' == $value['type']) ? 'multiple="multiple"' : ''; ?> |
|
495 | 495 | > |
496 | 496 | |
497 | 497 | <?php |
498 | - if ( ! empty( $value['options'] ) ) { |
|
499 | - foreach ( $value['options'] as $key => $val ) { |
|
498 | + if ( ! empty($value['options'])) { |
|
499 | + foreach ($value['options'] as $key => $val) { |
|
500 | 500 | ?> |
501 | - <option value="<?php echo esc_attr( $key ); ?>" <?php |
|
501 | + <option value="<?php echo esc_attr($key); ?>" <?php |
|
502 | 502 | |
503 | - if ( is_array( $option_value ) ) { |
|
504 | - selected( in_array( $key, $option_value ), true ); |
|
503 | + if (is_array($option_value)) { |
|
504 | + selected(in_array($key, $option_value), true); |
|
505 | 505 | } else { |
506 | - selected( $option_value, $key ); |
|
506 | + selected($option_value, $key); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | ?>><?php echo $val ?></option> |
@@ -519,28 +519,28 @@ discard block |
||
519 | 519 | |
520 | 520 | // Radio inputs. |
521 | 521 | case 'radio_inline' : |
522 | - $value['class'] = empty( $value['class'] ) ? 'give-radio-inline' : $value['class'] . ' give-radio-inline'; |
|
522 | + $value['class'] = empty($value['class']) ? 'give-radio-inline' : $value['class'].' give-radio-inline'; |
|
523 | 523 | case 'radio' : |
524 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
524 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
525 | 525 | ?> |
526 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
526 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
527 | 527 | <th scope="row" class="titledesc"> |
528 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
528 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
529 | 529 | </th> |
530 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
530 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
531 | 531 | <fieldset> |
532 | 532 | <ul> |
533 | 533 | <?php |
534 | - foreach ( $value['options'] as $key => $val ) { |
|
534 | + foreach ($value['options'] as $key => $val) { |
|
535 | 535 | ?> |
536 | 536 | <li> |
537 | 537 | <label><input |
538 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
538 | + name="<?php echo esc_attr($value['id']); ?>" |
|
539 | 539 | value="<?php echo $key; ?>" |
540 | 540 | type="radio" |
541 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
542 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
543 | - <?php checked( $key, $option_value ); ?> |
|
541 | + style="<?php echo esc_attr($value['css']); ?>" |
|
542 | + <?php echo implode(' ', $custom_attributes); ?> |
|
543 | + <?php checked($key, $option_value); ?> |
|
544 | 544 | /> <?php echo $val ?></label> |
545 | 545 | </li> |
546 | 546 | <?php |
@@ -554,21 +554,21 @@ discard block |
||
554 | 554 | |
555 | 555 | // Checkbox input. |
556 | 556 | case 'checkbox' : |
557 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
557 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
558 | 558 | ?> |
559 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
559 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
560 | 560 | <th scope="row" class="titledesc"> |
561 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
561 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
562 | 562 | </th> |
563 | 563 | <td class="give-forminp"> |
564 | 564 | <input |
565 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
566 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
565 | + name="<?php echo esc_attr($value['id']); ?>" |
|
566 | + id="<?php echo esc_attr($value['id']); ?>" |
|
567 | 567 | type="checkbox" |
568 | - class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>" |
|
568 | + class="<?php echo esc_attr(isset($value['class']) ? $value['class'] : ''); ?>" |
|
569 | 569 | value="1" |
570 | - <?php checked( $option_value, 'on' ); ?> |
|
571 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
570 | + <?php checked($option_value, 'on'); ?> |
|
571 | + <?php echo implode(' ', $custom_attributes); ?> |
|
572 | 572 | /> |
573 | 573 | <?php echo $description; ?> |
574 | 574 | </td> |
@@ -578,28 +578,28 @@ discard block |
||
578 | 578 | |
579 | 579 | // Multi Checkbox input. |
580 | 580 | case 'multicheck' : |
581 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
582 | - $option_value = is_array( $option_value ) ? $option_value : array(); |
|
581 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
582 | + $option_value = is_array($option_value) ? $option_value : array(); |
|
583 | 583 | ?> |
584 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
584 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
585 | 585 | <th scope="row" class="titledesc"> |
586 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
586 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
587 | 587 | </th> |
588 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>"> |
|
588 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>"> |
|
589 | 589 | <fieldset> |
590 | 590 | <ul> |
591 | 591 | <?php |
592 | - foreach ( $value['options'] as $key => $val ) { |
|
592 | + foreach ($value['options'] as $key => $val) { |
|
593 | 593 | ?> |
594 | 594 | <li> |
595 | 595 | <label> |
596 | 596 | <input |
597 | - name="<?php echo esc_attr( $value['id'] ); ?>[]" |
|
597 | + name="<?php echo esc_attr($value['id']); ?>[]" |
|
598 | 598 | value="<?php echo $key; ?>" |
599 | 599 | type="checkbox" |
600 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
601 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
602 | - <?php if ( in_array( $key, $option_value ) ) { |
|
600 | + style="<?php echo esc_attr($value['css']); ?>" |
|
601 | + <?php echo implode(' ', $custom_attributes); ?> |
|
602 | + <?php if (in_array($key, $option_value)) { |
|
603 | 603 | echo 'checked="checked"'; |
604 | 604 | } ?> |
605 | 605 | /> <?php echo $val ?> |
@@ -618,30 +618,30 @@ discard block |
||
618 | 618 | // File input field. |
619 | 619 | case 'file' : |
620 | 620 | case 'media' : |
621 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
622 | - $button_label = esc_html__( sprintf( 'Add or Upload %s', ( 'file' === $value['type'] ? 'File' : 'Image' ) ), 'give' ); |
|
623 | - $fvalue = empty( $value['fvalue'] ) ? 'url' : $value['fvalue']; |
|
624 | - |
|
625 | - $allow_media_preview_tags = array( 'jpg', 'jpeg', 'png', 'gif', 'ico' ); |
|
626 | - $preview_image_src = $option_value ? ( 'id' === $fvalue ? wp_get_attachment_url( $option_value ) : $option_value ) : '#'; |
|
627 | - $preview_image_extension = $preview_image_src ? pathinfo( $preview_image_src, PATHINFO_EXTENSION ) : ''; |
|
628 | - $is_show_preview = in_array( $preview_image_extension, $allow_media_preview_tags ); |
|
621 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
622 | + $button_label = esc_html__(sprintf('Add or Upload %s', ('file' === $value['type'] ? 'File' : 'Image')), 'give'); |
|
623 | + $fvalue = empty($value['fvalue']) ? 'url' : $value['fvalue']; |
|
624 | + |
|
625 | + $allow_media_preview_tags = array('jpg', 'jpeg', 'png', 'gif', 'ico'); |
|
626 | + $preview_image_src = $option_value ? ('id' === $fvalue ? wp_get_attachment_url($option_value) : $option_value) : '#'; |
|
627 | + $preview_image_extension = $preview_image_src ? pathinfo($preview_image_src, PATHINFO_EXTENSION) : ''; |
|
628 | + $is_show_preview = in_array($preview_image_extension, $allow_media_preview_tags); |
|
629 | 629 | ?> |
630 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
630 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
631 | 631 | <th scope="row" class="titledesc"> |
632 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
632 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
633 | 633 | </th> |
634 | 634 | <td class="give-forminp"> |
635 | 635 | <div class="give-field-wrap"> |
636 | 636 | <label for="<?php echo $value['id'] ?>"> |
637 | 637 | <input |
638 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
639 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
638 | + name="<?php echo esc_attr($value['id']); ?>" |
|
639 | + id="<?php echo esc_attr($value['id']); ?>" |
|
640 | 640 | type="text" |
641 | - class="give-input-field<?php echo esc_attr( isset( $value['class'] ) ? ' ' . $value['class'] : '' ); ?>" |
|
641 | + class="give-input-field<?php echo esc_attr(isset($value['class']) ? ' '.$value['class'] : ''); ?>" |
|
642 | 642 | value="<?php echo $option_value; ?>" |
643 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
644 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
643 | + style="<?php echo esc_attr($value['css']); ?>" |
|
644 | + <?php echo implode(' ', $custom_attributes); ?> |
|
645 | 645 | /> <input class="give-upload-button button" type="button" data-fvalue="<?php echo $fvalue; ?>" data-field-type="<?php echo $value['type']; ?>" value="<?php echo $button_label; ?>"> |
646 | 646 | <?php echo $description ?> |
647 | 647 | <div class="give-image-thumb<?php echo ! $option_value || ! $is_show_preview ? ' give-hidden' : ''; ?>"> |
@@ -658,17 +658,17 @@ discard block |
||
658 | 658 | // WordPress Editor. |
659 | 659 | case 'wysiwyg' : |
660 | 660 | // Get option value. |
661 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
661 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
662 | 662 | |
663 | 663 | // Get editor settings. |
664 | - $editor_settings = ! empty( $value['options'] ) ? $value['options'] : array(); |
|
664 | + $editor_settings = ! empty($value['options']) ? $value['options'] : array(); |
|
665 | 665 | ?> |
666 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
666 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
667 | 667 | <th scope="row" class="titledesc"> |
668 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
668 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
669 | 669 | </th> |
670 | 670 | <td class="give-forminp"> |
671 | - <?php wp_editor( $option_value, $value['id'], $editor_settings ); ?> |
|
671 | + <?php wp_editor($option_value, $value['id'], $editor_settings); ?> |
|
672 | 672 | <?php echo $description; ?> |
673 | 673 | </td> |
674 | 674 | </tr><?php |
@@ -677,9 +677,9 @@ discard block |
||
677 | 677 | // Custom: System setting field. |
678 | 678 | case 'system_info' : |
679 | 679 | ?> |
680 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
680 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
681 | 681 | <th scope="row" class="titledesc"> |
682 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
682 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
683 | 683 | </th> |
684 | 684 | <td class="give-forminp"> |
685 | 685 | <?php give_system_info_callback(); ?> |
@@ -690,14 +690,14 @@ discard block |
||
690 | 690 | |
691 | 691 | // Custom: Default gateways setting field. |
692 | 692 | case 'default_gateway' : |
693 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
693 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
694 | 694 | ?> |
695 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
695 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
696 | 696 | <th scope="row" class="titledesc"> |
697 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
697 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
698 | 698 | </th> |
699 | 699 | <td class="give-forminp"> |
700 | - <?php give_default_gateway_callback( $value, $option_value ); ?> |
|
700 | + <?php give_default_gateway_callback($value, $option_value); ?> |
|
701 | 701 | <?php echo $description; ?> |
702 | 702 | </td> |
703 | 703 | </tr><?php |
@@ -705,14 +705,14 @@ discard block |
||
705 | 705 | |
706 | 706 | // Custom: Enable gateways setting field. |
707 | 707 | case 'enabled_gateways' : |
708 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
708 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
709 | 709 | ?> |
710 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
710 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
711 | 711 | <th scope="row" class="titledesc"> |
712 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
712 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
713 | 713 | </th> |
714 | 714 | <td class="give-forminp"> |
715 | - <?php give_enabled_gateways_callback( $value, $option_value ); ?> |
|
715 | + <?php give_enabled_gateways_callback($value, $option_value); ?> |
|
716 | 716 | <?php echo $description; ?> |
717 | 717 | </td> |
718 | 718 | </tr><?php |
@@ -721,9 +721,9 @@ discard block |
||
721 | 721 | // Custom: Email preview buttons field. |
722 | 722 | case 'email_preview_buttons' : |
723 | 723 | ?> |
724 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
724 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
725 | 725 | <th scope="row" class="titledesc"> |
726 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
726 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
727 | 727 | </th> |
728 | 728 | <td class="give-forminp"> |
729 | 729 | <?php give_email_preview_buttons_callback(); ?> |
@@ -740,22 +740,22 @@ discard block |
||
740 | 740 | |
741 | 741 | // Custom: Gateway API key. |
742 | 742 | case 'api_key' : |
743 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
744 | - $type = ! empty( $option_value ) ? 'password' : 'text'; |
|
743 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
744 | + $type = ! empty($option_value) ? 'password' : 'text'; |
|
745 | 745 | ?> |
746 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
746 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
747 | 747 | <th scope="row" class="titledesc"> |
748 | - <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label> |
|
748 | + <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label> |
|
749 | 749 | </th> |
750 | - <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>"> |
|
750 | + <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>"> |
|
751 | 751 | <input |
752 | - name="<?php echo esc_attr( $value['id'] ); ?>" |
|
753 | - id="<?php echo esc_attr( $value['id'] ); ?>" |
|
754 | - type="<?php echo esc_attr( $type ); ?>" |
|
755 | - style="<?php echo esc_attr( $value['css'] ); ?>" |
|
756 | - value="<?php echo esc_attr( trim( $option_value ) ); ?>" |
|
757 | - class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>" |
|
758 | - <?php echo implode( ' ', $custom_attributes ); ?> |
|
752 | + name="<?php echo esc_attr($value['id']); ?>" |
|
753 | + id="<?php echo esc_attr($value['id']); ?>" |
|
754 | + type="<?php echo esc_attr($type); ?>" |
|
755 | + style="<?php echo esc_attr($value['css']); ?>" |
|
756 | + value="<?php echo esc_attr(trim($option_value)); ?>" |
|
757 | + class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>" |
|
758 | + <?php echo implode(' ', $custom_attributes); ?> |
|
759 | 759 | /> <?php echo $description; ?> |
760 | 760 | </td> |
761 | 761 | </tr><?php |
@@ -772,7 +772,7 @@ discard block |
||
772 | 772 | * |
773 | 773 | * @since 1.0 |
774 | 774 | */ |
775 | - do_action( "give_logs_view_{$current_section}" ); |
|
775 | + do_action("give_logs_view_{$current_section}"); |
|
776 | 776 | |
777 | 777 | echo $description; |
778 | 778 | break; |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | // Custom: Data field. |
781 | 781 | case 'data' : |
782 | 782 | |
783 | - include GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-data.php'; |
|
783 | + include GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-data.php'; |
|
784 | 784 | |
785 | 785 | echo $description; |
786 | 786 | break; |
@@ -788,12 +788,12 @@ discard block |
||
788 | 788 | // Custom: Give Docs Link field type. |
789 | 789 | case 'give_docs_link' : |
790 | 790 | ?> |
791 | - <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>> |
|
791 | + <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>> |
|
792 | 792 | <td class="give-docs-link" colspan="2"> |
793 | 793 | <?php |
794 | - echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] ) |
|
794 | + echo '<p class="give-docs-link"><a href="'.esc_url($value['url']) |
|
795 | 795 | . '" target="_blank">' |
796 | - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] ) |
|
796 | + . sprintf(esc_html__('Need Help? See docs on "%s"', 'give'), $value['title']) |
|
797 | 797 | . '<span class="dashicons dashicons-editor-help"></span></a></p>'; |
798 | 798 | ?> |
799 | 799 | </td> |
@@ -804,8 +804,8 @@ discard block |
||
804 | 804 | // You can add or handle your custom field action. |
805 | 805 | default: |
806 | 806 | // Get option value. |
807 | - $option_value = self::get_option( $option_name, $value['id'], $value['default'] ); |
|
808 | - do_action( 'give_admin_field_' . $value['type'], $value, $option_value ); |
|
807 | + $option_value = self::get_option($option_name, $value['id'], $value['default']); |
|
808 | + do_action('give_admin_field_'.$value['type'], $value, $option_value); |
|
809 | 809 | break; |
810 | 810 | } |
811 | 811 | } |
@@ -821,15 +821,15 @@ discard block |
||
821 | 821 | * |
822 | 822 | * @return string The HTML description of the field. |
823 | 823 | */ |
824 | - public static function get_field_description( $value ) { |
|
824 | + public static function get_field_description($value) { |
|
825 | 825 | $description = ''; |
826 | 826 | |
827 | 827 | // Support for both 'description' and 'desc' args. |
828 | - $description_key = isset( $value['description'] ) ? 'description' : 'desc'; |
|
829 | - $value = ( isset( $value[ $description_key ] ) && ! empty( $value[ $description_key ] ) ) ? $value[ $description_key ] : ''; |
|
828 | + $description_key = isset($value['description']) ? 'description' : 'desc'; |
|
829 | + $value = (isset($value[$description_key]) && ! empty($value[$description_key])) ? $value[$description_key] : ''; |
|
830 | 830 | |
831 | - if ( ! empty( $value ) ) { |
|
832 | - $description = '<p class="give-field-description">' . wp_kses_post( $value ) . '</p>'; |
|
831 | + if ( ! empty($value)) { |
|
832 | + $description = '<p class="give-field-description">'.wp_kses_post($value).'</p>'; |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | return $description; |
@@ -846,11 +846,11 @@ discard block |
||
846 | 846 | * |
847 | 847 | * @return array The description and tip as a 2 element array |
848 | 848 | */ |
849 | - public static function get_field_title( $value ) { |
|
850 | - $title = esc_html( $value['title'] ); |
|
849 | + public static function get_field_title($value) { |
|
850 | + $title = esc_html($value['title']); |
|
851 | 851 | |
852 | 852 | // If html tag detected then allow them to print. |
853 | - if ( strip_tags( $title ) ) { |
|
853 | + if (strip_tags($title)) { |
|
854 | 854 | $title = $value['title']; |
855 | 855 | } |
856 | 856 | |
@@ -869,8 +869,8 @@ discard block |
||
869 | 869 | * |
870 | 870 | * @return bool |
871 | 871 | */ |
872 | - public static function save_fields( $options, $option_name = '' ) { |
|
873 | - if ( empty( $_POST ) ) { |
|
872 | + public static function save_fields($options, $option_name = '') { |
|
873 | + if (empty($_POST)) { |
|
874 | 874 | return false; |
875 | 875 | } |
876 | 876 | |
@@ -878,37 +878,37 @@ discard block |
||
878 | 878 | $update_options = array(); |
879 | 879 | |
880 | 880 | // Loop options and get values to save. |
881 | - foreach ( $options as $option ) { |
|
882 | - if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) { |
|
881 | + foreach ($options as $option) { |
|
882 | + if ( ! isset($option['id']) || ! isset($option['type'])) { |
|
883 | 883 | continue; |
884 | 884 | } |
885 | 885 | |
886 | 886 | // Get posted value. |
887 | - if ( strstr( $option['id'], '[' ) ) { |
|
888 | - parse_str( $option['id'], $option_name_array ); |
|
889 | - $field_option_name = current( array_keys( $option_name_array ) ); |
|
890 | - $setting_name = key( $option_name_array[ $field_option_name ] ); |
|
891 | - $raw_value = isset( $_POST[ $field_option_name ][ $setting_name ] ) ? wp_unslash( $_POST[ $field_option_name ][ $setting_name ] ) : null; |
|
887 | + if (strstr($option['id'], '[')) { |
|
888 | + parse_str($option['id'], $option_name_array); |
|
889 | + $field_option_name = current(array_keys($option_name_array)); |
|
890 | + $setting_name = key($option_name_array[$field_option_name]); |
|
891 | + $raw_value = isset($_POST[$field_option_name][$setting_name]) ? wp_unslash($_POST[$field_option_name][$setting_name]) : null; |
|
892 | 892 | } else { |
893 | 893 | $field_option_name = $option['id']; |
894 | 894 | $setting_name = ''; |
895 | - $raw_value = isset( $_POST[ $option['id'] ] ) ? wp_unslash( $_POST[ $option['id'] ] ) : null; |
|
895 | + $raw_value = isset($_POST[$option['id']]) ? wp_unslash($_POST[$option['id']]) : null; |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | // Format the value based on option type. |
899 | - switch ( $option['type'] ) { |
|
899 | + switch ($option['type']) { |
|
900 | 900 | case 'checkbox' : |
901 | - $value = is_null( $raw_value ) ? '' : 'on'; |
|
901 | + $value = is_null($raw_value) ? '' : 'on'; |
|
902 | 902 | break; |
903 | 903 | case 'wysiwyg' : |
904 | 904 | case 'textarea' : |
905 | - $value = wp_kses_post( trim( $raw_value ) ); |
|
905 | + $value = wp_kses_post(trim($raw_value)); |
|
906 | 906 | break; |
907 | 907 | case 'multiselect' : |
908 | - $value = array_filter( array_map( 'give_clean', (array) $raw_value ) ); |
|
908 | + $value = array_filter(array_map('give_clean', (array) $raw_value)); |
|
909 | 909 | break; |
910 | 910 | default : |
911 | - $value = give_clean( $raw_value ); |
|
911 | + $value = give_clean($raw_value); |
|
912 | 912 | break; |
913 | 913 | } |
914 | 914 | |
@@ -917,37 +917,37 @@ discard block |
||
917 | 917 | * |
918 | 918 | * @since 1.8 |
919 | 919 | */ |
920 | - $value = apply_filters( 'give_admin_settings_sanitize_option', $value, $option, $raw_value ); |
|
920 | + $value = apply_filters('give_admin_settings_sanitize_option', $value, $option, $raw_value); |
|
921 | 921 | |
922 | 922 | /** |
923 | 923 | * Sanitize the value of an option by option name. |
924 | 924 | * |
925 | 925 | * @since 1.8 |
926 | 926 | */ |
927 | - $value = apply_filters( "give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value ); |
|
927 | + $value = apply_filters("give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value); |
|
928 | 928 | |
929 | - if ( is_null( $value ) ) { |
|
929 | + if (is_null($value)) { |
|
930 | 930 | continue; |
931 | 931 | } |
932 | 932 | |
933 | 933 | // Check if option is an array and handle that differently to single values. |
934 | - if ( $field_option_name && $setting_name ) { |
|
935 | - if ( ! isset( $update_options[ $field_option_name ] ) ) { |
|
936 | - $update_options[ $field_option_name ] = get_option( $field_option_name, array() ); |
|
934 | + if ($field_option_name && $setting_name) { |
|
935 | + if ( ! isset($update_options[$field_option_name])) { |
|
936 | + $update_options[$field_option_name] = get_option($field_option_name, array()); |
|
937 | 937 | } |
938 | - if ( ! is_array( $update_options[ $field_option_name ] ) ) { |
|
939 | - $update_options[ $field_option_name ] = array(); |
|
938 | + if ( ! is_array($update_options[$field_option_name])) { |
|
939 | + $update_options[$field_option_name] = array(); |
|
940 | 940 | } |
941 | - $update_options[ $field_option_name ][ $setting_name ] = $value; |
|
941 | + $update_options[$field_option_name][$setting_name] = $value; |
|
942 | 942 | } else { |
943 | - $update_options[ $field_option_name ] = $value; |
|
943 | + $update_options[$field_option_name] = $value; |
|
944 | 944 | } |
945 | 945 | } |
946 | 946 | |
947 | 947 | // Save all options in our array or there own option name i.e. option id. |
948 | - if ( empty( $option_name ) ) { |
|
949 | - foreach ( $update_options as $name => $value ) { |
|
950 | - update_option( $name, $value ); |
|
948 | + if (empty($option_name)) { |
|
949 | + foreach ($update_options as $name => $value) { |
|
950 | + update_option($name, $value); |
|
951 | 951 | |
952 | 952 | /** |
953 | 953 | * Trigger action. |
@@ -956,13 +956,13 @@ discard block |
||
956 | 956 | * |
957 | 957 | * @since 1.8 |
958 | 958 | */ |
959 | - do_action( "give_save_option_{$name}", $value, $name ); |
|
959 | + do_action("give_save_option_{$name}", $value, $name); |
|
960 | 960 | } |
961 | 961 | } else { |
962 | - $old_options = ( $old_options = get_option( $option_name ) ) ? $old_options : array(); |
|
963 | - $update_options = array_merge( $old_options, $update_options ); |
|
962 | + $old_options = ($old_options = get_option($option_name)) ? $old_options : array(); |
|
963 | + $update_options = array_merge($old_options, $update_options); |
|
964 | 964 | |
965 | - update_option( $option_name, $update_options ); |
|
965 | + update_option($option_name, $update_options); |
|
966 | 966 | |
967 | 967 | /** |
968 | 968 | * Trigger action. |
@@ -971,7 +971,7 @@ discard block |
||
971 | 971 | * |
972 | 972 | * @since 1.8 |
973 | 973 | */ |
974 | - do_action( "give_save_settings_{$option_name}", $update_options, $option_name ); |
|
974 | + do_action("give_save_settings_{$option_name}", $update_options, $option_name); |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | return true; |
@@ -2,12 +2,12 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * Admin View: Settings |
4 | 4 | */ |
5 | -if ( ! defined( 'ABSPATH' ) ) { |
|
5 | +if ( ! defined('ABSPATH')) { |
|
6 | 6 | exit; |
7 | 7 | } |
8 | 8 | |
9 | 9 | // Bailout: Do not output anything if setting tab is not defined. |
10 | -if ( ! empty( $tabs ) && array_key_exists( give_get_current_setting_tab(), $tabs ) ) : |
|
10 | +if ( ! empty($tabs) && array_key_exists(give_get_current_setting_tab(), $tabs)) : |
|
11 | 11 | /** |
12 | 12 | * Filter the form action. |
13 | 13 | * |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * |
18 | 18 | * @since 1.8 |
19 | 19 | */ |
20 | - $form_method = apply_filters( self::$setting_filter_prefix . '_form_method_tab_' . $current_tab, 'post' ); |
|
20 | + $form_method = apply_filters(self::$setting_filter_prefix.'_form_method_tab_'.$current_tab, 'post'); |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Filter the main form tab. |
@@ -29,17 +29,17 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @since 1.8 |
31 | 31 | */ |
32 | - $form_open_tag = apply_filters( self::$setting_filter_prefix . '_open_form', '<form method="' . $form_method . '" id="give-mainform" action="" enctype="multipart/form-data">' ); |
|
33 | - $form_close_tag = apply_filters( self::$setting_filter_prefix . '_close_form', '</form>' ); |
|
32 | + $form_open_tag = apply_filters(self::$setting_filter_prefix.'_open_form', '<form method="'.$form_method.'" id="give-mainform" action="" enctype="multipart/form-data">'); |
|
33 | + $form_close_tag = apply_filters(self::$setting_filter_prefix.'_close_form', '</form>'); |
|
34 | 34 | ?> |
35 | - <div class="wrap give-settings-page <?php echo self::$setting_filter_prefix . '-setting-page'; ?>"> |
|
35 | + <div class="wrap give-settings-page <?php echo self::$setting_filter_prefix.'-setting-page'; ?>"> |
|
36 | 36 | <?php |
37 | 37 | echo $form_open_tag; |
38 | 38 | |
39 | 39 | /* @var Give_Settings_Page $current_setting_obj */ |
40 | 40 | if ( |
41 | - ! empty( $current_setting_obj ) && |
|
42 | - method_exists( $current_setting_obj, 'get_heading_html' ) |
|
41 | + ! empty($current_setting_obj) && |
|
42 | + method_exists($current_setting_obj, 'get_heading_html') |
|
43 | 43 | ) { |
44 | 44 | echo $current_setting_obj->get_heading_html(); |
45 | 45 | } else { |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | // Backward compatibility. |
48 | 48 | echo sprintf( |
49 | 49 | '<h1 class="wp-heading-inline">%s</h1><hr class="wp-header-end">', |
50 | - esc_html( $tabs[ $current_tab ] ) |
|
50 | + esc_html($tabs[$current_tab]) |
|
51 | 51 | ); |
52 | 52 | } |
53 | 53 | |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | ?> |
56 | 56 | <div class="nav-tab-wrapper give-nav-tab-wrapper"> |
57 | 57 | <?php |
58 | - foreach ( $tabs as $name => $label ) { |
|
59 | - echo '<a href="' . admin_url( "edit.php?post_type=give_forms&page=" . self::$setting_filter_prefix . "&tab={$name}" ) . '" class="nav-tab ' . ( $current_tab === $name ? 'nav-tab-active' : 'give-mobile-hidden' ) . '">' . $label . '</a>'; |
|
58 | + foreach ($tabs as $name => $label) { |
|
59 | + echo '<a href="'.admin_url("edit.php?post_type=give_forms&page=".self::$setting_filter_prefix."&tab={$name}").'" class="nav-tab '.($current_tab === $name ? 'nav-tab-active' : 'give-mobile-hidden').'">'.$label.'</a>'; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @since 1.8 |
70 | 70 | */ |
71 | - do_action( self::$setting_filter_prefix . '_tabs' ); |
|
71 | + do_action(self::$setting_filter_prefix.'_tabs'); |
|
72 | 72 | ?> |
73 | 73 | </div> |
74 | 74 | <div class="give-sub-nav-tab-wrapper"> |
75 | - <a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e( 'View remaining setting tabs', 'give' ); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span> |
|
75 | + <a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e('View remaining setting tabs', 'give'); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span> |
|
76 | 76 | </a> |
77 | 77 | <nav class="give-sub-nav-tab give-hidden"></nav> |
78 | 78 | </div> |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @since 1.8 |
89 | 89 | */ |
90 | - do_action( self::$setting_filter_prefix . "_sections_{$current_tab}_page" ); |
|
90 | + do_action(self::$setting_filter_prefix."_sections_{$current_tab}_page"); |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Trigger Action. |
@@ -98,15 +98,15 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @since 1.8 |
100 | 100 | */ |
101 | - do_action( self::$setting_filter_prefix . "_settings_{$current_tab}_page" ); |
|
101 | + do_action(self::$setting_filter_prefix."_settings_{$current_tab}_page"); |
|
102 | 102 | |
103 | - if ( empty( $GLOBALS['give_hide_save_button'] ) ) : ?> |
|
103 | + if (empty($GLOBALS['give_hide_save_button'])) : ?> |
|
104 | 104 | <div class="give-submit-wrap"> |
105 | - <?php wp_nonce_field( 'give-save-settings', '_give-save-settings' ); ?> |
|
106 | - <input name="save" class="button-primary give-save-button" type="submit" value="<?php _e( 'Save changes', 'give' ); ?>"/> |
|
105 | + <?php wp_nonce_field('give-save-settings', '_give-save-settings'); ?> |
|
106 | + <input name="save" class="button-primary give-save-button" type="submit" value="<?php _e('Save changes', 'give'); ?>"/> |
|
107 | 107 | </div> |
108 | 108 | <?php endif; ?> |
109 | 109 | <?php echo $form_close_tag; ?> |
110 | 110 | </div> |
111 | -<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?> |
|
111 | +<?php else : echo '<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>'; ?> |
|
112 | 112 | <?php endif; ?> |
113 | 113 | \ No newline at end of file |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
19 | 19 | // Load WP_List_Table if not loaded. |
20 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
21 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
20 | +if ( ! class_exists('WP_List_Table')) { |
|
21 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | public function __construct() { |
62 | 62 | |
63 | 63 | // Set parent defaults. |
64 | - parent::__construct( array( |
|
65 | - 'singular' => __( 'Donor', 'give' ), // Singular name of the listed records. |
|
66 | - 'plural' => __( 'Donors', 'give' ), // Plural name of the listed records. |
|
64 | + parent::__construct(array( |
|
65 | + 'singular' => __('Donor', 'give'), // Singular name of the listed records. |
|
66 | + 'plural' => __('Donors', 'give'), // Plural name of the listed records. |
|
67 | 67 | 'ajax' => false, // Does this table support ajax?. |
68 | - ) ); |
|
68 | + )); |
|
69 | 69 | |
70 | 70 | } |
71 | 71 | |
@@ -80,23 +80,23 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return void |
82 | 82 | */ |
83 | - public function search_box( $text, $input_id ) { |
|
84 | - $input_id = $input_id . '-search-input'; |
|
83 | + public function search_box($text, $input_id) { |
|
84 | + $input_id = $input_id.'-search-input'; |
|
85 | 85 | |
86 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
87 | - echo sprintf( '<input type="hidden" name="orderby" value="%1$s" />', esc_attr( $_REQUEST['orderby'] ) ); |
|
86 | + if ( ! empty($_REQUEST['orderby'])) { |
|
87 | + echo sprintf('<input type="hidden" name="orderby" value="%1$s" />', esc_attr($_REQUEST['orderby'])); |
|
88 | 88 | } |
89 | 89 | |
90 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
91 | - echo sprintf( '<input type="hidden" name="order" value="%1$s" />', esc_attr( $_REQUEST['order'] ) ); |
|
90 | + if ( ! empty($_REQUEST['order'])) { |
|
91 | + echo sprintf('<input type="hidden" name="order" value="%1$s" />', esc_attr($_REQUEST['order'])); |
|
92 | 92 | } |
93 | 93 | ?> |
94 | 94 | <p class="search-box" role="search"> |
95 | 95 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
96 | 96 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
97 | - <?php submit_button( $text, 'button', false, false, array( |
|
97 | + <?php submit_button($text, 'button', false, false, array( |
|
98 | 98 | 'ID' => 'search-submit', |
99 | - ) ); ?> |
|
99 | + )); ?> |
|
100 | 100 | </p> |
101 | 101 | <?php |
102 | 102 | } |
@@ -112,32 +112,32 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return string Column Name. |
114 | 114 | */ |
115 | - public function column_default( $donor, $column_name ) { |
|
115 | + public function column_default($donor, $column_name) { |
|
116 | 116 | |
117 | - switch ( $column_name ) { |
|
117 | + switch ($column_name) { |
|
118 | 118 | |
119 | 119 | case 'num_donations' : |
120 | 120 | $value = sprintf( |
121 | 121 | '<a href="%s">%s</a>', |
122 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor['id'] ) ), |
|
123 | - esc_html( $donor['num_donations'] ) |
|
122 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($donor['id'])), |
|
123 | + esc_html($donor['num_donations']) |
|
124 | 124 | ); |
125 | 125 | break; |
126 | 126 | |
127 | 127 | case 'amount_spent' : |
128 | - $value = give_currency_filter( give_format_amount( $donor[ $column_name ], array( 'sanitize' => false ) ) ); |
|
128 | + $value = give_currency_filter(give_format_amount($donor[$column_name], array('sanitize' => false))); |
|
129 | 129 | break; |
130 | 130 | |
131 | 131 | case 'date_created' : |
132 | - $value = date_i18n( give_date_format(), strtotime( $donor['date_created'] ) ); |
|
132 | + $value = date_i18n(give_date_format(), strtotime($donor['date_created'])); |
|
133 | 133 | break; |
134 | 134 | |
135 | 135 | default: |
136 | - $value = isset( $donor[ $column_name ] ) ? $donor[ $column_name ] : null; |
|
136 | + $value = isset($donor[$column_name]) ? $donor[$column_name] : null; |
|
137 | 137 | break; |
138 | 138 | } |
139 | 139 | |
140 | - return apply_filters( "give_donors_column_{$column_name}", $value, $donor['id'] ); |
|
140 | + return apply_filters("give_donors_column_{$column_name}", $value, $donor['id']); |
|
141 | 141 | |
142 | 142 | } |
143 | 143 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @return string |
153 | 153 | */ |
154 | - public function column_cb( $donor ){ |
|
154 | + public function column_cb($donor) { |
|
155 | 155 | return sprintf( |
156 | 156 | '<input class="donor-selector" type="checkbox" name="%1$s[]" value="%2$d" data-name="%3$s" />', |
157 | 157 | $this->_args['singular'], |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return string |
172 | 172 | */ |
173 | - public function column_name( $donor ) { |
|
174 | - $name = '#' . $donor['id'] . ' '; |
|
175 | - $name .= ! empty( $donor['name'] ) ? $donor['name'] : '<em>' . __( 'Unnamed Donor', 'give' ) . '</em>'; |
|
176 | - $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ); |
|
177 | - $actions = $this->get_row_actions( $donor ); |
|
173 | + public function column_name($donor) { |
|
174 | + $name = '#'.$donor['id'].' '; |
|
175 | + $name .= ! empty($donor['name']) ? $donor['name'] : '<em>'.__('Unnamed Donor', 'give').'</em>'; |
|
176 | + $view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']); |
|
177 | + $actions = $this->get_row_actions($donor); |
|
178 | 178 | |
179 | - return '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>' . $this->row_actions( $actions ); |
|
179 | + return '<a href="'.esc_url($view_url).'">'.$name.'</a>'.$this->row_actions($actions); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | public function get_columns() { |
191 | 191 | $columns = array( |
192 | 192 | 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text. |
193 | - 'name' => __( 'Name', 'give' ), |
|
194 | - 'email' => __( 'Email', 'give' ), |
|
195 | - 'num_donations' => __( 'Donations', 'give' ), |
|
196 | - 'amount_spent' => __( 'Total Donated', 'give' ), |
|
197 | - 'date_created' => __( 'Date Created', 'give' ), |
|
193 | + 'name' => __('Name', 'give'), |
|
194 | + 'email' => __('Email', 'give'), |
|
195 | + 'num_donations' => __('Donations', 'give'), |
|
196 | + 'amount_spent' => __('Total Donated', 'give'), |
|
197 | + 'date_created' => __('Date Created', 'give'), |
|
198 | 198 | ); |
199 | 199 | |
200 | - return apply_filters( 'give_list_donors_columns', $columns ); |
|
200 | + return apply_filters('give_list_donors_columns', $columns); |
|
201 | 201 | |
202 | 202 | } |
203 | 203 | |
@@ -211,13 +211,13 @@ discard block |
||
211 | 211 | public function get_sortable_columns() { |
212 | 212 | |
213 | 213 | $columns = array( |
214 | - 'date_created' => array( 'date_created', true ), |
|
215 | - 'name' => array( 'name', true ), |
|
216 | - 'num_donations' => array( 'purchase_count', false ), |
|
217 | - 'amount_spent' => array( 'purchase_value', false ), |
|
214 | + 'date_created' => array('date_created', true), |
|
215 | + 'name' => array('name', true), |
|
216 | + 'num_donations' => array('purchase_count', false), |
|
217 | + 'amount_spent' => array('purchase_value', false), |
|
218 | 218 | ); |
219 | 219 | |
220 | - return apply_filters( 'give_list_donors_sortable_columns', $columns ); |
|
220 | + return apply_filters('give_list_donors_sortable_columns', $columns); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -230,15 +230,15 @@ discard block |
||
230 | 230 | * |
231 | 231 | * @return array An array of action links. |
232 | 232 | */ |
233 | - public function get_row_actions( $donor ) { |
|
233 | + public function get_row_actions($donor) { |
|
234 | 234 | |
235 | 235 | $actions = array( |
236 | - 'view' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ), sprintf( esc_attr__( 'View "%s"', 'give' ), $donor['name'] ), __( 'View Donor', 'give' ) ), |
|
237 | - 'notes' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor['id'] ), sprintf( esc_attr__( 'Notes for "%s"', 'give' ), $donor['name'] ), __( 'Notes', 'give' ) ), |
|
238 | - 'delete' => sprintf( '<a class="%1$s" href="#" aria-label="%2$s">%3$s</a>', 'give-single-donor-delete', sprintf( esc_attr__( 'Delete "%s"', 'give' ), $donor['name'] ), __( 'Delete', 'give' ) ), |
|
236 | + 'view' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']), sprintf(esc_attr__('View "%s"', 'give'), $donor['name']), __('View Donor', 'give')), |
|
237 | + 'notes' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor['id']), sprintf(esc_attr__('Notes for "%s"', 'give'), $donor['name']), __('Notes', 'give')), |
|
238 | + 'delete' => sprintf('<a class="%1$s" href="#" aria-label="%2$s">%3$s</a>', 'give-single-donor-delete', sprintf(esc_attr__('Delete "%s"', 'give'), $donor['name']), __('Delete', 'give')), |
|
239 | 239 | ); |
240 | 240 | |
241 | - return apply_filters( 'give_donor_row_actions', $actions, $donor ); |
|
241 | + return apply_filters('give_donor_row_actions', $actions, $donor); |
|
242 | 242 | |
243 | 243 | } |
244 | 244 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @return int Current page number. |
252 | 252 | */ |
253 | 253 | public function get_paged() { |
254 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
254 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * @return mixed string If search is present, false otherwise. |
264 | 264 | */ |
265 | 265 | public function get_search() { |
266 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
266 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function get_bulk_actions() { |
278 | 278 | $actions = array( |
279 | - 'delete' => __( 'Delete', 'give' ), |
|
279 | + 'delete' => __('Delete', 'give'), |
|
280 | 280 | ); |
281 | 281 | return $actions; |
282 | 282 | } |
@@ -289,19 +289,19 @@ discard block |
||
289 | 289 | * @access protected |
290 | 290 | * @since 1.8.16 |
291 | 291 | */ |
292 | - protected function display_tablenav( $which ) { |
|
293 | - if ( 'top' === $which ) { |
|
294 | - wp_nonce_field( 'bulk-' . $this->_args['plural'], '_wpnonce', false ); |
|
292 | + protected function display_tablenav($which) { |
|
293 | + if ('top' === $which) { |
|
294 | + wp_nonce_field('bulk-'.$this->_args['plural'], '_wpnonce', false); |
|
295 | 295 | } |
296 | 296 | ?> |
297 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
298 | - <?php if ( $this->has_items() ): ?> |
|
297 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
298 | + <?php if ($this->has_items()): ?> |
|
299 | 299 | <div class="alignleft actions bulkactions"> |
300 | - <?php $this->bulk_actions( $which ); ?> |
|
300 | + <?php $this->bulk_actions($which); ?> |
|
301 | 301 | </div> |
302 | 302 | <?php endif; |
303 | - $this->extra_tablenav( $which ); |
|
304 | - $this->pagination( $which ); |
|
303 | + $this->extra_tablenav($which); |
|
304 | + $this->pagination($which); |
|
305 | 305 | ?> |
306 | 306 | <br class="clear" /> |
307 | 307 | </div> |
@@ -322,13 +322,13 @@ discard block |
||
322 | 322 | |
323 | 323 | // Get donor query. |
324 | 324 | $args = $this->get_donor_query(); |
325 | - $donors = Give()->donors->get_donors( $args ); |
|
325 | + $donors = Give()->donors->get_donors($args); |
|
326 | 326 | |
327 | - if ( $donors ) { |
|
327 | + if ($donors) { |
|
328 | 328 | |
329 | - foreach ( $donors as $donor ) { |
|
329 | + foreach ($donors as $donor) { |
|
330 | 330 | |
331 | - $user_id = ! empty( $donor->user_id ) ? intval( $donor->user_id ) : 0; |
|
331 | + $user_id = ! empty($donor->user_id) ? intval($donor->user_id) : 0; |
|
332 | 332 | |
333 | 333 | $data[] = array( |
334 | 334 | 'id' => $donor->id, |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | } |
343 | 343 | } |
344 | 344 | |
345 | - return apply_filters( 'give_donors_column_query_data', $data ); |
|
345 | + return apply_filters('give_donors_column_query_data', $data); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -357,9 +357,9 @@ discard block |
||
357 | 357 | |
358 | 358 | $_donor_query['number'] = - 1; |
359 | 359 | $_donor_query['offset'] = 0; |
360 | - $donors = Give()->donors->get_donors( $_donor_query ); |
|
360 | + $donors = Give()->donors->get_donors($_donor_query); |
|
361 | 361 | |
362 | - return count( $donors ); |
|
362 | + return count($donors); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | /** |
@@ -372,10 +372,10 @@ discard block |
||
372 | 372 | */ |
373 | 373 | public function get_donor_query() { |
374 | 374 | $paged = $this->get_paged(); |
375 | - $offset = $this->per_page * ( $paged - 1 ); |
|
375 | + $offset = $this->per_page * ($paged - 1); |
|
376 | 376 | $search = $this->get_search(); |
377 | - $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC'; |
|
378 | - $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id'; |
|
377 | + $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; |
|
378 | + $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id'; |
|
379 | 379 | |
380 | 380 | $args = array( |
381 | 381 | 'number' => $this->per_page, |
@@ -384,10 +384,10 @@ discard block |
||
384 | 384 | 'orderby' => $orderby, |
385 | 385 | ); |
386 | 386 | |
387 | - if ( $search ) { |
|
388 | - if ( is_email( $search ) ) { |
|
387 | + if ($search) { |
|
388 | + if (is_email($search)) { |
|
389 | 389 | $args['email'] = $search; |
390 | - } elseif ( is_numeric( $search ) ) { |
|
390 | + } elseif (is_numeric($search)) { |
|
391 | 391 | $args['id'] = $search; |
392 | 392 | } else { |
393 | 393 | $args['name'] = $search; |
@@ -405,9 +405,9 @@ discard block |
||
405 | 405 | * @since 1.8.17 |
406 | 406 | * @access public |
407 | 407 | */ |
408 | - public function single_row( $item ) { |
|
409 | - echo sprintf( '<tr id="donor-%1$d" data-id="%2$d" data-name="%3$s">', $item['id'], $item['id'], $item['name'] ); |
|
410 | - $this->single_row_columns( $item ); |
|
408 | + public function single_row($item) { |
|
409 | + echo sprintf('<tr id="donor-%1$d" data-id="%2$d" data-name="%3$s">', $item['id'], $item['id'], $item['name']); |
|
410 | + $this->single_row_columns($item); |
|
411 | 411 | echo '</tr>'; |
412 | 412 | } |
413 | 413 | |
@@ -420,11 +420,11 @@ discard block |
||
420 | 420 | public function display() { |
421 | 421 | $singular = $this->_args['singular']; |
422 | 422 | |
423 | - $this->display_tablenav( 'top' ); |
|
423 | + $this->display_tablenav('top'); |
|
424 | 424 | |
425 | - $this->screen->render_screen_reader_content( 'heading_list' ); |
|
425 | + $this->screen->render_screen_reader_content('heading_list'); |
|
426 | 426 | ?> |
427 | - <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>"> |
|
427 | + <table class="wp-list-table <?php echo implode(' ', $this->get_table_classes()); ?>"> |
|
428 | 428 | <thead> |
429 | 429 | <tr> |
430 | 430 | <?php $this->print_column_headers(); ?> |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | </thead> |
433 | 433 | |
434 | 434 | <tbody id="the-list"<?php |
435 | - if ( $singular ) { |
|
435 | + if ($singular) { |
|
436 | 436 | echo " data-wp-lists='list:$singular'"; |
437 | 437 | } ?>> |
438 | 438 | <tr class="hidden"></tr> |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | <td colspan="6" class="colspanchange"> |
441 | 441 | |
442 | 442 | <fieldset class="inline-edit-col-left"> |
443 | - <legend class="inline-edit-legend"><?php _e( 'BULK DELETE', 'give' ); ?></legend> |
|
443 | + <legend class="inline-edit-legend"><?php _e('BULK DELETE', 'give'); ?></legend> |
|
444 | 444 | <div class="inline-edit-col"> |
445 | 445 | <div id="bulk-titles"> |
446 | 446 | <div id="give-bulk-donors" class="give-bulk-donors"> |
@@ -453,22 +453,22 @@ discard block |
||
453 | 453 | <div class="inline-edit-col"> |
454 | 454 | <label> |
455 | 455 | <input id="give-delete-donor-confirm" type="checkbox" name="give-delete-donor-confirm"/> |
456 | - <?php _e( 'Are you sure you want to delete the selected donor(s)?', 'give' ); ?> |
|
456 | + <?php _e('Are you sure you want to delete the selected donor(s)?', 'give'); ?> |
|
457 | 457 | </label> |
458 | 458 | <label> |
459 | 459 | <input id="give-delete-donor-records" type="checkbox" name="give-delete-donor-records"/> |
460 | - <?php _e( 'Delete all associated donations and records?', 'give' ); ?> |
|
460 | + <?php _e('Delete all associated donations and records?', 'give'); ?> |
|
461 | 461 | </label> |
462 | 462 | </div> |
463 | 463 | </fieldset> |
464 | 464 | |
465 | 465 | <p class="submit inline-edit-save"> |
466 | 466 | <input type="hidden" name="give_action" value="delete_donor"/> |
467 | - <input type="hidden" name="s" value="<?php echo ( ! empty( $_GET['s'] ) ) ? $_GET['s'] : ''; ?>"/> |
|
468 | - <input type="hidden" name="orderby" value="<?php echo ( ! empty( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id'; ?>"/> |
|
469 | - <input type="hidden" name="order" value="<?php echo ( ! empty( $_GET['order'] ) ) ? $_GET['order'] : 'desc'; ?>"/> |
|
470 | - <button type="button" id="give-bulk-delete-cancel" class="button cancel alignleft"><?php _e( 'Cancel', 'give' ); ?></button> |
|
471 | - <input type="submit" id="give-bulk-delete-button" disabled class="button button-primary alignright" value="<?php _e( 'Delete', 'give' ); ?>"> |
|
467 | + <input type="hidden" name="s" value="<?php echo ( ! empty($_GET['s'])) ? $_GET['s'] : ''; ?>"/> |
|
468 | + <input type="hidden" name="orderby" value="<?php echo ( ! empty($_GET['orderby'])) ? $_GET['orderby'] : 'id'; ?>"/> |
|
469 | + <input type="hidden" name="order" value="<?php echo ( ! empty($_GET['order'])) ? $_GET['order'] : 'desc'; ?>"/> |
|
470 | + <button type="button" id="give-bulk-delete-cancel" class="button cancel alignleft"><?php _e('Cancel', 'give'); ?></button> |
|
471 | + <input type="submit" id="give-bulk-delete-button" disabled class="button button-primary alignright" value="<?php _e('Delete', 'give'); ?>"> |
|
472 | 472 | <br class="clear"> |
473 | 473 | </p> |
474 | 474 | </td> |
@@ -478,13 +478,13 @@ discard block |
||
478 | 478 | |
479 | 479 | <tfoot> |
480 | 480 | <tr> |
481 | - <?php $this->print_column_headers( false ); ?> |
|
481 | + <?php $this->print_column_headers(false); ?> |
|
482 | 482 | </tr> |
483 | 483 | </tfoot> |
484 | 484 | |
485 | 485 | </table> |
486 | 486 | <?php |
487 | - $this->display_tablenav( 'bottom' ); |
|
487 | + $this->display_tablenav('bottom'); |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | /** |
@@ -501,16 +501,16 @@ discard block |
||
501 | 501 | $hidden = array(); // No hidden columns. |
502 | 502 | $sortable = $this->get_sortable_columns(); |
503 | 503 | |
504 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
504 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
505 | 505 | |
506 | 506 | $this->items = $this->donor_data(); |
507 | 507 | |
508 | 508 | $this->total = $this->get_donor_count(); |
509 | 509 | |
510 | - $this->set_pagination_args( array( |
|
510 | + $this->set_pagination_args(array( |
|
511 | 511 | 'total_items' => $this->total, |
512 | 512 | 'per_page' => $this->per_page, |
513 | - 'total_pages' => ceil( $this->total / $this->per_page ), |
|
514 | - ) ); |
|
513 | + 'total_pages' => ceil($this->total / $this->per_page), |
|
514 | + )); |
|
515 | 515 | } |
516 | 516 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | */ |
25 | 25 | function give_donors_page() { |
26 | 26 | $default_views = give_donor_views(); |
27 | - $requested_view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : 'donors'; |
|
28 | - if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) { |
|
29 | - give_render_donor_view( $requested_view, $default_views ); |
|
27 | + $requested_view = isset($_GET['view']) ? sanitize_text_field($_GET['view']) : 'donors'; |
|
28 | + if (array_key_exists($requested_view, $default_views) && function_exists($default_views[$requested_view])) { |
|
29 | + give_render_donor_view($requested_view, $default_views); |
|
30 | 30 | } else { |
31 | 31 | give_donors_list(); |
32 | 32 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | $views = array(); |
44 | 44 | |
45 | - return apply_filters( 'give_donor_views', $views ); |
|
45 | + return apply_filters('give_donor_views', $views); |
|
46 | 46 | |
47 | 47 | } |
48 | 48 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | $tabs = array(); |
58 | 58 | |
59 | - return apply_filters( 'give_donor_tabs', $tabs ); |
|
59 | + return apply_filters('give_donor_tabs', $tabs); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @return void |
68 | 68 | */ |
69 | 69 | function give_donors_list() { |
70 | - include dirname( __FILE__ ) . '/class-donor-table.php'; |
|
70 | + include dirname(__FILE__).'/class-donor-table.php'; |
|
71 | 71 | |
72 | 72 | $donors_table = new Give_Donor_List_Table(); |
73 | 73 | $donors_table->prepare_items(); |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @since 1.0 |
82 | 82 | */ |
83 | - do_action( 'give_donors_table_top' ); |
|
83 | + do_action('give_donors_table_top'); |
|
84 | 84 | ?> |
85 | 85 | |
86 | 86 | <hr class="wp-header-end"> |
87 | - <form id="give-donors-search-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>"> |
|
88 | - <?php $donors_table->search_box( __( 'Search Donors', 'give' ), 'give-donors' ); ?> |
|
87 | + <form id="give-donors-search-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors'); ?>"> |
|
88 | + <?php $donors_table->search_box(__('Search Donors', 'give'), 'give-donors'); ?> |
|
89 | 89 | <input type="hidden" name="post_type" value="give_forms" /> |
90 | 90 | <input type="hidden" name="page" value="give-donors" /> |
91 | 91 | <input type="hidden" name="view" value="donors" /> |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @since 1.0 |
104 | 104 | */ |
105 | - do_action( 'give_donors_table_bottom' ); |
|
105 | + do_action('give_donors_table_bottom'); |
|
106 | 106 | ?> |
107 | 107 | </div> |
108 | 108 | <?php |
@@ -118,33 +118,33 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @return void |
120 | 120 | */ |
121 | -function give_render_donor_view( $view, $callbacks ) { |
|
121 | +function give_render_donor_view($view, $callbacks) { |
|
122 | 122 | |
123 | 123 | $render = true; |
124 | 124 | |
125 | - $donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' ); |
|
125 | + $donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports'); |
|
126 | 126 | |
127 | - if ( ! current_user_can( $donor_view_role ) ) { |
|
128 | - give_set_error( 'give-no-access', __( 'You are not permitted to view this data.', 'give' ) ); |
|
127 | + if ( ! current_user_can($donor_view_role)) { |
|
128 | + give_set_error('give-no-access', __('You are not permitted to view this data.', 'give')); |
|
129 | 129 | $render = false; |
130 | 130 | } |
131 | 131 | |
132 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
133 | - give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) ); |
|
132 | + if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
133 | + give_set_error('give-invalid_donor', __('Invalid Donor ID.', 'give')); |
|
134 | 134 | $render = false; |
135 | 135 | } |
136 | 136 | |
137 | 137 | $donor_id = (int) $_GET['id']; |
138 | - $reconnect_user_id = ! empty( $_GET['user_id'] ) ? (int) $_GET['user_id'] : ''; |
|
139 | - $donor = new Give_Donor( $donor_id ); |
|
138 | + $reconnect_user_id = ! empty($_GET['user_id']) ? (int) $_GET['user_id'] : ''; |
|
139 | + $donor = new Give_Donor($donor_id); |
|
140 | 140 | |
141 | 141 | // Reconnect User with Donor profile. |
142 | - if( $reconnect_user_id ) { |
|
143 | - give_connect_user_donor_profile( $donor, array( 'user_id' => $reconnect_user_id ), array() ); |
|
142 | + if ($reconnect_user_id) { |
|
143 | + give_connect_user_donor_profile($donor, array('user_id' => $reconnect_user_id), array()); |
|
144 | 144 | } |
145 | 145 | |
146 | - if ( empty( $donor->id ) ) { |
|
147 | - give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) ); |
|
146 | + if (empty($donor->id)) { |
|
147 | + give_set_error('give-invalid_donor', __('Invalid Donor ID.', 'give')); |
|
148 | 148 | $render = false; |
149 | 149 | } |
150 | 150 | |
@@ -153,9 +153,9 @@ discard block |
||
153 | 153 | |
154 | 154 | <div class='wrap'> |
155 | 155 | |
156 | - <?php if ( give_get_errors() ) : ?> |
|
156 | + <?php if (give_get_errors()) : ?> |
|
157 | 157 | <div class="error settings-error"> |
158 | - <?php Give()->notices->render_frontend_notices( 0 ); ?> |
|
158 | + <?php Give()->notices->render_frontend_notices(0); ?> |
|
159 | 159 | </div> |
160 | 160 | <?php endif; ?> |
161 | 161 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | <?php |
164 | 164 | printf( |
165 | 165 | /* translators: %s: donor number */ |
166 | - esc_html__( 'Donor %s', 'give' ), |
|
166 | + esc_html__('Donor %s', 'give'), |
|
167 | 167 | $donor_id |
168 | 168 | ); |
169 | 169 | ?> |
@@ -171,26 +171,26 @@ discard block |
||
171 | 171 | |
172 | 172 | <hr class="wp-header-end"> |
173 | 173 | |
174 | - <?php if ( $donor && $render ) : ?> |
|
174 | + <?php if ($donor && $render) : ?> |
|
175 | 175 | |
176 | 176 | <h2 class="nav-tab-wrapper"> |
177 | 177 | <?php |
178 | - foreach ( $donor_tabs as $key => $tab ) : |
|
178 | + foreach ($donor_tabs as $key => $tab) : |
|
179 | 179 | $active = $key === $view ? true : false; |
180 | 180 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
181 | 181 | printf( |
182 | - '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>' . "\n", |
|
183 | - esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $donor->id ) ), |
|
184 | - esc_attr( $class ), |
|
185 | - sanitize_html_class( $tab['dashicon'] ), |
|
186 | - esc_html( $tab['title'] ) |
|
182 | + '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>'."\n", |
|
183 | + esc_url(admin_url('edit.php?post_type=give_forms&page=give-donors&view='.$key.'&id='.$donor->id)), |
|
184 | + esc_attr($class), |
|
185 | + sanitize_html_class($tab['dashicon']), |
|
186 | + esc_html($tab['title']) |
|
187 | 187 | ); |
188 | 188 | endforeach; |
189 | 189 | ?> |
190 | 190 | </h2> |
191 | 191 | |
192 | 192 | <div id="give-donor-card-wrapper"> |
193 | - <?php $callbacks[ $view ]( $donor ) ?> |
|
193 | + <?php $callbacks[$view]($donor) ?> |
|
194 | 194 | </div> |
195 | 195 | |
196 | 196 | <?php endif; ?> |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @return void |
212 | 212 | */ |
213 | -function give_donor_view( $donor ) { |
|
213 | +function give_donor_view($donor) { |
|
214 | 214 | |
215 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
215 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
216 | 216 | |
217 | 217 | /** |
218 | 218 | * Fires in donor profile screen, above the donor card. |
@@ -221,32 +221,32 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @param object $donor The donor object being displayed. |
223 | 223 | */ |
224 | - do_action( 'give_donor_card_top', $donor ); |
|
224 | + do_action('give_donor_card_top', $donor); |
|
225 | 225 | ?> |
226 | 226 | |
227 | 227 | <div id="donor-summary" class="info-wrapper donor-section postbox"> |
228 | 228 | |
229 | - <form id="edit-donor-info" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>"> |
|
229 | + <form id="edit-donor-info" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); ?>"> |
|
230 | 230 | |
231 | 231 | <div class="donor-info"> |
232 | 232 | |
233 | 233 | <div class="donor-bio-header clearfix"> |
234 | 234 | |
235 | 235 | <div class="avatar-wrap left" id="donor-avatar"> |
236 | - <?php echo get_avatar( $donor->email ); ?> |
|
236 | + <?php echo get_avatar($donor->email); ?> |
|
237 | 237 | </div> |
238 | 238 | |
239 | 239 | <div id="donor-name-wrap" class="left"> |
240 | 240 | <span class="donor-id">#<?php echo $donor->id; ?></span> |
241 | - <span class="donor-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr( $donor->name ); ?>" placeholder="<?php _e( 'Donor Name', 'give' ); ?>" /></span> |
|
241 | + <span class="donor-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr($donor->name); ?>" placeholder="<?php _e('Donor Name', 'give'); ?>" /></span> |
|
242 | 242 | <span class="donor-name info-item editable"><span data-key="name"><?php echo $donor->name; ?></span></span> |
243 | 243 | </div> |
244 | 244 | <p class="donor-since info-item"> |
245 | - <?php _e( 'Donor since', 'give' ); ?> |
|
246 | - <?php echo date_i18n( give_date_format(), strtotime( $donor->date_created ) ) ?> |
|
245 | + <?php _e('Donor since', 'give'); ?> |
|
246 | + <?php echo date_i18n(give_date_format(), strtotime($donor->date_created)) ?> |
|
247 | 247 | </p> |
248 | - <?php if ( current_user_can( $donor_edit_role ) ) : ?> |
|
249 | - <a href="#" id="edit-donor" class="button info-item editable donor-edit-link"><?php _e( 'Edit Donor', 'give' ); ?></a> |
|
248 | + <?php if (current_user_can($donor_edit_role)) : ?> |
|
249 | + <a href="#" id="edit-donor" class="button info-item editable donor-edit-link"><?php _e('Edit Donor', 'give'); ?></a> |
|
250 | 250 | <?php endif; ?> |
251 | 251 | </div> |
252 | 252 | <!-- /donor-bio-header --> |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | <table class="widefat"> |
257 | 257 | <tbody> |
258 | 258 | <tr class="alternate"> |
259 | - <th scope="col"><label for="tablecell"><?php _e( 'User:', 'give' ); ?></label></th> |
|
259 | + <th scope="col"><label for="tablecell"><?php _e('User:', 'give'); ?></label></th> |
|
260 | 260 | <td> |
261 | 261 | <span class="donor-user-id info-item edit-item"> |
262 | 262 | <?php |
@@ -273,48 +273,48 @@ discard block |
||
273 | 273 | 'data' => $data_atts, |
274 | 274 | ); |
275 | 275 | |
276 | - if ( ! empty( $user_id ) ) { |
|
277 | - $userdata = get_userdata( $user_id ); |
|
276 | + if ( ! empty($user_id)) { |
|
277 | + $userdata = get_userdata($user_id); |
|
278 | 278 | $user_args['selected'] = $user_id; |
279 | 279 | } |
280 | 280 | |
281 | - echo Give()->html->ajax_user_search( $user_args ); |
|
281 | + echo Give()->html->ajax_user_search($user_args); |
|
282 | 282 | ?> |
283 | 283 | </span> |
284 | 284 | |
285 | 285 | <span class="donor-user-id info-item editable"> |
286 | - <?php if ( ! empty( $userdata ) ) { ?> |
|
287 | - <span data-key="user_id">#<?php echo $donor->user_id . ' - ' . $userdata->display_name; ?></span> |
|
286 | + <?php if ( ! empty($userdata)) { ?> |
|
287 | + <span data-key="user_id">#<?php echo $donor->user_id.' - '.$userdata->display_name; ?></span> |
|
288 | 288 | <?php } else { ?> |
289 | - <span data-key="user_id"><?php _e( 'None', 'give' ); ?></span> |
|
289 | + <span data-key="user_id"><?php _e('None', 'give'); ?></span> |
|
290 | 290 | <?php } ?> |
291 | - <?php if ( current_user_can( $donor_edit_role ) && intval( $donor->user_id ) > 0 ) { ?> |
|
291 | + <?php if (current_user_can($donor_edit_role) && intval($donor->user_id) > 0) { ?> |
|
292 | 292 | <span class="disconnect-user"> |
293 | 293 | - |
294 | - <a id="disconnect-donor" href="#disconnect" aria-label="<?php _e( 'Disconnects the current user ID from this donor record.', 'give' ); ?>"> |
|
295 | - <?php _e( 'Disconnect User', 'give' ); ?> |
|
294 | + <a id="disconnect-donor" href="#disconnect" aria-label="<?php _e('Disconnects the current user ID from this donor record.', 'give'); ?>"> |
|
295 | + <?php _e('Disconnect User', 'give'); ?> |
|
296 | 296 | </a> |
297 | 297 | </span> |
298 | 298 | <span class="view-user-profile"> |
299 | 299 | | |
300 | - <a id="view-user-profile" href="<?php echo 'user-edit.php?user_id=' . $donor->user_id; ?>" aria-label="<?php _e( 'View User Profile of current user ID.', 'give' ); ?>"> |
|
301 | - <?php _e( 'View User Profile', 'give' ); ?> |
|
300 | + <a id="view-user-profile" href="<?php echo 'user-edit.php?user_id='.$donor->user_id; ?>" aria-label="<?php _e('View User Profile of current user ID.', 'give'); ?>"> |
|
301 | + <?php _e('View User Profile', 'give'); ?> |
|
302 | 302 | </a> |
303 | 303 | </span> |
304 | 304 | <?php } ?> |
305 | 305 | </span> |
306 | 306 | </td> |
307 | 307 | </tr> |
308 | - <?php if ( isset( $donor->user_id ) && $donor->user_id > 0 ) : ?> |
|
308 | + <?php if (isset($donor->user_id) && $donor->user_id > 0) : ?> |
|
309 | 309 | |
310 | 310 | <tr> |
311 | - <th scope="col"><?php _e( 'Address:', 'give' ); ?></th> |
|
311 | + <th scope="col"><?php _e('Address:', 'give'); ?></th> |
|
312 | 312 | <td class="row-title"> |
313 | 313 | |
314 | 314 | <div class="donor-address-wrapper"> |
315 | 315 | |
316 | 316 | <?php |
317 | - $address = get_user_meta( $donor->user_id, '_give_user_address', true ); |
|
317 | + $address = get_user_meta($donor->user_id, '_give_user_address', true); |
|
318 | 318 | $defaults = array( |
319 | 319 | 'line1' => '', |
320 | 320 | 'line2' => '', |
@@ -324,10 +324,10 @@ discard block |
||
324 | 324 | 'zip' => '', |
325 | 325 | ); |
326 | 326 | |
327 | - $address = wp_parse_args( $address, $defaults ); |
|
327 | + $address = wp_parse_args($address, $defaults); |
|
328 | 328 | ?> |
329 | 329 | |
330 | - <?php if ( ! empty( $address ) ) { ?> |
|
330 | + <?php if ( ! empty($address)) { ?> |
|
331 | 331 | <span class="donor-address info-item editable"> |
332 | 332 | <span class="info-item" data-key="line1"><?php echo $address['line1']; ?></span> |
333 | 333 | <span class="info-item" data-key="line2"><?php echo $address['line2']; ?></span> |
@@ -344,8 +344,8 @@ discard block |
||
344 | 344 | |
345 | 345 | // For State. |
346 | 346 | $selected_state = give_get_state(); |
347 | - $states = give_get_states( $selected_country ); |
|
348 | - $selected_state = ( isset( $address['state'] ) ? $address['state'] : $selected_state ); |
|
347 | + $states = give_get_states($selected_country); |
|
348 | + $selected_state = (isset($address['state']) ? $address['state'] : $selected_state); |
|
349 | 349 | |
350 | 350 | // Get the country list that does not have any states init. |
351 | 351 | $no_states_country = give_no_states_country_list(); |
@@ -353,32 +353,32 @@ discard block |
||
353 | 353 | <span class="donor-address info-item edit-item"> |
354 | 354 | <select data-key="country" name="customerinfo[country]" id="billing_country" class="billing_country give-select edit-item"> |
355 | 355 | <?php |
356 | - foreach ( $countries as $country_code => $country ) { |
|
357 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
356 | + foreach ($countries as $country_code => $country) { |
|
357 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
358 | 358 | } |
359 | 359 | ?> |
360 | 360 | </select> |
361 | - <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php _e( 'Address 1', 'give' ); ?>" value="<?php echo $address['line1']; ?>" /> |
|
362 | - <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php _e( 'Address 2', 'give' ); ?>" value="<?php echo $address['line2']; ?>" /> |
|
363 | - <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php _e( 'City', 'give' ); ?>" value="<?php echo $address['city']; ?>" /> |
|
361 | + <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php _e('Address 1', 'give'); ?>" value="<?php echo $address['line1']; ?>" /> |
|
362 | + <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php _e('Address 2', 'give'); ?>" value="<?php echo $address['line2']; ?>" /> |
|
363 | + <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php _e('City', 'give'); ?>" value="<?php echo $address['city']; ?>" /> |
|
364 | 364 | <?php |
365 | - if ( ! empty( $states ) ) { |
|
365 | + if ( ! empty($states)) { |
|
366 | 366 | ?> |
367 | 367 | <select data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-select info-item"> |
368 | 368 | <?php |
369 | - foreach ( $states as $state_code => $state ) { |
|
370 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
369 | + foreach ($states as $state_code => $state) { |
|
370 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
371 | 371 | } |
372 | 372 | ?> |
373 | 373 | </select> |
374 | 374 | <?php |
375 | 375 | } else { |
376 | 376 | ?> |
377 | - <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item <?php echo ( ! empty( $selected_country ) && array_key_exists( $selected_country, $no_states_country ) ? 'give-hidden' : '' ); ?>" placeholder="<?php _e( 'State / Province / County', 'give' ); ?>" /> |
|
377 | + <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item <?php echo ( ! empty($selected_country) && array_key_exists($selected_country, $no_states_country) ? 'give-hidden' : ''); ?>" placeholder="<?php _e('State / Province / County', 'give'); ?>" /> |
|
378 | 378 | <?php |
379 | 379 | } |
380 | 380 | ?> |
381 | - <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php _e( 'Zip / Postal Code', 'give' ); ?>" value="<?php echo $address['zip']; ?>" /> |
|
381 | + <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php _e('Zip / Postal Code', 'give'); ?>" value="<?php echo $address['zip']; ?>" /> |
|
382 | 382 | </span> |
383 | 383 | |
384 | 384 | </div> |
@@ -394,10 +394,10 @@ discard block |
||
394 | 394 | |
395 | 395 | <span id="donor-edit-actions" class="edit-item"> |
396 | 396 | <input type="hidden" data-key="id" name="customerinfo[id]" value="<?php echo $donor->id; ?>" /> |
397 | - <?php wp_nonce_field( 'edit-donor', '_wpnonce', false, true ); ?> |
|
397 | + <?php wp_nonce_field('edit-donor', '_wpnonce', false, true); ?> |
|
398 | 398 | <input type="hidden" name="give_action" value="edit-donor" /> |
399 | - <input type="submit" id="give-edit-donor-save" class="button-secondary" value="<?php _e( 'Update Donor', 'give' ); ?>" /> |
|
400 | - <a id="give-edit-donor-cancel" href="" class="delete"><?php _e( 'Cancel', 'give' ); ?></a> |
|
399 | + <input type="submit" id="give-edit-donor-save" class="button-secondary" value="<?php _e('Update Donor', 'give'); ?>" /> |
|
400 | + <a id="give-edit-donor-cancel" href="" class="delete"><?php _e('Cancel', 'give'); ?></a> |
|
401 | 401 | </span> |
402 | 402 | |
403 | 403 | </form> |
@@ -412,24 +412,24 @@ discard block |
||
412 | 412 | * |
413 | 413 | * @param object $donor The donor object being displayed. |
414 | 414 | */ |
415 | - do_action( 'give_donor_before_stats', $donor ); |
|
415 | + do_action('give_donor_before_stats', $donor); |
|
416 | 416 | ?> |
417 | 417 | |
418 | 418 | <div id="donor-stats-wrapper" class="donor-section postbox clear"> |
419 | 419 | <ul> |
420 | 420 | <li> |
421 | - <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor->id ) ); ?>"> |
|
421 | + <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($donor->id)); ?>"> |
|
422 | 422 | <span class="dashicons dashicons-heart"></span> |
423 | 423 | <?php |
424 | 424 | // Completed Donations. |
425 | - $completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give' ), $donor->purchase_count ); |
|
426 | - echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $donor ); |
|
425 | + $completed_donations_text = sprintf(_n('%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give'), $donor->purchase_count); |
|
426 | + echo apply_filters('give_donor_completed_donations', $completed_donations_text, $donor); |
|
427 | 427 | ?> |
428 | 428 | </a> |
429 | 429 | </li> |
430 | 430 | <li> |
431 | 431 | <span class="dashicons dashicons-chart-area"></span> |
432 | - <?php echo give_currency_filter( give_format_amount( $donor->get_total_donation_amount(), array( 'sanitize' => false ) ) ); ?> <?php _e( 'Lifetime Donations', 'give' ); ?> |
|
432 | + <?php echo give_currency_filter(give_format_amount($donor->get_total_donation_amount(), array('sanitize' => false))); ?> <?php _e('Lifetime Donations', 'give'); ?> |
|
433 | 433 | </li> |
434 | 434 | <?php |
435 | 435 | /** |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | * |
442 | 442 | * @param object $donor The donor object being displayed. |
443 | 443 | */ |
444 | - do_action( 'give_donor_stats_list', $donor ); |
|
444 | + do_action('give_donor_stats_list', $donor); |
|
445 | 445 | ?> |
446 | 446 | </ul> |
447 | 447 | </div> |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * |
455 | 455 | * @param object $donor The donor object being displayed. |
456 | 456 | */ |
457 | - do_action( 'give_donor_before_tables_wrapper', $donor ); |
|
457 | + do_action('give_donor_before_tables_wrapper', $donor); |
|
458 | 458 | ?> |
459 | 459 | |
460 | 460 | <div id="donor-tables-wrapper" class="donor-section"> |
@@ -467,46 +467,46 @@ discard block |
||
467 | 467 | * |
468 | 468 | * @param object $donor The donor object being displayed. |
469 | 469 | */ |
470 | - do_action( 'give_donor_before_tables', $donor ); |
|
470 | + do_action('give_donor_before_tables', $donor); |
|
471 | 471 | ?> |
472 | 472 | |
473 | - <h3><?php _e( 'Donor Emails', 'give' ); ?></h3> |
|
473 | + <h3><?php _e('Donor Emails', 'give'); ?></h3> |
|
474 | 474 | |
475 | 475 | <table class="wp-list-table widefat striped emails"> |
476 | 476 | <thead> |
477 | 477 | <tr> |
478 | - <th><?php _e( 'Email', 'give' ); ?></th> |
|
479 | - <th><?php _e( 'Actions', 'give' ); ?></th> |
|
478 | + <th><?php _e('Email', 'give'); ?></th> |
|
479 | + <th><?php _e('Actions', 'give'); ?></th> |
|
480 | 480 | </tr> |
481 | 481 | </thead> |
482 | 482 | |
483 | 483 | <tbody> |
484 | - <?php if ( ! empty( $donor->emails ) ) { ?> |
|
484 | + <?php if ( ! empty($donor->emails)) { ?> |
|
485 | 485 | |
486 | - <?php foreach ( $donor->emails as $key => $email ) : ?> |
|
486 | + <?php foreach ($donor->emails as $key => $email) : ?> |
|
487 | 487 | <tr data-key="<?php echo $key; ?>"> |
488 | 488 | <td> |
489 | 489 | <?php echo $email; ?> |
490 | - <?php if ( 'primary' === $key ) : ?> |
|
490 | + <?php if ('primary' === $key) : ?> |
|
491 | 491 | <span class="dashicons dashicons-star-filled primary-email-icon"></span> |
492 | 492 | <?php endif; ?> |
493 | 493 | </td> |
494 | 494 | <td> |
495 | - <?php if ( 'primary' !== $key ) : ?> |
|
495 | + <?php if ('primary' !== $key) : ?> |
|
496 | 496 | <?php |
497 | - $base_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); |
|
498 | - $promote_url = wp_nonce_url( add_query_arg( array( |
|
499 | - 'email' => rawurlencode( $email ), |
|
497 | + $base_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); |
|
498 | + $promote_url = wp_nonce_url(add_query_arg(array( |
|
499 | + 'email' => rawurlencode($email), |
|
500 | 500 | 'give_action' => 'set_donor_primary_email', |
501 | - ), $base_url ), 'give-set-donor-primary-email' ); |
|
502 | - $remove_url = wp_nonce_url( add_query_arg( array( |
|
503 | - 'email' => rawurlencode( $email ), |
|
501 | + ), $base_url), 'give-set-donor-primary-email'); |
|
502 | + $remove_url = wp_nonce_url(add_query_arg(array( |
|
503 | + 'email' => rawurlencode($email), |
|
504 | 504 | 'give_action' => 'remove_donor_email', |
505 | - ), $base_url ), 'give-remove-donor-email' ); |
|
505 | + ), $base_url), 'give-remove-donor-email'); |
|
506 | 506 | ?> |
507 | - <a href="<?php echo $promote_url; ?>"><?php _e( 'Make Primary', 'give' ); ?></a> |
|
507 | + <a href="<?php echo $promote_url; ?>"><?php _e('Make Primary', 'give'); ?></a> |
|
508 | 508 | | |
509 | - <a href="<?php echo $remove_url; ?>" class="delete"><?php _e( 'Remove', 'give' ); ?></a> |
|
509 | + <a href="<?php echo $remove_url; ?>" class="delete"><?php _e('Remove', 'give'); ?></a> |
|
510 | 510 | <?php endif; ?> |
511 | 511 | </td> |
512 | 512 | </tr> |
@@ -516,59 +516,59 @@ discard block |
||
516 | 516 | <td colspan="2" class="add-donor-email-td"> |
517 | 517 | <div class="add-donor-email-wrapper"> |
518 | 518 | <input type="hidden" name="donor-id" value="<?php echo $donor->id; ?>" /> |
519 | - <?php wp_nonce_field( 'give_add_donor_email', 'add_email_nonce', false, true ); ?> |
|
520 | - <input type="email" name="additional-email" value="" placeholder="<?php _e( 'Email Address', 'give' ); ?>" /> |
|
521 | - <input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" /> <label for="make-additional-primary"><?php _e( 'Make Primary', 'give' ); ?></label> |
|
522 | - <button class="button-secondary give-add-donor-email" id="add-donor-email"><?php _e( 'Add Email', 'give' ); ?></button> |
|
519 | + <?php wp_nonce_field('give_add_donor_email', 'add_email_nonce', false, true); ?> |
|
520 | + <input type="email" name="additional-email" value="" placeholder="<?php _e('Email Address', 'give'); ?>" /> |
|
521 | + <input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" /> <label for="make-additional-primary"><?php _e('Make Primary', 'give'); ?></label> |
|
522 | + <button class="button-secondary give-add-donor-email" id="add-donor-email"><?php _e('Add Email', 'give'); ?></button> |
|
523 | 523 | <span class="spinner"></span> |
524 | 524 | </div> |
525 | 525 | <div class="notice-wrap"></div> |
526 | 526 | </td> |
527 | 527 | </tr> |
528 | 528 | <?php } else { ?> |
529 | - <tr><td colspan="2"><?php _e( 'No Emails Found', 'give' ); ?></td></tr> |
|
529 | + <tr><td colspan="2"><?php _e('No Emails Found', 'give'); ?></td></tr> |
|
530 | 530 | <?php }// End if(). |
531 | 531 | ?> |
532 | 532 | </tbody> |
533 | 533 | </table> |
534 | 534 | |
535 | - <h3><?php _e( 'Recent Donations', 'give' ); ?></h3> |
|
535 | + <h3><?php _e('Recent Donations', 'give'); ?></h3> |
|
536 | 536 | <?php |
537 | - $payment_ids = explode( ',', $donor->payment_ids ); |
|
538 | - $payments = give_get_payments( array( |
|
537 | + $payment_ids = explode(',', $donor->payment_ids); |
|
538 | + $payments = give_get_payments(array( |
|
539 | 539 | 'post__in' => $payment_ids, |
540 | - ) ); |
|
541 | - $payments = array_slice( $payments, 0, 10 ); |
|
540 | + )); |
|
541 | + $payments = array_slice($payments, 0, 10); |
|
542 | 542 | ?> |
543 | 543 | <table class="wp-list-table widefat striped payments"> |
544 | 544 | <thead> |
545 | 545 | <tr> |
546 | - <th scope="col"><?php _e( 'ID', 'give' ); ?></th> |
|
547 | - <th scope="col"><?php _e( 'Amount', 'give' ); ?></th> |
|
548 | - <th scope="col"><?php _e( 'Date', 'give' ); ?></th> |
|
549 | - <th scope="col"><?php _e( 'Status', 'give' ); ?></th> |
|
550 | - <th scope="col"><?php _e( 'Actions', 'give' ); ?></th> |
|
546 | + <th scope="col"><?php _e('ID', 'give'); ?></th> |
|
547 | + <th scope="col"><?php _e('Amount', 'give'); ?></th> |
|
548 | + <th scope="col"><?php _e('Date', 'give'); ?></th> |
|
549 | + <th scope="col"><?php _e('Status', 'give'); ?></th> |
|
550 | + <th scope="col"><?php _e('Actions', 'give'); ?></th> |
|
551 | 551 | </tr> |
552 | 552 | </thead> |
553 | 553 | <tbody> |
554 | - <?php if ( ! empty( $payments ) ) { ?> |
|
555 | - <?php foreach ( $payments as $payment ) : ?> |
|
554 | + <?php if ( ! empty($payments)) { ?> |
|
555 | + <?php foreach ($payments as $payment) : ?> |
|
556 | 556 | <tr> |
557 | 557 | <td><?php echo $payment->ID; ?></td> |
558 | - <td><?php echo give_donation_amount( $payment->ID, 'donor' ); ?></td> |
|
559 | - <td><?php echo date_i18n( give_date_format(), strtotime( $payment->post_date ) ); ?></td> |
|
560 | - <td><?php echo give_get_payment_status( $payment, true ); ?></td> |
|
558 | + <td><?php echo give_donation_amount($payment->ID, 'donor'); ?></td> |
|
559 | + <td><?php echo date_i18n(give_date_format(), strtotime($payment->post_date)); ?></td> |
|
560 | + <td><?php echo give_get_payment_status($payment, true); ?></td> |
|
561 | 561 | <td> |
562 | 562 | <?php |
563 | 563 | printf( |
564 | 564 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
565 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment->ID ), |
|
565 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$payment->ID), |
|
566 | 566 | sprintf( |
567 | 567 | /* translators: %s: Donation ID */ |
568 | - esc_attr__( 'View Donation %s.', 'give' ), |
|
568 | + esc_attr__('View Donation %s.', 'give'), |
|
569 | 569 | $payment->ID |
570 | 570 | ), |
571 | - __( 'View Donation', 'give' ) |
|
571 | + __('View Donation', 'give') |
|
572 | 572 | ); |
573 | 573 | ?> |
574 | 574 | |
@@ -583,47 +583,47 @@ discard block |
||
583 | 583 | * @param object $donor The donor object being displayed. |
584 | 584 | * @param object $payment The payment object being displayed. |
585 | 585 | */ |
586 | - do_action( 'give_donor_recent_purchases_actions', $donor, $payment ); |
|
586 | + do_action('give_donor_recent_purchases_actions', $donor, $payment); |
|
587 | 587 | ?> |
588 | 588 | </td> |
589 | 589 | </tr> |
590 | 590 | <?php endforeach; ?> |
591 | 591 | <?php } else { ?> |
592 | 592 | <tr> |
593 | - <td colspan="5"><?php _e( 'No donations found.', 'give' ); ?></td> |
|
593 | + <td colspan="5"><?php _e('No donations found.', 'give'); ?></td> |
|
594 | 594 | </tr> |
595 | 595 | <?php }// End if(). |
596 | 596 | ?> |
597 | 597 | </tbody> |
598 | 598 | </table> |
599 | 599 | |
600 | - <h3><?php _e( 'Completed Forms', 'give' ); ?></h3> |
|
600 | + <h3><?php _e('Completed Forms', 'give'); ?></h3> |
|
601 | 601 | <?php |
602 | - $donations = give_get_users_completed_donations( $donor->email ); |
|
602 | + $donations = give_get_users_completed_donations($donor->email); |
|
603 | 603 | ?> |
604 | 604 | <table class="wp-list-table widefat striped donations"> |
605 | 605 | <thead> |
606 | 606 | <tr> |
607 | - <th scope="col"><?php _e( 'Form', 'give' ); ?></th> |
|
608 | - <th scope="col" width="120px"><?php _e( 'Actions', 'give' ); ?></th> |
|
607 | + <th scope="col"><?php _e('Form', 'give'); ?></th> |
|
608 | + <th scope="col" width="120px"><?php _e('Actions', 'give'); ?></th> |
|
609 | 609 | </tr> |
610 | 610 | </thead> |
611 | 611 | <tbody> |
612 | - <?php if ( ! empty( $donations ) ) { ?> |
|
613 | - <?php foreach ( $donations as $donation ) : ?> |
|
612 | + <?php if ( ! empty($donations)) { ?> |
|
613 | + <?php foreach ($donations as $donation) : ?> |
|
614 | 614 | <tr> |
615 | 615 | <td><?php echo $donation->post_title; ?></td> |
616 | 616 | <td> |
617 | 617 | <?php |
618 | 618 | printf( |
619 | 619 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
620 | - esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ), |
|
620 | + esc_url(admin_url('post.php?action=edit&post='.$donation->ID)), |
|
621 | 621 | sprintf( |
622 | 622 | /* translators: %s: form name */ |
623 | - esc_attr__( 'View Form %s.', 'give' ), |
|
623 | + esc_attr__('View Form %s.', 'give'), |
|
624 | 624 | $donation->post_title |
625 | 625 | ), |
626 | - __( 'View Form', 'give' ) |
|
626 | + __('View Form', 'give') |
|
627 | 627 | ); |
628 | 628 | ?> |
629 | 629 | </td> |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | <?php endforeach; ?> |
632 | 632 | <?php } else { ?> |
633 | 633 | <tr> |
634 | - <td colspan="2"><?php _e( 'No completed donations found.', 'give' ); ?></td> |
|
634 | + <td colspan="2"><?php _e('No completed donations found.', 'give'); ?></td> |
|
635 | 635 | </tr> |
636 | 636 | <?php } ?> |
637 | 637 | </tbody> |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | * |
646 | 646 | * @param object $donor The donor object being displayed. |
647 | 647 | */ |
648 | - do_action( 'give_donor_after_tables', $donor ); |
|
648 | + do_action('give_donor_after_tables', $donor); |
|
649 | 649 | ?> |
650 | 650 | |
651 | 651 | </div> |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | * |
659 | 659 | * @param object $donor The donor object being displayed. |
660 | 660 | */ |
661 | - do_action( 'give_donor_card_bottom', $donor ); |
|
661 | + do_action('give_donor_card_bottom', $donor); |
|
662 | 662 | |
663 | 663 | } |
664 | 664 | |
@@ -671,30 +671,30 @@ discard block |
||
671 | 671 | * |
672 | 672 | * @return void |
673 | 673 | */ |
674 | -function give_donor_notes_view( $donor ) { |
|
674 | +function give_donor_notes_view($donor) { |
|
675 | 675 | |
676 | - $paged = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? $_GET['paged'] : 1; |
|
677 | - $paged = absint( $paged ); |
|
676 | + $paged = isset($_GET['paged']) && is_numeric($_GET['paged']) ? $_GET['paged'] : 1; |
|
677 | + $paged = absint($paged); |
|
678 | 678 | $note_count = $donor->get_notes_count(); |
679 | - $per_page = apply_filters( 'give_donor_notes_per_page', 20 ); |
|
680 | - $total_pages = ceil( $note_count / $per_page ); |
|
681 | - $donor_notes = $donor->get_notes( $per_page, $paged ); |
|
679 | + $per_page = apply_filters('give_donor_notes_per_page', 20); |
|
680 | + $total_pages = ceil($note_count / $per_page); |
|
681 | + $donor_notes = $donor->get_notes($per_page, $paged); |
|
682 | 682 | ?> |
683 | 683 | |
684 | 684 | <div id="donor-notes-wrapper"> |
685 | 685 | <div class="donor-notes-header"> |
686 | - <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span> |
|
686 | + <?php echo get_avatar($donor->email, 30); ?> <span><?php echo $donor->name; ?></span> |
|
687 | 687 | </div> |
688 | - <h3><?php _e( 'Notes', 'give' ); ?></h3> |
|
688 | + <h3><?php _e('Notes', 'give'); ?></h3> |
|
689 | 689 | |
690 | - <?php if ( 1 == $paged ) : ?> |
|
690 | + <?php if (1 == $paged) : ?> |
|
691 | 691 | <div style="display: block; margin-bottom: 55px;"> |
692 | - <form id="give-add-donor-note" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor->id ); ?>"> |
|
692 | + <form id="give-add-donor-note" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor->id); ?>"> |
|
693 | 693 | <textarea id="donor-note" name="donor_note" class="donor-note-input" rows="10"></textarea> |
694 | 694 | <br /> |
695 | 695 | <input type="hidden" id="donor-id" name="customer_id" value="<?php echo $donor->id; ?>" /> |
696 | 696 | <input type="hidden" name="give_action" value="add-donor-note" /> |
697 | - <?php wp_nonce_field( 'add-donor-note', 'add_donor_note_nonce', true, true ); ?> |
|
697 | + <?php wp_nonce_field('add-donor-note', 'add_donor_note_nonce', true, true); ?> |
|
698 | 698 | <input id="add-donor-note" class="right button-primary" type="submit" value="Add Note" /> |
699 | 699 | </form> |
700 | 700 | </div> |
@@ -709,26 +709,26 @@ discard block |
||
709 | 709 | 'show_all' => true, |
710 | 710 | ); |
711 | 711 | |
712 | - echo paginate_links( $pagination_args ); |
|
712 | + echo paginate_links($pagination_args); |
|
713 | 713 | ?> |
714 | 714 | |
715 | 715 | <div id="give-donor-notes" class="postbox"> |
716 | - <?php if ( count( $donor_notes ) > 0 ) { ?> |
|
717 | - <?php foreach ( $donor_notes as $key => $note ) : ?> |
|
716 | + <?php if (count($donor_notes) > 0) { ?> |
|
717 | + <?php foreach ($donor_notes as $key => $note) : ?> |
|
718 | 718 | <div class="donor-note-wrapper dashboard-comment-wrap comment-item"> |
719 | 719 | <span class="note-content-wrap"> |
720 | - <?php echo stripslashes( $note ); ?> |
|
720 | + <?php echo stripslashes($note); ?> |
|
721 | 721 | </span> |
722 | 722 | </div> |
723 | 723 | <?php endforeach; ?> |
724 | 724 | <?php } else { ?> |
725 | 725 | <div class="give-no-donor-notes"> |
726 | - <?php _e( 'No donor notes found.', 'give' ); ?> |
|
726 | + <?php _e('No donor notes found.', 'give'); ?> |
|
727 | 727 | </div> |
728 | 728 | <?php } ?> |
729 | 729 | </div> |
730 | 730 | |
731 | - <?php echo paginate_links( $pagination_args ); ?> |
|
731 | + <?php echo paginate_links($pagination_args); ?> |
|
732 | 732 | |
733 | 733 | </div> |
734 | 734 | |
@@ -744,9 +744,9 @@ discard block |
||
744 | 744 | * |
745 | 745 | * @return void |
746 | 746 | */ |
747 | -function give_donor_delete_view( $donor ) { |
|
747 | +function give_donor_delete_view($donor) { |
|
748 | 748 | |
749 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
749 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
750 | 750 | |
751 | 751 | /** |
752 | 752 | * Fires in donor delete screen, above the content. |
@@ -755,15 +755,15 @@ discard block |
||
755 | 755 | * |
756 | 756 | * @param object $donor The donor object being displayed. |
757 | 757 | */ |
758 | - do_action( 'give_donor_delete_top', $donor ); |
|
758 | + do_action('give_donor_delete_top', $donor); |
|
759 | 759 | ?> |
760 | 760 | |
761 | 761 | <div class="info-wrapper donor-section"> |
762 | 762 | |
763 | - <form id="delete-donor" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor->id ); ?>"> |
|
763 | + <form id="delete-donor" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor->id); ?>"> |
|
764 | 764 | |
765 | 765 | <div class="donor-notes-header"> |
766 | - <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span> |
|
766 | + <?php echo get_avatar($donor->email, 30); ?> <span><?php echo $donor->name; ?></span> |
|
767 | 767 | </div> |
768 | 768 | |
769 | 769 | |
@@ -771,20 +771,20 @@ discard block |
||
771 | 771 | |
772 | 772 | <span class="delete-donor-options"> |
773 | 773 | <p> |
774 | - <?php echo Give()->html->checkbox( array( |
|
774 | + <?php echo Give()->html->checkbox(array( |
|
775 | 775 | 'name' => 'give-donor-delete-confirm', |
776 | - ) ); ?> |
|
777 | - <label for="give-donor-delete-confirm"><?php _e( 'Are you sure you want to delete this donor?', 'give' ); ?></label> |
|
776 | + )); ?> |
|
777 | + <label for="give-donor-delete-confirm"><?php _e('Are you sure you want to delete this donor?', 'give'); ?></label> |
|
778 | 778 | </p> |
779 | 779 | |
780 | 780 | <p> |
781 | - <?php echo Give()->html->checkbox( array( |
|
781 | + <?php echo Give()->html->checkbox(array( |
|
782 | 782 | 'name' => 'give-donor-delete-records', |
783 | 783 | 'options' => array( |
784 | 784 | 'disabled' => true, |
785 | 785 | ), |
786 | - ) ); ?> |
|
787 | - <label for="give-donor-delete-records"><?php _e( 'Delete all associated donations and records?', 'give' ); ?></label> |
|
786 | + )); ?> |
|
787 | + <label for="give-donor-delete-records"><?php _e('Delete all associated donations and records?', 'give'); ?></label> |
|
788 | 788 | </p> |
789 | 789 | |
790 | 790 | <?php |
@@ -797,16 +797,16 @@ discard block |
||
797 | 797 | * |
798 | 798 | * @param object $donor The donor object being displayed. |
799 | 799 | */ |
800 | - do_action( 'give_donor_delete_inputs', $donor ); |
|
800 | + do_action('give_donor_delete_inputs', $donor); |
|
801 | 801 | ?> |
802 | 802 | </span> |
803 | 803 | |
804 | 804 | <span id="donor-edit-actions"> |
805 | 805 | <input type="hidden" name="customer_id" value="<?php echo $donor->id; ?>" /> |
806 | - <?php wp_nonce_field( 'delete-donor', '_wpnonce', false, true ); ?> |
|
806 | + <?php wp_nonce_field('delete-donor', '_wpnonce', false, true); ?> |
|
807 | 807 | <input type="hidden" name="give_action" value="delete-donor" /> |
808 | - <input type="submit" disabled="disabled" id="give-delete-donor" class="button-primary" value="<?php _e( 'Delete Donor', 'give' ); ?>" /> |
|
809 | - <a id="give-delete-donor-cancel" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>" class="delete"><?php _e( 'Cancel', 'give' ); ?></a> |
|
808 | + <input type="submit" disabled="disabled" id="give-delete-donor" class="button-primary" value="<?php _e('Delete Donor', 'give'); ?>" /> |
|
809 | + <a id="give-delete-donor-cancel" href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); ?>" class="delete"><?php _e('Cancel', 'give'); ?></a> |
|
810 | 810 | </span> |
811 | 811 | |
812 | 812 | </div> |
@@ -822,5 +822,5 @@ discard block |
||
822 | 822 | * |
823 | 823 | * @param object $donor The donor object being displayed. |
824 | 824 | */ |
825 | - do_action( 'give_donor_delete_bottom', $donor ); |
|
825 | + do_action('give_donor_delete_bottom', $donor); |
|
826 | 826 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,17 +23,17 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array|bool $output Response messages |
25 | 25 | */ |
26 | -function give_edit_donor( $args ) { |
|
26 | +function give_edit_donor($args) { |
|
27 | 27 | |
28 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
28 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
29 | 29 | |
30 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
31 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
30 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
31 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
32 | 32 | 'response' => 403, |
33 | - ) ); |
|
33 | + )); |
|
34 | 34 | } |
35 | 35 | |
36 | - if ( empty( $args ) ) { |
|
36 | + if (empty($args)) { |
|
37 | 37 | return false; |
38 | 38 | } |
39 | 39 | |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | $donor_id = (int) $args['customerinfo']['id']; |
42 | 42 | $nonce = $args['_wpnonce']; |
43 | 43 | |
44 | - if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) { |
|
45 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
44 | + if ( ! wp_verify_nonce($nonce, 'edit-donor')) { |
|
45 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
46 | 46 | 'response' => 400, |
47 | - ) ); |
|
47 | + )); |
|
48 | 48 | } |
49 | 49 | |
50 | - $donor = new Give_Donor( $donor_id ); |
|
50 | + $donor = new Give_Donor($donor_id); |
|
51 | 51 | |
52 | - if ( empty( $donor->id ) ) { |
|
52 | + if (empty($donor->id)) { |
|
53 | 53 | return false; |
54 | 54 | } |
55 | 55 | |
@@ -64,79 +64,79 @@ discard block |
||
64 | 64 | 'country' => '', |
65 | 65 | ); |
66 | 66 | |
67 | - $donor_info = wp_parse_args( $donor_info, $defaults ); |
|
67 | + $donor_info = wp_parse_args($donor_info, $defaults); |
|
68 | 68 | |
69 | - if ( (int) $donor_info['user_id'] !== (int) $donor->user_id ) { |
|
69 | + if ((int) $donor_info['user_id'] !== (int) $donor->user_id) { |
|
70 | 70 | |
71 | 71 | // Make sure we don't already have this user attached to a donor. |
72 | - if ( ! empty( $donor_info['user_id'] ) && false !== Give()->donors->get_donor_by( 'user_id', $donor_info['user_id'] ) ) { |
|
73 | - give_set_error( 'give-invalid-donor-user_id', sprintf( __( 'The User ID #%d is already associated with a different donor.', 'give' ), $donor_info['user_id'] ) ); |
|
72 | + if ( ! empty($donor_info['user_id']) && false !== Give()->donors->get_donor_by('user_id', $donor_info['user_id'])) { |
|
73 | + give_set_error('give-invalid-donor-user_id', sprintf(__('The User ID #%d is already associated with a different donor.', 'give'), $donor_info['user_id'])); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | // Make sure it's actually a user. |
77 | - $user = get_user_by( 'id', $donor_info['user_id'] ); |
|
78 | - if ( ! empty( $donor_info['user_id'] ) && false === $user ) { |
|
79 | - give_set_error( 'give-invalid-user_id', sprintf( __( 'The User ID #%d does not exist. Please assign an existing user.', 'give' ), $donor_info['user_id'] ) ); |
|
77 | + $user = get_user_by('id', $donor_info['user_id']); |
|
78 | + if ( ! empty($donor_info['user_id']) && false === $user) { |
|
79 | + give_set_error('give-invalid-user_id', sprintf(__('The User ID #%d does not exist. Please assign an existing user.', 'give'), $donor_info['user_id'])); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | - if ( give_get_errors() ) { |
|
83 | + if (give_get_errors()) { |
|
84 | 84 | return false; |
85 | 85 | } |
86 | 86 | |
87 | 87 | // Setup the donor address, if present. |
88 | 88 | $address = array(); |
89 | - if ( intval( $donor_info['user_id'] ) > 0 ) { |
|
90 | - |
|
91 | - $current_address = (array) get_user_meta( $donor_info['user_id'], '_give_user_address', true ); |
|
92 | - |
|
93 | - if ( is_array( $current_address ) && 0 < count( $current_address ) ) { |
|
94 | - $current_address = wp_parse_args( $current_address, $defaults ); |
|
95 | - $address['line1'] = ! empty( $donor_info['line1'] ) ? $donor_info['line1'] : $current_address['line1']; |
|
96 | - $address['line2'] = ! empty( $donor_info['line2'] ) ? $donor_info['line2'] : $current_address['line2']; |
|
97 | - $address['city'] = ! empty( $donor_info['city'] ) ? $donor_info['city'] : $current_address['city']; |
|
98 | - $address['country'] = ! empty( $donor_info['country'] ) ? $donor_info['country'] : $current_address['country']; |
|
99 | - $address['zip'] = ! empty( $donor_info['zip'] ) ? $donor_info['zip'] : $current_address['zip']; |
|
100 | - $address['state'] = ! empty( $donor_info['state'] ) ? $donor_info['state'] : $current_address['state']; |
|
89 | + if (intval($donor_info['user_id']) > 0) { |
|
90 | + |
|
91 | + $current_address = (array) get_user_meta($donor_info['user_id'], '_give_user_address', true); |
|
92 | + |
|
93 | + if (is_array($current_address) && 0 < count($current_address)) { |
|
94 | + $current_address = wp_parse_args($current_address, $defaults); |
|
95 | + $address['line1'] = ! empty($donor_info['line1']) ? $donor_info['line1'] : $current_address['line1']; |
|
96 | + $address['line2'] = ! empty($donor_info['line2']) ? $donor_info['line2'] : $current_address['line2']; |
|
97 | + $address['city'] = ! empty($donor_info['city']) ? $donor_info['city'] : $current_address['city']; |
|
98 | + $address['country'] = ! empty($donor_info['country']) ? $donor_info['country'] : $current_address['country']; |
|
99 | + $address['zip'] = ! empty($donor_info['zip']) ? $donor_info['zip'] : $current_address['zip']; |
|
100 | + $address['state'] = ! empty($donor_info['state']) ? $donor_info['state'] : $current_address['state']; |
|
101 | 101 | } else { |
102 | - $address['line1'] = ! empty( $donor_info['line1'] ) ? $donor_info['line1'] : ''; |
|
103 | - $address['line2'] = ! empty( $donor_info['line2'] ) ? $donor_info['line2'] : ''; |
|
104 | - $address['city'] = ! empty( $donor_info['city'] ) ? $donor_info['city'] : ''; |
|
105 | - $address['country'] = ! empty( $donor_info['country'] ) ? $donor_info['country'] : ''; |
|
106 | - $address['zip'] = ! empty( $donor_info['zip'] ) ? $donor_info['zip'] : ''; |
|
107 | - $address['state'] = ! empty( $donor_info['state'] ) ? $donor_info['state'] : ''; |
|
102 | + $address['line1'] = ! empty($donor_info['line1']) ? $donor_info['line1'] : ''; |
|
103 | + $address['line2'] = ! empty($donor_info['line2']) ? $donor_info['line2'] : ''; |
|
104 | + $address['city'] = ! empty($donor_info['city']) ? $donor_info['city'] : ''; |
|
105 | + $address['country'] = ! empty($donor_info['country']) ? $donor_info['country'] : ''; |
|
106 | + $address['zip'] = ! empty($donor_info['zip']) ? $donor_info['zip'] : ''; |
|
107 | + $address['state'] = ! empty($donor_info['state']) ? $donor_info['state'] : ''; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | } |
111 | 111 | |
112 | 112 | // Sanitize the inputs. |
113 | 113 | $donor_data = array(); |
114 | - $donor_data['name'] = strip_tags( stripslashes( $donor_info['name'] ) ); |
|
114 | + $donor_data['name'] = strip_tags(stripslashes($donor_info['name'])); |
|
115 | 115 | $donor_data['user_id'] = $donor_info['user_id']; |
116 | 116 | |
117 | - $donor_data = apply_filters( 'give_edit_donor_info', $donor_data, $donor_id ); |
|
118 | - $address = apply_filters( 'give_edit_donor_address', $address, $donor_id ); |
|
117 | + $donor_data = apply_filters('give_edit_donor_info', $donor_data, $donor_id); |
|
118 | + $address = apply_filters('give_edit_donor_address', $address, $donor_id); |
|
119 | 119 | |
120 | - $donor_data = array_map( 'sanitize_text_field', $donor_data ); |
|
121 | - $address = array_map( 'sanitize_text_field', $address ); |
|
120 | + $donor_data = array_map('sanitize_text_field', $donor_data); |
|
121 | + $address = array_map('sanitize_text_field', $address); |
|
122 | 122 | |
123 | - $output = give_connect_user_donor_profile( $donor, $donor_data, $address ); |
|
123 | + $output = give_connect_user_donor_profile($donor, $donor_data, $address); |
|
124 | 124 | |
125 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
126 | - header( 'Content-Type: application/json' ); |
|
127 | - echo json_encode( $output ); |
|
125 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
126 | + header('Content-Type: application/json'); |
|
127 | + echo json_encode($output); |
|
128 | 128 | wp_die(); |
129 | 129 | } |
130 | 130 | |
131 | - if ( $output['success'] ) { |
|
132 | - wp_redirect( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id={$donor_id}&give-message=profile-updated" ) ); |
|
131 | + if ($output['success']) { |
|
132 | + wp_redirect(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id={$donor_id}&give-message=profile-updated")); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | exit; |
136 | 136 | |
137 | 137 | } |
138 | 138 | |
139 | -add_action( 'give_edit-donor', 'give_edit_donor', 10, 1 ); |
|
139 | +add_action('give_edit-donor', 'give_edit_donor', 10, 1); |
|
140 | 140 | |
141 | 141 | /** |
142 | 142 | * Save a donor note. |
@@ -147,40 +147,40 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @return int The Note ID that was saved, or 0 if nothing was saved. |
149 | 149 | */ |
150 | -function give_donor_save_note( $args ) { |
|
150 | +function give_donor_save_note($args) { |
|
151 | 151 | |
152 | - $donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' ); |
|
152 | + $donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports'); |
|
153 | 153 | |
154 | - if ( ! is_admin() || ! current_user_can( $donor_view_role ) ) { |
|
155 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
154 | + if ( ! is_admin() || ! current_user_can($donor_view_role)) { |
|
155 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
156 | 156 | 'response' => 403, |
157 | - ) ); |
|
157 | + )); |
|
158 | 158 | } |
159 | 159 | |
160 | - if ( empty( $args ) ) { |
|
160 | + if (empty($args)) { |
|
161 | 161 | return false; |
162 | 162 | } |
163 | 163 | |
164 | - $donor_note = trim( sanitize_text_field( $args['donor_note'] ) ); |
|
164 | + $donor_note = trim(sanitize_text_field($args['donor_note'])); |
|
165 | 165 | $donor_id = (int) $args['customer_id']; |
166 | 166 | $nonce = $args['add_donor_note_nonce']; |
167 | 167 | |
168 | - if ( ! wp_verify_nonce( $nonce, 'add-donor-note' ) ) { |
|
169 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
168 | + if ( ! wp_verify_nonce($nonce, 'add-donor-note')) { |
|
169 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
170 | 170 | 'response' => 400, |
171 | - ) ); |
|
171 | + )); |
|
172 | 172 | } |
173 | 173 | |
174 | - if ( empty( $donor_note ) ) { |
|
175 | - give_set_error( 'empty-donor-note', __( 'A note is required.', 'give' ) ); |
|
174 | + if (empty($donor_note)) { |
|
175 | + give_set_error('empty-donor-note', __('A note is required.', 'give')); |
|
176 | 176 | } |
177 | 177 | |
178 | - if ( give_get_errors() ) { |
|
178 | + if (give_get_errors()) { |
|
179 | 179 | return false; |
180 | 180 | } |
181 | 181 | |
182 | - $donor = new Give_Donor( $donor_id ); |
|
183 | - $new_note = $donor->add_note( $donor_note ); |
|
182 | + $donor = new Give_Donor($donor_id); |
|
183 | + $new_note = $donor->add_note($donor_note); |
|
184 | 184 | |
185 | 185 | /** |
186 | 186 | * Fires before inserting donor note. |
@@ -190,22 +190,22 @@ discard block |
||
190 | 190 | * |
191 | 191 | * @since 1.0 |
192 | 192 | */ |
193 | - do_action( 'give_pre_insert_donor_note', $donor_id, $new_note ); |
|
193 | + do_action('give_pre_insert_donor_note', $donor_id, $new_note); |
|
194 | 194 | |
195 | - if ( ! empty( $new_note ) && ! empty( $donor->id ) ) { |
|
195 | + if ( ! empty($new_note) && ! empty($donor->id)) { |
|
196 | 196 | |
197 | 197 | ob_start(); |
198 | 198 | ?> |
199 | 199 | <div class="donor-note-wrapper dashboard-comment-wrap comment-item"> |
200 | 200 | <span class="note-content-wrap"> |
201 | - <?php echo stripslashes( $new_note ); ?> |
|
201 | + <?php echo stripslashes($new_note); ?> |
|
202 | 202 | </span> |
203 | 203 | </div> |
204 | 204 | <?php |
205 | 205 | $output = ob_get_contents(); |
206 | 206 | ob_end_clean(); |
207 | 207 | |
208 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
208 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
209 | 209 | echo $output; |
210 | 210 | exit; |
211 | 211 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | |
219 | 219 | } |
220 | 220 | |
221 | -add_action( 'give_add-donor-note', 'give_donor_save_note', 10, 1 ); |
|
221 | +add_action('give_add-donor-note', 'give_donor_save_note', 10, 1); |
|
222 | 222 | |
223 | 223 | /** |
224 | 224 | * Delete a donor. |
@@ -229,41 +229,41 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return int Whether it was a successful deletion. |
231 | 231 | */ |
232 | -function give_donor_delete( $args ) { |
|
232 | +function give_donor_delete($args) { |
|
233 | 233 | |
234 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
234 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
235 | 235 | |
236 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
237 | - wp_die( __( 'You do not have permission to delete donors.', 'give' ), __( 'Error', 'give' ), array( |
|
236 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
237 | + wp_die(__('You do not have permission to delete donors.', 'give'), __('Error', 'give'), array( |
|
238 | 238 | 'response' => 403, |
239 | - ) ); |
|
239 | + )); |
|
240 | 240 | } |
241 | 241 | |
242 | - if ( empty( $args ) ) { |
|
242 | + if (empty($args)) { |
|
243 | 243 | return false; |
244 | 244 | } |
245 | 245 | |
246 | 246 | $donor_id = (int) $args['customer_id']; |
247 | - $confirm = ! empty( $args['give-donor-delete-confirm'] ) ? true : false; |
|
248 | - $remove_data = ! empty( $args['give-donor-delete-records'] ) ? true : false; |
|
247 | + $confirm = ! empty($args['give-donor-delete-confirm']) ? true : false; |
|
248 | + $remove_data = ! empty($args['give-donor-delete-records']) ? true : false; |
|
249 | 249 | $nonce = $args['_wpnonce']; |
250 | 250 | |
251 | - if ( ! wp_verify_nonce( $nonce, 'delete-donor' ) ) { |
|
252 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
251 | + if ( ! wp_verify_nonce($nonce, 'delete-donor')) { |
|
252 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
253 | 253 | 'response' => 400, |
254 | - ) ); |
|
254 | + )); |
|
255 | 255 | } |
256 | 256 | |
257 | - if ( ! $confirm ) { |
|
258 | - give_set_error( 'donor-delete-no-confirm', __( 'Please confirm you want to delete this donor.', 'give' ) ); |
|
257 | + if ( ! $confirm) { |
|
258 | + give_set_error('donor-delete-no-confirm', __('Please confirm you want to delete this donor.', 'give')); |
|
259 | 259 | } |
260 | 260 | |
261 | - if ( give_get_errors() ) { |
|
262 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id ) ); |
|
261 | + if (give_get_errors()) { |
|
262 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id)); |
|
263 | 263 | exit; |
264 | 264 | } |
265 | 265 | |
266 | - $donor = new Give_Donor( $donor_id ); |
|
266 | + $donor = new Give_Donor($donor_id); |
|
267 | 267 | |
268 | 268 | /** |
269 | 269 | * Fires before deleting donor. |
@@ -274,50 +274,50 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @since 1.0 |
276 | 276 | */ |
277 | - do_action( 'give_pre_delete_donor', $donor_id, $confirm, $remove_data ); |
|
277 | + do_action('give_pre_delete_donor', $donor_id, $confirm, $remove_data); |
|
278 | 278 | |
279 | - if ( $donor->id > 0 ) { |
|
279 | + if ($donor->id > 0) { |
|
280 | 280 | |
281 | - $payments_array = explode( ',', $donor->payment_ids ); |
|
282 | - $success = Give()->donors->delete( $donor->id ); |
|
281 | + $payments_array = explode(',', $donor->payment_ids); |
|
282 | + $success = Give()->donors->delete($donor->id); |
|
283 | 283 | |
284 | - if ( $success ) { |
|
284 | + if ($success) { |
|
285 | 285 | |
286 | - if ( $remove_data ) { |
|
286 | + if ($remove_data) { |
|
287 | 287 | |
288 | 288 | // Remove all donations, logs, etc. |
289 | - foreach ( $payments_array as $payment_id ) { |
|
290 | - give_delete_donation( $payment_id ); |
|
289 | + foreach ($payments_array as $payment_id) { |
|
290 | + give_delete_donation($payment_id); |
|
291 | 291 | } |
292 | 292 | } else { |
293 | 293 | |
294 | 294 | // Just set the donations to customer_id of 0. |
295 | - foreach ( $payments_array as $payment_id ) { |
|
296 | - give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 ); |
|
295 | + foreach ($payments_array as $payment_id) { |
|
296 | + give_update_payment_meta($payment_id, '_give_payment_customer_id', 0); |
|
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
300 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=donor-deleted' ); |
|
300 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=donor-deleted'); |
|
301 | 301 | |
302 | 302 | } else { |
303 | 303 | |
304 | - give_set_error( 'give-donor-delete-failed', __( 'Error deleting donor.', 'give' ) ); |
|
305 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor_id ); |
|
304 | + give_set_error('give-donor-delete-failed', __('Error deleting donor.', 'give')); |
|
305 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor_id); |
|
306 | 306 | |
307 | 307 | } |
308 | 308 | } else { |
309 | 309 | |
310 | - give_set_error( 'give-donor-delete-invalid-id', __( 'Invalid Donor ID.', 'give' ) ); |
|
311 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); |
|
310 | + give_set_error('give-donor-delete-invalid-id', __('Invalid Donor ID.', 'give')); |
|
311 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors'); |
|
312 | 312 | |
313 | 313 | } |
314 | 314 | |
315 | - wp_redirect( $redirect ); |
|
315 | + wp_redirect($redirect); |
|
316 | 316 | exit; |
317 | 317 | |
318 | 318 | } |
319 | 319 | |
320 | -add_action( 'give_delete-donor', 'give_donor_delete', 10, 1 ); |
|
320 | +add_action('give_delete-donor', 'give_donor_delete', 10, 1); |
|
321 | 321 | |
322 | 322 | /** |
323 | 323 | * Disconnect a user ID from a donor |
@@ -328,17 +328,17 @@ discard block |
||
328 | 328 | * |
329 | 329 | * @return bool|array If the disconnect was successful. |
330 | 330 | */ |
331 | -function give_disconnect_donor_user_id( $args ) { |
|
331 | +function give_disconnect_donor_user_id($args) { |
|
332 | 332 | |
333 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
333 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
334 | 334 | |
335 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
336 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
335 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
336 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
337 | 337 | 'response' => 403, |
338 | - ) ); |
|
338 | + )); |
|
339 | 339 | } |
340 | 340 | |
341 | - if ( empty( $args ) ) { |
|
341 | + if (empty($args)) { |
|
342 | 342 | return false; |
343 | 343 | } |
344 | 344 | |
@@ -346,14 +346,14 @@ discard block |
||
346 | 346 | |
347 | 347 | $nonce = $args['_wpnonce']; |
348 | 348 | |
349 | - if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) { |
|
350 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
349 | + if ( ! wp_verify_nonce($nonce, 'edit-donor')) { |
|
350 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
351 | 351 | 'response' => 400, |
352 | - ) ); |
|
352 | + )); |
|
353 | 353 | } |
354 | 354 | |
355 | - $donor = new Give_Donor( $donor_id ); |
|
356 | - if ( empty( $donor->id ) ) { |
|
355 | + $donor = new Give_Donor($donor_id); |
|
356 | + if (empty($donor->id)) { |
|
357 | 357 | return false; |
358 | 358 | } |
359 | 359 | |
@@ -367,34 +367,34 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @since 1.0 |
369 | 369 | */ |
370 | - do_action( 'give_pre_donor_disconnect_user_id', $donor_id, $user_id ); |
|
370 | + do_action('give_pre_donor_disconnect_user_id', $donor_id, $user_id); |
|
371 | 371 | |
372 | 372 | $output = array(); |
373 | 373 | $donor_args = array( |
374 | 374 | 'user_id' => 0, |
375 | 375 | ); |
376 | 376 | |
377 | - if ( $donor->update( $donor_args ) ) { |
|
377 | + if ($donor->update($donor_args)) { |
|
378 | 378 | global $wpdb; |
379 | 379 | |
380 | - if ( ! empty( $donor->payment_ids ) ) { |
|
381 | - $wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $donor->payment_ids )" ); |
|
380 | + if ( ! empty($donor->payment_ids)) { |
|
381 | + $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $donor->payment_ids )"); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | // Set Donor Disconnection status true, if user and donor are disconnected with each other. |
385 | - update_user_meta( $user_id, '_give_is_donor_disconnected', true ); |
|
386 | - update_user_meta( $user_id, '_give_disconnected_donor_id', $donor->id ); |
|
387 | - $donor->update_meta( '_give_disconnected_user_id', $user_id ); |
|
385 | + update_user_meta($user_id, '_give_is_donor_disconnected', true); |
|
386 | + update_user_meta($user_id, '_give_disconnected_donor_id', $donor->id); |
|
387 | + $donor->update_meta('_give_disconnected_user_id', $user_id); |
|
388 | 388 | |
389 | 389 | $output['success'] = true; |
390 | 390 | |
391 | 391 | } else { |
392 | 392 | |
393 | 393 | $output['success'] = false; |
394 | - give_set_error( 'give-disconnect-user-fail', __( 'Failed to disconnect user from donor.', 'give' ) ); |
|
394 | + give_set_error('give-disconnect-user-fail', __('Failed to disconnect user from donor.', 'give')); |
|
395 | 395 | } |
396 | 396 | |
397 | - $output['redirect'] = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' ) . $donor_id; |
|
397 | + $output['redirect'] = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id=').$donor_id; |
|
398 | 398 | |
399 | 399 | /** |
400 | 400 | * Fires after disconnecting user ID from a donor. |
@@ -403,11 +403,11 @@ discard block |
||
403 | 403 | * |
404 | 404 | * @since 1.0 |
405 | 405 | */ |
406 | - do_action( 'give_post_donor_disconnect_user_id', $donor_id ); |
|
406 | + do_action('give_post_donor_disconnect_user_id', $donor_id); |
|
407 | 407 | |
408 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
409 | - header( 'Content-Type: application/json' ); |
|
410 | - echo json_encode( $output ); |
|
408 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
409 | + header('Content-Type: application/json'); |
|
410 | + echo json_encode($output); |
|
411 | 411 | wp_die(); |
412 | 412 | } |
413 | 413 | |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | |
416 | 416 | } |
417 | 417 | |
418 | -add_action( 'give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1 ); |
|
418 | +add_action('give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1); |
|
419 | 419 | |
420 | 420 | /** |
421 | 421 | * Add an email address to the donor from within the admin and log a donor note. |
@@ -426,86 +426,86 @@ discard block |
||
426 | 426 | * |
427 | 427 | * @return mixed If DOING_AJAX echos out JSON, otherwise returns array of success (bool) and message (string). |
428 | 428 | */ |
429 | -function give_add_donor_email( $args ) { |
|
429 | +function give_add_donor_email($args) { |
|
430 | 430 | |
431 | 431 | $donor_id = ''; |
432 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
432 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
433 | 433 | |
434 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
435 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
434 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
435 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
436 | 436 | 'response' => 403, |
437 | - ) ); |
|
437 | + )); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | $output = array(); |
441 | - if ( empty( $args ) || empty( $args['email'] ) || empty( $args['customer_id'] ) ) { |
|
441 | + if (empty($args) || empty($args['email']) || empty($args['customer_id'])) { |
|
442 | 442 | $output['success'] = false; |
443 | - if ( empty( $args['email'] ) ) { |
|
444 | - $output['message'] = __( 'Email address is required.', 'give' ); |
|
445 | - } elseif ( empty( $args['customer_id'] ) ) { |
|
446 | - $output['message'] = __( 'Donor ID is required.', 'give' ); |
|
443 | + if (empty($args['email'])) { |
|
444 | + $output['message'] = __('Email address is required.', 'give'); |
|
445 | + } elseif (empty($args['customer_id'])) { |
|
446 | + $output['message'] = __('Donor ID is required.', 'give'); |
|
447 | 447 | } else { |
448 | - $output['message'] = __( 'An error has occurred. Please try again.', 'give' ); |
|
448 | + $output['message'] = __('An error has occurred. Please try again.', 'give'); |
|
449 | 449 | } |
450 | - } elseif ( ! wp_verify_nonce( $args['_wpnonce'], 'give_add_donor_email' ) ) { |
|
450 | + } elseif ( ! wp_verify_nonce($args['_wpnonce'], 'give_add_donor_email')) { |
|
451 | 451 | $output = array( |
452 | 452 | 'success' => false, |
453 | - 'message' => __( 'Nonce verification failed.', 'give' ), |
|
453 | + 'message' => __('Nonce verification failed.', 'give'), |
|
454 | 454 | ); |
455 | - } elseif ( ! is_email( $args['email'] ) ) { |
|
455 | + } elseif ( ! is_email($args['email'])) { |
|
456 | 456 | $output = array( |
457 | 457 | 'success' => false, |
458 | - 'message' => __( 'Invalid email.', 'give' ), |
|
458 | + 'message' => __('Invalid email.', 'give'), |
|
459 | 459 | ); |
460 | 460 | } else { |
461 | - $email = sanitize_email( $args['email'] ); |
|
461 | + $email = sanitize_email($args['email']); |
|
462 | 462 | $donor_id = (int) $args['customer_id']; |
463 | 463 | $primary = 'true' === $args['primary'] ? true : false; |
464 | - $donor = new Give_Donor( $donor_id ); |
|
465 | - if ( false === $donor->add_email( $email, $primary ) ) { |
|
466 | - if ( in_array( $email, $donor->emails ) ) { |
|
464 | + $donor = new Give_Donor($donor_id); |
|
465 | + if (false === $donor->add_email($email, $primary)) { |
|
466 | + if (in_array($email, $donor->emails)) { |
|
467 | 467 | $output = array( |
468 | 468 | 'success' => false, |
469 | - 'message' => __( 'Email already associated with this donor.', 'give' ), |
|
469 | + 'message' => __('Email already associated with this donor.', 'give'), |
|
470 | 470 | ); |
471 | 471 | } else { |
472 | 472 | $output = array( |
473 | 473 | 'success' => false, |
474 | - 'message' => __( 'Email address is already associated with another donor.', 'give' ), |
|
474 | + 'message' => __('Email address is already associated with another donor.', 'give'), |
|
475 | 475 | ); |
476 | 476 | } |
477 | 477 | } else { |
478 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&give-message=email-added' ); |
|
478 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&give-message=email-added'); |
|
479 | 479 | $output = array( |
480 | 480 | 'success' => true, |
481 | - 'message' => __( 'Email successfully added to donor.', 'give' ), |
|
481 | + 'message' => __('Email successfully added to donor.', 'give'), |
|
482 | 482 | 'redirect' => $redirect, |
483 | 483 | ); |
484 | 484 | |
485 | 485 | $user = wp_get_current_user(); |
486 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' ); |
|
487 | - $donor_note = sprintf( __( 'Email address %1$s added by %2$s', 'give' ), $email, $user_login ); |
|
488 | - $donor->add_note( $donor_note ); |
|
486 | + $user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give'); |
|
487 | + $donor_note = sprintf(__('Email address %1$s added by %2$s', 'give'), $email, $user_login); |
|
488 | + $donor->add_note($donor_note); |
|
489 | 489 | |
490 | - if ( $primary ) { |
|
491 | - $donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $email, $user_login ); |
|
492 | - $donor->add_note( $donor_note ); |
|
490 | + if ($primary) { |
|
491 | + $donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $email, $user_login); |
|
492 | + $donor->add_note($donor_note); |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | } // End if(). |
496 | 496 | |
497 | - do_action( 'give_post_add_donor_email', $donor_id, $args ); |
|
497 | + do_action('give_post_add_donor_email', $donor_id, $args); |
|
498 | 498 | |
499 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
500 | - header( 'Content-Type: application/json' ); |
|
501 | - echo json_encode( $output ); |
|
499 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
500 | + header('Content-Type: application/json'); |
|
501 | + echo json_encode($output); |
|
502 | 502 | wp_die(); |
503 | 503 | } |
504 | 504 | |
505 | 505 | return $output; |
506 | 506 | } |
507 | 507 | |
508 | -add_action( 'give_add_donor_email', 'give_add_donor_email', 10, 1 ); |
|
508 | +add_action('give_add_donor_email', 'give_add_donor_email', 10, 1); |
|
509 | 509 | |
510 | 510 | |
511 | 511 | /** |
@@ -516,39 +516,39 @@ discard block |
||
516 | 516 | * @return bool|null |
517 | 517 | */ |
518 | 518 | function give_remove_donor_email() { |
519 | - if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
519 | + if (empty($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
520 | 520 | return false; |
521 | 521 | } |
522 | - if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) { |
|
522 | + if (empty($_GET['email']) || ! is_email($_GET['email'])) { |
|
523 | 523 | return false; |
524 | 524 | } |
525 | - if ( empty( $_GET['_wpnonce'] ) ) { |
|
525 | + if (empty($_GET['_wpnonce'])) { |
|
526 | 526 | return false; |
527 | 527 | } |
528 | 528 | |
529 | 529 | $nonce = $_GET['_wpnonce']; |
530 | - if ( ! wp_verify_nonce( $nonce, 'give-remove-donor-email' ) ) { |
|
531 | - wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array( |
|
530 | + if ( ! wp_verify_nonce($nonce, 'give-remove-donor-email')) { |
|
531 | + wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array( |
|
532 | 532 | 'response' => 403, |
533 | - ) ); |
|
533 | + )); |
|
534 | 534 | } |
535 | 535 | |
536 | - $donor = new Give_Donor( $_GET['id'] ); |
|
537 | - if ( $donor->remove_email( $_GET['email'] ) ) { |
|
538 | - $url = add_query_arg( 'give-message', 'email-removed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
536 | + $donor = new Give_Donor($_GET['id']); |
|
537 | + if ($donor->remove_email($_GET['email'])) { |
|
538 | + $url = add_query_arg('give-message', 'email-removed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
539 | 539 | $user = wp_get_current_user(); |
540 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' ); |
|
541 | - $donor_note = sprintf( __( 'Email address %1$s removed by %2$s', 'give' ), $_GET['email'], $user_login ); |
|
542 | - $donor->add_note( $donor_note ); |
|
540 | + $user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give'); |
|
541 | + $donor_note = sprintf(__('Email address %1$s removed by %2$s', 'give'), $_GET['email'], $user_login); |
|
542 | + $donor->add_note($donor_note); |
|
543 | 543 | } else { |
544 | - $url = add_query_arg( 'give-message', 'email-remove-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
544 | + $url = add_query_arg('give-message', 'email-remove-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
545 | 545 | } |
546 | 546 | |
547 | - wp_safe_redirect( $url ); |
|
547 | + wp_safe_redirect($url); |
|
548 | 548 | exit; |
549 | 549 | } |
550 | 550 | |
551 | -add_action( 'give_remove_donor_email', 'give_remove_donor_email', 10 ); |
|
551 | +add_action('give_remove_donor_email', 'give_remove_donor_email', 10); |
|
552 | 552 | |
553 | 553 | |
554 | 554 | /** |
@@ -560,44 +560,44 @@ discard block |
||
560 | 560 | * @return bool|null |
561 | 561 | */ |
562 | 562 | function give_set_donor_primary_email() { |
563 | - if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
563 | + if (empty($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
564 | 564 | return false; |
565 | 565 | } |
566 | 566 | |
567 | - if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) { |
|
567 | + if (empty($_GET['email']) || ! is_email($_GET['email'])) { |
|
568 | 568 | return false; |
569 | 569 | } |
570 | 570 | |
571 | - if ( empty( $_GET['_wpnonce'] ) ) { |
|
571 | + if (empty($_GET['_wpnonce'])) { |
|
572 | 572 | return false; |
573 | 573 | } |
574 | 574 | |
575 | 575 | $nonce = $_GET['_wpnonce']; |
576 | 576 | |
577 | - if ( ! wp_verify_nonce( $nonce, 'give-set-donor-primary-email' ) ) { |
|
578 | - wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array( |
|
577 | + if ( ! wp_verify_nonce($nonce, 'give-set-donor-primary-email')) { |
|
578 | + wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array( |
|
579 | 579 | 'response' => 403, |
580 | - ) ); |
|
580 | + )); |
|
581 | 581 | } |
582 | 582 | |
583 | - $donor = new Give_Donor( $_GET['id'] ); |
|
583 | + $donor = new Give_Donor($_GET['id']); |
|
584 | 584 | |
585 | - if ( $donor->set_primary_email( $_GET['email'] ) ) { |
|
586 | - $url = add_query_arg( 'give-message', 'primary-email-updated', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
585 | + if ($donor->set_primary_email($_GET['email'])) { |
|
586 | + $url = add_query_arg('give-message', 'primary-email-updated', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
587 | 587 | $user = wp_get_current_user(); |
588 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' ); |
|
589 | - $donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $_GET['email'], $user_login ); |
|
588 | + $user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give'); |
|
589 | + $donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $_GET['email'], $user_login); |
|
590 | 590 | |
591 | - $donor->add_note( $donor_note ); |
|
591 | + $donor->add_note($donor_note); |
|
592 | 592 | } else { |
593 | - $url = add_query_arg( 'give-message', 'primary-email-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
593 | + $url = add_query_arg('give-message', 'primary-email-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
594 | 594 | } |
595 | 595 | |
596 | - wp_safe_redirect( $url ); |
|
596 | + wp_safe_redirect($url); |
|
597 | 597 | exit; |
598 | 598 | } |
599 | 599 | |
600 | -add_action( 'give_set_donor_primary_email', 'give_set_donor_primary_email', 10 ); |
|
600 | +add_action('give_set_donor_primary_email', 'give_set_donor_primary_email', 10); |
|
601 | 601 | |
602 | 602 | /** |
603 | 603 | * Delete Donor using Bulk Actions. |
@@ -608,57 +608,57 @@ discard block |
||
608 | 608 | * |
609 | 609 | * @return void |
610 | 610 | */ |
611 | -function give_delete_donor( $args ) { |
|
611 | +function give_delete_donor($args) { |
|
612 | 612 | |
613 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
613 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
614 | 614 | |
615 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
616 | - wp_die( __( 'You do not have permission to delete donors.', 'give' ), __( 'Error', 'give' ), array( |
|
615 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
616 | + wp_die(__('You do not have permission to delete donors.', 'give'), __('Error', 'give'), array( |
|
617 | 617 | 'response' => 403, |
618 | - ) ); |
|
618 | + )); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | $give_args = array(); |
622 | - $donor_ids = ( ! empty( $_GET['donor'] ) && is_array( $_GET['donor'] ) && count( $_GET['donor'] ) > 0 ) ? $_GET['donor'] : array(); |
|
623 | - $delete_donor = ! empty( $_GET['give-delete-donor-confirm'] ) ? $_GET['give-delete-donor-confirm'] : ''; |
|
624 | - $delete_donations = ! empty( $_GET['give-delete-donor-records'] ) ? $_GET['give-delete-donor-records'] : ''; |
|
625 | - $search_keyword = ! empty( $_GET['s'] ) ? $_GET['s'] : ''; |
|
626 | - $give_args['orderby'] = ! empty( $_GET['orderby'] ) ? $_GET['orderby'] : 'id'; |
|
627 | - $give_args['order'] = ! empty( $_GET['order'] ) ? $_GET['order'] : 'desc'; |
|
622 | + $donor_ids = ( ! empty($_GET['donor']) && is_array($_GET['donor']) && count($_GET['donor']) > 0) ? $_GET['donor'] : array(); |
|
623 | + $delete_donor = ! empty($_GET['give-delete-donor-confirm']) ? $_GET['give-delete-donor-confirm'] : ''; |
|
624 | + $delete_donations = ! empty($_GET['give-delete-donor-records']) ? $_GET['give-delete-donor-records'] : ''; |
|
625 | + $search_keyword = ! empty($_GET['s']) ? $_GET['s'] : ''; |
|
626 | + $give_args['orderby'] = ! empty($_GET['orderby']) ? $_GET['orderby'] : 'id'; |
|
627 | + $give_args['order'] = ! empty($_GET['order']) ? $_GET['order'] : 'desc'; |
|
628 | 628 | $nonce = $args['_wpnonce']; |
629 | 629 | |
630 | 630 | // Verify Nonce for deleting bulk donors. |
631 | - if ( ! wp_verify_nonce( $nonce, 'bulk-donors' ) ) { |
|
632 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
631 | + if ( ! wp_verify_nonce($nonce, 'bulk-donors')) { |
|
632 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
633 | 633 | 'response' => 400, |
634 | - ) ); |
|
634 | + )); |
|
635 | 635 | } |
636 | 636 | |
637 | - if( count( $donor_ids ) > 0 ) { |
|
638 | - foreach ( $donor_ids as $donor_id ) { |
|
639 | - $donor = new Give_Donor( $donor_id ); |
|
637 | + if (count($donor_ids) > 0) { |
|
638 | + foreach ($donor_ids as $donor_id) { |
|
639 | + $donor = new Give_Donor($donor_id); |
|
640 | 640 | |
641 | - if ( $donor->id > 0 ) { |
|
641 | + if ($donor->id > 0) { |
|
642 | 642 | |
643 | - if( $delete_donor ) { |
|
644 | - $donor_deleted = Give()->donors->delete( $donor->id ); |
|
643 | + if ($delete_donor) { |
|
644 | + $donor_deleted = Give()->donors->delete($donor->id); |
|
645 | 645 | |
646 | - if ( $donor_deleted ) { |
|
647 | - $donation_ids = explode( ',', $donor->payment_ids ); |
|
646 | + if ($donor_deleted) { |
|
647 | + $donation_ids = explode(',', $donor->payment_ids); |
|
648 | 648 | |
649 | - if( $delete_donations ) { |
|
649 | + if ($delete_donations) { |
|
650 | 650 | |
651 | 651 | // Remove all donations, logs, etc. |
652 | - foreach ( $donation_ids as $donation_id ) { |
|
653 | - give_delete_donation( $donation_id ); |
|
652 | + foreach ($donation_ids as $donation_id) { |
|
653 | + give_delete_donation($donation_id); |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | $give_args['give-message'] = 'donor-donations-deleted'; |
657 | 657 | } else { |
658 | 658 | |
659 | 659 | // Just set the donations to customer_id of 0. |
660 | - foreach ( $donation_ids as $donation_id ) { |
|
661 | - give_update_payment_meta( $donation_id, '_give_payment_customer_id', 0 ); |
|
660 | + foreach ($donation_ids as $donation_id) { |
|
661 | + give_update_payment_meta($donation_id, '_give_payment_customer_id', 0); |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | $give_args['give-message'] = 'donor-deleted'; |
@@ -675,13 +675,13 @@ discard block |
||
675 | 675 | } |
676 | 676 | |
677 | 677 | // Add Search Keyword on redirection, if it exists. |
678 | - if ( ! empty( $search_keyword ) ) { |
|
678 | + if ( ! empty($search_keyword)) { |
|
679 | 679 | $give_args['s'] = $search_keyword; |
680 | 680 | } |
681 | 681 | |
682 | - wp_redirect( add_query_arg( $give_args, admin_url( 'edit.php?post_type=give_forms&page=give-donors' ) ) ); |
|
682 | + wp_redirect(add_query_arg($give_args, admin_url('edit.php?post_type=give_forms&page=give-donors'))); |
|
683 | 683 | give_die(); |
684 | 684 | } |
685 | 685 | } |
686 | 686 | |
687 | -add_action( 'give_delete_donor', 'give_delete_donor' ); |
|
688 | 687 | \ No newline at end of file |
688 | +add_action('give_delete_donor', 'give_delete_donor'); |
|
689 | 689 | \ No newline at end of file |