@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | |
18 | 18 | // Exit if accessed directly. |
19 | -if ( ! defined( 'ABSPATH' ) ) { |
|
19 | +if ( ! defined('ABSPATH')) { |
|
20 | 20 | exit; |
21 | 21 | } |
22 | 22 | |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | * @return void |
30 | 30 | */ |
31 | 31 | function give_reports_page() { |
32 | - $current_page = admin_url( 'edit.php?post_type=give_forms&page=give-reports' ); |
|
33 | - $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings'; |
|
32 | + $current_page = admin_url('edit.php?post_type=give_forms&page=give-reports'); |
|
33 | + $active_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings'; |
|
34 | 34 | $views = give_reports_default_views(); |
35 | 35 | ?> |
36 | 36 | <div class="wrap give-settings-page"> |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | <h1 class="screen-reader-text"><?php echo get_admin_page_title(); ?></h1> |
39 | 39 | |
40 | 40 | <h2 class="nav-tab-wrapper"> |
41 | - <?php foreach ( $views as $tab => $label ) { ?> |
|
42 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
41 | + <?php foreach ($views as $tab => $label) { ?> |
|
42 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
43 | 43 | 'tab' => $tab, |
44 | 44 | 'settings-updated' => false, |
45 | - ), $current_page ) ); ?>" class="nav-tab <?php echo $tab === $active_tab ? esc_attr( 'nav-tab-active' ) : ''; ?>"><?php echo esc_html( $label ); ?></a> |
|
45 | + ), $current_page)); ?>" class="nav-tab <?php echo $tab === $active_tab ? esc_attr('nav-tab-active') : ''; ?>"><?php echo esc_html($label); ?></a> |
|
46 | 46 | <?php } ?> |
47 | - <?php if ( current_user_can( 'export_give_reports' ) ) { ?> |
|
48 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
47 | + <?php if (current_user_can('export_give_reports')) { ?> |
|
48 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
49 | 49 | 'tab' => 'export', |
50 | 50 | 'settings-updated' => false, |
51 | - ), $current_page ) ); ?>" class="nav-tab <?php echo 'export' === $active_tab ? esc_attr( 'nav-tab-active' ) : ''; ?>"><?php esc_html_e( 'Export', 'give' ); ?></a> |
|
51 | + ), $current_page)); ?>" class="nav-tab <?php echo 'export' === $active_tab ? esc_attr('nav-tab-active') : ''; ?>"><?php esc_html_e('Export', 'give'); ?></a> |
|
52 | 52 | <?php } |
53 | 53 | /** |
54 | 54 | * Fires in the report tabs. |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @since 1.0 |
59 | 59 | */ |
60 | - do_action( 'give_reports_tabs' ); |
|
60 | + do_action('give_reports_tabs'); |
|
61 | 61 | ?> |
62 | 62 | </h2> |
63 | 63 | |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @since 1.0 |
69 | 69 | */ |
70 | - do_action( 'give_reports_page_top' ); |
|
70 | + do_action('give_reports_page_top'); |
|
71 | 71 | |
72 | 72 | // Set $active_tab prior to hook firing. |
73 | - if ( in_array( $active_tab, array_keys( $views ) ) ) { |
|
73 | + if (in_array($active_tab, array_keys($views))) { |
|
74 | 74 | $active_tab = 'reports'; |
75 | 75 | } |
76 | 76 | |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @since 1.0 |
81 | 81 | */ |
82 | - do_action( "give_reports_tab_{$active_tab}" ); |
|
82 | + do_action("give_reports_tab_{$active_tab}"); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Fires after the report page. |
86 | 86 | * |
87 | 87 | * @since 1.0 |
88 | 88 | */ |
89 | - do_action( 'give_reports_page_bottom' ); |
|
89 | + do_action('give_reports_page_bottom'); |
|
90 | 90 | ?> |
91 | 91 | </div><!-- .wrap --> |
92 | 92 | <?php |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | */ |
101 | 101 | function give_reports_default_views() { |
102 | 102 | $views = array( |
103 | - 'earnings' => esc_html__( 'Income', 'give' ), |
|
104 | - 'forms' => esc_html__( 'Forms', 'give' ), |
|
105 | - 'donors' => esc_html__( 'Donors', 'give' ), |
|
106 | - 'gateways' => esc_html__( 'Donation Methods', 'give' ), |
|
103 | + 'earnings' => esc_html__('Income', 'give'), |
|
104 | + 'forms' => esc_html__('Forms', 'give'), |
|
105 | + 'donors' => esc_html__('Donors', 'give'), |
|
106 | + 'gateways' => esc_html__('Donation Methods', 'give'), |
|
107 | 107 | ); |
108 | 108 | |
109 | - $views = apply_filters( 'give_report_views', $views ); |
|
109 | + $views = apply_filters('give_report_views', $views); |
|
110 | 110 | |
111 | 111 | return $views; |
112 | 112 | } |
@@ -121,15 +121,15 @@ discard block |
||
121 | 121 | * @since 1.0 |
122 | 122 | * @return string $view Report View |
123 | 123 | */ |
124 | -function give_get_reporting_view( $default = 'earnings' ) { |
|
124 | +function give_get_reporting_view($default = 'earnings') { |
|
125 | 125 | |
126 | - if ( ! isset( $_GET['view'] ) || ! in_array( $_GET['view'], array_keys( give_reports_default_views() ) ) ) { |
|
126 | + if ( ! isset($_GET['view']) || ! in_array($_GET['view'], array_keys(give_reports_default_views()))) { |
|
127 | 127 | $view = $default; |
128 | 128 | } else { |
129 | 129 | $view = $_GET['view']; |
130 | 130 | } |
131 | 131 | |
132 | - return apply_filters( 'give_get_reporting_view', $view ); |
|
132 | + return apply_filters('give_get_reporting_view', $view); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $current_view = 'earnings'; |
143 | 143 | $views = give_reports_default_views(); |
144 | 144 | |
145 | - if ( isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $views ) ) { |
|
145 | + if (isset($_GET['tab']) && array_key_exists($_GET['tab'], $views)) { |
|
146 | 146 | $current_view = $_GET['tab']; |
147 | 147 | } |
148 | 148 | |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @since 1.0 |
153 | 153 | */ |
154 | - do_action( "give_reports_view_{$current_view}" ); |
|
154 | + do_action("give_reports_view_{$current_view}"); |
|
155 | 155 | } |
156 | 156 | |
157 | -add_action( 'give_reports_tab_reports', 'give_reports_tab_reports' ); |
|
157 | +add_action('give_reports_tab_reports', 'give_reports_tab_reports'); |
|
158 | 158 | |
159 | 159 | /** |
160 | 160 | * Renders the Reports Page Views Drop Downs |
@@ -164,19 +164,19 @@ discard block |
||
164 | 164 | */ |
165 | 165 | function give_report_views() { |
166 | 166 | $views = give_reports_default_views(); |
167 | - $current_view = isset( $_GET['view'] ) ? $_GET['view'] : 'earnings'; |
|
167 | + $current_view = isset($_GET['view']) ? $_GET['view'] : 'earnings'; |
|
168 | 168 | /** |
169 | 169 | * Fires before the report page actions form. |
170 | 170 | * |
171 | 171 | * @since 1.0 |
172 | 172 | */ |
173 | - do_action( 'give_report_view_actions_before' ); |
|
173 | + do_action('give_report_view_actions_before'); |
|
174 | 174 | ?> |
175 | 175 | <form id="give-reports-filter" method="get"> |
176 | 176 | <select id="give-reports-view" name="view"> |
177 | - <option value="-1"><?php esc_html_e( 'Report Type', 'give' ); ?></option> |
|
178 | - <?php foreach ( $views as $view_id => $label ) : ?> |
|
179 | - <option value="<?php echo esc_attr( $view_id ); ?>" <?php selected( $view_id, $current_view ); ?>><?php echo $label; ?></option> |
|
177 | + <option value="-1"><?php esc_html_e('Report Type', 'give'); ?></option> |
|
178 | + <?php foreach ($views as $view_id => $label) : ?> |
|
179 | + <option value="<?php echo esc_attr($view_id); ?>" <?php selected($view_id, $current_view); ?>><?php echo $label; ?></option> |
|
180 | 180 | <?php endforeach; ?> |
181 | 181 | </select> |
182 | 182 | |
@@ -188,12 +188,12 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @since 1.0 |
190 | 190 | */ |
191 | - do_action( 'give_report_view_actions' ); |
|
191 | + do_action('give_report_view_actions'); |
|
192 | 192 | ?> |
193 | 193 | |
194 | 194 | <input type="hidden" name="post_type" value="give_forms"/> |
195 | 195 | <input type="hidden" name="page" value="give-reports"/> |
196 | - <?php submit_button( esc_html__( 'Show', 'give' ), 'secondary', 'submit', false ); ?> |
|
196 | + <?php submit_button(esc_html__('Show', 'give'), 'secondary', 'submit', false); ?> |
|
197 | 197 | </form> |
198 | 198 | <?php |
199 | 199 | /** |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @since 1.0 |
203 | 203 | */ |
204 | - do_action( 'give_report_view_actions_after' ); |
|
204 | + do_action('give_report_view_actions_after'); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -214,18 +214,18 @@ discard block |
||
214 | 214 | */ |
215 | 215 | function give_reports_forms_table() { |
216 | 216 | |
217 | - if ( isset( $_GET['form-id'] ) ) { |
|
217 | + if (isset($_GET['form-id'])) { |
|
218 | 218 | return; |
219 | 219 | } |
220 | 220 | |
221 | - include( dirname( __FILE__ ) . '/class-form-reports-table.php' ); |
|
221 | + include(dirname(__FILE__).'/class-form-reports-table.php'); |
|
222 | 222 | |
223 | 223 | $give_table = new Give_Form_Reports_Table(); |
224 | 224 | $give_table->prepare_items(); |
225 | 225 | $give_table->display(); |
226 | 226 | } |
227 | 227 | |
228 | -add_action( 'give_reports_view_forms', 'give_reports_forms_table' ); |
|
228 | +add_action('give_reports_view_forms', 'give_reports_forms_table'); |
|
229 | 229 | |
230 | 230 | /** |
231 | 231 | * Renders the detailed report for a specific give form |
@@ -234,20 +234,20 @@ discard block |
||
234 | 234 | * @return void |
235 | 235 | */ |
236 | 236 | function give_reports_form_details() { |
237 | - if ( ! isset( $_GET['form-id'] ) ) { |
|
237 | + if ( ! isset($_GET['form-id'])) { |
|
238 | 238 | return; |
239 | 239 | } |
240 | 240 | ?> |
241 | 241 | <div class="tablenav top reports-forms-details-wrap"> |
242 | 242 | <div class="actions bulkactions"> |
243 | - <button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e( 'Go Back', 'give' ); ?></button> |
|
243 | + <button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e('Go Back', 'give'); ?></button> |
|
244 | 244 | </div> |
245 | 245 | </div> |
246 | 246 | <?php |
247 | - give_reports_graph_of_form( absint( $_GET['form-id'] ) ); |
|
247 | + give_reports_graph_of_form(absint($_GET['form-id'])); |
|
248 | 248 | } |
249 | 249 | |
250 | -add_action( 'give_reports_view_forms', 'give_reports_form_details' ); |
|
250 | +add_action('give_reports_view_forms', 'give_reports_form_details'); |
|
251 | 251 | |
252 | 252 | /** |
253 | 253 | * Renders the Reports Donors Table |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @return void |
259 | 259 | */ |
260 | 260 | function give_reports_donors_table() { |
261 | - include( dirname( __FILE__ ) . '/class-donor-reports-table.php' ); |
|
261 | + include(dirname(__FILE__).'/class-donor-reports-table.php'); |
|
262 | 262 | |
263 | 263 | $give_table = new Give_Donor_Reports_Table(); |
264 | 264 | $give_table->prepare_items(); |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | * |
271 | 271 | * @since 1.0 |
272 | 272 | */ |
273 | - do_action( 'give_logs_donors_table_top' ); |
|
273 | + do_action('give_logs_donors_table_top'); |
|
274 | 274 | ?> |
275 | 275 | <form id="give-donors-filter" method="get"> |
276 | 276 | <?php |
277 | - $give_table->search_box( esc_html__( 'Search', 'give' ), 'give-donors' ); |
|
277 | + $give_table->search_box(esc_html__('Search', 'give'), 'give-donors'); |
|
278 | 278 | $give_table->display(); |
279 | 279 | ?> |
280 | 280 | <input type="hidden" name="post_type" value="give_forms"/> |
@@ -287,13 +287,13 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @since 1.0 |
289 | 289 | */ |
290 | - do_action( 'give_logs_donors_table_bottom' ); |
|
290 | + do_action('give_logs_donors_table_bottom'); |
|
291 | 291 | ?> |
292 | 292 | </div> |
293 | 293 | <?php |
294 | 294 | } |
295 | 295 | |
296 | -add_action( 'give_reports_view_donors', 'give_reports_donors_table' ); |
|
296 | +add_action('give_reports_view_donors', 'give_reports_donors_table'); |
|
297 | 297 | |
298 | 298 | |
299 | 299 | /** |
@@ -305,14 +305,14 @@ discard block |
||
305 | 305 | * @return void |
306 | 306 | */ |
307 | 307 | function give_reports_gateways_table() { |
308 | - include( dirname( __FILE__ ) . '/class-gateways-reports-table.php' ); |
|
308 | + include(dirname(__FILE__).'/class-gateways-reports-table.php'); |
|
309 | 309 | |
310 | 310 | $give_table = new Give_Gateawy_Reports_Table(); |
311 | 311 | $give_table->prepare_items(); |
312 | 312 | $give_table->display(); |
313 | 313 | } |
314 | 314 | |
315 | -add_action( 'give_reports_view_gateways', 'give_reports_gateways_table' ); |
|
315 | +add_action('give_reports_view_gateways', 'give_reports_gateways_table'); |
|
316 | 316 | |
317 | 317 | |
318 | 318 | /** |
@@ -324,13 +324,13 @@ discard block |
||
324 | 324 | function give_reports_earnings() { |
325 | 325 | ?> |
326 | 326 | <div class="tablenav top reports-table-nav"> |
327 | - <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e( 'Income Report', 'give' ); ?></span></h3> |
|
327 | + <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e('Income Report', 'give'); ?></span></h3> |
|
328 | 328 | </div> |
329 | 329 | <?php |
330 | 330 | give_reports_graph(); |
331 | 331 | } |
332 | 332 | |
333 | -add_action( 'give_reports_view_earnings', 'give_reports_earnings' ); |
|
333 | +add_action('give_reports_view_earnings', 'give_reports_earnings'); |
|
334 | 334 | |
335 | 335 | |
336 | 336 | /** |
@@ -351,14 +351,14 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @since 1.0 |
353 | 353 | */ |
354 | - do_action( 'give_reports_tab_export_content_top' ); |
|
354 | + do_action('give_reports_tab_export_content_top'); |
|
355 | 355 | ?> |
356 | 356 | |
357 | 357 | <table class="widefat export-options-table give-table"> |
358 | 358 | <thead> |
359 | 359 | <tr> |
360 | - <th scope="col"><?php esc_html_e( 'Export Type', 'give' ); ?></th> |
|
361 | - <th scope="col"><?php esc_html_e( 'Export Options', 'give' ); ?></th> |
|
360 | + <th scope="col"><?php esc_html_e('Export Type', 'give'); ?></th> |
|
361 | + <th scope="col"><?php esc_html_e('Export Options', 'give'); ?></th> |
|
362 | 362 | </tr> |
363 | 363 | </thead> |
364 | 364 | <tbody> |
@@ -370,42 +370,42 @@ discard block |
||
370 | 370 | * |
371 | 371 | * @since 1.0 |
372 | 372 | */ |
373 | - do_action( 'give_reports_tab_export_table_top' ); |
|
373 | + do_action('give_reports_tab_export_table_top'); |
|
374 | 374 | ?> |
375 | 375 | <tr class="give-export-pdf-sales-earnings"> |
376 | 376 | <td scope="row" class="row-title"> |
377 | - <h3><span><?php esc_html_e( 'Export PDF of Donations and Income', 'give' ); ?></span> |
|
377 | + <h3><span><?php esc_html_e('Export PDF of Donations and Income', 'give'); ?></span> |
|
378 | 378 | </h3> |
379 | - <p><?php esc_html_e( 'Download a PDF of Donations and Income reports for all forms for the current year.', 'give' ); ?></p> |
|
379 | + <p><?php esc_html_e('Download a PDF of Donations and Income reports for all forms for the current year.', 'give'); ?></p> |
|
380 | 380 | </td> |
381 | 381 | <td> |
382 | - <a class="button" href="<?php echo wp_nonce_url( add_query_arg( array( 'give-action' => 'generate_pdf' ) ), 'give_generate_pdf' ); ?>"><?php esc_html_e( 'Generate PDF', 'give' ); ?></a> |
|
382 | + <a class="button" href="<?php echo wp_nonce_url(add_query_arg(array('give-action' => 'generate_pdf')), 'give_generate_pdf'); ?>"><?php esc_html_e('Generate PDF', 'give'); ?></a> |
|
383 | 383 | </td> |
384 | 384 | </tr> |
385 | 385 | <tr class="alternate give-export-sales-earnings"> |
386 | 386 | <td scope="row" class="row-title"> |
387 | - <h3><span><?php esc_html_e( 'Export Income and Donation Stats', 'give' ); ?></span></h3> |
|
388 | - <p><?php esc_html_e( 'Download a CSV of income and donations over time.', 'give' ); ?></p> |
|
387 | + <h3><span><?php esc_html_e('Export Income and Donation Stats', 'give'); ?></span></h3> |
|
388 | + <p><?php esc_html_e('Download a CSV of income and donations over time.', 'give'); ?></p> |
|
389 | 389 | </td> |
390 | 390 | <td> |
391 | 391 | <form method="post"> |
392 | 392 | <?php |
393 | 393 | printf( |
394 | 394 | /* translators: 1: start date dropdown 2: end date dropdown */ |
395 | - esc_html__( '%1$s to %2$s', 'give' ), |
|
396 | - Give()->html->year_dropdown( 'start_year' ) . ' ' . Give()->html->month_dropdown( 'start_month' ), |
|
397 | - Give()->html->year_dropdown( 'end_year' ) . ' ' . Give()->html->month_dropdown( 'end_month' ) |
|
395 | + esc_html__('%1$s to %2$s', 'give'), |
|
396 | + Give()->html->year_dropdown('start_year').' '.Give()->html->month_dropdown('start_month'), |
|
397 | + Give()->html->year_dropdown('end_year').' '.Give()->html->month_dropdown('end_month') |
|
398 | 398 | ); |
399 | 399 | ?> |
400 | 400 | <input type="hidden" name="give-action" value="earnings_export"/> |
401 | - <input type="submit" value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" class="button-secondary"/> |
|
401 | + <input type="submit" value="<?php esc_attr_e('Generate CSV', 'give'); ?>" class="button-secondary"/> |
|
402 | 402 | </form> |
403 | 403 | </td> |
404 | 404 | </tr> |
405 | 405 | <tr class="give-export-payment-history"> |
406 | 406 | <td scope="row" class="row-title"> |
407 | - <h3><span><?php esc_html_e( 'Export Donation History', 'give' ); ?></span></h3> |
|
408 | - <p><?php esc_html_e( 'Download a CSV of all donations recorded.', 'give' ); ?></p> |
|
407 | + <h3><span><?php esc_html_e('Export Donation History', 'give'); ?></span></h3> |
|
408 | + <p><?php esc_html_e('Download a CSV of all donations recorded.', 'give'); ?></p> |
|
409 | 409 | </td> |
410 | 410 | <td> |
411 | 411 | <form id="give-export-payments" class="give-export-form" method="post"> |
@@ -413,27 +413,27 @@ discard block |
||
413 | 413 | $args = array( |
414 | 414 | 'id' => 'give-payment-export-start', |
415 | 415 | 'name' => 'start', |
416 | - 'placeholder' => esc_attr__( 'Start date', 'give' ), |
|
416 | + 'placeholder' => esc_attr__('Start date', 'give'), |
|
417 | 417 | ); |
418 | - echo Give()->html->date_field( $args ); ?> |
|
418 | + echo Give()->html->date_field($args); ?> |
|
419 | 419 | <?php |
420 | 420 | $args = array( |
421 | 421 | 'id' => 'give-payment-export-end', |
422 | 422 | 'name' => 'end', |
423 | - 'placeholder' => esc_attr__( 'End date', 'give' ), |
|
423 | + 'placeholder' => esc_attr__('End date', 'give'), |
|
424 | 424 | ); |
425 | - echo Give()->html->date_field( $args ); ?> |
|
425 | + echo Give()->html->date_field($args); ?> |
|
426 | 426 | <select name="status"> |
427 | - <option value="any"><?php esc_html_e( 'All Statuses', 'give' ); ?></option> |
|
427 | + <option value="any"><?php esc_html_e('All Statuses', 'give'); ?></option> |
|
428 | 428 | <?php |
429 | 429 | $statuses = give_get_payment_statuses(); |
430 | - foreach ( $statuses as $status => $label ) { |
|
431 | - echo '<option value="' . $status . '">' . $label . '</option>'; |
|
430 | + foreach ($statuses as $status => $label) { |
|
431 | + echo '<option value="'.$status.'">'.$label.'</option>'; |
|
432 | 432 | } |
433 | 433 | ?> |
434 | 434 | </select> |
435 | 435 | <?php |
436 | - if ( give_is_setting_enabled( give_get_option( 'categories' ) ) ) { |
|
436 | + if (give_is_setting_enabled(give_get_option('categories'))) { |
|
437 | 437 | echo Give()->html->category_dropdown( |
438 | 438 | 'give_forms_categories[]', |
439 | 439 | 0, |
@@ -443,12 +443,12 @@ discard block |
||
443 | 443 | 'multiple' => true, |
444 | 444 | 'selected' => array(), |
445 | 445 | 'show_option_all' => false, |
446 | - 'placeholder' => __( 'Choose one or more from categories', 'give' ), |
|
446 | + 'placeholder' => __('Choose one or more from categories', 'give'), |
|
447 | 447 | ) |
448 | 448 | ); |
449 | 449 | } |
450 | 450 | |
451 | - if ( give_is_setting_enabled( give_get_option( 'tags' ) ) ) { |
|
451 | + if (give_is_setting_enabled(give_get_option('tags'))) { |
|
452 | 452 | echo Give()->html->tags_dropdown( |
453 | 453 | 'give_forms_tags[]', |
454 | 454 | 0, |
@@ -458,16 +458,16 @@ discard block |
||
458 | 458 | 'multiple' => true, |
459 | 459 | 'selected' => array(), |
460 | 460 | 'show_option_all' => false, |
461 | - 'placeholder' => __( 'Choose one or more from tags', 'give' ), |
|
461 | + 'placeholder' => __('Choose one or more from tags', 'give'), |
|
462 | 462 | ) |
463 | 463 | ); |
464 | 464 | } |
465 | 465 | |
466 | - wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); |
|
466 | + wp_nonce_field('give_ajax_export', 'give_ajax_export'); |
|
467 | 467 | ?> |
468 | 468 | <input type="hidden" name="give-export-class" value="Give_Batch_Payments_Export"/> |
469 | 469 | <span> |
470 | - <input type="submit" value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" class="button-secondary"/> |
|
470 | + <input type="submit" value="<?php esc_attr_e('Generate CSV', 'give'); ?>" class="button-secondary"/> |
|
471 | 471 | <span class="spinner"></span> |
472 | 472 | </span> |
473 | 473 | </form> |
@@ -475,8 +475,8 @@ discard block |
||
475 | 475 | </tr> |
476 | 476 | <tr class="alternate give-export-donors"> |
477 | 477 | <td scope="row" class="row-title"> |
478 | - <h3><span><?php esc_html_e( 'Export Donors in CSV', 'give' ); ?></span></h3> |
|
479 | - <p><?php esc_html_e( 'Download an export of donors for all donation forms or only those who have given to a particular form.', 'give' ); ?></p> |
|
478 | + <h3><span><?php esc_html_e('Export Donors in CSV', 'give'); ?></span></h3> |
|
479 | + <p><?php esc_html_e('Download an export of donors for all donation forms or only those who have given to a particular form.', 'give'); ?></p> |
|
480 | 480 | </td> |
481 | 481 | <td> |
482 | 482 | <form method="post" id="give_donor_export" class="give-export-form"> |
@@ -487,46 +487,46 @@ discard block |
||
487 | 487 | 'id' => 'give_customer_export_form', |
488 | 488 | 'chosen' => true, |
489 | 489 | ); |
490 | - echo Give()->html->forms_dropdown( $args ); ?> |
|
490 | + echo Give()->html->forms_dropdown($args); ?> |
|
491 | 491 | |
492 | - <input type="submit" value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" class="button-secondary"/> |
|
492 | + <input type="submit" value="<?php esc_attr_e('Generate CSV', 'give'); ?>" class="button-secondary"/> |
|
493 | 493 | |
494 | 494 | <div id="export-donor-options-wrap" class="give-clearfix"> |
495 | - <p><?php esc_html_e( 'Export Columns:', 'give' ); ?></p> |
|
495 | + <p><?php esc_html_e('Export Columns:', 'give'); ?></p> |
|
496 | 496 | <ul id="give-export-option-ul"> |
497 | 497 | <li> |
498 | - <label for="give-export-fullname"><input type="checkbox" checked name="give_export_option[full_name]" id="give-export-fullname"><?php esc_html_e( 'Name', 'give' ); ?> |
|
498 | + <label for="give-export-fullname"><input type="checkbox" checked name="give_export_option[full_name]" id="give-export-fullname"><?php esc_html_e('Name', 'give'); ?> |
|
499 | 499 | </label> |
500 | 500 | </li> |
501 | 501 | <li> |
502 | - <label for="give-export-email"><input type="checkbox" checked name="give_export_option[email]" id="give-export-email"><?php esc_html_e( 'Email', 'give' ); ?> |
|
502 | + <label for="give-export-email"><input type="checkbox" checked name="give_export_option[email]" id="give-export-email"><?php esc_html_e('Email', 'give'); ?> |
|
503 | 503 | </label> |
504 | 504 | </li> |
505 | 505 | <li> |
506 | - <label for="give-export-address"><input type="checkbox" checked name="give_export_option[address]" id="give-export-address"><?php esc_html_e( 'Address', 'give' ); ?> |
|
506 | + <label for="give-export-address"><input type="checkbox" checked name="give_export_option[address]" id="give-export-address"><?php esc_html_e('Address', 'give'); ?> |
|
507 | 507 | </label> |
508 | 508 | </li> |
509 | 509 | <li> |
510 | - <label for="give-export-userid"><input type="checkbox" checked name="give_export_option[userid]" id="give-export-userid"><?php esc_html_e( 'User ID', 'give' ); ?> |
|
510 | + <label for="give-export-userid"><input type="checkbox" checked name="give_export_option[userid]" id="give-export-userid"><?php esc_html_e('User ID', 'give'); ?> |
|
511 | 511 | </label> |
512 | 512 | </li> |
513 | 513 | <li> |
514 | - <label for="give-export-first-donation-date"><input type="checkbox" checked name="give_export_option[date_first_donated]" id="give-export-first-donation-date"><?php esc_html_e( 'First Donation Date', 'give' ); ?> |
|
514 | + <label for="give-export-first-donation-date"><input type="checkbox" checked name="give_export_option[date_first_donated]" id="give-export-first-donation-date"><?php esc_html_e('First Donation Date', 'give'); ?> |
|
515 | 515 | </label> |
516 | 516 | </li> |
517 | 517 | <li> |
518 | - <label for="give-export-donation-number"><input type="checkbox" checked name="give_export_option[donations]" id="give-export-donation-number"><?php esc_html_e( 'Number of Donations', 'give' ); ?> |
|
518 | + <label for="give-export-donation-number"><input type="checkbox" checked name="give_export_option[donations]" id="give-export-donation-number"><?php esc_html_e('Number of Donations', 'give'); ?> |
|
519 | 519 | </label> |
520 | 520 | </li> |
521 | 521 | <li> |
522 | - <label for="give-export-donation-sum"><input type="checkbox" checked name="give_export_option[donation_sum]" id="give-export-donation-sum"><?php esc_html_e( 'Total Donated', 'give' ); ?> |
|
522 | + <label for="give-export-donation-sum"><input type="checkbox" checked name="give_export_option[donation_sum]" id="give-export-donation-sum"><?php esc_html_e('Total Donated', 'give'); ?> |
|
523 | 523 | </label> |
524 | 524 | </li> |
525 | 525 | </ul> |
526 | 526 | </div> |
527 | - <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?> |
|
527 | + <?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?> |
|
528 | 528 | <input type="hidden" name="give-export-class" value="Give_Batch_Customers_Export"/> |
529 | - <input type="hidden" name="give_export_option[query_id]" value="<?php echo uniqid( 'give_' ); ?>"/> |
|
529 | + <input type="hidden" name="give_export_option[query_id]" value="<?php echo uniqid('give_'); ?>"/> |
|
530 | 530 | </form> |
531 | 531 | </td> |
532 | 532 | </tr> |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | * |
539 | 539 | * @since 1.0 |
540 | 540 | */ |
541 | - do_action( 'give_reports_tab_export_table_bottom' ); |
|
541 | + do_action('give_reports_tab_export_table_bottom'); |
|
542 | 542 | ?> |
543 | 543 | </tbody> |
544 | 544 | </table> |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | * |
550 | 550 | * @since 1.0 |
551 | 551 | */ |
552 | - do_action( 'give_reports_tab_export_content_bottom' ); |
|
552 | + do_action('give_reports_tab_export_content_bottom'); |
|
553 | 553 | ?> |
554 | 554 | |
555 | 555 | </div> |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | <?php |
561 | 561 | } |
562 | 562 | |
563 | -add_action( 'give_reports_tab_export', 'give_reports_tab_export' ); |
|
563 | +add_action('give_reports_tab_export', 'give_reports_tab_export'); |
|
564 | 564 | |
565 | 565 | /** |
566 | 566 | * Renders the Reports page |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | */ |
571 | 571 | function give_reports_tab_logs() { |
572 | 572 | |
573 | - require( GIVE_PLUGIN_DIR . 'includes/admin/reporting/logs.php' ); |
|
573 | + require(GIVE_PLUGIN_DIR.'includes/admin/reporting/logs.php'); |
|
574 | 574 | |
575 | 575 | // Get current section. |
576 | 576 | $current_section = $_GET['section'] = give_get_current_setting_section(); |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | * |
581 | 581 | * @since 1.0 |
582 | 582 | */ |
583 | - do_action( "give_logs_view_{$current_section}" ); |
|
583 | + do_action("give_logs_view_{$current_section}"); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | /** |
@@ -591,9 +591,9 @@ discard block |
||
591 | 591 | */ |
592 | 592 | function give_estimated_monthly_stats() { |
593 | 593 | |
594 | - $estimated = get_transient( 'give_estimated_monthly_stats' ); |
|
594 | + $estimated = get_transient('give_estimated_monthly_stats'); |
|
595 | 595 | |
596 | - if ( false === $estimated ) { |
|
596 | + if (false === $estimated) { |
|
597 | 597 | |
598 | 598 | $estimated = array( |
599 | 599 | 'earnings' => 0, |
@@ -602,22 +602,22 @@ discard block |
||
602 | 602 | |
603 | 603 | $stats = new Give_Payment_Stats; |
604 | 604 | |
605 | - $to_date_earnings = $stats->get_earnings( 0, 'this_month' ); |
|
606 | - $to_date_sales = $stats->get_sales( 0, 'this_month' ); |
|
605 | + $to_date_earnings = $stats->get_earnings(0, 'this_month'); |
|
606 | + $to_date_sales = $stats->get_sales(0, 'this_month'); |
|
607 | 607 | |
608 | - $current_day = date( 'd', current_time( 'timestamp' ) ); |
|
609 | - $current_month = date( 'n', current_time( 'timestamp' ) ); |
|
610 | - $current_year = date( 'Y', current_time( 'timestamp' ) ); |
|
611 | - $days_in_month = cal_days_in_month( CAL_GREGORIAN, $current_month, $current_year ); |
|
608 | + $current_day = date('d', current_time('timestamp')); |
|
609 | + $current_month = date('n', current_time('timestamp')); |
|
610 | + $current_year = date('Y', current_time('timestamp')); |
|
611 | + $days_in_month = cal_days_in_month(CAL_GREGORIAN, $current_month, $current_year); |
|
612 | 612 | |
613 | - $estimated['earnings'] = ( $to_date_earnings / $current_day ) * $days_in_month; |
|
614 | - $estimated['sales'] = ( $to_date_sales / $current_day ) * $days_in_month; |
|
613 | + $estimated['earnings'] = ($to_date_earnings / $current_day) * $days_in_month; |
|
614 | + $estimated['sales'] = ($to_date_sales / $current_day) * $days_in_month; |
|
615 | 615 | |
616 | 616 | // Cache for one day |
617 | - set_transient( 'give_estimated_monthly_stats', $estimated, 86400 ); |
|
617 | + set_transient('give_estimated_monthly_stats', $estimated, 86400); |
|
618 | 618 | } |
619 | 619 | |
620 | - return maybe_unserialize( $estimated ); |
|
620 | + return maybe_unserialize($estimated); |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | // @TODO: After release 1.8 Donations -> Reports generates with new setting api, so we can remove some old code from this file. |
@@ -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 | |
@@ -62,26 +62,26 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @param array $request The Form Data passed into the batch processing |
64 | 64 | */ |
65 | - public function set_properties( $request ) { |
|
65 | + public function set_properties($request) { |
|
66 | 66 | |
67 | 67 | // Set data from form submission |
68 | - if ( isset( $_POST['form'] ) ) { |
|
69 | - parse_str( $_POST['form'], $this->data ); |
|
68 | + if (isset($_POST['form'])) { |
|
69 | + parse_str($_POST['form'], $this->data); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | $this->form = $this->data['forms']; |
73 | 73 | |
74 | 74 | // Setup donor ids cache. |
75 | - if( ! empty( $this->form ) ) { |
|
75 | + if ( ! empty($this->form)) { |
|
76 | 76 | // Cache donor ids to output unique list of donor. |
77 | - $this->query_id = give_clean( $_REQUEST['give_export_option']['query_id'] ); |
|
78 | - if( ! ( $this->donor_ids = get_transient( $this->query_id ) ) ) { |
|
77 | + $this->query_id = give_clean($_REQUEST['give_export_option']['query_id']); |
|
78 | + if ( ! ($this->donor_ids = get_transient($this->query_id))) { |
|
79 | 79 | $this->donor_ids = array(); |
80 | - set_transient( $this->query_id, $this->donor_ids, HOUR_IN_SECONDS ); |
|
80 | + set_transient($this->query_id, $this->donor_ids, HOUR_IN_SECONDS); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
84 | - $this->price_id = ! empty( $request['give_price_option'] ) && 'all' !== $request['give_price_option'] ? absint( $request['give_price_option'] ) : null; |
|
84 | + $this->price_id = ! empty($request['give_price_option']) && 'all' !== $request['give_price_option'] ? absint($request['give_price_option']) : null; |
|
85 | 85 | |
86 | 86 | } |
87 | 87 | |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function csv_cols() { |
96 | 96 | |
97 | - $columns = isset( $this->data['give_export_option'] ) ? $this->data['give_export_option'] : array(); |
|
97 | + $columns = isset($this->data['give_export_option']) ? $this->data['give_export_option'] : array(); |
|
98 | 98 | |
99 | 99 | // We need columns. |
100 | - if ( empty( $columns ) ) { |
|
100 | + if (empty($columns)) { |
|
101 | 101 | return false; |
102 | 102 | } |
103 | 103 | |
104 | - $cols = $this->get_cols( $columns ); |
|
104 | + $cols = $this->get_cols($columns); |
|
105 | 105 | |
106 | 106 | return $cols; |
107 | 107 | } |
@@ -113,38 +113,38 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return array |
115 | 115 | */ |
116 | - private function get_cols( $columns ) { |
|
116 | + private function get_cols($columns) { |
|
117 | 117 | |
118 | 118 | $cols = array(); |
119 | 119 | |
120 | - foreach ( $columns as $key => $value ) { |
|
120 | + foreach ($columns as $key => $value) { |
|
121 | 121 | |
122 | - switch ( $key ) { |
|
122 | + switch ($key) { |
|
123 | 123 | case 'full_name' : |
124 | - $cols['full_name'] = esc_html__( 'Full Name', 'give' ); |
|
124 | + $cols['full_name'] = esc_html__('Full Name', 'give'); |
|
125 | 125 | break; |
126 | 126 | case 'email' : |
127 | - $cols['email'] = esc_html__( 'Email Address', 'give' ); |
|
127 | + $cols['email'] = esc_html__('Email Address', 'give'); |
|
128 | 128 | break; |
129 | 129 | case 'address' : |
130 | - $cols['address_line1'] = esc_html__( 'Address', 'give' ); |
|
131 | - $cols['address_line2'] = esc_html__( 'Address 2', 'give' ); |
|
132 | - $cols['address_city'] = esc_html__( 'City', 'give' ); |
|
133 | - $cols['address_state'] = esc_html__( 'State', 'give' ); |
|
134 | - $cols['address_zip'] = esc_html__( 'Zip', 'give' ); |
|
135 | - $cols['address_country'] = esc_html__( 'Country', 'give' ); |
|
130 | + $cols['address_line1'] = esc_html__('Address', 'give'); |
|
131 | + $cols['address_line2'] = esc_html__('Address 2', 'give'); |
|
132 | + $cols['address_city'] = esc_html__('City', 'give'); |
|
133 | + $cols['address_state'] = esc_html__('State', 'give'); |
|
134 | + $cols['address_zip'] = esc_html__('Zip', 'give'); |
|
135 | + $cols['address_country'] = esc_html__('Country', 'give'); |
|
136 | 136 | break; |
137 | 137 | case 'userid' : |
138 | - $cols['userid'] = esc_html__( 'User ID', 'give' ); |
|
138 | + $cols['userid'] = esc_html__('User ID', 'give'); |
|
139 | 139 | break; |
140 | 140 | case 'date_first_donated' : |
141 | - $cols['date_first_donated'] = esc_html__( 'First Donation Date', 'give' ); |
|
141 | + $cols['date_first_donated'] = esc_html__('First Donation Date', 'give'); |
|
142 | 142 | break; |
143 | 143 | case 'donations' : |
144 | - $cols['donations'] = esc_html__( 'Number of Donations', 'give' ); |
|
144 | + $cols['donations'] = esc_html__('Number of Donations', 'give'); |
|
145 | 145 | break; |
146 | 146 | case 'donation_sum' : |
147 | - $cols['donation_sum'] = esc_html__( 'Sum of Donations', 'give' ); |
|
147 | + $cols['donation_sum'] = esc_html__('Sum of Donations', 'give'); |
|
148 | 148 | break; |
149 | 149 | } |
150 | 150 | } |
@@ -167,20 +167,20 @@ discard block |
||
167 | 167 | |
168 | 168 | $i = 0; |
169 | 169 | |
170 | - if ( ! empty( $this->form ) ) { |
|
170 | + if ( ! empty($this->form)) { |
|
171 | 171 | |
172 | 172 | // Export donors of a specific product |
173 | 173 | global $give_logs; |
174 | 174 | |
175 | 175 | $args = array( |
176 | - 'post_parent' => absint( $this->form ), |
|
176 | + 'post_parent' => absint($this->form), |
|
177 | 177 | 'log_type' => 'sale', |
178 | 178 | 'posts_per_page' => 30, |
179 | 179 | 'paged' => $this->step, |
180 | 180 | ); |
181 | 181 | |
182 | 182 | // Check for price option |
183 | - if ( null !== $this->price_id ) { |
|
183 | + if (null !== $this->price_id) { |
|
184 | 184 | $args['meta_query'] = array( |
185 | 185 | array( |
186 | 186 | 'key' => '_give_log_price_id', |
@@ -189,44 +189,44 @@ discard block |
||
189 | 189 | ); |
190 | 190 | } |
191 | 191 | |
192 | - $logs = $give_logs->get_connected_logs( $args ); |
|
192 | + $logs = $give_logs->get_connected_logs($args); |
|
193 | 193 | |
194 | - if ( $logs ) { |
|
195 | - foreach ( $logs as $log ) { |
|
196 | - $payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true ); |
|
197 | - $payment = new Give_Payment( $payment_id ); |
|
194 | + if ($logs) { |
|
195 | + foreach ($logs as $log) { |
|
196 | + $payment_id = get_post_meta($log->ID, '_give_log_payment_id', true); |
|
197 | + $payment = new Give_Payment($payment_id); |
|
198 | 198 | |
199 | 199 | // Continue if donor already included. |
200 | - if( in_array( $payment->customer_id , $this->donor_ids ) ) { |
|
200 | + if (in_array($payment->customer_id, $this->donor_ids)) { |
|
201 | 201 | continue; |
202 | 202 | } |
203 | 203 | |
204 | 204 | $this->donor_ids[] = $payment->customer_id; |
205 | 205 | |
206 | - $donor = Give()->customers->get_customer_by( 'id', $payment->customer_id ); |
|
207 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
208 | - $i ++; |
|
206 | + $donor = Give()->customers->get_customer_by('id', $payment->customer_id); |
|
207 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
208 | + $i++; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | // Cache donor ids only if admin export donor for specific form. |
212 | - set_transient( $this->query_id, array_unique( $this->donor_ids ), HOUR_IN_SECONDS ); |
|
212 | + set_transient($this->query_id, array_unique($this->donor_ids), HOUR_IN_SECONDS); |
|
213 | 213 | } |
214 | 214 | } else { |
215 | 215 | |
216 | 216 | // Export all donors. |
217 | - $offset = 30 * ( $this->step - 1 ); |
|
218 | - $donors = Give()->customers->get_customers( array( 'number' => 30, 'offset' => $offset ) ); |
|
217 | + $offset = 30 * ($this->step - 1); |
|
218 | + $donors = Give()->customers->get_customers(array('number' => 30, 'offset' => $offset)); |
|
219 | 219 | |
220 | - foreach ( $donors as $donor ) { |
|
220 | + foreach ($donors as $donor) { |
|
221 | 221 | |
222 | - $data[] = $this->set_donor_data( $i, $data, $donor ); |
|
223 | - $i ++; |
|
222 | + $data[] = $this->set_donor_data($i, $data, $donor); |
|
223 | + $i++; |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | 227 | |
228 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
229 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
228 | + $data = apply_filters('give_export_get_data', $data); |
|
229 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
230 | 230 | |
231 | 231 | return $data; |
232 | 232 | } |
@@ -242,18 +242,18 @@ discard block |
||
242 | 242 | $percentage = 0; |
243 | 243 | |
244 | 244 | // We can't count the number when getting them for a specific form |
245 | - if ( empty( $this->form ) ) { |
|
245 | + if (empty($this->form)) { |
|
246 | 246 | |
247 | 247 | $total = Give()->customers->count(); |
248 | 248 | |
249 | - if ( $total > 0 ) { |
|
249 | + if ($total > 0) { |
|
250 | 250 | |
251 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
251 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
252 | 252 | |
253 | 253 | } |
254 | 254 | } |
255 | 255 | |
256 | - if ( $percentage > 100 ) { |
|
256 | + if ($percentage > 100) { |
|
257 | 257 | $percentage = 100; |
258 | 258 | } |
259 | 259 | |
@@ -269,46 +269,46 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return mixed |
271 | 271 | */ |
272 | - private function set_donor_data( $i, $data, $donor ) { |
|
272 | + private function set_donor_data($i, $data, $donor) { |
|
273 | 273 | |
274 | 274 | $columns = $this->csv_cols(); |
275 | 275 | |
276 | 276 | // Set address variable |
277 | 277 | $address = ''; |
278 | - if ( isset( $donor->user_id ) && $donor->user_id > 0 ) { |
|
279 | - $address = give_get_donor_address( $donor->user_id ); |
|
278 | + if (isset($donor->user_id) && $donor->user_id > 0) { |
|
279 | + $address = give_get_donor_address($donor->user_id); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | // Set columns |
283 | - if ( ! empty( $columns['full_name'] ) ) { |
|
284 | - $data[ $i ]['full_name'] = $donor->name; |
|
283 | + if ( ! empty($columns['full_name'])) { |
|
284 | + $data[$i]['full_name'] = $donor->name; |
|
285 | 285 | } |
286 | - if ( ! empty( $columns['email'] ) ) { |
|
287 | - $data[ $i ]['email'] = $donor->email; |
|
286 | + if ( ! empty($columns['email'])) { |
|
287 | + $data[$i]['email'] = $donor->email; |
|
288 | 288 | } |
289 | - if ( ! empty( $columns['address_line1'] ) ) { |
|
290 | - |
|
291 | - $data[ $i ]['address_line1'] = isset( $address['line1'] ) ? $address['line1'] : ''; |
|
292 | - $data[ $i ]['address_line2'] = isset( $address['line2'] ) ? $address['line2'] : ''; |
|
293 | - $data[ $i ]['address_city'] = isset( $address['city'] ) ? $address['city'] : ''; |
|
294 | - $data[ $i ]['address_state'] = isset( $address['state'] ) ? $address['state'] : ''; |
|
295 | - $data[ $i ]['address_zip'] = isset( $address['zip'] ) ? $address['zip'] : ''; |
|
296 | - $data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : ''; |
|
289 | + if ( ! empty($columns['address_line1'])) { |
|
290 | + |
|
291 | + $data[$i]['address_line1'] = isset($address['line1']) ? $address['line1'] : ''; |
|
292 | + $data[$i]['address_line2'] = isset($address['line2']) ? $address['line2'] : ''; |
|
293 | + $data[$i]['address_city'] = isset($address['city']) ? $address['city'] : ''; |
|
294 | + $data[$i]['address_state'] = isset($address['state']) ? $address['state'] : ''; |
|
295 | + $data[$i]['address_zip'] = isset($address['zip']) ? $address['zip'] : ''; |
|
296 | + $data[$i]['address_country'] = isset($address['country']) ? $address['country'] : ''; |
|
297 | 297 | } |
298 | - if ( ! empty( $columns['userid'] ) ) { |
|
299 | - $data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : ''; |
|
298 | + if ( ! empty($columns['userid'])) { |
|
299 | + $data[$i]['userid'] = ! empty($donor->user_id) ? $donor->user_id : ''; |
|
300 | 300 | } |
301 | - if ( ! empty( $columns['date_first_donated'] ) ) { |
|
302 | - $data[ $i ]['date_first_donated'] = date_i18n( give_date_format(), strtotime( $donor->date_created ) ); |
|
301 | + if ( ! empty($columns['date_first_donated'])) { |
|
302 | + $data[$i]['date_first_donated'] = date_i18n(give_date_format(), strtotime($donor->date_created)); |
|
303 | 303 | } |
304 | - if ( ! empty( $columns['donations'] ) ) { |
|
305 | - $data[ $i ]['donations'] = $donor->purchase_count; |
|
304 | + if ( ! empty($columns['donations'])) { |
|
305 | + $data[$i]['donations'] = $donor->purchase_count; |
|
306 | 306 | } |
307 | - if ( ! empty( $columns['donation_sum'] ) ) { |
|
308 | - $data[ $i ]['donation_sum'] = give_format_amount( $donor->purchase_value ); |
|
307 | + if ( ! empty($columns['donation_sum'])) { |
|
308 | + $data[$i]['donation_sum'] = give_format_amount($donor->purchase_value); |
|
309 | 309 | } |
310 | 310 | |
311 | - return $data[ $i ]; |
|
311 | + return $data[$i]; |
|
312 | 312 | |
313 | 313 | } |
314 | 314 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @license https://opensource.org/licenses/gpl-license GNU Public License |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function give_process_batch_export_form() { |
24 | 24 | |
25 | - if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'give-batch-export' ) ) { |
|
26 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
25 | + if ( ! wp_verify_nonce($_REQUEST['nonce'], 'give-batch-export')) { |
|
26 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
27 | 27 | } |
28 | 28 | |
29 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php'; |
|
29 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export.php'; |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Fires before batch export. |
@@ -35,14 +35,14 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @param string $class Export class. |
37 | 37 | */ |
38 | - do_action( 'give_batch_export_class_include', $_REQUEST['class'] ); |
|
38 | + do_action('give_batch_export_class_include', $_REQUEST['class']); |
|
39 | 39 | |
40 | 40 | $export = new $_REQUEST['class']; |
41 | 41 | $export->export(); |
42 | 42 | |
43 | 43 | } |
44 | 44 | |
45 | -add_action( 'give_form_batch_export', 'give_process_batch_export_form' ); |
|
45 | +add_action('give_form_batch_export', 'give_process_batch_export_form'); |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Exports earnings for a specified time period |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | * @return void |
54 | 54 | */ |
55 | 55 | function give_export_earnings() { |
56 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export-earnings.php'; |
|
56 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export-earnings.php'; |
|
57 | 57 | |
58 | 58 | $earnings_export = new Give_Earnings_Export(); |
59 | 59 | |
60 | 60 | $earnings_export->export(); |
61 | 61 | } |
62 | 62 | |
63 | -add_action( 'give_earnings_export', 'give_export_earnings' ); |
|
63 | +add_action('give_earnings_export', 'give_export_earnings'); |
|
64 | 64 | |
65 | 65 | |
66 | 66 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return void |
71 | 71 | */ |
72 | 72 | function give_register_batch_exporters() { |
73 | - if ( is_admin() ) { |
|
73 | + if (is_admin()) { |
|
74 | 74 | /** |
75 | 75 | * Fires in the admin, while plugins loaded. |
76 | 76 | * |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param string $class Export class. |
82 | 82 | */ |
83 | - do_action( 'give_register_batch_exporter' ); |
|
83 | + do_action('give_register_batch_exporter'); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | -add_action( 'plugins_loaded', 'give_register_batch_exporters' ); |
|
87 | +add_action('plugins_loaded', 'give_register_batch_exporters'); |
|
88 | 88 | |
89 | 89 | /** |
90 | 90 | * Register the payments batch exporter |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | * @since 1.5 |
93 | 93 | */ |
94 | 94 | function give_register_payments_batch_export() { |
95 | - add_action( 'give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1 ); |
|
95 | + add_action('give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1); |
|
96 | 96 | } |
97 | 97 | |
98 | -add_action( 'give_register_batch_exporter', 'give_register_payments_batch_export', 10 ); |
|
98 | +add_action('give_register_batch_exporter', 'give_register_payments_batch_export', 10); |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Loads the payments batch process if needed |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @return void |
108 | 108 | */ |
109 | -function give_include_payments_batch_processor( $class ) { |
|
109 | +function give_include_payments_batch_processor($class) { |
|
110 | 110 | |
111 | - if ( 'Give_Batch_Payments_Export' === $class ) { |
|
112 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-payments.php'; |
|
111 | + if ('Give_Batch_Payments_Export' === $class) { |
|
112 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-payments.php'; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | } |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | * @since 1.5.2 |
121 | 121 | */ |
122 | 122 | function give_register_customers_batch_export() { |
123 | - add_action( 'give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1 ); |
|
123 | + add_action('give_batch_export_class_include', 'give_include_customers_batch_processor', 10, 1); |
|
124 | 124 | } |
125 | 125 | |
126 | -add_action( 'give_register_batch_exporter', 'give_register_customers_batch_export', 10 ); |
|
126 | +add_action('give_register_batch_exporter', 'give_register_customers_batch_export', 10); |
|
127 | 127 | |
128 | 128 | /** |
129 | 129 | * Loads the customers batch process if needed |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return void |
136 | 136 | */ |
137 | -function give_include_customers_batch_processor( $class ) { |
|
137 | +function give_include_customers_batch_processor($class) { |
|
138 | 138 | |
139 | - if ( 'Give_Batch_Customers_Export' === $class ) { |
|
140 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-customers.php'; |
|
139 | + if ('Give_Batch_Customers_Export' === $class) { |
|
140 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-customers.php'; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | } |
@@ -148,10 +148,10 @@ discard block |
||
148 | 148 | * @since 1.5 |
149 | 149 | */ |
150 | 150 | function give_register_forms_batch_export() { |
151 | - add_action( 'give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1 ); |
|
151 | + add_action('give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1); |
|
152 | 152 | } |
153 | 153 | |
154 | -add_action( 'give_register_batch_exporter', 'give_register_forms_batch_export', 10 ); |
|
154 | +add_action('give_register_batch_exporter', 'give_register_forms_batch_export', 10); |
|
155 | 155 | |
156 | 156 | /** |
157 | 157 | * Loads the file downloads batch process if needed |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return void |
164 | 164 | */ |
165 | -function give_include_forms_batch_processor( $class ) { |
|
165 | +function give_include_forms_batch_processor($class) { |
|
166 | 166 | |
167 | - if ( 'Give_Batch_Forms_Export' === $class ) { |
|
168 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export-forms.php'; |
|
167 | + if ('Give_Batch_Forms_Export' === $class) { |
|
168 | + require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export-forms.php'; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | } |
@@ -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 | |
@@ -26,26 +26,26 @@ discard block |
||
26 | 26 | function give_test_ajax_works() { |
27 | 27 | |
28 | 28 | // Check if the Airplane Mode plugin is installed |
29 | - if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
29 | + if (class_exists('Airplane_Mode_Core')) { |
|
30 | 30 | |
31 | 31 | $airplane = Airplane_Mode_Core::getInstance(); |
32 | 32 | |
33 | - if ( method_exists( $airplane, 'enabled' ) ) { |
|
33 | + if (method_exists($airplane, 'enabled')) { |
|
34 | 34 | |
35 | - if ( $airplane->enabled() ) { |
|
35 | + if ($airplane->enabled()) { |
|
36 | 36 | return true; |
37 | 37 | } |
38 | 38 | } else { |
39 | 39 | |
40 | - if ( $airplane->check_status() == 'on' ) { |
|
40 | + if ($airplane->check_status() == 'on') { |
|
41 | 41 | return true; |
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | - add_filter( 'block_local_requests', '__return_false' ); |
|
46 | + add_filter('block_local_requests', '__return_false'); |
|
47 | 47 | |
48 | - if ( get_transient( '_give_ajax_works' ) ) { |
|
48 | + if (get_transient('_give_ajax_works')) { |
|
49 | 49 | return true; |
50 | 50 | } |
51 | 51 | |
@@ -57,35 +57,35 @@ discard block |
||
57 | 57 | ), |
58 | 58 | ); |
59 | 59 | |
60 | - $ajax = wp_remote_post( give_get_ajax_url(), $params ); |
|
60 | + $ajax = wp_remote_post(give_get_ajax_url(), $params); |
|
61 | 61 | |
62 | 62 | $works = true; |
63 | 63 | |
64 | - if ( is_wp_error( $ajax ) ) { |
|
64 | + if (is_wp_error($ajax)) { |
|
65 | 65 | |
66 | 66 | $works = false; |
67 | 67 | |
68 | 68 | } else { |
69 | 69 | |
70 | - if ( empty( $ajax['response'] ) ) { |
|
70 | + if (empty($ajax['response'])) { |
|
71 | 71 | $works = false; |
72 | 72 | } |
73 | 73 | |
74 | - if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) { |
|
74 | + if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) { |
|
75 | 75 | $works = false; |
76 | 76 | } |
77 | 77 | |
78 | - if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) { |
|
78 | + if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) { |
|
79 | 79 | $works = false; |
80 | 80 | } |
81 | 81 | |
82 | - if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) { |
|
82 | + if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) { |
|
83 | 83 | $works = false; |
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | - if ( $works ) { |
|
88 | - set_transient( '_give_ajax_works', '1', DAY_IN_SECONDS ); |
|
87 | + if ($works) { |
|
88 | + set_transient('_give_ajax_works', '1', DAY_IN_SECONDS); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | return $works; |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | * @return string |
101 | 101 | */ |
102 | 102 | function give_get_ajax_url() { |
103 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
103 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
104 | 104 | |
105 | 105 | $current_url = give_get_current_page_url(); |
106 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
106 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
107 | 107 | |
108 | - if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) { |
|
109 | - $ajax_url = preg_replace( '/^http/', 'https', $ajax_url ); |
|
108 | + if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) { |
|
109 | + $ajax_url = preg_replace('/^http/', 'https', $ajax_url); |
|
110 | 110 | } |
111 | 111 | |
112 | - return apply_filters( 'give_ajax_url', $ajax_url ); |
|
112 | + return apply_filters('give_ajax_url', $ajax_url); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -125,12 +125,12 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @since 1.7 |
127 | 127 | */ |
128 | - do_action( 'give_donation_form_login_fields' ); |
|
128 | + do_action('give_donation_form_login_fields'); |
|
129 | 129 | |
130 | 130 | give_die(); |
131 | 131 | } |
132 | 132 | |
133 | -add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' ); |
|
133 | +add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields'); |
|
134 | 134 | |
135 | 135 | /** |
136 | 136 | * Load Checkout Fields |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @return void |
141 | 141 | */ |
142 | 142 | function give_load_checkout_fields() { |
143 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : ''; |
|
143 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : ''; |
|
144 | 144 | |
145 | 145 | ob_start(); |
146 | 146 | |
@@ -149,18 +149,18 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @since 1.7 |
151 | 151 | */ |
152 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
152 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
153 | 153 | |
154 | 154 | $fields = ob_get_clean(); |
155 | 155 | |
156 | - wp_send_json( array( |
|
157 | - 'fields' => wp_json_encode( $fields ), |
|
158 | - 'submit' => wp_json_encode( give_checkout_button_purchase( $form_id ) ), |
|
159 | - ) ); |
|
156 | + wp_send_json(array( |
|
157 | + 'fields' => wp_json_encode($fields), |
|
158 | + 'submit' => wp_json_encode(give_checkout_button_purchase($form_id)), |
|
159 | + )); |
|
160 | 160 | } |
161 | 161 | |
162 | -add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' ); |
|
163 | -add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' ); |
|
162 | +add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields'); |
|
163 | +add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields'); |
|
164 | 164 | |
165 | 165 | /** |
166 | 166 | * Get Form Title via AJAX (used only in WordPress Admin) |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | * @return void |
171 | 171 | */ |
172 | 172 | function give_ajax_get_form_title() { |
173 | - if ( isset( $_POST['form_id'] ) ) { |
|
174 | - $title = get_the_title( $_POST['form_id'] ); |
|
175 | - if ( $title ) { |
|
173 | + if (isset($_POST['form_id'])) { |
|
174 | + $title = get_the_title($_POST['form_id']); |
|
175 | + if ($title) { |
|
176 | 176 | echo $title; |
177 | 177 | } else { |
178 | 178 | echo 'fail'; |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | give_die(); |
182 | 182 | } |
183 | 183 | |
184 | -add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' ); |
|
185 | -add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' ); |
|
184 | +add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title'); |
|
185 | +add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title'); |
|
186 | 186 | |
187 | 187 | /** |
188 | 188 | * Retrieve a states drop down |
@@ -193,23 +193,23 @@ discard block |
||
193 | 193 | */ |
194 | 194 | function give_ajax_get_states_field() { |
195 | 195 | |
196 | - if ( empty( $_POST['country'] ) ) { |
|
196 | + if (empty($_POST['country'])) { |
|
197 | 197 | $_POST['country'] = give_get_country(); |
198 | 198 | } |
199 | - $states = give_get_states( $_POST['country'] ); |
|
199 | + $states = give_get_states($_POST['country']); |
|
200 | 200 | |
201 | - if ( ! empty( $states ) ) { |
|
201 | + if ( ! empty($states)) { |
|
202 | 202 | |
203 | 203 | $args = array( |
204 | 204 | 'name' => $_POST['field_name'], |
205 | 205 | 'id' => $_POST['field_name'], |
206 | - 'class' => $_POST['field_name'] . ' give-select', |
|
207 | - 'options' => give_get_states( $_POST['country'] ), |
|
206 | + 'class' => $_POST['field_name'].' give-select', |
|
207 | + 'options' => give_get_states($_POST['country']), |
|
208 | 208 | 'show_option_all' => false, |
209 | 209 | 'show_option_none' => false, |
210 | 210 | ); |
211 | 211 | |
212 | - $response = Give()->html->select( $args ); |
|
212 | + $response = Give()->html->select($args); |
|
213 | 213 | |
214 | 214 | } else { |
215 | 215 | |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | give_die(); |
222 | 222 | } |
223 | 223 | |
224 | -add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' ); |
|
225 | -add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' ); |
|
224 | +add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field'); |
|
225 | +add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field'); |
|
226 | 226 | |
227 | 227 | /** |
228 | 228 | * Retrieve a states drop down |
@@ -234,17 +234,17 @@ discard block |
||
234 | 234 | function give_ajax_form_search() { |
235 | 235 | global $wpdb; |
236 | 236 | |
237 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
237 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
238 | 238 | $results = array(); |
239 | - if ( current_user_can( 'edit_give_forms' ) ) { |
|
240 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
239 | + if (current_user_can('edit_give_forms')) { |
|
240 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
241 | 241 | } else { |
242 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
242 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
243 | 243 | } |
244 | 244 | |
245 | - if ( $items ) { |
|
245 | + if ($items) { |
|
246 | 246 | |
247 | - foreach ( $items as $item ) { |
|
247 | + foreach ($items as $item) { |
|
248 | 248 | |
249 | 249 | $results[] = array( |
250 | 250 | 'id' => $item->ID, |
@@ -255,18 +255,18 @@ discard block |
||
255 | 255 | |
256 | 256 | $items[] = array( |
257 | 257 | 'id' => 0, |
258 | - 'name' => esc_html__( 'No forms found.', 'give' ), |
|
258 | + 'name' => esc_html__('No forms found.', 'give'), |
|
259 | 259 | ); |
260 | 260 | |
261 | 261 | } |
262 | 262 | |
263 | - echo json_encode( $results ); |
|
263 | + echo json_encode($results); |
|
264 | 264 | |
265 | 265 | give_die(); |
266 | 266 | } |
267 | 267 | |
268 | -add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' ); |
|
269 | -add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' ); |
|
268 | +add_action('wp_ajax_give_form_search', 'give_ajax_form_search'); |
|
269 | +add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search'); |
|
270 | 270 | |
271 | 271 | /** |
272 | 272 | * Search the donors database via Ajax |
@@ -278,38 +278,38 @@ discard block |
||
278 | 278 | function give_ajax_donor_search() { |
279 | 279 | global $wpdb; |
280 | 280 | |
281 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
281 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
282 | 282 | $results = array(); |
283 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
283 | + if ( ! current_user_can('view_give_reports')) { |
|
284 | 284 | $donors = array(); |
285 | 285 | } else { |
286 | - $donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" ); |
|
286 | + $donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50"); |
|
287 | 287 | } |
288 | 288 | |
289 | - if ( $donors ) { |
|
289 | + if ($donors) { |
|
290 | 290 | |
291 | - foreach ( $donors as $donor ) { |
|
291 | + foreach ($donors as $donor) { |
|
292 | 292 | |
293 | 293 | $results[] = array( |
294 | 294 | 'id' => $donor->id, |
295 | - 'name' => $donor->name . '(' . $donor->email . ')', |
|
295 | + 'name' => $donor->name.'('.$donor->email.')', |
|
296 | 296 | ); |
297 | 297 | } |
298 | 298 | } else { |
299 | 299 | |
300 | 300 | $donors[] = array( |
301 | 301 | 'id' => 0, |
302 | - 'name' => esc_html__( 'No donors found.', 'give' ), |
|
302 | + 'name' => esc_html__('No donors found.', 'give'), |
|
303 | 303 | ); |
304 | 304 | |
305 | 305 | } |
306 | 306 | |
307 | - echo json_encode( $results ); |
|
307 | + echo json_encode($results); |
|
308 | 308 | |
309 | 309 | give_die(); |
310 | 310 | } |
311 | 311 | |
312 | -add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' ); |
|
312 | +add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search'); |
|
313 | 313 | |
314 | 314 | |
315 | 315 | /** |
@@ -321,42 +321,42 @@ discard block |
||
321 | 321 | */ |
322 | 322 | function give_ajax_search_users() { |
323 | 323 | |
324 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
324 | + if (current_user_can('manage_give_settings')) { |
|
325 | 325 | |
326 | - $search_query = trim( $_POST['user_name'] ); |
|
327 | - $exclude = trim( $_POST['exclude'] ); |
|
326 | + $search_query = trim($_POST['user_name']); |
|
327 | + $exclude = trim($_POST['exclude']); |
|
328 | 328 | |
329 | 329 | $get_users_args = array( |
330 | 330 | 'number' => 9999, |
331 | - 'search' => $search_query . '*', |
|
331 | + 'search' => $search_query.'*', |
|
332 | 332 | ); |
333 | 333 | |
334 | - if ( ! empty( $exclude ) ) { |
|
335 | - $exclude_array = explode( ',', $exclude ); |
|
334 | + if ( ! empty($exclude)) { |
|
335 | + $exclude_array = explode(',', $exclude); |
|
336 | 336 | $get_users_args['exclude'] = $exclude_array; |
337 | 337 | } |
338 | 338 | |
339 | - $get_users_args = apply_filters( 'give_search_users_args', $get_users_args ); |
|
339 | + $get_users_args = apply_filters('give_search_users_args', $get_users_args); |
|
340 | 340 | |
341 | - $found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search_query ); |
|
341 | + $found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search_query); |
|
342 | 342 | |
343 | 343 | $user_list = '<ul>'; |
344 | - if ( $found_users ) { |
|
345 | - foreach ( $found_users as $user ) { |
|
346 | - $user_list .= '<li><a href="#" data-userid="' . esc_attr( $user->ID ) . '" data-login="' . esc_attr( $user->user_login ) . '">' . esc_html( $user->user_login ) . '</a></li>'; |
|
344 | + if ($found_users) { |
|
345 | + foreach ($found_users as $user) { |
|
346 | + $user_list .= '<li><a href="#" data-userid="'.esc_attr($user->ID).'" data-login="'.esc_attr($user->user_login).'">'.esc_html($user->user_login).'</a></li>'; |
|
347 | 347 | } |
348 | 348 | } else { |
349 | - $user_list .= '<li>' . esc_html__( 'No users found.', 'give' ) . '</li>'; |
|
349 | + $user_list .= '<li>'.esc_html__('No users found.', 'give').'</li>'; |
|
350 | 350 | } |
351 | 351 | $user_list .= '</ul>'; |
352 | 352 | |
353 | - echo json_encode( array( 'results' => $user_list ) ); |
|
353 | + echo json_encode(array('results' => $user_list)); |
|
354 | 354 | |
355 | 355 | } |
356 | 356 | die(); |
357 | 357 | } |
358 | 358 | |
359 | -add_action( 'wp_ajax_give_search_users', 'give_ajax_search_users' ); |
|
359 | +add_action('wp_ajax_give_search_users', 'give_ajax_search_users'); |
|
360 | 360 | |
361 | 361 | |
362 | 362 | /** |
@@ -368,32 +368,32 @@ discard block |
||
368 | 368 | */ |
369 | 369 | function give_check_for_form_price_variations() { |
370 | 370 | |
371 | - if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
372 | - die( '-1' ); |
|
371 | + if ( ! current_user_can('edit_give_forms', get_current_user_id())) { |
|
372 | + die('-1'); |
|
373 | 373 | } |
374 | 374 | |
375 | - $form_id = intval( $_POST['form_id'] ); |
|
376 | - $form = get_post( $form_id ); |
|
375 | + $form_id = intval($_POST['form_id']); |
|
376 | + $form = get_post($form_id); |
|
377 | 377 | |
378 | - if ( 'give_forms' != $form->post_type ) { |
|
379 | - die( '-2' ); |
|
378 | + if ('give_forms' != $form->post_type) { |
|
379 | + die('-2'); |
|
380 | 380 | } |
381 | 381 | |
382 | - if ( give_has_variable_prices( $form_id ) ) { |
|
383 | - $variable_prices = give_get_variable_prices( $form_id ); |
|
382 | + if (give_has_variable_prices($form_id)) { |
|
383 | + $variable_prices = give_get_variable_prices($form_id); |
|
384 | 384 | |
385 | - if ( $variable_prices ) { |
|
385 | + if ($variable_prices) { |
|
386 | 386 | $ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">'; |
387 | 387 | |
388 | - if ( isset( $_POST['all_prices'] ) ) { |
|
389 | - $ajax_response .= '<option value="all">' . esc_html__( 'All Levels', 'give' ) . '</option>'; |
|
388 | + if (isset($_POST['all_prices'])) { |
|
389 | + $ajax_response .= '<option value="all">'.esc_html__('All Levels', 'give').'</option>'; |
|
390 | 390 | } |
391 | 391 | |
392 | - foreach ( $variable_prices as $key => $price ) { |
|
392 | + foreach ($variable_prices as $key => $price) { |
|
393 | 393 | |
394 | - $level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'] ) ); |
|
394 | + $level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount'])); |
|
395 | 395 | |
396 | - $ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>'; |
|
396 | + $ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>'; |
|
397 | 397 | } |
398 | 398 | $ajax_response .= '</select>'; |
399 | 399 | echo $ajax_response; |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | give_die(); |
404 | 404 | } |
405 | 405 | |
406 | -add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' ); |
|
406 | +add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations'); |
|
407 | 407 | |
408 | 408 | |
409 | 409 | /** |
@@ -414,25 +414,25 @@ discard block |
||
414 | 414 | * @return void |
415 | 415 | */ |
416 | 416 | function give_check_for_form_price_variations_html() { |
417 | - if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) { |
|
417 | + if ( ! current_user_can('edit_give_payments', get_current_user_id())) { |
|
418 | 418 | wp_die(); |
419 | 419 | } |
420 | 420 | |
421 | - $form_id = ! empty( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : 0; |
|
422 | - $payment_id = ! empty( $_POST['payment_id'] ) ? intval( $_POST['payment_id'] ) : 0; |
|
423 | - $form = get_post( $form_id ); |
|
421 | + $form_id = ! empty($_POST['form_id']) ? intval($_POST['form_id']) : 0; |
|
422 | + $payment_id = ! empty($_POST['payment_id']) ? intval($_POST['payment_id']) : 0; |
|
423 | + $form = get_post($form_id); |
|
424 | 424 | |
425 | - if ( 'give_forms' != $form->post_type ) { |
|
425 | + if ('give_forms' != $form->post_type) { |
|
426 | 426 | wp_die(); |
427 | 427 | } |
428 | 428 | |
429 | - if ( ! give_has_variable_prices( $form_id ) || ! $form_id ) { |
|
430 | - esc_html_e( 'n/a', 'give' ); |
|
429 | + if ( ! give_has_variable_prices($form_id) || ! $form_id) { |
|
430 | + esc_html_e('n/a', 'give'); |
|
431 | 431 | } else { |
432 | 432 | $prices_atts = ''; |
433 | - if( $variable_prices = give_get_variable_prices( $form_id ) ) { |
|
434 | - foreach ( $variable_prices as $variable_price ) { |
|
435 | - $prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount( $variable_price['_give_amount'] ); |
|
433 | + if ($variable_prices = give_get_variable_prices($form_id)) { |
|
434 | + foreach ($variable_prices as $variable_price) { |
|
435 | + $prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount']); |
|
436 | 436 | } |
437 | 437 | } |
438 | 438 | |
@@ -443,12 +443,12 @@ discard block |
||
443 | 443 | 'chosen' => true, |
444 | 444 | 'show_option_all' => '', |
445 | 445 | 'show_option_none' => '', |
446 | - 'select_atts' => 'data-prices=' . esc_attr( json_encode( $prices_atts ) ), |
|
446 | + 'select_atts' => 'data-prices='.esc_attr(json_encode($prices_atts)), |
|
447 | 447 | ); |
448 | 448 | |
449 | - if( $payment_id ) { |
|
449 | + if ($payment_id) { |
|
450 | 450 | // Payment object. |
451 | - $payment = new Give_Payment( $payment_id ); |
|
451 | + $payment = new Give_Payment($payment_id); |
|
452 | 452 | |
453 | 453 | // Payment meta. |
454 | 454 | $payment_meta = $payment->get_meta(); |
@@ -456,10 +456,10 @@ discard block |
||
456 | 456 | } |
457 | 457 | |
458 | 458 | // Render variable prices select tag html. |
459 | - give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
|
459 | + give_get_form_variable_price_dropdown($variable_price_dropdown_option, true); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | give_die(); |
463 | 463 | } |
464 | 464 | |
465 | -add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' ); |
|
465 | +add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html'); |
@@ -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,7 +23,7 @@ discard block |
||
23 | 23 | * @return mixed |
24 | 24 | */ |
25 | 25 | function give_get_price_decimals() { |
26 | - return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) ); |
|
26 | + return apply_filters('give_sanitize_amount_decimals', give_get_option('number_decimals', 0)); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @return mixed |
35 | 35 | */ |
36 | 36 | function give_get_price_thousand_separator() { |
37 | - return give_get_option( 'thousands_separator', ',' ); |
|
37 | + return give_get_option('thousands_separator', ','); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @return mixed |
46 | 46 | */ |
47 | 47 | function give_get_price_decimal_separator() { |
48 | - return give_get_option( 'decimal_separator', '.' ); |
|
48 | + return give_get_option('decimal_separator', '.'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -61,67 +61,67 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return string $amount Newly sanitized amount |
63 | 63 | */ |
64 | -function give_sanitize_amount( $number, $dp = false, $trim_zeros = false ) { |
|
64 | +function give_sanitize_amount($number, $dp = false, $trim_zeros = false) { |
|
65 | 65 | |
66 | 66 | // Bailout. |
67 | - if ( empty( $number ) ) { |
|
67 | + if (empty($number)) { |
|
68 | 68 | return $number; |
69 | 69 | } |
70 | 70 | |
71 | 71 | // Remove slash from amount. |
72 | 72 | // If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number. |
73 | 73 | // To prevent notices and warning remove slash from amount/number. |
74 | - $number = wp_unslash( $number ); |
|
74 | + $number = wp_unslash($number); |
|
75 | 75 | |
76 | 76 | $thousand_separator = give_get_price_thousand_separator(); |
77 | 77 | |
78 | 78 | $locale = localeconv(); |
79 | - $decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] ); |
|
79 | + $decimals = array(give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point']); |
|
80 | 80 | |
81 | 81 | // Remove locale from string |
82 | - if ( ! is_float( $number ) ) { |
|
83 | - $number = str_replace( $decimals, '.', $number ); |
|
82 | + if ( ! is_float($number)) { |
|
83 | + $number = str_replace($decimals, '.', $number); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | // Remove thousand amount formatting if amount has. |
87 | 87 | // This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db. |
88 | 88 | // Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code. |
89 | - if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) { |
|
90 | - $number = str_replace( $thousand_separator, '', $number ); |
|
91 | - } elseif ( in_array( $thousand_separator, $decimals ) ) { |
|
92 | - $number = preg_replace( '/\.(?=.*\.)/', '', $number ); |
|
89 | + if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) { |
|
90 | + $number = str_replace($thousand_separator, '', $number); |
|
91 | + } elseif (in_array($thousand_separator, $decimals)) { |
|
92 | + $number = preg_replace('/\.(?=.*\.)/', '', $number); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | // Remove non numeric entity before decimal separator. |
96 | - $number = preg_replace( '/[^0-9\.]/', '', $number ); |
|
96 | + $number = preg_replace('/[^0-9\.]/', '', $number); |
|
97 | 97 | $default_dp = give_get_price_decimals(); |
98 | 98 | |
99 | 99 | // Reset negative amount to zero. |
100 | - if ( 0 > $number ) { |
|
101 | - $number = number_format( 0, $default_dp, '.' ); |
|
100 | + if (0 > $number) { |
|
101 | + $number = number_format(0, $default_dp, '.'); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | // If number does not have decimal then add number of decimals to it. |
105 | 105 | if ( |
106 | - false === strpos( $number, '.' ) |
|
107 | - || ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) ) |
|
106 | + false === strpos($number, '.') |
|
107 | + || ($default_dp > strlen(substr($number, strpos($number, '.') + 1))) |
|
108 | 108 | ) { |
109 | - $number = number_format( $number, $default_dp, '.', '' ); |
|
109 | + $number = number_format($number, $default_dp, '.', ''); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | // Format number by custom number of decimals. |
113 | - if ( false !== $dp ) { |
|
114 | - $dp = intval( is_bool( $dp ) ? $default_dp : $dp ); |
|
115 | - $dp = apply_filters( 'give_sanitize_amount_decimals', $dp, $number ); |
|
116 | - $number = number_format( floatval( $number ), $dp, '.', '' ); |
|
113 | + if (false !== $dp) { |
|
114 | + $dp = intval(is_bool($dp) ? $default_dp : $dp); |
|
115 | + $dp = apply_filters('give_sanitize_amount_decimals', $dp, $number); |
|
116 | + $number = number_format(floatval($number), $dp, '.', ''); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | // Trim zeros. |
120 | - if ( $trim_zeros && strstr( $number, '.' ) ) { |
|
121 | - $number = rtrim( rtrim( $number, '0' ), '.' ); |
|
120 | + if ($trim_zeros && strstr($number, '.')) { |
|
121 | + $number = rtrim(rtrim($number, '0'), '.'); |
|
122 | 122 | } |
123 | 123 | |
124 | - return apply_filters( 'give_sanitize_amount', $number ); |
|
124 | + return apply_filters('give_sanitize_amount', $number); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -134,22 +134,22 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return string $amount Newly formatted amount or Price Not Available |
136 | 136 | */ |
137 | -function give_format_amount( $amount, $decimals = true ) { |
|
138 | - $thousands_sep = give_get_option( 'thousands_separator', ',' ); |
|
139 | - $decimal_sep = give_get_option( 'decimal_separator', '.' ); |
|
137 | +function give_format_amount($amount, $decimals = true) { |
|
138 | + $thousands_sep = give_get_option('thousands_separator', ','); |
|
139 | + $decimal_sep = give_get_option('decimal_separator', '.'); |
|
140 | 140 | |
141 | - if ( empty( $amount ) ) { |
|
141 | + if (empty($amount)) { |
|
142 | 142 | $amount = 0; |
143 | 143 | } else { |
144 | 144 | // Sanitize amount before formatting. |
145 | - $amount = give_sanitize_amount( $amount ); |
|
145 | + $amount = give_sanitize_amount($amount); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | $decimals = $decimals ? give_get_price_decimals() : 0; |
149 | 149 | |
150 | - $formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
150 | + $formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
151 | 151 | |
152 | - return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
152 | + return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | |
@@ -166,33 +166,33 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return float|string formatted amount number with large number names. |
168 | 168 | */ |
169 | -function give_human_format_large_amount( $amount ) { |
|
169 | +function give_human_format_large_amount($amount) { |
|
170 | 170 | |
171 | 171 | // Get thousand separator. |
172 | 172 | $thousands_sep = give_get_price_thousand_separator(); |
173 | 173 | |
174 | 174 | // Sanitize amount. |
175 | - $sanitize_amount = give_sanitize_amount( $amount ); |
|
175 | + $sanitize_amount = give_sanitize_amount($amount); |
|
176 | 176 | |
177 | 177 | // Explode amount to calculate name of large numbers. |
178 | - $amount_array = explode( $thousands_sep, $amount ); |
|
178 | + $amount_array = explode($thousands_sep, $amount); |
|
179 | 179 | |
180 | 180 | // Calculate amount parts count. |
181 | - $amount_count_parts = count( $amount_array ); |
|
181 | + $amount_count_parts = count($amount_array); |
|
182 | 182 | |
183 | 183 | // Human format amount (default). |
184 | 184 | $human_format_amount = $amount; |
185 | 185 | |
186 | 186 | // Calculate large number formatted amount. |
187 | - if ( 4 < $amount_count_parts ) { |
|
188 | - $human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) ); |
|
189 | - } elseif ( 3 < $amount_count_parts ) { |
|
190 | - $human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) ); |
|
191 | - } elseif ( 2 < $amount_count_parts ) { |
|
192 | - $human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) ); |
|
187 | + if (4 < $amount_count_parts) { |
|
188 | + $human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2)); |
|
189 | + } elseif (3 < $amount_count_parts) { |
|
190 | + $human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
191 | + } elseif (2 < $amount_count_parts) { |
|
192 | + $human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2)); |
|
193 | 193 | } |
194 | 194 | |
195 | - return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount ); |
|
195 | + return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @return string $amount Newly formatted amount or Price Not Available |
207 | 207 | */ |
208 | -function give_format_decimal( $amount, $dp = false ) { |
|
208 | +function give_format_decimal($amount, $dp = false) { |
|
209 | 209 | $decimal_separator = give_get_price_decimal_separator(); |
210 | - $formatted_amount = give_sanitize_amount( $amount, $dp ); |
|
210 | + $formatted_amount = give_sanitize_amount($amount, $dp); |
|
211 | 211 | |
212 | - if ( false !== strpos( $formatted_amount, '.' ) ) { |
|
213 | - $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
212 | + if (false !== strpos($formatted_amount, '.')) { |
|
213 | + $formatted_amount = str_replace('.', $decimal_separator, $formatted_amount); |
|
214 | 214 | } |
215 | 215 | |
216 | - return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
216 | + return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -226,24 +226,24 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @return mixed|string |
228 | 228 | */ |
229 | -function give_currency_filter( $price = '', $currency = '' ) { |
|
229 | +function give_currency_filter($price = '', $currency = '') { |
|
230 | 230 | |
231 | - if ( empty( $currency ) ) { |
|
231 | + if (empty($currency)) { |
|
232 | 232 | $currency = give_get_currency(); |
233 | 233 | } |
234 | 234 | |
235 | - $position = give_get_option( 'currency_position', 'before' ); |
|
235 | + $position = give_get_option('currency_position', 'before'); |
|
236 | 236 | |
237 | 237 | $negative = $price < 0; |
238 | 238 | |
239 | - if ( $negative ) { |
|
239 | + if ($negative) { |
|
240 | 240 | // Remove proceeding "-". |
241 | - $price = substr( $price, 1 ); |
|
241 | + $price = substr($price, 1); |
|
242 | 242 | } |
243 | 243 | |
244 | - $symbol = give_currency_symbol( $currency ); |
|
244 | + $symbol = give_currency_symbol($currency); |
|
245 | 245 | |
246 | - switch ( $currency ) : |
|
246 | + switch ($currency) : |
|
247 | 247 | case 'GBP' : |
248 | 248 | case 'BRL' : |
249 | 249 | case 'EUR' : |
@@ -272,13 +272,13 @@ discard block |
||
272 | 272 | case 'MAD' : |
273 | 273 | case 'KRW' : |
274 | 274 | case 'ZAR' : |
275 | - $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol ); |
|
275 | + $formatted = ('before' === $position ? $symbol.$price : $price.$symbol); |
|
276 | 276 | break; |
277 | 277 | case 'NOK' : |
278 | - $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol ); |
|
278 | + $formatted = ('before' === $position ? $symbol.' '.$price : $price.' '.$symbol); |
|
279 | 279 | break; |
280 | 280 | default : |
281 | - $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency ); |
|
281 | + $formatted = ('before' === $position ? $currency.' '.$price : $price.' '.$currency); |
|
282 | 282 | break; |
283 | 283 | endswitch; |
284 | 284 | |
@@ -293,11 +293,11 @@ discard block |
||
293 | 293 | * and if currency is USD and currency position is after then |
294 | 294 | * filter name will be give_usd_currency_filter_after |
295 | 295 | */ |
296 | - $formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price ); |
|
296 | + $formatted = apply_filters('give_'.strtolower($currency)."_currency_filter_{$position}", $formatted, $currency, $price); |
|
297 | 297 | |
298 | - if ( $negative ) { |
|
298 | + if ($negative) { |
|
299 | 299 | // Prepend the minus sign before the currency sign. |
300 | - $formatted = '-' . $formatted; |
|
300 | + $formatted = '-'.$formatted; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | return $formatted; |
@@ -313,21 +313,21 @@ discard block |
||
313 | 313 | */ |
314 | 314 | function give_currency_decimal_filter() { |
315 | 315 | |
316 | - remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
316 | + remove_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
317 | 317 | |
318 | 318 | // Set default number of decimals. |
319 | 319 | $decimals = give_get_price_decimals(); |
320 | 320 | |
321 | - add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
321 | + add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
322 | 322 | |
323 | 323 | // Get number of decimals with backward compatibility ( version < 1.6 ) |
324 | - if ( 1 <= func_num_args() ) { |
|
325 | - $decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) ); |
|
324 | + if (1 <= func_num_args()) { |
|
325 | + $decimals = (false === func_get_arg(0) ? $decimals : absint(func_get_arg(0))); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | $currency = give_get_currency(); |
329 | 329 | |
330 | - switch ( $currency ) { |
|
330 | + switch ($currency) { |
|
331 | 331 | case 'RIAL' : |
332 | 332 | case 'JPY' : |
333 | 333 | case 'TWD' : |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | break; |
338 | 338 | } |
339 | 339 | |
340 | - return apply_filters( 'give_currency_decimal_count', $decimals, $currency ); |
|
340 | + return apply_filters('give_currency_decimal_count', $decimals, $currency); |
|
341 | 341 | } |
342 | 342 | |
343 | -add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
344 | -add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' ); |
|
343 | +add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
344 | +add_filter('give_format_amount_decimals', 'give_currency_decimal_filter'); |
|
345 | 345 | |
346 | 346 | |
347 | 347 | /** |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | * |
354 | 354 | * @return string Date format string |
355 | 355 | */ |
356 | -function give_date_format( $date_context = '' ) { |
|
356 | +function give_date_format($date_context = '') { |
|
357 | 357 | /** |
358 | 358 | * Filter the date context |
359 | 359 | * |
@@ -374,19 +374,19 @@ discard block |
||
374 | 374 | * |
375 | 375 | * } |
376 | 376 | */ |
377 | - $date_format_contexts = apply_filters( 'give_date_format_contexts', array() ); |
|
377 | + $date_format_contexts = apply_filters('give_date_format_contexts', array()); |
|
378 | 378 | |
379 | 379 | // Set date format to default date format. |
380 | - $date_format = get_option( 'date_format' ); |
|
380 | + $date_format = get_option('date_format'); |
|
381 | 381 | |
382 | 382 | // Update date format if we have non empty date format context array and non empty date format string for that context. |
383 | - if ( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) { |
|
384 | - $date_format = ! empty( $date_format_contexts[ $date_context ] ) |
|
385 | - ? $date_format_contexts[ $date_context ] |
|
383 | + if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) { |
|
384 | + $date_format = ! empty($date_format_contexts[$date_context]) |
|
385 | + ? $date_format_contexts[$date_context] |
|
386 | 386 | : $date_format; |
387 | 387 | } |
388 | 388 | |
389 | - return apply_filters( 'give_date_format', $date_format ); |
|
389 | + return apply_filters('give_date_format', $date_format); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | /** |
@@ -399,13 +399,13 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @return string |
401 | 401 | */ |
402 | -function give_get_cache_key( $action, $query_args ) { |
|
402 | +function give_get_cache_key($action, $query_args) { |
|
403 | 403 | // Bailout. |
404 | - if ( ! is_array( $query_args ) || empty( $query_args ) ) { |
|
404 | + if ( ! is_array($query_args) || empty($query_args)) { |
|
405 | 405 | return ''; |
406 | 406 | } |
407 | 407 | |
408 | - return "give_cache_{$action}_" . substr( md5( serialize( $query_args ) ), 0, 15 ); |
|
408 | + return "give_cache_{$action}_".substr(md5(serialize($query_args)), 0, 15); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | /** |
@@ -418,11 +418,11 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @return string|array |
420 | 420 | */ |
421 | -function give_clean( $var ) { |
|
422 | - if ( is_array( $var ) ) { |
|
423 | - return array_map( 'give_clean', $var ); |
|
421 | +function give_clean($var) { |
|
422 | + if (is_array($var)) { |
|
423 | + return array_map('give_clean', $var); |
|
424 | 424 | } else { |
425 | - return is_scalar( $var ) ? sanitize_text_field( $var ) : $var; |
|
425 | + return is_scalar($var) ? sanitize_text_field($var) : $var; |
|
426 | 426 | } |
427 | 427 | } |
428 | 428 | |
@@ -435,10 +435,10 @@ discard block |
||
435 | 435 | * |
436 | 436 | * @return int |
437 | 437 | */ |
438 | -function give_let_to_num( $size ) { |
|
439 | - $l = substr( $size, - 1 ); |
|
440 | - $ret = substr( $size, 0, - 1 ); |
|
441 | - switch ( strtoupper( $l ) ) { |
|
438 | +function give_let_to_num($size) { |
|
439 | + $l = substr($size, - 1); |
|
440 | + $ret = substr($size, 0, - 1); |
|
441 | + switch (strtoupper($l)) { |
|
442 | 442 | case 'P': |
443 | 443 | $ret *= 1024; |
444 | 444 | case 'T': |
@@ -463,17 +463,17 @@ discard block |
||
463 | 463 | * @param int $action |
464 | 464 | * @param array $wp_die_args |
465 | 465 | */ |
466 | -function give_validate_nonce( $nonce, $action = - 1, $wp_die_args = array() ) { |
|
466 | +function give_validate_nonce($nonce, $action = - 1, $wp_die_args = array()) { |
|
467 | 467 | |
468 | 468 | $default_wp_die_args = array( |
469 | - 'message' => esc_html__( 'Nonce verification has failed.', 'give' ), |
|
470 | - 'title' => esc_html__( 'Error', 'give' ), |
|
471 | - 'args' => array( 'response' => 403 ), |
|
469 | + 'message' => esc_html__('Nonce verification has failed.', 'give'), |
|
470 | + 'title' => esc_html__('Error', 'give'), |
|
471 | + 'args' => array('response' => 403), |
|
472 | 472 | ); |
473 | 473 | |
474 | - $wp_die_args = wp_parse_args( $wp_die_args, $default_wp_die_args ); |
|
474 | + $wp_die_args = wp_parse_args($wp_die_args, $default_wp_die_args); |
|
475 | 475 | |
476 | - if ( ! wp_verify_nonce( $nonce, $action ) ) { |
|
476 | + if ( ! wp_verify_nonce($nonce, $action)) { |
|
477 | 477 | wp_die( |
478 | 478 | $wp_die_args['message'], |
479 | 479 | $wp_die_args['title'], |
@@ -495,23 +495,23 @@ discard block |
||
495 | 495 | * |
496 | 496 | * @return mixed |
497 | 497 | */ |
498 | -function give_check_variable( $variable, $conditional = '', $default = false ) { |
|
498 | +function give_check_variable($variable, $conditional = '', $default = false) { |
|
499 | 499 | |
500 | - switch ( $conditional ) { |
|
500 | + switch ($conditional) { |
|
501 | 501 | case 'isset_empty': |
502 | - $variable = ( isset( $variable ) && ! empty( $variable ) ) ? $variable : $default; |
|
502 | + $variable = (isset($variable) && ! empty($variable)) ? $variable : $default; |
|
503 | 503 | break; |
504 | 504 | |
505 | 505 | case 'empty': |
506 | - $variable = ! empty( $variable ) ? $variable : $default; |
|
506 | + $variable = ! empty($variable) ? $variable : $default; |
|
507 | 507 | break; |
508 | 508 | |
509 | 509 | case 'null': |
510 | - $variable = ! is_null( $variable ) ? $variable : $default; |
|
510 | + $variable = ! is_null($variable) ? $variable : $default; |
|
511 | 511 | break; |
512 | 512 | |
513 | 513 | default: |
514 | - $variable = isset( $variable ) ? $variable : $default; |
|
514 | + $variable = isset($variable) ? $variable : $default; |
|
515 | 515 | |
516 | 516 | } |
517 | 517 |